1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (c) 2013-2016, Intel Corporation. All rights reserved.
5 #ifndef _LINUX_MEI_CL_BUS_H
6 #define _LINUX_MEI_CL_BUS_H
8 #include <linux/device.h>
9 #include <linux/uuid.h>
10 #include <linux/mod_devicetable.h>
16 typedef void (*mei_cldev_cb_t
)(struct mei_cl_device
*cldev
);
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.
25 * @bus_list: device on the bus list
26 * @bus: parent mei device
27 * @dev: linux driver model device pointer
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 notify event callback
35 * @notif_cb: Drivers register this callback to get asynchronous ME
36 * FW notification pending notifications.
38 * @do_match: whether the device can be matched with a driver
39 * @is_added: device is already scanned
40 * @priv_data: client private data
42 struct mei_cl_device
{
43 struct list_head bus_list
;
44 struct mei_device
*bus
;
47 struct mei_me_client
*me_cl
;
49 char name
[MEI_CL_NAME_SIZE
];
51 struct work_struct rx_work
;
53 struct work_struct notif_work
;
54 mei_cldev_cb_t notif_cb
;
56 unsigned int do_match
:1;
57 unsigned int is_added
:1;
62 #define to_mei_cl_device(d) container_of(d, struct mei_cl_device, dev)
64 struct mei_cl_driver
{
65 struct device_driver driver
;
68 const struct mei_cl_device_id
*id_table
;
70 int (*probe
)(struct mei_cl_device
*cldev
,
71 const struct mei_cl_device_id
*id
);
72 void (*remove
)(struct mei_cl_device
*cldev
);
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)
80 void mei_cldev_driver_unregister(struct mei_cl_driver
*cldrv
);
83 * module_mei_cl_driver - Helper macro for registering mei cl driver
85 * @__mei_cldrv: mei_cl_driver structure
87 * Helper macro for mei cl drivers which do not do anything special in module
88 * init/exit, for eliminating a boilerplate code.
90 #define module_mei_cl_driver(__mei_cldrv) \
91 module_driver(__mei_cldrv, \
92 mei_cldev_driver_register,\
93 mei_cldev_driver_unregister)
95 ssize_t
mei_cldev_send(struct mei_cl_device
*cldev
, const u8
*buf
,
97 ssize_t
mei_cldev_send_timeout(struct mei_cl_device
*cldev
, const u8
*buf
,
98 size_t length
, unsigned long timeout
);
99 ssize_t
mei_cldev_recv(struct mei_cl_device
*cldev
, u8
*buf
, size_t length
);
100 ssize_t
mei_cldev_recv_nonblock(struct mei_cl_device
*cldev
, u8
*buf
,
102 ssize_t
mei_cldev_recv_timeout(struct mei_cl_device
*cldev
, u8
*buf
, size_t length
,
103 unsigned long timeout
);
104 ssize_t
mei_cldev_send_vtag(struct mei_cl_device
*cldev
, const u8
*buf
,
105 size_t length
, u8 vtag
);
106 ssize_t
mei_cldev_send_vtag_timeout(struct mei_cl_device
*cldev
, const u8
*buf
,
107 size_t length
, u8 vtag
, unsigned long timeout
);
108 ssize_t
mei_cldev_recv_vtag(struct mei_cl_device
*cldev
, u8
*buf
, size_t length
,
110 ssize_t
mei_cldev_recv_nonblock_vtag(struct mei_cl_device
*cldev
, u8
*buf
,
111 size_t length
, u8
*vtag
);
112 ssize_t
mei_cldev_recv_vtag_timeout(struct mei_cl_device
*cldev
, u8
*buf
, size_t length
,
113 u8
*vtag
, unsigned long timeout
);
115 int mei_cldev_register_rx_cb(struct mei_cl_device
*cldev
, mei_cldev_cb_t rx_cb
);
116 int mei_cldev_register_notif_cb(struct mei_cl_device
*cldev
,
117 mei_cldev_cb_t notif_cb
);
119 const uuid_le
*mei_cldev_uuid(const struct mei_cl_device
*cldev
);
120 u8
mei_cldev_ver(const struct mei_cl_device
*cldev
);
122 void *mei_cldev_get_drvdata(const struct mei_cl_device
*cldev
);
123 void mei_cldev_set_drvdata(struct mei_cl_device
*cldev
, void *data
);
125 int mei_cldev_enable(struct mei_cl_device
*cldev
);
126 int mei_cldev_disable(struct mei_cl_device
*cldev
);
127 bool mei_cldev_enabled(const struct mei_cl_device
*cldev
);
128 ssize_t
mei_cldev_send_gsc_command(struct mei_cl_device
*cldev
,
129 u8 client_id
, u32 fence_id
,
130 struct scatterlist
*sg_in
,
132 struct scatterlist
*sg_out
);
134 void *mei_cldev_dma_map(struct mei_cl_device
*cldev
, u8 buffer_id
, size_t size
);
135 int mei_cldev_dma_unmap(struct mei_cl_device
*cldev
);
137 #endif /* _LINUX_MEI_CL_BUS_H */