board-armadillo800eva.c 7.4 KB

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