setup.c 16 KB

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