at v5.3 2.8 kB view raw
1/* SPDX-License-Identifier: GPL-2.0-only */ 2/* 3 * Intel MIC Platform Software Stack (MPSS) 4 * 5 * Copyright(c) 2014 Intel Corporation. 6 * 7 * Intel MIC Bus driver. 8 * 9 * This implementation is very similar to the the virtio bus driver 10 * implementation @ include/linux/virtio.h. 11 */ 12#ifndef _MIC_BUS_H_ 13#define _MIC_BUS_H_ 14/* 15 * Everything a mbus driver needs to work with any particular mbus 16 * implementation. 17 */ 18#include <linux/interrupt.h> 19#include <linux/dma-mapping.h> 20 21struct mbus_device_id { 22 __u32 device; 23 __u32 vendor; 24}; 25 26#define MBUS_DEV_DMA_HOST 2 27#define MBUS_DEV_DMA_MIC 3 28#define MBUS_DEV_ANY_ID 0xffffffff 29 30/** 31 * mbus_device - representation of a device using mbus 32 * @mmio_va: virtual address of mmio space 33 * @hw_ops: the hardware ops supported by this device. 34 * @id: the device type identification (used to match it with a driver). 35 * @dev: underlying device. 36 * be used to communicate with. 37 * @index: unique position on the mbus bus 38 */ 39struct mbus_device { 40 void __iomem *mmio_va; 41 struct mbus_hw_ops *hw_ops; 42 struct mbus_device_id id; 43 struct device dev; 44 int index; 45}; 46 47/** 48 * mbus_driver - operations for a mbus I/O driver 49 * @driver: underlying device driver (populate name and owner). 50 * @id_table: the ids serviced by this driver. 51 * @probe: the function to call when a device is found. Returns 0 or -errno. 52 * @remove: the function to call when a device is removed. 53 */ 54struct mbus_driver { 55 struct device_driver driver; 56 const struct mbus_device_id *id_table; 57 int (*probe)(struct mbus_device *dev); 58 void (*scan)(struct mbus_device *dev); 59 void (*remove)(struct mbus_device *dev); 60}; 61 62/** 63 * struct mic_irq - opaque pointer used as cookie 64 */ 65struct mic_irq; 66 67/** 68 * mbus_hw_ops - Hardware operations for accessing a MIC device on the MIC bus. 69 */ 70struct mbus_hw_ops { 71 struct mic_irq* (*request_threaded_irq)(struct mbus_device *mbdev, 72 irq_handler_t handler, 73 irq_handler_t thread_fn, 74 const char *name, void *data, 75 int intr_src); 76 void (*free_irq)(struct mbus_device *mbdev, 77 struct mic_irq *cookie, void *data); 78 void (*ack_interrupt)(struct mbus_device *mbdev, int num); 79}; 80 81struct mbus_device * 82mbus_register_device(struct device *pdev, int id, const struct dma_map_ops *dma_ops, 83 struct mbus_hw_ops *hw_ops, int index, 84 void __iomem *mmio_va); 85void mbus_unregister_device(struct mbus_device *mbdev); 86 87int mbus_register_driver(struct mbus_driver *drv); 88void mbus_unregister_driver(struct mbus_driver *drv); 89 90static inline struct mbus_device *dev_to_mbus(struct device *_dev) 91{ 92 return container_of(_dev, struct mbus_device, dev); 93} 94 95static inline struct mbus_driver *drv_to_mbus(struct device_driver *drv) 96{ 97 return container_of(drv, struct mbus_driver, driver); 98} 99 100#endif /* _MIC_BUS_H */