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/mod_devicetable.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
;
43 const struct ishtp_device_id
*id
;
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 /* wait for IPC resume */
85 bool ishtp_wait_resume(struct ishtp_device
*dev
);
86 /* Trace interface for clients */
87 ishtp_print_log
ishtp_trace_callback(struct ishtp_cl_device
*cl_device
);
88 /* Get device pointer of PCI device for DMA acces */
89 struct device
*ishtp_get_pci_device(struct ishtp_cl_device
*cl_device
);
91 struct ishtp_cl
*ishtp_cl_allocate(struct ishtp_cl_device
*cl_device
);
92 void ishtp_cl_free(struct ishtp_cl
*cl
);
93 int ishtp_cl_link(struct ishtp_cl
*cl
);
94 void ishtp_cl_unlink(struct ishtp_cl
*cl
);
95 int ishtp_cl_disconnect(struct ishtp_cl
*cl
);
96 int ishtp_cl_connect(struct ishtp_cl
*cl
);
97 int ishtp_cl_establish_connection(struct ishtp_cl
*cl
, const guid_t
*uuid
,
98 int tx_size
, int rx_size
, bool reset
);
99 void ishtp_cl_destroy_connection(struct ishtp_cl
*cl
, bool reset
);
100 int ishtp_cl_send(struct ishtp_cl
*cl
, uint8_t *buf
, size_t length
);
101 int ishtp_cl_flush_queues(struct ishtp_cl
*cl
);
102 int ishtp_cl_io_rb_recycle(struct ishtp_cl_rb
*rb
);
103 bool ishtp_cl_tx_empty(struct ishtp_cl
*cl
);
104 struct ishtp_cl_rb
*ishtp_cl_rx_get_rb(struct ishtp_cl
*cl
);
105 void *ishtp_get_client_data(struct ishtp_cl
*cl
);
106 void ishtp_set_client_data(struct ishtp_cl
*cl
, void *data
);
107 struct ishtp_device
*ishtp_get_ishtp_device(struct ishtp_cl
*cl
);
108 void ishtp_set_tx_ring_size(struct ishtp_cl
*cl
, int size
);
109 void ishtp_set_rx_ring_size(struct ishtp_cl
*cl
, int size
);
110 void ishtp_set_connection_state(struct ishtp_cl
*cl
, int state
);
111 void ishtp_cl_set_fw_client_id(struct ishtp_cl
*cl
, int fw_client_id
);
113 void ishtp_put_device(struct ishtp_cl_device
*cl_dev
);
114 void ishtp_get_device(struct ishtp_cl_device
*cl_dev
);
115 void ishtp_set_drvdata(struct ishtp_cl_device
*cl_device
, void *data
);
116 void *ishtp_get_drvdata(struct ishtp_cl_device
*cl_device
);
117 struct ishtp_cl_device
*ishtp_dev_to_cl_device(struct device
*dev
);
118 int ishtp_register_event_cb(struct ishtp_cl_device
*device
,
119 void (*read_cb
)(struct ishtp_cl_device
*));
120 struct ishtp_fw_client
*ishtp_fw_cl_get_client(struct ishtp_device
*dev
,
122 int ishtp_get_fw_client_id(struct ishtp_fw_client
*fw_client
);
123 int ish_hw_reset(struct ishtp_device
*dev
);
124 #endif /* _INTEL_ISH_CLIENT_IF_H_ */