]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
e5354107 SO |
2 | #ifndef _LINUX_MEI_CL_BUS_H |
3 | #define _LINUX_MEI_CL_BUS_H | |
4 | ||
5 | #include <linux/device.h> | |
6 | #include <linux/uuid.h> | |
1f180359 | 7 | #include <linux/mod_devicetable.h> |
e5354107 SO |
8 | |
9 | struct mei_cl_device; | |
512f64d9 | 10 | struct mei_device; |
e5354107 | 11 | |
7c7a6077 | 12 | typedef void (*mei_cldev_cb_t)(struct mei_cl_device *cldev); |
dbac993f TW |
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 | * | |
0ff0a8d8 | 21 | * @bus_list: device on the bus list |
512f64d9 | 22 | * @bus: parent mei device |
dbac993f TW |
23 | * @dev: linux driver model device pointer |
24 | * @me_cl: me client | |
25 | * @cl: mei client | |
26 | * @name: device name | |
7c7a6077 AU |
27 | * @rx_work: async work to execute Rx event callback |
28 | * @rx_cb: Drivers register this callback to get asynchronous ME | |
29 | * Rx buffer pending notifications. | |
30 | * @notif_work: async work to execute FW notif event callback | |
31 | * @notif_cb: Drivers register this callback to get asynchronous ME | |
32 | * FW notification pending notifications. | |
71ce7891 TW |
33 | * |
34 | * @do_match: wheather device can be matched with a driver | |
0ff0a8d8 | 35 | * @is_added: device is already scanned |
dbac993f TW |
36 | * @priv_data: client private data |
37 | */ | |
38 | struct mei_cl_device { | |
0ff0a8d8 | 39 | struct list_head bus_list; |
512f64d9 | 40 | struct mei_device *bus; |
dbac993f TW |
41 | struct device dev; |
42 | ||
43 | struct mei_me_client *me_cl; | |
44 | struct mei_cl *cl; | |
45 | char name[MEI_CL_NAME_SIZE]; | |
46 | ||
7c7a6077 AU |
47 | struct work_struct rx_work; |
48 | mei_cldev_cb_t rx_cb; | |
49 | struct work_struct notif_work; | |
50 | mei_cldev_cb_t notif_cb; | |
71ce7891 TW |
51 | |
52 | unsigned int do_match:1; | |
0ff0a8d8 | 53 | unsigned int is_added:1; |
dbac993f TW |
54 | |
55 | void *priv_data; | |
56 | }; | |
57 | ||
e5354107 SO |
58 | struct mei_cl_driver { |
59 | struct device_driver driver; | |
60 | const char *name; | |
61 | ||
62 | const struct mei_cl_device_id *id_table; | |
63 | ||
89391382 | 64 | int (*probe)(struct mei_cl_device *cldev, |
e5354107 | 65 | const struct mei_cl_device_id *id); |
89391382 | 66 | int (*remove)(struct mei_cl_device *cldev); |
e5354107 SO |
67 | }; |
68 | ||
d49dc5e7 TW |
69 | int __mei_cldev_driver_register(struct mei_cl_driver *cldrv, |
70 | struct module *owner); | |
71 | #define mei_cldev_driver_register(cldrv) \ | |
72 | __mei_cldev_driver_register(cldrv, THIS_MODULE) | |
333e4ee0 | 73 | |
d49dc5e7 | 74 | void mei_cldev_driver_unregister(struct mei_cl_driver *cldrv); |
333e4ee0 | 75 | |
5be149bd TW |
76 | /** |
77 | * module_mei_cl_driver - Helper macro for registering mei cl driver | |
78 | * | |
076802d0 | 79 | * @__mei_cldrv: mei_cl_driver structure |
5be149bd TW |
80 | * |
81 | * Helper macro for mei cl drivers which do not do anything special in module | |
82 | * init/exit, for eliminating a boilerplate code. | |
83 | */ | |
84 | #define module_mei_cl_driver(__mei_cldrv) \ | |
85 | module_driver(__mei_cldrv, \ | |
86 | mei_cldev_driver_register,\ | |
87 | mei_cldev_driver_unregister) | |
88 | ||
d49dc5e7 | 89 | ssize_t mei_cldev_send(struct mei_cl_device *cldev, u8 *buf, size_t length); |
076802d0 AU |
90 | ssize_t mei_cldev_recv(struct mei_cl_device *cldev, u8 *buf, size_t length); |
91 | ssize_t mei_cldev_recv_nonblock(struct mei_cl_device *cldev, u8 *buf, | |
92 | size_t length); | |
3e833295 | 93 | |
7c7a6077 AU |
94 | int mei_cldev_register_rx_cb(struct mei_cl_device *cldev, mei_cldev_cb_t rx_cb); |
95 | int mei_cldev_register_notif_cb(struct mei_cl_device *cldev, | |
96 | mei_cldev_cb_t notif_cb); | |
3e833295 | 97 | |
baeacd03 TW |
98 | const uuid_le *mei_cldev_uuid(const struct mei_cl_device *cldev); |
99 | u8 mei_cldev_ver(const struct mei_cl_device *cldev); | |
100 | ||
d49dc5e7 TW |
101 | void *mei_cldev_get_drvdata(const struct mei_cl_device *cldev); |
102 | void mei_cldev_set_drvdata(struct mei_cl_device *cldev, void *data); | |
aa6aef21 | 103 | |
d49dc5e7 TW |
104 | int mei_cldev_enable(struct mei_cl_device *cldev); |
105 | int mei_cldev_disable(struct mei_cl_device *cldev); | |
01a14ede | 106 | bool mei_cldev_enabled(struct mei_cl_device *cldev); |
e46980a1 | 107 | |
e5354107 | 108 | #endif /* _LINUX_MEI_CL_BUS_H */ |