blob: 7ce172f656f8e7d3b6a558ed93a5d13b279e0544 [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 Pandruvada8991eb32019-03-18 12:14:24 -070012struct ishtp_cl;
13
14/* Client state */
15enum cl_state {
16 ISHTP_CL_INITIALIZING = 0,
17 ISHTP_CL_CONNECTING,
18 ISHTP_CL_CONNECTED,
19 ISHTP_CL_DISCONNECTING,
20 ISHTP_CL_DISCONNECTED
21};
Srinivas Pandruvada7ab21842019-03-18 12:14:20 -070022
Srinivas Pandruvadae00a8642019-03-18 12:14:22 -070023/**
24 * struct ishtp_cl_device - ISHTP device handle
25 * @driver: driver instance on a bus
26 * @name: Name of the device for probe
27 * @probe: driver callback for device probe
28 * @remove: driver callback on device removal
29 *
30 * Client drivers defines to get probed/removed for ISHTP client device.
31 */
32struct ishtp_cl_driver {
33 struct device_driver driver;
34 const char *name;
35 const guid_t *guid;
36 int (*probe)(struct ishtp_cl_device *dev);
37 int (*remove)(struct ishtp_cl_device *dev);
38 int (*reset)(struct ishtp_cl_device *dev);
39 const struct dev_pm_ops *pm;
40};
41
Srinivas Pandruvada8991eb32019-03-18 12:14:24 -070042/**
43 * struct ishtp_msg_data - ISHTP message data struct
44 * @size: Size of data in the *data
45 * @data: Pointer to data
46 */
47struct ishtp_msg_data {
48 uint32_t size;
49 unsigned char *data;
50};
51
52/*
53 * struct ishtp_cl_rb - request block structure
54 * @list: Link to list members
55 * @cl: ISHTP client instance
56 * @buffer: message header
57 * @buf_idx: Index into buffer
58 * @read_time: unused at this time
59 */
60struct ishtp_cl_rb {
61 struct list_head list;
62 struct ishtp_cl *cl;
63 struct ishtp_msg_data buffer;
64 unsigned long buf_idx;
65 unsigned long read_time;
66};
67
Srinivas Pandruvadae00a8642019-03-18 12:14:22 -070068int ishtp_cl_driver_register(struct ishtp_cl_driver *driver,
69 struct module *owner);
70void ishtp_cl_driver_unregister(struct ishtp_cl_driver *driver);
71int ishtp_register_event_cb(struct ishtp_cl_device *device,
72 void (*read_cb)(struct ishtp_cl_device *));
73
Srinivas Pandruvada7ab21842019-03-18 12:14:20 -070074/* Get the device * from ishtp device instance */
75struct device *ishtp_device(struct ishtp_cl_device *cl_device);
76/* Trace interface for clients */
77void *ishtp_trace_callback(struct ishtp_cl_device *cl_device);
78
Srinivas Pandruvada8991eb32019-03-18 12:14:24 -070079struct ishtp_cl *ishtp_cl_allocate(struct ishtp_cl_device *cl_device);
80void ishtp_cl_free(struct ishtp_cl *cl);
81int ishtp_cl_link(struct ishtp_cl *cl);
82void ishtp_cl_unlink(struct ishtp_cl *cl);
83int ishtp_cl_disconnect(struct ishtp_cl *cl);
84int ishtp_cl_connect(struct ishtp_cl *cl);
85int ishtp_cl_send(struct ishtp_cl *cl, uint8_t *buf, size_t length);
86int ishtp_cl_flush_queues(struct ishtp_cl *cl);
87int ishtp_cl_io_rb_recycle(struct ishtp_cl_rb *rb);
88bool ishtp_cl_tx_empty(struct ishtp_cl *cl);
89struct ishtp_cl_rb *ishtp_cl_rx_get_rb(struct ishtp_cl *cl);
90
Srinivas Pandruvada7ab21842019-03-18 12:14:20 -070091#endif /* _INTEL_ISH_CLIENT_IF_H_ */