enp2611.c 6.1 KB

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