1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-only */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * ISHTP bus definitions 4*4882a593Smuzhiyun * 5*4882a593Smuzhiyun * Copyright (c) 2014-2016, Intel Corporation. 6*4882a593Smuzhiyun */ 7*4882a593Smuzhiyun #ifndef _LINUX_ISHTP_CL_BUS_H 8*4882a593Smuzhiyun #define _LINUX_ISHTP_CL_BUS_H 9*4882a593Smuzhiyun 10*4882a593Smuzhiyun #include <linux/device.h> 11*4882a593Smuzhiyun #include <linux/mod_devicetable.h> 12*4882a593Smuzhiyun #include <linux/intel-ish-client-if.h> 13*4882a593Smuzhiyun 14*4882a593Smuzhiyun struct ishtp_cl; 15*4882a593Smuzhiyun struct ishtp_cl_device; 16*4882a593Smuzhiyun struct ishtp_device; 17*4882a593Smuzhiyun struct ishtp_msg_hdr; 18*4882a593Smuzhiyun 19*4882a593Smuzhiyun /** 20*4882a593Smuzhiyun * struct ishtp_cl_device - ISHTP device handle 21*4882a593Smuzhiyun * @dev: device pointer 22*4882a593Smuzhiyun * @ishtp_dev: pointer to ishtp device structure to primarily to access 23*4882a593Smuzhiyun * hw device operation callbacks and properties 24*4882a593Smuzhiyun * @fw_client: fw_client pointer to get fw information like protocol name 25*4882a593Smuzhiyun * max message length etc. 26*4882a593Smuzhiyun * @device_link: Link to next client in the list on a bus 27*4882a593Smuzhiyun * @event_work: Used to schedule rx event for client 28*4882a593Smuzhiyun * @driver_data: Storage driver private data 29*4882a593Smuzhiyun * @reference_count: Used for get/put device 30*4882a593Smuzhiyun * @event_cb: Callback to driver to send events 31*4882a593Smuzhiyun * 32*4882a593Smuzhiyun * An ishtp_cl_device pointer is returned from ishtp_add_device() 33*4882a593Smuzhiyun * and links ISHTP bus clients to their actual host client pointer. 34*4882a593Smuzhiyun * Drivers for ISHTP devices will get an ishtp_cl_device pointer 35*4882a593Smuzhiyun * when being probed and shall use it for doing bus I/O. 36*4882a593Smuzhiyun */ 37*4882a593Smuzhiyun struct ishtp_cl_device { 38*4882a593Smuzhiyun struct device dev; 39*4882a593Smuzhiyun struct ishtp_device *ishtp_dev; 40*4882a593Smuzhiyun struct ishtp_fw_client *fw_client; 41*4882a593Smuzhiyun struct list_head device_link; 42*4882a593Smuzhiyun struct work_struct event_work; 43*4882a593Smuzhiyun void *driver_data; 44*4882a593Smuzhiyun int reference_count; 45*4882a593Smuzhiyun void (*event_cb)(struct ishtp_cl_device *device); 46*4882a593Smuzhiyun }; 47*4882a593Smuzhiyun 48*4882a593Smuzhiyun int ishtp_bus_new_client(struct ishtp_device *dev); 49*4882a593Smuzhiyun void ishtp_remove_all_clients(struct ishtp_device *dev); 50*4882a593Smuzhiyun int ishtp_cl_device_bind(struct ishtp_cl *cl); 51*4882a593Smuzhiyun void ishtp_cl_bus_rx_event(struct ishtp_cl_device *device); 52*4882a593Smuzhiyun 53*4882a593Smuzhiyun /* Write a multi-fragment message */ 54*4882a593Smuzhiyun int ishtp_send_msg(struct ishtp_device *dev, 55*4882a593Smuzhiyun struct ishtp_msg_hdr *hdr, void *msg, 56*4882a593Smuzhiyun void (*ipc_send_compl)(void *), 57*4882a593Smuzhiyun void *ipc_send_compl_prm); 58*4882a593Smuzhiyun 59*4882a593Smuzhiyun /* Write a single-fragment message */ 60*4882a593Smuzhiyun int ishtp_write_message(struct ishtp_device *dev, 61*4882a593Smuzhiyun struct ishtp_msg_hdr *hdr, 62*4882a593Smuzhiyun void *buf); 63*4882a593Smuzhiyun 64*4882a593Smuzhiyun /* Use DMA to send/receive messages */ 65*4882a593Smuzhiyun int ishtp_use_dma_transfer(void); 66*4882a593Smuzhiyun 67*4882a593Smuzhiyun /* Exported functions */ 68*4882a593Smuzhiyun void ishtp_bus_remove_all_clients(struct ishtp_device *ishtp_dev, 69*4882a593Smuzhiyun bool warm_reset); 70*4882a593Smuzhiyun 71*4882a593Smuzhiyun void ishtp_recv(struct ishtp_device *dev); 72*4882a593Smuzhiyun void ishtp_reset_handler(struct ishtp_device *dev); 73*4882a593Smuzhiyun void ishtp_reset_compl_handler(struct ishtp_device *dev); 74*4882a593Smuzhiyun 75*4882a593Smuzhiyun int ishtp_fw_cl_by_uuid(struct ishtp_device *dev, const guid_t *cuuid); 76*4882a593Smuzhiyun #endif /* _LINUX_ISHTP_CL_BUS_H */ 77