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 8 #include <linux/device.h> 9 #include <linux/uuid.h> 10 #include <linux/mod_devicetable.h> 11 12 struct mei_cl_device; 13 struct mei_device; 14 struct scatterlist; 15 16 typedef void (*mei_cldev_cb_t)(struct mei_cl_device *cldev); 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 * 25 * @bus_list: device on the bus list 26 * @bus: parent mei device 27 * @dev: linux driver model device pointer 28 * @me_cl: me client 29 * @cl: mei client 30 * @name: device name 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. 37 * 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 41 */ 42 struct mei_cl_device { 43 struct list_head bus_list; 44 struct mei_device *bus; 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 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; 55 56 unsigned int do_match:1; 57 unsigned int is_added:1; 58 59 void *priv_data; 60 }; 61 62 #define to_mei_cl_device(d) container_of(d, struct mei_cl_device, dev) 63 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 70 int (*probe)(struct mei_cl_device *cldev, 71 const struct mei_cl_device_id *id); 72 void (*remove)(struct mei_cl_device *cldev); 73 }; 74 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) 79 80 void mei_cldev_driver_unregister(struct mei_cl_driver *cldrv); 81 82 /** 83 * module_mei_cl_driver - Helper macro for registering mei cl driver 84 * 85 * @__mei_cldrv: mei_cl_driver structure 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 95 ssize_t mei_cldev_send(struct mei_cl_device *cldev, const u8 *buf, 96 size_t length); 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, 101 size_t length); 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, 109 u8 *vtag); 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); 114 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); 118 119 const uuid_le *mei_cldev_uuid(const struct mei_cl_device *cldev); 120 u8 mei_cldev_ver(const struct mei_cl_device *cldev); 121 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); 124 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, 131 size_t total_in_len, 132 struct scatterlist *sg_out); 133 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); 136 137 #endif /* _LINUX_MEI_CL_BUS_H */ 138
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.