hiddenDangerAnalysis.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. /*
  2. * Emma Mobile EV2 processor support
  3. *
  4. * Copyright (C) 2012 Magnus Damm
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; version 2 of the License.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  18. */
  19. #include <linux/kernel.h>
  20. #include <linux/init.h>
  21. #include <linux/interrupt.h>
  22. #include <linux/irq.h>
  23. #include <linux/platform_device.h>
  24. #include <linux/platform_data/gpio-em.h>
  25. #include <linux/of_platform.h>
  26. #include <linux/delay.h>
  27. #include <linux/input.h>
  28. #include <linux/io.h>
  29. #include <linux/of_irq.h>
  30. #include <mach/hardware.h>
  31. #include <mach/common.h>
  32. #include <mach/emev2.h>
  33. #include <mach/irqs.h>
  34. #include <asm/mach-types.h>
  35. #include <asm/mach/arch.h>
  36. #include <asm/mach/map.h>
  37. #include <asm/mach/time.h>
  38. #include <asm/hardware/gic.h>
  39. static struct map_desc emev2_io_desc[] __initdata = {
  40. #ifdef CONFIG_SMP
  41. /* 128K entity map for 0xe0100000 (SMU) */
  42. {
  43. .virtual = 0xe0100000,
  44. .pfn = __phys_to_pfn(0xe0100000),
  45. .length = SZ_128K,
  46. .type = MT_DEVICE
  47. },
  48. /* 2M mapping for SCU + L2 controller */
  49. {
  50. .virtual = 0xf0000000,
  51. .pfn = __phys_to_pfn(0x1e000000),
  52. .length = SZ_2M,
  53. .type = MT_DEVICE
  54. },
  55. #endif
  56. };
  57. void __init emev2_map_io(void)
  58. {
  59. iotable_init(emev2_io_desc, ARRAY_SIZE(emev2_io_desc));
  60. }
  61. /* UART */
  62. static struct resource uart0_resources[] = {
  63. [0] = {
  64. .start = 0xe1020000,
  65. .end = 0xe1020037,
  66. .flags = IORESOURCE_MEM,
  67. },
  68. [1] = {
  69. .start = 40,
  70. .flags = IORESOURCE_IRQ,
  71. }
  72. };
  73. static struct platform_device uart0_device = {
  74. .name = "serial8250-em",
  75. .id = 0,
  76. .num_resources = ARRAY_SIZE(uart0_resources),
  77. .resource = uart0_resources,
  78. };
  79. static struct resource uart1_resources[] = {
  80. [0] = {
  81. .start = 0xe1030000,
  82. .end = 0xe1030037,
  83. .flags = IORESOURCE_MEM,
  84. },
  85. [1] = {
  86. .start = 41,
  87. .flags = IORESOURCE_IRQ,
  88. }
  89. };
  90. static struct platform_device uart1_device = {
  91. .name = "serial8250-em",
  92. .id = 1,
  93. .num_resources = ARRAY_SIZE(uart1_resources),
  94. .resource = uart1_resources,
  95. };
  96. static struct resource uart2_resources[] = {
  97. [0] = {
  98. .start = 0xe1040000,
  99. .end = 0xe1040037,
  100. .flags = IORESOURCE_MEM,
  101. },
  102. [1] = {
  103. .start = 42,
  104. .flags = IORESOURCE_IRQ,
  105. }
  106. };
  107. static struct platform_device uart2_device = {
  108. .name = "serial8250-em",
  109. .id = 2,
  110. .num_resources = ARRAY_SIZE(uart2_resources),
  111. .resource = uart2_resources,
  112. };
  113. static struct resource uart3_resources[] = {
  114. [0] = {
  115. .start = 0xe1050000,
  116. .end = 0xe1050037,
  117. .flags = IORESOURCE_MEM,
  118. },
  119. [1] = {
  120. .start = 43,
  121. .flags = IORESOURCE_IRQ,
  122. }
  123. };
  124. static struct platform_device uart3_device = {
  125. .name = "serial8250-em",
  126. .id = 3,
  127. .num_resources = ARRAY_SIZE(uart3_resources),
  128. .resource = uart3_resources,
  129. };
  130. /* STI */
  131. static struct resource sti_resources[] = {
  132. [0] = {
  133. .name = "STI",
  134. .start = 0xe0180000,
  135. .end = 0xe0180053,
  136. .flags = IORESOURCE_MEM,
  137. },
  138. [1] = {
  139. .start = 157,
  140. .flags = IORESOURCE_IRQ,
  141. },
  142. };
  143. static struct platform_device sti_device = {
  144. .name = "em_sti",
  145. .id = 0,
  146. .resource = sti_resources,
  147. .num_resources = ARRAY_SIZE(sti_resources),
  148. };
  149. /* GIO */
  150. static struct gpio_em_config gio0_config = {
  151. .gpio_base = 0,
  152. .irq_base = EMEV2_GPIO_IRQ(0),
  153. .number_of_pins = 32,
  154. };
  155. static struct resource gio0_resources[] = {
  156. [0] = {
  157. .name = "GIO_000",
  158. .start = 0xe0050000,
  159. .end = 0xe005002b,
  160. .flags = IORESOURCE_MEM,
  161. },
  162. [1] = {
  163. .name = "GIO_000",
  164. .start = 0xe0050040,
  165. .end = 0xe005005f,
  166. .flags = IORESOURCE_MEM,
  167. },
  168. [2] = {
  169. .start = 99,
  170. .flags = IORESOURCE_IRQ,
  171. },
  172. [3] = {
  173. .start = 100,
  174. .flags = IORESOURCE_IRQ,
  175. },
  176. };
  177. static struct platform_device gio0_device = {
  178. .name = "em_gio",
  179. .id = 0,
  180. .resource = gio0_resources,
  181. .num_resources = ARRAY_SIZE(gio0_resources),
  182. .dev = {
  183. .platform_data = &gio0_config,
  184. },
  185. };
  186. static struct gpio_em_config gio1_config = {
  187. .gpio_base = 32,
  188. .irq_base = EMEV2_GPIO_IRQ(32),
  189. .number_of_pins = 32,
  190. };
  191. static struct resource gio1_resources[] = {
  192. [0] = {
  193. .name = "GIO_032",
  194. .start = 0xe0050080,
  195. .end = 0xe00500ab,
  196. .flags = IORESOURCE_MEM,
  197. },
  198. [1] = {
  199. .name = "GIO_032",
  200. .start = 0xe00500c0,
  201. .end = 0xe00500df,
  202. .flags = IORESOURCE_MEM,
  203. },
  204. [2] = {
  205. .start = 101,
  206. .flags = IORESOURCE_IRQ,
  207. },
  208. [3] = {
  209. .start = 102,
  210. .flags = IORESOURCE_IRQ,
  211. },
  212. };
  213. static struct platform_device gio1_device = {
  214. .name = "em_gio",
  215. .id = 1,
  216. .resource = gio1_resources,
  217. .num_resources = ARRAY_SIZE(gio1_resources),
  218. .dev = {
  219. .platform_data = &gio1_config,
  220. },
  221. };
  222. static struct gpio_em_config gio2_config = {
  223. .gpio_base = 64,
  224. .irq_base = EMEV2_GPIO_IRQ(64),
  225. .number_of_pins = 32,
  226. };
  227. static struct resource gio2_resources[] = {
  228. [0] = {
  229. .name = "GIO_064",
  230. .start = 0xe0050100,
  231. .end = 0xe005012b,
  232. .flags = IORESOURCE_MEM,
  233. },
  234. [1] = {
  235. .name = "GIO_064",
  236. .start = 0xe0050140,
  237. .end = 0xe005015f,
  238. .flags = IORESOURCE_MEM,
  239. },
  240. [2] = {
  241. .start = 103,
  242. .flags = IORESOURCE_IRQ,
  243. },
  244. [3] = {
  245. .start = 104,
  246. .flags = IORESOURCE_IRQ,
  247. },
  248. };
  249. static struct platform_device gio2_device = {
  250. .name = "em_gio",
  251. .id = 2,
  252. .resource = gio2_resources,
  253. .num_resources = ARRAY_SIZE(gio2_resources),
  254. .dev = {
  255. .platform_data = &gio2_config,
  256. },
  257. };
  258. static struct gpio_em_config gio3_config = {
  259. .gpio_base = 96,