setup.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  1. /*
  2. * KFR2R09 board support code
  3. *
  4. * Copyright (C) 2009 Magnus Damm
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file "COPYING" in the main directory of this archive
  8. * for more details.
  9. */
  10. #include <linux/init.h>
  11. #include <linux/platform_device.h>
  12. #include <linux/interrupt.h>
  13. #include <linux/mmc/host.h>
  14. #include <linux/mfd/tmio.h>
  15. #include <linux/mtd/physmap.h>
  16. #include <linux/mtd/onenand.h>
  17. #include <linux/delay.h>
  18. #include <linux/clk.h>
  19. #include <linux/gpio.h>
  20. #include <linux/input.h>
  21. #include <linux/input/sh_keysc.h>
  22. #include <linux/i2c.h>
  23. #include <linux/platform_data/lv5207lp.h>
  24. #include <linux/regulator/fixed.h>
  25. #include <linux/regulator/machine.h>
  26. #include <linux/usb/r8a66597.h>
  27. #include <linux/videodev2.h>
  28. #include <linux/sh_intc.h>
  29. #include <media/i2c/rj54n1cb0c.h>
  30. #include <media/soc_camera.h>
  31. #include <media/drv-intf/sh_mobile_ceu.h>
  32. #include <video/sh_mobile_lcdc.h>
  33. #include <asm/suspend.h>
  34. #include <asm/clock.h>
  35. #include <asm/machvec.h>
  36. #include <asm/io.h>
  37. #include <cpu/sh7724.h>
  38. #include <mach/kfr2r09.h>
  39. static struct mtd_partition kfr2r09_nor_flash_partitions[] =
  40. {
  41. {
  42. .name = "boot",
  43. .offset = 0,
  44. .size = (4 * 1024 * 1024),
  45. .mask_flags = MTD_WRITEABLE, /* Read-only */
  46. },
  47. {
  48. .name = "other",
  49. .offset = MTDPART_OFS_APPEND,
  50. .size = MTDPART_SIZ_FULL,
  51. },
  52. };
  53. static struct physmap_flash_data kfr2r09_nor_flash_data = {
  54. .width = 2,
  55. .parts = kfr2r09_nor_flash_partitions,
  56. .nr_parts = ARRAY_SIZE(kfr2r09_nor_flash_partitions),
  57. };
  58. static struct resource kfr2r09_nor_flash_resources[] = {
  59. [0] = {
  60. .name = "NOR Flash",
  61. .start = 0x00000000,
  62. .end = 0x03ffffff,
  63. .flags = IORESOURCE_MEM,
  64. }
  65. };
  66. static struct platform_device kfr2r09_nor_flash_device = {
  67. .name = "physmap-flash",
  68. .resource = kfr2r09_nor_flash_resources,
  69. .num_resources = ARRAY_SIZE(kfr2r09_nor_flash_resources),
  70. .dev = {
  71. .platform_data = &kfr2r09_nor_flash_data,
  72. },
  73. };
  74. static struct resource kfr2r09_nand_flash_resources[] = {
  75. [0] = {
  76. .name = "NAND Flash",
  77. .start = 0x10000000,
  78. .end = 0x1001ffff,
  79. .flags = IORESOURCE_MEM,
  80. }
  81. };
  82. static struct platform_device kfr2r09_nand_flash_device = {
  83. .name = "onenand-flash",
  84. .resource = kfr2r09_nand_flash_resources,
  85. .num_resources = ARRAY_SIZE(kfr2r09_nand_flash_resources),
  86. };
  87. static struct sh_keysc_info kfr2r09_sh_keysc_info = {
  88. .mode = SH_KEYSC_MODE_1, /* KEYOUT0->4, KEYIN0->4 */
  89. .scan_timing = 3,
  90. .delay = 10,
  91. .keycodes = {
  92. KEY_PHONE, KEY_CLEAR, KEY_MAIL, KEY_WWW, KEY_ENTER,
  93. KEY_1, KEY_2, KEY_3, 0, KEY_UP,
  94. KEY_4, KEY_5, KEY_6, 0, KEY_LEFT,
  95. KEY_7, KEY_8, KEY_9, KEY_PROG1, KEY_RIGHT,
  96. KEY_S, KEY_0, KEY_P, KEY_PROG2, KEY_DOWN,
  97. 0, 0, 0, 0, 0
  98. },
  99. };
  100. static struct resource kfr2r09_sh_keysc_resources[] = {
  101. [0] = {
  102. .name = "KEYSC",
  103. .start = 0x044b0000,
  104. .end = 0x044b000f,
  105. .flags = IORESOURCE_MEM,
  106. },
  107. [1] = {
  108. .start = evt2irq(0xbe0),
  109. .flags = IORESOURCE_IRQ,
  110. },
  111. };
  112. static struct platform_device kfr2r09_sh_keysc_device = {
  113. .name = "sh_keysc",
  114. .id = 0, /* "keysc0" clock */
  115. .num_resources = ARRAY_SIZE(kfr2r09_sh_keysc_resources),
  116. .resource = kfr2r09_sh_keysc_resources,
  117. .dev = {
  118. .platform_data = &kfr2r09_sh_keysc_info,
  119. },
  120. };
  121. static const struct fb_videomode kfr2r09_lcdc_modes[] = {
  122. {
  123. .name = "TX07D34VM0AAA",
  124. .xres = 240,
  125. .yres = 400,
  126. .left_margin = 0,
  127. .right_margin = 16,
  128. .hsync_len = 8,
  129. .upper_margin = 0,
  130. .lower_margin = 1,
  131. .vsync_len = 1,
  132. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  133. },
  134. };
  135. static struct sh_mobile_lcdc_info kfr2r09_sh_lcdc_info = {
  136. .clock_source = LCDC_CLK_BUS,
  137. .ch[0] = {
  138. .chan = LCDC_CHAN_MAINLCD,
  139. .fourcc = V4L2_PIX_FMT_RGB565,
  140. .interface_type = SYS18,
  141. .clock_divider = 6,
  142. .flags = LCDC_FLAGS_DWPOL,
  143. .lcd_modes = kfr2r09_lcdc_modes,
  144. .num_modes = ARRAY_SIZE(kfr2r09_lcdc_modes),
  145. .panel_cfg = {
  146. .width = 35,
  147. .height = 58,
  148. .setup_sys = kfr2r09_lcd_setup,
  149. .start_transfer = kfr2r09_lcd_start,
  150. },
  151. .sys_bus_cfg = {
  152. .ldmt2r = 0x07010904,
  153. .ldmt3r = 0x14012914,
  154. /* set 1s delay to encourage fsync() */
  155. .deferred_io_msec = 1000,
  156. },
  157. }
  158. };
  159. static struct resource kfr2r09_sh_lcdc_resources[] = {
  160. [0] = {
  161. .name = "LCDC",
  162. .start = 0xfe940000, /* P4-only space */
  163. .end = 0xfe942fff,
  164. .flags = IORESOURCE_MEM,
  165. },
  166. [1] = {
  167. .start = evt2irq(0xf40),
  168. .flags = IORESOURCE_IRQ,
  169. },
  170. };
  171. static struct platform_device kfr2r09_sh_lcdc_device = {
  172. .name = "sh_mobile_lcdc_fb",
  173. .num_resources = ARRAY_SIZE(kfr2r09_sh_lcdc_resources),
  174. .resource = kfr2r09_sh_lcdc_resources,
  175. .dev = {
  176. .platform_data = &kfr2r09_sh_lcdc_info,
  177. },
  178. };
  179. static struct lv5207lp_platform_data kfr2r09_backlight_data = {
  180. .fbdev = &kfr2r09_sh_lcdc_device.dev,
  181. .def_value = 13,
  182. .max_value = 13,
  183. };
  184. static struct i2c_board_info kfr2r09_backlight_board_info = {
  185. I2C_BOARD_INFO("lv5207lp", 0x75),
  186. .platform_data = &kfr2r09_backlight_data,
  187. };
  188. static struct r8a66597_platdata kfr2r09_usb0_gadget_data = {
  189. .on_chip = 1,
  190. };
  191. static struct resource kfr2r09_usb0_gadget_resources[] = {
  192. [0] = {
  193. .start = 0x04d80000,
  194. .end = 0x04d80123,
  195. .flags = IORESOURCE_MEM,
  196. },
  197. [1] = {
  198. .start = evt2irq(0xa20),
  199. .end = evt2irq(0xa20),
  200. .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
  201. },
  202. };
  203. static struct platform_device kfr2r09_usb0_gadget_device = {
  204. .name = "r8a66597_udc",
  205. .id = 0,
  206. .dev = {
  207. .dma_mask = NULL, /* not use dma */
  208. .coherent_dma_mask = 0xffffffff,
  209. .platform_data = &kfr2r09_usb0_gadget_data,
  210. },
  211. .num_resources = ARRAY_SIZE(kfr2r09_usb0_gadget_resources),
  212. .resource = kfr2r09_usb0_gadget_resources,
  213. };
  214. static struct sh_mobile_ceu_info sh_mobile_ceu_info = {
  215. .flags = SH_CEU_FLAG_USE_8BIT_BUS,
  216. };
  217. static struct resource kfr2r09_ceu_resources[] = {
  218. [0] = {
  219. .name = "CEU",
  220. .start = 0xfe910000,
  221. .end = 0xfe91009f,
  222. .flags = IORESOURCE_MEM,
  223. },
  224. [1] = {
  225. .start = evt2irq(0x880),
  226. .end = evt2irq(0x880),
  227. .flags = IORESOURCE_IRQ,
  228. },
  229. [2] = {
  230. /* place holder for contiguous memory */
  231. },
  232. };
  233. static struct platform_device kfr2r09_ceu_device = {
  234. .name = "sh_mobile_ceu",
  235. .id = 0, /* "ceu0" clock */
  236. .num_resources = ARRAY_SIZE(kfr2r09_ceu_resources),
  237. .resource = kfr2r09_ceu_resources,
  238. .dev = {
  239. .platform_data = &sh_mobile_ceu_info,
  240. },
  241. };
  242. static struct i2c_board_info kfr2r09_i2c_camera = {
  243. I2C_BOARD_INFO("rj54n1cb0c", 0x50),
  244. };
  245. static struct clk *camera_clk;
  246. /* set VIO_CKO clock to 25MHz */
  247. #define CEU_MCLK_FREQ 25000000
  248. #define DRVCRB 0xA405018C
  249. static int camera_power(struct device *dev, int mode)
  250. {
  251. int ret;
  252. if (mode) {
  253. long rate;
  254. camera_clk = clk_get(NULL, "video_clk");
  255. if (IS_ERR(camera_clk))
  256. return PTR_ERR(camera_clk);
  257. rate = clk_round_rate(camera_clk, CEU_MCLK_FREQ);
  258. ret = clk_set_rate(camera_clk, rate);
  259. if (ret < 0)
  260. goto eclkrate;
  261. /* set DRVCRB
  262. *
  263. * use 1.8 V for VccQ_VIO
  264. * use 2.85V for VccQ_SR
  265. */
  266. __raw_writew((__raw_readw(DRVCRB) & ~0x0003) | 0x0001, DRVCRB);
  267. /* reset clear */
  268. ret = gpio_request(GPIO_PTB4, NULL);
  269. if (ret < 0)
  270. goto eptb4;
  271. ret = gpio_request(GPIO_PTB7, NULL);
  272. if (ret < 0)
  273. goto eptb7;
  274. ret = gpio_direction_output(GPIO_PTB4, 1);
  275. if (!ret)
  276. ret = gpio_direction_output(GPIO_PTB7, 1);
  277. if (ret < 0)
  278. goto egpioout;
  279. msleep(1);
  280. ret = clk_enable(camera_clk); /* start VIO_CKO */
  281. if (ret < 0)
  282. goto eclkon;
  283. return 0;
  284. }
  285. ret = 0;
  286. clk_disable(camera_clk);
  287. eclkon:
  288. gpio_set_value(GPIO_PTB7, 0);
  289. egpioout:
  290. gpio_set_value(GPIO_PTB4, 0);
  291. gpio_free(GPIO_PTB7);
  292. eptb7:
  293. gpio_free(GPIO_PTB4);
  294. eptb4:
  295. eclkrate:
  296. clk_put(camera_clk);
  297. return ret;
  298. }
  299. static struct rj54n1_pdata rj54n1_priv = {
  300. .mclk_freq = CEU_MCLK_FREQ,
  301. .ioctl_high = false,
  302. };
  303. static struct soc_camera_link rj54n1_link = {
  304. .power = camera_power,
  305. .board_info = &kfr2r09_i2c_camera,
  306. .i2c_adapter_id = 1,
  307. .priv = &rj54n1_priv,
  308. };
  309. static struct platform_device kfr2r09_camera = {
  310. .name = "soc-camera-pdrv",
  311. .id = 0,
  312. .dev = {
  313. .platform_data = &rj54n1_link,
  314. },
  315. };
  316. /* Fixed 3.3V regulator to be used by SDHI0 */
  317. static struct regulator_consumer_supply fixed3v3_power_consumers[] =
  318. {
  319. REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
  320. REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
  321. };
  322. static struct resource kfr2r09_sh_sdhi0_resources[] = {
  323. [0] = {
  324. .name = "SDHI0",
  325. .start = 0x04ce0000,
  326. .end = 0x04ce00ff,
  327. .flags = IORESOURCE_MEM,
  328. },
  329. [1] = {
  330. .start = evt2irq(0xe80),
  331. .flags = IORESOURCE_IRQ,
  332. },
  333. };
  334. static struct tmio_mmc_data sh7724_sdhi0_data = {
  335. .chan_priv_tx = (void *)SHDMA_SLAVE_SDHI0_TX,
  336. .chan_priv_rx = (void *)SHDMA_SLAVE_SDHI0_RX,
  337. .flags = TMIO_MMC_WRPROTECT_DISABLE,
  338. .capabilities = MMC_CAP_SDIO_IRQ,
  339. };
  340. static struct platform_device kfr2r09_sh_sdhi0_device = {
  341. .name = "sh_mobile_sdhi",
  342. .num_resources = ARRAY_SIZE(kfr2r09_sh_sdhi0_resources),
  343. .resource = kfr2r09_sh_sdhi0_resources,
  344. .dev = {
  345. .platform_data = &sh7724_sdhi0_data,
  346. },
  347. };
  348. static struct platform_device *kfr2r09_devices[] __initdata = {
  349. &kfr2r09_nor_flash_device,
  350. &kfr2r09_nand_flash_device,
  351. &kfr2r09_sh_keysc_device,
  352. &kfr2r09_sh_lcdc_device,
  353. &kfr2r09_ceu_device,
  354. &kfr2r09_camera,
  355. &kfr2r09_sh_sdhi0_device,
  356. };
  357. #define BSC_CS0BCR 0xfec10004
  358. #define BSC_CS0WCR 0xfec10024
  359. #define BSC_CS4BCR 0xfec10010
  360. #define BSC_CS4WCR 0xfec10030
  361. #define PORT_MSELCRB 0xa4050182
  362. #ifdef CONFIG_I2C
  363. static int kfr2r09_usb0_gadget_i2c_setup(void)
  364. {
  365. struct i2c_adapter *a;
  366. struct i2c_msg msg;
  367. unsigned char buf[2];
  368. int ret;
  369. a = i2c_get_adapter(0);
  370. if (!a)
  371. return -ENODEV;
  372. /* set bit 1 (the second bit) of chip at 0x09, register 0x13 */
  373. buf[0] = 0x13;
  374. msg.addr = 0x09;
  375. msg.buf = buf;
  376. msg.len = 1;
  377. msg.flags = 0;
  378. ret = i2c_transfer(a, &msg, 1);
  379. if (ret != 1)
  380. return -ENODEV;
  381. buf[0] = 0;
  382. msg.addr = 0x09;
  383. msg.buf = buf;
  384. msg.len = 1;
  385. msg.flags = I2C_M_RD;
  386. ret = i2c_transfer(a, &msg, 1);
  387. if (ret != 1)
  388. return -ENODEV;
  389. buf[1] = buf[0] | (1 << 1);
  390. buf[0] = 0x13;
  391. msg.addr = 0x09;
  392. msg.buf = buf;
  393. msg.len = 2;
  394. msg.flags = 0;
  395. ret = i2c_transfer(a, &msg, 1);
  396. if (ret != 1)
  397. return -ENODEV;
  398. return 0;
  399. }
  400. static int kfr2r09_serial_i2c_setup(void)
  401. {
  402. struct i2c_adapter *a;
  403. struct i2c_msg msg;
  404. unsigned char buf[2];
  405. int ret;
  406. a = i2c_get_adapter(0);
  407. if (!a)
  408. return -ENODEV;
  409. /* set bit 6 (the 7th bit) of chip at 0x09, register 0x13 */
  410. buf[0] = 0x13;
  411. msg.addr = 0x09;
  412. msg.buf = buf;
  413. msg.len = 1;
  414. msg.flags = 0;
  415. ret = i2c_transfer(a, &msg, 1);
  416. if (ret != 1)
  417. return -ENODEV;
  418. buf[0] = 0;
  419. msg.addr = 0x09;
  420. msg.buf = buf;
  421. msg.len = 1;
  422. msg.flags = I2C_M_RD;
  423. ret = i2c_transfer(a, &msg, 1);
  424. if (ret != 1)
  425. return -ENODEV;
  426. buf[1] = buf[0] | (1 << 6);
  427. buf[0] = 0x13;
  428. msg.addr = 0x09;
  429. msg.buf = buf;
  430. msg.len = 2;
  431. msg.flags = 0;
  432. ret = i2c_transfer(a, &msg, 1);
  433. if (ret != 1)
  434. return -ENODEV;
  435. return 0;
  436. }
  437. #else
  438. static int kfr2r09_usb0_gadget_i2c_setup(void)
  439. {
  440. return -ENODEV;
  441. }
  442. static int kfr2r09_serial_i2c_setup(void)
  443. {
  444. return -ENODEV;
  445. }
  446. #endif
  447. static int kfr2r09_usb0_gadget_setup(void)
  448. {
  449. int plugged_in;
  450. gpio_request(GPIO_PTN4, NULL); /* USB_DET */
  451. gpio_direction_input(GPIO_PTN4);
  452. plugged_in = gpio_get_value(GPIO_PTN4);
  453. if (!plugged_in)
  454. return -ENODEV; /* no cable plugged in */
  455. if (kfr2r09_usb0_gadget_i2c_setup() != 0)
  456. return -ENODEV; /* unable to configure using i2c */
  457. __raw_writew((__raw_readw(PORT_MSELCRB) & ~0xc000) | 0x8000, PORT_MSELCRB);
  458. gpio_request(GPIO_FN_PDSTATUS, NULL); /* R-standby disables USB clock */
  459. gpio_request(GPIO_PTV6, NULL); /* USBCLK_ON */
  460. gpio_direction_output(GPIO_PTV6, 1); /* USBCLK_ON = H */
  461. msleep(20); /* wait 20ms to let the clock settle */
  462. clk_enable(clk_get(NULL, "usb0"));
  463. __raw_writew(0x0600, 0xa40501d4);
  464. return 0;
  465. }
  466. extern char kfr2r09_sdram_enter_start;
  467. extern char kfr2r09_sdram_enter_end;
  468. extern char kfr2r09_sdram_leave_start;
  469. extern char kfr2r09_sdram_leave_end;
  470. static int __init kfr2r09_devices_setup(void)
  471. {
  472. /* register board specific self-refresh code */
  473. sh_mobile_register_self_refresh(SUSP_SH_STANDBY | SUSP_SH_SF |
  474. SUSP_SH_RSTANDBY,
  475. &kfr2r09_sdram_enter_start,
  476. &kfr2r09_sdram_enter_end,
  477. &kfr2r09_sdram_leave_start,
  478. &kfr2r09_sdram_leave_end);
  479. regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers,
  480. ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
  481. /* enable SCIF1 serial port for YC401 console support */
  482. gpio_request(GPIO_FN_SCIF1_RXD, NULL);
  483. gpio_request(GPIO_FN_SCIF1_TXD, NULL);
  484. kfr2r09_serial_i2c_setup(); /* ECONTMSK(bit6=L10ONEN) set 1 */
  485. gpio_request(GPIO_PTG3, NULL); /* HPON_ON */
  486. gpio_direction_output(GPIO_PTG3, 1); /* HPON_ON = H */
  487. /* setup NOR flash at CS0 */
  488. __raw_writel(0x36db0400, BSC_CS0BCR);
  489. __raw_writel(0x00000500, BSC_CS0WCR);
  490. /* setup NAND flash at CS4 */
  491. __raw_writel(0x36db0400, BSC_CS4BCR);
  492. __raw_writel(0x00000500, BSC_CS4WCR);
  493. /* setup KEYSC pins */
  494. gpio_request(GPIO_FN_KEYOUT0, NULL);
  495. gpio_request(GPIO_FN_KEYOUT1, NULL);
  496. gpio_request(GPIO_FN_KEYOUT2, NULL);
  497. gpio_request(GPIO_FN_KEYOUT3, NULL);
  498. gpio_request(GPIO_FN_KEYOUT4_IN6, NULL);
  499. gpio_request(GPIO_FN_KEYIN0, NULL);
  500. gpio_request(GPIO_FN_KEYIN1, NULL);
  501. gpio_request(GPIO_FN_KEYIN2, NULL);
  502. gpio_request(GPIO_FN_KEYIN3, NULL);
  503. gpio_request(GPIO_FN_KEYIN4, NULL);
  504. gpio_request(GPIO_FN_KEYOUT5_IN5, NULL);
  505. /* setup LCDC pins for SYS panel */
  506. gpio_request(GPIO_FN_LCDD17, NULL);
  507. gpio_request(GPIO_FN_LCDD16, NULL);
  508. gpio_request(GPIO_FN_LCDD15, NULL);
  509. gpio_request(GPIO_FN_LCDD14, NULL);
  510. gpio_request(GPIO_FN_LCDD13, NULL);
  511. gpio_request(GPIO_FN_LCDD12, NULL);
  512. gpio_request(GPIO_FN_LCDD11, NULL);
  513. gpio_request(GPIO_FN_LCDD10, NULL);
  514. gpio_request(GPIO_FN_LCDD9, NULL);
  515. gpio_request(GPIO_FN_LCDD8, NULL);
  516. gpio_request(GPIO_FN_LCDD7, NULL);
  517. gpio_request(GPIO_FN_LCDD6, NULL);
  518. gpio_request(GPIO_FN_LCDD5, NULL);
  519. gpio_request(GPIO_FN_LCDD4, NULL);
  520. gpio_request(GPIO_FN_LCDD3, NULL);
  521. gpio_request(GPIO_FN_LCDD2, NULL);
  522. gpio_request(GPIO_FN_LCDD1, NULL);
  523. gpio_request(GPIO_FN_LCDD0, NULL);
  524. gpio_request(GPIO_FN_LCDRS, NULL); /* LCD_RS */
  525. gpio_request(GPIO_FN_LCDCS, NULL); /* LCD_CS/ */
  526. gpio_request(GPIO_FN_LCDRD, NULL); /* LCD_RD/ */
  527. gpio_request(GPIO_FN_LCDWR, NULL); /* LCD_WR/ */
  528. gpio_request(GPIO_FN_LCDVSYN, NULL); /* LCD_VSYNC */
  529. gpio_request(GPIO_PTE4, NULL); /* LCD_RST/ */
  530. gpio_direction_output(GPIO_PTE4, 1);
  531. gpio_request(GPIO_PTF4, NULL); /* PROTECT/ */
  532. gpio_direction_output(GPIO_PTF4, 1);
  533. gpio_request(GPIO_PTU0, NULL); /* LEDSTDBY/ */
  534. gpio_direction_output(GPIO_PTU0, 1);
  535. /* setup USB function */
  536. if (kfr2r09_usb0_gadget_setup() == 0)
  537. platform_device_register(&kfr2r09_usb0_gadget_device);
  538. /* CEU */
  539. gpio_request(GPIO_FN_VIO_CKO, NULL);
  540. gpio_request(GPIO_FN_VIO0_CLK, NULL);
  541. gpio_request(GPIO_FN_VIO0_VD, NULL);
  542. gpio_request(GPIO_FN_VIO0_HD, NULL);
  543. gpio_request(GPIO_FN_VIO0_FLD, NULL);
  544. gpio_request(GPIO_FN_VIO0_D7, NULL);
  545. gpio_request(GPIO_FN_VIO0_D6, NULL);
  546. gpio_request(GPIO_FN_VIO0_D5, NULL);
  547. gpio_request(GPIO_FN_VIO0_D4, NULL);
  548. gpio_request(GPIO_FN_VIO0_D3, NULL);
  549. gpio_request(GPIO_FN_VIO0_D2, NULL);
  550. gpio_request(GPIO_FN_VIO0_D1, NULL);
  551. gpio_request(GPIO_FN_VIO0_D0, NULL);
  552. platform_resource_setup_memory(&kfr2r09_ceu_device, "ceu", 4 << 20);
  553. /* SDHI0 connected to yc304 */
  554. gpio_request(GPIO_FN_SDHI0CD, NULL);
  555. gpio_request(GPIO_FN_SDHI0D3, NULL);
  556. gpio_request(GPIO_FN_SDHI0D2, NULL);
  557. gpio_request(GPIO_FN_SDHI0D1, NULL);
  558. gpio_request(GPIO_FN_SDHI0D0, NULL);
  559. gpio_request(GPIO_FN_SDHI0CMD, NULL);
  560. gpio_request(GPIO_FN_SDHI0CLK, NULL);
  561. i2c_register_board_info(0, &kfr2r09_backlight_board_info, 1);
  562. return platform_add_devices(kfr2r09_devices,
  563. ARRAY_SIZE(kfr2r09_devices));
  564. }
  565. device_initcall(kfr2r09_devices_setup);
  566. /* Return the board specific boot mode pin configuration */
  567. static int kfr2r09_mode_pins(void)
  568. {
  569. /* MD0=1, MD1=1, MD2=0: Clock Mode 3
  570. * MD3=0: 16-bit Area0 Bus Width
  571. * MD5=1: Little Endian
  572. * MD8=1: Test Mode Disabled
  573. */
  574. return MODE_PIN0 | MODE_PIN1 | MODE_PIN5 | MODE_PIN8;
  575. }
  576. /*
  577. * The Machine Vector
  578. */
  579. static struct sh_machine_vector mv_kfr2r09 __initmv = {
  580. .mv_name = "kfr2r09",
  581. .mv_mode_pins = kfr2r09_mode_pins,
  582. };