vme_bridge.h 4.4 KB

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