gt64260.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. /*
  2. * include/asm-ppc/gt64260.h
  3. *
  4. * Prototypes, etc. for the Marvell/Galileo GT64260 host bridge routines.
  5. *
  6. * Author: Mark A. Greer <mgreer@mvista.com>
  7. *
  8. * 2001 (c) MontaVista, Software, Inc. This file is licensed under
  9. * the terms of the GNU General Public License version 2. This program
  10. * is licensed "as is" without any warranty of any kind, whether express
  11. * or implied.
  12. */
  13. #ifndef __ASMPPC_GT64260_H
  14. #define __ASMPPC_GT64260_H
  15. #include <linux/kernel.h>
  16. #include <linux/init.h>
  17. #include <linux/pci.h>
  18. #include <linux/slab.h>
  19. #include <asm/byteorder.h>
  20. #include <asm/io.h>
  21. #include <asm/irq.h>
  22. #include <asm/uaccess.h>
  23. #include <asm/machdep.h>
  24. #include <asm/pci-bridge.h>
  25. #include <asm/gt64260_defs.h>
  26. extern u32 gt64260_base;
  27. extern u32 gt64260_irq_base; /* We handle the next 96 IRQs from here */
  28. extern u32 gt64260_revision;
  29. extern u8 gt64260_pci_exclude_bridge;
  30. #ifndef TRUE
  31. #define TRUE 1
  32. #endif
  33. #ifndef FALSE
  34. #define FALSE 0
  35. #endif
  36. /* IRQs defined by the 64260 */
  37. #define GT64260_IRQ_MPSC0 40
  38. #define GT64260_IRQ_MPSC1 42
  39. #define GT64260_IRQ_SDMA 36
  40. /*
  41. * Define a default physical memory map to be set up on the bridge.
  42. * Also define a struct to pass that info from board-specific routines to
  43. * GT64260 generic set up routines. By passing this info in, the board
  44. * support developer can modify it at will.
  45. */
  46. /*
  47. * This is the default memory map:
  48. * CPU PCI
  49. * --- ---
  50. * PCI 0 I/O: 0xfa000000-0xfaffffff 0x00000000-0x00ffffff
  51. * PCI 1 I/O: 0xfb000000-0xfbffffff 0x01000000-0x01ffffff
  52. * PCI 0 MEM: 0x80000000-0x8fffffff 0x80000000-0x8fffffff
  53. * PCI 1 MEM: 0x90000000-0x9fffffff 0x90000000-0x9fffffff
  54. */
  55. /* Default physical memory map for the GT64260 bridge */
  56. /*
  57. * PCI Bus 0 Definitions
  58. */
  59. #define GT64260_PCI_0_IO_SIZE 0x01000000U
  60. #define GT64260_PCI_0_MEM_SIZE 0x10000000U
  61. /* Processor Physical addresses */
  62. #define GT64260_PCI_0_IO_START_PROC 0xfa000000U
  63. #define GT64260_PCI_0_IO_END_PROC (GT64260_PCI_0_IO_START_PROC + \
  64. GT64260_PCI_0_IO_SIZE - 1)
  65. /* PCI 0 addresses */
  66. #define GT64260_PCI_0_IO_START 0x00000000U
  67. #define GT64260_PCI_0_IO_END (GT64260_PCI_0_IO_START + \
  68. GT64260_PCI_0_IO_SIZE - 1)
  69. /* Processor Physical addresses */
  70. #define GT64260_PCI_0_MEM_START_PROC 0x80000000U
  71. #define GT64260_PCI_0_MEM_END_PROC (GT64260_PCI_0_MEM_START_PROC + \
  72. GT64260_PCI_0_MEM_SIZE - 1)
  73. /* PCI 0 addresses */
  74. #define GT64260_PCI_0_MEM_START 0x80000000U
  75. #define GT64260_PCI_0_MEM_END (GT64260_PCI_0_MEM_START + \
  76. GT64260_PCI_0_MEM_SIZE - 1)
  77. /*
  78. * PCI Bus 1 Definitions
  79. */
  80. #define GT64260_PCI_1_IO_SIZE 0x01000000U
  81. #define GT64260_PCI_1_MEM_SIZE 0x10000000U
  82. /* PCI 1 addresses */
  83. #define GT64260_PCI_1_IO_START 0x01000000U
  84. #define GT64260_PCI_1_IO_END (GT64260_PCI_1_IO_START + \
  85. GT64260_PCI_1_IO_SIZE - 1)
  86. /* Processor Physical addresses */
  87. #define GT64260_PCI_1_IO_START_PROC 0xfb000000U
  88. #define GT64260_PCI_1_IO_END_PROC (GT64260_PCI_1_IO_START_PROC + \
  89. GT64260_PCI_1_IO_SIZE - 1)
  90. /* PCI 1 addresses */
  91. #define GT64260_PCI_1_MEM_START 0x90000000U
  92. #define GT64260_PCI_1_MEM_END (GT64260_PCI_1_MEM_START + \
  93. GT64260_PCI_1_MEM_SIZE - 1)
  94. /* Processor Physical addresses */
  95. #define GT64260_PCI_1_MEM_START_PROC 0x90000000U
  96. #define GT64260_PCI_1_MEM_END_PROC (GT64260_PCI_1_MEM_START_PROC + \
  97. GT64260_PCI_1_MEM_SIZE - 1)
  98. /* Define struct to pass mem-map info into gt64260_common.c code */
  99. typedef struct {
  100. struct pci_controller *hose_a;
  101. struct pci_controller *hose_b;
  102. u32 mem_size;
  103. u32 pci_0_io_start_proc;
  104. u32 pci_0_io_start_pci;
  105. u32 pci_0_io_size;
  106. u32 pci_0_io_swap;
  107. u32 pci_0_mem_start_proc;
  108. u32 pci_0_mem_start_pci_hi;
  109. u32 pci_0_mem_start_pci_lo;
  110. u32 pci_0_mem_size;
  111. u32 pci_0_mem_swap;
  112. u32 pci_1_io_start_proc;
  113. u32 pci_1_io_start_pci;
  114. u32 pci_1_io_size;
  115. u32 pci_1_io_swap;
  116. u32 pci_1_mem_start_proc;
  117. u32 pci_1_mem_start_pci_hi;
  118. u32 pci_1_mem_start_pci_lo;
  119. u32 pci_1_mem_size;
  120. u32 pci_1_mem_swap;
  121. } gt64260_bridge_info_t;
  122. #define GT64260_BRIDGE_INFO_DEFAULT(ip, ms) { \
  123. (ip)->mem_size = (ms); \
  124. \
  125. (ip)->pci_0_io_start_proc = GT64260_PCI_0_IO_START_PROC; \
  126. (ip)->pci_0_io_start_pci = GT64260_PCI_0_IO_START; \
  127. (ip)->pci_0_io_size = GT64260_PCI_0_IO_SIZE; \
  128. (ip)->pci_0_io_swap = GT64260_CPU_PCI_SWAP_NONE; \
  129. \
  130. (ip)->pci_0_mem_start_proc = GT64260_PCI_0_MEM_START_PROC; \
  131. (ip)->pci_0_mem_start_pci_hi = 0x00000000; \
  132. (ip)->pci_0_mem_start_pci_lo = GT64260_PCI_0_MEM_START; \
  133. (ip)->pci_0_mem_size = GT64260_PCI_0_MEM_SIZE; \
  134. (ip)->pci_0_mem_swap = GT64260_CPU_PCI_SWAP_NONE; \
  135. \
  136. (ip)->pci_1_io_start_proc = GT64260_PCI_1_IO_START_PROC; \
  137. (ip)->pci_1_io_start_pci = GT64260_PCI_1_IO_START; \
  138. (ip)->pci_1_io_size = GT64260_PCI_1_IO_SIZE; \
  139. (ip)->pci_1_io_swap = GT64260_CPU_PCI_SWAP_NONE; \
  140. \
  141. (ip)->pci_1_mem_start_proc = GT64260_PCI_1_MEM_START_PROC; \
  142. (ip)->pci_1_mem_start_pci_hi = 0x00000000; \
  143. (ip)->pci_1_mem_start_pci_lo = GT64260_PCI_1_MEM_START; \
  144. (ip)->pci_1_mem_size = GT64260_PCI_1_MEM_SIZE; \
  145. (ip)->pci_1_mem_swap = GT64260_CPU_PCI_SWAP_NONE; \
  146. }
  147. /*
  148. *****************************************************************************
  149. *
  150. * I/O macros to access the 64260's registers
  151. *
  152. *****************************************************************************
  153. */
  154. extern inline uint32_t gt_read(uint32_t offs){
  155. return (in_le32((volatile uint *)(gt64260_base + offs)));
  156. }
  157. extern inline void gt_write(uint32_t offs, uint32_t d){
  158. out_le32((volatile uint *)(gt64260_base + offs), d);
  159. }
  160. #if 0 /* paranoid SMP version */
  161. extern inline void gt_modify(u32 offs, u32 data, u32 mask) \
  162. {
  163. uint32_t reg;
  164. spin_lock(&gt64260_lock);
  165. reg = gt_read(offs) & (~mask); /* zero any bits we care about*/
  166. reg |= data & mask; /* set bits from the data */
  167. gt_write(offs, reg);
  168. spin_unlock(&gt64260_lock);
  169. }
  170. #else
  171. extern inline void gt_modify(uint32_t offs, uint32_t data, uint32_t mask)
  172. {
  173. uint32_t reg;
  174. reg = gt_read(offs) & (~(mask)); /* zero any bits we care about*/
  175. reg |= (data) & (mask); /* set bits from the data */
  176. gt_write(offs, reg);
  177. }
  178. #endif
  179. #define gt_set_bits(offs, bits) gt_modify(offs, ~0, bits)
  180. #define gt_clr_bits(offs, bits) gt_modify(offs, 0, bits)
  181. /*
  182. *****************************************************************************
  183. *
  184. * Function Prototypes
  185. *
  186. *****************************************************************************
  187. */
  188. int gt64260_find_bridges(u32 phys_base_addr, gt64260_bridge_info_t *info,
  189. int ((*map_irq)(struct pci_dev *, unsigned char, unsigned char)));
  190. int gt64260_bridge_init(gt64260_bridge_info_t *info);
  191. int gt64260_cpu_scs_set_window(u32 window,
  192. u32 base_addr,
  193. u32 size);
  194. int gt64260_cpu_cs_set_window(u32 window,
  195. u32 base_addr,
  196. u32 size);
  197. int gt64260_cpu_boot_set_window(u32 base_addr,
  198. u32 size);
  199. int gt64260_cpu_set_pci_io_window(u32 pci_bus,
  200. u32 cpu_base_addr,
  201. u32 pci_base_addr,
  202. u32 size,
  203. u32 swap);
  204. int gt64260_cpu_set_pci_mem_window(u32 pci_bus,
  205. u32 window,
  206. u32 cpu_base_addr,
  207. u32 pci_base_addr_hi,
  208. u32 pci_base_addr_lo,
  209. u32 size,
  210. u32 swap_64bit);
  211. int gt64260_cpu_prot_set_window(u32 window,
  212. u32 base_addr,
  213. u32 size,
  214. u32 access_bits);
  215. int gt64260_cpu_snoop_set_window(u32 window,
  216. u32 base_addr,
  217. u32 size,
  218. u32 snoop_type);
  219. void gt64260_cpu_disable_all_windows(void);
  220. int gt64260_pci_bar_enable(u32 pci_bus, u32 enable_bits);
  221. int gt64260_pci_slave_scs_set_window(struct pci_controller *hose,
  222. u32 window,
  223. u32 pci_base_addr,
  224. u32 cpu_base_addr,
  225. u32 size);
  226. int gt64260_pci_slave_cs_set_window(struct pci_controller *hose,
  227. u32 window,
  228. u32 pci_base_addr,
  229. u32 cpu_base_addr,
  230. u32 size);
  231. int gt64260_pci_slave_boot_set_window(struct pci_controller *hose,
  232. u32 pci_base_addr,
  233. u32 cpu_base_addr,
  234. u32 size);
  235. int gt64260_pci_slave_p2p_mem_set_window(struct pci_controller *hose,
  236. u32 window,
  237. u32 pci_base_addr,
  238. u32 other_bus_base_addr,
  239. u32 size);
  240. int gt64260_pci_slave_p2p_io_set_window(struct pci_controller *hose,
  241. u32 pci_base_addr,
  242. u32 other_bus_base_addr,
  243. u32 size);
  244. int gt64260_pci_slave_dac_scs_set_window(struct pci_controller *hose,
  245. u32 window,
  246. u32 pci_base_addr_hi,
  247. u32 pci_base_addr_lo,
  248. u32 cpu_base_addr,
  249. u32 size);
  250. int gt64260_pci_slave_dac_cs_set_window(struct pci_controller *hose,
  251. u32 window,
  252. u32 pci_base_addr_hi,
  253. u32 pci_base_addr_lo,
  254. u32 cpu_base_addr,
  255. u32 size);
  256. int gt64260_pci_slave_dac_boot_set_window(struct pci_controller *hose,
  257. u32 pci_base_addr_hi,
  258. u32 pci_base_addr_lo,
  259. u32 cpu_base_addr,
  260. u32 size);
  261. int gt64260_pci_slave_dac_p2p_mem_set_window(struct pci_controller *hose,
  262. u32 window,
  263. u32 pci_base_addr_hi,
  264. u32 pci_base_addr_lo,
  265. u32 other_bus_base_addr,
  266. u32 size);
  267. int gt64260_pci_acc_cntl_set_window(u32 pci_bus,
  268. u32 window,
  269. u32 base_addr_hi,
  270. u32 base_addr_lo,
  271. u32 size,
  272. u32 features);
  273. int gt64260_pci_snoop_set_window(u32 pci_bus,
  274. u32 window,
  275. u32 base_addr_hi,
  276. u32 base_addr_lo,
  277. u32 size,
  278. u32 snoop_type);
  279. int gt64260_set_base(u32 new_base);
  280. int gt64260_get_base(u32 *base);
  281. int gt64260_pci_exclude_device(u8 bus, u8 devfn);
  282. void gt64260_init_irq(void);
  283. int gt64260_get_irq(void);
  284. void gt64260_mpsc_progress(char *s, unsigned short hex);
  285. #endif /* __ASMPPC_GT64260_H */