n2100.c 6.4 KB

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