n2100.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. /*
  2. * arch/arm/mach-iop32x/n2100.c
  3. *
  4. * Board support code for the Thecus N2100 platform.
  5. *
  6. * Author: Rory Bolt <rorybolt@pacbell.net>
  7. * Copyright (C) 2002 Rory Bolt
  8. * Copyright 2003 (c) MontaVista, Software, Inc.
  9. * Copyright (C) 2004 Intel Corp.
  10. *
  11. * This program is free software; you can redistribute it and/or modify it
  12. * under the terms of the GNU General Public License as published by the
  13. * Free Software Foundation; either version 2 of the License, or (at your
  14. * option) any later version.
  15. */
  16. #include <linux/mm.h>
  17. #include <linux/init.h>
  18. #include <linux/delay.h>
  19. #include <linux/kernel.h>
  20. #include <linux/pci.h>
  21. #include <linux/pm.h>
  22. #include <linux/string.h>
  23. #include <linux/slab.h>
  24. #include <linux/serial_core.h>
  25. #include <linux/serial_8250.h>
  26. #include <linux/mtd/physmap.h>
  27. #include <linux/platform_device.h>
  28. #include <linux/reboot.h>
  29. #include <asm/hardware.h>
  30. #include <asm/io.h>
  31. #include <asm/irq.h>
  32. #include <asm/mach/arch.h>
  33. #include <asm/mach/map.h>
  34. #include <asm/mach/pci.h>
  35. #include <asm/mach/time.h>
  36. #include <asm/mach-types.h>
  37. #include <asm/page.h>
  38. #include <asm/pgtable.h>
  39. /*
  40. * N2100 timer tick configuration.
  41. */
  42. static void __init n2100_timer_init(void)
  43. {
  44. /* 33.000 MHz crystal. */
  45. iop3xx_init_time(198000000);
  46. }
  47. static struct sys_timer n2100_timer = {
  48. .init = n2100_timer_init,
  49. .offset = iop3xx_gettimeoffset,
  50. };
  51. /*
  52. * N2100 I/O.
  53. */
  54. static struct map_desc n2100_io_desc[] __initdata = {
  55. { /* on-board devices */
  56. .virtual = N2100_UART,
  57. .pfn = __phys_to_pfn(N2100_UART),
  58. .length = 0x00100000,
  59. .type = MT_DEVICE
  60. },
  61. };
  62. void __init n2100_map_io(void)
  63. {
  64. iop3xx_map_io();
  65. iotable_init(n2100_io_desc, ARRAY_SIZE(n2100_io_desc));
  66. }
  67. /*
  68. * N2100 PCI.
  69. */
  70. static inline int __init
  71. n2100_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
  72. {
  73. int irq;
  74. if (PCI_SLOT(dev->devfn) == 1) {
  75. /* RTL8110SB #1 */
  76. irq = IRQ_IOP32X_XINT0;
  77. } else if (PCI_SLOT(dev->devfn) == 2) {
  78. /* RTL8110SB #2 */
  79. irq = IRQ_IOP32X_XINT3;
  80. } else if (PCI_SLOT(dev->devfn) == 3) {
  81. /* Sil3512 */
  82. irq = IRQ_IOP32X_XINT2;
  83. } else if (PCI_SLOT(dev->devfn) == 4 && pin == 1) {
  84. /* VT6212 INTA */
  85. irq = IRQ_IOP32X_XINT1;
  86. } else if (PCI_SLOT(dev->devfn) == 4 && pin == 2) {
  87. /* VT6212 INTB */
  88. irq = IRQ_IOP32X_XINT0;
  89. } else if (PCI_SLOT(dev->devfn) == 4 && pin == 3) {
  90. /* VT6212 INTC */
  91. irq = IRQ_IOP32X_XINT2;
  92. } else if (PCI_SLOT(dev->devfn) == 5) {
  93. /* Mini-PCI slot */
  94. irq = IRQ_IOP32X_XINT3;
  95. } else {
  96. printk(KERN_ERR "n2100_pci_map_irq() called for unknown "
  97. "device PCI:%d:%d:%d\n", dev->bus->number,
  98. PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
  99. irq = -1;
  100. }
  101. return irq;
  102. }
  103. static struct hw_pci n2100_pci __initdata = {
  104. .swizzle = pci_std_swizzle,
  105. .nr_controllers = 1,
  106. .setup = iop3xx_pci_setup,
  107. .preinit = iop3xx_pci_preinit,
  108. .scan = iop3xx_pci_scan_bus,
  109. .map_irq = n2100_pci_map_irq,
  110. };
  111. /*
  112. * Both r8169 chips on the n2100 exhibit PCI parity problems. Set
  113. * the ->broken_parity_status flag for both ports so that the r8169
  114. * driver knows it should ignore error interrupts.
  115. */
  116. static void n2100_fixup_r8169(struct pci_dev *dev)
  117. {
  118. if (dev->bus->number == 0 &&
  119. (dev->devfn == PCI_DEVFN(1, 0) ||
  120. dev->devfn == PCI_DEVFN(2, 0)))
  121. dev->broken_parity_status = 1;
  122. }
  123. DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_REALTEK, PCI_ANY_ID, n2100_fixup_r8169);
  124. static int __init n2100_pci_init(void)
  125. {
  126. if (machine_is_n2100())
  127. pci_common_init(&n2100_pci);
  128. return 0;
  129. }
  130. subsys_initcall(n2100_pci_init);
  131. /*
  132. * N2100 machine initialisation.
  133. */
  134. static struct physmap_flash_data n2100_flash_data = {
  135. .width = 2,
  136. };
  137. static struct resource n2100_flash_resource = {
  138. .start = 0xf0000000,
  139. .end = 0xf0ffffff,
  140. .flags = IORESOURCE_MEM,
  141. };
  142. static struct platform_device n2100_flash_device = {
  143. .name = "physmap-flash",
  144. .id = 0,
  145. .dev = {
  146. .platform_data = &n2100_flash_data,
  147. },
  148. .num_resources = 1,
  149. .resource = &n2100_flash_resource,
  150. };
  151. static struct plat_serial8250_port n2100_serial_port[] = {
  152. {
  153. .mapbase = N2100_UART,
  154. .membase = (char *)N2100_UART,
  155. .irq = 0,
  156. .flags = UPF_SKIP_TEST,
  157. .iotype = UPIO_MEM,
  158. .regshift = 0,
  159. .uartclk = 1843200,
  160. },
  161. { },
  162. };
  163. static struct resource n2100_uart_resource = {
  164. .start = N2100_UART,
  165. .end = N2100_UART + 7,
  166. .flags = IORESOURCE_MEM,
  167. };
  168. static struct platform_device n2100_serial_device = {
  169. .name = "serial8250",
  170. .id = PLAT8250_DEV_PLATFORM,
  171. .dev = {
  172. .platform_data = n2100_serial_port,
  173. },
  174. .num_resources = 1,
  175. .resource = &n2100_uart_resource,
  176. };
  177. /*
  178. * Pull PCA9532 GPIO #8 low to power off the machine.
  179. */
  180. static void n2100_power_off(void)
  181. {
  182. local_irq_disable();
  183. /* Start condition, I2C address of PCA9532, write transaction. */
  184. *IOP3XX_IDBR0 = 0xc0;
  185. *IOP3XX_ICR0 = 0xe9;
  186. mdelay(1);
  187. /* Write address 0x08. */
  188. *IOP3XX_IDBR0 = 0x08;
  189. *IOP3XX_ICR0 = 0xe8;
  190. mdelay(1);
  191. /* Write data 0x01, stop condition. */
  192. *IOP3XX_IDBR0 = 0x01;
  193. *IOP3XX_ICR0 = 0xea;
  194. while (1)
  195. ;
  196. }
  197. static struct timer_list power_button_poll_timer;
  198. static void power_button_poll(unsigned long dummy)
  199. {
  200. if (gpio_line_get(N2100_POWER_BUTTON) == 0) {
  201. ctrl_alt_del();
  202. return;
  203. }
  204. power_button_poll_timer.expires = jiffies + (HZ / 10);
  205. add_timer(&power_button_poll_timer);
  206. }
  207. static void __init n2100_init_machine(void)
  208. {
  209. platform_device_register(&iop3xx_i2c0_device);
  210. platform_device_register(&n2100_flash_device);
  211. platform_device_register(&n2100_serial_device);
  212. pm_power_off = n2100_power_off;
  213. init_timer(&power_button_poll_timer);
  214. power_button_poll_timer.function = power_button_poll;
  215. power_button_poll_timer.expires = jiffies + (HZ / 10);
  216. add_timer(&power_button_poll_timer);
  217. }
  218. MACHINE_START(N2100, "Thecus N2100")
  219. /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
  220. .phys_io = N2100_UART,
  221. .io_pg_offst = ((N2100_UART) >> 18) & 0xfffc,
  222. .boot_params = 0xa0000100,
  223. .map_io = n2100_map_io,
  224. .init_irq = iop32x_init_irq,
  225. .timer = &n2100_timer,
  226. .init_machine = n2100_init_machine,
  227. MACHINE_END