Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Copyright (c) 2013-2016, Intel Corporation. All rights reserved.
0004  */
0005 #ifndef _LINUX_MEI_CL_BUS_H
0006 #define _LINUX_MEI_CL_BUS_H
0007 
0008 #include <linux/device.h>
0009 #include <linux/uuid.h>
0010 #include <linux/mod_devicetable.h>
0011 
0012 struct mei_cl_device;
0013 struct mei_device;
0014 
0015 typedef void (*mei_cldev_cb_t)(struct mei_cl_device *cldev);
0016 
0017 /**
0018  * struct mei_cl_device - MEI device handle
0019  * An mei_cl_device pointer is returned from mei_add_device()
0020  * and links MEI bus clients to their actual ME host client pointer.
0021  * Drivers for MEI devices will get an mei_cl_device pointer
0022  * when being probed and shall use it for doing ME bus I/O.
0023  *
0024  * @bus_list: device on the bus list
0025  * @bus: parent mei device
0026  * @dev: linux driver model device pointer
0027  * @me_cl: me client
0028  * @cl: mei client
0029  * @name: device name
0030  * @rx_work: async work to execute Rx event callback
0031  * @rx_cb: Drivers register this callback to get asynchronous ME
0032  *  Rx buffer pending notifications.
0033  * @notif_work: async work to execute FW notif event callback
0034  * @notif_cb: Drivers register this callback to get asynchronous ME
0035  *  FW notification pending notifications.
0036  *
0037  * @do_match: wheather device can be matched with a driver
0038  * @is_added: device is already scanned
0039  * @priv_data: client private data
0040  */
0041 struct mei_cl_device {
0042     struct list_head bus_list;
0043     struct mei_device *bus;
0044     struct device dev;
0045 
0046     struct mei_me_client *me_cl;
0047     struct mei_cl *cl;
0048     char name[MEI_CL_NAME_SIZE];
0049 
0050     struct work_struct rx_work;
0051     mei_cldev_cb_t rx_cb;
0052     struct work_struct notif_work;
0053     mei_cldev_cb_t notif_cb;
0054 
0055     unsigned int do_match:1;
0056     unsigned int is_added:1;
0057 
0058     void *priv_data;
0059 };
0060 
0061 #define to_mei_cl_device(d) container_of(d, struct mei_cl_device, dev)
0062 
0063 struct mei_cl_driver {
0064     struct device_driver driver;
0065     const char *name;
0066 
0067     const struct mei_cl_device_id *id_table;
0068 
0069     int (*probe)(struct mei_cl_device *cldev,
0070              const struct mei_cl_device_id *id);
0071     void (*remove)(struct mei_cl_device *cldev);
0072 };
0073 
0074 int __mei_cldev_driver_register(struct mei_cl_driver *cldrv,
0075                 struct module *owner);
0076 #define mei_cldev_driver_register(cldrv)             \
0077     __mei_cldev_driver_register(cldrv, THIS_MODULE)
0078 
0079 void mei_cldev_driver_unregister(struct mei_cl_driver *cldrv);
0080 
0081 /**
0082  * module_mei_cl_driver - Helper macro for registering mei cl driver
0083  *
0084  * @__mei_cldrv: mei_cl_driver structure
0085  *
0086  *  Helper macro for mei cl drivers which do not do anything special in module
0087  *  init/exit, for eliminating a boilerplate code.
0088  */
0089 #define module_mei_cl_driver(__mei_cldrv) \
0090     module_driver(__mei_cldrv, \
0091               mei_cldev_driver_register,\
0092               mei_cldev_driver_unregister)
0093 
0094 ssize_t mei_cldev_send(struct mei_cl_device *cldev, const u8 *buf,
0095                size_t length);
0096 ssize_t mei_cldev_recv(struct mei_cl_device *cldev, u8 *buf, size_t length);
0097 ssize_t mei_cldev_recv_nonblock(struct mei_cl_device *cldev, u8 *buf,
0098                 size_t length);
0099 ssize_t mei_cldev_send_vtag(struct mei_cl_device *cldev, const u8 *buf,
0100                 size_t length, u8 vtag);
0101 ssize_t mei_cldev_recv_vtag(struct mei_cl_device *cldev, u8 *buf, size_t length,
0102                 u8 *vtag);
0103 ssize_t mei_cldev_recv_nonblock_vtag(struct mei_cl_device *cldev, u8 *buf,
0104                      size_t length, u8 *vtag);
0105 
0106 int mei_cldev_register_rx_cb(struct mei_cl_device *cldev, mei_cldev_cb_t rx_cb);
0107 int mei_cldev_register_notif_cb(struct mei_cl_device *cldev,
0108                 mei_cldev_cb_t notif_cb);
0109 
0110 const uuid_le *mei_cldev_uuid(const struct mei_cl_device *cldev);
0111 u8 mei_cldev_ver(const struct mei_cl_device *cldev);
0112 
0113 void *mei_cldev_get_drvdata(const struct mei_cl_device *cldev);
0114 void mei_cldev_set_drvdata(struct mei_cl_device *cldev, void *data);
0115 
0116 int mei_cldev_enable(struct mei_cl_device *cldev);
0117 int mei_cldev_disable(struct mei_cl_device *cldev);
0118 bool mei_cldev_enabled(const struct mei_cl_device *cldev);
0119 
0120 void *mei_cldev_dma_map(struct mei_cl_device *cldev, u8 buffer_id, size_t size);
0121 int mei_cldev_dma_unmap(struct mei_cl_device *cldev);
0122 
0123 #endif /* _LINUX_MEI_CL_BUS_H */