board-armadillo800eva.c 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. /*
  2. * armadillo 800 eva board support
  3. *
  4. * Copyright (C) 2012 Renesas Solutions Corp.
  5. * Copyright (C) 2012 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
  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. */
  21. #include <linux/clk.h>
  22. #include <linux/err.h>
  23. #include <linux/kernel.h>
  24. #include <linux/input.h>
  25. #include <linux/platform_device.h>
  26. #include <linux/gpio.h>
  27. #include <linux/gpio_keys.h>
  28. #include <linux/sh_eth.h>
  29. #include <linux/videodev2.h>
  30. #include <mach/common.h>
  31. #include <mach/irqs.h>
  32. #include <asm/page.h>
  33. #include <asm/mach-types.h>
  34. #include <asm/mach/arch.h>
  35. #include <asm/mach/map.h>
  36. #include <asm/mach/time.h>
  37. #include <asm/hardware/cache-l2x0.h>
  38. #include <mach/r8a7740.h>
  39. #include <video/sh_mobile_lcdc.h>
  40. /*
  41. * CON1 Camera Module
  42. * CON2 Extension Bus
  43. * CON3 HDMI Output
  44. * CON4 Composite Video Output
  45. * CON5 H-UDI JTAG
  46. * CON6 ARM JTAG
  47. * CON7 SD1
  48. * CON8 SD2
  49. * CON9 RTC BackUp
  50. * CON10 Monaural Mic Input
  51. * CON11 Stereo Headphone Output
  52. * CON12 Audio Line Output(L)
  53. * CON13 Audio Line Output(R)
  54. * CON14 AWL13 Module
  55. * CON15 Extension
  56. * CON16 LCD1
  57. * CON17 LCD2
  58. * CON19 Power Input
  59. * CON20 USB1
  60. * CON21 USB2
  61. * CON22 Serial
  62. * CON23 LAN
  63. * CON24 USB3
  64. * LED1 Camera LED(Yellow)
  65. * LED2 Power LED (Green)
  66. * ED3-LED6 User LED(Yellow)
  67. * LED7 LAN link LED(Green)
  68. * LED8 LAN activity LED(Yellow)
  69. */
  70. /*
  71. * DipSwitch
  72. *
  73. * SW1
  74. *
  75. * -12345678-+---------------+----------------------------
  76. * 1 | boot | hermit
  77. * 0 | boot | OS auto boot
  78. * -12345678-+---------------+----------------------------
  79. * 00 | boot device | eMMC
  80. * 10 | boot device | SDHI0 (CON7)
  81. * 01 | boot device | -
  82. * 11 | boot device | Extension Buss (CS0)
  83. * -12345678-+---------------+----------------------------
  84. * 0 | Extension Bus | D8-D15 disable, eMMC enable
  85. * 1 | Extension Bus | D8-D15 enable, eMMC disable
  86. * -12345678-+---------------+----------------------------
  87. * 0 | SDHI1 | COM8 enable, COM14 disable
  88. * 1 | SDHI1 | COM8 enable, COM14 disable
  89. * -12345678-+---------------+----------------------------
  90. * 00 | JTAG | SH-X2
  91. * 10 | JTAG | ARM
  92. * 01 | JTAG | -
  93. * 11 | JTAG | Boundary Scan
  94. *-----------+---------------+----------------------------
  95. */
  96. /* Ether */
  97. static struct sh_eth_plat_data sh_eth_platdata = {
  98. .phy = 0x00, /* LAN8710A */
  99. .edmac_endian = EDMAC_LITTLE_ENDIAN,
  100. .register_type = SH_ETH_REG_GIGABIT,
  101. .phy_interface = PHY_INTERFACE_MODE_MII,
  102. };
  103. static struct resource sh_eth_resources[] = {
  104. {
  105. .start = 0xe9a00000,
  106. .end = 0xe9a00800 - 1,
  107. .flags = IORESOURCE_MEM,
  108. }, {
  109. .start = 0xe9a01800,
  110. .end = 0xe9a02000 - 1,
  111. .flags = IORESOURCE_MEM,
  112. }, {
  113. .start = evt2irq(0x0500),
  114. .flags = IORESOURCE_IRQ,
  115. },
  116. };
  117. static struct platform_device sh_eth_device = {
  118. .name = "sh-eth",
  119. .dev = {
  120. .platform_data = &sh_eth_platdata,
  121. },
  122. .resource = sh_eth_resources,
  123. .num_resources = ARRAY_SIZE(sh_eth_resources),
  124. };
  125. /* LCDC */
  126. static struct fb_videomode lcdc0_mode = {
  127. .name = "AMPIER/AM-800480",
  128. .xres = 800,
  129. .yres = 480,
  130. .left_margin = 88,
  131. .right_margin = 40,
  132. .hsync_len = 128,
  133. .upper_margin = 20,
  134. .lower_margin = 5,
  135. .vsync_len = 5,
  136. .sync = 0,
  137. };
  138. static struct sh_mobile_lcdc_info lcdc0_info = {
  139. .clock_source = LCDC_CLK_BUS,
  140. .ch[0] = {
  141. .chan = LCDC_CHAN_MAINLCD,
  142. .fourcc = V4L2_PIX_FMT_RGB565,
  143. .interface_type = RGB24,
  144. .clock_divider = 5,
  145. .flags = 0,
  146. .lcd_modes = &lcdc0_mode,
  147. .num_modes = 1,
  148. .panel_cfg = {
  149. .width = 111,
  150. .height = 68,
  151. },
  152. },
  153. };
  154. static struct resource lcdc0_resources[] = {
  155. [0] = {
  156. .name = "LCD0",
  157. .start = 0xfe940000,
  158. .end = 0xfe943fff,
  159. .flags = IORESOURCE_MEM,
  160. },
  161. [1] = {
  162. .start = intcs_evt2irq(0x580),
  163. .flags = IORESOURCE_IRQ,
  164. },
  165. };
  166. static struct platform_device lcdc0_device = {
  167. .name = "sh_mobile_lcdc_fb",
  168. .num_resources = ARRAY_SIZE(lcdc0_resources),
  169. .resource = lcdc0_resources,
  170. .id = 0,
  171. .dev = {
  172. .platform_data = &lcdc0_info,
  173. .coherent_dma_mask = ~0,
  174. },
  175. };
  176. /* GPIO KEY */
  177. #define GPIO_KEY(c, g, d) { .code = c, .gpio = g, .desc = d, .active_low = 1 }
  178. static struct gpio_keys_button gpio_buttons[] = {
  179. GPIO_KEY(KEY_POWER, GPIO_PORT99, "SW1"),
  180. GPIO_KEY(KEY_BACK, GPIO_PORT100, "SW2"),
  181. GPIO_KEY(KEY_MENU, GPIO_PORT97, "SW3"),
  182. GPIO_KEY(KEY_HOME, GPIO_PORT98, "SW4"),
  183. };
  184. static struct gpio_keys_platform_data gpio_key_info = {
  185. .buttons = gpio_buttons,
  186. .nbuttons = ARRAY_SIZE(gpio_buttons),
  187. };
  188. static struct platform_device gpio_keys_device = {
  189. .name = "gpio-keys",
  190. .id = -1,
  191. .dev = {
  192. .platform_data = &gpio_key_info,
  193. },
  194. };
  195. /*
  196. * board devices
  197. */
  198. static struct platform_device *eva_devices[] __initdata = {
  199. &lcdc0_device,
  200. &gpio_keys_device,
  201. &sh_eth_device,
  202. };
  203. /*
  204. * board init
  205. */
  206. static void __init eva_init(void)
  207. {
  208. r8a7740_pinmux_init();
  209. /* SCIFA1 */
  210. gpio_request(GPIO_FN_SCIFA1_RXD, NULL);
  211. gpio_request(GPIO_FN_SCIFA1_TXD, NULL);
  212. /* LCDC0 */
  213. gpio_request(GPIO_FN_LCDC0_SELECT, NULL);
  214. gpio_request(GPIO_FN_LCD0_D0, NULL);
  215. gpio_request(GPIO_FN_LCD0_D1, NULL);
  216. gpio_request(GPIO_FN_LCD0_D2, NULL);
  217. gpio_request(GPIO_FN_LCD0_D3, NULL);
  218. gpio_request(GPIO_FN_LCD0_D4, NULL);
  219. gpio_request(GPIO_FN_LCD0_D5, NULL);
  220. gpio_request(GPIO_FN_LCD0_D6, NULL);
  221. gpio_request(GPIO_FN_LCD0_D7, NULL);
  222. gpio_request(GPIO_FN_LCD0_D8, NULL);
  223. gpio_request(GPIO_FN_LCD0_D9, NULL);
  224. gpio_request(GPIO_FN_LCD0_D10, NULL);
  225. gpio_request(GPIO_FN_LCD0_D11, NULL);
  226. gpio_request(GPIO_FN_LCD0_D12, NULL);
  227. gpio_request(GPIO_FN_LCD0_D13, NULL);
  228. gpio_request(GPIO_FN_LCD0_D14, NULL);
  229. gpio_request(GPIO_FN_LCD0_D15, NULL);
  230. gpio_request(GPIO_FN_LCD0_D16, NULL);
  231. gpio_request(GPIO_FN_LCD0_D17, NULL);
  232. gpio_request(GPIO_FN_LCD0_D18_PORT40, NULL);
  233. gpio_request(GPIO_FN_LCD0_D19_PORT4, NULL);
  234. gpio_request(GPIO_FN_LCD0_D20_PORT3, NULL);
  235. gpio_request(GPIO_FN_LCD0_D21_PORT2, NULL);
  236. gpio_request(GPIO_FN_LCD0_D22_PORT0, NULL);
  237. gpio_request(GPIO_FN_LCD0_D23_PORT1, NULL);
  238. gpio_request(GPIO_FN_LCD0_DCK, NULL);
  239. gpio_request(GPIO_FN_LCD0_VSYN, NULL);
  240. gpio_request(GPIO_FN_LCD0_HSYN, NULL);
  241. gpio_request(GPIO_FN_LCD0_DISP, NULL);
  242. gpio_request(GPIO_FN_LCD0_LCLK_PORT165, NULL);
  243. gpio_request(GPIO_PORT61, NULL); /* LCDDON */
  244. gpio_direction_output(GPIO_PORT61, 1);
  245. gpio_request(GPIO_PORT202, NULL); /* LCD0_LED_CONT */
  246. gpio_direction_output(GPIO_PORT202, 0);
  247. /* GETHER */
  248. gpio_request(GPIO_FN_ET_CRS, NULL);
  249. gpio_request(GPIO_FN_ET_MDC, NULL);
  250. gpio_request(GPIO_FN_ET_MDIO, NULL);
  251. gpio_request(GPIO_FN_ET_TX_ER, NULL);
  252. gpio_request(GPIO_FN_ET_RX_ER, NULL);
  253. gpio_request(GPIO_FN_ET_ERXD0, NULL);
  254. gpio_request(GPIO_FN_ET_ERXD1, NULL);
  255. gpio_request(GPIO_FN_ET_ERXD2, NULL);
  256. gpio_request(GPIO_FN_ET_ERXD3, NULL);
  257. gpio_request(GPIO_FN_ET_TX_CLK, NULL);
  258. gpio_request(GPIO_FN_ET_TX_EN, NULL);
  259. gpio_request(GPIO_FN_ET_ETXD0, NULL);
  260. gpio_request(GPIO_FN_ET_ETXD1, NULL);
  261. gpio_request(GPIO_FN_ET_ETXD2, NULL);
  262. gpio_request(GPIO_FN_ET_ETXD3, NULL);
  263. gpio_request(GPIO_FN_ET_PHY_INT, NULL);
  264. gpio_request(GPIO_FN_ET_COL, NULL);
  265. gpio_request(GPIO_FN_ET_RX_DV, NULL);
  266. gpio_request(GPIO_FN_ET_RX_CLK, NULL);
  267. gpio_request(GPIO_PORT18, NULL); /* PHY_RST */
  268. gpio_direction_output(GPIO_PORT18, 1);
  269. /*
  270. * CAUTION
  271. *
  272. * DBGMD/LCDC0/FSIA MUX
  273. * DBGMD_SELECT_B should be set after setting PFC Function.
  274. */
  275. gpio_request(GPIO_PORT176, NULL);
  276. gpio_direction_output(GPIO_PORT176, 1);
  277. #ifdef CONFIG_CACHE_L2X0
  278. /* Early BRESP enable, Shared attribute override enable, 32K*8way */
  279. l2x0_init(__io(0xf0002000), 0x40440000, 0x82000fff);
  280. #endif
  281. r8a7740_add_standard_devices();
  282. platform_add_devices(eva_devices,
  283. ARRAY_SIZE(eva_devices));
  284. }
  285. static void __init eva_earlytimer_init(void)
  286. {
  287. struct clk *xtal1;
  288. r8a7740_clock_init(MD_CK0 | MD_CK2);
  289. xtal1 = clk_get(NULL, "extal1");
  290. if (!IS_ERR(xtal1)) {
  291. /* armadillo 800 eva extal1 is 24MHz */
  292. clk_set_rate(xtal1, 24000000);
  293. clk_put(xtal1);
  294. }
  295. shmobile_earlytimer_init();
  296. }
  297. static void __init eva_add_early_devices(void)
  298. {
  299. r8a7740_add_early_devices();
  300. /* override timer setup with board-specific code */
  301. shmobile_timer.init = eva_earlytimer_init;
  302. }
  303. MACHINE_START(ARMADILLO800EVA, "armadillo800eva")
  304. .map_io = r8a7740_map_io,
  305. .init_early = eva_add_early_devices,
  306. .init_irq = r8a7740_init_irq,
  307. .handle_irq = shmobile_handle_irq_intc,
  308. .init_machine = eva_init,
  309. .timer = &shmobile_timer,
  310. MACHINE_END