enp2611.c 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. /*
  2. * arch/arm/mach-ixp2000/enp2611.c
  3. *
  4. * Radisys ENP-2611 support.
  5. *
  6. * Created 2004 by Lennert Buytenhek from the ixdp2x01 code. The
  7. * original version carries the following notices:
  8. *
  9. * Original Author: Andrzej Mialkowski <andrzej.mialkowski@intel.com>
  10. * Maintainer: Deepak Saxena <dsaxena@plexity.net>
  11. *
  12. * Copyright (C) 2002-2003 Intel Corp.
  13. * Copyright (C) 2003-2004 MontaVista Software, Inc.
  14. *
  15. * This program is free software; you can redistribute it and/or modify it
  16. * under the terms of the GNU General Public License as published by the
  17. * Free Software Foundation; either version 2 of the License, or (at your
  18. * option) any later version.
  19. */
  20. #include <linux/kernel.h>
  21. #include <linux/init.h>
  22. #include <linux/mm.h>
  23. #include <linux/sched.h>
  24. #include <linux/interrupt.h>
  25. #include <linux/bitops.h>
  26. #include <linux/pci.h>
  27. #include <linux/ioport.h>
  28. #include <linux/delay.h>
  29. #include <linux/serial.h>
  30. #include <linux/tty.h>
  31. #include <linux/serial_core.h>
  32. #include <linux/platform_device.h>
  33. #include <linux/io.h>
  34. #include <asm/irq.h>
  35. #include <asm/pgtable.h>
  36. #include <asm/page.h>
  37. #include <asm/system.h>
  38. #include <mach/hardware.h>
  39. #include <asm/mach-types.h>
  40. #include <asm/mach/pci.h>
  41. #include <asm/mach/map.h>
  42. #include <asm/mach/irq.h>
  43. #include <asm/mach/time.h>
  44. #include <asm/mach/arch.h>
  45. #include <asm/mach/flash.h>
  46. /*************************************************************************
  47. * ENP-2611 timer tick configuration
  48. *************************************************************************/
  49. static void __init enp2611_timer_init(void)
  50. {
  51. ixp2000_init_time(50 * 1000 * 1000);
  52. }
  53. static struct sys_timer enp2611_timer = {
  54. .init = enp2611_timer_init,
  55. .offset = ixp2000_gettimeoffset,
  56. };
  57. /*************************************************************************
  58. * ENP-2611 I/O
  59. *************************************************************************/
  60. static struct map_desc enp2611_io_desc[] __initdata = {
  61. {
  62. .virtual = ENP2611_CALEB_VIRT_BASE,
  63. .pfn = __phys_to_pfn(ENP2611_CALEB_PHYS_BASE),
  64. .length = ENP2611_CALEB_SIZE,
  65. .type = MT_DEVICE,
  66. }, {
  67. .virtual = ENP2611_PM3386_0_VIRT_BASE,
  68. .pfn = __phys_to_pfn(ENP2611_PM3386_0_PHYS_BASE),
  69. .length = ENP2611_PM3386_0_SIZE,
  70. .type = MT_DEVICE,
  71. }, {
  72. .virtual = ENP2611_PM3386_1_VIRT_BASE,
  73. .pfn = __phys_to_pfn(ENP2611_PM3386_1_PHYS_BASE),
  74. .length = ENP2611_PM3386_1_SIZE,
  75. .type = MT_DEVICE,
  76. }
  77. };
  78. void __init enp2611_map_io(void)
  79. {
  80. ixp2000_map_io();
  81. iotable_init(enp2611_io_desc, ARRAY_SIZE(enp2611_io_desc));
  82. }
  83. /*************************************************************************
  84. * ENP-2611 PCI
  85. *************************************************************************/
  86. static int enp2611_pci_setup(int nr, struct pci_sys_data *sys)
  87. {
  88. sys->mem_offset = 0xe0000000;
  89. ixp2000_pci_setup(nr, sys);
  90. return 1;
  91. }
  92. static void __init enp2611_pci_preinit(void)
  93. {
  94. ixp2000_reg_write(IXP2000_PCI_ADDR_EXT, 0x00100000);
  95. ixp2000_pci_preinit();
  96. pcibios_setup("firmware");
  97. }
  98. static inline int enp2611_pci_valid_device(struct pci_bus *bus,
  99. unsigned int devfn)
  100. {
  101. /* The 82559 ethernet controller appears at both PCI:1:0:0 and
  102. * PCI:1:2:0, so let's pretend the second one isn't there.
  103. */
  104. if (bus->number == 0x01 && devfn == 0x10)
  105. return 0;
  106. return 1;
  107. }
  108. static int enp2611_pci_read_config(struct pci_bus *bus, unsigned int devfn,
  109. int where, int size, u32 *value)
  110. {
  111. if (enp2611_pci_valid_device(bus, devfn))
  112. return ixp2000_pci_read_config(bus, devfn, where, size, value);
  113. return PCIBIOS_DEVICE_NOT_FOUND;
  114. }
  115. static int enp2611_pci_write_config(struct pci_bus *bus, unsigned int devfn,
  116. int where, int size, u32 value)
  117. {
  118. if (enp2611_pci_valid_device(bus, devfn))
  119. return ixp2000_pci_write_config(bus, devfn, where, size, value);
  120. return PCIBIOS_DEVICE_NOT_FOUND;
  121. }
  122. static struct pci_ops enp2611_pci_ops = {
  123. .read = enp2611_pci_read_config,
  124. .write = enp2611_pci_write_config
  125. };
  126. static struct pci_bus * __init enp2611_pci_scan_bus(int nr,
  127. struct pci_sys_data *sys)
  128. {
  129. return pci_scan_bus(sys->busnr, &enp2611_pci_ops, sys);
  130. }
  131. static int __init enp2611_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  132. {
  133. int irq;
  134. if (dev->bus->number == 0 && PCI_SLOT(dev->devfn) == 0) {
  135. /* IXP2400. */
  136. irq = IRQ_IXP2000_PCIA;
  137. } else if (dev->bus->number == 0 && PCI_SLOT(dev->devfn) == 1) {
  138. /* 21555 non-transparent bridge. */
  139. irq = IRQ_IXP2000_PCIB;
  140. } else if (dev->bus->number == 0 && PCI_SLOT(dev->devfn) == 4) {
  141. /* PCI2050B transparent bridge. */
  142. irq = -1;
  143. } else if (dev->bus->number == 1 && PCI_SLOT(dev->devfn) == 0) {
  144. /* 82559 ethernet. */
  145. irq = IRQ_IXP2000_PCIA;
  146. } else if (dev->bus->number == 1 && PCI_SLOT(dev->devfn) == 1) {
  147. /* SPI-3 option board. */
  148. irq = IRQ_IXP2000_PCIB;
  149. } else {
  150. printk(KERN_ERR "enp2611_pci_map_irq() called for unknown "
  151. "device PCI:%d:%d:%d\n", dev->bus->number,
  152. PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
  153. irq = -1;
  154. }
  155. return irq;
  156. }
  157. struct hw_pci enp2611_pci __initdata = {
  158. .nr_controllers = 1,
  159. .setup = enp2611_pci_setup,
  160. .preinit = enp2611_pci_preinit,
  161. .scan = enp2611_pci_scan_bus,
  162. .map_irq = enp2611_pci_map_irq,
  163. };
  164. int __init enp2611_pci_init(void)
  165. {
  166. if (machine_is_enp2611())
  167. pci_common_init(&enp2611_pci);
  168. return 0;
  169. }
  170. subsys_initcall(enp2611_pci_init);
  171. /*************************************************************************
  172. * ENP-2611 Machine Initialization
  173. *************************************************************************/
  174. static struct flash_platform_data enp2611_flash_platform_data = {
  175. .map_name = "cfi_probe",
  176. .width = 1,
  177. };
  178. static struct ixp2000_flash_data enp2611_flash_data = {
  179. .platform_data = &enp2611_flash_platform_data,
  180. .nr_banks = 1
  181. };
  182. static struct resource enp2611_flash_resource = {
  183. .start = 0xc4000000,
  184. .end = 0xc4000000 + 0x00ffffff,
  185. .flags = IORESOURCE_MEM,
  186. };
  187. static struct platform_device enp2611_flash = {
  188. .name = "IXP2000-Flash",
  189. .id = 0,
  190. .dev = {
  191. .platform_data = &enp2611_flash_data,
  192. },
  193. .num_resources = 1,
  194. .resource = &enp2611_flash_resource,
  195. };
  196. static struct ixp2000_i2c_pins enp2611_i2c_gpio_pins = {
  197. .sda_pin = ENP2611_GPIO_SDA,
  198. .scl_pin = ENP2611_GPIO_SCL,
  199. };
  200. static struct platform_device enp2611_i2c_controller = {
  201. .name = "IXP2000-I2C",
  202. .id = 0,
  203. .dev = {
  204. .platform_data = &enp2611_i2c_gpio_pins
  205. },
  206. .num_resources = 0
  207. };
  208. static struct platform_device *enp2611_devices[] __initdata = {
  209. &enp2611_flash,
  210. &enp2611_i2c_controller
  211. };
  212. static void __init enp2611_init_machine(void)
  213. {
  214. platform_add_devices(enp2611_devices, ARRAY_SIZE(enp2611_devices));
  215. ixp2000_uart_init();
  216. }
  217. MACHINE_START(ENP2611, "Radisys ENP-2611 PCI network processor board")
  218. /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
  219. .phys_io = IXP2000_UART_PHYS_BASE,
  220. .io_pg_offst = ((IXP2000_UART_VIRT_BASE) >> 18) & 0xfffc,
  221. .boot_params = 0x00000100,
  222. .map_io = enp2611_map_io,
  223. .init_irq = ixp2000_init_irq,
  224. .timer = &enp2611_timer,
  225. .init_machine = enp2611_init_machine,
  226. MACHINE_END