blob: 0d6b4bc191c5a849437a8c99b61e550c26214c9b [file] [log] [blame]
Srinivas Pandruvada7ab21842019-03-18 12:14:20 -07001/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Intel ISH client Interface definitions
4 *
5 * Copyright (c) 2019, Intel Corporation.
6 */
7
8#ifndef _INTEL_ISH_CLIENT_IF_H_
9#define _INTEL_ISH_CLIENT_IF_H_
10
11struct ishtp_cl_device;
Srinivas Pandruvada5f7224c2019-03-18 12:14:26 -070012struct ishtp_device;
Srinivas Pandruvada8991eb32019-03-18 12:14:24 -070013struct ishtp_cl;
Srinivas Pandruvada5f7224c2019-03-18 12:14:26 -070014struct ishtp_fw_client;
Srinivas Pandruvada8991eb32019-03-18 12:14:24 -070015
16/* Client state */
17enum cl_state {
18 ISHTP_CL_INITIALIZING = 0,
19 ISHTP_CL_CONNECTING,
20 ISHTP_CL_CONNECTED,
21 ISHTP_CL_DISCONNECTING,
22 ISHTP_CL_DISCONNECTED
23};
Srinivas Pandruvada7ab21842019-03-18 12:14:20 -070024
Srinivas Pandruvadae00a8642019-03-18 12:14:22 -070025/**
26 * struct ishtp_cl_device - ISHTP device handle
27 * @driver: driver instance on a bus
28 * @name: Name of the device for probe
29 * @probe: driver callback for device probe
30 * @remove: driver callback on device removal
31 *
32 * Client drivers defines to get probed/removed for ISHTP client device.
33 */
34struct ishtp_cl_driver {
35 struct device_driver driver;
36 const char *name;
37 const guid_t *guid;
38 int (*probe)(struct ishtp_cl_device *dev);
39 int (*remove)(struct ishtp_cl_device *dev);
40 int (*reset)(struct ishtp_cl_device *dev);
41 const struct dev_pm_ops *pm;
42};
43
Srinivas Pandruvada8991eb32019-03-18 12:14:24 -070044/**
45 * struct ishtp_msg_data - ISHTP message data struct
46 * @size: Size of data in the *data
47 * @data: Pointer to data
48 */
49struct ishtp_msg_data {
50 uint32_t size;
51 unsigned char *data;
52};
53
54/*
55 * struct ishtp_cl_rb - request block structure
56 * @list: Link to list members
57 * @cl: ISHTP client instance
58 * @buffer: message header
59 * @buf_idx: Index into buffer
60 * @read_time: unused at this time
61 */
62struct ishtp_cl_rb {
63 struct list_head list;
64 struct ishtp_cl *cl;
65 struct ishtp_msg_data buffer;
66 unsigned long buf_idx;
67 unsigned long read_time;
68};
69
Srinivas Pandruvadae00a8642019-03-18 12:14:22 -070070int ishtp_cl_driver_register(struct ishtp_cl_driver *driver,
71 struct module *owner);
72void ishtp_cl_driver_unregister(struct ishtp_cl_driver *driver);
73int ishtp_register_event_cb(struct ishtp_cl_device *device,
74 void (*read_cb)(struct ishtp_cl_device *));
75
Srinivas Pandruvada7ab21842019-03-18 12:14:20 -070076/* Get the device * from ishtp device instance */
77struct device *ishtp_device(struct ishtp_cl_device *cl_device);
78/* Trace interface for clients */
79void *ishtp_trace_callback(struct ishtp_cl_device *cl_device);
Srinivas Pandruvada0e568a12019-03-18 12:14:28 -070080/* Get device pointer of PCI device for DMA acces */
81struct device *ishtp_get_pci_device(struct ishtp_cl_device *cl_device);
Srinivas Pandruvada7ab21842019-03-18 12:14:20 -070082
Srinivas Pandruvada8991eb32019-03-18 12:14:24 -070083struct ishtp_cl *ishtp_cl_allocate(struct ishtp_cl_device *cl_device);
84void ishtp_cl_free(struct ishtp_cl *cl);
85int ishtp_cl_link(struct ishtp_cl *cl);
86void ishtp_cl_unlink(struct ishtp_cl *cl);
87int ishtp_cl_disconnect(struct ishtp_cl *cl);
88int ishtp_cl_connect(struct ishtp_cl *cl);
89int ishtp_cl_send(struct ishtp_cl *cl, uint8_t *buf, size_t length);
90int ishtp_cl_flush_queues(struct ishtp_cl *cl);
91int ishtp_cl_io_rb_recycle(struct ishtp_cl_rb *rb);
92bool ishtp_cl_tx_empty(struct ishtp_cl *cl);
93struct ishtp_cl_rb *ishtp_cl_rx_get_rb(struct ishtp_cl *cl);
Srinivas Pandruvada51cbc702019-03-18 12:14:25 -070094void *ishtp_get_client_data(struct ishtp_cl *cl);
95void ishtp_set_client_data(struct ishtp_cl *cl, void *data);
96struct ishtp_device *ishtp_get_ishtp_device(struct ishtp_cl *cl);
97void ishtp_set_tx_ring_size(struct ishtp_cl *cl, int size);
98void ishtp_set_rx_ring_size(struct ishtp_cl *cl, int size);
99void ishtp_set_connection_state(struct ishtp_cl *cl, int state);
100void ishtp_cl_set_fw_client_id(struct ishtp_cl *cl, int fw_client_id);
Srinivas Pandruvada8991eb32019-03-18 12:14:24 -0700101
Srinivas Pandruvada5f7224c2019-03-18 12:14:26 -0700102void ishtp_put_device(struct ishtp_cl_device *cl_dev);
103void ishtp_get_device(struct ishtp_cl_device *cl_dev);
104void ishtp_set_drvdata(struct ishtp_cl_device *cl_device, void *data);
105void *ishtp_get_drvdata(struct ishtp_cl_device *cl_device);
Hyungwoo Yangb12bbdc2019-06-05 21:52:27 -0700106struct ishtp_cl_device *ishtp_dev_to_cl_device(struct device *dev);
Srinivas Pandruvada5f7224c2019-03-18 12:14:26 -0700107int ishtp_register_event_cb(struct ishtp_cl_device *device,
108 void (*read_cb)(struct ishtp_cl_device *));
109struct ishtp_fw_client *ishtp_fw_cl_get_client(struct ishtp_device *dev,
110 const guid_t *uuid);
111int ishtp_get_fw_client_id(struct ishtp_fw_client *fw_client);
112int ish_hw_reset(struct ishtp_device *dev);
Srinivas Pandruvada7ab21842019-03-18 12:14:20 -0700113#endif /* _INTEL_ISH_CLIENT_IF_H_ */