whiterose

linux unikernel
Log | Files | Refs | README | LICENSE | git clone https://git.ne02ptzero.me/git/whiterose

bus.h (4082B)


      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 
     21 struct ishtp_cl;
     22 struct ishtp_cl_device;
     23 struct ishtp_device;
     24 struct ishtp_msg_hdr;
     25 
     26 /**
     27  * struct ishtp_cl_device - ISHTP device handle
     28  * @dev:	device pointer
     29  * @ishtp_dev:	pointer to ishtp device structure to primarily to access
     30  *		hw device operation callbacks and properties
     31  * @fw_client:	fw_client pointer to get fw information like protocol name
     32  *		max message length etc.
     33  * @device_link: Link to next client in the list on a bus
     34  * @event_work:	Used to schedule rx event for client
     35  * @driver_data: Storage driver private data
     36  * @reference_count:	Used for get/put device
     37  * @event_cb:	Callback to driver to send events
     38  *
     39  * An ishtp_cl_device pointer is returned from ishtp_add_device()
     40  * and links ISHTP bus clients to their actual host client pointer.
     41  * Drivers for ISHTP devices will get an ishtp_cl_device pointer
     42  * when being probed and shall use it for doing bus I/O.
     43  */
     44 struct ishtp_cl_device {
     45 	struct device		dev;
     46 	struct ishtp_device	*ishtp_dev;
     47 	struct ishtp_fw_client	*fw_client;
     48 	struct list_head	device_link;
     49 	struct work_struct	event_work;
     50 	void			*driver_data;
     51 	int			reference_count;
     52 	void (*event_cb)(struct ishtp_cl_device *device);
     53 };
     54 
     55 /**
     56  * struct ishtp_cl_device - ISHTP device handle
     57  * @driver:	driver instance on a bus
     58  * @name:	Name of the device for probe
     59  * @probe:	driver callback for device probe
     60  * @remove:	driver callback on device removal
     61  *
     62  * Client drivers defines to get probed/removed for ISHTP client device.
     63  */
     64 struct ishtp_cl_driver {
     65 	struct device_driver driver;
     66 	const char *name;
     67 	int (*probe)(struct ishtp_cl_device *dev);
     68 	int (*remove)(struct ishtp_cl_device *dev);
     69 	int (*reset)(struct ishtp_cl_device *dev);
     70 	const struct dev_pm_ops *pm;
     71 };
     72 
     73 
     74 int	ishtp_bus_new_client(struct ishtp_device *dev);
     75 void	ishtp_remove_all_clients(struct ishtp_device *dev);
     76 int	ishtp_cl_device_bind(struct ishtp_cl *cl);
     77 void	ishtp_cl_bus_rx_event(struct ishtp_cl_device *device);
     78 
     79 /* Write a multi-fragment message */
     80 int	ishtp_send_msg(struct ishtp_device *dev,
     81 		       struct ishtp_msg_hdr *hdr, void *msg,
     82 		       void (*ipc_send_compl)(void *),
     83 		       void *ipc_send_compl_prm);
     84 
     85 /* Write a single-fragment message */
     86 int	ishtp_write_message(struct ishtp_device *dev,
     87 			    struct ishtp_msg_hdr *hdr,
     88 			    void *buf);
     89 
     90 /* Use DMA to send/receive messages */
     91 int ishtp_use_dma_transfer(void);
     92 
     93 /* Exported functions */
     94 void	ishtp_bus_remove_all_clients(struct ishtp_device *ishtp_dev,
     95 				     bool warm_reset);
     96 
     97 void	ishtp_recv(struct ishtp_device *dev);
     98 void	ishtp_reset_handler(struct ishtp_device *dev);
     99 void	ishtp_reset_compl_handler(struct ishtp_device *dev);
    100 
    101 void	ishtp_put_device(struct ishtp_cl_device *);
    102 void	ishtp_get_device(struct ishtp_cl_device *);
    103 
    104 void	ishtp_set_drvdata(struct ishtp_cl_device *cl_device, void *data);
    105 void	*ishtp_get_drvdata(struct ishtp_cl_device *cl_device);
    106 
    107 int	__ishtp_cl_driver_register(struct ishtp_cl_driver *driver,
    108 				   struct module *owner);
    109 #define ishtp_cl_driver_register(driver)		\
    110 	__ishtp_cl_driver_register(driver, THIS_MODULE)
    111 void	ishtp_cl_driver_unregister(struct ishtp_cl_driver *driver);
    112 
    113 int	ishtp_register_event_cb(struct ishtp_cl_device *device,
    114 				void (*read_cb)(struct ishtp_cl_device *));
    115 int	ishtp_fw_cl_by_uuid(struct ishtp_device *dev, const guid_t *cuuid);
    116 struct	ishtp_fw_client *ishtp_fw_cl_get_client(struct ishtp_device *dev,
    117 						const guid_t *uuid);
    118 
    119 #endif /* _LINUX_ISHTP_CL_BUS_H */