Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) #ifndef _VME_BRIDGE_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) #define _VME_BRIDGE_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) #include <linux/vme.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #define VME_CRCSR_BUF_SIZE (508*1024)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * Resource structures
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) struct vme_master_resource {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 	struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 	struct vme_bridge *parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 	 * We are likely to need to access the VME bus in interrupt context, so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 	 * protect master routines with a spinlock rather than a mutex.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 	spinlock_t lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 	int locked;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 	int number;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	u32 address_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	u32 cycle_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	u32 width_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	struct resource bus_resource;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	void __iomem *kern_base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) struct vme_slave_resource {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	struct vme_bridge *parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	struct mutex mtx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	int locked;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	int number;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	u32 address_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	u32 cycle_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) struct vme_dma_pattern {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	u32 pattern;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	u32 type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) struct vme_dma_pci {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	dma_addr_t address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) struct vme_dma_vme {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	unsigned long long address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	u32 aspace;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	u32 cycle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	u32 dwidth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) struct vme_dma_list {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	struct vme_dma_resource *parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	struct list_head entries;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	struct mutex mtx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) struct vme_dma_resource {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	struct vme_bridge *parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	struct mutex mtx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	int locked;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	int number;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	struct list_head pending;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	struct list_head running;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	u32 route_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) struct vme_lm_resource {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	struct vme_bridge *parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	struct mutex mtx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	int locked;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	int number;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	int monitors;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) struct vme_error_handler {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	unsigned long long start;	/* Beginning of error window */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	unsigned long long end;		/* End of error window */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	unsigned long long first_error;	/* Address of the first error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	u32 aspace;			/* Address space of error window*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	unsigned num_errors;		/* Number of errors */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) struct vme_callback {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	void (*func)(int, int, void*);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	void *priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) struct vme_irq {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	int count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	struct vme_callback callback[VME_NUM_STATUSID];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) /* Allow 16 characters for name (including null character) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) #define VMENAMSIZ 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) /* This structure stores all the information about one bridge
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)  * The structure should be dynamically allocated by the driver and one instance
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)  * of the structure should be present for each VME chip present in the system.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) struct vme_bridge {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	char name[VMENAMSIZ];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	int num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	struct list_head master_resources;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	struct list_head slave_resources;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	struct list_head dma_resources;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	struct list_head lm_resources;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	/* List for registered errors handlers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	struct list_head vme_error_handlers;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	/* List of devices on this bridge */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	struct list_head devices;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	/* Bridge Info - XXX Move to private structure? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	struct device *parent;	/* Parent device (eg. pdev->dev for PCI) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	void *driver_priv;	/* Private pointer for the bridge driver */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	struct list_head bus_list; /* list of VME buses */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	/* Interrupt callbacks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	struct vme_irq irq[7];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	/* Locking for VME irq callback configuration */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	struct mutex irq_mtx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	/* Slave Functions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	int (*slave_get) (struct vme_slave_resource *, int *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 		unsigned long long *, unsigned long long *, dma_addr_t *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		u32 *, u32 *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	int (*slave_set) (struct vme_slave_resource *, int, unsigned long long,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 		unsigned long long, dma_addr_t, u32, u32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	/* Master Functions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	int (*master_get) (struct vme_master_resource *, int *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		unsigned long long *, unsigned long long *, u32 *, u32 *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 		u32 *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	int (*master_set) (struct vme_master_resource *, int,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		unsigned long long, unsigned long long,  u32, u32, u32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	ssize_t (*master_read) (struct vme_master_resource *, void *, size_t,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 		loff_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	ssize_t (*master_write) (struct vme_master_resource *, void *, size_t,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 		loff_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	unsigned int (*master_rmw) (struct vme_master_resource *, unsigned int,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 		unsigned int, unsigned int, loff_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	/* DMA Functions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	int (*dma_list_add) (struct vme_dma_list *, struct vme_dma_attr *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 		struct vme_dma_attr *, size_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	int (*dma_list_exec) (struct vme_dma_list *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	int (*dma_list_empty) (struct vme_dma_list *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	/* Interrupt Functions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	void (*irq_set) (struct vme_bridge *, int, int, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	int (*irq_generate) (struct vme_bridge *, int, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	/* Location monitor functions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	int (*lm_set) (struct vme_lm_resource *, unsigned long long, u32, u32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	int (*lm_get) (struct vme_lm_resource *, unsigned long long *, u32 *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 		u32 *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	int (*lm_attach)(struct vme_lm_resource *, int,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 			 void (*callback)(void *), void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	int (*lm_detach) (struct vme_lm_resource *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	/* CR/CSR space functions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	int (*slot_get) (struct vme_bridge *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	/* Bridge parent interface */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	void *(*alloc_consistent)(struct device *dev, size_t size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		dma_addr_t *dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	void (*free_consistent)(struct device *dev, size_t size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		void *vaddr, dma_addr_t dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) void vme_bus_error_handler(struct vme_bridge *bridge,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 			   unsigned long long address, int am);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) void vme_irq_handler(struct vme_bridge *, int, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) struct vme_bridge *vme_init_bridge(struct vme_bridge *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) int vme_register_bridge(struct vme_bridge *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) void vme_unregister_bridge(struct vme_bridge *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) struct vme_error_handler *vme_register_error_handler(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	struct vme_bridge *bridge, u32 aspace,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	unsigned long long address, size_t len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) void vme_unregister_error_handler(struct vme_error_handler *handler);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) #endif /* _VME_BRIDGE_H_ */