board-kzm9g.c 6.3 KB

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