setup-emev2.c 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  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/delay.h>
  26. #include <linux/input.h>
  27. #include <linux/io.h>
  28. #include <mach/hardware.h>
  29. #include <mach/common.h>
  30. #include <mach/emev2.h>
  31. #include <mach/irqs.h>
  32. #include <asm/mach-types.h>
  33. #include <asm/mach/arch.h>
  34. #include <asm/mach/map.h>
  35. #include <asm/mach/time.h>
  36. #include <asm/hardware/gic.h>
  37. static struct map_desc emev2_io_desc[] __initdata = {
  38. #ifdef CONFIG_SMP
  39. /* 128K entity map for 0xe0100000 (SMU) */
  40. {
  41. .virtual = 0xe0100000,
  42. .pfn = __phys_to_pfn(0xe0100000),
  43. .length = SZ_128K,
  44. .type = MT_DEVICE
  45. },
  46. /* 2M mapping for SCU + L2 controller */
  47. {
  48. .virtual = 0xf0000000,
  49. .pfn = __phys_to_pfn(0x1e000000),
  50. .length = SZ_2M,
  51. .type = MT_DEVICE
  52. },
  53. #endif
  54. };
  55. void __init emev2_map_io(void)
  56. {
  57. iotable_init(emev2_io_desc, ARRAY_SIZE(emev2_io_desc));
  58. }
  59. /* UART */
  60. static struct resource uart0_resources[] = {
  61. [0] = {
  62. .start = 0xe1020000,
  63. .end = 0xe1020037,
  64. .flags = IORESOURCE_MEM,
  65. },
  66. [1] = {
  67. .start = 40,
  68. .flags = IORESOURCE_IRQ,
  69. }
  70. };
  71. static struct platform_device uart0_device = {
  72. .name = "serial8250-em",
  73. .id = 0,
  74. .num_resources = ARRAY_SIZE(uart0_resources),
  75. .resource = uart0_resources,
  76. };
  77. static struct resource uart1_resources[] = {
  78. [0] = {
  79. .start = 0xe1030000,
  80. .end = 0xe1030037,
  81. .flags = IORESOURCE_MEM,
  82. },
  83. [1] = {
  84. .start = 41,
  85. .flags = IORESOURCE_IRQ,
  86. }
  87. };
  88. static struct platform_device uart1_device = {
  89. .name = "serial8250-em",
  90. .id = 1,
  91. .num_resources = ARRAY_SIZE(uart1_resources),
  92. .resource = uart1_resources,
  93. };
  94. static struct resource uart2_resources[] = {
  95. [0] = {
  96. .start = 0xe1040000,
  97. .end = 0xe1040037,
  98. .flags = IORESOURCE_MEM,
  99. },
  100. [1] = {
  101. .start = 42,
  102. .flags = IORESOURCE_IRQ,
  103. }
  104. };
  105. static struct platform_device uart2_device = {
  106. .name = "serial8250-em",
  107. .id = 2,
  108. .num_resources = ARRAY_SIZE(uart2_resources),
  109. .resource = uart2_resources,
  110. };
  111. static struct resource uart3_resources[] = {
  112. [0] = {
  113. .start = 0xe1050000,
  114. .end = 0xe1050037,
  115. .flags = IORESOURCE_MEM,
  116. },
  117. [1] = {
  118. .start = 43,
  119. .flags = IORESOURCE_IRQ,
  120. }
  121. };
  122. static struct platform_device uart3_device = {
  123. .name = "serial8250-em",
  124. .id = 3,
  125. .num_resources = ARRAY_SIZE(uart3_resources),
  126. .resource = uart3_resources,
  127. };
  128. /* STI */
  129. static struct resource sti_resources[] = {
  130. [0] = {
  131. .name = "STI",
  132. .start = 0xe0180000,
  133. .end = 0xe0180053,
  134. .flags = IORESOURCE_MEM,
  135. },
  136. [1] = {
  137. .start = 157,
  138. .flags = IORESOURCE_IRQ,
  139. },
  140. };
  141. static struct platform_device sti_device = {
  142. .name = "em_sti",
  143. .id = 0,
  144. .resource = sti_resources,
  145. .num_resources = ARRAY_SIZE(sti_resources),
  146. };
  147. /* GIO */
  148. static struct gpio_em_config gio0_config = {
  149. .gpio_base = 0,
  150. .irq_base = EMEV2_GPIO_IRQ(0),
  151. .number_of_pins = 32,
  152. };
  153. static struct resource gio0_resources[] = {
  154. [0] = {
  155. .name = "GIO_000",
  156. .start = 0xe0050000,
  157. .end = 0xe005002b,
  158. .flags = IORESOURCE_MEM,
  159. },
  160. [1] = {
  161. .name = "GIO_000",
  162. .start = 0xe0050040,
  163. .end = 0xe005005f,
  164. .flags = IORESOURCE_MEM,
  165. },
  166. [2] = {
  167. .start = 99,
  168. .flags = IORESOURCE_IRQ,
  169. },
  170. [3] = {
  171. .start = 100,
  172. .flags = IORESOURCE_IRQ,
  173. },
  174. };
  175. static struct platform_device gio0_device = {
  176. .name = "em_gio",
  177. .id = 0,
  178. .resource = gio0_resources,
  179. .num_resources = ARRAY_SIZE(gio0_resources),
  180. .dev = {
  181. .platform_data = &gio0_config,
  182. },
  183. };
  184. static struct gpio_em_config gio1_config = {
  185. .gpio_base = 32,
  186. .irq_base = EMEV2_GPIO_IRQ(32),
  187. .number_of_pins = 32,
  188. };
  189. static struct resource gio1_resources[] = {
  190. [0] = {
  191. .name = "GIO_032",
  192. .start = 0xe0050080,
  193. .end = 0xe00500ab,
  194. .flags = IORESOURCE_MEM,
  195. },
  196. [1] = {
  197. .name = "GIO_032",
  198. .start = 0xe00500c0,
  199. .end = 0xe00500df,
  200. .flags = IORESOURCE_MEM,
  201. },
  202. [2] = {
  203. .start = 101,
  204. .flags = IORESOURCE_IRQ,
  205. },
  206. [3] = {
  207. .start = 102,
  208. .flags = IORESOURCE_IRQ,
  209. },
  210. };
  211. static struct platform_device gio1_device = {
  212. .name = "em_gio",
  213. .id = 1,
  214. .resource = gio1_resources,
  215. .num_resources = ARRAY_SIZE(gio1_resources),
  216. .dev = {
  217. .platform_data = &gio1_config,
  218. },
  219. };
  220. static struct gpio_em_config gio2_config = {
  221. .gpio_base = 64,
  222. .irq_base = EMEV2_GPIO_IRQ(64),
  223. .number_of_pins = 32,
  224. };
  225. static struct resource gio2_resources[] = {
  226. [0] = {
  227. .name = "GIO_064",
  228. .start = 0xe0050100,
  229. .end = 0xe005012b,
  230. .flags = IORESOURCE_MEM,
  231. },
  232. [1] = {
  233. .name = "GIO_064",
  234. .start = 0xe0050140,
  235. .end = 0xe005015f,
  236. .flags = IORESOURCE_MEM,
  237. },
  238. [2] = {
  239. .start = 103,
  240. .flags = IORESOURCE_IRQ,
  241. },
  242. [3] = {
  243. .start = 104,
  244. .flags = IORESOURCE_IRQ,
  245. },
  246. };
  247. static struct platform_device gio2_device = {
  248. .name = "em_gio",
  249. .id = 2,
  250. .resource = gio2_resources,
  251. .num_resources = ARRAY_SIZE(gio2_resources),
  252. .dev = {
  253. .platform_data = &gio2_config,
  254. },
  255. };
  256. static struct gpio_em_config gio3_config = {
  257. .gpio_base = 96,
  258. .irq_base = EMEV2_GPIO_IRQ(96),
  259. .number_of_pins = 32,
  260. };
  261. static struct resource gio3_resources[] = {
  262. [0] = {
  263. .name = "GIO_096",
  264. .start = 0xe0050100,
  265. .end = 0xe005012b,
  266. .flags = IORESOURCE_MEM,
  267. },
  268. [1] = {
  269. .name = "GIO_096",
  270. .start = 0xe0050140,
  271. .end = 0xe005015f,
  272. .flags = IORESOURCE_MEM,
  273. },
  274. [2] = {
  275. .start = 105,
  276. .flags = IORESOURCE_IRQ,
  277. },
  278. [3] = {
  279. .start = 106,
  280. .flags = IORESOURCE_IRQ,
  281. },
  282. };
  283. static struct platform_device gio3_device = {
  284. .name = "em_gio",
  285. .id = 3,
  286. .resource = gio3_resources,
  287. .num_resources = ARRAY_SIZE(gio3_resources),
  288. .dev = {
  289. .platform_data = &gio3_config,
  290. },
  291. };
  292. static struct gpio_em_config gio4_config = {
  293. .gpio_base = 128,
  294. .irq_base = EMEV2_GPIO_IRQ(128),
  295. .number_of_pins = 31,
  296. };
  297. static struct resource gio4_resources[] = {
  298. [0] = {
  299. .name = "GIO_128",
  300. .start = 0xe0050200,
  301. .end = 0xe005022b,
  302. .flags = IORESOURCE_MEM,
  303. },
  304. [1] = {
  305. .name = "GIO_128",
  306. .start = 0xe0050240,
  307. .end = 0xe005025f,
  308. .flags = IORESOURCE_MEM,
  309. },
  310. [2] = {
  311. .start = 107,
  312. .flags = IORESOURCE_IRQ,
  313. },
  314. [3] = {
  315. .start = 108,
  316. .flags = IORESOURCE_IRQ,
  317. },
  318. };
  319. static struct platform_device gio4_device = {
  320. .name = "em_gio",
  321. .id = 4,
  322. .resource = gio4_resources,
  323. .num_resources = ARRAY_SIZE(gio4_resources),
  324. .dev = {
  325. .platform_data = &gio4_config,
  326. },
  327. };
  328. static struct platform_device *emev2_early_devices[] __initdata = {
  329. &uart0_device,
  330. &uart1_device,
  331. &uart2_device,
  332. &uart3_device,
  333. };
  334. static struct platform_device *emev2_late_devices[] __initdata = {
  335. &sti_device,
  336. &gio0_device,
  337. &gio1_device,
  338. &gio2_device,
  339. &gio3_device,
  340. &gio4_device,
  341. };
  342. void __init emev2_add_standard_devices(void)
  343. {
  344. emev2_clock_init();
  345. platform_add_devices(emev2_early_devices,
  346. ARRAY_SIZE(emev2_early_devices));
  347. platform_add_devices(emev2_late_devices,
  348. ARRAY_SIZE(emev2_late_devices));
  349. }
  350. void __init emev2_add_early_devices(void)
  351. {
  352. shmobile_setup_delay(533, 1, 3); /* Cortex-A9 @ 533MHz */
  353. early_platform_add_devices(emev2_early_devices,
  354. ARRAY_SIZE(emev2_early_devices));
  355. /* setup early console here as well */
  356. shmobile_setup_console();
  357. }
  358. void __init emev2_init_irq(void)
  359. {
  360. void __iomem *gic_dist_base;
  361. void __iomem *gic_cpu_base;
  362. /* Static mappings, never released */
  363. gic_dist_base = ioremap(0xe0028000, PAGE_SIZE);
  364. gic_cpu_base = ioremap(0xe0020000, PAGE_SIZE);
  365. BUG_ON(!gic_dist_base || !gic_cpu_base);
  366. /* Use GIC to handle interrupts */
  367. gic_init(0, 29, gic_dist_base, gic_cpu_base);
  368. }