18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * ISHTP bus definitions
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (c) 2014-2016, Intel Corporation.
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci#ifndef _LINUX_ISHTP_CL_BUS_H
88c2ecf20Sopenharmony_ci#define _LINUX_ISHTP_CL_BUS_H
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#include <linux/device.h>
118c2ecf20Sopenharmony_ci#include <linux/mod_devicetable.h>
128c2ecf20Sopenharmony_ci#include <linux/intel-ish-client-if.h>
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_cistruct ishtp_cl;
158c2ecf20Sopenharmony_cistruct ishtp_cl_device;
168c2ecf20Sopenharmony_cistruct ishtp_device;
178c2ecf20Sopenharmony_cistruct ishtp_msg_hdr;
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci/**
208c2ecf20Sopenharmony_ci * struct ishtp_cl_device - ISHTP device handle
218c2ecf20Sopenharmony_ci * @dev:	device pointer
228c2ecf20Sopenharmony_ci * @ishtp_dev:	pointer to ishtp device structure to primarily to access
238c2ecf20Sopenharmony_ci *		hw device operation callbacks and properties
248c2ecf20Sopenharmony_ci * @fw_client:	fw_client pointer to get fw information like protocol name
258c2ecf20Sopenharmony_ci *		max message length etc.
268c2ecf20Sopenharmony_ci * @device_link: Link to next client in the list on a bus
278c2ecf20Sopenharmony_ci * @event_work:	Used to schedule rx event for client
288c2ecf20Sopenharmony_ci * @driver_data: Storage driver private data
298c2ecf20Sopenharmony_ci * @reference_count:	Used for get/put device
308c2ecf20Sopenharmony_ci * @event_cb:	Callback to driver to send events
318c2ecf20Sopenharmony_ci *
328c2ecf20Sopenharmony_ci * An ishtp_cl_device pointer is returned from ishtp_add_device()
338c2ecf20Sopenharmony_ci * and links ISHTP bus clients to their actual host client pointer.
348c2ecf20Sopenharmony_ci * Drivers for ISHTP devices will get an ishtp_cl_device pointer
358c2ecf20Sopenharmony_ci * when being probed and shall use it for doing bus I/O.
368c2ecf20Sopenharmony_ci */
378c2ecf20Sopenharmony_cistruct ishtp_cl_device {
388c2ecf20Sopenharmony_ci	struct device		dev;
398c2ecf20Sopenharmony_ci	struct ishtp_device	*ishtp_dev;
408c2ecf20Sopenharmony_ci	struct ishtp_fw_client	*fw_client;
418c2ecf20Sopenharmony_ci	struct list_head	device_link;
428c2ecf20Sopenharmony_ci	struct work_struct	event_work;
438c2ecf20Sopenharmony_ci	void			*driver_data;
448c2ecf20Sopenharmony_ci	int			reference_count;
458c2ecf20Sopenharmony_ci	void (*event_cb)(struct ishtp_cl_device *device);
468c2ecf20Sopenharmony_ci};
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ciint	ishtp_bus_new_client(struct ishtp_device *dev);
498c2ecf20Sopenharmony_civoid	ishtp_remove_all_clients(struct ishtp_device *dev);
508c2ecf20Sopenharmony_ciint	ishtp_cl_device_bind(struct ishtp_cl *cl);
518c2ecf20Sopenharmony_civoid	ishtp_cl_bus_rx_event(struct ishtp_cl_device *device);
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci/* Write a multi-fragment message */
548c2ecf20Sopenharmony_ciint	ishtp_send_msg(struct ishtp_device *dev,
558c2ecf20Sopenharmony_ci		       struct ishtp_msg_hdr *hdr, void *msg,
568c2ecf20Sopenharmony_ci		       void (*ipc_send_compl)(void *),
578c2ecf20Sopenharmony_ci		       void *ipc_send_compl_prm);
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci/* Write a single-fragment message */
608c2ecf20Sopenharmony_ciint	ishtp_write_message(struct ishtp_device *dev,
618c2ecf20Sopenharmony_ci			    struct ishtp_msg_hdr *hdr,
628c2ecf20Sopenharmony_ci			    void *buf);
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci/* Use DMA to send/receive messages */
658c2ecf20Sopenharmony_ciint ishtp_use_dma_transfer(void);
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci/* Exported functions */
688c2ecf20Sopenharmony_civoid	ishtp_bus_remove_all_clients(struct ishtp_device *ishtp_dev,
698c2ecf20Sopenharmony_ci				     bool warm_reset);
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_civoid	ishtp_recv(struct ishtp_device *dev);
728c2ecf20Sopenharmony_civoid	ishtp_reset_handler(struct ishtp_device *dev);
738c2ecf20Sopenharmony_civoid	ishtp_reset_compl_handler(struct ishtp_device *dev);
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ciint	ishtp_fw_cl_by_uuid(struct ishtp_device *dev, const guid_t *cuuid);
768c2ecf20Sopenharmony_ci#endif /* _LINUX_ISHTP_CL_BUS_H */
77