vme_bridge.h 5.1 KB

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