vme_bridge.h 5.0 KB

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