mei_cl_bus.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #ifndef _LINUX_MEI_CL_BUS_H
  2. #define _LINUX_MEI_CL_BUS_H
  3. #include <linux/device.h>
  4. #include <linux/uuid.h>
  5. #include <linux/mod_devicetable.h>
  6. struct mei_cl_device;
  7. struct mei_device;
  8. typedef void (*mei_cldev_event_cb_t)(struct mei_cl_device *cldev,
  9. u32 events, void *context);
  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. * @event_work: async work to execute event callback
  24. * @event_cb: Drivers register this callback to get asynchronous ME
  25. * events (e.g. Rx buffer pending) notifications.
  26. * @event_context: event callback run context
  27. * @events_mask: Events bit mask requested by driver.
  28. * @events: Events bitmask sent to the driver.
  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 event_work;
  42. mei_cldev_event_cb_t event_cb;
  43. void *event_context;
  44. unsigned long events_mask;
  45. unsigned long events;
  46. unsigned int do_match:1;
  47. unsigned int is_added:1;
  48. void *priv_data;
  49. };
  50. struct mei_cl_driver {
  51. struct device_driver driver;
  52. const char *name;
  53. const struct mei_cl_device_id *id_table;
  54. int (*probe)(struct mei_cl_device *cldev,
  55. const struct mei_cl_device_id *id);
  56. int (*remove)(struct mei_cl_device *cldev);
  57. };
  58. int __mei_cldev_driver_register(struct mei_cl_driver *cldrv,
  59. struct module *owner);
  60. #define mei_cldev_driver_register(cldrv) \
  61. __mei_cldev_driver_register(cldrv, THIS_MODULE)
  62. void mei_cldev_driver_unregister(struct mei_cl_driver *cldrv);
  63. ssize_t mei_cldev_send(struct mei_cl_device *cldev, u8 *buf, size_t length);
  64. ssize_t mei_cldev_recv(struct mei_cl_device *cldev, u8 *buf, size_t length);
  65. int mei_cldev_register_event_cb(struct mei_cl_device *cldev,
  66. unsigned long event_mask,
  67. mei_cldev_event_cb_t read_cb, void *context);
  68. #define MEI_CL_EVENT_RX 0
  69. #define MEI_CL_EVENT_TX 1
  70. #define MEI_CL_EVENT_NOTIF 2
  71. const uuid_le *mei_cldev_uuid(const struct mei_cl_device *cldev);
  72. u8 mei_cldev_ver(const struct mei_cl_device *cldev);
  73. void *mei_cldev_get_drvdata(const struct mei_cl_device *cldev);
  74. void mei_cldev_set_drvdata(struct mei_cl_device *cldev, void *data);
  75. int mei_cldev_enable(struct mei_cl_device *cldev);
  76. int mei_cldev_disable(struct mei_cl_device *cldev);
  77. bool mei_cldev_enabled(struct mei_cl_device *cldev);
  78. #endif /* _LINUX_MEI_CL_BUS_H */