board-ap4evb.c 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. /*
  2. * AP4EVB board support
  3. *
  4. * Copyright (C) 2010 Magnus Damm
  5. * Copyright (C) 2008 Yoshihiro Shimoda
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; version 2 of the License.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include <linux/kernel.h>
  21. #include <linux/init.h>
  22. #include <linux/interrupt.h>
  23. #include <linux/irq.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/delay.h>
  26. #include <linux/mtd/mtd.h>
  27. #include <linux/mtd/partitions.h>
  28. #include <linux/mtd/physmap.h>
  29. #include <linux/io.h>
  30. #include <linux/smsc911x.h>
  31. #include <linux/gpio.h>
  32. #include <linux/input.h>
  33. #include <linux/input/sh_keysc.h>
  34. #include <mach/common.h>
  35. #include <mach/sh7372.h>
  36. #include <asm/mach-types.h>
  37. #include <asm/mach/arch.h>
  38. #include <asm/mach/map.h>
  39. /*
  40. * Address Interface BusWidth note
  41. * ------------------------------------------------------------------
  42. * 0x0000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = ON
  43. * 0x0800_0000 user area -
  44. * 0x1000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = OFF
  45. * 0x1400_0000 Ether (LAN9220) 16bit
  46. * 0x1600_0000 user area - cannot use with NAND
  47. * 0x1800_0000 user area -
  48. * 0x1A00_0000 -
  49. * 0x4000_0000 LPDDR2-SDRAM (POP) 32bit
  50. */
  51. /*
  52. * NOR Flash ROM
  53. *
  54. * SW1 | SW2 | SW7 | NOR Flash ROM
  55. * bit1 | bit1 bit2 | bit1 | Memory allocation
  56. * ------+------------+------+------------------
  57. * OFF | ON OFF | ON | Area 0
  58. * OFF | ON OFF | OFF | Area 4
  59. */
  60. /*
  61. * NAND Flash ROM
  62. *
  63. * SW1 | SW2 | SW7 | NAND Flash ROM
  64. * bit1 | bit1 bit2 | bit2 | Memory allocation
  65. * ------+------------+------+------------------
  66. * OFF | ON OFF | ON | FCE 0
  67. * OFF | ON OFF | OFF | FCE 1
  68. */
  69. /*
  70. * SMSC 9220
  71. *
  72. * SW1 SMSC 9220
  73. * -----------------------
  74. * ON access disable
  75. * OFF access enable
  76. */
  77. /*
  78. * KEYSC
  79. *
  80. * SW43 KEYSC
  81. * -------------------------
  82. * ON enable
  83. * OFF disable
  84. */
  85. /* MTD */
  86. static struct mtd_partition nor_flash_partitions[] = {
  87. {
  88. .name = "loader",
  89. .offset = 0x00000000,
  90. .size = 512 * 1024,
  91. },
  92. {
  93. .name = "bootenv",
  94. .offset = MTDPART_OFS_APPEND,
  95. .size = 512 * 1024,
  96. },
  97. {
  98. .name = "kernel_ro",
  99. .offset = MTDPART_OFS_APPEND,
  100. .size = 8 * 1024 * 1024,
  101. .mask_flags = MTD_WRITEABLE,
  102. },
  103. {
  104. .name = "kernel",
  105. .offset = MTDPART_OFS_APPEND,
  106. .size = 8 * 1024 * 1024,
  107. },
  108. {
  109. .name = "data",
  110. .offset = MTDPART_OFS_APPEND,
  111. .size = MTDPART_SIZ_FULL,
  112. },
  113. };
  114. static struct physmap_flash_data nor_flash_data = {
  115. .width = 2,
  116. .parts = nor_flash_partitions,
  117. .nr_parts = ARRAY_SIZE(nor_flash_partitions),
  118. };
  119. static struct resource nor_flash_resources[] = {
  120. [0] = {
  121. .start = 0x00000000,
  122. .end = 0x08000000 - 1,
  123. .flags = IORESOURCE_MEM,
  124. }
  125. };
  126. static struct platform_device nor_flash_device = {
  127. .name = "physmap-flash",
  128. .dev = {
  129. .platform_data = &nor_flash_data,
  130. },
  131. .num_resources = ARRAY_SIZE(nor_flash_resources),
  132. .resource = nor_flash_resources,
  133. };
  134. /* SMSC 9220 */
  135. static struct resource smc911x_resources[] = {
  136. {
  137. .start = 0x14000000,
  138. .end = 0x16000000 - 1,
  139. .flags = IORESOURCE_MEM,
  140. }, {
  141. .start = 6,
  142. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  143. },
  144. };
  145. static struct smsc911x_platform_config smsc911x_info = {
  146. .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS,
  147. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  148. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  149. };
  150. static struct platform_device smc911x_device = {
  151. .name = "smsc911x",
  152. .id = -1,
  153. .num_resources = ARRAY_SIZE(smc911x_resources),
  154. .resource = smc911x_resources,
  155. .dev = {
  156. .platform_data = &smsc911x_info,
  157. },
  158. };
  159. /* KEYSC (Needs SW43 set to ON) */
  160. static struct sh_keysc_info keysc_info = {
  161. .mode = SH_KEYSC_MODE_1,
  162. .scan_timing = 3,
  163. .delay = 2500,
  164. .keycodes = {
  165. KEY_0, KEY_1, KEY_2, KEY_3, KEY_4,
  166. KEY_5, KEY_6, KEY_7, KEY_8, KEY_9,
  167. KEY_A, KEY_B, KEY_C, KEY_D, KEY_E,
  168. KEY_F, KEY_G, KEY_H, KEY_I, KEY_J,
  169. KEY_K, KEY_L, KEY_M, KEY_N, KEY_O,
  170. },
  171. };
  172. static struct resource keysc_resources[] = {
  173. [0] = {
  174. .name = "KEYSC",
  175. .start = 0xe61b0000,
  176. .end = 0xe61b0063,
  177. .flags = IORESOURCE_MEM,
  178. },
  179. [1] = {
  180. .start = 79,
  181. .flags = IORESOURCE_IRQ,
  182. },
  183. };
  184. static struct platform_device keysc_device = {
  185. .name = "sh_keysc",
  186. .id = 0, /* "keysc0" clock */
  187. .num_resources = ARRAY_SIZE(keysc_resources),
  188. .resource = keysc_resources,
  189. .dev = {
  190. .platform_data = &keysc_info,
  191. },
  192. };
  193. /* SDHI0 */
  194. static struct resource sdhi0_resources[] = {
  195. [0] = {
  196. .name = "SDHI0",
  197. .start = 0xe6850000,
  198. .end = 0xe68501ff,
  199. .flags = IORESOURCE_MEM,
  200. },
  201. [1] = {
  202. .start = 96,
  203. .flags = IORESOURCE_IRQ,
  204. },
  205. };
  206. static struct platform_device sdhi0_device = {
  207. .name = "sh_mobile_sdhi",
  208. .num_resources = ARRAY_SIZE(sdhi0_resources),
  209. .resource = sdhi0_resources,
  210. .id = 0,
  211. };
  212. static struct platform_device *ap4evb_devices[] __initdata = {
  213. &nor_flash_device,
  214. &smc911x_device,
  215. &keysc_device,
  216. &sdhi0_device,
  217. };
  218. static struct map_desc ap4evb_io_desc[] __initdata = {
  219. /* create a 1:1 entity map for 0xe6xxxxxx
  220. * used by CPGA, INTC and PFC.
  221. */
  222. {
  223. .virtual = 0xe6000000,
  224. .pfn = __phys_to_pfn(0xe6000000),
  225. .length = 256 << 20,
  226. .type = MT_DEVICE_NONSHARED
  227. },
  228. };
  229. static void __init ap4evb_map_io(void)
  230. {
  231. iotable_init(ap4evb_io_desc, ARRAY_SIZE(ap4evb_io_desc));
  232. /* setup early devices, clocks and console here as well */
  233. sh7372_add_early_devices();
  234. sh7367_clock_init(); /* use g3 clocks for now */
  235. shmobile_setup_console();
  236. }
  237. static void __init ap4evb_init(void)
  238. {
  239. sh7372_pinmux_init();
  240. /* enable SCIFA0 */
  241. gpio_request(GPIO_FN_SCIFA0_TXD, NULL);
  242. gpio_request(GPIO_FN_SCIFA0_RXD, NULL);
  243. /* enable SMSC911X */
  244. gpio_request(GPIO_FN_CS5A, NULL);
  245. gpio_request(GPIO_FN_IRQ6_39, NULL);
  246. /* enable LED 1 - 4 */
  247. gpio_request(GPIO_PORT185, NULL);
  248. gpio_request(GPIO_PORT186, NULL);
  249. gpio_request(GPIO_PORT187, NULL);
  250. gpio_request(GPIO_PORT188, NULL);
  251. gpio_direction_output(GPIO_PORT185, 1);
  252. gpio_direction_output(GPIO_PORT186, 1);
  253. gpio_direction_output(GPIO_PORT187, 1);
  254. gpio_direction_output(GPIO_PORT188, 1);
  255. gpio_export(GPIO_PORT185, 0);
  256. gpio_export(GPIO_PORT186, 0);
  257. gpio_export(GPIO_PORT187, 0);
  258. gpio_export(GPIO_PORT188, 0);
  259. /* enable Debug switch (S6) */
  260. gpio_request(GPIO_PORT32, NULL);
  261. gpio_request(GPIO_PORT33, NULL);
  262. gpio_request(GPIO_PORT34, NULL);
  263. gpio_request(GPIO_PORT35, NULL);
  264. gpio_direction_input(GPIO_PORT32);
  265. gpio_direction_input(GPIO_PORT33);
  266. gpio_direction_input(GPIO_PORT34);
  267. gpio_direction_input(GPIO_PORT35);
  268. gpio_export(GPIO_PORT32, 0);
  269. gpio_export(GPIO_PORT33, 0);
  270. gpio_export(GPIO_PORT34, 0);
  271. gpio_export(GPIO_PORT35, 0);
  272. /* enable KEYSC */
  273. gpio_request(GPIO_FN_KEYOUT0, NULL);
  274. gpio_request(GPIO_FN_KEYOUT1, NULL);
  275. gpio_request(GPIO_FN_KEYOUT2, NULL);
  276. gpio_request(GPIO_FN_KEYOUT3, NULL);
  277. gpio_request(GPIO_FN_KEYOUT4, NULL);
  278. gpio_request(GPIO_FN_KEYIN0_136, NULL);
  279. gpio_request(GPIO_FN_KEYIN1_135, NULL);
  280. gpio_request(GPIO_FN_KEYIN2_134, NULL);
  281. gpio_request(GPIO_FN_KEYIN3_133, NULL);
  282. gpio_request(GPIO_FN_KEYIN4, NULL);
  283. /* SDHI0 */
  284. gpio_request(GPIO_FN_SDHICD0, NULL);
  285. gpio_request(GPIO_FN_SDHIWP0, NULL);
  286. gpio_request(GPIO_FN_SDHICMD0, NULL);
  287. gpio_request(GPIO_FN_SDHICLK0, NULL);
  288. gpio_request(GPIO_FN_SDHID0_3, NULL);
  289. gpio_request(GPIO_FN_SDHID0_2, NULL);
  290. gpio_request(GPIO_FN_SDHID0_1, NULL);
  291. gpio_request(GPIO_FN_SDHID0_0, NULL);
  292. sh7372_add_standard_devices();
  293. platform_add_devices(ap4evb_devices, ARRAY_SIZE(ap4evb_devices));
  294. }
  295. MACHINE_START(AP4EVB, "ap4evb")
  296. .phys_io = 0xe6000000,
  297. .io_pg_offst = ((0xe6000000) >> 18) & 0xfffc,
  298. .map_io = ap4evb_map_io,
  299. .init_irq = sh7372_init_irq,
  300. .init_machine = ap4evb_init,
  301. .timer = &shmobile_timer,
  302. MACHINE_END