Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Intel ISH client Interface definitions
0004  *
0005  * Copyright (c) 2019, Intel Corporation.
0006  */
0007 
0008 #ifndef _INTEL_ISH_CLIENT_IF_H_
0009 #define _INTEL_ISH_CLIENT_IF_H_
0010 
0011 #include <linux/device.h>
0012 #include <linux/mod_devicetable.h>
0013 
0014 struct ishtp_cl_device;
0015 struct ishtp_device;
0016 struct ishtp_cl;
0017 struct ishtp_fw_client;
0018 
0019 typedef __printf(2, 3) void (*ishtp_print_log)(struct ishtp_device *dev,
0020                            const char *format, ...);
0021 
0022 /* Client state */
0023 enum cl_state {
0024     ISHTP_CL_INITIALIZING = 0,
0025     ISHTP_CL_CONNECTING,
0026     ISHTP_CL_CONNECTED,
0027     ISHTP_CL_DISCONNECTING,
0028     ISHTP_CL_DISCONNECTED
0029 };
0030 
0031 /**
0032  * struct ishtp_cl_device - ISHTP device handle
0033  * @driver: driver instance on a bus
0034  * @name:   Name of the device for probe
0035  * @probe:  driver callback for device probe
0036  * @remove: driver callback on device removal
0037  *
0038  * Client drivers defines to get probed/removed for ISHTP client device.
0039  */
0040 struct ishtp_cl_driver {
0041     struct device_driver driver;
0042     const char *name;
0043     const struct ishtp_device_id *id;
0044     int (*probe)(struct ishtp_cl_device *dev);
0045     void (*remove)(struct ishtp_cl_device *dev);
0046     int (*reset)(struct ishtp_cl_device *dev);
0047     const struct dev_pm_ops *pm;
0048 };
0049 
0050 /**
0051  * struct ishtp_msg_data - ISHTP message data struct
0052  * @size:   Size of data in the *data
0053  * @data:   Pointer to data
0054  */
0055 struct ishtp_msg_data {
0056     uint32_t size;
0057     unsigned char *data;
0058 };
0059 
0060 /*
0061  * struct ishtp_cl_rb - request block structure
0062  * @list:   Link to list members
0063  * @cl:     ISHTP client instance
0064  * @buffer: message header
0065  * @buf_idx:    Index into buffer
0066  * @read_time:   unused at this time
0067  */
0068 struct ishtp_cl_rb {
0069     struct list_head list;
0070     struct ishtp_cl *cl;
0071     struct ishtp_msg_data buffer;
0072     unsigned long buf_idx;
0073     unsigned long read_time;
0074 };
0075 
0076 int ishtp_cl_driver_register(struct ishtp_cl_driver *driver,
0077                  struct module *owner);
0078 void ishtp_cl_driver_unregister(struct ishtp_cl_driver *driver);
0079 int ishtp_register_event_cb(struct ishtp_cl_device *device,
0080                 void (*read_cb)(struct ishtp_cl_device *));
0081 
0082 /* Get the device * from ishtp device instance */
0083 struct device *ishtp_device(struct ishtp_cl_device *cl_device);
0084 /* wait for IPC resume */
0085 bool ishtp_wait_resume(struct ishtp_device *dev);
0086 /* Trace interface for clients */
0087 ishtp_print_log ishtp_trace_callback(struct ishtp_cl_device *cl_device);
0088 /* Get device pointer of PCI device for DMA acces */
0089 struct device *ishtp_get_pci_device(struct ishtp_cl_device *cl_device);
0090 
0091 struct ishtp_cl *ishtp_cl_allocate(struct ishtp_cl_device *cl_device);
0092 void ishtp_cl_free(struct ishtp_cl *cl);
0093 int ishtp_cl_link(struct ishtp_cl *cl);
0094 void ishtp_cl_unlink(struct ishtp_cl *cl);
0095 int ishtp_cl_disconnect(struct ishtp_cl *cl);
0096 int ishtp_cl_connect(struct ishtp_cl *cl);
0097 int ishtp_cl_send(struct ishtp_cl *cl, uint8_t *buf, size_t length);
0098 int ishtp_cl_flush_queues(struct ishtp_cl *cl);
0099 int ishtp_cl_io_rb_recycle(struct ishtp_cl_rb *rb);
0100 bool ishtp_cl_tx_empty(struct ishtp_cl *cl);
0101 struct ishtp_cl_rb *ishtp_cl_rx_get_rb(struct ishtp_cl *cl);
0102 void *ishtp_get_client_data(struct ishtp_cl *cl);
0103 void ishtp_set_client_data(struct ishtp_cl *cl, void *data);
0104 struct ishtp_device *ishtp_get_ishtp_device(struct ishtp_cl *cl);
0105 void ishtp_set_tx_ring_size(struct ishtp_cl *cl, int size);
0106 void ishtp_set_rx_ring_size(struct ishtp_cl *cl, int size);
0107 void ishtp_set_connection_state(struct ishtp_cl *cl, int state);
0108 void ishtp_cl_set_fw_client_id(struct ishtp_cl *cl, int fw_client_id);
0109 
0110 void ishtp_put_device(struct ishtp_cl_device *cl_dev);
0111 void ishtp_get_device(struct ishtp_cl_device *cl_dev);
0112 void ishtp_set_drvdata(struct ishtp_cl_device *cl_device, void *data);
0113 void *ishtp_get_drvdata(struct ishtp_cl_device *cl_device);
0114 struct ishtp_cl_device *ishtp_dev_to_cl_device(struct device *dev);
0115 int ishtp_register_event_cb(struct ishtp_cl_device *device,
0116                 void (*read_cb)(struct ishtp_cl_device *));
0117 struct  ishtp_fw_client *ishtp_fw_cl_get_client(struct ishtp_device *dev,
0118                         const guid_t *uuid);
0119 int ishtp_get_fw_client_id(struct ishtp_fw_client *fw_client);
0120 int ish_hw_reset(struct ishtp_device *dev);
0121 #endif /* _INTEL_ISH_CLIENT_IF_H_ */