setup.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953
  1. /*
  2. * linux/arch/sh/boards/se/7724/setup.c
  3. *
  4. * Copyright (C) 2009 Renesas Solutions Corp.
  5. *
  6. * Kuninori Morimoto <morimoto.kuninori@renesas.com>
  7. *
  8. * This file is subject to the terms and conditions of the GNU General Public
  9. * License. See the file "COPYING" in the main directory of this archive
  10. * for more details.
  11. */
  12. #include <linux/init.h>
  13. #include <linux/device.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/mfd/sh_mobile_sdhi.h>
  17. #include <linux/mmc/host.h>
  18. #include <linux/mtd/physmap.h>
  19. #include <linux/delay.h>
  20. #include <linux/smc91x.h>
  21. #include <linux/gpio.h>
  22. #include <linux/input.h>
  23. #include <linux/input/sh_keysc.h>
  24. #include <linux/usb/r8a66597.h>
  25. #include <video/sh_mobile_lcdc.h>
  26. #include <media/sh_mobile_ceu.h>
  27. #include <sound/sh_fsi.h>
  28. #include <asm/io.h>
  29. #include <asm/heartbeat.h>
  30. #include <asm/sh_eth.h>
  31. #include <asm/clock.h>
  32. #include <asm/suspend.h>
  33. #include <cpu/sh7724.h>
  34. #include <mach-se/mach/se7724.h>
  35. /*
  36. * SWx 1234 5678
  37. * ------------------------------------
  38. * SW31 : 1001 1100 : default
  39. * SW32 : 0111 1111 : use on board flash
  40. *
  41. * SW41 : abxx xxxx -> a = 0 : Analog monitor
  42. * 1 : Digital monitor
  43. * b = 0 : VGA
  44. * 1 : 720p
  45. */
  46. /*
  47. * about 720p
  48. *
  49. * When you use 1280 x 720 lcdc output,
  50. * you should change OSC6 lcdc clock from 25.175MHz to 74.25MHz,
  51. * and change SW41 to use 720p
  52. */
  53. /*
  54. * about sound
  55. *
  56. * This setup.c supports FSI slave mode.
  57. * Please change J20, J21, J22 pin to 1-2 connection.
  58. */
  59. /* Heartbeat */
  60. static struct resource heartbeat_resource = {
  61. .start = PA_LED,
  62. .end = PA_LED,
  63. .flags = IORESOURCE_MEM | IORESOURCE_MEM_16BIT,
  64. };
  65. static struct platform_device heartbeat_device = {
  66. .name = "heartbeat",
  67. .id = -1,
  68. .num_resources = 1,
  69. .resource = &heartbeat_resource,
  70. };
  71. /* LAN91C111 */
  72. static struct smc91x_platdata smc91x_info = {
  73. .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
  74. };
  75. static struct resource smc91x_eth_resources[] = {
  76. [0] = {
  77. .name = "SMC91C111" ,
  78. .start = 0x1a300300,
  79. .end = 0x1a30030f,
  80. .flags = IORESOURCE_MEM,
  81. },
  82. [1] = {
  83. .start = IRQ0_SMC,
  84. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  85. },
  86. };
  87. static struct platform_device smc91x_eth_device = {
  88. .name = "smc91x",
  89. .num_resources = ARRAY_SIZE(smc91x_eth_resources),
  90. .resource = smc91x_eth_resources,
  91. .dev = {
  92. .platform_data = &smc91x_info,
  93. },
  94. };
  95. /* MTD */
  96. static struct mtd_partition nor_flash_partitions[] = {
  97. {
  98. .name = "uboot",
  99. .offset = 0,
  100. .size = (1 * 1024 * 1024),
  101. .mask_flags = MTD_WRITEABLE, /* Read-only */
  102. }, {
  103. .name = "kernel",
  104. .offset = MTDPART_OFS_APPEND,
  105. .size = (2 * 1024 * 1024),
  106. }, {
  107. .name = "free-area",
  108. .offset = MTDPART_OFS_APPEND,
  109. .size = MTDPART_SIZ_FULL,
  110. },
  111. };
  112. static struct physmap_flash_data nor_flash_data = {
  113. .width = 2,
  114. .parts = nor_flash_partitions,
  115. .nr_parts = ARRAY_SIZE(nor_flash_partitions),
  116. };
  117. static struct resource nor_flash_resources[] = {
  118. [0] = {
  119. .name = "NOR Flash",
  120. .start = 0x00000000,
  121. .end = 0x01ffffff,
  122. .flags = IORESOURCE_MEM,
  123. }
  124. };
  125. static struct platform_device nor_flash_device = {
  126. .name = "physmap-flash",
  127. .resource = nor_flash_resources,
  128. .num_resources = ARRAY_SIZE(nor_flash_resources),
  129. .dev = {
  130. .platform_data = &nor_flash_data,
  131. },
  132. };
  133. /* LCDC */
  134. const static struct fb_videomode lcdc_720p_modes[] = {
  135. {
  136. .name = "LB070WV1",
  137. .sync = 0, /* hsync and vsync are active low */
  138. .xres = 1280,
  139. .yres = 720,
  140. .left_margin = 220,
  141. .right_margin = 110,
  142. .hsync_len = 40,
  143. .upper_margin = 20,
  144. .lower_margin = 5,
  145. .vsync_len = 5,
  146. },
  147. };
  148. const static struct fb_videomode lcdc_vga_modes[] = {
  149. {
  150. .name = "LB070WV1",
  151. .sync = 0, /* hsync and vsync are active low */
  152. .xres = 640,
  153. .yres = 480,
  154. .left_margin = 105,
  155. .right_margin = 50,
  156. .hsync_len = 96,
  157. .upper_margin = 33,
  158. .lower_margin = 10,
  159. .vsync_len = 2,
  160. },
  161. };
  162. static struct sh_mobile_lcdc_info lcdc_info = {
  163. .clock_source = LCDC_CLK_EXTERNAL,
  164. .ch[0] = {
  165. .chan = LCDC_CHAN_MAINLCD,
  166. .bpp = 16,
  167. .clock_divider = 1,
  168. .lcd_size_cfg = { /* 7.0 inch */
  169. .width = 152,
  170. .height = 91,
  171. },
  172. .board_cfg = {
  173. },
  174. }
  175. };
  176. static struct resource lcdc_resources[] = {
  177. [0] = {
  178. .name = "LCDC",
  179. .start = 0xfe940000,
  180. .end = 0xfe942fff,
  181. .flags = IORESOURCE_MEM,
  182. },
  183. [1] = {
  184. .start = 106,
  185. .flags = IORESOURCE_IRQ,
  186. },
  187. };
  188. static struct platform_device lcdc_device = {
  189. .name = "sh_mobile_lcdc_fb",
  190. .num_resources = ARRAY_SIZE(lcdc_resources),
  191. .resource = lcdc_resources,
  192. .dev = {
  193. .platform_data = &lcdc_info,
  194. },
  195. .archdata = {
  196. .hwblk_id = HWBLK_LCDC,
  197. },
  198. };
  199. /* CEU0 */
  200. static struct sh_mobile_ceu_info sh_mobile_ceu0_info = {
  201. .flags = SH_CEU_FLAG_USE_8BIT_BUS,
  202. };
  203. static struct resource ceu0_resources[] = {
  204. [0] = {
  205. .name = "CEU0",
  206. .start = 0xfe910000,
  207. .end = 0xfe91009f,
  208. .flags = IORESOURCE_MEM,
  209. },
  210. [1] = {
  211. .start = 52,
  212. .flags = IORESOURCE_IRQ,
  213. },
  214. [2] = {
  215. /* place holder for contiguous memory */
  216. },
  217. };
  218. static struct platform_device ceu0_device = {
  219. .name = "sh_mobile_ceu",
  220. .id = 0, /* "ceu0" clock */
  221. .num_resources = ARRAY_SIZE(ceu0_resources),
  222. .resource = ceu0_resources,
  223. .dev = {
  224. .platform_data = &sh_mobile_ceu0_info,
  225. },
  226. .archdata = {
  227. .hwblk_id = HWBLK_CEU0,
  228. },
  229. };
  230. /* CEU1 */
  231. static struct sh_mobile_ceu_info sh_mobile_ceu1_info = {
  232. .flags = SH_CEU_FLAG_USE_8BIT_BUS,
  233. };
  234. static struct resource ceu1_resources[] = {
  235. [0] = {
  236. .name = "CEU1",
  237. .start = 0xfe914000,
  238. .end = 0xfe91409f,
  239. .flags = IORESOURCE_MEM,
  240. },
  241. [1] = {
  242. .start = 63,
  243. .flags = IORESOURCE_IRQ,
  244. },
  245. [2] = {
  246. /* place holder for contiguous memory */
  247. },
  248. };
  249. static struct platform_device ceu1_device = {
  250. .name = "sh_mobile_ceu",
  251. .id = 1, /* "ceu1" clock */
  252. .num_resources = ARRAY_SIZE(ceu1_resources),
  253. .resource = ceu1_resources,
  254. .dev = {
  255. .platform_data = &sh_mobile_ceu1_info,
  256. },
  257. .archdata = {
  258. .hwblk_id = HWBLK_CEU1,
  259. },
  260. };
  261. /* FSI */
  262. /* change J20, J21, J22 pin to 1-2 connection to use slave mode */
  263. static struct sh_fsi_platform_info fsi_info = {
  264. .porta_flags = SH_FSI_BRS_INV |
  265. SH_FSI_OUT_SLAVE_MODE |
  266. SH_FSI_IN_SLAVE_MODE |
  267. SH_FSI_OFMT(PCM) |
  268. SH_FSI_IFMT(PCM),
  269. };
  270. static struct resource fsi_resources[] = {
  271. [0] = {
  272. .name = "FSI",
  273. .start = 0xFE3C0000,
  274. .end = 0xFE3C021d,
  275. .flags = IORESOURCE_MEM,
  276. },
  277. [1] = {
  278. .start = 108,
  279. .flags = IORESOURCE_IRQ,
  280. },
  281. };
  282. static struct platform_device fsi_device = {
  283. .name = "sh_fsi",
  284. .id = 0,
  285. .num_resources = ARRAY_SIZE(fsi_resources),
  286. .resource = fsi_resources,
  287. .dev = {
  288. .platform_data = &fsi_info,
  289. },
  290. .archdata = {
  291. .hwblk_id = HWBLK_SPU, /* FSI needs SPU hwblk */
  292. },
  293. };
  294. static struct platform_device fsi_ak4642_device = {
  295. .name = "sh_fsi_a_ak4642",
  296. };
  297. /* KEYSC in SoC (Needs SW33-2 set to ON) */
  298. static struct sh_keysc_info keysc_info = {
  299. .mode = SH_KEYSC_MODE_1,
  300. .scan_timing = 3,
  301. .delay = 50,
  302. .keycodes = {
  303. KEY_1, KEY_2, KEY_3, KEY_4, KEY_5,
  304. KEY_6, KEY_7, KEY_8, KEY_9, KEY_A,
  305. KEY_B, KEY_C, KEY_D, KEY_E, KEY_F,
  306. KEY_G, KEY_H, KEY_I, KEY_K, KEY_L,
  307. KEY_M, KEY_N, KEY_O, KEY_P, KEY_Q,
  308. KEY_R, KEY_S, KEY_T, KEY_U, KEY_V,
  309. },
  310. };
  311. static struct resource keysc_resources[] = {
  312. [0] = {
  313. .name = "KEYSC",
  314. .start = 0x044b0000,
  315. .end = 0x044b000f,
  316. .flags = IORESOURCE_MEM,
  317. },
  318. [1] = {
  319. .start = 79,
  320. .flags = IORESOURCE_IRQ,
  321. },
  322. };
  323. static struct platform_device keysc_device = {
  324. .name = "sh_keysc",
  325. .id = 0, /* "keysc0" clock */
  326. .num_resources = ARRAY_SIZE(keysc_resources),
  327. .resource = keysc_resources,
  328. .dev = {
  329. .platform_data = &keysc_info,
  330. },
  331. .archdata = {
  332. .hwblk_id = HWBLK_KEYSC,
  333. },
  334. };
  335. /* SH Eth */
  336. static struct resource sh_eth_resources[] = {
  337. [0] = {
  338. .start = SH_ETH_ADDR,
  339. .end = SH_ETH_ADDR + 0x1FC,
  340. .flags = IORESOURCE_MEM,
  341. },
  342. [1] = {
  343. .start = 91,
  344. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  345. },
  346. };
  347. static struct sh_eth_plat_data sh_eth_plat = {
  348. .phy = 0x1f, /* SMSC LAN8187 */
  349. .edmac_endian = EDMAC_LITTLE_ENDIAN,
  350. };
  351. static struct platform_device sh_eth_device = {
  352. .name = "sh-eth",
  353. .id = 0,
  354. .dev = {
  355. .platform_data = &sh_eth_plat,
  356. },
  357. .num_resources = ARRAY_SIZE(sh_eth_resources),
  358. .resource = sh_eth_resources,
  359. .archdata = {
  360. .hwblk_id = HWBLK_ETHER,
  361. },
  362. };
  363. static struct r8a66597_platdata sh7724_usb0_host_data = {
  364. .on_chip = 1,
  365. };
  366. static struct resource sh7724_usb0_host_resources[] = {
  367. [0] = {
  368. .start = 0xa4d80000,
  369. .end = 0xa4d80124 - 1,
  370. .flags = IORESOURCE_MEM,
  371. },
  372. [1] = {
  373. .start = 65,
  374. .end = 65,
  375. .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
  376. },
  377. };
  378. static struct platform_device sh7724_usb0_host_device = {
  379. .name = "r8a66597_hcd",
  380. .id = 0,
  381. .dev = {
  382. .dma_mask = NULL, /* not use dma */
  383. .coherent_dma_mask = 0xffffffff,
  384. .platform_data = &sh7724_usb0_host_data,
  385. },
  386. .num_resources = ARRAY_SIZE(sh7724_usb0_host_resources),
  387. .resource = sh7724_usb0_host_resources,
  388. .archdata = {
  389. .hwblk_id = HWBLK_USB0,
  390. },
  391. };
  392. static struct r8a66597_platdata sh7724_usb1_gadget_data = {
  393. .on_chip = 1,
  394. };
  395. static struct resource sh7724_usb1_gadget_resources[] = {
  396. [0] = {
  397. .start = 0xa4d90000,
  398. .end = 0xa4d90123,
  399. .flags = IORESOURCE_MEM,
  400. },
  401. [1] = {
  402. .start = 66,
  403. .end = 66,
  404. .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
  405. },
  406. };
  407. static struct platform_device sh7724_usb1_gadget_device = {
  408. .name = "r8a66597_udc",
  409. .id = 1, /* USB1 */
  410. .dev = {
  411. .dma_mask = NULL, /* not use dma */
  412. .coherent_dma_mask = 0xffffffff,
  413. .platform_data = &sh7724_usb1_gadget_data,
  414. },
  415. .num_resources = ARRAY_SIZE(sh7724_usb1_gadget_resources),
  416. .resource = sh7724_usb1_gadget_resources,
  417. };
  418. static struct resource sdhi0_cn7_resources[] = {
  419. [0] = {
  420. .name = "SDHI0",
  421. .start = 0x04ce0000,
  422. .end = 0x04ce01ff,
  423. .flags = IORESOURCE_MEM,
  424. },
  425. [1] = {
  426. .start = 100,
  427. .flags = IORESOURCE_IRQ,
  428. },
  429. };
  430. static struct sh_mobile_sdhi_info sh7724_sdhi0_data = {
  431. .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
  432. .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
  433. .tmio_caps = MMC_CAP_SDIO_IRQ,
  434. };
  435. static struct platform_device sdhi0_cn7_device = {
  436. .name = "sh_mobile_sdhi",
  437. .id = 0,
  438. .num_resources = ARRAY_SIZE(sdhi0_cn7_resources),
  439. .resource = sdhi0_cn7_resources,
  440. .dev = {
  441. .platform_data = &sh7724_sdhi0_data,
  442. },
  443. .archdata = {
  444. .hwblk_id = HWBLK_SDHI0,
  445. },
  446. };
  447. static struct resource sdhi1_cn8_resources[] = {
  448. [0] = {
  449. .name = "SDHI1",
  450. .start = 0x04cf0000,
  451. .end = 0x04cf01ff,
  452. .flags = IORESOURCE_MEM,
  453. },
  454. [1] = {
  455. .start = 23,
  456. .flags = IORESOURCE_IRQ,
  457. },
  458. };
  459. static struct sh_mobile_sdhi_info sh7724_sdhi1_data = {
  460. .dma_slave_tx = SHDMA_SLAVE_SDHI1_TX,
  461. .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX,
  462. .tmio_caps = MMC_CAP_SDIO_IRQ,
  463. };
  464. static struct platform_device sdhi1_cn8_device = {
  465. .name = "sh_mobile_sdhi",
  466. .id = 1,
  467. .num_resources = ARRAY_SIZE(sdhi1_cn8_resources),
  468. .resource = sdhi1_cn8_resources,
  469. .dev = {
  470. .platform_data = &sh7724_sdhi1_data,
  471. },
  472. .archdata = {
  473. .hwblk_id = HWBLK_SDHI1,
  474. },
  475. };
  476. /* IrDA */
  477. static struct resource irda_resources[] = {
  478. [0] = {
  479. .name = "IrDA",
  480. .start = 0xA45D0000,
  481. .end = 0xA45D0049,
  482. .flags = IORESOURCE_MEM,
  483. },
  484. [1] = {
  485. .start = 20,
  486. .flags = IORESOURCE_IRQ,
  487. },
  488. };
  489. static struct platform_device irda_device = {
  490. .name = "sh_sir",
  491. .num_resources = ARRAY_SIZE(irda_resources),
  492. .resource = irda_resources,
  493. };
  494. #include <media/ak881x.h>
  495. #include <media/sh_vou.h>
  496. static struct ak881x_pdata ak881x_pdata = {
  497. .flags = AK881X_IF_MODE_SLAVE,
  498. };
  499. static struct i2c_board_info ak8813 = {
  500. /* With open J18 jumper address is 0x21 */
  501. I2C_BOARD_INFO("ak8813", 0x20),
  502. .platform_data = &ak881x_pdata,
  503. };
  504. static struct sh_vou_pdata sh_vou_pdata = {
  505. .bus_fmt = SH_VOU_BUS_8BIT,
  506. .flags = SH_VOU_HSYNC_LOW | SH_VOU_VSYNC_LOW,
  507. .board_info = &ak8813,
  508. .i2c_adap = 0,
  509. };
  510. static struct resource sh_vou_resources[] = {
  511. [0] = {
  512. .start = 0xfe960000,
  513. .end = 0xfe962043,
  514. .flags = IORESOURCE_MEM,
  515. },
  516. [1] = {
  517. .start = 55,
  518. .flags = IORESOURCE_IRQ,
  519. },
  520. };
  521. static struct platform_device vou_device = {
  522. .name = "sh-vou",
  523. .id = -1,
  524. .num_resources = ARRAY_SIZE(sh_vou_resources),
  525. .resource = sh_vou_resources,
  526. .dev = {
  527. .platform_data = &sh_vou_pdata,
  528. },
  529. .archdata = {
  530. .hwblk_id = HWBLK_VOU,
  531. },
  532. };
  533. static struct platform_device *ms7724se_devices[] __initdata = {
  534. &heartbeat_device,
  535. &smc91x_eth_device,
  536. &lcdc_device,
  537. &nor_flash_device,
  538. &ceu0_device,
  539. &ceu1_device,
  540. &keysc_device,
  541. &sh_eth_device,
  542. &sh7724_usb0_host_device,
  543. &sh7724_usb1_gadget_device,
  544. &fsi_device,
  545. &fsi_ak4642_device,
  546. &sdhi0_cn7_device,
  547. &sdhi1_cn8_device,
  548. &irda_device,
  549. &vou_device,
  550. };
  551. /* I2C device */
  552. static struct i2c_board_info i2c0_devices[] = {
  553. {
  554. I2C_BOARD_INFO("ak4642", 0x12),
  555. },
  556. };
  557. #define EEPROM_OP 0xBA206000
  558. #define EEPROM_ADR 0xBA206004
  559. #define EEPROM_DATA 0xBA20600C
  560. #define EEPROM_STAT 0xBA206010
  561. #define EEPROM_STRT 0xBA206014
  562. static int __init sh_eth_is_eeprom_ready(void)
  563. {
  564. int t = 10000;
  565. while (t--) {
  566. if (!__raw_readw(EEPROM_STAT))
  567. return 1;
  568. udelay(1);
  569. }
  570. printk(KERN_ERR "ms7724se can not access to eeprom\n");
  571. return 0;
  572. }
  573. static void __init sh_eth_init(void)
  574. {
  575. int i;
  576. u16 mac;
  577. /* check EEPROM status */
  578. if (!sh_eth_is_eeprom_ready())
  579. return;
  580. /* read MAC addr from EEPROM */
  581. for (i = 0 ; i < 3 ; i++) {
  582. __raw_writew(0x0, EEPROM_OP); /* read */
  583. __raw_writew(i*2, EEPROM_ADR);
  584. __raw_writew(0x1, EEPROM_STRT);
  585. if (!sh_eth_is_eeprom_ready())
  586. return;
  587. mac = __raw_readw(EEPROM_DATA);
  588. sh_eth_plat.mac_addr[i << 1] = mac & 0xff;
  589. sh_eth_plat.mac_addr[(i << 1) + 1] = mac >> 8;
  590. }
  591. }
  592. #define SW4140 0xBA201000
  593. #define FPGA_OUT 0xBA200400
  594. #define PORT_HIZA 0xA4050158
  595. #define PORT_MSELCRB 0xA4050182
  596. #define SW41_A 0x0100
  597. #define SW41_B 0x0200
  598. #define SW41_C 0x0400
  599. #define SW41_D 0x0800
  600. #define SW41_E 0x1000
  601. #define SW41_F 0x2000
  602. #define SW41_G 0x4000
  603. #define SW41_H 0x8000
  604. extern char ms7724se_sdram_enter_start;
  605. extern char ms7724se_sdram_enter_end;
  606. extern char ms7724se_sdram_leave_start;
  607. extern char ms7724se_sdram_leave_end;
  608. static int __init arch_setup(void)
  609. {
  610. /* enable I2C device */
  611. i2c_register_board_info(0, i2c0_devices,
  612. ARRAY_SIZE(i2c0_devices));
  613. return 0;
  614. }
  615. arch_initcall(arch_setup);
  616. static int __init devices_setup(void)
  617. {
  618. u16 sw = __raw_readw(SW4140); /* select camera, monitor */
  619. struct clk *clk;
  620. u16 fpga_out;
  621. /* register board specific self-refresh code */
  622. sh_mobile_register_self_refresh(SUSP_SH_STANDBY | SUSP_SH_SF |
  623. SUSP_SH_RSTANDBY,
  624. &ms7724se_sdram_enter_start,
  625. &ms7724se_sdram_enter_end,
  626. &ms7724se_sdram_leave_start,
  627. &ms7724se_sdram_leave_end);
  628. /* Reset Release */
  629. fpga_out = __raw_readw(FPGA_OUT);
  630. /* bit4: NTSC_PDN, bit5: NTSC_RESET */
  631. fpga_out &= ~((1 << 1) | /* LAN */
  632. (1 << 4) | /* AK8813 PDN */
  633. (1 << 5) | /* AK8813 RESET */
  634. (1 << 6) | /* VIDEO DAC */
  635. (1 << 7) | /* AK4643 */
  636. (1 << 8) | /* IrDA */
  637. (1 << 12) | /* USB0 */
  638. (1 << 14)); /* RMII */
  639. __raw_writew(fpga_out | (1 << 4), FPGA_OUT);
  640. udelay(10);
  641. /* AK8813 RESET */
  642. __raw_writew(fpga_out | (1 << 5), FPGA_OUT);
  643. udelay(10);
  644. __raw_writew(fpga_out, FPGA_OUT);
  645. /* turn on USB clocks, use external clock */
  646. __raw_writew((__raw_readw(PORT_MSELCRB) & ~0xc000) | 0x8000, PORT_MSELCRB);
  647. /* Let LED9 show STATUS2 */
  648. gpio_request(GPIO_FN_STATUS2, NULL);
  649. /* Lit LED10 show STATUS0 */
  650. gpio_request(GPIO_FN_STATUS0, NULL);
  651. /* Lit LED11 show PDSTATUS */
  652. gpio_request(GPIO_FN_PDSTATUS, NULL);
  653. /* enable USB0 port */
  654. __raw_writew(0x0600, 0xa40501d4);
  655. /* enable USB1 port */
  656. __raw_writew(0x0600, 0xa4050192);
  657. /* enable IRQ 0,1,2 */
  658. gpio_request(GPIO_FN_INTC_IRQ0, NULL);
  659. gpio_request(GPIO_FN_INTC_IRQ1, NULL);
  660. gpio_request(GPIO_FN_INTC_IRQ2, NULL);
  661. /* enable SCIFA3 */
  662. gpio_request(GPIO_FN_SCIF3_I_SCK, NULL);
  663. gpio_request(GPIO_FN_SCIF3_I_RXD, NULL);
  664. gpio_request(GPIO_FN_SCIF3_I_TXD, NULL);
  665. gpio_request(GPIO_FN_SCIF3_I_CTS, NULL);
  666. gpio_request(GPIO_FN_SCIF3_I_RTS, NULL);
  667. /* enable LCDC */
  668. gpio_request(GPIO_FN_LCDD23, NULL);
  669. gpio_request(GPIO_FN_LCDD22, NULL);
  670. gpio_request(GPIO_FN_LCDD21, NULL);
  671. gpio_request(GPIO_FN_LCDD20, NULL);
  672. gpio_request(GPIO_FN_LCDD19, NULL);
  673. gpio_request(GPIO_FN_LCDD18, NULL);
  674. gpio_request(GPIO_FN_LCDD17, NULL);
  675. gpio_request(GPIO_FN_LCDD16, NULL);
  676. gpio_request(GPIO_FN_LCDD15, NULL);
  677. gpio_request(GPIO_FN_LCDD14, NULL);
  678. gpio_request(GPIO_FN_LCDD13, NULL);
  679. gpio_request(GPIO_FN_LCDD12, NULL);
  680. gpio_request(GPIO_FN_LCDD11, NULL);
  681. gpio_request(GPIO_FN_LCDD10, NULL);
  682. gpio_request(GPIO_FN_LCDD9, NULL);
  683. gpio_request(GPIO_FN_LCDD8, NULL);
  684. gpio_request(GPIO_FN_LCDD7, NULL);
  685. gpio_request(GPIO_FN_LCDD6, NULL);
  686. gpio_request(GPIO_FN_LCDD5, NULL);
  687. gpio_request(GPIO_FN_LCDD4, NULL);
  688. gpio_request(GPIO_FN_LCDD3, NULL);
  689. gpio_request(GPIO_FN_LCDD2, NULL);
  690. gpio_request(GPIO_FN_LCDD1, NULL);
  691. gpio_request(GPIO_FN_LCDD0, NULL);
  692. gpio_request(GPIO_FN_LCDDISP, NULL);
  693. gpio_request(GPIO_FN_LCDHSYN, NULL);
  694. gpio_request(GPIO_FN_LCDDCK, NULL);
  695. gpio_request(GPIO_FN_LCDVSYN, NULL);
  696. gpio_request(GPIO_FN_LCDDON, NULL);
  697. gpio_request(GPIO_FN_LCDVEPWC, NULL);
  698. gpio_request(GPIO_FN_LCDVCPWC, NULL);
  699. gpio_request(GPIO_FN_LCDRD, NULL);
  700. gpio_request(GPIO_FN_LCDLCLK, NULL);
  701. __raw_writew((__raw_readw(PORT_HIZA) & ~0x0001), PORT_HIZA);
  702. /* enable CEU0 */
  703. gpio_request(GPIO_FN_VIO0_D15, NULL);
  704. gpio_request(GPIO_FN_VIO0_D14, NULL);
  705. gpio_request(GPIO_FN_VIO0_D13, NULL);
  706. gpio_request(GPIO_FN_VIO0_D12, NULL);
  707. gpio_request(GPIO_FN_VIO0_D11, NULL);
  708. gpio_request(GPIO_FN_VIO0_D10, NULL);
  709. gpio_request(GPIO_FN_VIO0_D9, NULL);
  710. gpio_request(GPIO_FN_VIO0_D8, NULL);
  711. gpio_request(GPIO_FN_VIO0_D7, NULL);
  712. gpio_request(GPIO_FN_VIO0_D6, NULL);
  713. gpio_request(GPIO_FN_VIO0_D5, NULL);
  714. gpio_request(GPIO_FN_VIO0_D4, NULL);
  715. gpio_request(GPIO_FN_VIO0_D3, NULL);
  716. gpio_request(GPIO_FN_VIO0_D2, NULL);
  717. gpio_request(GPIO_FN_VIO0_D1, NULL);
  718. gpio_request(GPIO_FN_VIO0_D0, NULL);
  719. gpio_request(GPIO_FN_VIO0_VD, NULL);
  720. gpio_request(GPIO_FN_VIO0_CLK, NULL);
  721. gpio_request(GPIO_FN_VIO0_FLD, NULL);
  722. gpio_request(GPIO_FN_VIO0_HD, NULL);
  723. platform_resource_setup_memory(&ceu0_device, "ceu0", 4 << 20);
  724. /* enable CEU1 */
  725. gpio_request(GPIO_FN_VIO1_D7, NULL);
  726. gpio_request(GPIO_FN_VIO1_D6, NULL);
  727. gpio_request(GPIO_FN_VIO1_D5, NULL);
  728. gpio_request(GPIO_FN_VIO1_D4, NULL);
  729. gpio_request(GPIO_FN_VIO1_D3, NULL);
  730. gpio_request(GPIO_FN_VIO1_D2, NULL);
  731. gpio_request(GPIO_FN_VIO1_D1, NULL);
  732. gpio_request(GPIO_FN_VIO1_D0, NULL);
  733. gpio_request(GPIO_FN_VIO1_FLD, NULL);
  734. gpio_request(GPIO_FN_VIO1_HD, NULL);
  735. gpio_request(GPIO_FN_VIO1_VD, NULL);
  736. gpio_request(GPIO_FN_VIO1_CLK, NULL);
  737. platform_resource_setup_memory(&ceu1_device, "ceu1", 4 << 20);
  738. /* KEYSC */
  739. gpio_request(GPIO_FN_KEYOUT5_IN5, NULL);
  740. gpio_request(GPIO_FN_KEYOUT4_IN6, NULL);
  741. gpio_request(GPIO_FN_KEYIN4, NULL);
  742. gpio_request(GPIO_FN_KEYIN3, NULL);
  743. gpio_request(GPIO_FN_KEYIN2, NULL);
  744. gpio_request(GPIO_FN_KEYIN1, NULL);
  745. gpio_request(GPIO_FN_KEYIN0, NULL);
  746. gpio_request(GPIO_FN_KEYOUT3, NULL);
  747. gpio_request(GPIO_FN_KEYOUT2, NULL);
  748. gpio_request(GPIO_FN_KEYOUT1, NULL);
  749. gpio_request(GPIO_FN_KEYOUT0, NULL);
  750. /* enable FSI */
  751. gpio_request(GPIO_FN_FSIMCKA, NULL);
  752. gpio_request(GPIO_FN_FSIIASD, NULL);
  753. gpio_request(GPIO_FN_FSIOASD, NULL);
  754. gpio_request(GPIO_FN_FSIIABCK, NULL);
  755. gpio_request(GPIO_FN_FSIIALRCK, NULL);
  756. gpio_request(GPIO_FN_FSIOABCK, NULL);
  757. gpio_request(GPIO_FN_FSIOALRCK, NULL);
  758. gpio_request(GPIO_FN_CLKAUDIOAO, NULL);
  759. /* set SPU2 clock to 83.4 MHz */
  760. clk = clk_get(NULL, "spu_clk");
  761. if (!IS_ERR(clk)) {
  762. clk_set_rate(clk, clk_round_rate(clk, 83333333));
  763. clk_put(clk);
  764. }
  765. /* change parent of FSI A */
  766. clk = clk_get(NULL, "fsia_clk");
  767. if (!IS_ERR(clk)) {
  768. /* 48kHz dummy clock was used to make sure 1/1 divide */
  769. clk_set_rate(&sh7724_fsimcka_clk, 48000);
  770. clk_set_parent(clk, &sh7724_fsimcka_clk);
  771. clk_set_rate(clk, 48000);
  772. clk_put(clk);
  773. }
  774. /* SDHI0 connected to cn7 */
  775. gpio_request(GPIO_FN_SDHI0CD, NULL);
  776. gpio_request(GPIO_FN_SDHI0WP, NULL);
  777. gpio_request(GPIO_FN_SDHI0D3, NULL);
  778. gpio_request(GPIO_FN_SDHI0D2, NULL);
  779. gpio_request(GPIO_FN_SDHI0D1, NULL);
  780. gpio_request(GPIO_FN_SDHI0D0, NULL);
  781. gpio_request(GPIO_FN_SDHI0CMD, NULL);
  782. gpio_request(GPIO_FN_SDHI0CLK, NULL);
  783. /* SDHI1 connected to cn8 */
  784. gpio_request(GPIO_FN_SDHI1CD, NULL);
  785. gpio_request(GPIO_FN_SDHI1WP, NULL);
  786. gpio_request(GPIO_FN_SDHI1D3, NULL);
  787. gpio_request(GPIO_FN_SDHI1D2, NULL);
  788. gpio_request(GPIO_FN_SDHI1D1, NULL);
  789. gpio_request(GPIO_FN_SDHI1D0, NULL);
  790. gpio_request(GPIO_FN_SDHI1CMD, NULL);
  791. gpio_request(GPIO_FN_SDHI1CLK, NULL);
  792. /* enable IrDA */
  793. gpio_request(GPIO_FN_IRDA_OUT, NULL);
  794. gpio_request(GPIO_FN_IRDA_IN, NULL);
  795. /*
  796. * enable SH-Eth
  797. *
  798. * please remove J33 pin from your board !!
  799. *
  800. * ms7724 board should not use GPIO_FN_LNKSTA pin
  801. * So, This time PTX5 is set to input pin
  802. */
  803. gpio_request(GPIO_FN_RMII_RXD0, NULL);
  804. gpio_request(GPIO_FN_RMII_RXD1, NULL);
  805. gpio_request(GPIO_FN_RMII_TXD0, NULL);
  806. gpio_request(GPIO_FN_RMII_TXD1, NULL);
  807. gpio_request(GPIO_FN_RMII_REF_CLK, NULL);
  808. gpio_request(GPIO_FN_RMII_TX_EN, NULL);
  809. gpio_request(GPIO_FN_RMII_RX_ER, NULL);
  810. gpio_request(GPIO_FN_RMII_CRS_DV, NULL);
  811. gpio_request(GPIO_FN_MDIO, NULL);
  812. gpio_request(GPIO_FN_MDC, NULL);
  813. gpio_request(GPIO_PTX5, NULL);
  814. gpio_direction_input(GPIO_PTX5);
  815. sh_eth_init();
  816. if (sw & SW41_B) {
  817. /* 720p */
  818. lcdc_info.ch[0].lcd_cfg = lcdc_720p_modes;
  819. lcdc_info.ch[0].num_cfg = ARRAY_SIZE(lcdc_720p_modes);
  820. } else {
  821. /* VGA */
  822. lcdc_info.ch[0].lcd_cfg = lcdc_vga_modes;
  823. lcdc_info.ch[0].num_cfg = ARRAY_SIZE(lcdc_vga_modes);
  824. }
  825. if (sw & SW41_A) {
  826. /* Digital monitor */
  827. lcdc_info.ch[0].interface_type = RGB18;
  828. lcdc_info.ch[0].flags = 0;
  829. } else {
  830. /* Analog monitor */
  831. lcdc_info.ch[0].interface_type = RGB24;
  832. lcdc_info.ch[0].flags = LCDC_FLAGS_DWPOL;
  833. }
  834. /* VOU */
  835. gpio_request(GPIO_FN_DV_D15, NULL);
  836. gpio_request(GPIO_FN_DV_D14, NULL);
  837. gpio_request(GPIO_FN_DV_D13, NULL);
  838. gpio_request(GPIO_FN_DV_D12, NULL);
  839. gpio_request(GPIO_FN_DV_D11, NULL);
  840. gpio_request(GPIO_FN_DV_D10, NULL);
  841. gpio_request(GPIO_FN_DV_D9, NULL);
  842. gpio_request(GPIO_FN_DV_D8, NULL);
  843. gpio_request(GPIO_FN_DV_CLKI, NULL);
  844. gpio_request(GPIO_FN_DV_CLK, NULL);
  845. gpio_request(GPIO_FN_DV_VSYNC, NULL);
  846. gpio_request(GPIO_FN_DV_HSYNC, NULL);
  847. return platform_add_devices(ms7724se_devices,
  848. ARRAY_SIZE(ms7724se_devices));
  849. }
  850. device_initcall(devices_setup);
  851. static struct sh_machine_vector mv_ms7724se __initmv = {
  852. .mv_name = "ms7724se",
  853. .mv_init_irq = init_se7724_IRQ,
  854. .mv_nr_irqs = SE7724_FPGA_IRQ_BASE + SE7724_FPGA_IRQ_NR,
  855. };