diag_usb.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /* Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #ifndef DIAGUSB_H
  13. #define DIAGUSB_H
  14. #ifdef CONFIG_DIAG_OVER_USB
  15. #include <linux/usb/usbdiag.h>
  16. #endif
  17. #include "diagchar.h"
  18. #include "diag_mux.h"
  19. #define DIAG_USB_LOCAL 0
  20. #define DIAG_USB_LOCAL_LAST 1
  21. #define DIAG_USB_BRIDGE_BASE DIAG_USB_LOCAL_LAST
  22. #define DIAG_USB_MDM (DIAG_USB_BRIDGE_BASE)
  23. #define DIAG_USB_MDM2 (DIAG_USB_BRIDGE_BASE + 1)
  24. #define DIAG_USB_QSC (DIAG_USB_BRIDGE_BASE + 2)
  25. #define DIAG_USB_BRIDGE_LAST (DIAG_USB_BRIDGE_BASE + 3)
  26. #ifndef CONFIG_DIAGFWD_BRIDGE_CODE
  27. #define NUM_DIAG_USB_DEV DIAG_USB_LOCAL_LAST
  28. #else
  29. #define NUM_DIAG_USB_DEV DIAG_USB_BRIDGE_LAST
  30. #endif
  31. #define DIAG_USB_NAME_SZ 24
  32. #define DIAG_USB_GET_NAME(x) (diag_usb[x].name)
  33. #define DIAG_USB_MODE 0
  34. struct diag_usb_buf_tbl_t {
  35. struct list_head track;
  36. unsigned char *buf;
  37. uint32_t len;
  38. atomic_t ref_count;
  39. int ctxt;
  40. };
  41. struct diag_usb_info {
  42. int id;
  43. int ctxt;
  44. char name[DIAG_USB_NAME_SZ];
  45. atomic_t connected;
  46. atomic_t diag_state;
  47. atomic_t read_pending;
  48. int enabled;
  49. int mempool;
  50. int max_size;
  51. struct list_head buf_tbl;
  52. unsigned long read_cnt;
  53. unsigned long write_cnt;
  54. spinlock_t lock;
  55. spinlock_t write_lock;
  56. struct usb_diag_ch *hdl;
  57. struct diag_mux_ops *ops;
  58. unsigned char *read_buf;
  59. struct diag_request *read_ptr;
  60. struct work_struct read_work;
  61. struct work_struct read_done_work;
  62. struct work_struct connect_work;
  63. struct work_struct disconnect_work;
  64. struct workqueue_struct *usb_wq;
  65. };
  66. #ifdef CONFIG_DIAG_OVER_USB
  67. extern struct diag_usb_info diag_usb[NUM_DIAG_USB_DEV];
  68. int diag_usb_register(int id, int ctxt, struct diag_mux_ops *ops);
  69. int diag_usb_queue_read(int id);
  70. int diag_usb_write(int id, unsigned char *buf, int len, int ctxt);
  71. void diag_usb_connect_all(void);
  72. void diag_usb_disconnect_all(void);
  73. void diag_usb_exit(int id);
  74. #else
  75. int diag_usb_register(int id, int ctxt, struct diag_mux_ops *ops)
  76. {
  77. return 0;
  78. }
  79. int diag_usb_queue_read(int id)
  80. {
  81. return 0;
  82. }
  83. int diag_usb_write(int id, unsigned char *buf, int len, int ctxt)
  84. {
  85. return 0;
  86. }
  87. void diag_usb_connect_all(void)
  88. {
  89. }
  90. void diag_usb_disconnect_all(void)
  91. {
  92. }
  93. void diag_usb_exit(int id)
  94. {
  95. }
  96. #endif
  97. #endif