Linux-libre 5.4.49-gnu
[librecmc/linux-libre.git] / drivers / hid / intel-ish-hid / ishtp / bus.h
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * ISHTP bus definitions
4  *
5  * Copyright (c) 2014-2016, Intel Corporation.
6  */
7 #ifndef _LINUX_ISHTP_CL_BUS_H
8 #define _LINUX_ISHTP_CL_BUS_H
9
10 #include <linux/device.h>
11 #include <linux/mod_devicetable.h>
12 #include <linux/intel-ish-client-if.h>
13
14 struct ishtp_cl;
15 struct ishtp_cl_device;
16 struct ishtp_device;
17 struct ishtp_msg_hdr;
18
19 /**
20  * struct ishtp_cl_device - ISHTP device handle
21  * @dev:        device pointer
22  * @ishtp_dev:  pointer to ishtp device structure to primarily to access
23  *              hw device operation callbacks and properties
24  * @fw_client:  fw_client pointer to get fw information like protocol name
25  *              max message length etc.
26  * @device_link: Link to next client in the list on a bus
27  * @event_work: Used to schedule rx event for client
28  * @driver_data: Storage driver private data
29  * @reference_count:    Used for get/put device
30  * @event_cb:   Callback to driver to send events
31  *
32  * An ishtp_cl_device pointer is returned from ishtp_add_device()
33  * and links ISHTP bus clients to their actual host client pointer.
34  * Drivers for ISHTP devices will get an ishtp_cl_device pointer
35  * when being probed and shall use it for doing bus I/O.
36  */
37 struct ishtp_cl_device {
38         struct device           dev;
39         struct ishtp_device     *ishtp_dev;
40         struct ishtp_fw_client  *fw_client;
41         struct list_head        device_link;
42         struct work_struct      event_work;
43         void                    *driver_data;
44         int                     reference_count;
45         void (*event_cb)(struct ishtp_cl_device *device);
46 };
47
48 int     ishtp_bus_new_client(struct ishtp_device *dev);
49 void    ishtp_remove_all_clients(struct ishtp_device *dev);
50 int     ishtp_cl_device_bind(struct ishtp_cl *cl);
51 void    ishtp_cl_bus_rx_event(struct ishtp_cl_device *device);
52
53 /* Write a multi-fragment message */
54 int     ishtp_send_msg(struct ishtp_device *dev,
55                        struct ishtp_msg_hdr *hdr, void *msg,
56                        void (*ipc_send_compl)(void *),
57                        void *ipc_send_compl_prm);
58
59 /* Write a single-fragment message */
60 int     ishtp_write_message(struct ishtp_device *dev,
61                             struct ishtp_msg_hdr *hdr,
62                             void *buf);
63
64 /* Use DMA to send/receive messages */
65 int ishtp_use_dma_transfer(void);
66
67 /* Exported functions */
68 void    ishtp_bus_remove_all_clients(struct ishtp_device *ishtp_dev,
69                                      bool warm_reset);
70
71 void    ishtp_recv(struct ishtp_device *dev);
72 void    ishtp_reset_handler(struct ishtp_device *dev);
73 void    ishtp_reset_compl_handler(struct ishtp_device *dev);
74
75 int     ishtp_fw_cl_by_uuid(struct ishtp_device *dev, const guid_t *cuuid);
76 #endif /* _LINUX_ISHTP_CL_BUS_H */