ixdp2800.c 7.3 KB

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