setup.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821
  1. /*
  2. * Copyright (C) 2009 Renesas Solutions Corp.
  3. *
  4. * Kuninori Morimoto <morimoto.kuninori@renesas.com>
  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/device.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/mtd/physmap.h>
  14. #include <linux/gpio.h>
  15. #include <linux/interrupt.h>
  16. #include <linux/io.h>
  17. #include <linux/delay.h>
  18. #include <linux/usb/r8a66597.h>
  19. #include <linux/i2c.h>
  20. #include <linux/i2c/tsc2007.h>
  21. #include <linux/input.h>
  22. #include <linux/input/sh_keysc.h>
  23. #include <linux/mfd/sh_mobile_sdhi.h>
  24. #include <video/sh_mobile_lcdc.h>
  25. #include <media/sh_mobile_ceu.h>
  26. #include <asm/heartbeat.h>
  27. #include <asm/sh_eth.h>
  28. #include <asm/clock.h>
  29. #include <asm/suspend.h>
  30. #include <cpu/sh7724.h>
  31. /*
  32. * Address Interface BusWidth
  33. *-----------------------------------------
  34. * 0x0000_0000 uboot 16bit
  35. * 0x0004_0000 Linux romImage 16bit
  36. * 0x0014_0000 MTD for Linux 16bit
  37. * 0x0400_0000 Internal I/O 16/32bit
  38. * 0x0800_0000 DRAM 32bit
  39. * 0x1800_0000 MFI 16bit
  40. */
  41. /* SWITCH
  42. *------------------------------
  43. * DS2[1] = FlashROM write protect ON : write protect
  44. * OFF : No write protect
  45. * DS2[2] = RMII / TS, SCIF ON : RMII
  46. * OFF : TS, SCIF3
  47. * DS2[3] = Camera / Video ON : Camera
  48. * OFF : NTSC/PAL (IN)
  49. * DS2[5] = NTSC_OUT Clock ON : On board OSC
  50. * OFF : SH7724 DV_CLK
  51. * DS2[6-7] = MMC / SD ON-OFF : SD
  52. * OFF-ON : MMC
  53. */
  54. /* Heartbeat */
  55. static unsigned char led_pos[] = { 0, 1, 2, 3 };
  56. static struct heartbeat_data heartbeat_data = {
  57. .regsize = 8,
  58. .nr_bits = 4,
  59. .bit_pos = led_pos,
  60. };
  61. static struct resource heartbeat_resources[] = {
  62. [0] = {
  63. .start = 0xA405012C, /* PTG */
  64. .end = 0xA405012E - 1,
  65. .flags = IORESOURCE_MEM,
  66. },
  67. };
  68. static struct platform_device heartbeat_device = {
  69. .name = "heartbeat",
  70. .id = -1,
  71. .dev = {
  72. .platform_data = &heartbeat_data,
  73. },
  74. .num_resources = ARRAY_SIZE(heartbeat_resources),
  75. .resource = heartbeat_resources,
  76. };
  77. /* MTD */
  78. static struct mtd_partition nor_flash_partitions[] = {
  79. {
  80. .name = "boot loader",
  81. .offset = 0,
  82. .size = (5 * 1024 * 1024),
  83. .mask_flags = MTD_WRITEABLE, /* force read-only */
  84. }, {
  85. .name = "free-area",
  86. .offset = MTDPART_OFS_APPEND,
  87. .size = MTDPART_SIZ_FULL,
  88. },
  89. };
  90. static struct physmap_flash_data nor_flash_data = {
  91. .width = 2,
  92. .parts = nor_flash_partitions,
  93. .nr_parts = ARRAY_SIZE(nor_flash_partitions),
  94. };
  95. static struct resource nor_flash_resources[] = {
  96. [0] = {
  97. .name = "NOR Flash",
  98. .start = 0x00000000,
  99. .end = 0x03ffffff,
  100. .flags = IORESOURCE_MEM,
  101. }
  102. };
  103. static struct platform_device nor_flash_device = {
  104. .name = "physmap-flash",
  105. .resource = nor_flash_resources,
  106. .num_resources = ARRAY_SIZE(nor_flash_resources),
  107. .dev = {
  108. .platform_data = &nor_flash_data,
  109. },
  110. };
  111. /* SH Eth */
  112. #define SH_ETH_ADDR (0xA4600000)
  113. #define SH_ETH_MAHR (SH_ETH_ADDR + 0x1C0)
  114. #define SH_ETH_MALR (SH_ETH_ADDR + 0x1C8)
  115. static struct resource sh_eth_resources[] = {
  116. [0] = {
  117. .start = SH_ETH_ADDR,
  118. .end = SH_ETH_ADDR + 0x1FC,
  119. .flags = IORESOURCE_MEM,
  120. },
  121. [1] = {
  122. .start = 91,
  123. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  124. },
  125. };
  126. struct sh_eth_plat_data sh_eth_plat = {
  127. .phy = 0x1f, /* SMSC LAN8700 */
  128. .edmac_endian = EDMAC_LITTLE_ENDIAN,
  129. .ether_link_active_low = 1
  130. };
  131. static struct platform_device sh_eth_device = {
  132. .name = "sh-eth",
  133. .id = 0,
  134. .dev = {
  135. .platform_data = &sh_eth_plat,
  136. },
  137. .num_resources = ARRAY_SIZE(sh_eth_resources),
  138. .resource = sh_eth_resources,
  139. .archdata = {
  140. .hwblk_id = HWBLK_ETHER,
  141. },
  142. };
  143. /* USB0 host */
  144. void usb0_port_power(int port, int power)
  145. {
  146. gpio_set_value(GPIO_PTB4, power);
  147. }
  148. static struct r8a66597_platdata usb0_host_data = {
  149. .on_chip = 1,
  150. .port_power = usb0_port_power,
  151. };
  152. static struct resource usb0_host_resources[] = {
  153. [0] = {
  154. .start = 0xa4d80000,
  155. .end = 0xa4d80124 - 1,
  156. .flags = IORESOURCE_MEM,
  157. },
  158. [1] = {
  159. .start = 65,
  160. .end = 65,
  161. .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
  162. },
  163. };
  164. static struct platform_device usb0_host_device = {
  165. .name = "r8a66597_hcd",
  166. .id = 0,
  167. .dev = {
  168. .dma_mask = NULL, /* not use dma */
  169. .coherent_dma_mask = 0xffffffff,
  170. .platform_data = &usb0_host_data,
  171. },
  172. .num_resources = ARRAY_SIZE(usb0_host_resources),
  173. .resource = usb0_host_resources,
  174. };
  175. /* USB1 host/function */
  176. void usb1_port_power(int port, int power)
  177. {
  178. gpio_set_value(GPIO_PTB5, power);
  179. }
  180. static struct r8a66597_platdata usb1_common_data = {
  181. .on_chip = 1,
  182. .port_power = usb1_port_power,
  183. };
  184. static struct resource usb1_common_resources[] = {
  185. [0] = {
  186. .start = 0xa4d90000,
  187. .end = 0xa4d90124 - 1,
  188. .flags = IORESOURCE_MEM,
  189. },
  190. [1] = {
  191. .start = 66,
  192. .end = 66,
  193. .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
  194. },
  195. };
  196. static struct platform_device usb1_common_device = {
  197. /* .name will be added in arch_setup */
  198. .id = 1,
  199. .dev = {
  200. .dma_mask = NULL, /* not use dma */
  201. .coherent_dma_mask = 0xffffffff,
  202. .platform_data = &usb1_common_data,
  203. },
  204. .num_resources = ARRAY_SIZE(usb1_common_resources),
  205. .resource = usb1_common_resources,
  206. };
  207. /* LCDC */
  208. static struct sh_mobile_lcdc_info lcdc_info = {
  209. .ch[0] = {
  210. .interface_type = RGB18,
  211. .chan = LCDC_CHAN_MAINLCD,
  212. .bpp = 16,
  213. .lcd_cfg = {
  214. .sync = 0, /* hsync and vsync are active low */
  215. },
  216. .lcd_size_cfg = { /* 7.0 inch */
  217. .width = 152,
  218. .height = 91,
  219. },
  220. .board_cfg = {
  221. },
  222. }
  223. };
  224. static struct resource lcdc_resources[] = {
  225. [0] = {
  226. .name = "LCDC",
  227. .start = 0xfe940000,
  228. .end = 0xfe942fff,
  229. .flags = IORESOURCE_MEM,
  230. },
  231. [1] = {
  232. .start = 106,
  233. .flags = IORESOURCE_IRQ,
  234. },
  235. };
  236. static struct platform_device lcdc_device = {
  237. .name = "sh_mobile_lcdc_fb",
  238. .num_resources = ARRAY_SIZE(lcdc_resources),
  239. .resource = lcdc_resources,
  240. .dev = {
  241. .platform_data = &lcdc_info,
  242. },
  243. .archdata = {
  244. .hwblk_id = HWBLK_LCDC,
  245. },
  246. };
  247. /* CEU0 */
  248. static struct sh_mobile_ceu_info sh_mobile_ceu0_info = {
  249. .flags = SH_CEU_FLAG_USE_8BIT_BUS,
  250. };
  251. static struct resource ceu0_resources[] = {
  252. [0] = {
  253. .name = "CEU0",
  254. .start = 0xfe910000,
  255. .end = 0xfe91009f,
  256. .flags = IORESOURCE_MEM,
  257. },
  258. [1] = {
  259. .start = 52,
  260. .flags = IORESOURCE_IRQ,
  261. },
  262. [2] = {
  263. /* place holder for contiguous memory */
  264. },
  265. };
  266. static struct platform_device ceu0_device = {
  267. .name = "sh_mobile_ceu",
  268. .id = 0, /* "ceu0" clock */
  269. .num_resources = ARRAY_SIZE(ceu0_resources),
  270. .resource = ceu0_resources,
  271. .dev = {
  272. .platform_data = &sh_mobile_ceu0_info,
  273. },
  274. .archdata = {
  275. .hwblk_id = HWBLK_CEU0,
  276. },
  277. };
  278. /* CEU1 */
  279. static struct sh_mobile_ceu_info sh_mobile_ceu1_info = {
  280. .flags = SH_CEU_FLAG_USE_8BIT_BUS,
  281. };
  282. static struct resource ceu1_resources[] = {
  283. [0] = {
  284. .name = "CEU1",
  285. .start = 0xfe914000,
  286. .end = 0xfe91409f,
  287. .flags = IORESOURCE_MEM,
  288. },
  289. [1] = {
  290. .start = 63,
  291. .flags = IORESOURCE_IRQ,
  292. },
  293. [2] = {
  294. /* place holder for contiguous memory */
  295. },
  296. };
  297. static struct platform_device ceu1_device = {
  298. .name = "sh_mobile_ceu",
  299. .id = 1, /* "ceu1" clock */
  300. .num_resources = ARRAY_SIZE(ceu1_resources),
  301. .resource = ceu1_resources,
  302. .dev = {
  303. .platform_data = &sh_mobile_ceu1_info,
  304. },
  305. .archdata = {
  306. .hwblk_id = HWBLK_CEU1,
  307. },
  308. };
  309. /* I2C device */
  310. static struct i2c_board_info i2c1_devices[] = {
  311. {
  312. I2C_BOARD_INFO("r2025sd", 0x32),
  313. },
  314. };
  315. /* KEYSC */
  316. static struct sh_keysc_info keysc_info = {
  317. .mode = SH_KEYSC_MODE_1,
  318. .scan_timing = 3,
  319. .delay = 50,
  320. .kycr2_delay = 100,
  321. .keycodes = { KEY_1, 0, 0, 0, 0,
  322. KEY_2, 0, 0, 0, 0,
  323. KEY_3, 0, 0, 0, 0,
  324. KEY_4, 0, 0, 0, 0,
  325. KEY_5, 0, 0, 0, 0,
  326. KEY_6, 0, 0, 0, 0, },
  327. };
  328. static struct resource keysc_resources[] = {
  329. [0] = {
  330. .name = "KEYSC",
  331. .start = 0x044b0000,
  332. .end = 0x044b000f,
  333. .flags = IORESOURCE_MEM,
  334. },
  335. [1] = {
  336. .start = 79,
  337. .flags = IORESOURCE_IRQ,
  338. },
  339. };
  340. static struct platform_device keysc_device = {
  341. .name = "sh_keysc",
  342. .id = 0, /* keysc0 clock */
  343. .num_resources = ARRAY_SIZE(keysc_resources),
  344. .resource = keysc_resources,
  345. .dev = {
  346. .platform_data = &keysc_info,
  347. },
  348. .archdata = {
  349. .hwblk_id = HWBLK_KEYSC,
  350. },
  351. };
  352. /* TouchScreen */
  353. #define IRQ0 32
  354. static int ts_get_pendown_state(void)
  355. {
  356. int val = 0;
  357. gpio_free(GPIO_FN_INTC_IRQ0);
  358. gpio_request(GPIO_PTZ0, NULL);
  359. gpio_direction_input(GPIO_PTZ0);
  360. val = gpio_get_value(GPIO_PTZ0);
  361. gpio_free(GPIO_PTZ0);
  362. gpio_request(GPIO_FN_INTC_IRQ0, NULL);
  363. return val ? 0 : 1;
  364. }
  365. static int ts_init(void)
  366. {
  367. gpio_request(GPIO_FN_INTC_IRQ0, NULL);
  368. return 0;
  369. }
  370. struct tsc2007_platform_data tsc2007_info = {
  371. .model = 2007,
  372. .x_plate_ohms = 180,
  373. .get_pendown_state = ts_get_pendown_state,
  374. .init_platform_hw = ts_init,
  375. };
  376. static struct i2c_board_info ts_i2c_clients = {
  377. I2C_BOARD_INFO("tsc2007", 0x48),
  378. .type = "tsc2007",
  379. .platform_data = &tsc2007_info,
  380. .irq = IRQ0,
  381. };
  382. /* SHDI0 */
  383. static void sdhi0_set_pwr(struct platform_device *pdev, int state)
  384. {
  385. gpio_set_value(GPIO_PTB6, state);
  386. }
  387. static struct sh_mobile_sdhi_info sdhi0_info = {
  388. .set_pwr = sdhi0_set_pwr,
  389. };
  390. static struct resource sdhi0_resources[] = {
  391. [0] = {
  392. .name = "SDHI0",
  393. .start = 0x04ce0000,
  394. .end = 0x04ce01ff,
  395. .flags = IORESOURCE_MEM,
  396. },
  397. [1] = {
  398. .start = 101,
  399. .flags = IORESOURCE_IRQ,
  400. },
  401. };
  402. static struct platform_device sdhi0_device = {
  403. .name = "sh_mobile_sdhi",
  404. .num_resources = ARRAY_SIZE(sdhi0_resources),
  405. .resource = sdhi0_resources,
  406. .id = 0,
  407. .dev = {
  408. .platform_data = &sdhi0_info,
  409. },
  410. .archdata = {
  411. .hwblk_id = HWBLK_SDHI0,
  412. },
  413. };
  414. /* SHDI1 */
  415. static void sdhi1_set_pwr(struct platform_device *pdev, int state)
  416. {
  417. gpio_set_value(GPIO_PTB7, state);
  418. }
  419. static struct sh_mobile_sdhi_info sdhi1_info = {
  420. .set_pwr = sdhi1_set_pwr,
  421. };
  422. static struct resource sdhi1_resources[] = {
  423. [0] = {
  424. .name = "SDHI1",
  425. .start = 0x04cf0000,
  426. .end = 0x04cf01ff,
  427. .flags = IORESOURCE_MEM,
  428. },
  429. [1] = {
  430. .start = 24,
  431. .flags = IORESOURCE_IRQ,
  432. },
  433. };
  434. static struct platform_device sdhi1_device = {
  435. .name = "sh_mobile_sdhi",
  436. .num_resources = ARRAY_SIZE(sdhi1_resources),
  437. .resource = sdhi1_resources,
  438. .id = 1,
  439. .dev = {
  440. .platform_data = &sdhi1_info,
  441. },
  442. .archdata = {
  443. .hwblk_id = HWBLK_SDHI1,
  444. },
  445. };
  446. static struct platform_device *ecovec_devices[] __initdata = {
  447. &heartbeat_device,
  448. &nor_flash_device,
  449. &sh_eth_device,
  450. &usb0_host_device,
  451. &usb1_common_device,
  452. &lcdc_device,
  453. &ceu0_device,
  454. &ceu1_device,
  455. &keysc_device,
  456. &sdhi0_device,
  457. &sdhi1_device,
  458. };
  459. #define EEPROM_ADDR 0x50
  460. static u8 mac_read(struct i2c_adapter *a, u8 command)
  461. {
  462. struct i2c_msg msg[2];
  463. u8 buf;
  464. int ret;
  465. msg[0].addr = EEPROM_ADDR;
  466. msg[0].flags = 0;
  467. msg[0].len = 1;
  468. msg[0].buf = &command;
  469. msg[1].addr = EEPROM_ADDR;
  470. msg[1].flags = I2C_M_RD;
  471. msg[1].len = 1;
  472. msg[1].buf = &buf;
  473. ret = i2c_transfer(a, msg, 2);
  474. if (ret < 0) {
  475. printk(KERN_ERR "error %d\n", ret);
  476. buf = 0xff;
  477. }
  478. return buf;
  479. }
  480. static void __init sh_eth_init(struct sh_eth_plat_data *pd)
  481. {
  482. struct i2c_adapter *a = i2c_get_adapter(1);
  483. int i;
  484. if (!a) {
  485. pr_err("can not get I2C 1\n");
  486. return;
  487. }
  488. /* read MAC address frome EEPROM */
  489. for (i = 0; i < sizeof(pd->mac_addr); i++) {
  490. pd->mac_addr[i] = mac_read(a, 0x10 + i);
  491. msleep(10);
  492. }
  493. }
  494. #define PORT_HIZA 0xA4050158
  495. #define IODRIVEA 0xA405018A
  496. extern char ecovec24_sdram_enter_start;
  497. extern char ecovec24_sdram_enter_end;
  498. extern char ecovec24_sdram_leave_start;
  499. extern char ecovec24_sdram_leave_end;
  500. static int __init arch_setup(void)
  501. {
  502. /* register board specific self-refresh code */
  503. sh_mobile_register_self_refresh(SUSP_SH_STANDBY | SUSP_SH_SF,
  504. &ecovec24_sdram_enter_start,
  505. &ecovec24_sdram_enter_end,
  506. &ecovec24_sdram_leave_start,
  507. &ecovec24_sdram_leave_end);
  508. /* enable STATUS0, STATUS2 and PDSTATUS */
  509. gpio_request(GPIO_FN_STATUS0, NULL);
  510. gpio_request(GPIO_FN_STATUS2, NULL);
  511. gpio_request(GPIO_FN_PDSTATUS, NULL);
  512. /* enable SCIFA0 */
  513. gpio_request(GPIO_FN_SCIF0_TXD, NULL);
  514. gpio_request(GPIO_FN_SCIF0_RXD, NULL);
  515. /* enable debug LED */
  516. gpio_request(GPIO_PTG0, NULL);
  517. gpio_request(GPIO_PTG1, NULL);
  518. gpio_request(GPIO_PTG2, NULL);
  519. gpio_request(GPIO_PTG3, NULL);
  520. gpio_direction_output(GPIO_PTG0, 0);
  521. gpio_direction_output(GPIO_PTG1, 0);
  522. gpio_direction_output(GPIO_PTG2, 0);
  523. gpio_direction_output(GPIO_PTG3, 0);
  524. ctrl_outw((ctrl_inw(PORT_HIZA) & ~(0x1 << 1)) , PORT_HIZA);
  525. /* enable SH-Eth */
  526. gpio_request(GPIO_PTA1, NULL);
  527. gpio_direction_output(GPIO_PTA1, 1);
  528. mdelay(20);
  529. gpio_request(GPIO_FN_RMII_RXD0, NULL);
  530. gpio_request(GPIO_FN_RMII_RXD1, NULL);
  531. gpio_request(GPIO_FN_RMII_TXD0, NULL);
  532. gpio_request(GPIO_FN_RMII_TXD1, NULL);
  533. gpio_request(GPIO_FN_RMII_REF_CLK, NULL);
  534. gpio_request(GPIO_FN_RMII_TX_EN, NULL);
  535. gpio_request(GPIO_FN_RMII_RX_ER, NULL);
  536. gpio_request(GPIO_FN_RMII_CRS_DV, NULL);
  537. gpio_request(GPIO_FN_MDIO, NULL);
  538. gpio_request(GPIO_FN_MDC, NULL);
  539. gpio_request(GPIO_FN_LNKSTA, NULL);
  540. /* enable USB */
  541. ctrl_outw(0x0000, 0xA4D80000);
  542. ctrl_outw(0x0000, 0xA4D90000);
  543. gpio_request(GPIO_PTB3, NULL);
  544. gpio_request(GPIO_PTB4, NULL);
  545. gpio_request(GPIO_PTB5, NULL);
  546. gpio_direction_input(GPIO_PTB3);
  547. gpio_direction_output(GPIO_PTB4, 0);
  548. gpio_direction_output(GPIO_PTB5, 0);
  549. ctrl_outw(0x0600, 0xa40501d4);
  550. ctrl_outw(0x0600, 0xa4050192);
  551. if (gpio_get_value(GPIO_PTB3)) {
  552. printk(KERN_INFO "USB1 function is selected\n");
  553. usb1_common_device.name = "r8a66597_udc";
  554. } else {
  555. printk(KERN_INFO "USB1 host is selected\n");
  556. usb1_common_device.name = "r8a66597_hcd";
  557. }
  558. /* enable LCDC */
  559. gpio_request(GPIO_FN_LCDD23, NULL);
  560. gpio_request(GPIO_FN_LCDD22, NULL);
  561. gpio_request(GPIO_FN_LCDD21, NULL);
  562. gpio_request(GPIO_FN_LCDD20, NULL);
  563. gpio_request(GPIO_FN_LCDD19, NULL);
  564. gpio_request(GPIO_FN_LCDD18, NULL);
  565. gpio_request(GPIO_FN_LCDD17, NULL);
  566. gpio_request(GPIO_FN_LCDD16, NULL);
  567. gpio_request(GPIO_FN_LCDD15, NULL);
  568. gpio_request(GPIO_FN_LCDD14, NULL);
  569. gpio_request(GPIO_FN_LCDD13, NULL);
  570. gpio_request(GPIO_FN_LCDD12, NULL);
  571. gpio_request(GPIO_FN_LCDD11, NULL);
  572. gpio_request(GPIO_FN_LCDD10, NULL);
  573. gpio_request(GPIO_FN_LCDD9, NULL);
  574. gpio_request(GPIO_FN_LCDD8, NULL);
  575. gpio_request(GPIO_FN_LCDD7, NULL);
  576. gpio_request(GPIO_FN_LCDD6, NULL);
  577. gpio_request(GPIO_FN_LCDD5, NULL);
  578. gpio_request(GPIO_FN_LCDD4, NULL);
  579. gpio_request(GPIO_FN_LCDD3, NULL);
  580. gpio_request(GPIO_FN_LCDD2, NULL);
  581. gpio_request(GPIO_FN_LCDD1, NULL);
  582. gpio_request(GPIO_FN_LCDD0, NULL);
  583. gpio_request(GPIO_FN_LCDDISP, NULL);
  584. gpio_request(GPIO_FN_LCDHSYN, NULL);
  585. gpio_request(GPIO_FN_LCDDCK, NULL);
  586. gpio_request(GPIO_FN_LCDVSYN, NULL);
  587. gpio_request(GPIO_FN_LCDDON, NULL);
  588. gpio_request(GPIO_FN_LCDLCLK, NULL);
  589. ctrl_outw((ctrl_inw(PORT_HIZA) & ~0x0001), PORT_HIZA);
  590. gpio_request(GPIO_PTE6, NULL);
  591. gpio_request(GPIO_PTU1, NULL);
  592. gpio_request(GPIO_PTR1, NULL);
  593. gpio_request(GPIO_PTA2, NULL);
  594. gpio_direction_input(GPIO_PTE6);
  595. gpio_direction_output(GPIO_PTU1, 0);
  596. gpio_direction_output(GPIO_PTR1, 0);
  597. gpio_direction_output(GPIO_PTA2, 0);
  598. /* I/O buffer drive ability is high */
  599. ctrl_outw((ctrl_inw(IODRIVEA) & ~0x00c0) | 0x0080 , IODRIVEA);
  600. if (gpio_get_value(GPIO_PTE6)) {
  601. /* DVI */
  602. lcdc_info.clock_source = LCDC_CLK_EXTERNAL;
  603. lcdc_info.ch[0].clock_divider = 1,
  604. lcdc_info.ch[0].lcd_cfg.name = "DVI";
  605. lcdc_info.ch[0].lcd_cfg.xres = 1280;
  606. lcdc_info.ch[0].lcd_cfg.yres = 720;
  607. lcdc_info.ch[0].lcd_cfg.left_margin = 220;
  608. lcdc_info.ch[0].lcd_cfg.right_margin = 110;
  609. lcdc_info.ch[0].lcd_cfg.hsync_len = 40;
  610. lcdc_info.ch[0].lcd_cfg.upper_margin = 20;
  611. lcdc_info.ch[0].lcd_cfg.lower_margin = 5;
  612. lcdc_info.ch[0].lcd_cfg.vsync_len = 5;
  613. gpio_set_value(GPIO_PTA2, 1);
  614. gpio_set_value(GPIO_PTU1, 1);
  615. } else {
  616. /* Panel */
  617. lcdc_info.clock_source = LCDC_CLK_PERIPHERAL;
  618. lcdc_info.ch[0].clock_divider = 2,
  619. lcdc_info.ch[0].lcd_cfg.name = "Panel";
  620. lcdc_info.ch[0].lcd_cfg.xres = 800;
  621. lcdc_info.ch[0].lcd_cfg.yres = 480;
  622. lcdc_info.ch[0].lcd_cfg.left_margin = 220;
  623. lcdc_info.ch[0].lcd_cfg.right_margin = 110;
  624. lcdc_info.ch[0].lcd_cfg.hsync_len = 70;
  625. lcdc_info.ch[0].lcd_cfg.upper_margin = 20;
  626. lcdc_info.ch[0].lcd_cfg.lower_margin = 5;
  627. lcdc_info.ch[0].lcd_cfg.vsync_len = 5;
  628. gpio_set_value(GPIO_PTR1, 1);
  629. /* FIXME
  630. *
  631. * LCDDON control is needed for Panel,
  632. * but current sh_mobile_lcdc driver doesn't control it.
  633. * It is temporary correspondence
  634. */
  635. gpio_request(GPIO_PTF4, NULL);
  636. gpio_direction_output(GPIO_PTF4, 1);
  637. /* enable TouchScreen */
  638. i2c_register_board_info(0, &ts_i2c_clients, 1);
  639. set_irq_type(IRQ0, IRQ_TYPE_LEVEL_LOW);
  640. }
  641. /* enable CEU0 */
  642. gpio_request(GPIO_FN_VIO0_D15, NULL);
  643. gpio_request(GPIO_FN_VIO0_D14, NULL);
  644. gpio_request(GPIO_FN_VIO0_D13, NULL);
  645. gpio_request(GPIO_FN_VIO0_D12, NULL);
  646. gpio_request(GPIO_FN_VIO0_D11, NULL);
  647. gpio_request(GPIO_FN_VIO0_D10, NULL);
  648. gpio_request(GPIO_FN_VIO0_D9, NULL);
  649. gpio_request(GPIO_FN_VIO0_D8, NULL);
  650. gpio_request(GPIO_FN_VIO0_D7, NULL);
  651. gpio_request(GPIO_FN_VIO0_D6, NULL);
  652. gpio_request(GPIO_FN_VIO0_D5, NULL);
  653. gpio_request(GPIO_FN_VIO0_D4, NULL);
  654. gpio_request(GPIO_FN_VIO0_D3, NULL);
  655. gpio_request(GPIO_FN_VIO0_D2, NULL);
  656. gpio_request(GPIO_FN_VIO0_D1, NULL);
  657. gpio_request(GPIO_FN_VIO0_D0, NULL);
  658. gpio_request(GPIO_FN_VIO0_VD, NULL);
  659. gpio_request(GPIO_FN_VIO0_CLK, NULL);
  660. gpio_request(GPIO_FN_VIO0_FLD, NULL);
  661. gpio_request(GPIO_FN_VIO0_HD, NULL);
  662. platform_resource_setup_memory(&ceu0_device, "ceu0", 4 << 20);
  663. /* enable CEU1 */
  664. gpio_request(GPIO_FN_VIO1_D7, NULL);
  665. gpio_request(GPIO_FN_VIO1_D6, NULL);
  666. gpio_request(GPIO_FN_VIO1_D5, NULL);
  667. gpio_request(GPIO_FN_VIO1_D4, NULL);
  668. gpio_request(GPIO_FN_VIO1_D3, NULL);
  669. gpio_request(GPIO_FN_VIO1_D2, NULL);
  670. gpio_request(GPIO_FN_VIO1_D1, NULL);
  671. gpio_request(GPIO_FN_VIO1_D0, NULL);
  672. gpio_request(GPIO_FN_VIO1_FLD, NULL);
  673. gpio_request(GPIO_FN_VIO1_HD, NULL);
  674. gpio_request(GPIO_FN_VIO1_VD, NULL);
  675. gpio_request(GPIO_FN_VIO1_CLK, NULL);
  676. platform_resource_setup_memory(&ceu1_device, "ceu1", 4 << 20);
  677. /* enable KEYSC */
  678. gpio_request(GPIO_FN_KEYOUT5_IN5, NULL);
  679. gpio_request(GPIO_FN_KEYOUT4_IN6, NULL);
  680. gpio_request(GPIO_FN_KEYOUT3, NULL);
  681. gpio_request(GPIO_FN_KEYOUT2, NULL);
  682. gpio_request(GPIO_FN_KEYOUT1, NULL);
  683. gpio_request(GPIO_FN_KEYOUT0, NULL);
  684. gpio_request(GPIO_FN_KEYIN0, NULL);
  685. /* enable user debug switch */
  686. gpio_request(GPIO_PTR0, NULL);
  687. gpio_request(GPIO_PTR4, NULL);
  688. gpio_request(GPIO_PTR5, NULL);
  689. gpio_request(GPIO_PTR6, NULL);
  690. gpio_direction_input(GPIO_PTR0);
  691. gpio_direction_input(GPIO_PTR4);
  692. gpio_direction_input(GPIO_PTR5);
  693. gpio_direction_input(GPIO_PTR6);
  694. /* enable SDHI0 (needs DS2.4 set to ON) */
  695. gpio_request(GPIO_FN_SDHI0CD, NULL);
  696. gpio_request(GPIO_FN_SDHI0WP, NULL);
  697. gpio_request(GPIO_FN_SDHI0CMD, NULL);
  698. gpio_request(GPIO_FN_SDHI0CLK, NULL);
  699. gpio_request(GPIO_FN_SDHI0D3, NULL);
  700. gpio_request(GPIO_FN_SDHI0D2, NULL);
  701. gpio_request(GPIO_FN_SDHI0D1, NULL);
  702. gpio_request(GPIO_FN_SDHI0D0, NULL);
  703. gpio_request(GPIO_PTB6, NULL);
  704. gpio_direction_output(GPIO_PTB6, 0);
  705. /* enable SDHI1 (needs DS2.6,7 set to ON,OFF) */
  706. gpio_request(GPIO_FN_SDHI1CD, NULL);
  707. gpio_request(GPIO_FN_SDHI1WP, NULL);
  708. gpio_request(GPIO_FN_SDHI1CMD, NULL);
  709. gpio_request(GPIO_FN_SDHI1CLK, NULL);
  710. gpio_request(GPIO_FN_SDHI1D3, NULL);
  711. gpio_request(GPIO_FN_SDHI1D2, NULL);
  712. gpio_request(GPIO_FN_SDHI1D1, NULL);
  713. gpio_request(GPIO_FN_SDHI1D0, NULL);
  714. gpio_request(GPIO_PTB7, NULL);
  715. gpio_direction_output(GPIO_PTB7, 0);
  716. /* I/O buffer drive ability is high for SDHI1 */
  717. ctrl_outw((ctrl_inw(IODRIVEA) & ~0x3000) | 0x2000 , IODRIVEA);
  718. /* enable I2C device */
  719. i2c_register_board_info(1, i2c1_devices,
  720. ARRAY_SIZE(i2c1_devices));
  721. return platform_add_devices(ecovec_devices,
  722. ARRAY_SIZE(ecovec_devices));
  723. }
  724. arch_initcall(arch_setup);
  725. static int __init devices_setup(void)
  726. {
  727. sh_eth_init(&sh_eth_plat);
  728. return 0;
  729. }
  730. device_initcall(devices_setup);
  731. static struct sh_machine_vector mv_ecovec __initmv = {
  732. .mv_name = "R0P7724 (EcoVec)",
  733. };