hiddenDangerAnalysis.c 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. /*
  2. * Support for the Arcom ZEUS.
  3. *
  4. * Copyright (C) 2006 Arcom Control Systems Ltd.
  5. *
  6. * Loosely based on Arcom's 2.6.16.28.
  7. * Maintained by Marc Zyngier <maz@misterjones.org>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #include <linux/cpufreq.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/irq.h>
  16. #include <linux/pm.h>
  17. #include <linux/gpio.h>
  18. #include <linux/serial_8250.h>
  19. #include <linux/dm9000.h>
  20. #include <linux/mmc/host.h>
  21. #include <linux/spi/spi.h>
  22. #include <linux/spi/pxa2xx_spi.h>
  23. #include <linux/mtd/mtd.h>
  24. #include <linux/mtd/partitions.h>
  25. #include <linux/mtd/physmap.h>
  26. #include <linux/i2c.h>
  27. #include <linux/i2c/pxa-i2c.h>
  28. #include <linux/i2c/pca953x.h>
  29. #include <linux/apm-emulation.h>
  30. #include <linux/can/platform/mcp251x.h>
  31. #include <asm/mach-types.h>
  32. #include <asm/suspend.h>
  33. #include <asm/system_info.h>
  34. #include <asm/mach/arch.h>
  35. #include <asm/mach/map.h>
  36. #include <mach/pxa27x.h>
  37. #include <mach/regs-uart.h>
  38. #include <linux/platform_data/usb-ohci-pxa27x.h>
  39. #include <linux/platform_data/mmc-pxamci.h>
  40. #include <mach/pxa27x-udc.h>
  41. #include <mach/udc.h>
  42. #include <linux/platform_data/video-pxafb.h>
  43. #include <mach/pm.h>
  44. #include <mach/audio.h>
  45. #include <linux/platform_data/pcmcia-pxa2xx_viper.h>
  46. #include <mach/zeus.h>
  47. #include <mach/smemc.h>
  48. #include "generic.h"
  49. /*
  50. * Interrupt handling
  51. */
  52. static unsigned long zeus_irq_enabled_mask;
  53. static const int zeus_isa_irqs[] = { 3, 4, 5, 6, 7, 10, 11, 12, };
  54. static const int zeus_isa_irq_map[] = {
  55. 0, /* ISA irq #0, invalid */
  56. 0, /* ISA irq #1, invalid */
  57. 0, /* ISA irq #2, invalid */
  58. 1 << 0, /* ISA irq #3 */
  59. 1 << 1, /* ISA irq #4 */
  60. 1 << 2, /* ISA irq #5 */
  61. 1 << 3, /* ISA irq #6 */
  62. 1 << 4, /* ISA irq #7 */
  63. 0, /* ISA irq #8, invalid */
  64. 0, /* ISA irq #9, invalid */
  65. 1 << 5, /* ISA irq #10 */
  66. 1 << 6, /* ISA irq #11 */
  67. 1 << 7, /* ISA irq #12 */
  68. };
  69. static inline int zeus_irq_to_bitmask(unsigned int irq)
  70. {
  71. return zeus_isa_irq_map[irq - PXA_ISA_IRQ(0)];
  72. }
  73. static inline int zeus_bit_to_irq(int bit)
  74. {
  75. return zeus_isa_irqs[bit] + PXA_ISA_IRQ(0);
  76. }
  77. static void zeus_ack_irq(struct irq_data *d)
  78. {
  79. __raw_writew(zeus_irq_to_bitmask(d->irq), ZEUS_CPLD_ISA_IRQ);
  80. }
  81. static void zeus_mask_irq(struct irq_data *d)
  82. {
  83. zeus_irq_enabled_mask &= ~(zeus_irq_to_bitmask(d->irq));
  84. }
  85. static void zeus_unmask_irq(struct irq_data *d)
  86. {
  87. zeus_irq_enabled_mask |= zeus_irq_to_bitmask(d->irq);
  88. }
  89. static inline unsigned long zeus_irq_pending(void)
  90. {
  91. return __raw_readw(ZEUS_CPLD_ISA_IRQ) & zeus_irq_enabled_mask;
  92. }
  93. static void zeus_irq_handler(unsigned int irq, struct irq_desc *desc)
  94. {
  95. unsigned long pending;
  96. pending = zeus_irq_pending();
  97. do {
  98. /* we're in a chained irq handler,
  99. * so ack the interrupt by hand */
  100. desc->irq_data.chip->irq_ack(&desc->irq_data);
  101. if (likely(pending)) {
  102. irq = zeus_bit_to_irq(__ffs(pending));
  103. generic_handle_irq(irq);
  104. }
  105. pending = zeus_irq_pending();
  106. } while (pending);
  107. }
  108. static struct irq_chip zeus_irq_chip = {
  109. .name = "ISA",
  110. .irq_ack = zeus_ack_irq,
  111. .irq_mask = zeus_mask_irq,
  112. .irq_unmask = zeus_unmask_irq,
  113. };
  114. static void __init zeus_init_irq(void)
  115. {
  116. int level;
  117. int isa_irq;
  118. pxa27x_init_irq();
  119. /* Peripheral IRQs. It would be nice to move those inside driver
  120. configuration, but it is not supported at the moment. */
  121. irq_set_irq_type(gpio_to_irq(ZEUS_AC97_GPIO), IRQ_TYPE_EDGE_RISING);
  122. irq_set_irq_type(gpio_to_irq(ZEUS_WAKEUP_GPIO), IRQ_TYPE_EDGE_RISING);
  123. irq_set_irq_type(gpio_to_irq(ZEUS_PTT_GPIO), IRQ_TYPE_EDGE_RISING);
  124. irq_set_irq_type(gpio_to_irq(ZEUS_EXTGPIO_GPIO),
  125. IRQ_TYPE_EDGE_FALLING);
  126. irq_set_irq_type(gpio_to_irq(ZEUS_CAN_GPIO), IRQ_TYPE_EDGE_FALLING);
  127. /* Setup ISA IRQs */
  128. for (level = 0; level < ARRAY_SIZE(zeus_isa_irqs); level++) {
  129. isa_irq = zeus_bit_to_irq(level);
  130. irq_set_chip_and_handler(isa_irq, &zeus_irq_chip,
  131. handle_edge_irq);
  132. set_irq_flags(isa_irq, IRQF_VALID | IRQF_PROBE);
  133. }
  134. irq_set_irq_type(gpio_to_irq(ZEUS_ISA_GPIO), IRQ_TYPE_EDGE_RISING);
  135. irq_set_chained_handler(gpio_to_irq(ZEUS_ISA_GPIO), zeus_irq_handler);
  136. }
  137. /*
  138. * Platform devices
  139. */
  140. /* Flash */
  141. static struct resource zeus_mtd_resources[] = {
  142. [0] = { /* NOR Flash (up to 64MB) */
  143. .start = ZEUS_FLASH_PHYS,
  144. .end = ZEUS_FLASH_PHYS + SZ_64M - 1,
  145. .flags = IORESOURCE_MEM,
  146. },
  147. [1] = { /* SRAM */
  148. .start = ZEUS_SRAM_PHYS,
  149. .end = ZEUS_SRAM_PHYS + SZ_512K - 1,
  150. .flags = IORESOURCE_MEM,
  151. },
  152. };
  153. static struct physmap_flash_data zeus_flash_data[] = {
  154. [0] = {
  155. .width = 2,
  156. .parts = NULL,
  157. .nr_parts = 0,
  158. },
  159. };
  160. static struct platform_device zeus_mtd_devices[] = {
  161. [0] = {
  162. .name = "physmap-flash",
  163. .id = 0,
  164. .dev = {
  165. .platform_data = &zeus_flash_data[0],
  166. },
  167. .resource = &zeus_mtd_resources[0],
  168. .num_resources = 1,
  169. },
  170. };
  171. /* Serial */
  172. static struct resource zeus_serial_resources[] = {
  173. {
  174. .start = 0x10000000,
  175. .end = 0x1000000f,
  176. .flags = IORESOURCE_MEM,
  177. },
  178. {
  179. .start = 0x10800000,
  180. .end = 0x1080000f,
  181. .flags = IORESOURCE_MEM,
  182. },
  183. {
  184. .start = 0x11000000,
  185. .end = 0x1100000f,
  186. .flags = IORESOURCE_MEM,
  187. },
  188. {
  189. .start = 0x40100000,
  190. .end = 0x4010001f,
  191. .flags = IORESOURCE_MEM,
  192. },
  193. {
  194. .start = 0x40200000,
  195. .end = 0x4020001f,
  196. .flags = IORESOURCE_MEM,
  197. },
  198. {
  199. .start = 0x40700000,
  200. .end = 0x4070001f,
  201. .flags = IORESOURCE_MEM,
  202. },
  203. };
  204. static struct plat_serial8250_port serial_platform_data[] = {
  205. /* External UARTs */
  206. /* FIXME: Shared IRQs on COM1-COM4 will not work properly on v1i1 hardware. */
  207. { /* COM1 */
  208. .mapbase = 0x10000000,
  209. .irq = PXA_GPIO_TO_IRQ(ZEUS_UARTA_GPIO),
  210. .irqflags = IRQF_TRIGGER_RISING,
  211. .uartclk = 14745600,
  212. .regshift = 1,
  213. .flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
  214. .iotype = UPIO_MEM,
  215. },
  216. { /* COM2 */
  217. .mapbase = 0x10800000,
  218. .irq = PXA_GPIO_TO_IRQ(ZEUS_UARTB_GPIO),
  219. .irqflags = IRQF_TRIGGER_RISING,
  220. .uartclk = 14745600,
  221. .regshift = 1,
  222. .flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
  223. .iotype = UPIO_MEM,
  224. },
  225. { /* COM3 */
  226. .mapbase = 0x11000000,
  227. .irq = PXA_GPIO_TO_IRQ(ZEUS_UARTC_GPIO),
  228. .irqflags = IRQF_TRIGGER_RISING,
  229. .uartclk = 14745600,
  230. .regshift = 1,
  231. .flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
  232. .iotype = UPIO_MEM,
  233. },
  234. { /* COM4 */
  235. .mapbase = 0x11800000,
  236. .irq = PXA_GPIO_TO_IRQ(ZEUS_UARTD_GPIO),
  237. .irqflags = IRQF_TRIGGER_RISING,
  238. .uartclk = 14745600,
  239. .regshift = 1,
  240. .flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
  241. .iotype = UPIO_MEM,
  242. },
  243. /* Internal UARTs */
  244. { /* FFUART */
  245. .membase = (void *)&FFUART,
  246. .mapbase = __PREG(FFUART),
  247. .irq = IRQ_FFUART,
  248. .uartclk = 921600 * 16,
  249. .regshift = 2,
  250. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
  251. .iotype = UPIO_MEM,
  252. },
  253. { /* BTUART */
  254. .membase = (void *)&BTUART,
  255. .mapbase = __PREG(BTUART),
  256. .irq = IRQ_BTUART,
  257. .uartclk = 921600 * 16,
  258. .regshift = 2,
  259. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
  260. .iotype = UPIO_MEM,
  261. },
  262. { /* STUART */
  263. .membase = (void *)&STUART,
  264. .mapbase = __PREG(STUART),
  265. .irq = IRQ_STUART,
  266. .uartclk = 921600 * 16,
  267. .regshift = 2,
  268. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
  269. .iotype = UPIO_MEM,
  270. },
  271. { },
  272. };
  273. static struct platform_device zeus_serial_device = {
  274. .name = "serial8250",
  275. .id = PLAT8250_DEV_PLATFORM,
  276. .dev = {
  277. .platform_data = serial_platform_data,
  278. },
  279. .num_resources = ARRAY_SIZE(zeus_serial_resources),
  280. .resource = zeus_serial_resources,
  281. };
  282. /* Ethernet */
  283. static struct resource zeus_dm9k0_resource[] = {
  284. [0] = {
  285. .start = ZEUS_ETH0_PHYS,
  286. .end = ZEUS_ETH0_PHYS + 1,
  287. .flags = IORESOURCE_MEM
  288. },