ixdp2800.c 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. /*
  2. * arch/arm/mach-ixp2000/ixdp2800.c
  3. *
  4. * IXDP2800 platform support
  5. *
  6. * Original Author: Jeffrey Daly <jeffrey.daly@intel.com>
  7. * Maintainer: Deepak Saxena <dsaxena@plexity.net>
  8. *
  9. * Copyright (C) 2002 Intel Corp.
  10. * Copyright (C) 2003-2004 MontaVista Software, Inc.
  11. *
  12. * This program is free software; you can redistribute it and/or modify it
  13. * under the terms of the GNU General Public License as published by the
  14. * Free Software Foundation; either version 2 of the License, or (at your
  15. * option) any later version.
  16. */
  17. #include <linux/config.h>
  18. #include <linux/kernel.h>
  19. #include <linux/init.h>
  20. #include <linux/mm.h>
  21. #include <linux/sched.h>
  22. #include <linux/interrupt.h>
  23. #include <linux/device.h>
  24. #include <linux/bitops.h>
  25. #include <linux/pci.h>
  26. #include <linux/ioport.h>
  27. #include <linux/slab.h>
  28. #include <linux/delay.h>
  29. #include <asm/io.h>
  30. #include <asm/irq.h>
  31. #include <asm/pgtable.h>
  32. #include <asm/page.h>
  33. #include <asm/system.h>
  34. #include <asm/hardware.h>
  35. #include <asm/mach-types.h>
  36. #include <asm/mach/pci.h>
  37. #include <asm/mach/map.h>
  38. #include <asm/mach/irq.h>
  39. #include <asm/mach/time.h>
  40. #include <asm/mach/flash.h>
  41. #include <asm/mach/arch.h>
  42. /*************************************************************************
  43. * IXDP2800 timer tick
  44. *************************************************************************/
  45. static void __init ixdp2800_timer_init(void)
  46. {
  47. ixp2000_init_time(50000000);
  48. }
  49. static struct sys_timer ixdp2800_timer = {
  50. .init = ixdp2800_timer_init,
  51. .offset = ixp2000_gettimeoffset,
  52. };
  53. /*************************************************************************
  54. * IXDP2800 PCI
  55. *************************************************************************/
  56. static void __init ixdp2800_slave_disable_pci_master(void)
  57. {
  58. *IXP2000_PCI_CMDSTAT &= ~(PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY);
  59. }
  60. static void __init ixdp2800_master_wait_for_slave(void)
  61. {
  62. volatile u32 *addr;
  63. printk(KERN_INFO "IXDP2800: waiting for slave NPU to configure "
  64. "its BAR sizes\n");
  65. addr = ixp2000_pci_config_addr(0, IXDP2X00_SLAVE_NPU_DEVFN,
  66. PCI_BASE_ADDRESS_1);
  67. do {
  68. *addr = 0xffffffff;
  69. cpu_relax();
  70. } while (*addr != 0xfe000008);
  71. addr = ixp2000_pci_config_addr(0, IXDP2X00_SLAVE_NPU_DEVFN,
  72. PCI_BASE_ADDRESS_2);
  73. do {
  74. *addr = 0xffffffff;
  75. cpu_relax();
  76. } while (*addr != 0xc0000008);
  77. /*
  78. * Configure the slave's SDRAM BAR by hand.
  79. */
  80. *addr = 0x40000008;
  81. }
  82. static void __init ixdp2800_slave_wait_for_master_enable(void)
  83. {
  84. printk(KERN_INFO "IXDP2800: waiting for master NPU to enable us\n");
  85. while ((*IXP2000_PCI_CMDSTAT & PCI_COMMAND_MASTER) == 0)
  86. cpu_relax();
  87. }
  88. void __init ixdp2800_pci_preinit(void)
  89. {
  90. printk("ixdp2x00_pci_preinit called\n");
  91. *IXP2000_PCI_ADDR_EXT = 0x0001e000;
  92. if (!ixdp2x00_master_npu())
  93. ixdp2800_slave_disable_pci_master();
  94. *IXP2000_PCI_SRAM_BASE_ADDR_MASK = (0x2000000 - 1) & ~0x3ffff;
  95. *IXP2000_PCI_DRAM_BASE_ADDR_MASK = (0x40000000 - 1) & ~0xfffff;
  96. ixp2000_pci_preinit();
  97. if (ixdp2x00_master_npu()) {
  98. /*
  99. * Wait until the slave set its SRAM/SDRAM BAR sizes
  100. * correctly before we proceed to scan and enumerate
  101. * the bus.
  102. */
  103. ixdp2800_master_wait_for_slave();
  104. /*
  105. * We configure the SDRAM BARs by hand because they
  106. * are 1G and fall outside of the regular allocated
  107. * PCI address space.
  108. */
  109. *IXP2000_PCI_SDRAM_BAR = 0x00000008;
  110. } else {
  111. /*
  112. * Wait for the master to complete scanning the bus
  113. * and assigning resources before we proceed to scan
  114. * the bus ourselves. Set pci=firmware to honor the
  115. * master's resource assignment.
  116. */
  117. ixdp2800_slave_wait_for_master_enable();
  118. pcibios_setup("firmware");
  119. }
  120. }
  121. /*
  122. * We assign the SDRAM BARs for the two IXP2800 CPUs by hand, outside
  123. * of the regular PCI window, because there's only 512M of outbound PCI
  124. * memory window on each IXP, while we need 1G for each of the BARs.
  125. */
  126. static void __devinit ixp2800_pci_fixup(struct pci_dev *dev)
  127. {
  128. if (machine_is_ixdp2800()) {
  129. dev->resource[2].start = 0;
  130. dev->resource[2].end = 0;
  131. dev->resource[2].flags = 0;
  132. }
  133. }
  134. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_IXP2800, ixp2800_pci_fixup);
  135. static int __init ixdp2800_pci_setup(int nr, struct pci_sys_data *sys)
  136. {
  137. sys->mem_offset = 0x00000000;
  138. ixp2000_pci_setup(nr, sys);
  139. return 1;
  140. }
  141. static int __init ixdp2800_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  142. {
  143. if (ixdp2x00_master_npu()) {
  144. /*
  145. * Root bus devices. Slave NPU is only one with interrupt.
  146. * Everything else, we just return -1 which is invalid.
  147. */
  148. if(!dev->bus->self) {
  149. if(dev->devfn == IXDP2X00_SLAVE_NPU_DEVFN )
  150. return IRQ_IXDP2800_INGRESS_NPU;
  151. return -1;
  152. }
  153. /*
  154. * Bridge behind the PMC slot.
  155. */
  156. if(dev->bus->self->devfn == IXDP2X00_PMC_DEVFN &&
  157. dev->bus->parent->self->devfn == IXDP2X00_P2P_DEVFN &&
  158. !dev->bus->parent->self->bus->parent)
  159. return IRQ_IXDP2800_PMC;
  160. /*
  161. * Device behind the first bridge
  162. */
  163. if(dev->bus->self->devfn == IXDP2X00_P2P_DEVFN) {
  164. switch(dev->devfn) {
  165. case IXDP2X00_PMC_DEVFN:
  166. return IRQ_IXDP2800_PMC;
  167. case IXDP2800_MASTER_ENET_DEVFN:
  168. return IRQ_IXDP2800_EGRESS_ENET;
  169. case IXDP2800_SWITCH_FABRIC_DEVFN:
  170. return IRQ_IXDP2800_FABRIC;
  171. }
  172. }
  173. return -1;
  174. } else return IRQ_IXP2000_PCIB; /* Slave NIC interrupt */
  175. }
  176. static void __init ixdp2800_master_enable_slave(void)
  177. {
  178. volatile u32 *addr;
  179. printk(KERN_INFO "IXDP2800: enabling slave NPU\n");
  180. addr = (volatile u32 *)ixp2000_pci_config_addr(0,
  181. IXDP2X00_SLAVE_NPU_DEVFN,
  182. PCI_COMMAND);
  183. *addr |= PCI_COMMAND_MASTER;
  184. }
  185. static void __init ixdp2800_master_wait_for_slave_bus_scan(void)
  186. {
  187. volatile u32 *addr;
  188. printk(KERN_INFO "IXDP2800: waiting for slave to finish bus scan\n");
  189. addr = (volatile u32 *)ixp2000_pci_config_addr(0,
  190. IXDP2X00_SLAVE_NPU_DEVFN,
  191. PCI_COMMAND);
  192. while ((*addr & PCI_COMMAND_MEMORY) == 0)
  193. cpu_relax();
  194. }
  195. static void __init ixdp2800_slave_signal_bus_scan_completion(void)
  196. {
  197. printk(KERN_INFO "IXDP2800: bus scan done, signaling master\n");
  198. *IXP2000_PCI_CMDSTAT |= PCI_COMMAND_MEMORY;
  199. }
  200. static void __init ixdp2800_pci_postinit(void)
  201. {
  202. if (!ixdp2x00_master_npu()) {
  203. ixdp2x00_slave_pci_postinit();
  204. ixdp2800_slave_signal_bus_scan_completion();
  205. }
  206. }
  207. struct __initdata hw_pci ixdp2800_pci __initdata = {
  208. .nr_controllers = 1,
  209. .setup = ixdp2800_pci_setup,
  210. .preinit = ixdp2800_pci_preinit,
  211. .postinit = ixdp2800_pci_postinit,
  212. .scan = ixp2000_pci_scan_bus,
  213. .map_irq = ixdp2800_pci_map_irq,
  214. };
  215. int __init ixdp2800_pci_init(void)
  216. {
  217. if (machine_is_ixdp2800()) {
  218. struct pci_dev *dev;
  219. pci_common_init(&ixdp2800_pci);
  220. if (ixdp2x00_master_npu()) {
  221. dev = pci_find_slot(1, IXDP2800_SLAVE_ENET_DEVFN);
  222. pci_remove_bus_device(dev);
  223. ixdp2800_master_enable_slave();
  224. ixdp2800_master_wait_for_slave_bus_scan();
  225. } else {
  226. dev = pci_find_slot(1, IXDP2800_MASTER_ENET_DEVFN);
  227. pci_remove_bus_device(dev);
  228. }
  229. }
  230. return 0;
  231. }
  232. subsys_initcall(ixdp2800_pci_init);
  233. void ixdp2800_init_irq(void)
  234. {
  235. ixdp2x00_init_irq(IXDP2800_CPLD_INT_STAT, IXDP2800_CPLD_INT_MASK, IXDP2800_NR_IRQS);
  236. }
  237. MACHINE_START(IXDP2800, "Intel IXDP2800 Development Platform")
  238. /* Maintainer: MontaVista Software, Inc. */
  239. .phys_ram = 0x00000000,
  240. .phys_io = IXP2000_UART_PHYS_BASE,
  241. .io_pg_offst = ((IXP2000_UART_VIRT_BASE) >> 18) & 0xfffc,
  242. .boot_params = 0x00000100,
  243. .map_io = ixdp2x00_map_io,
  244. .init_irq = ixdp2800_init_irq,
  245. .timer = &ixdp2800_timer,
  246. .init_machine = ixdp2x00_init_machine,
  247. MACHINE_END