Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 1 | #ifndef _LINUX_MEI_CL_BUS_H |
| 2 | #define _LINUX_MEI_CL_BUS_H |
| 3 | |
| 4 | #include <linux/device.h> |
| 5 | #include <linux/uuid.h> |
Tomas Winkler | 1f18035 | 2014-09-29 16:31:46 +0300 | [diff] [blame] | 6 | #include <linux/mod_devicetable.h> |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 7 | |
| 8 | struct mei_cl_device; |
Tomas Winkler | 512f64d | 2015-07-23 15:08:41 +0300 | [diff] [blame] | 9 | struct mei_device; |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 10 | |
Tomas Winkler | dbac993 | 2015-05-07 15:54:07 +0300 | [diff] [blame] | 11 | typedef void (*mei_cl_event_cb_t)(struct mei_cl_device *device, |
| 12 | u32 events, void *context); |
| 13 | |
| 14 | /** |
| 15 | * struct mei_cl_device - MEI device handle |
| 16 | * An mei_cl_device pointer is returned from mei_add_device() |
| 17 | * and links MEI bus clients to their actual ME host client pointer. |
| 18 | * Drivers for MEI devices will get an mei_cl_device pointer |
| 19 | * when being probed and shall use it for doing ME bus I/O. |
| 20 | * |
Tomas Winkler | 0ff0a8d | 2015-07-23 15:08:42 +0300 | [diff] [blame] | 21 | * @bus_list: device on the bus list |
Tomas Winkler | 512f64d | 2015-07-23 15:08:41 +0300 | [diff] [blame] | 22 | * @bus: parent mei device |
Tomas Winkler | dbac993 | 2015-05-07 15:54:07 +0300 | [diff] [blame] | 23 | * @dev: linux driver model device pointer |
| 24 | * @me_cl: me client |
| 25 | * @cl: mei client |
| 26 | * @name: device name |
| 27 | * @event_work: async work to execute event callback |
| 28 | * @event_cb: Drivers register this callback to get asynchronous ME |
| 29 | * events (e.g. Rx buffer pending) notifications. |
| 30 | * @event_context: event callback run context |
| 31 | * @events: Events bitmask sent to the driver. |
Tomas Winkler | 71ce789 | 2015-07-23 15:08:43 +0300 | [diff] [blame^] | 32 | * |
| 33 | * @do_match: wheather device can be matched with a driver |
Tomas Winkler | 0ff0a8d | 2015-07-23 15:08:42 +0300 | [diff] [blame] | 34 | * @is_added: device is already scanned |
Tomas Winkler | dbac993 | 2015-05-07 15:54:07 +0300 | [diff] [blame] | 35 | * @priv_data: client private data |
| 36 | */ |
| 37 | struct mei_cl_device { |
Tomas Winkler | 0ff0a8d | 2015-07-23 15:08:42 +0300 | [diff] [blame] | 38 | struct list_head bus_list; |
Tomas Winkler | 512f64d | 2015-07-23 15:08:41 +0300 | [diff] [blame] | 39 | struct mei_device *bus; |
Tomas Winkler | dbac993 | 2015-05-07 15:54:07 +0300 | [diff] [blame] | 40 | struct device dev; |
| 41 | |
| 42 | struct mei_me_client *me_cl; |
| 43 | struct mei_cl *cl; |
| 44 | char name[MEI_CL_NAME_SIZE]; |
| 45 | |
| 46 | struct work_struct event_work; |
| 47 | mei_cl_event_cb_t event_cb; |
| 48 | void *event_context; |
| 49 | unsigned long events; |
Tomas Winkler | 71ce789 | 2015-07-23 15:08:43 +0300 | [diff] [blame^] | 50 | |
| 51 | unsigned int do_match:1; |
Tomas Winkler | 0ff0a8d | 2015-07-23 15:08:42 +0300 | [diff] [blame] | 52 | unsigned int is_added:1; |
Tomas Winkler | dbac993 | 2015-05-07 15:54:07 +0300 | [diff] [blame] | 53 | |
| 54 | void *priv_data; |
| 55 | }; |
| 56 | |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 57 | struct mei_cl_driver { |
| 58 | struct device_driver driver; |
| 59 | const char *name; |
| 60 | |
| 61 | const struct mei_cl_device_id *id_table; |
| 62 | |
| 63 | int (*probe)(struct mei_cl_device *dev, |
| 64 | const struct mei_cl_device_id *id); |
| 65 | int (*remove)(struct mei_cl_device *dev); |
| 66 | }; |
| 67 | |
Samuel Ortiz | 333e4ee | 2013-03-27 17:29:54 +0200 | [diff] [blame] | 68 | int __mei_cl_driver_register(struct mei_cl_driver *driver, |
| 69 | struct module *owner); |
| 70 | #define mei_cl_driver_register(driver) \ |
| 71 | __mei_cl_driver_register(driver, THIS_MODULE) |
| 72 | |
| 73 | void mei_cl_driver_unregister(struct mei_cl_driver *driver); |
| 74 | |
Tomas Winkler | 39db74c | 2014-11-27 14:07:28 +0200 | [diff] [blame] | 75 | ssize_t mei_cl_send(struct mei_cl_device *device, u8 *buf, size_t length); |
| 76 | ssize_t mei_cl_recv(struct mei_cl_device *device, u8 *buf, size_t length); |
Samuel Ortiz | 3e83329 | 2013-03-27 17:29:55 +0200 | [diff] [blame] | 77 | |
Samuel Ortiz | 3e83329 | 2013-03-27 17:29:55 +0200 | [diff] [blame] | 78 | int mei_cl_register_event_cb(struct mei_cl_device *device, |
| 79 | mei_cl_event_cb_t read_cb, void *context); |
| 80 | |
| 81 | #define MEI_CL_EVENT_RX 0 |
| 82 | #define MEI_CL_EVENT_TX 1 |
| 83 | |
Samuel Ortiz | aa6aef2 | 2013-03-27 17:29:59 +0200 | [diff] [blame] | 84 | void *mei_cl_get_drvdata(const struct mei_cl_device *device); |
| 85 | void mei_cl_set_drvdata(struct mei_cl_device *device, void *data); |
| 86 | |
Samuel Ortiz | e46980a | 2013-04-09 01:51:38 +0300 | [diff] [blame] | 87 | int mei_cl_enable_device(struct mei_cl_device *device); |
| 88 | int mei_cl_disable_device(struct mei_cl_device *device); |
| 89 | |
Samuel Ortiz | e535410 | 2013-03-27 17:29:53 +0200 | [diff] [blame] | 90 | #endif /* _LINUX_MEI_CL_BUS_H */ |