setup.c 24 KB

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