1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Intel ISH client Interface definitions
5 * Copyright (c) 2019, Intel Corporation.
8 #ifndef _INTEL_ISH_CLIENT_IF_H_
9 #define _INTEL_ISH_CLIENT_IF_H_
11 #include <linux/device.h>
12 #include <linux/uuid.h>
14 struct ishtp_cl_device;
17 struct ishtp_fw_client;
19 typedef __printf(2, 3) void (*ishtp_print_log)(struct ishtp_device *dev,
20 const char *format, ...);
24 ISHTP_CL_INITIALIZING = 0,
27 ISHTP_CL_DISCONNECTING,
32 * struct ishtp_cl_device - ISHTP device handle
33 * @driver: driver instance on a bus
34 * @name: Name of the device for probe
35 * @probe: driver callback for device probe
36 * @remove: driver callback on device removal
38 * Client drivers defines to get probed/removed for ISHTP client device.
40 struct ishtp_cl_driver {
41 struct device_driver driver;
44 int (*probe)(struct ishtp_cl_device *dev);
45 void (*remove)(struct ishtp_cl_device *dev);
46 int (*reset)(struct ishtp_cl_device *dev);
47 const struct dev_pm_ops *pm;
51 * struct ishtp_msg_data - ISHTP message data struct
52 * @size: Size of data in the *data
53 * @data: Pointer to data
55 struct ishtp_msg_data {
61 * struct ishtp_cl_rb - request block structure
62 * @list: Link to list members
63 * @cl: ISHTP client instance
64 * @buffer: message header
65 * @buf_idx: Index into buffer
66 * @read_time: unused at this time
69 struct list_head list;
71 struct ishtp_msg_data buffer;
72 unsigned long buf_idx;
73 unsigned long read_time;
76 int ishtp_cl_driver_register(struct ishtp_cl_driver *driver,
77 struct module *owner);
78 void ishtp_cl_driver_unregister(struct ishtp_cl_driver *driver);
79 int ishtp_register_event_cb(struct ishtp_cl_device *device,
80 void (*read_cb)(struct ishtp_cl_device *));
82 /* Get the device * from ishtp device instance */
83 struct device *ishtp_device(struct ishtp_cl_device *cl_device);
84 /* Trace interface for clients */
85 ishtp_print_log ishtp_trace_callback(struct ishtp_cl_device *cl_device);
86 /* Get device pointer of PCI device for DMA acces */
87 struct device *ishtp_get_pci_device(struct ishtp_cl_device *cl_device);
89 struct ishtp_cl *ishtp_cl_allocate(struct ishtp_cl_device *cl_device);
90 void ishtp_cl_free(struct ishtp_cl *cl);
91 int ishtp_cl_link(struct ishtp_cl *cl);
92 void ishtp_cl_unlink(struct ishtp_cl *cl);
93 int ishtp_cl_disconnect(struct ishtp_cl *cl);
94 int ishtp_cl_connect(struct ishtp_cl *cl);
95 int ishtp_cl_send(struct ishtp_cl *cl, uint8_t *buf, size_t length);
96 int ishtp_cl_flush_queues(struct ishtp_cl *cl);
97 int ishtp_cl_io_rb_recycle(struct ishtp_cl_rb *rb);
98 bool ishtp_cl_tx_empty(struct ishtp_cl *cl);
99 struct ishtp_cl_rb *ishtp_cl_rx_get_rb(struct ishtp_cl *cl);
100 void *ishtp_get_client_data(struct ishtp_cl *cl);
101 void ishtp_set_client_data(struct ishtp_cl *cl, void *data);
102 struct ishtp_device *ishtp_get_ishtp_device(struct ishtp_cl *cl);
103 void ishtp_set_tx_ring_size(struct ishtp_cl *cl, int size);
104 void ishtp_set_rx_ring_size(struct ishtp_cl *cl, int size);
105 void ishtp_set_connection_state(struct ishtp_cl *cl, int state);
106 void ishtp_cl_set_fw_client_id(struct ishtp_cl *cl, int fw_client_id);
108 void ishtp_put_device(struct ishtp_cl_device *cl_dev);
109 void ishtp_get_device(struct ishtp_cl_device *cl_dev);
110 void ishtp_set_drvdata(struct ishtp_cl_device *cl_device, void *data);
111 void *ishtp_get_drvdata(struct ishtp_cl_device *cl_device);
112 struct ishtp_cl_device *ishtp_dev_to_cl_device(struct device *dev);
113 int ishtp_register_event_cb(struct ishtp_cl_device *device,
114 void (*read_cb)(struct ishtp_cl_device *));
115 struct ishtp_fw_client *ishtp_fw_cl_get_client(struct ishtp_device *dev,
117 int ishtp_get_fw_client_id(struct ishtp_fw_client *fw_client);
118 int ish_hw_reset(struct ishtp_device *dev);
119 #endif /* _INTEL_ISH_CLIENT_IF_H_ */