board-kzm9g.c 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. /*
  2. * KZM-A9-GT board support
  3. *
  4. * Copyright (C) 2012 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
  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/delay.h>
  20. #include <linux/gpio.h>
  21. #include <linux/io.h>
  22. #include <linux/irq.h>
  23. #include <linux/i2c.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/smsc911x.h>
  26. #include <linux/usb/r8a66597.h>
  27. #include <linux/videodev2.h>
  28. #include <mach/irqs.h>
  29. #include <mach/sh73a0.h>
  30. #include <mach/common.h>
  31. #include <asm/hardware/cache-l2x0.h>
  32. #include <asm/hardware/gic.h>
  33. #include <asm/mach-types.h>
  34. #include <asm/mach/arch.h>
  35. #include <video/sh_mobile_lcdc.h>
  36. /* SMSC 9221 */
  37. static struct resource smsc9221_resources[] = {
  38. [0] = {
  39. .start = 0x10000000, /* CS4 */
  40. .end = 0x100000ff,
  41. .flags = IORESOURCE_MEM,
  42. },
  43. [1] = {
  44. .start = intcs_evt2irq(0x260), /* IRQ3 */
  45. .flags = IORESOURCE_IRQ,
  46. },
  47. };
  48. static struct smsc911x_platform_config smsc9221_platdata = {
  49. .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,
  50. .phy_interface = PHY_INTERFACE_MODE_MII,
  51. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  52. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  53. };
  54. static struct platform_device smsc_device = {
  55. .name = "smsc911x",
  56. .dev = {
  57. .platform_data = &smsc9221_platdata,
  58. },
  59. .resource = smsc9221_resources,
  60. .num_resources = ARRAY_SIZE(smsc9221_resources),
  61. };
  62. /* USB external chip */
  63. static struct r8a66597_platdata usb_host_data = {
  64. .on_chip = 0,
  65. .xtal = R8A66597_PLATDATA_XTAL_48MHZ,
  66. };
  67. static struct resource usb_resources[] = {
  68. [0] = {
  69. .start = 0x10010000,
  70. .end = 0x1001ffff - 1,
  71. .flags = IORESOURCE_MEM,
  72. },
  73. [1] = {
  74. .start = intcs_evt2irq(0x220), /* IRQ1 */
  75. .flags = IORESOURCE_IRQ,
  76. },
  77. };
  78. static struct platform_device usb_host_device = {
  79. .name = "r8a66597_hcd",
  80. .dev = {
  81. .platform_data = &usb_host_data,
  82. .dma_mask = NULL,
  83. .coherent_dma_mask = 0xffffffff,
  84. },
  85. .num_resources = ARRAY_SIZE(usb_resources),
  86. .resource = usb_resources,
  87. };
  88. /* LCDC */
  89. static struct fb_videomode kzm_lcdc_mode = {
  90. .name = "WVGA Panel",
  91. .xres = 800,
  92. .yres = 480,
  93. .left_margin = 220,
  94. .right_margin = 110,
  95. .hsync_len = 70,
  96. .upper_margin = 20,
  97. .lower_margin = 5,
  98. .vsync_len = 5,
  99. .sync = 0,
  100. };
  101. static struct sh_mobile_lcdc_info lcdc_info = {
  102. .clock_source = LCDC_CLK_BUS,
  103. .ch[0] = {
  104. .chan = LCDC_CHAN_MAINLCD,
  105. .fourcc = V4L2_PIX_FMT_RGB565,
  106. .interface_type = RGB24,
  107. .lcd_modes = &kzm_lcdc_mode,
  108. .num_modes = 1,
  109. .clock_divider = 5,
  110. .flags = 0,
  111. .panel_cfg = {
  112. .width = 152,
  113. .height = 91,
  114. },
  115. }
  116. };
  117. static struct resource lcdc_resources[] = {
  118. [0] = {
  119. .name = "LCDC",
  120. .start = 0xfe940000,
  121. .end = 0xfe943fff,
  122. .flags = IORESOURCE_MEM,
  123. },
  124. [1] = {
  125. .start = intcs_evt2irq(0x580),
  126. .flags = IORESOURCE_IRQ,
  127. },
  128. };
  129. static struct platform_device lcdc_device = {
  130. .name = "sh_mobile_lcdc_fb",
  131. .num_resources = ARRAY_SIZE(lcdc_resources),
  132. .resource = lcdc_resources,
  133. .dev = {
  134. .platform_data = &lcdc_info,
  135. .coherent_dma_mask = ~0,
  136. },
  137. };
  138. static struct i2c_board_info i2c1_devices[] = {
  139. {
  140. I2C_BOARD_INFO("st1232-ts", 0x55),
  141. .irq = intcs_evt2irq(0x300), /* IRQ8 */
  142. },
  143. };
  144. static struct platform_device *kzm_devices[] __initdata = {
  145. &smsc_device,
  146. &usb_host_device,
  147. &lcdc_device,
  148. };
  149. /*
  150. * FIXME
  151. *
  152. * This is quick hack for enabling LCDC backlight
  153. */
  154. static int __init as3711_enable_lcdc_backlight(void)
  155. {
  156. struct i2c_adapter *a = i2c_get_adapter(0);
  157. struct i2c_msg msg;
  158. int i, ret;
  159. __u8 magic[] = {
  160. 0x40, 0x2a,
  161. 0x43, 0x3c,
  162. 0x44, 0x3c,
  163. 0x45, 0x3c,
  164. 0x54, 0x03,
  165. 0x51, 0x00,
  166. 0x51, 0x01,
  167. 0xff, 0x00, /* wait */
  168. 0x43, 0xf0,
  169. 0x44, 0xf0,
  170. 0x45, 0xf0,
  171. };
  172. if (!machine_is_kzm9g())
  173. return 0;
  174. if (!a)
  175. return 0;
  176. msg.addr = 0x40;
  177. msg.len = 2;
  178. msg.flags = 0;
  179. for (i = 0; i < ARRAY_SIZE(magic); i += 2) {
  180. msg.buf = magic + i;
  181. if (0xff == msg.buf[0]) {
  182. udelay(500);
  183. continue;
  184. }
  185. ret = i2c_transfer(a, &msg, 1);
  186. if (ret < 0) {
  187. pr_err("i2c transfer fail\n");
  188. break;
  189. }
  190. }
  191. return 0;
  192. }
  193. device_initcall(as3711_enable_lcdc_backlight);
  194. static void __init kzm_init(void)
  195. {
  196. sh73a0_pinmux_init();
  197. /* enable SCIFA4 */
  198. gpio_request(GPIO_FN_SCIFA4_TXD, NULL);
  199. gpio_request(GPIO_FN_SCIFA4_RXD, NULL);
  200. gpio_request(GPIO_FN_SCIFA4_RTS_, NULL);
  201. gpio_request(GPIO_FN_SCIFA4_CTS_, NULL);
  202. /* CS4 for SMSC/USB */
  203. gpio_request(GPIO_FN_CS4_, NULL); /* CS4 */
  204. /* SMSC */
  205. gpio_request(GPIO_PORT224, NULL); /* IRQ3 */
  206. gpio_direction_input(GPIO_PORT224);
  207. /* LCDC */
  208. gpio_request(GPIO_FN_LCDD23, NULL);
  209. gpio_request(GPIO_FN_LCDD22, NULL);
  210. gpio_request(GPIO_FN_LCDD21, NULL);
  211. gpio_request(GPIO_FN_LCDD20, NULL);
  212. gpio_request(GPIO_FN_LCDD19, NULL);
  213. gpio_request(GPIO_FN_LCDD18, NULL);
  214. gpio_request(GPIO_FN_LCDD17, NULL);
  215. gpio_request(GPIO_FN_LCDD16, NULL);
  216. gpio_request(GPIO_FN_LCDD15, NULL);
  217. gpio_request(GPIO_FN_LCDD14, NULL);
  218. gpio_request(GPIO_FN_LCDD13, NULL);
  219. gpio_request(GPIO_FN_LCDD12, NULL);
  220. gpio_request(GPIO_FN_LCDD11, NULL);
  221. gpio_request(GPIO_FN_LCDD10, NULL);
  222. gpio_request(GPIO_FN_LCDD9, NULL);
  223. gpio_request(GPIO_FN_LCDD8, NULL);
  224. gpio_request(GPIO_FN_LCDD7, NULL);
  225. gpio_request(GPIO_FN_LCDD6, NULL);
  226. gpio_request(GPIO_FN_LCDD5, NULL);
  227. gpio_request(GPIO_FN_LCDD4, NULL);
  228. gpio_request(GPIO_FN_LCDD3, NULL);
  229. gpio_request(GPIO_FN_LCDD2, NULL);
  230. gpio_request(GPIO_FN_LCDD1, NULL);
  231. gpio_request(GPIO_FN_LCDD0, NULL);
  232. gpio_request(GPIO_FN_LCDDISP, NULL);
  233. gpio_request(GPIO_FN_LCDDCK, NULL);
  234. gpio_request(GPIO_PORT222, NULL); /* LCDCDON */
  235. gpio_request(GPIO_PORT226, NULL); /* SC */
  236. gpio_direction_output(GPIO_PORT222, 1);
  237. gpio_direction_output(GPIO_PORT226, 1);
  238. /* Touchscreen */
  239. gpio_request(GPIO_PORT223, NULL); /* IRQ8 */
  240. gpio_direction_input(GPIO_PORT223);
  241. #ifdef CONFIG_CACHE_L2X0
  242. /* Early BRESP enable, Shared attribute override enable, 64K*8way */
  243. l2x0_init(IOMEM(0xf0100000), 0x40460000, 0x82000fff);
  244. #endif
  245. i2c_register_board_info(1, i2c1_devices, ARRAY_SIZE(i2c1_devices));
  246. sh73a0_add_standard_devices();
  247. platform_add_devices(kzm_devices, ARRAY_SIZE(kzm_devices));
  248. }
  249. MACHINE_START(KZM9G, "kzm9g")
  250. .map_io = sh73a0_map_io,
  251. .init_early = sh73a0_add_early_devices,
  252. .nr_irqs = NR_IRQS_LEGACY,
  253. .init_irq = sh73a0_init_irq,
  254. .handle_irq = gic_handle_irq,
  255. .init_machine = kzm_init,
  256. .timer = &shmobile_timer,
  257. MACHINE_END