enp2611.c 6.9 KB

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