board-armadillo800eva.c 6.7 KB

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