setup.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Renesas System Solutions Asia Pte. Ltd - Migo-R
  4. *
  5. * Copyright (C) 2008 Magnus Damm
  6. */
  7. #include <linux/clkdev.h>
  8. #include <linux/dma-mapping.h>
  9. #include <linux/init.h>
  10. #include <linux/platform_device.h>
  11. #include <linux/interrupt.h>
  12. #include <linux/input.h>
  13. #include <linux/input/sh_keysc.h>
  14. #include <linux/memblock.h>
  15. #include <linux/mmc/host.h>
  16. #include <linux/mtd/physmap.h>
  17. #include <linux/mfd/tmio.h>
  18. #include <linux/mtd/rawnand.h>
  19. #include <linux/i2c.h>
  20. #include <linux/regulator/fixed.h>
  21. #include <linux/regulator/machine.h>
  22. #include <linux/smc91x.h>
  23. #include <linux/delay.h>
  24. #include <linux/clk.h>
  25. #include <linux/gpio.h>
  26. #include <linux/gpio/machine.h>
  27. #include <linux/videodev2.h>
  28. #include <linux/sh_intc.h>
  29. #include <video/sh_mobile_lcdc.h>
  30. #include <media/drv-intf/renesas-ceu.h>
  31. #include <media/i2c/ov772x.h>
  32. #include <media/i2c/tw9910.h>
  33. #include <asm/clock.h>
  34. #include <asm/machvec.h>
  35. #include <asm/io.h>
  36. #include <asm/suspend.h>
  37. #include <mach/migor.h>
  38. #include <cpu/sh7722.h>
  39. /* Address IRQ Size Bus Description
  40. * 0x00000000 64MB 16 NOR Flash (SP29PL256N)
  41. * 0x0c000000 64MB 64 SDRAM (2xK4M563233G)
  42. * 0x10000000 IRQ0 16 Ethernet (SMC91C111)
  43. * 0x14000000 IRQ4 16 USB 2.0 Host Controller (M66596)
  44. * 0x18000000 8GB 8 NAND Flash (K9K8G08U0A)
  45. */
  46. #define CEU_BUFFER_MEMORY_SIZE (4 << 20)
  47. static phys_addr_t ceu_dma_membase;
  48. static struct smc91x_platdata smc91x_info = {
  49. .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
  50. };
  51. static struct resource smc91x_eth_resources[] = {
  52. [0] = {
  53. .name = "SMC91C111" ,
  54. .start = 0x10000300,
  55. .end = 0x1000030f,
  56. .flags = IORESOURCE_MEM,
  57. },
  58. [1] = {
  59. .start = evt2irq(0x600), /* IRQ0 */
  60. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  61. },
  62. };
  63. static struct platform_device smc91x_eth_device = {
  64. .name = "smc91x",
  65. .num_resources = ARRAY_SIZE(smc91x_eth_resources),
  66. .resource = smc91x_eth_resources,
  67. .dev = {
  68. .platform_data = &smc91x_info,
  69. },
  70. };
  71. static struct sh_keysc_info sh_keysc_info = {
  72. .mode = SH_KEYSC_MODE_2, /* KEYOUT0->4, KEYIN1->5 */
  73. .scan_timing = 3,
  74. .delay = 5,
  75. .keycodes = {
  76. 0, KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT, KEY_ENTER,
  77. 0, KEY_F, KEY_C, KEY_D, KEY_H, KEY_1,
  78. 0, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6,
  79. 0, KEY_7, KEY_8, KEY_9, KEY_S, KEY_0,
  80. 0, KEY_P, KEY_STOP, KEY_REWIND, KEY_PLAY, KEY_FASTFORWARD,
  81. },
  82. };
  83. static struct resource sh_keysc_resources[] = {
  84. [0] = {
  85. .start = 0x044b0000,
  86. .end = 0x044b000f,
  87. .flags = IORESOURCE_MEM,
  88. },
  89. [1] = {
  90. .start = evt2irq(0xbe0),
  91. .flags = IORESOURCE_IRQ,
  92. },
  93. };
  94. static struct platform_device sh_keysc_device = {
  95. .name = "sh_keysc",
  96. .id = 0, /* "keysc0" clock */
  97. .num_resources = ARRAY_SIZE(sh_keysc_resources),
  98. .resource = sh_keysc_resources,
  99. .dev = {
  100. .platform_data = &sh_keysc_info,
  101. },
  102. };
  103. static struct mtd_partition migor_nor_flash_partitions[] =
  104. {
  105. {
  106. .name = "uboot",
  107. .offset = 0,
  108. .size = (1 * 1024 * 1024),
  109. .mask_flags = MTD_WRITEABLE, /* Read-only */
  110. },
  111. {
  112. .name = "rootfs",
  113. .offset = MTDPART_OFS_APPEND,
  114. .size = (15 * 1024 * 1024),
  115. },
  116. {
  117. .name = "other",
  118. .offset = MTDPART_OFS_APPEND,
  119. .size = MTDPART_SIZ_FULL,
  120. },
  121. };
  122. static struct physmap_flash_data migor_nor_flash_data = {
  123. .width = 2,
  124. .parts = migor_nor_flash_partitions,
  125. .nr_parts = ARRAY_SIZE(migor_nor_flash_partitions),
  126. };
  127. static struct resource migor_nor_flash_resources[] = {
  128. [0] = {
  129. .name = "NOR Flash",
  130. .start = 0x00000000,
  131. .end = 0x03ffffff,
  132. .flags = IORESOURCE_MEM,
  133. }
  134. };
  135. static struct platform_device migor_nor_flash_device = {
  136. .name = "physmap-flash",
  137. .resource = migor_nor_flash_resources,
  138. .num_resources = ARRAY_SIZE(migor_nor_flash_resources),
  139. .dev = {
  140. .platform_data = &migor_nor_flash_data,
  141. },
  142. };
  143. static struct mtd_partition migor_nand_flash_partitions[] = {
  144. {
  145. .name = "nanddata1",
  146. .offset = 0x0,
  147. .size = 512 * 1024 * 1024,
  148. },
  149. {
  150. .name = "nanddata2",
  151. .offset = MTDPART_OFS_APPEND,
  152. .size = 512 * 1024 * 1024,
  153. },
  154. };
  155. static void migor_nand_flash_cmd_ctl(struct mtd_info *mtd, int cmd,
  156. unsigned int ctrl)
  157. {
  158. struct nand_chip *chip = mtd_to_nand(mtd);
  159. if (cmd == NAND_CMD_NONE)
  160. return;
  161. if (ctrl & NAND_CLE)
  162. writeb(cmd, chip->IO_ADDR_W + 0x00400000);
  163. else if (ctrl & NAND_ALE)
  164. writeb(cmd, chip->IO_ADDR_W + 0x00800000);
  165. else
  166. writeb(cmd, chip->IO_ADDR_W);
  167. }
  168. static int migor_nand_flash_ready(struct mtd_info *mtd)
  169. {
  170. return gpio_get_value(GPIO_PTA1); /* NAND_RBn */
  171. }
  172. static struct platform_nand_data migor_nand_flash_data = {
  173. .chip = {
  174. .nr_chips = 1,
  175. .partitions = migor_nand_flash_partitions,
  176. .nr_partitions = ARRAY_SIZE(migor_nand_flash_partitions),
  177. .chip_delay = 20,
  178. },
  179. .ctrl = {
  180. .dev_ready = migor_nand_flash_ready,
  181. .cmd_ctrl = migor_nand_flash_cmd_ctl,
  182. },
  183. };
  184. static struct resource migor_nand_flash_resources[] = {
  185. [0] = {
  186. .name = "NAND Flash",
  187. .start = 0x18000000,
  188. .end = 0x18ffffff,
  189. .flags = IORESOURCE_MEM,
  190. },
  191. };
  192. static struct platform_device migor_nand_flash_device = {
  193. .name = "gen_nand",
  194. .resource = migor_nand_flash_resources,
  195. .num_resources = ARRAY_SIZE(migor_nand_flash_resources),
  196. .dev = {
  197. .platform_data = &migor_nand_flash_data,
  198. }
  199. };
  200. static const struct fb_videomode migor_lcd_modes[] = {
  201. {
  202. #if defined(CONFIG_SH_MIGOR_RTA_WVGA)
  203. .name = "LB070WV1",
  204. .xres = 800,
  205. .yres = 480,
  206. .left_margin = 64,
  207. .right_margin = 16,
  208. .hsync_len = 120,
  209. .sync = 0,
  210. #elif defined(CONFIG_SH_MIGOR_QVGA)
  211. .name = "PH240320T",
  212. .xres = 320,
  213. .yres = 240,
  214. .left_margin = 0,
  215. .right_margin = 16,
  216. .hsync_len = 8,
  217. .sync = FB_SYNC_HOR_HIGH_ACT,
  218. #endif
  219. .upper_margin = 1,
  220. .lower_margin = 17,
  221. .vsync_len = 2,
  222. },
  223. };
  224. static struct sh_mobile_lcdc_info sh_mobile_lcdc_info = {
  225. #if defined(CONFIG_SH_MIGOR_RTA_WVGA)
  226. .clock_source = LCDC_CLK_BUS,
  227. .ch[0] = {
  228. .chan = LCDC_CHAN_MAINLCD,
  229. .fourcc = V4L2_PIX_FMT_RGB565,
  230. .interface_type = RGB16,
  231. .clock_divider = 2,
  232. .lcd_modes = migor_lcd_modes,
  233. .num_modes = ARRAY_SIZE(migor_lcd_modes),
  234. .panel_cfg = { /* 7.0 inch */
  235. .width = 152,
  236. .height = 91,
  237. },
  238. }
  239. #elif defined(CONFIG_SH_MIGOR_QVGA)
  240. .clock_source = LCDC_CLK_PERIPHERAL,
  241. .ch[0] = {
  242. .chan = LCDC_CHAN_MAINLCD,
  243. .fourcc = V4L2_PIX_FMT_RGB565,
  244. .interface_type = SYS16A,
  245. .clock_divider = 10,
  246. .lcd_modes = migor_lcd_modes,
  247. .num_modes = ARRAY_SIZE(migor_lcd_modes),
  248. .panel_cfg = {
  249. .width = 49, /* 2.4 inch */
  250. .height = 37,
  251. .setup_sys = migor_lcd_qvga_setup,
  252. },
  253. .sys_bus_cfg = {
  254. .ldmt2r = 0x06000a09,
  255. .ldmt3r = 0x180e3418,
  256. /* set 1s delay to encourage fsync() */
  257. .deferred_io_msec = 1000,
  258. },
  259. }
  260. #endif
  261. };
  262. static struct resource migor_lcdc_resources[] = {
  263. [0] = {
  264. .name = "LCDC",
  265. .start = 0xfe940000, /* P4-only space */
  266. .end = 0xfe942fff,
  267. .flags = IORESOURCE_MEM,
  268. },
  269. [1] = {
  270. .start = evt2irq(0x580),
  271. .flags = IORESOURCE_IRQ,
  272. },
  273. };
  274. static struct platform_device migor_lcdc_device = {
  275. .name = "sh_mobile_lcdc_fb",
  276. .num_resources = ARRAY_SIZE(migor_lcdc_resources),
  277. .resource = migor_lcdc_resources,
  278. .dev = {
  279. .platform_data = &sh_mobile_lcdc_info,
  280. },
  281. };
  282. static struct ceu_platform_data ceu_pdata = {
  283. .num_subdevs = 2,
  284. .subdevs = {
  285. { /* [0] = ov772x */
  286. .flags = 0,
  287. .bus_width = 8,
  288. .bus_shift = 0,
  289. .i2c_adapter_id = 0,
  290. .i2c_address = 0x21,
  291. },
  292. { /* [1] = tw9910 */
  293. .flags = 0,
  294. .bus_width = 8,
  295. .bus_shift = 0,
  296. .i2c_adapter_id = 0,
  297. .i2c_address = 0x45,
  298. },
  299. },
  300. };
  301. static struct resource migor_ceu_resources[] = {
  302. [0] = {
  303. .name = "CEU",
  304. .start = 0xfe910000,
  305. .end = 0xfe91009f,
  306. .flags = IORESOURCE_MEM,
  307. },
  308. [1] = {
  309. .start = evt2irq(0x880),
  310. .flags = IORESOURCE_IRQ,
  311. },
  312. };
  313. static struct platform_device migor_ceu_device = {
  314. .name = "renesas-ceu",
  315. .id = 0, /* ceu.0 */
  316. .num_resources = ARRAY_SIZE(migor_ceu_resources),
  317. .resource = migor_ceu_resources,
  318. .dev = {
  319. .platform_data = &ceu_pdata,
  320. },
  321. };
  322. /* Powerdown/reset gpios for CEU image sensors */
  323. static struct gpiod_lookup_table ov7725_gpios = {
  324. .dev_id = "0-0021",
  325. .table = {
  326. GPIO_LOOKUP("sh7722_pfc", GPIO_PTT0, "powerdown",
  327. GPIO_ACTIVE_HIGH),
  328. GPIO_LOOKUP("sh7722_pfc", GPIO_PTT3, "reset", GPIO_ACTIVE_LOW),
  329. },
  330. };
  331. static struct gpiod_lookup_table tw9910_gpios = {
  332. .dev_id = "0-0045",
  333. .table = {
  334. GPIO_LOOKUP("sh7722_pfc", GPIO_PTT2, "pdn", GPIO_ACTIVE_LOW),
  335. GPIO_LOOKUP("sh7722_pfc", GPIO_PTT3, "rstb", GPIO_ACTIVE_LOW),
  336. },
  337. };
  338. /* Fixed 3.3V regulator to be used by SDHI0 */
  339. static struct regulator_consumer_supply fixed3v3_power_consumers[] =
  340. {
  341. REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
  342. REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
  343. };
  344. static struct resource sdhi_cn9_resources[] = {
  345. [0] = {
  346. .name = "SDHI",
  347. .start = 0x04ce0000,
  348. .end = 0x04ce00ff,
  349. .flags = IORESOURCE_MEM,
  350. },
  351. [1] = {
  352. .start = evt2irq(0xe80),
  353. .flags = IORESOURCE_IRQ,
  354. },
  355. };
  356. static struct tmio_mmc_data sh7724_sdhi_data = {
  357. .chan_priv_tx = (void *)SHDMA_SLAVE_SDHI0_TX,
  358. .chan_priv_rx = (void *)SHDMA_SLAVE_SDHI0_RX,
  359. .capabilities = MMC_CAP_SDIO_IRQ,
  360. };
  361. static struct platform_device sdhi_cn9_device = {
  362. .name = "sh_mobile_sdhi",
  363. .num_resources = ARRAY_SIZE(sdhi_cn9_resources),
  364. .resource = sdhi_cn9_resources,
  365. .dev = {
  366. .platform_data = &sh7724_sdhi_data,
  367. },
  368. };
  369. static struct ov772x_camera_info ov7725_info = {
  370. .flags = 0,
  371. };
  372. static struct tw9910_video_info tw9910_info = {
  373. .buswidth = 8,
  374. .mpout = TW9910_MPO_FIELD,
  375. };
  376. static struct i2c_board_info migor_i2c_devices[] = {
  377. {
  378. I2C_BOARD_INFO("rs5c372b", 0x32),
  379. },
  380. {
  381. I2C_BOARD_INFO("migor_ts", 0x51),
  382. .irq = evt2irq(0x6c0), /* IRQ6 */
  383. },
  384. {
  385. I2C_BOARD_INFO("wm8978", 0x1a),
  386. },
  387. {
  388. I2C_BOARD_INFO("ov772x", 0x21),
  389. .platform_data = &ov7725_info,
  390. },
  391. {
  392. I2C_BOARD_INFO("tw9910", 0x45),
  393. .platform_data = &tw9910_info,
  394. },
  395. };
  396. static struct platform_device *migor_devices[] __initdata = {
  397. &smc91x_eth_device,
  398. &sh_keysc_device,
  399. &migor_lcdc_device,
  400. &migor_nor_flash_device,
  401. &migor_nand_flash_device,
  402. &sdhi_cn9_device,
  403. };
  404. extern char migor_sdram_enter_start;
  405. extern char migor_sdram_enter_end;
  406. extern char migor_sdram_leave_start;
  407. extern char migor_sdram_leave_end;
  408. static int __init migor_devices_setup(void)
  409. {
  410. struct clk *video_clk;
  411. /* register board specific self-refresh code */
  412. sh_mobile_register_self_refresh(SUSP_SH_STANDBY | SUSP_SH_SF,
  413. &migor_sdram_enter_start,
  414. &migor_sdram_enter_end,
  415. &migor_sdram_leave_start,
  416. &migor_sdram_leave_end);
  417. regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers,
  418. ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
  419. /* Let D11 LED show STATUS0 */
  420. gpio_request(GPIO_FN_STATUS0, NULL);
  421. /* Lit D12 LED show PDSTATUS */
  422. gpio_request(GPIO_FN_PDSTATUS, NULL);
  423. /* SMC91C111 - Enable IRQ0, Setup CS4 for 16-bit fast access */
  424. gpio_request(GPIO_FN_IRQ0, NULL);
  425. __raw_writel(0x00003400, BSC_CS4BCR);
  426. __raw_writel(0x00110080, BSC_CS4WCR);
  427. /* KEYSC */
  428. gpio_request(GPIO_FN_KEYOUT0, NULL);
  429. gpio_request(GPIO_FN_KEYOUT1, NULL);
  430. gpio_request(GPIO_FN_KEYOUT2, NULL);
  431. gpio_request(GPIO_FN_KEYOUT3, NULL);
  432. gpio_request(GPIO_FN_KEYOUT4_IN6, NULL);
  433. gpio_request(GPIO_FN_KEYIN1, NULL);
  434. gpio_request(GPIO_FN_KEYIN2, NULL);
  435. gpio_request(GPIO_FN_KEYIN3, NULL);
  436. gpio_request(GPIO_FN_KEYIN4, NULL);
  437. gpio_request(GPIO_FN_KEYOUT5_IN5, NULL);
  438. /* NAND Flash */
  439. gpio_request(GPIO_FN_CS6A_CE2B, NULL);
  440. __raw_writel((__raw_readl(BSC_CS6ABCR) & ~0x0600) | 0x0200, BSC_CS6ABCR);
  441. gpio_request(GPIO_PTA1, NULL);
  442. gpio_direction_input(GPIO_PTA1);
  443. /* SDHI */
  444. gpio_request(GPIO_FN_SDHICD, NULL);
  445. gpio_request(GPIO_FN_SDHIWP, NULL);
  446. gpio_request(GPIO_FN_SDHID3, NULL);
  447. gpio_request(GPIO_FN_SDHID2, NULL);
  448. gpio_request(GPIO_FN_SDHID1, NULL);
  449. gpio_request(GPIO_FN_SDHID0, NULL);
  450. gpio_request(GPIO_FN_SDHICMD, NULL);
  451. gpio_request(GPIO_FN_SDHICLK, NULL);
  452. /* Touch Panel */
  453. gpio_request(GPIO_FN_IRQ6, NULL);
  454. /* LCD Panel */
  455. #ifdef CONFIG_SH_MIGOR_QVGA /* LCDC - QVGA - Enable SYS Interface signals */
  456. gpio_request(GPIO_FN_LCDD17, NULL);
  457. gpio_request(GPIO_FN_LCDD16, NULL);
  458. gpio_request(GPIO_FN_LCDD15, NULL);
  459. gpio_request(GPIO_FN_LCDD14, NULL);
  460. gpio_request(GPIO_FN_LCDD13, NULL);
  461. gpio_request(GPIO_FN_LCDD12, NULL);
  462. gpio_request(GPIO_FN_LCDD11, NULL);
  463. gpio_request(GPIO_FN_LCDD10, NULL);
  464. gpio_request(GPIO_FN_LCDD8, NULL);
  465. gpio_request(GPIO_FN_LCDD7, NULL);
  466. gpio_request(GPIO_FN_LCDD6, NULL);
  467. gpio_request(GPIO_FN_LCDD5, NULL);
  468. gpio_request(GPIO_FN_LCDD4, NULL);
  469. gpio_request(GPIO_FN_LCDD3, NULL);
  470. gpio_request(GPIO_FN_LCDD2, NULL);
  471. gpio_request(GPIO_FN_LCDD1, NULL);
  472. gpio_request(GPIO_FN_LCDRS, NULL);
  473. gpio_request(GPIO_FN_LCDCS, NULL);
  474. gpio_request(GPIO_FN_LCDRD, NULL);
  475. gpio_request(GPIO_FN_LCDWR, NULL);
  476. gpio_request(GPIO_PTH2, NULL); /* LCD_DON */
  477. gpio_direction_output(GPIO_PTH2, 1);
  478. #endif
  479. #ifdef CONFIG_SH_MIGOR_RTA_WVGA /* LCDC - WVGA - Enable RGB Interface signals */
  480. gpio_request(GPIO_FN_LCDD15, NULL);
  481. gpio_request(GPIO_FN_LCDD14, NULL);
  482. gpio_request(GPIO_FN_LCDD13, NULL);
  483. gpio_request(GPIO_FN_LCDD12, NULL);
  484. gpio_request(GPIO_FN_LCDD11, NULL);
  485. gpio_request(GPIO_FN_LCDD10, NULL);
  486. gpio_request(GPIO_FN_LCDD9, NULL);
  487. gpio_request(GPIO_FN_LCDD8, NULL);
  488. gpio_request(GPIO_FN_LCDD7, NULL);
  489. gpio_request(GPIO_FN_LCDD6, NULL);
  490. gpio_request(GPIO_FN_LCDD5, NULL);
  491. gpio_request(GPIO_FN_LCDD4, NULL);
  492. gpio_request(GPIO_FN_LCDD3, NULL);
  493. gpio_request(GPIO_FN_LCDD2, NULL);
  494. gpio_request(GPIO_FN_LCDD1, NULL);
  495. gpio_request(GPIO_FN_LCDD0, NULL);
  496. gpio_request(GPIO_FN_LCDLCLK, NULL);
  497. gpio_request(GPIO_FN_LCDDCK, NULL);
  498. gpio_request(GPIO_FN_LCDVEPWC, NULL);
  499. gpio_request(GPIO_FN_LCDVCPWC, NULL);
  500. gpio_request(GPIO_FN_LCDVSYN, NULL);
  501. gpio_request(GPIO_FN_LCDHSYN, NULL);
  502. gpio_request(GPIO_FN_LCDDISP, NULL);
  503. gpio_request(GPIO_FN_LCDDON, NULL);
  504. #endif
  505. /* CEU */
  506. gpio_request(GPIO_FN_VIO_CLK2, NULL);
  507. gpio_request(GPIO_FN_VIO_VD2, NULL);
  508. gpio_request(GPIO_FN_VIO_HD2, NULL);
  509. gpio_request(GPIO_FN_VIO_FLD, NULL);
  510. gpio_request(GPIO_FN_VIO_CKO, NULL);
  511. gpio_request(GPIO_FN_VIO_D15, NULL);
  512. gpio_request(GPIO_FN_VIO_D14, NULL);
  513. gpio_request(GPIO_FN_VIO_D13, NULL);
  514. gpio_request(GPIO_FN_VIO_D12, NULL);
  515. gpio_request(GPIO_FN_VIO_D11, NULL);
  516. gpio_request(GPIO_FN_VIO_D10, NULL);
  517. gpio_request(GPIO_FN_VIO_D9, NULL);
  518. gpio_request(GPIO_FN_VIO_D8, NULL);
  519. __raw_writew(__raw_readw(PORT_MSELCRB) | 0x2000, PORT_MSELCRB); /* D15->D8 */
  520. /* SIU: Port B */
  521. gpio_request(GPIO_FN_SIUBOLR, NULL);
  522. gpio_request(GPIO_FN_SIUBOBT, NULL);
  523. gpio_request(GPIO_FN_SIUBISLD, NULL);
  524. gpio_request(GPIO_FN_SIUBOSLD, NULL);
  525. gpio_request(GPIO_FN_SIUMCKB, NULL);
  526. /*
  527. * The original driver sets SIUB OLR/OBT, ILR/IBT, and SIUA OLR/OBT to
  528. * output. Need only SIUB, set to output for master mode (table 34.2)
  529. */
  530. __raw_writew(__raw_readw(PORT_MSELCRA) | 1, PORT_MSELCRA);
  531. /*
  532. * Use 10 MHz VIO_CKO instead of 24 MHz to work around signal quality
  533. * issues on Panel Board V2.1.
  534. */
  535. video_clk = clk_get(NULL, "video_clk");
  536. if (!IS_ERR(video_clk)) {
  537. clk_set_rate(video_clk, clk_round_rate(video_clk, 10000000));
  538. clk_put(video_clk);
  539. }
  540. /* Add a clock alias for ov7725 xclk source. */
  541. clk_add_alias(NULL, "0-0021", "video_clk", NULL);
  542. /* Register GPIOs for video sources. */
  543. gpiod_add_lookup_table(&ov7725_gpios);
  544. gpiod_add_lookup_table(&tw9910_gpios);
  545. i2c_register_board_info(0, migor_i2c_devices,
  546. ARRAY_SIZE(migor_i2c_devices));
  547. /* Initialize CEU platform device separately to map memory first */
  548. device_initialize(&migor_ceu_device.dev);
  549. arch_setup_pdev_archdata(&migor_ceu_device);
  550. dma_declare_coherent_memory(&migor_ceu_device.dev,
  551. ceu_dma_membase, ceu_dma_membase,
  552. ceu_dma_membase + CEU_BUFFER_MEMORY_SIZE - 1,
  553. DMA_MEMORY_EXCLUSIVE);
  554. platform_device_add(&migor_ceu_device);
  555. return platform_add_devices(migor_devices, ARRAY_SIZE(migor_devices));
  556. }
  557. arch_initcall(migor_devices_setup);
  558. /* Return the board specific boot mode pin configuration */
  559. static int migor_mode_pins(void)
  560. {
  561. /* MD0=1, MD1=1, MD2=0: Clock Mode 3
  562. * MD3=0: 16-bit Area0 Bus Width
  563. * MD5=1: Little Endian
  564. * TSTMD=1, MD8=0: Test Mode Disabled
  565. */
  566. return MODE_PIN0 | MODE_PIN1 | MODE_PIN5;
  567. }
  568. /* Reserve a portion of memory for CEU buffers */
  569. static void __init migor_mv_mem_reserve(void)
  570. {
  571. phys_addr_t phys;
  572. phys_addr_t size = CEU_BUFFER_MEMORY_SIZE;
  573. phys = memblock_alloc_base(size, PAGE_SIZE, MEMBLOCK_ALLOC_ANYWHERE);
  574. memblock_free(phys, size);
  575. memblock_remove(phys, size);
  576. ceu_dma_membase = phys;
  577. }
  578. /*
  579. * The Machine Vector
  580. */
  581. static struct sh_machine_vector mv_migor __initmv = {
  582. .mv_name = "Migo-R",
  583. .mv_mode_pins = migor_mode_pins,
  584. .mv_mem_reserve = migor_mv_mem_reserve,
  585. };