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