Srinivas Pandruvada | 7ab2184 | 2019-03-18 12:14:20 -0700 | [diff] [blame] | 1 | /* 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 | |
| 11 | struct ishtp_cl_device; |
Srinivas Pandruvada | 8991eb3 | 2019-03-18 12:14:24 -0700 | [diff] [blame^] | 12 | struct ishtp_cl; |
| 13 | |
| 14 | /* Client state */ |
| 15 | enum 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 Pandruvada | 7ab2184 | 2019-03-18 12:14:20 -0700 | [diff] [blame] | 22 | |
Srinivas Pandruvada | e00a864 | 2019-03-18 12:14:22 -0700 | [diff] [blame] | 23 | /** |
| 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 | */ |
| 32 | struct 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 Pandruvada | 8991eb3 | 2019-03-18 12:14:24 -0700 | [diff] [blame^] | 42 | /** |
| 43 | * struct ishtp_msg_data - ISHTP message data struct |
| 44 | * @size: Size of data in the *data |
| 45 | * @data: Pointer to data |
| 46 | */ |
| 47 | struct 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 | */ |
| 60 | struct 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 Pandruvada | e00a864 | 2019-03-18 12:14:22 -0700 | [diff] [blame] | 68 | int ishtp_cl_driver_register(struct ishtp_cl_driver *driver, |
| 69 | struct module *owner); |
| 70 | void ishtp_cl_driver_unregister(struct ishtp_cl_driver *driver); |
| 71 | int ishtp_register_event_cb(struct ishtp_cl_device *device, |
| 72 | void (*read_cb)(struct ishtp_cl_device *)); |
| 73 | |
Srinivas Pandruvada | 7ab2184 | 2019-03-18 12:14:20 -0700 | [diff] [blame] | 74 | /* Get the device * from ishtp device instance */ |
| 75 | struct device *ishtp_device(struct ishtp_cl_device *cl_device); |
| 76 | /* Trace interface for clients */ |
| 77 | void *ishtp_trace_callback(struct ishtp_cl_device *cl_device); |
| 78 | |
Srinivas Pandruvada | 8991eb3 | 2019-03-18 12:14:24 -0700 | [diff] [blame^] | 79 | struct ishtp_cl *ishtp_cl_allocate(struct ishtp_cl_device *cl_device); |
| 80 | void ishtp_cl_free(struct ishtp_cl *cl); |
| 81 | int ishtp_cl_link(struct ishtp_cl *cl); |
| 82 | void ishtp_cl_unlink(struct ishtp_cl *cl); |
| 83 | int ishtp_cl_disconnect(struct ishtp_cl *cl); |
| 84 | int ishtp_cl_connect(struct ishtp_cl *cl); |
| 85 | int ishtp_cl_send(struct ishtp_cl *cl, uint8_t *buf, size_t length); |
| 86 | int ishtp_cl_flush_queues(struct ishtp_cl *cl); |
| 87 | int ishtp_cl_io_rb_recycle(struct ishtp_cl_rb *rb); |
| 88 | bool ishtp_cl_tx_empty(struct ishtp_cl *cl); |
| 89 | struct ishtp_cl_rb *ishtp_cl_rx_get_rb(struct ishtp_cl *cl); |
| 90 | |
Srinivas Pandruvada | 7ab2184 | 2019-03-18 12:14:20 -0700 | [diff] [blame] | 91 | #endif /* _INTEL_ISH_CLIENT_IF_H_ */ |