setup.c 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137
  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/spi/spi.h>
  22. #include <linux/spi/sh_msiof.h>
  23. #include <linux/spi/mmc_spi.h>
  24. #include <linux/mmc/host.h>
  25. #include <linux/input.h>
  26. #include <linux/input/sh_keysc.h>
  27. #include <linux/mfd/sh_mobile_sdhi.h>
  28. #include <video/sh_mobile_lcdc.h>
  29. #include <sound/sh_fsi.h>
  30. #include <media/sh_mobile_ceu.h>
  31. #include <media/tw9910.h>
  32. #include <media/mt9t112.h>
  33. #include <asm/heartbeat.h>
  34. #include <asm/sh_eth.h>
  35. #include <asm/clock.h>
  36. #include <asm/suspend.h>
  37. #include <cpu/sh7724.h>
  38. /*
  39. * Address Interface BusWidth
  40. *-----------------------------------------
  41. * 0x0000_0000 uboot 16bit
  42. * 0x0004_0000 Linux romImage 16bit
  43. * 0x0014_0000 MTD for Linux 16bit
  44. * 0x0400_0000 Internal I/O 16/32bit
  45. * 0x0800_0000 DRAM 32bit
  46. * 0x1800_0000 MFI 16bit
  47. */
  48. /* SWITCH
  49. *------------------------------
  50. * DS2[1] = FlashROM write protect ON : write protect
  51. * OFF : No write protect
  52. * DS2[2] = RMII / TS, SCIF ON : RMII
  53. * OFF : TS, SCIF3
  54. * DS2[3] = Camera / Video ON : Camera
  55. * OFF : NTSC/PAL (IN)
  56. * DS2[5] = NTSC_OUT Clock ON : On board OSC
  57. * OFF : SH7724 DV_CLK
  58. * DS2[6-7] = MMC / SD ON-OFF : SD
  59. * OFF-ON : MMC
  60. */
  61. /* Heartbeat */
  62. static unsigned char led_pos[] = { 0, 1, 2, 3 };
  63. static struct heartbeat_data heartbeat_data = {
  64. .nr_bits = 4,
  65. .bit_pos = led_pos,
  66. };
  67. static struct resource heartbeat_resource = {
  68. .start = 0xA405012C, /* PTG */
  69. .end = 0xA405012E - 1,
  70. .flags = IORESOURCE_MEM | IORESOURCE_MEM_8BIT,
  71. };
  72. static struct platform_device heartbeat_device = {
  73. .name = "heartbeat",
  74. .id = -1,
  75. .dev = {
  76. .platform_data = &heartbeat_data,
  77. },
  78. .num_resources = 1,
  79. .resource = &heartbeat_resource,
  80. };
  81. /* MTD */
  82. static struct mtd_partition nor_flash_partitions[] = {
  83. {
  84. .name = "boot loader",
  85. .offset = 0,
  86. .size = (5 * 1024 * 1024),
  87. .mask_flags = MTD_WRITEABLE, /* force read-only */
  88. }, {
  89. .name = "free-area",
  90. .offset = MTDPART_OFS_APPEND,
  91. .size = MTDPART_SIZ_FULL,
  92. },
  93. };
  94. static struct physmap_flash_data nor_flash_data = {
  95. .width = 2,
  96. .parts = nor_flash_partitions,
  97. .nr_parts = ARRAY_SIZE(nor_flash_partitions),
  98. };
  99. static struct resource nor_flash_resources[] = {
  100. [0] = {
  101. .name = "NOR Flash",
  102. .start = 0x00000000,
  103. .end = 0x03ffffff,
  104. .flags = IORESOURCE_MEM,
  105. }
  106. };
  107. static struct platform_device nor_flash_device = {
  108. .name = "physmap-flash",
  109. .resource = nor_flash_resources,
  110. .num_resources = ARRAY_SIZE(nor_flash_resources),
  111. .dev = {
  112. .platform_data = &nor_flash_data,
  113. },
  114. };
  115. /* SH Eth */
  116. #define SH_ETH_ADDR (0xA4600000)
  117. static struct resource sh_eth_resources[] = {
  118. [0] = {
  119. .start = SH_ETH_ADDR,
  120. .end = SH_ETH_ADDR + 0x1FC,
  121. .flags = IORESOURCE_MEM,
  122. },
  123. [1] = {
  124. .start = 91,
  125. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  126. },
  127. };
  128. struct sh_eth_plat_data sh_eth_plat = {
  129. .phy = 0x1f, /* SMSC LAN8700 */
  130. .edmac_endian = EDMAC_LITTLE_ENDIAN,
  131. .ether_link_active_low = 1
  132. };
  133. static struct platform_device sh_eth_device = {
  134. .name = "sh-eth",
  135. .id = 0,
  136. .dev = {
  137. .platform_data = &sh_eth_plat,
  138. },
  139. .num_resources = ARRAY_SIZE(sh_eth_resources),
  140. .resource = sh_eth_resources,
  141. .archdata = {
  142. .hwblk_id = HWBLK_ETHER,
  143. },
  144. };
  145. /* USB0 host */
  146. void usb0_port_power(int port, int power)
  147. {
  148. gpio_set_value(GPIO_PTB4, power);
  149. }
  150. static struct r8a66597_platdata usb0_host_data = {
  151. .on_chip = 1,
  152. .port_power = usb0_port_power,
  153. };
  154. static struct resource usb0_host_resources[] = {
  155. [0] = {
  156. .start = 0xa4d80000,
  157. .end = 0xa4d80124 - 1,
  158. .flags = IORESOURCE_MEM,
  159. },
  160. [1] = {
  161. .start = 65,
  162. .end = 65,
  163. .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
  164. },
  165. };
  166. static struct platform_device usb0_host_device = {
  167. .name = "r8a66597_hcd",
  168. .id = 0,
  169. .dev = {
  170. .dma_mask = NULL, /* not use dma */
  171. .coherent_dma_mask = 0xffffffff,
  172. .platform_data = &usb0_host_data,
  173. },
  174. .num_resources = ARRAY_SIZE(usb0_host_resources),
  175. .resource = usb0_host_resources,
  176. };
  177. /* USB1 host/function */
  178. void usb1_port_power(int port, int power)
  179. {
  180. gpio_set_value(GPIO_PTB5, power);
  181. }
  182. static struct r8a66597_platdata usb1_common_data = {
  183. .on_chip = 1,
  184. .port_power = usb1_port_power,
  185. };
  186. static struct resource usb1_common_resources[] = {
  187. [0] = {
  188. .start = 0xa4d90000,
  189. .end = 0xa4d90124 - 1,
  190. .flags = IORESOURCE_MEM,
  191. },
  192. [1] = {
  193. .start = 66,
  194. .end = 66,
  195. .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
  196. },
  197. };
  198. static struct platform_device usb1_common_device = {
  199. /* .name will be added in arch_setup */
  200. .id = 1,
  201. .dev = {
  202. .dma_mask = NULL, /* not use dma */
  203. .coherent_dma_mask = 0xffffffff,
  204. .platform_data = &usb1_common_data,
  205. },
  206. .num_resources = ARRAY_SIZE(usb1_common_resources),
  207. .resource = usb1_common_resources,
  208. };
  209. /* LCDC */
  210. static struct sh_mobile_lcdc_info lcdc_info = {
  211. .ch[0] = {
  212. .interface_type = RGB18,
  213. .chan = LCDC_CHAN_MAINLCD,
  214. .bpp = 16,
  215. .lcd_cfg = {
  216. .sync = 0, /* hsync and vsync are active low */
  217. },
  218. .lcd_size_cfg = { /* 7.0 inch */
  219. .width = 152,
  220. .height = 91,
  221. },
  222. .board_cfg = {
  223. },
  224. }
  225. };
  226. static struct resource lcdc_resources[] = {
  227. [0] = {
  228. .name = "LCDC",
  229. .start = 0xfe940000,
  230. .end = 0xfe942fff,
  231. .flags = IORESOURCE_MEM,
  232. },
  233. [1] = {
  234. .start = 106,
  235. .flags = IORESOURCE_IRQ,
  236. },
  237. };
  238. static struct platform_device lcdc_device = {
  239. .name = "sh_mobile_lcdc_fb",
  240. .num_resources = ARRAY_SIZE(lcdc_resources),
  241. .resource = lcdc_resources,
  242. .dev = {
  243. .platform_data = &lcdc_info,
  244. },
  245. .archdata = {
  246. .hwblk_id = HWBLK_LCDC,
  247. },
  248. };
  249. /* CEU0 */
  250. static struct sh_mobile_ceu_info sh_mobile_ceu0_info = {
  251. .flags = SH_CEU_FLAG_USE_8BIT_BUS,
  252. };
  253. static struct resource ceu0_resources[] = {
  254. [0] = {
  255. .name = "CEU0",
  256. .start = 0xfe910000,
  257. .end = 0xfe91009f,
  258. .flags = IORESOURCE_MEM,
  259. },
  260. [1] = {
  261. .start = 52,
  262. .flags = IORESOURCE_IRQ,
  263. },
  264. [2] = {
  265. /* place holder for contiguous memory */
  266. },
  267. };
  268. static struct platform_device ceu0_device = {
  269. .name = "sh_mobile_ceu",
  270. .id = 0, /* "ceu0" clock */
  271. .num_resources = ARRAY_SIZE(ceu0_resources),
  272. .resource = ceu0_resources,
  273. .dev = {
  274. .platform_data = &sh_mobile_ceu0_info,
  275. },
  276. .archdata = {
  277. .hwblk_id = HWBLK_CEU0,
  278. },
  279. };
  280. /* CEU1 */
  281. static struct sh_mobile_ceu_info sh_mobile_ceu1_info = {
  282. .flags = SH_CEU_FLAG_USE_8BIT_BUS,
  283. };
  284. static struct resource ceu1_resources[] = {
  285. [0] = {
  286. .name = "CEU1",
  287. .start = 0xfe914000,
  288. .end = 0xfe91409f,
  289. .flags = IORESOURCE_MEM,
  290. },
  291. [1] = {
  292. .start = 63,
  293. .flags = IORESOURCE_IRQ,
  294. },
  295. [2] = {
  296. /* place holder for contiguous memory */
  297. },
  298. };
  299. static struct platform_device ceu1_device = {
  300. .name = "sh_mobile_ceu",
  301. .id = 1, /* "ceu1" clock */
  302. .num_resources = ARRAY_SIZE(ceu1_resources),
  303. .resource = ceu1_resources,
  304. .dev = {
  305. .platform_data = &sh_mobile_ceu1_info,
  306. },
  307. .archdata = {
  308. .hwblk_id = HWBLK_CEU1,
  309. },
  310. };
  311. /* I2C device */
  312. static struct i2c_board_info i2c0_devices[] = {
  313. {
  314. I2C_BOARD_INFO("da7210", 0x1a),
  315. },
  316. };
  317. static struct i2c_board_info i2c1_devices[] = {
  318. {
  319. I2C_BOARD_INFO("r2025sd", 0x32),
  320. },
  321. };
  322. /* KEYSC */
  323. static struct sh_keysc_info keysc_info = {
  324. .mode = SH_KEYSC_MODE_1,
  325. .scan_timing = 3,
  326. .delay = 50,
  327. .kycr2_delay = 100,
  328. .keycodes = { KEY_1, 0, 0, 0, 0,
  329. KEY_2, 0, 0, 0, 0,
  330. KEY_3, 0, 0, 0, 0,
  331. KEY_4, 0, 0, 0, 0,
  332. KEY_5, 0, 0, 0, 0,
  333. KEY_6, 0, 0, 0, 0, },
  334. };
  335. static struct resource keysc_resources[] = {
  336. [0] = {
  337. .name = "KEYSC",
  338. .start = 0x044b0000,
  339. .end = 0x044b000f,
  340. .flags = IORESOURCE_MEM,
  341. },
  342. [1] = {
  343. .start = 79,
  344. .flags = IORESOURCE_IRQ,
  345. },
  346. };
  347. static struct platform_device keysc_device = {
  348. .name = "sh_keysc",
  349. .id = 0, /* keysc0 clock */
  350. .num_resources = ARRAY_SIZE(keysc_resources),
  351. .resource = keysc_resources,
  352. .dev = {
  353. .platform_data = &keysc_info,
  354. },
  355. .archdata = {
  356. .hwblk_id = HWBLK_KEYSC,
  357. },
  358. };
  359. /* TouchScreen */
  360. #define IRQ0 32
  361. static int ts_get_pendown_state(void)
  362. {
  363. int val = 0;
  364. gpio_free(GPIO_FN_INTC_IRQ0);
  365. gpio_request(GPIO_PTZ0, NULL);
  366. gpio_direction_input(GPIO_PTZ0);
  367. val = gpio_get_value(GPIO_PTZ0);
  368. gpio_free(GPIO_PTZ0);
  369. gpio_request(GPIO_FN_INTC_IRQ0, NULL);
  370. return val ? 0 : 1;
  371. }
  372. static int ts_init(void)
  373. {
  374. gpio_request(GPIO_FN_INTC_IRQ0, NULL);
  375. return 0;
  376. }
  377. struct tsc2007_platform_data tsc2007_info = {
  378. .model = 2007,
  379. .x_plate_ohms = 180,
  380. .get_pendown_state = ts_get_pendown_state,
  381. .init_platform_hw = ts_init,
  382. };
  383. static struct i2c_board_info ts_i2c_clients = {
  384. I2C_BOARD_INFO("tsc2007", 0x48),
  385. .type = "tsc2007",
  386. .platform_data = &tsc2007_info,
  387. .irq = IRQ0,
  388. };
  389. #ifdef CONFIG_MFD_SH_MOBILE_SDHI
  390. /* SHDI0 */
  391. static void sdhi0_set_pwr(struct platform_device *pdev, int state)
  392. {
  393. gpio_set_value(GPIO_PTB6, state);
  394. }
  395. static struct sh_mobile_sdhi_info sdhi0_info = {
  396. .set_pwr = sdhi0_set_pwr,
  397. };
  398. static struct resource sdhi0_resources[] = {
  399. [0] = {
  400. .name = "SDHI0",
  401. .start = 0x04ce0000,
  402. .end = 0x04ce01ff,
  403. .flags = IORESOURCE_MEM,
  404. },
  405. [1] = {
  406. .start = 101,
  407. .flags = IORESOURCE_IRQ,
  408. },
  409. };
  410. static struct platform_device sdhi0_device = {
  411. .name = "sh_mobile_sdhi",
  412. .num_resources = ARRAY_SIZE(sdhi0_resources),
  413. .resource = sdhi0_resources,
  414. .id = 0,
  415. .dev = {
  416. .platform_data = &sdhi0_info,
  417. },
  418. .archdata = {
  419. .hwblk_id = HWBLK_SDHI0,
  420. },
  421. };
  422. /* SHDI1 */
  423. static void sdhi1_set_pwr(struct platform_device *pdev, int state)
  424. {
  425. gpio_set_value(GPIO_PTB7, state);
  426. }
  427. static struct sh_mobile_sdhi_info sdhi1_info = {
  428. .set_pwr = sdhi1_set_pwr,
  429. };
  430. static struct resource sdhi1_resources[] = {
  431. [0] = {
  432. .name = "SDHI1",
  433. .start = 0x04cf0000,
  434. .end = 0x04cf01ff,
  435. .flags = IORESOURCE_MEM,
  436. },
  437. [1] = {
  438. .start = 24,
  439. .flags = IORESOURCE_IRQ,
  440. },
  441. };
  442. static struct platform_device sdhi1_device = {
  443. .name = "sh_mobile_sdhi",
  444. .num_resources = ARRAY_SIZE(sdhi1_resources),
  445. .resource = sdhi1_resources,
  446. .id = 1,
  447. .dev = {
  448. .platform_data = &sdhi1_info,
  449. },
  450. .archdata = {
  451. .hwblk_id = HWBLK_SDHI1,
  452. },
  453. };
  454. #else
  455. /* MMC SPI */
  456. static int mmc_spi_get_ro(struct device *dev)
  457. {
  458. return gpio_get_value(GPIO_PTY6);
  459. }
  460. static int mmc_spi_get_cd(struct device *dev)
  461. {
  462. return !gpio_get_value(GPIO_PTY7);
  463. }
  464. static void mmc_spi_setpower(struct device *dev, unsigned int maskval)
  465. {
  466. gpio_set_value(GPIO_PTB6, maskval ? 1 : 0);
  467. }
  468. static struct mmc_spi_platform_data mmc_spi_info = {
  469. .get_ro = mmc_spi_get_ro,
  470. .get_cd = mmc_spi_get_cd,
  471. .caps = MMC_CAP_NEEDS_POLL,
  472. .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, /* 3.3V only */
  473. .setpower = mmc_spi_setpower,
  474. };
  475. static struct spi_board_info spi_bus[] = {
  476. {
  477. .modalias = "mmc_spi",
  478. .platform_data = &mmc_spi_info,
  479. .max_speed_hz = 5000000,
  480. .mode = SPI_MODE_0,
  481. .controller_data = (void *) GPIO_PTM4,
  482. },
  483. };
  484. /* MSIOF0 */
  485. static struct sh_msiof_spi_info msiof0_data = {
  486. .num_chipselect = 1,
  487. };
  488. static struct resource msiof0_resources[] = {
  489. [0] = {
  490. .name = "MSIOF0",
  491. .start = 0xa4c40000,
  492. .end = 0xa4c40063,
  493. .flags = IORESOURCE_MEM,
  494. },
  495. [1] = {
  496. .start = 84,
  497. .flags = IORESOURCE_IRQ,
  498. },
  499. };
  500. static struct platform_device msiof0_device = {
  501. .name = "spi_sh_msiof",
  502. .id = 0, /* MSIOF0 */
  503. .dev = {
  504. .platform_data = &msiof0_data,
  505. },
  506. .num_resources = ARRAY_SIZE(msiof0_resources),
  507. .resource = msiof0_resources,
  508. .archdata = {
  509. .hwblk_id = HWBLK_MSIOF0,
  510. },
  511. };
  512. #endif
  513. /* I2C Video/Camera */
  514. static struct i2c_board_info i2c_camera[] = {
  515. {
  516. I2C_BOARD_INFO("tw9910", 0x45),
  517. },
  518. {
  519. /* 1st camera */
  520. I2C_BOARD_INFO("mt9t112", 0x3c),
  521. },
  522. {
  523. /* 2nd camera */
  524. I2C_BOARD_INFO("mt9t112", 0x3c),
  525. },
  526. };
  527. /* tw9910 */
  528. static int tw9910_power(struct device *dev, int mode)
  529. {
  530. int val = mode ? 0 : 1;
  531. gpio_set_value(GPIO_PTU2, val);
  532. if (mode)
  533. mdelay(100);
  534. return 0;
  535. }
  536. static struct tw9910_video_info tw9910_info = {
  537. .buswidth = SOCAM_DATAWIDTH_8,
  538. .mpout = TW9910_MPO_FIELD,
  539. };
  540. static struct soc_camera_link tw9910_link = {
  541. .i2c_adapter_id = 0,
  542. .bus_id = 1,
  543. .power = tw9910_power,
  544. .board_info = &i2c_camera[0],
  545. .module_name = "tw9910",
  546. .priv = &tw9910_info,
  547. };
  548. /* mt9t112 */
  549. static int mt9t112_power1(struct device *dev, int mode)
  550. {
  551. gpio_set_value(GPIO_PTA3, mode);
  552. if (mode)
  553. mdelay(100);
  554. return 0;
  555. }
  556. static struct mt9t112_camera_info mt9t112_info1 = {
  557. .flags = MT9T112_FLAG_PCLK_RISING_EDGE | MT9T112_FLAG_DATAWIDTH_8,
  558. .divider = { 0x49, 0x6, 0, 6, 0, 9, 9, 6, 0 }, /* for 24MHz */
  559. };
  560. static struct soc_camera_link mt9t112_link1 = {
  561. .i2c_adapter_id = 0,
  562. .power = mt9t112_power1,
  563. .bus_id = 0,
  564. .board_info = &i2c_camera[1],
  565. .module_name = "mt9t112",
  566. .priv = &mt9t112_info1,
  567. };
  568. static int mt9t112_power2(struct device *dev, int mode)
  569. {
  570. gpio_set_value(GPIO_PTA4, mode);
  571. if (mode)
  572. mdelay(100);
  573. return 0;
  574. }
  575. static struct mt9t112_camera_info mt9t112_info2 = {
  576. .flags = MT9T112_FLAG_PCLK_RISING_EDGE | MT9T112_FLAG_DATAWIDTH_8,
  577. .divider = { 0x49, 0x6, 0, 6, 0, 9, 9, 6, 0 }, /* for 24MHz */
  578. };
  579. static struct soc_camera_link mt9t112_link2 = {
  580. .i2c_adapter_id = 1,
  581. .power = mt9t112_power2,
  582. .bus_id = 1,
  583. .board_info = &i2c_camera[2],
  584. .module_name = "mt9t112",
  585. .priv = &mt9t112_info2,
  586. };
  587. static struct platform_device camera_devices[] = {
  588. {
  589. .name = "soc-camera-pdrv",
  590. .id = 0,
  591. .dev = {
  592. .platform_data = &tw9910_link,
  593. },
  594. },
  595. {
  596. .name = "soc-camera-pdrv",
  597. .id = 1,
  598. .dev = {
  599. .platform_data = &mt9t112_link1,
  600. },
  601. },
  602. {
  603. .name = "soc-camera-pdrv",
  604. .id = 2,
  605. .dev = {
  606. .platform_data = &mt9t112_link2,
  607. },
  608. },
  609. };
  610. /* FSI */
  611. /*
  612. * FSI-B use external clock which came from da7210.
  613. * So, we should change parent of fsi
  614. */
  615. #define FCLKBCR 0xa415000c
  616. static void fsimck_init(struct clk *clk)
  617. {
  618. u32 status = ctrl_inl(clk->enable_reg);
  619. /* use external clock */
  620. status &= ~0x000000ff;
  621. status |= 0x00000080;
  622. ctrl_outl(status, clk->enable_reg);
  623. }
  624. static struct clk_ops fsimck_clk_ops = {
  625. .init = fsimck_init,
  626. };
  627. static struct clk fsimckb_clk = {
  628. .name = "fsimckb_clk",
  629. .id = -1,
  630. .ops = &fsimck_clk_ops,
  631. .enable_reg = (void __iomem *)FCLKBCR,
  632. .rate = 0, /* unknown */
  633. };
  634. struct sh_fsi_platform_info fsi_info = {
  635. .portb_flags = SH_FSI_BRS_INV |
  636. SH_FSI_OUT_SLAVE_MODE |
  637. SH_FSI_IN_SLAVE_MODE |
  638. SH_FSI_OFMT(I2S) |
  639. SH_FSI_IFMT(I2S),
  640. };
  641. static struct resource fsi_resources[] = {
  642. [0] = {
  643. .name = "FSI",
  644. .start = 0xFE3C0000,
  645. .end = 0xFE3C021d,
  646. .flags = IORESOURCE_MEM,
  647. },
  648. [1] = {
  649. .start = 108,
  650. .flags = IORESOURCE_IRQ,
  651. },
  652. };
  653. static struct platform_device fsi_device = {
  654. .name = "sh_fsi",
  655. .id = 0,
  656. .num_resources = ARRAY_SIZE(fsi_resources),
  657. .resource = fsi_resources,
  658. .dev = {
  659. .platform_data = &fsi_info,
  660. },
  661. .archdata = {
  662. .hwblk_id = HWBLK_SPU, /* FSI needs SPU hwblk */
  663. },
  664. };
  665. static struct platform_device *ecovec_devices[] __initdata = {
  666. &heartbeat_device,
  667. &nor_flash_device,
  668. &sh_eth_device,
  669. &usb0_host_device,
  670. &usb1_common_device,
  671. &lcdc_device,
  672. &ceu0_device,
  673. &ceu1_device,
  674. &keysc_device,
  675. #ifdef CONFIG_MFD_SH_MOBILE_SDHI
  676. &sdhi0_device,
  677. &sdhi1_device,
  678. #else
  679. &msiof0_device,
  680. #endif
  681. &camera_devices[0],
  682. &camera_devices[1],
  683. &camera_devices[2],
  684. &fsi_device,
  685. };
  686. #define EEPROM_ADDR 0x50
  687. static u8 mac_read(struct i2c_adapter *a, u8 command)
  688. {
  689. struct i2c_msg msg[2];
  690. u8 buf;
  691. int ret;
  692. msg[0].addr = EEPROM_ADDR;
  693. msg[0].flags = 0;
  694. msg[0].len = 1;
  695. msg[0].buf = &command;
  696. msg[1].addr = EEPROM_ADDR;
  697. msg[1].flags = I2C_M_RD;
  698. msg[1].len = 1;
  699. msg[1].buf = &buf;
  700. ret = i2c_transfer(a, msg, 2);
  701. if (ret < 0) {
  702. printk(KERN_ERR "error %d\n", ret);
  703. buf = 0xff;
  704. }
  705. return buf;
  706. }
  707. static void __init sh_eth_init(struct sh_eth_plat_data *pd)
  708. {
  709. struct i2c_adapter *a = i2c_get_adapter(1);
  710. int i;
  711. if (!a) {
  712. pr_err("can not get I2C 1\n");
  713. return;
  714. }
  715. /* read MAC address frome EEPROM */
  716. for (i = 0; i < sizeof(pd->mac_addr); i++) {
  717. pd->mac_addr[i] = mac_read(a, 0x10 + i);
  718. msleep(10);
  719. }
  720. }
  721. #define PORT_HIZA 0xA4050158
  722. #define IODRIVEA 0xA405018A
  723. extern char ecovec24_sdram_enter_start;
  724. extern char ecovec24_sdram_enter_end;
  725. extern char ecovec24_sdram_leave_start;
  726. extern char ecovec24_sdram_leave_end;
  727. static int __init arch_setup(void)
  728. {
  729. struct clk *clk;
  730. /* register board specific self-refresh code */
  731. sh_mobile_register_self_refresh(SUSP_SH_STANDBY | SUSP_SH_SF,
  732. &ecovec24_sdram_enter_start,
  733. &ecovec24_sdram_enter_end,
  734. &ecovec24_sdram_leave_start,
  735. &ecovec24_sdram_leave_end);
  736. /* enable STATUS0, STATUS2 and PDSTATUS */
  737. gpio_request(GPIO_FN_STATUS0, NULL);
  738. gpio_request(GPIO_FN_STATUS2, NULL);
  739. gpio_request(GPIO_FN_PDSTATUS, NULL);
  740. /* enable SCIFA0 */
  741. gpio_request(GPIO_FN_SCIF0_TXD, NULL);
  742. gpio_request(GPIO_FN_SCIF0_RXD, NULL);
  743. /* enable debug LED */
  744. gpio_request(GPIO_PTG0, NULL);
  745. gpio_request(GPIO_PTG1, NULL);
  746. gpio_request(GPIO_PTG2, NULL);
  747. gpio_request(GPIO_PTG3, NULL);
  748. gpio_direction_output(GPIO_PTG0, 0);
  749. gpio_direction_output(GPIO_PTG1, 0);
  750. gpio_direction_output(GPIO_PTG2, 0);
  751. gpio_direction_output(GPIO_PTG3, 0);
  752. ctrl_outw((ctrl_inw(PORT_HIZA) & ~(0x1 << 1)) , PORT_HIZA);
  753. /* enable SH-Eth */
  754. gpio_request(GPIO_PTA1, NULL);
  755. gpio_direction_output(GPIO_PTA1, 1);
  756. mdelay(20);
  757. gpio_request(GPIO_FN_RMII_RXD0, NULL);
  758. gpio_request(GPIO_FN_RMII_RXD1, NULL);
  759. gpio_request(GPIO_FN_RMII_TXD0, NULL);
  760. gpio_request(GPIO_FN_RMII_TXD1, NULL);
  761. gpio_request(GPIO_FN_RMII_REF_CLK, NULL);
  762. gpio_request(GPIO_FN_RMII_TX_EN, NULL);
  763. gpio_request(GPIO_FN_RMII_RX_ER, NULL);
  764. gpio_request(GPIO_FN_RMII_CRS_DV, NULL);
  765. gpio_request(GPIO_FN_MDIO, NULL);
  766. gpio_request(GPIO_FN_MDC, NULL);
  767. gpio_request(GPIO_FN_LNKSTA, NULL);
  768. /* enable USB */
  769. ctrl_outw(0x0000, 0xA4D80000);
  770. ctrl_outw(0x0000, 0xA4D90000);
  771. gpio_request(GPIO_PTB3, NULL);
  772. gpio_request(GPIO_PTB4, NULL);
  773. gpio_request(GPIO_PTB5, NULL);
  774. gpio_direction_input(GPIO_PTB3);
  775. gpio_direction_output(GPIO_PTB4, 0);
  776. gpio_direction_output(GPIO_PTB5, 0);
  777. ctrl_outw(0x0600, 0xa40501d4);
  778. ctrl_outw(0x0600, 0xa4050192);
  779. if (gpio_get_value(GPIO_PTB3)) {
  780. printk(KERN_INFO "USB1 function is selected\n");
  781. usb1_common_device.name = "r8a66597_udc";
  782. } else {
  783. printk(KERN_INFO "USB1 host is selected\n");
  784. usb1_common_device.name = "r8a66597_hcd";
  785. }
  786. /* enable LCDC */
  787. gpio_request(GPIO_FN_LCDD23, NULL);
  788. gpio_request(GPIO_FN_LCDD22, NULL);
  789. gpio_request(GPIO_FN_LCDD21, NULL);
  790. gpio_request(GPIO_FN_LCDD20, NULL);
  791. gpio_request(GPIO_FN_LCDD19, NULL);
  792. gpio_request(GPIO_FN_LCDD18, NULL);
  793. gpio_request(GPIO_FN_LCDD17, NULL);
  794. gpio_request(GPIO_FN_LCDD16, NULL);
  795. gpio_request(GPIO_FN_LCDD15, NULL);
  796. gpio_request(GPIO_FN_LCDD14, NULL);
  797. gpio_request(GPIO_FN_LCDD13, NULL);
  798. gpio_request(GPIO_FN_LCDD12, NULL);
  799. gpio_request(GPIO_FN_LCDD11, NULL);
  800. gpio_request(GPIO_FN_LCDD10, NULL);
  801. gpio_request(GPIO_FN_LCDD9, NULL);
  802. gpio_request(GPIO_FN_LCDD8, NULL);
  803. gpio_request(GPIO_FN_LCDD7, NULL);
  804. gpio_request(GPIO_FN_LCDD6, NULL);
  805. gpio_request(GPIO_FN_LCDD5, NULL);
  806. gpio_request(GPIO_FN_LCDD4, NULL);
  807. gpio_request(GPIO_FN_LCDD3, NULL);
  808. gpio_request(GPIO_FN_LCDD2, NULL);
  809. gpio_request(GPIO_FN_LCDD1, NULL);
  810. gpio_request(GPIO_FN_LCDD0, NULL);
  811. gpio_request(GPIO_FN_LCDDISP, NULL);
  812. gpio_request(GPIO_FN_LCDHSYN, NULL);
  813. gpio_request(GPIO_FN_LCDDCK, NULL);
  814. gpio_request(GPIO_FN_LCDVSYN, NULL);
  815. gpio_request(GPIO_FN_LCDDON, NULL);
  816. gpio_request(GPIO_FN_LCDLCLK, NULL);
  817. ctrl_outw((ctrl_inw(PORT_HIZA) & ~0x0001), PORT_HIZA);
  818. gpio_request(GPIO_PTE6, NULL);
  819. gpio_request(GPIO_PTU1, NULL);
  820. gpio_request(GPIO_PTR1, NULL);
  821. gpio_request(GPIO_PTA2, NULL);
  822. gpio_direction_input(GPIO_PTE6);
  823. gpio_direction_output(GPIO_PTU1, 0);
  824. gpio_direction_output(GPIO_PTR1, 0);
  825. gpio_direction_output(GPIO_PTA2, 0);
  826. /* I/O buffer drive ability is high */
  827. ctrl_outw((ctrl_inw(IODRIVEA) & ~0x00c0) | 0x0080 , IODRIVEA);
  828. if (gpio_get_value(GPIO_PTE6)) {
  829. /* DVI */
  830. lcdc_info.clock_source = LCDC_CLK_EXTERNAL;
  831. lcdc_info.ch[0].clock_divider = 1,
  832. lcdc_info.ch[0].lcd_cfg.name = "DVI";
  833. lcdc_info.ch[0].lcd_cfg.xres = 1280;
  834. lcdc_info.ch[0].lcd_cfg.yres = 720;
  835. lcdc_info.ch[0].lcd_cfg.left_margin = 220;
  836. lcdc_info.ch[0].lcd_cfg.right_margin = 110;
  837. lcdc_info.ch[0].lcd_cfg.hsync_len = 40;
  838. lcdc_info.ch[0].lcd_cfg.upper_margin = 20;
  839. lcdc_info.ch[0].lcd_cfg.lower_margin = 5;
  840. lcdc_info.ch[0].lcd_cfg.vsync_len = 5;
  841. gpio_set_value(GPIO_PTA2, 1);
  842. gpio_set_value(GPIO_PTU1, 1);
  843. } else {
  844. /* Panel */
  845. lcdc_info.clock_source = LCDC_CLK_PERIPHERAL;
  846. lcdc_info.ch[0].clock_divider = 2,
  847. lcdc_info.ch[0].lcd_cfg.name = "Panel";
  848. lcdc_info.ch[0].lcd_cfg.xres = 800;
  849. lcdc_info.ch[0].lcd_cfg.yres = 480;
  850. lcdc_info.ch[0].lcd_cfg.left_margin = 220;
  851. lcdc_info.ch[0].lcd_cfg.right_margin = 110;
  852. lcdc_info.ch[0].lcd_cfg.hsync_len = 70;
  853. lcdc_info.ch[0].lcd_cfg.upper_margin = 20;
  854. lcdc_info.ch[0].lcd_cfg.lower_margin = 5;
  855. lcdc_info.ch[0].lcd_cfg.vsync_len = 5;
  856. gpio_set_value(GPIO_PTR1, 1);
  857. /* FIXME
  858. *
  859. * LCDDON control is needed for Panel,
  860. * but current sh_mobile_lcdc driver doesn't control it.
  861. * It is temporary correspondence
  862. */
  863. gpio_request(GPIO_PTF4, NULL);
  864. gpio_direction_output(GPIO_PTF4, 1);
  865. /* enable TouchScreen */
  866. i2c_register_board_info(0, &ts_i2c_clients, 1);
  867. set_irq_type(IRQ0, IRQ_TYPE_LEVEL_LOW);
  868. }
  869. /* enable CEU0 */
  870. gpio_request(GPIO_FN_VIO0_D15, NULL);
  871. gpio_request(GPIO_FN_VIO0_D14, NULL);
  872. gpio_request(GPIO_FN_VIO0_D13, NULL);
  873. gpio_request(GPIO_FN_VIO0_D12, NULL);
  874. gpio_request(GPIO_FN_VIO0_D11, NULL);
  875. gpio_request(GPIO_FN_VIO0_D10, NULL);
  876. gpio_request(GPIO_FN_VIO0_D9, NULL);
  877. gpio_request(GPIO_FN_VIO0_D8, NULL);
  878. gpio_request(GPIO_FN_VIO0_D7, NULL);
  879. gpio_request(GPIO_FN_VIO0_D6, NULL);
  880. gpio_request(GPIO_FN_VIO0_D5, NULL);
  881. gpio_request(GPIO_FN_VIO0_D4, NULL);
  882. gpio_request(GPIO_FN_VIO0_D3, NULL);
  883. gpio_request(GPIO_FN_VIO0_D2, NULL);
  884. gpio_request(GPIO_FN_VIO0_D1, NULL);
  885. gpio_request(GPIO_FN_VIO0_D0, NULL);
  886. gpio_request(GPIO_FN_VIO0_VD, NULL);
  887. gpio_request(GPIO_FN_VIO0_CLK, NULL);
  888. gpio_request(GPIO_FN_VIO0_FLD, NULL);
  889. gpio_request(GPIO_FN_VIO0_HD, NULL);
  890. platform_resource_setup_memory(&ceu0_device, "ceu0", 4 << 20);
  891. /* enable CEU1 */
  892. gpio_request(GPIO_FN_VIO1_D7, NULL);
  893. gpio_request(GPIO_FN_VIO1_D6, NULL);
  894. gpio_request(GPIO_FN_VIO1_D5, NULL);
  895. gpio_request(GPIO_FN_VIO1_D4, NULL);
  896. gpio_request(GPIO_FN_VIO1_D3, NULL);
  897. gpio_request(GPIO_FN_VIO1_D2, NULL);
  898. gpio_request(GPIO_FN_VIO1_D1, NULL);
  899. gpio_request(GPIO_FN_VIO1_D0, NULL);
  900. gpio_request(GPIO_FN_VIO1_FLD, NULL);
  901. gpio_request(GPIO_FN_VIO1_HD, NULL);
  902. gpio_request(GPIO_FN_VIO1_VD, NULL);
  903. gpio_request(GPIO_FN_VIO1_CLK, NULL);
  904. platform_resource_setup_memory(&ceu1_device, "ceu1", 4 << 20);
  905. /* enable KEYSC */
  906. gpio_request(GPIO_FN_KEYOUT5_IN5, NULL);
  907. gpio_request(GPIO_FN_KEYOUT4_IN6, NULL);
  908. gpio_request(GPIO_FN_KEYOUT3, NULL);
  909. gpio_request(GPIO_FN_KEYOUT2, NULL);
  910. gpio_request(GPIO_FN_KEYOUT1, NULL);
  911. gpio_request(GPIO_FN_KEYOUT0, NULL);
  912. gpio_request(GPIO_FN_KEYIN0, NULL);
  913. /* enable user debug switch */
  914. gpio_request(GPIO_PTR0, NULL);
  915. gpio_request(GPIO_PTR4, NULL);
  916. gpio_request(GPIO_PTR5, NULL);
  917. gpio_request(GPIO_PTR6, NULL);
  918. gpio_direction_input(GPIO_PTR0);
  919. gpio_direction_input(GPIO_PTR4);
  920. gpio_direction_input(GPIO_PTR5);
  921. gpio_direction_input(GPIO_PTR6);
  922. #ifdef CONFIG_MFD_SH_MOBILE_SDHI
  923. /* enable SDHI0 on CN11 (needs DS2.4 set to ON) */
  924. gpio_request(GPIO_FN_SDHI0CD, NULL);
  925. gpio_request(GPIO_FN_SDHI0WP, NULL);
  926. gpio_request(GPIO_FN_SDHI0CMD, NULL);
  927. gpio_request(GPIO_FN_SDHI0CLK, NULL);
  928. gpio_request(GPIO_FN_SDHI0D3, NULL);
  929. gpio_request(GPIO_FN_SDHI0D2, NULL);
  930. gpio_request(GPIO_FN_SDHI0D1, NULL);
  931. gpio_request(GPIO_FN_SDHI0D0, NULL);
  932. gpio_request(GPIO_PTB6, NULL);
  933. gpio_direction_output(GPIO_PTB6, 0);
  934. /* enable SDHI1 on CN12 (needs DS2.6,7 set to ON,OFF) */
  935. gpio_request(GPIO_FN_SDHI1CD, NULL);
  936. gpio_request(GPIO_FN_SDHI1WP, NULL);
  937. gpio_request(GPIO_FN_SDHI1CMD, NULL);
  938. gpio_request(GPIO_FN_SDHI1CLK, NULL);
  939. gpio_request(GPIO_FN_SDHI1D3, NULL);
  940. gpio_request(GPIO_FN_SDHI1D2, NULL);
  941. gpio_request(GPIO_FN_SDHI1D1, NULL);
  942. gpio_request(GPIO_FN_SDHI1D0, NULL);
  943. gpio_request(GPIO_PTB7, NULL);
  944. gpio_direction_output(GPIO_PTB7, 0);
  945. /* I/O buffer drive ability is high for SDHI1 */
  946. ctrl_outw((ctrl_inw(IODRIVEA) & ~0x3000) | 0x2000 , IODRIVEA);
  947. #else
  948. /* enable MSIOF0 on CN11 (needs DS2.4 set to OFF) */
  949. gpio_request(GPIO_FN_MSIOF0_TXD, NULL);
  950. gpio_request(GPIO_FN_MSIOF0_RXD, NULL);
  951. gpio_request(GPIO_FN_MSIOF0_TSCK, NULL);
  952. gpio_request(GPIO_PTM4, NULL); /* software CS control of TSYNC pin */
  953. gpio_direction_output(GPIO_PTM4, 1); /* active low CS */
  954. gpio_request(GPIO_PTB6, NULL); /* 3.3V power control */
  955. gpio_direction_output(GPIO_PTB6, 0); /* disable power by default */
  956. gpio_request(GPIO_PTY6, NULL); /* write protect */
  957. gpio_direction_input(GPIO_PTY6);
  958. gpio_request(GPIO_PTY7, NULL); /* card detect */
  959. gpio_direction_input(GPIO_PTY7);
  960. spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus));
  961. #endif
  962. /* enable Video */
  963. gpio_request(GPIO_PTU2, NULL);
  964. gpio_direction_output(GPIO_PTU2, 1);
  965. /* enable Camera */
  966. gpio_request(GPIO_PTA3, NULL);
  967. gpio_request(GPIO_PTA4, NULL);
  968. gpio_direction_output(GPIO_PTA3, 0);
  969. gpio_direction_output(GPIO_PTA4, 0);
  970. /* enable FSI */
  971. gpio_request(GPIO_FN_FSIMCKB, NULL);
  972. gpio_request(GPIO_FN_FSIIBSD, NULL);
  973. gpio_request(GPIO_FN_FSIOBSD, NULL);
  974. gpio_request(GPIO_FN_FSIIBBCK, NULL);
  975. gpio_request(GPIO_FN_FSIIBLRCK, NULL);
  976. gpio_request(GPIO_FN_FSIOBBCK, NULL);
  977. gpio_request(GPIO_FN_FSIOBLRCK, NULL);
  978. gpio_request(GPIO_FN_CLKAUDIOBO, NULL);
  979. /* change parent of FSI B */
  980. clk = clk_get(NULL, "fsib_clk");
  981. clk_register(&fsimckb_clk);
  982. clk_set_parent(clk, &fsimckb_clk);
  983. clk_set_rate(clk, 11000);
  984. clk_set_rate(&fsimckb_clk, 11000);
  985. clk_put(clk);
  986. gpio_request(GPIO_PTU0, NULL);
  987. gpio_direction_output(GPIO_PTU0, 0);
  988. mdelay(20);
  989. /* enable I2C device */
  990. i2c_register_board_info(0, i2c0_devices,
  991. ARRAY_SIZE(i2c0_devices));
  992. i2c_register_board_info(1, i2c1_devices,
  993. ARRAY_SIZE(i2c1_devices));
  994. return platform_add_devices(ecovec_devices,
  995. ARRAY_SIZE(ecovec_devices));
  996. }
  997. arch_initcall(arch_setup);
  998. static int __init devices_setup(void)
  999. {
  1000. sh_eth_init(&sh_eth_plat);
  1001. return 0;
  1002. }
  1003. device_initcall(devices_setup);
  1004. static struct sh_machine_vector mv_ecovec __initmv = {
  1005. .mv_name = "R0P7724 (EcoVec)",
  1006. };