n2100.c 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  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/leds-pca9532.h>
  20. #include <linux/delay.h>
  21. #include <linux/kernel.h>
  22. #include <linux/pci.h>
  23. #include <linux/pm.h>
  24. #include <linux/string.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 <linux/io.h>
  32. #include <mach/hardware.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 <mach/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. };
  53. /*
  54. * N2100 I/O.
  55. */
  56. static struct map_desc n2100_io_desc[] __initdata = {
  57. { /* on-board devices */
  58. .virtual = N2100_UART,
  59. .pfn = __phys_to_pfn(N2100_UART),
  60. .length = 0x00100000,
  61. .type = MT_DEVICE
  62. },
  63. };
  64. void __init n2100_map_io(void)
  65. {
  66. iop3xx_map_io();
  67. iotable_init(n2100_io_desc, ARRAY_SIZE(n2100_io_desc));
  68. }
  69. /*
  70. * N2100 PCI.
  71. */
  72. static int __init
  73. n2100_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
  74. {
  75. int irq;
  76. if (PCI_SLOT(dev->devfn) == 1) {
  77. /* RTL8110SB #1 */
  78. irq = IRQ_IOP32X_XINT0;
  79. } else if (PCI_SLOT(dev->devfn) == 2) {
  80. /* RTL8110SB #2 */
  81. irq = IRQ_IOP32X_XINT3;
  82. } else if (PCI_SLOT(dev->devfn) == 3) {
  83. /* Sil3512 */
  84. irq = IRQ_IOP32X_XINT2;
  85. } else if (PCI_SLOT(dev->devfn) == 4 && pin == 1) {
  86. /* VT6212 INTA */
  87. irq = IRQ_IOP32X_XINT1;
  88. } else if (PCI_SLOT(dev->devfn) == 4 && pin == 2) {
  89. /* VT6212 INTB */
  90. irq = IRQ_IOP32X_XINT0;
  91. } else if (PCI_SLOT(dev->devfn) == 4 && pin == 3) {
  92. /* VT6212 INTC */
  93. irq = IRQ_IOP32X_XINT2;
  94. } else if (PCI_SLOT(dev->devfn) == 5) {
  95. /* Mini-PCI slot */
  96. irq = IRQ_IOP32X_XINT3;
  97. } else {
  98. printk(KERN_ERR "n2100_pci_map_irq() called for unknown "
  99. "device PCI:%d:%d:%d\n", dev->bus->number,
  100. PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
  101. irq = -1;
  102. }
  103. return irq;
  104. }
  105. static struct hw_pci n2100_pci __initdata = {
  106. .nr_controllers = 1,
  107. .ops = &iop3xx_ops,
  108. .setup = iop3xx_pci_setup,
  109. .preinit = iop3xx_pci_preinit,
  110. .map_irq = n2100_pci_map_irq,
  111. };
  112. /*
  113. * Both r8169 chips on the n2100 exhibit PCI parity problems. Set
  114. * the ->broken_parity_status flag for both ports so that the r8169
  115. * driver knows it should ignore error interrupts.
  116. */
  117. static void n2100_fixup_r8169(struct pci_dev *dev)
  118. {
  119. if (dev->bus->number == 0 &&
  120. (dev->devfn == PCI_DEVFN(1, 0) ||
  121. dev->devfn == PCI_DEVFN(2, 0)))
  122. dev->broken_parity_status = 1;
  123. }
  124. DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_REALTEK, PCI_ANY_ID, n2100_fixup_r8169);
  125. static int __init n2100_pci_init(void)
  126. {
  127. if (machine_is_n2100())
  128. pci_common_init(&n2100_pci);
  129. return 0;
  130. }
  131. subsys_initcall(n2100_pci_init);
  132. /*
  133. * N2100 machine initialisation.
  134. */
  135. static struct physmap_flash_data n2100_flash_data = {
  136. .width = 2,
  137. };
  138. static struct resource n2100_flash_resource = {
  139. .start = 0xf0000000,
  140. .end = 0xf0ffffff,
  141. .flags = IORESOURCE_MEM,
  142. };
  143. static struct platform_device n2100_flash_device = {
  144. .name = "physmap-flash",
  145. .id = 0,
  146. .dev = {
  147. .platform_data = &n2100_flash_data,
  148. },
  149. .num_resources = 1,
  150. .resource = &n2100_flash_resource,
  151. };
  152. static struct plat_serial8250_port n2100_serial_port[] = {
  153. {
  154. .mapbase = N2100_UART,
  155. .membase = (char *)N2100_UART,
  156. .irq = 0,
  157. .flags = UPF_SKIP_TEST | UPF_AUTO_IRQ | UPF_SHARE_IRQ,
  158. .iotype = UPIO_MEM,
  159. .regshift = 0,
  160. .uartclk = 1843200,
  161. },
  162. { },
  163. };
  164. static struct resource n2100_uart_resource = {
  165. .start = N2100_UART,
  166. .end = N2100_UART + 7,
  167. .flags = IORESOURCE_MEM,
  168. };
  169. static struct platform_device n2100_serial_device = {
  170. .name = "serial8250",
  171. .id = PLAT8250_DEV_PLATFORM,
  172. .dev = {
  173. .platform_data = n2100_serial_port,
  174. },
  175. .num_resources = 1,
  176. .resource = &n2100_uart_resource,
  177. };
  178. static struct f75375s_platform_data n2100_f75375s = {
  179. .pwm = { 255, 255 },
  180. .pwm_enable = { 0, 0 },
  181. };
  182. static struct pca9532_platform_data n2100_leds = {
  183. .leds = {
  184. { .name = "n2100:red:satafail0",
  185. .state = PCA9532_OFF,
  186. .type = PCA9532_TYPE_LED,
  187. },
  188. { .name = "n2100:red:satafail1",
  189. .state = PCA9532_OFF,
  190. .type = PCA9532_TYPE_LED,
  191. },
  192. { .name = "n2100:blue:usb",
  193. .state = PCA9532_OFF,
  194. .type = PCA9532_TYPE_LED,
  195. },
  196. { .type = PCA9532_TYPE_NONE },
  197. { .type = PCA9532_TYPE_NONE },
  198. { .type = PCA9532_TYPE_NONE },
  199. { .type = PCA9532_TYPE_NONE },
  200. { .name = "n2100:red:usb",
  201. .state = PCA9532_OFF,
  202. .type = PCA9532_TYPE_LED,
  203. },
  204. { .type = PCA9532_TYPE_NONE }, /* power OFF gpio */
  205. { .type = PCA9532_TYPE_NONE }, /* reset gpio */
  206. { .type = PCA9532_TYPE_NONE },
  207. { .type = PCA9532_TYPE_NONE },
  208. { .type = PCA9532_TYPE_NONE },
  209. { .name = "n2100:orange:system",
  210. .state = PCA9532_OFF,
  211. .type = PCA9532_TYPE_LED,
  212. },
  213. { .name = "n2100:red:system",
  214. .state = PCA9532_OFF,
  215. .type = PCA9532_TYPE_LED,
  216. },
  217. { .name = "N2100 beeper" ,
  218. .state = PCA9532_OFF,
  219. .type = PCA9532_TYPE_N2100_BEEP,
  220. },
  221. },
  222. .psc = { 0, 0 },
  223. .pwm = { 0, 0 },
  224. };
  225. static struct i2c_board_info __initdata n2100_i2c_devices[] = {
  226. {
  227. I2C_BOARD_INFO("rs5c372b", 0x32),
  228. },
  229. {
  230. I2C_BOARD_INFO("f75375", 0x2e),
  231. .platform_data = &n2100_f75375s,
  232. },
  233. {
  234. I2C_BOARD_INFO("pca9532", 0x60),
  235. .platform_data = &n2100_leds,
  236. },
  237. };
  238. /*
  239. * Pull PCA9532 GPIO #8 low to power off the machine.
  240. */
  241. static void n2100_power_off(void)
  242. {
  243. local_irq_disable();
  244. /* Start condition, I2C address of PCA9532, write transaction. */
  245. *IOP3XX_IDBR0 = 0xc0;
  246. *IOP3XX_ICR0 = 0xe9;
  247. mdelay(1);
  248. /* Write address 0x08. */
  249. *IOP3XX_IDBR0 = 0x08;
  250. *IOP3XX_ICR0 = 0xe8;
  251. mdelay(1);
  252. /* Write data 0x01, stop condition. */
  253. *IOP3XX_IDBR0 = 0x01;
  254. *IOP3XX_ICR0 = 0xea;
  255. while (1)
  256. ;
  257. }
  258. static void n2100_restart(char mode, const char *cmd)
  259. {
  260. gpio_line_set(N2100_HARDWARE_RESET, GPIO_LOW);
  261. gpio_line_config(N2100_HARDWARE_RESET, GPIO_OUT);
  262. while (1)
  263. ;
  264. }
  265. static struct timer_list power_button_poll_timer;
  266. static void power_button_poll(unsigned long dummy)
  267. {
  268. if (gpio_line_get(N2100_POWER_BUTTON) == 0) {
  269. ctrl_alt_del();
  270. return;
  271. }
  272. power_button_poll_timer.expires = jiffies + (HZ / 10);
  273. add_timer(&power_button_poll_timer);
  274. }
  275. static void __init n2100_init_machine(void)
  276. {
  277. platform_device_register(&iop3xx_i2c0_device);
  278. platform_device_register(&n2100_flash_device);
  279. platform_device_register(&n2100_serial_device);
  280. platform_device_register(&iop3xx_dma_0_channel);
  281. platform_device_register(&iop3xx_dma_1_channel);
  282. i2c_register_board_info(0, n2100_i2c_devices,
  283. ARRAY_SIZE(n2100_i2c_devices));
  284. pm_power_off = n2100_power_off;
  285. init_timer(&power_button_poll_timer);
  286. power_button_poll_timer.function = power_button_poll;
  287. power_button_poll_timer.expires = jiffies + (HZ / 10);
  288. add_timer(&power_button_poll_timer);
  289. }
  290. MACHINE_START(N2100, "Thecus N2100")
  291. /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
  292. .atag_offset = 0x100,
  293. .map_io = n2100_map_io,
  294. .init_irq = iop32x_init_irq,
  295. .timer = &n2100_timer,
  296. .init_machine = n2100_init_machine,
  297. .restart = n2100_restart,
  298. MACHINE_END