mei_cl_bus.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _LINUX_MEI_CL_BUS_H
  3. #define _LINUX_MEI_CL_BUS_H
  4. #include <linux/device.h>
  5. #include <linux/uuid.h>
  6. #include <linux/mod_devicetable.h>
  7. struct mei_cl_device;
  8. struct mei_device;
  9. typedef void (*mei_cldev_cb_t)(struct mei_cl_device *cldev);
  10. /**
  11. * struct mei_cl_device - MEI device handle
  12. * An mei_cl_device pointer is returned from mei_add_device()
  13. * and links MEI bus clients to their actual ME host client pointer.
  14. * Drivers for MEI devices will get an mei_cl_device pointer
  15. * when being probed and shall use it for doing ME bus I/O.
  16. *
  17. * @bus_list: device on the bus list
  18. * @bus: parent mei device
  19. * @dev: linux driver model device pointer
  20. * @me_cl: me client
  21. * @cl: mei client
  22. * @name: device name
  23. * @rx_work: async work to execute Rx event callback
  24. * @rx_cb: Drivers register this callback to get asynchronous ME
  25. * Rx buffer pending notifications.
  26. * @notif_work: async work to execute FW notif event callback
  27. * @notif_cb: Drivers register this callback to get asynchronous ME
  28. * FW notification pending notifications.
  29. *
  30. * @do_match: wheather device can be matched with a driver
  31. * @is_added: device is already scanned
  32. * @priv_data: client private data
  33. */
  34. struct mei_cl_device {
  35. struct list_head bus_list;
  36. struct mei_device *bus;
  37. struct device dev;
  38. struct mei_me_client *me_cl;
  39. struct mei_cl *cl;
  40. char name[MEI_CL_NAME_SIZE];
  41. struct work_struct rx_work;
  42. mei_cldev_cb_t rx_cb;
  43. struct work_struct notif_work;
  44. mei_cldev_cb_t notif_cb;
  45. unsigned int do_match:1;
  46. unsigned int is_added:1;
  47. void *priv_data;
  48. };
  49. struct mei_cl_driver {
  50. struct device_driver driver;
  51. const char *name;
  52. const struct mei_cl_device_id *id_table;
  53. int (*probe)(struct mei_cl_device *cldev,
  54. const struct mei_cl_device_id *id);
  55. int (*remove)(struct mei_cl_device *cldev);
  56. };
  57. int __mei_cldev_driver_register(struct mei_cl_driver *cldrv,
  58. struct module *owner);
  59. #define mei_cldev_driver_register(cldrv) \
  60. __mei_cldev_driver_register(cldrv, THIS_MODULE)
  61. void mei_cldev_driver_unregister(struct mei_cl_driver *cldrv);
  62. /**
  63. * module_mei_cl_driver - Helper macro for registering mei cl driver
  64. *
  65. * @__mei_cldrv: mei_cl_driver structure
  66. *
  67. * Helper macro for mei cl drivers which do not do anything special in module
  68. * init/exit, for eliminating a boilerplate code.
  69. */
  70. #define module_mei_cl_driver(__mei_cldrv) \
  71. module_driver(__mei_cldrv, \
  72. mei_cldev_driver_register,\
  73. mei_cldev_driver_unregister)
  74. ssize_t mei_cldev_send(struct mei_cl_device *cldev, u8 *buf, size_t length);
  75. ssize_t mei_cldev_recv(struct mei_cl_device *cldev, u8 *buf, size_t length);
  76. ssize_t mei_cldev_recv_nonblock(struct mei_cl_device *cldev, u8 *buf,
  77. size_t length);
  78. int mei_cldev_register_rx_cb(struct mei_cl_device *cldev, mei_cldev_cb_t rx_cb);
  79. int mei_cldev_register_notif_cb(struct mei_cl_device *cldev,
  80. mei_cldev_cb_t notif_cb);
  81. const uuid_le *mei_cldev_uuid(const struct mei_cl_device *cldev);
  82. u8 mei_cldev_ver(const struct mei_cl_device *cldev);
  83. void *mei_cldev_get_drvdata(const struct mei_cl_device *cldev);
  84. void mei_cldev_set_drvdata(struct mei_cl_device *cldev, void *data);
  85. int mei_cldev_enable(struct mei_cl_device *cldev);
  86. int mei_cldev_disable(struct mei_cl_device *cldev);
  87. bool mei_cldev_enabled(struct mei_cl_device *cldev);
  88. #endif /* _LINUX_MEI_CL_BUS_H */