mei_cl_bus.h 3.4 KB

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