ixdp2800.c 7.4 KB

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