enp2611.c 6.6 KB

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