setup.c 24 KB

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