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