1 /* 2 * ISHTP bus definitions 3 * 4 * Copyright (c) 2014-2016, Intel Corporation. 5 * 6 * This program is free software; you can redistribute it and/or modify it 7 * under the terms and conditions of the GNU General Public License, 8 * version 2, as published by the Free Software Foundation. 9 * 10 * This program is distributed in the hope it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 * more details. 14 */ 15 #ifndef _LINUX_ISHTP_CL_BUS_H 16 #define _LINUX_ISHTP_CL_BUS_H 17 18 #include <linux/device.h> 19 #include <linux/mod_devicetable.h> 20 #include <linux/intel-ish-client-if.h> 21 22 struct ishtp_cl; 23 struct ishtp_cl_device; 24 struct ishtp_device; 25 struct ishtp_msg_hdr; 26 27 /** 28 * struct ishtp_cl_device - ISHTP device handle 29 * @dev: device pointer 30 * @ishtp_dev: pointer to ishtp device structure to primarily to access 31 * hw device operation callbacks and properties 32 * @fw_client: fw_client pointer to get fw information like protocol name 33 * max message length etc. 34 * @device_link: Link to next client in the list on a bus 35 * @event_work: Used to schedule rx event for client 36 * @driver_data: Storage driver private data 37 * @reference_count: Used for get/put device 38 * @event_cb: Callback to driver to send events 39 * 40 * An ishtp_cl_device pointer is returned from ishtp_add_device() 41 * and links ISHTP bus clients to their actual host client pointer. 42 * Drivers for ISHTP devices will get an ishtp_cl_device pointer 43 * when being probed and shall use it for doing bus I/O. 44 */ 45 struct ishtp_cl_device { 46 struct device dev; 47 struct ishtp_device *ishtp_dev; 48 struct ishtp_fw_client *fw_client; 49 struct list_head device_link; 50 struct work_struct event_work; 51 void *driver_data; 52 int reference_count; 53 void (*event_cb)(struct ishtp_cl_device *device); 54 }; 55 56 int ishtp_bus_new_client(struct ishtp_device *dev); 57 void ishtp_remove_all_clients(struct ishtp_device *dev); 58 int ishtp_cl_device_bind(struct ishtp_cl *cl); 59 void ishtp_cl_bus_rx_event(struct ishtp_cl_device *device); 60 61 /* Write a multi-fragment message */ 62 int ishtp_send_msg(struct ishtp_device *dev, 63 struct ishtp_msg_hdr *hdr, void *msg, 64 void (*ipc_send_compl)(void *), 65 void *ipc_send_compl_prm); 66 67 /* Write a single-fragment message */ 68 int ishtp_write_message(struct ishtp_device *dev, 69 struct ishtp_msg_hdr *hdr, 70 void *buf); 71 72 /* Use DMA to send/receive messages */ 73 int ishtp_use_dma_transfer(void); 74 75 /* Exported functions */ 76 void ishtp_bus_remove_all_clients(struct ishtp_device *ishtp_dev, 77 bool warm_reset); 78 79 void ishtp_recv(struct ishtp_device *dev); 80 void ishtp_reset_handler(struct ishtp_device *dev); 81 void ishtp_reset_compl_handler(struct ishtp_device *dev); 82 83 int ishtp_fw_cl_by_uuid(struct ishtp_device *dev, const guid_t *cuuid); 84 #endif /* _LINUX_ISHTP_CL_BUS_H */ 85