Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
1e55b609 TW |
2 | /* |
3 | * Copyright (c) 2013-2016, Intel Corporation. All rights reserved. | |
4 | */ | |
e5354107 SO |
5 | #ifndef _LINUX_MEI_CL_BUS_H |
6 | #define _LINUX_MEI_CL_BUS_H | |
7 | ||
8 | #include <linux/device.h> | |
9 | #include <linux/uuid.h> | |
1f180359 | 10 | #include <linux/mod_devicetable.h> |
e5354107 SO |
11 | |
12 | struct mei_cl_device; | |
512f64d9 | 13 | struct mei_device; |
2266e58a | 14 | struct scatterlist; |
e5354107 | 15 | |
7c7a6077 | 16 | typedef void (*mei_cldev_cb_t)(struct mei_cl_device *cldev); |
dbac993f TW |
17 | |
18 | /** | |
19 | * struct mei_cl_device - MEI device handle | |
20 | * An mei_cl_device pointer is returned from mei_add_device() | |
21 | * and links MEI bus clients to their actual ME host client pointer. | |
22 | * Drivers for MEI devices will get an mei_cl_device pointer | |
23 | * when being probed and shall use it for doing ME bus I/O. | |
24 | * | |
0ff0a8d8 | 25 | * @bus_list: device on the bus list |
512f64d9 | 26 | * @bus: parent mei device |
dbac993f TW |
27 | * @dev: linux driver model device pointer |
28 | * @me_cl: me client | |
29 | * @cl: mei client | |
30 | * @name: device name | |
7c7a6077 AU |
31 | * @rx_work: async work to execute Rx event callback |
32 | * @rx_cb: Drivers register this callback to get asynchronous ME | |
33 | * Rx buffer pending notifications. | |
34 | * @notif_work: async work to execute FW notif event callback | |
35 | * @notif_cb: Drivers register this callback to get asynchronous ME | |
36 | * FW notification pending notifications. | |
71ce7891 TW |
37 | * |
38 | * @do_match: wheather device can be matched with a driver | |
0ff0a8d8 | 39 | * @is_added: device is already scanned |
dbac993f TW |
40 | * @priv_data: client private data |
41 | */ | |
42 | struct mei_cl_device { | |
0ff0a8d8 | 43 | struct list_head bus_list; |
512f64d9 | 44 | struct mei_device *bus; |
dbac993f TW |
45 | struct device dev; |
46 | ||
47 | struct mei_me_client *me_cl; | |
48 | struct mei_cl *cl; | |
49 | char name[MEI_CL_NAME_SIZE]; | |
50 | ||
7c7a6077 AU |
51 | struct work_struct rx_work; |
52 | mei_cldev_cb_t rx_cb; | |
53 | struct work_struct notif_work; | |
54 | mei_cldev_cb_t notif_cb; | |
71ce7891 TW |
55 | |
56 | unsigned int do_match:1; | |
0ff0a8d8 | 57 | unsigned int is_added:1; |
dbac993f TW |
58 | |
59 | void *priv_data; | |
60 | }; | |
61 | ||
32ea33a0 TW |
62 | #define to_mei_cl_device(d) container_of(d, struct mei_cl_device, dev) |
63 | ||
e5354107 SO |
64 | struct mei_cl_driver { |
65 | struct device_driver driver; | |
66 | const char *name; | |
67 | ||
68 | const struct mei_cl_device_id *id_table; | |
69 | ||
89391382 | 70 | int (*probe)(struct mei_cl_device *cldev, |
e5354107 | 71 | const struct mei_cl_device_id *id); |
bf5c9cc8 | 72 | void (*remove)(struct mei_cl_device *cldev); |
e5354107 SO |
73 | }; |
74 | ||
d49dc5e7 TW |
75 | int __mei_cldev_driver_register(struct mei_cl_driver *cldrv, |
76 | struct module *owner); | |
77 | #define mei_cldev_driver_register(cldrv) \ | |
78 | __mei_cldev_driver_register(cldrv, THIS_MODULE) | |
333e4ee0 | 79 | |
d49dc5e7 | 80 | void mei_cldev_driver_unregister(struct mei_cl_driver *cldrv); |
333e4ee0 | 81 | |
5be149bd TW |
82 | /** |
83 | * module_mei_cl_driver - Helper macro for registering mei cl driver | |
84 | * | |
076802d0 | 85 | * @__mei_cldrv: mei_cl_driver structure |
5be149bd TW |
86 | * |
87 | * Helper macro for mei cl drivers which do not do anything special in module | |
88 | * init/exit, for eliminating a boilerplate code. | |
89 | */ | |
90 | #define module_mei_cl_driver(__mei_cldrv) \ | |
91 | module_driver(__mei_cldrv, \ | |
92 | mei_cldev_driver_register,\ | |
93 | mei_cldev_driver_unregister) | |
94 | ||
0912ef48 KK |
95 | ssize_t mei_cldev_send(struct mei_cl_device *cldev, const u8 *buf, |
96 | size_t length); | |
076802d0 AU |
97 | ssize_t mei_cldev_recv(struct mei_cl_device *cldev, u8 *buf, size_t length); |
98 | ssize_t mei_cldev_recv_nonblock(struct mei_cl_device *cldev, u8 *buf, | |
99 | size_t length); | |
0912ef48 KK |
100 | ssize_t mei_cldev_send_vtag(struct mei_cl_device *cldev, const u8 *buf, |
101 | size_t length, u8 vtag); | |
85261c1f AU |
102 | ssize_t mei_cldev_recv_vtag(struct mei_cl_device *cldev, u8 *buf, size_t length, |
103 | u8 *vtag); | |
104 | ssize_t mei_cldev_recv_nonblock_vtag(struct mei_cl_device *cldev, u8 *buf, | |
105 | size_t length, u8 *vtag); | |
3e833295 | 106 | |
7c7a6077 AU |
107 | int mei_cldev_register_rx_cb(struct mei_cl_device *cldev, mei_cldev_cb_t rx_cb); |
108 | int mei_cldev_register_notif_cb(struct mei_cl_device *cldev, | |
109 | mei_cldev_cb_t notif_cb); | |
3e833295 | 110 | |
baeacd03 TW |
111 | const uuid_le *mei_cldev_uuid(const struct mei_cl_device *cldev); |
112 | u8 mei_cldev_ver(const struct mei_cl_device *cldev); | |
113 | ||
d49dc5e7 TW |
114 | void *mei_cldev_get_drvdata(const struct mei_cl_device *cldev); |
115 | void mei_cldev_set_drvdata(struct mei_cl_device *cldev, void *data); | |
aa6aef21 | 116 | |
d49dc5e7 TW |
117 | int mei_cldev_enable(struct mei_cl_device *cldev); |
118 | int mei_cldev_disable(struct mei_cl_device *cldev); | |
0912ef48 | 119 | bool mei_cldev_enabled(const struct mei_cl_device *cldev); |
2266e58a VL |
120 | ssize_t mei_cldev_send_gsc_command(struct mei_cl_device *cldev, |
121 | u8 client_id, u32 fence_id, | |
122 | struct scatterlist *sg_in, | |
123 | size_t total_in_len, | |
124 | struct scatterlist *sg_out); | |
e46980a1 | 125 | |
2cca3465 AU |
126 | void *mei_cldev_dma_map(struct mei_cl_device *cldev, u8 buffer_id, size_t size); |
127 | int mei_cldev_dma_unmap(struct mei_cl_device *cldev); | |
128 | ||
e5354107 | 129 | #endif /* _LINUX_MEI_CL_BUS_H */ |