setup.c 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448
  1. /*
  2. * Copyright (C) 2009 Renesas Solutions Corp.
  3. *
  4. * Kuninori Morimoto <morimoto.kuninori@renesas.com>
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file "COPYING" in the main directory of this archive
  8. * for more details.
  9. */
  10. #include <asm/clock.h>
  11. #include <asm/heartbeat.h>
  12. #include <asm/suspend.h>
  13. #include <cpu/sh7724.h>
  14. #include <linux/delay.h>
  15. #include <linux/device.h>
  16. #include <linux/i2c.h>
  17. #include <linux/io.h>
  18. #include <linux/init.h>
  19. #include <linux/input.h>
  20. #include <linux/input/sh_keysc.h>
  21. #include <linux/interrupt.h>
  22. #include <linux/memblock.h>
  23. #include <linux/mfd/tmio.h>
  24. #include <linux/mmc/host.h>
  25. #include <linux/mmc/sh_mmcif.h>
  26. #include <linux/mtd/physmap.h>
  27. #include <linux/gpio.h>
  28. #include <linux/gpio/machine.h>
  29. #include <linux/platform_data/gpio_backlight.h>
  30. #include <linux/platform_data/tsc2007.h>
  31. #include <linux/platform_device.h>
  32. #include <linux/regulator/fixed.h>
  33. #include <linux/regulator/machine.h>
  34. #include <linux/sh_eth.h>
  35. #include <linux/sh_intc.h>
  36. #include <linux/spi/mmc_spi.h>
  37. #include <linux/spi/sh_msiof.h>
  38. #include <linux/spi/spi.h>
  39. #include <linux/usb/r8a66597.h>
  40. #include <linux/usb/renesas_usbhs.h>
  41. #include <linux/videodev2.h>
  42. #include <media/drv-intf/renesas-ceu.h>
  43. #include <media/i2c/mt9t112.h>
  44. #include <media/i2c/tw9910.h>
  45. #include <sound/sh_fsi.h>
  46. #include <sound/simple_card.h>
  47. #include <video/sh_mobile_lcdc.h>
  48. /*
  49. * Address Interface BusWidth
  50. *-----------------------------------------
  51. * 0x0000_0000 uboot 16bit
  52. * 0x0004_0000 Linux romImage 16bit
  53. * 0x0014_0000 MTD for Linux 16bit
  54. * 0x0400_0000 Internal I/O 16/32bit
  55. * 0x0800_0000 DRAM 32bit
  56. * 0x1800_0000 MFI 16bit
  57. */
  58. /* SWITCH
  59. *------------------------------
  60. * DS2[1] = FlashROM write protect ON : write protect
  61. * OFF : No write protect
  62. * DS2[2] = RMII / TS, SCIF ON : RMII
  63. * OFF : TS, SCIF3
  64. * DS2[3] = Camera / Video ON : Camera
  65. * OFF : NTSC/PAL (IN)
  66. * DS2[5] = NTSC_OUT Clock ON : On board OSC
  67. * OFF : SH7724 DV_CLK
  68. * DS2[6-7] = MMC / SD ON-OFF : SD
  69. * OFF-ON : MMC
  70. */
  71. /*
  72. * FSI - DA7210
  73. *
  74. * it needs amixer settings for playing
  75. *
  76. * amixer set 'HeadPhone' 80
  77. * amixer set 'Out Mixer Left DAC Left' on
  78. * amixer set 'Out Mixer Right DAC Right' on
  79. */
  80. #define CEU_BUFFER_MEMORY_SIZE (4 << 20)
  81. static phys_addr_t ceu0_dma_membase;
  82. static phys_addr_t ceu1_dma_membase;
  83. /* Heartbeat */
  84. static unsigned char led_pos[] = { 0, 1, 2, 3 };
  85. static struct heartbeat_data heartbeat_data = {
  86. .nr_bits = 4,
  87. .bit_pos = led_pos,
  88. };
  89. static struct resource heartbeat_resource = {
  90. .start = 0xA405012C, /* PTG */
  91. .end = 0xA405012E - 1,
  92. .flags = IORESOURCE_MEM | IORESOURCE_MEM_8BIT,
  93. };
  94. static struct platform_device heartbeat_device = {
  95. .name = "heartbeat",
  96. .id = -1,
  97. .dev = {
  98. .platform_data = &heartbeat_data,
  99. },
  100. .num_resources = 1,
  101. .resource = &heartbeat_resource,
  102. };
  103. /* MTD */
  104. static struct mtd_partition nor_flash_partitions[] = {
  105. {
  106. .name = "boot loader",
  107. .offset = 0,
  108. .size = (5 * 1024 * 1024),
  109. .mask_flags = MTD_WRITEABLE, /* force read-only */
  110. }, {
  111. .name = "free-area",
  112. .offset = MTDPART_OFS_APPEND,
  113. .size = MTDPART_SIZ_FULL,
  114. },
  115. };
  116. static struct physmap_flash_data nor_flash_data = {
  117. .width = 2,
  118. .parts = nor_flash_partitions,
  119. .nr_parts = ARRAY_SIZE(nor_flash_partitions),
  120. };
  121. static struct resource nor_flash_resources[] = {
  122. [0] = {
  123. .name = "NOR Flash",
  124. .start = 0x00000000,
  125. .end = 0x03ffffff,
  126. .flags = IORESOURCE_MEM,
  127. }
  128. };
  129. static struct platform_device nor_flash_device = {
  130. .name = "physmap-flash",
  131. .resource = nor_flash_resources,
  132. .num_resources = ARRAY_SIZE(nor_flash_resources),
  133. .dev = {
  134. .platform_data = &nor_flash_data,
  135. },
  136. };
  137. /* SH Eth */
  138. #define SH_ETH_ADDR (0xA4600000)
  139. static struct resource sh_eth_resources[] = {
  140. [0] = {
  141. .start = SH_ETH_ADDR,
  142. .end = SH_ETH_ADDR + 0x1FC,
  143. .flags = IORESOURCE_MEM,
  144. },
  145. [1] = {
  146. .start = evt2irq(0xd60),
  147. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  148. },
  149. };
  150. static struct sh_eth_plat_data sh_eth_plat = {
  151. .phy = 0x1f, /* SMSC LAN8700 */
  152. .phy_interface = PHY_INTERFACE_MODE_MII,
  153. .ether_link_active_low = 1
  154. };
  155. static struct platform_device sh_eth_device = {
  156. .name = "sh7724-ether",
  157. .id = 0,
  158. .dev = {
  159. .platform_data = &sh_eth_plat,
  160. },
  161. .num_resources = ARRAY_SIZE(sh_eth_resources),
  162. .resource = sh_eth_resources,
  163. };
  164. /* USB0 host */
  165. static void usb0_port_power(int port, int power)
  166. {
  167. gpio_set_value(GPIO_PTB4, power);
  168. }
  169. static struct r8a66597_platdata usb0_host_data = {
  170. .on_chip = 1,
  171. .port_power = usb0_port_power,
  172. };
  173. static struct resource usb0_host_resources[] = {
  174. [0] = {
  175. .start = 0xa4d80000,
  176. .end = 0xa4d80124 - 1,
  177. .flags = IORESOURCE_MEM,
  178. },
  179. [1] = {
  180. .start = evt2irq(0xa20),
  181. .end = evt2irq(0xa20),
  182. .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
  183. },
  184. };
  185. static struct platform_device usb0_host_device = {
  186. .name = "r8a66597_hcd",
  187. .id = 0,
  188. .dev = {
  189. .dma_mask = NULL, /* not use dma */
  190. .coherent_dma_mask = 0xffffffff,
  191. .platform_data = &usb0_host_data,
  192. },
  193. .num_resources = ARRAY_SIZE(usb0_host_resources),
  194. .resource = usb0_host_resources,
  195. };
  196. /* USB1 host/function */
  197. static void usb1_port_power(int port, int power)
  198. {
  199. gpio_set_value(GPIO_PTB5, power);
  200. }
  201. static struct r8a66597_platdata usb1_common_data = {
  202. .on_chip = 1,
  203. .port_power = usb1_port_power,
  204. };
  205. static struct resource usb1_common_resources[] = {
  206. [0] = {
  207. .start = 0xa4d90000,
  208. .end = 0xa4d90124 - 1,
  209. .flags = IORESOURCE_MEM,
  210. },
  211. [1] = {
  212. .start = evt2irq(0xa40),
  213. .end = evt2irq(0xa40),
  214. .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
  215. },
  216. };
  217. static struct platform_device usb1_common_device = {
  218. /* .name will be added in arch_setup */
  219. .id = 1,
  220. .dev = {
  221. .dma_mask = NULL, /* not use dma */
  222. .coherent_dma_mask = 0xffffffff,
  223. .platform_data = &usb1_common_data,
  224. },
  225. .num_resources = ARRAY_SIZE(usb1_common_resources),
  226. .resource = usb1_common_resources,
  227. };
  228. /*
  229. * USBHS
  230. */
  231. static int usbhs_get_id(struct platform_device *pdev)
  232. {
  233. return gpio_get_value(GPIO_PTB3);
  234. }
  235. static int usbhs_phy_reset(struct platform_device *pdev)
  236. {
  237. /* enable vbus if HOST */
  238. if (!gpio_get_value(GPIO_PTB3))
  239. gpio_set_value(GPIO_PTB5, 1);
  240. return 0;
  241. }
  242. static struct renesas_usbhs_platform_info usbhs_info = {
  243. .platform_callback = {
  244. .get_id = usbhs_get_id,
  245. .phy_reset = usbhs_phy_reset,
  246. },
  247. .driver_param = {
  248. .buswait_bwait = 4,
  249. .detection_delay = 5,
  250. .d0_tx_id = SHDMA_SLAVE_USB1D0_TX,
  251. .d0_rx_id = SHDMA_SLAVE_USB1D0_RX,
  252. .d1_tx_id = SHDMA_SLAVE_USB1D1_TX,
  253. .d1_rx_id = SHDMA_SLAVE_USB1D1_RX,
  254. },
  255. };
  256. static struct resource usbhs_resources[] = {
  257. [0] = {
  258. .start = 0xa4d90000,
  259. .end = 0xa4d90124 - 1,
  260. .flags = IORESOURCE_MEM,
  261. },
  262. [1] = {
  263. .start = evt2irq(0xa40),
  264. .end = evt2irq(0xa40),
  265. .flags = IORESOURCE_IRQ,
  266. },
  267. };
  268. static struct platform_device usbhs_device = {
  269. .name = "renesas_usbhs",
  270. .id = 1,
  271. .dev = {
  272. .dma_mask = NULL, /* not use dma */
  273. .coherent_dma_mask = 0xffffffff,
  274. .platform_data = &usbhs_info,
  275. },
  276. .num_resources = ARRAY_SIZE(usbhs_resources),
  277. .resource = usbhs_resources,
  278. };
  279. /* LCDC and backlight */
  280. static const struct fb_videomode ecovec_lcd_modes[] = {
  281. {
  282. .name = "Panel",
  283. .xres = 800,
  284. .yres = 480,
  285. .left_margin = 220,
  286. .right_margin = 110,
  287. .hsync_len = 70,
  288. .upper_margin = 20,
  289. .lower_margin = 5,
  290. .vsync_len = 5,
  291. .sync = 0, /* hsync and vsync are active low */
  292. },
  293. };
  294. static const struct fb_videomode ecovec_dvi_modes[] = {
  295. {
  296. .name = "DVI",
  297. .xres = 1280,
  298. .yres = 720,
  299. .left_margin = 220,
  300. .right_margin = 110,
  301. .hsync_len = 40,
  302. .upper_margin = 20,
  303. .lower_margin = 5,
  304. .vsync_len = 5,
  305. .sync = 0, /* hsync and vsync are active low */
  306. },
  307. };
  308. static struct sh_mobile_lcdc_info lcdc_info = {
  309. .ch[0] = {
  310. .interface_type = RGB18,
  311. .chan = LCDC_CHAN_MAINLCD,
  312. .fourcc = V4L2_PIX_FMT_RGB565,
  313. .panel_cfg = { /* 7.0 inch */
  314. .width = 152,
  315. .height = 91,
  316. },
  317. }
  318. };
  319. static struct resource lcdc_resources[] = {
  320. [0] = {
  321. .name = "LCDC",
  322. .start = 0xfe940000,
  323. .end = 0xfe942fff,
  324. .flags = IORESOURCE_MEM,
  325. },
  326. [1] = {
  327. .start = evt2irq(0xf40),
  328. .flags = IORESOURCE_IRQ,
  329. },
  330. };
  331. static struct platform_device lcdc_device = {
  332. .name = "sh_mobile_lcdc_fb",
  333. .num_resources = ARRAY_SIZE(lcdc_resources),
  334. .resource = lcdc_resources,
  335. .dev = {
  336. .platform_data = &lcdc_info,
  337. },
  338. };
  339. static struct gpio_backlight_platform_data gpio_backlight_data = {
  340. .fbdev = &lcdc_device.dev,
  341. .gpio = GPIO_PTR1,
  342. .def_value = 1,
  343. .name = "backlight",
  344. };
  345. static struct platform_device gpio_backlight_device = {
  346. .name = "gpio-backlight",
  347. .dev = {
  348. .platform_data = &gpio_backlight_data,
  349. },
  350. };
  351. /* CEU0 */
  352. static struct ceu_platform_data ceu0_pdata = {
  353. .num_subdevs = 2,
  354. .subdevs = {
  355. { /* [0] = mt9t112 */
  356. .flags = 0,
  357. .bus_width = 8,
  358. .bus_shift = 0,
  359. .i2c_adapter_id = 0,
  360. .i2c_address = 0x3c,
  361. },
  362. { /* [1] = tw9910 */
  363. .flags = 0,
  364. .bus_width = 8,
  365. .bus_shift = 0,
  366. .i2c_adapter_id = 0,
  367. .i2c_address = 0x45,
  368. },
  369. },
  370. };
  371. static struct resource ceu0_resources[] = {
  372. [0] = {
  373. .name = "CEU0",
  374. .start = 0xfe910000,
  375. .end = 0xfe91009f,
  376. .flags = IORESOURCE_MEM,
  377. },
  378. [1] = {
  379. .start = evt2irq(0x880),
  380. .flags = IORESOURCE_IRQ,
  381. },
  382. };
  383. static struct platform_device ceu0_device = {
  384. .name = "renesas-ceu",
  385. .id = 0, /* ceu.0 */
  386. .num_resources = ARRAY_SIZE(ceu0_resources),
  387. .resource = ceu0_resources,
  388. .dev = {
  389. .platform_data = &ceu0_pdata,
  390. },
  391. };
  392. /* CEU1 */
  393. static struct ceu_platform_data ceu1_pdata = {
  394. .num_subdevs = 1,
  395. .subdevs = {
  396. { /* [0] = mt9t112 */
  397. .flags = 0,
  398. .bus_width = 8,
  399. .bus_shift = 0,
  400. .i2c_adapter_id = 1,
  401. .i2c_address = 0x3c,
  402. },
  403. },
  404. };
  405. static struct resource ceu1_resources[] = {
  406. [0] = {
  407. .name = "CEU1",
  408. .start = 0xfe914000,
  409. .end = 0xfe91409f,
  410. .flags = IORESOURCE_MEM,
  411. },
  412. [1] = {
  413. .start = evt2irq(0x9e0),
  414. .flags = IORESOURCE_IRQ,
  415. },
  416. };
  417. static struct platform_device ceu1_device = {
  418. .name = "renesas-ceu",
  419. .id = 1, /* ceu.1 */
  420. .num_resources = ARRAY_SIZE(ceu1_resources),
  421. .resource = ceu1_resources,
  422. .dev = {
  423. .platform_data = &ceu1_pdata,
  424. },
  425. };
  426. /* Power up/down GPIOs for camera devices and video decoder */
  427. static struct gpiod_lookup_table tw9910_gpios = {
  428. .dev_id = "0-0045",
  429. .table = {
  430. GPIO_LOOKUP("sh7724_pfc", GPIO_PTU2, "pdn", GPIO_ACTIVE_HIGH),
  431. },
  432. };
  433. static struct gpiod_lookup_table mt9t112_0_gpios = {
  434. .dev_id = "0-003c",
  435. .table = {
  436. GPIO_LOOKUP("sh7724_pfc", GPIO_PTA3, "standby",
  437. GPIO_ACTIVE_HIGH),
  438. },
  439. };
  440. static struct gpiod_lookup_table mt9t112_1_gpios = {
  441. .dev_id = "1-003c",
  442. .table = {
  443. GPIO_LOOKUP("sh7724_pfc", GPIO_PTA4, "standby",
  444. GPIO_ACTIVE_HIGH),
  445. },
  446. };
  447. /* I2C device */
  448. static struct tw9910_video_info tw9910_info = {
  449. .buswidth = 8,
  450. .mpout = TW9910_MPO_FIELD,
  451. };
  452. static struct mt9t112_platform_data mt9t112_0_pdata = {
  453. .flags = MT9T112_FLAG_PCLK_RISING_EDGE,
  454. .divider = { 0x49, 0x6, 0, 6, 0, 9, 9, 6, 0 }, /* for 24MHz */
  455. };
  456. static struct mt9t112_platform_data mt9t112_1_pdata = {
  457. .flags = MT9T112_FLAG_PCLK_RISING_EDGE,
  458. .divider = { 0x49, 0x6, 0, 6, 0, 9, 9, 6, 0 }, /* for 24MHz */
  459. };
  460. static struct i2c_board_info i2c0_devices[] = {
  461. {
  462. I2C_BOARD_INFO("da7210", 0x1a),
  463. },
  464. {
  465. I2C_BOARD_INFO("tw9910", 0x45),
  466. .platform_data = &tw9910_info,
  467. },
  468. {
  469. /* 1st camera */
  470. I2C_BOARD_INFO("mt9t112", 0x3c),
  471. .platform_data = &mt9t112_0_pdata,
  472. },
  473. };
  474. static struct i2c_board_info i2c1_devices[] = {
  475. {
  476. I2C_BOARD_INFO("r2025sd", 0x32),
  477. },
  478. {
  479. I2C_BOARD_INFO("lis3lv02d", 0x1c),
  480. .irq = evt2irq(0x620),
  481. },
  482. {
  483. /* 2nd camera */
  484. I2C_BOARD_INFO("mt9t112", 0x3c),
  485. .platform_data = &mt9t112_1_pdata,
  486. },
  487. };
  488. /* KEYSC */
  489. static struct sh_keysc_info keysc_info = {
  490. .mode = SH_KEYSC_MODE_1,
  491. .scan_timing = 3,
  492. .delay = 50,
  493. .kycr2_delay = 100,
  494. .keycodes = { KEY_1, 0, 0, 0, 0,
  495. KEY_2, 0, 0, 0, 0,
  496. KEY_3, 0, 0, 0, 0,
  497. KEY_4, 0, 0, 0, 0,
  498. KEY_5, 0, 0, 0, 0,
  499. KEY_6, 0, 0, 0, 0, },
  500. };
  501. static struct resource keysc_resources[] = {
  502. [0] = {
  503. .name = "KEYSC",
  504. .start = 0x044b0000,
  505. .end = 0x044b000f,
  506. .flags = IORESOURCE_MEM,
  507. },
  508. [1] = {
  509. .start = evt2irq(0xbe0),
  510. .flags = IORESOURCE_IRQ,
  511. },
  512. };
  513. static struct platform_device keysc_device = {
  514. .name = "sh_keysc",
  515. .id = 0, /* keysc0 clock */
  516. .num_resources = ARRAY_SIZE(keysc_resources),
  517. .resource = keysc_resources,
  518. .dev = {
  519. .platform_data = &keysc_info,
  520. },
  521. };
  522. /* TouchScreen */
  523. #define IRQ0 evt2irq(0x600)
  524. static int ts_get_pendown_state(struct device *dev)
  525. {
  526. int val = 0;
  527. gpio_free(GPIO_FN_INTC_IRQ0);
  528. gpio_request(GPIO_PTZ0, NULL);
  529. gpio_direction_input(GPIO_PTZ0);
  530. val = gpio_get_value(GPIO_PTZ0);
  531. gpio_free(GPIO_PTZ0);
  532. gpio_request(GPIO_FN_INTC_IRQ0, NULL);
  533. return val ? 0 : 1;
  534. }
  535. static int ts_init(void)
  536. {
  537. gpio_request(GPIO_FN_INTC_IRQ0, NULL);
  538. return 0;
  539. }
  540. static struct tsc2007_platform_data tsc2007_info = {
  541. .model = 2007,
  542. .x_plate_ohms = 180,
  543. .get_pendown_state = ts_get_pendown_state,
  544. .init_platform_hw = ts_init,
  545. };
  546. static struct i2c_board_info ts_i2c_clients = {
  547. I2C_BOARD_INFO("tsc2007", 0x48),
  548. .type = "tsc2007",
  549. .platform_data = &tsc2007_info,
  550. .irq = IRQ0,
  551. };
  552. static struct regulator_consumer_supply cn12_power_consumers[] =
  553. {
  554. REGULATOR_SUPPLY("vmmc", "sh_mmcif.0"),
  555. REGULATOR_SUPPLY("vqmmc", "sh_mmcif.0"),
  556. REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.1"),
  557. REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.1"),
  558. };
  559. static struct regulator_init_data cn12_power_init_data = {
  560. .constraints = {
  561. .valid_ops_mask = REGULATOR_CHANGE_STATUS,
  562. },
  563. .num_consumer_supplies = ARRAY_SIZE(cn12_power_consumers),
  564. .consumer_supplies = cn12_power_consumers,
  565. };
  566. static struct fixed_voltage_config cn12_power_info = {
  567. .supply_name = "CN12 SD/MMC Vdd",
  568. .microvolts = 3300000,
  569. .gpio = GPIO_PTB7,
  570. .enable_high = 1,
  571. .init_data = &cn12_power_init_data,
  572. };
  573. static struct platform_device cn12_power = {
  574. .name = "reg-fixed-voltage",
  575. .id = 0,
  576. .dev = {
  577. .platform_data = &cn12_power_info,
  578. },
  579. };
  580. #if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)
  581. /* SDHI0 */
  582. static struct regulator_consumer_supply sdhi0_power_consumers[] =
  583. {
  584. REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
  585. REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
  586. };
  587. static struct regulator_init_data sdhi0_power_init_data = {
  588. .constraints = {
  589. .valid_ops_mask = REGULATOR_CHANGE_STATUS,
  590. },
  591. .num_consumer_supplies = ARRAY_SIZE(sdhi0_power_consumers),
  592. .consumer_supplies = sdhi0_power_consumers,
  593. };
  594. static struct fixed_voltage_config sdhi0_power_info = {
  595. .supply_name = "CN11 SD/MMC Vdd",
  596. .microvolts = 3300000,
  597. .gpio = GPIO_PTB6,
  598. .enable_high = 1,
  599. .init_data = &sdhi0_power_init_data,
  600. };
  601. static struct platform_device sdhi0_power = {
  602. .name = "reg-fixed-voltage",
  603. .id = 1,
  604. .dev = {
  605. .platform_data = &sdhi0_power_info,
  606. },
  607. };
  608. static struct tmio_mmc_data sdhi0_info = {
  609. .chan_priv_tx = (void *)SHDMA_SLAVE_SDHI0_TX,
  610. .chan_priv_rx = (void *)SHDMA_SLAVE_SDHI0_RX,
  611. .capabilities = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD |
  612. MMC_CAP_NEEDS_POLL,
  613. .flags = TMIO_MMC_USE_GPIO_CD,
  614. .cd_gpio = GPIO_PTY7,
  615. };
  616. static struct resource sdhi0_resources[] = {
  617. [0] = {
  618. .name = "SDHI0",
  619. .start = 0x04ce0000,
  620. .end = 0x04ce00ff,
  621. .flags = IORESOURCE_MEM,
  622. },
  623. [1] = {
  624. .start = evt2irq(0xe80),
  625. .flags = IORESOURCE_IRQ,
  626. },
  627. };
  628. static struct platform_device sdhi0_device = {
  629. .name = "sh_mobile_sdhi",
  630. .num_resources = ARRAY_SIZE(sdhi0_resources),
  631. .resource = sdhi0_resources,
  632. .id = 0,
  633. .dev = {
  634. .platform_data = &sdhi0_info,
  635. },
  636. };
  637. #if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
  638. /* SDHI1 */
  639. static struct tmio_mmc_data sdhi1_info = {
  640. .chan_priv_tx = (void *)SHDMA_SLAVE_SDHI1_TX,
  641. .chan_priv_rx = (void *)SHDMA_SLAVE_SDHI1_RX,
  642. .capabilities = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD |
  643. MMC_CAP_NEEDS_POLL,
  644. .flags = TMIO_MMC_USE_GPIO_CD,
  645. .cd_gpio = GPIO_PTW7,
  646. };
  647. static struct resource sdhi1_resources[] = {
  648. [0] = {
  649. .name = "SDHI1",
  650. .start = 0x04cf0000,
  651. .end = 0x04cf00ff,
  652. .flags = IORESOURCE_MEM,
  653. },
  654. [1] = {
  655. .start = evt2irq(0x4e0),
  656. .flags = IORESOURCE_IRQ,
  657. },
  658. };
  659. static struct platform_device sdhi1_device = {
  660. .name = "sh_mobile_sdhi",
  661. .num_resources = ARRAY_SIZE(sdhi1_resources),
  662. .resource = sdhi1_resources,
  663. .id = 1,
  664. .dev = {
  665. .platform_data = &sdhi1_info,
  666. },
  667. };
  668. #endif /* CONFIG_MMC_SH_MMCIF */
  669. #else
  670. /* MMC SPI */
  671. static void mmc_spi_setpower(struct device *dev, unsigned int maskval)
  672. {
  673. gpio_set_value(GPIO_PTB6, maskval ? 1 : 0);
  674. }
  675. static struct mmc_spi_platform_data mmc_spi_info = {
  676. .caps = MMC_CAP_NEEDS_POLL,
  677. .caps2 = MMC_CAP2_RO_ACTIVE_HIGH,
  678. .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, /* 3.3V only */
  679. .setpower = mmc_spi_setpower,
  680. .flags = MMC_SPI_USE_CD_GPIO | MMC_SPI_USE_RO_GPIO,
  681. .cd_gpio = GPIO_PTY7,
  682. .ro_gpio = GPIO_PTY6,
  683. };
  684. static struct spi_board_info spi_bus[] = {
  685. {
  686. .modalias = "mmc_spi",
  687. .platform_data = &mmc_spi_info,
  688. .max_speed_hz = 5000000,
  689. .mode = SPI_MODE_0,
  690. .controller_data = (void *) GPIO_PTM4,
  691. },
  692. };
  693. /* MSIOF0 */
  694. static struct sh_msiof_spi_info msiof0_data = {
  695. .num_chipselect = 1,
  696. };
  697. static struct resource msiof0_resources[] = {
  698. [0] = {
  699. .name = "MSIOF0",
  700. .start = 0xa4c40000,
  701. .end = 0xa4c40063,
  702. .flags = IORESOURCE_MEM,
  703. },
  704. [1] = {
  705. .start = evt2irq(0xc80),
  706. .flags = IORESOURCE_IRQ,
  707. },
  708. };
  709. static struct platform_device msiof0_device = {
  710. .name = "spi_sh_msiof",
  711. .id = 0, /* MSIOF0 */
  712. .dev = {
  713. .platform_data = &msiof0_data,
  714. },
  715. .num_resources = ARRAY_SIZE(msiof0_resources),
  716. .resource = msiof0_resources,
  717. };
  718. #endif
  719. /* FSI */
  720. static struct resource fsi_resources[] = {
  721. [0] = {
  722. .name = "FSI",
  723. .start = 0xFE3C0000,
  724. .end = 0xFE3C021d,
  725. .flags = IORESOURCE_MEM,
  726. },
  727. [1] = {
  728. .start = evt2irq(0xf80),
  729. .flags = IORESOURCE_IRQ,
  730. },
  731. };
  732. static struct platform_device fsi_device = {
  733. .name = "sh_fsi",
  734. .id = 0,
  735. .num_resources = ARRAY_SIZE(fsi_resources),
  736. .resource = fsi_resources,
  737. };
  738. static struct asoc_simple_card_info fsi_da7210_info = {
  739. .name = "DA7210",
  740. .card = "FSIB-DA7210",
  741. .codec = "da7210.0-001a",
  742. .platform = "sh_fsi.0",
  743. .daifmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM,
  744. .cpu_dai = {
  745. .name = "fsib-dai",
  746. },
  747. .codec_dai = {
  748. .name = "da7210-hifi",
  749. },
  750. };
  751. static struct platform_device fsi_da7210_device = {
  752. .name = "asoc-simple-card",
  753. .dev = {
  754. .platform_data = &fsi_da7210_info,
  755. .coherent_dma_mask = DMA_BIT_MASK(32),
  756. .dma_mask = &fsi_da7210_device.dev.coherent_dma_mask,
  757. },
  758. };
  759. /* IrDA */
  760. static struct resource irda_resources[] = {
  761. [0] = {
  762. .name = "IrDA",
  763. .start = 0xA45D0000,
  764. .end = 0xA45D0049,
  765. .flags = IORESOURCE_MEM,
  766. },
  767. [1] = {
  768. .start = evt2irq(0x480),
  769. .flags = IORESOURCE_IRQ,
  770. },
  771. };
  772. static struct platform_device irda_device = {
  773. .name = "sh_sir",
  774. .num_resources = ARRAY_SIZE(irda_resources),
  775. .resource = irda_resources,
  776. };
  777. #include <media/i2c/ak881x.h>
  778. #include <media/drv-intf/sh_vou.h>
  779. static struct ak881x_pdata ak881x_pdata = {
  780. .flags = AK881X_IF_MODE_SLAVE,
  781. };
  782. static struct i2c_board_info ak8813 = {
  783. I2C_BOARD_INFO("ak8813", 0x20),
  784. .platform_data = &ak881x_pdata,
  785. };
  786. static struct sh_vou_pdata sh_vou_pdata = {
  787. .bus_fmt = SH_VOU_BUS_8BIT,
  788. .flags = SH_VOU_HSYNC_LOW | SH_VOU_VSYNC_LOW,
  789. .board_info = &ak8813,
  790. .i2c_adap = 0,
  791. };
  792. static struct resource sh_vou_resources[] = {
  793. [0] = {
  794. .start = 0xfe960000,
  795. .end = 0xfe962043,
  796. .flags = IORESOURCE_MEM,
  797. },
  798. [1] = {
  799. .start = evt2irq(0x8e0),
  800. .flags = IORESOURCE_IRQ,
  801. },
  802. };
  803. static struct platform_device vou_device = {
  804. .name = "sh-vou",
  805. .id = -1,
  806. .num_resources = ARRAY_SIZE(sh_vou_resources),
  807. .resource = sh_vou_resources,
  808. .dev = {
  809. .platform_data = &sh_vou_pdata,
  810. },
  811. };
  812. #if defined(CONFIG_MMC_SH_MMCIF) || defined(CONFIG_MMC_SH_MMCIF_MODULE)
  813. /* SH_MMCIF */
  814. static struct resource sh_mmcif_resources[] = {
  815. [0] = {
  816. .name = "SH_MMCIF",
  817. .start = 0xA4CA0000,
  818. .end = 0xA4CA00FF,
  819. .flags = IORESOURCE_MEM,
  820. },
  821. [1] = {
  822. /* MMC2I */
  823. .start = evt2irq(0x5a0),
  824. .flags = IORESOURCE_IRQ,
  825. },
  826. [2] = {
  827. /* MMC3I */
  828. .start = evt2irq(0x5c0),
  829. .flags = IORESOURCE_IRQ,
  830. },
  831. };
  832. static struct sh_mmcif_plat_data sh_mmcif_plat = {
  833. .sup_pclk = 0, /* SH7724: Max Pclk/2 */
  834. .caps = MMC_CAP_4_BIT_DATA |
  835. MMC_CAP_8_BIT_DATA |
  836. MMC_CAP_NEEDS_POLL,
  837. .ocr = MMC_VDD_32_33 | MMC_VDD_33_34,
  838. };
  839. static struct platform_device sh_mmcif_device = {
  840. .name = "sh_mmcif",
  841. .id = 0,
  842. .dev = {
  843. .platform_data = &sh_mmcif_plat,
  844. },
  845. .num_resources = ARRAY_SIZE(sh_mmcif_resources),
  846. .resource = sh_mmcif_resources,
  847. };
  848. #endif
  849. static struct platform_device *ecovec_ceu_devices[] __initdata = {
  850. &ceu0_device,
  851. &ceu1_device,
  852. };
  853. static struct platform_device *ecovec_devices[] __initdata = {
  854. &heartbeat_device,
  855. &nor_flash_device,
  856. &sh_eth_device,
  857. &usb0_host_device,
  858. &usb1_common_device,
  859. &usbhs_device,
  860. &lcdc_device,
  861. &gpio_backlight_device,
  862. &keysc_device,
  863. &cn12_power,
  864. #if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)
  865. &sdhi0_power,
  866. &sdhi0_device,
  867. #if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
  868. &sdhi1_device,
  869. #endif
  870. #else
  871. &msiof0_device,
  872. #endif
  873. &fsi_device,
  874. &fsi_da7210_device,
  875. &irda_device,
  876. &vou_device,
  877. #if defined(CONFIG_MMC_SH_MMCIF) || defined(CONFIG_MMC_SH_MMCIF_MODULE)
  878. &sh_mmcif_device,
  879. #endif
  880. };
  881. #ifdef CONFIG_I2C
  882. #define EEPROM_ADDR 0x50
  883. static u8 mac_read(struct i2c_adapter *a, u8 command)
  884. {
  885. struct i2c_msg msg[2];
  886. u8 buf;
  887. int ret;
  888. msg[0].addr = EEPROM_ADDR;
  889. msg[0].flags = 0;
  890. msg[0].len = 1;
  891. msg[0].buf = &command;
  892. msg[1].addr = EEPROM_ADDR;
  893. msg[1].flags = I2C_M_RD;
  894. msg[1].len = 1;
  895. msg[1].buf = &buf;
  896. ret = i2c_transfer(a, msg, 2);
  897. if (ret < 0) {
  898. printk(KERN_ERR "error %d\n", ret);
  899. buf = 0xff;
  900. }
  901. return buf;
  902. }
  903. static void __init sh_eth_init(struct sh_eth_plat_data *pd)
  904. {
  905. struct i2c_adapter *a = i2c_get_adapter(1);
  906. int i;
  907. if (!a) {
  908. pr_err("can not get I2C 1\n");
  909. return;
  910. }
  911. /* read MAC address from EEPROM */
  912. for (i = 0; i < sizeof(pd->mac_addr); i++) {
  913. pd->mac_addr[i] = mac_read(a, 0x10 + i);
  914. msleep(10);
  915. }
  916. i2c_put_adapter(a);
  917. }
  918. #else
  919. static void __init sh_eth_init(struct sh_eth_plat_data *pd)
  920. {
  921. pr_err("unable to read sh_eth MAC address\n");
  922. }
  923. #endif
  924. #define PORT_HIZA 0xA4050158
  925. #define IODRIVEA 0xA405018A
  926. extern char ecovec24_sdram_enter_start;
  927. extern char ecovec24_sdram_enter_end;
  928. extern char ecovec24_sdram_leave_start;
  929. extern char ecovec24_sdram_leave_end;
  930. static int __init arch_setup(void)
  931. {
  932. struct clk *clk;
  933. bool cn12_enabled = false;
  934. /* register board specific self-refresh code */
  935. sh_mobile_register_self_refresh(SUSP_SH_STANDBY | SUSP_SH_SF |
  936. SUSP_SH_RSTANDBY,
  937. &ecovec24_sdram_enter_start,
  938. &ecovec24_sdram_enter_end,
  939. &ecovec24_sdram_leave_start,
  940. &ecovec24_sdram_leave_end);
  941. /* enable STATUS0, STATUS2 and PDSTATUS */
  942. gpio_request(GPIO_FN_STATUS0, NULL);
  943. gpio_request(GPIO_FN_STATUS2, NULL);
  944. gpio_request(GPIO_FN_PDSTATUS, NULL);
  945. /* enable SCIFA0 */
  946. gpio_request(GPIO_FN_SCIF0_TXD, NULL);
  947. gpio_request(GPIO_FN_SCIF0_RXD, NULL);
  948. /* enable debug LED */
  949. gpio_request(GPIO_PTG0, NULL);
  950. gpio_request(GPIO_PTG1, NULL);
  951. gpio_request(GPIO_PTG2, NULL);
  952. gpio_request(GPIO_PTG3, NULL);
  953. gpio_direction_output(GPIO_PTG0, 0);
  954. gpio_direction_output(GPIO_PTG1, 0);
  955. gpio_direction_output(GPIO_PTG2, 0);
  956. gpio_direction_output(GPIO_PTG3, 0);
  957. __raw_writew((__raw_readw(PORT_HIZA) & ~(0x1 << 1)) , PORT_HIZA);
  958. /* enable SH-Eth */
  959. gpio_request(GPIO_PTA1, NULL);
  960. gpio_direction_output(GPIO_PTA1, 1);
  961. mdelay(20);
  962. gpio_request(GPIO_FN_RMII_RXD0, NULL);
  963. gpio_request(GPIO_FN_RMII_RXD1, NULL);
  964. gpio_request(GPIO_FN_RMII_TXD0, NULL);
  965. gpio_request(GPIO_FN_RMII_TXD1, NULL);
  966. gpio_request(GPIO_FN_RMII_REF_CLK, NULL);
  967. gpio_request(GPIO_FN_RMII_TX_EN, NULL);
  968. gpio_request(GPIO_FN_RMII_RX_ER, NULL);
  969. gpio_request(GPIO_FN_RMII_CRS_DV, NULL);
  970. gpio_request(GPIO_FN_MDIO, NULL);
  971. gpio_request(GPIO_FN_MDC, NULL);
  972. gpio_request(GPIO_FN_LNKSTA, NULL);
  973. /* enable USB */
  974. __raw_writew(0x0000, 0xA4D80000);
  975. __raw_writew(0x0000, 0xA4D90000);
  976. gpio_request(GPIO_PTB3, NULL);
  977. gpio_request(GPIO_PTB4, NULL);
  978. gpio_request(GPIO_PTB5, NULL);
  979. gpio_direction_input(GPIO_PTB3);
  980. gpio_direction_output(GPIO_PTB4, 0);
  981. gpio_direction_output(GPIO_PTB5, 0);
  982. __raw_writew(0x0600, 0xa40501d4);
  983. __raw_writew(0x0600, 0xa4050192);
  984. if (gpio_get_value(GPIO_PTB3)) {
  985. printk(KERN_INFO "USB1 function is selected\n");
  986. usb1_common_device.name = "r8a66597_udc";
  987. } else {
  988. printk(KERN_INFO "USB1 host is selected\n");
  989. usb1_common_device.name = "r8a66597_hcd";
  990. }
  991. /* enable LCDC */
  992. gpio_request(GPIO_FN_LCDD23, NULL);
  993. gpio_request(GPIO_FN_LCDD22, NULL);
  994. gpio_request(GPIO_FN_LCDD21, NULL);
  995. gpio_request(GPIO_FN_LCDD20, NULL);
  996. gpio_request(GPIO_FN_LCDD19, NULL);
  997. gpio_request(GPIO_FN_LCDD18, NULL);
  998. gpio_request(GPIO_FN_LCDD17, NULL);
  999. gpio_request(GPIO_FN_LCDD16, NULL);
  1000. gpio_request(GPIO_FN_LCDD15, NULL);
  1001. gpio_request(GPIO_FN_LCDD14, NULL);
  1002. gpio_request(GPIO_FN_LCDD13, NULL);
  1003. gpio_request(GPIO_FN_LCDD12, NULL);
  1004. gpio_request(GPIO_FN_LCDD11, NULL);
  1005. gpio_request(GPIO_FN_LCDD10, NULL);
  1006. gpio_request(GPIO_FN_LCDD9, NULL);
  1007. gpio_request(GPIO_FN_LCDD8, NULL);
  1008. gpio_request(GPIO_FN_LCDD7, NULL);
  1009. gpio_request(GPIO_FN_LCDD6, NULL);
  1010. gpio_request(GPIO_FN_LCDD5, NULL);
  1011. gpio_request(GPIO_FN_LCDD4, NULL);
  1012. gpio_request(GPIO_FN_LCDD3, NULL);
  1013. gpio_request(GPIO_FN_LCDD2, NULL);
  1014. gpio_request(GPIO_FN_LCDD1, NULL);
  1015. gpio_request(GPIO_FN_LCDD0, NULL);
  1016. gpio_request(GPIO_FN_LCDDISP, NULL);
  1017. gpio_request(GPIO_FN_LCDHSYN, NULL);
  1018. gpio_request(GPIO_FN_LCDDCK, NULL);
  1019. gpio_request(GPIO_FN_LCDVSYN, NULL);
  1020. gpio_request(GPIO_FN_LCDDON, NULL);
  1021. gpio_request(GPIO_FN_LCDLCLK, NULL);
  1022. __raw_writew((__raw_readw(PORT_HIZA) & ~0x0001), PORT_HIZA);
  1023. gpio_request(GPIO_PTE6, NULL);
  1024. gpio_request(GPIO_PTU1, NULL);
  1025. gpio_request(GPIO_PTA2, NULL);
  1026. gpio_direction_input(GPIO_PTE6);
  1027. gpio_direction_output(GPIO_PTU1, 0);
  1028. gpio_direction_output(GPIO_PTA2, 0);
  1029. /* I/O buffer drive ability is high */
  1030. __raw_writew((__raw_readw(IODRIVEA) & ~0x00c0) | 0x0080 , IODRIVEA);
  1031. if (gpio_get_value(GPIO_PTE6)) {
  1032. /* DVI */
  1033. lcdc_info.clock_source = LCDC_CLK_EXTERNAL;
  1034. lcdc_info.ch[0].clock_divider = 1;
  1035. lcdc_info.ch[0].lcd_modes = ecovec_dvi_modes;
  1036. lcdc_info.ch[0].num_modes = ARRAY_SIZE(ecovec_dvi_modes);
  1037. /* No backlight */
  1038. gpio_backlight_data.fbdev = NULL;
  1039. gpio_set_value(GPIO_PTA2, 1);
  1040. gpio_set_value(GPIO_PTU1, 1);
  1041. } else {
  1042. /* Panel */
  1043. lcdc_info.clock_source = LCDC_CLK_PERIPHERAL;
  1044. lcdc_info.ch[0].clock_divider = 2;
  1045. lcdc_info.ch[0].lcd_modes = ecovec_lcd_modes;
  1046. lcdc_info.ch[0].num_modes = ARRAY_SIZE(ecovec_lcd_modes);
  1047. /* FIXME
  1048. *
  1049. * LCDDON control is needed for Panel,
  1050. * but current sh_mobile_lcdc driver doesn't control it.
  1051. * It is temporary correspondence
  1052. */
  1053. gpio_request(GPIO_PTF4, NULL);
  1054. gpio_direction_output(GPIO_PTF4, 1);
  1055. /* enable TouchScreen */
  1056. i2c_register_board_info(0, &ts_i2c_clients, 1);
  1057. irq_set_irq_type(IRQ0, IRQ_TYPE_LEVEL_LOW);
  1058. }
  1059. /* enable CEU0 */
  1060. gpio_request(GPIO_FN_VIO0_D15, NULL);
  1061. gpio_request(GPIO_FN_VIO0_D14, NULL);
  1062. gpio_request(GPIO_FN_VIO0_D13, NULL);
  1063. gpio_request(GPIO_FN_VIO0_D12, NULL);
  1064. gpio_request(GPIO_FN_VIO0_D11, NULL);
  1065. gpio_request(GPIO_FN_VIO0_D10, NULL);
  1066. gpio_request(GPIO_FN_VIO0_D9, NULL);
  1067. gpio_request(GPIO_FN_VIO0_D8, NULL);
  1068. gpio_request(GPIO_FN_VIO0_D7, NULL);
  1069. gpio_request(GPIO_FN_VIO0_D6, NULL);
  1070. gpio_request(GPIO_FN_VIO0_D5, NULL);
  1071. gpio_request(GPIO_FN_VIO0_D4, NULL);
  1072. gpio_request(GPIO_FN_VIO0_D3, NULL);
  1073. gpio_request(GPIO_FN_VIO0_D2, NULL);
  1074. gpio_request(GPIO_FN_VIO0_D1, NULL);
  1075. gpio_request(GPIO_FN_VIO0_D0, NULL);
  1076. gpio_request(GPIO_FN_VIO0_VD, NULL);
  1077. gpio_request(GPIO_FN_VIO0_CLK, NULL);
  1078. gpio_request(GPIO_FN_VIO0_FLD, NULL);
  1079. gpio_request(GPIO_FN_VIO0_HD, NULL);
  1080. /* enable CEU1 */
  1081. gpio_request(GPIO_FN_VIO1_D7, NULL);
  1082. gpio_request(GPIO_FN_VIO1_D6, NULL);
  1083. gpio_request(GPIO_FN_VIO1_D5, NULL);
  1084. gpio_request(GPIO_FN_VIO1_D4, NULL);
  1085. gpio_request(GPIO_FN_VIO1_D3, NULL);
  1086. gpio_request(GPIO_FN_VIO1_D2, NULL);
  1087. gpio_request(GPIO_FN_VIO1_D1, NULL);
  1088. gpio_request(GPIO_FN_VIO1_D0, NULL);
  1089. gpio_request(GPIO_FN_VIO1_FLD, NULL);
  1090. gpio_request(GPIO_FN_VIO1_HD, NULL);
  1091. gpio_request(GPIO_FN_VIO1_VD, NULL);
  1092. gpio_request(GPIO_FN_VIO1_CLK, NULL);
  1093. /* enable KEYSC */
  1094. gpio_request(GPIO_FN_KEYOUT5_IN5, NULL);
  1095. gpio_request(GPIO_FN_KEYOUT4_IN6, NULL);
  1096. gpio_request(GPIO_FN_KEYOUT3, NULL);
  1097. gpio_request(GPIO_FN_KEYOUT2, NULL);
  1098. gpio_request(GPIO_FN_KEYOUT1, NULL);
  1099. gpio_request(GPIO_FN_KEYOUT0, NULL);
  1100. gpio_request(GPIO_FN_KEYIN0, NULL);
  1101. /* enable user debug switch */
  1102. gpio_request(GPIO_PTR0, NULL);
  1103. gpio_request(GPIO_PTR4, NULL);
  1104. gpio_request(GPIO_PTR5, NULL);
  1105. gpio_request(GPIO_PTR6, NULL);
  1106. gpio_direction_input(GPIO_PTR0);
  1107. gpio_direction_input(GPIO_PTR4);
  1108. gpio_direction_input(GPIO_PTR5);
  1109. gpio_direction_input(GPIO_PTR6);
  1110. /* SD-card slot CN11 */
  1111. #if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)
  1112. /* enable SDHI0 on CN11 (needs DS2.4 set to ON) */
  1113. gpio_request(GPIO_FN_SDHI0WP, NULL);
  1114. gpio_request(GPIO_FN_SDHI0CMD, NULL);
  1115. gpio_request(GPIO_FN_SDHI0CLK, NULL);
  1116. gpio_request(GPIO_FN_SDHI0D3, NULL);
  1117. gpio_request(GPIO_FN_SDHI0D2, NULL);
  1118. gpio_request(GPIO_FN_SDHI0D1, NULL);
  1119. gpio_request(GPIO_FN_SDHI0D0, NULL);
  1120. #else
  1121. /* enable MSIOF0 on CN11 (needs DS2.4 set to OFF) */
  1122. gpio_request(GPIO_FN_MSIOF0_TXD, NULL);
  1123. gpio_request(GPIO_FN_MSIOF0_RXD, NULL);
  1124. gpio_request(GPIO_FN_MSIOF0_TSCK, NULL);
  1125. gpio_request(GPIO_PTM4, NULL); /* software CS control of TSYNC pin */
  1126. gpio_direction_output(GPIO_PTM4, 1); /* active low CS */
  1127. gpio_request(GPIO_PTB6, NULL); /* 3.3V power control */
  1128. gpio_direction_output(GPIO_PTB6, 0); /* disable power by default */
  1129. spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus));
  1130. #endif
  1131. /* MMC/SD-card slot CN12 */
  1132. #if defined(CONFIG_MMC_SH_MMCIF) || defined(CONFIG_MMC_SH_MMCIF_MODULE)
  1133. /* enable MMCIF (needs DS2.6,7 set to OFF,ON) */
  1134. gpio_request(GPIO_FN_MMC_D7, NULL);
  1135. gpio_request(GPIO_FN_MMC_D6, NULL);
  1136. gpio_request(GPIO_FN_MMC_D5, NULL);
  1137. gpio_request(GPIO_FN_MMC_D4, NULL);
  1138. gpio_request(GPIO_FN_MMC_D3, NULL);
  1139. gpio_request(GPIO_FN_MMC_D2, NULL);
  1140. gpio_request(GPIO_FN_MMC_D1, NULL);
  1141. gpio_request(GPIO_FN_MMC_D0, NULL);
  1142. gpio_request(GPIO_FN_MMC_CLK, NULL);
  1143. gpio_request(GPIO_FN_MMC_CMD, NULL);
  1144. cn12_enabled = true;
  1145. #elif defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)
  1146. /* enable SDHI1 on CN12 (needs DS2.6,7 set to ON,OFF) */
  1147. gpio_request(GPIO_FN_SDHI1WP, NULL);
  1148. gpio_request(GPIO_FN_SDHI1CMD, NULL);
  1149. gpio_request(GPIO_FN_SDHI1CLK, NULL);
  1150. gpio_request(GPIO_FN_SDHI1D3, NULL);
  1151. gpio_request(GPIO_FN_SDHI1D2, NULL);
  1152. gpio_request(GPIO_FN_SDHI1D1, NULL);
  1153. gpio_request(GPIO_FN_SDHI1D0, NULL);
  1154. cn12_enabled = true;
  1155. #endif
  1156. if (cn12_enabled)
  1157. /* I/O buffer drive ability is high for CN12 */
  1158. __raw_writew((__raw_readw(IODRIVEA) & ~0x3000) | 0x2000,
  1159. IODRIVEA);
  1160. /* enable FSI */
  1161. gpio_request(GPIO_FN_FSIMCKB, NULL);
  1162. gpio_request(GPIO_FN_FSIIBSD, NULL);
  1163. gpio_request(GPIO_FN_FSIOBSD, NULL);
  1164. gpio_request(GPIO_FN_FSIIBBCK, NULL);
  1165. gpio_request(GPIO_FN_FSIIBLRCK, NULL);
  1166. gpio_request(GPIO_FN_FSIOBBCK, NULL);
  1167. gpio_request(GPIO_FN_FSIOBLRCK, NULL);
  1168. gpio_request(GPIO_FN_CLKAUDIOBO, NULL);
  1169. /* set SPU2 clock to 83.4 MHz */
  1170. clk = clk_get(NULL, "spu_clk");
  1171. if (!IS_ERR(clk)) {
  1172. clk_set_rate(clk, clk_round_rate(clk, 83333333));
  1173. clk_put(clk);
  1174. }
  1175. /* change parent of FSI B */
  1176. clk = clk_get(NULL, "fsib_clk");
  1177. if (!IS_ERR(clk)) {
  1178. /* 48kHz dummy clock was used to make sure 1/1 divide */
  1179. clk_set_rate(&sh7724_fsimckb_clk, 48000);
  1180. clk_set_parent(clk, &sh7724_fsimckb_clk);
  1181. clk_set_rate(clk, 48000);
  1182. clk_put(clk);
  1183. }
  1184. gpio_request(GPIO_PTU0, NULL);
  1185. gpio_direction_output(GPIO_PTU0, 0);
  1186. mdelay(20);
  1187. /* enable motion sensor */
  1188. gpio_request(GPIO_FN_INTC_IRQ1, NULL);
  1189. gpio_direction_input(GPIO_FN_INTC_IRQ1);
  1190. /* set VPU clock to 166 MHz */
  1191. clk = clk_get(NULL, "vpu_clk");
  1192. if (!IS_ERR(clk)) {
  1193. clk_set_rate(clk, clk_round_rate(clk, 166000000));
  1194. clk_put(clk);
  1195. }
  1196. /* enable IrDA */
  1197. gpio_request(GPIO_FN_IRDA_OUT, NULL);
  1198. gpio_request(GPIO_FN_IRDA_IN, NULL);
  1199. gpio_request(GPIO_PTU5, NULL);
  1200. gpio_direction_output(GPIO_PTU5, 0);
  1201. /* Register gpio lookup tables for cameras and video decoder */
  1202. gpiod_add_lookup_table(&tw9910_gpios);
  1203. gpiod_add_lookup_table(&mt9t112_0_gpios);
  1204. gpiod_add_lookup_table(&mt9t112_1_gpios);
  1205. /* enable I2C device */
  1206. i2c_register_board_info(0, i2c0_devices,
  1207. ARRAY_SIZE(i2c0_devices));
  1208. i2c_register_board_info(1, i2c1_devices,
  1209. ARRAY_SIZE(i2c1_devices));
  1210. #if defined(CONFIG_VIDEO_SH_VOU) || defined(CONFIG_VIDEO_SH_VOU_MODULE)
  1211. /* VOU */
  1212. gpio_request(GPIO_FN_DV_D15, NULL);
  1213. gpio_request(GPIO_FN_DV_D14, NULL);
  1214. gpio_request(GPIO_FN_DV_D13, NULL);
  1215. gpio_request(GPIO_FN_DV_D12, NULL);
  1216. gpio_request(GPIO_FN_DV_D11, NULL);
  1217. gpio_request(GPIO_FN_DV_D10, NULL);
  1218. gpio_request(GPIO_FN_DV_D9, NULL);
  1219. gpio_request(GPIO_FN_DV_D8, NULL);
  1220. gpio_request(GPIO_FN_DV_CLKI, NULL);
  1221. gpio_request(GPIO_FN_DV_CLK, NULL);
  1222. gpio_request(GPIO_FN_DV_VSYNC, NULL);
  1223. gpio_request(GPIO_FN_DV_HSYNC, NULL);
  1224. /* AK8813 power / reset sequence */
  1225. gpio_request(GPIO_PTG4, NULL);
  1226. gpio_request(GPIO_PTU3, NULL);
  1227. /* Reset */
  1228. gpio_direction_output(GPIO_PTG4, 0);
  1229. /* Power down */
  1230. gpio_direction_output(GPIO_PTU3, 1);
  1231. udelay(10);
  1232. /* Power up, reset */
  1233. gpio_set_value(GPIO_PTU3, 0);
  1234. udelay(10);
  1235. /* Remove reset */
  1236. gpio_set_value(GPIO_PTG4, 1);
  1237. #endif
  1238. /* Initialize CEU platform devices separately to map memory first */
  1239. device_initialize(&ecovec_ceu_devices[0]->dev);
  1240. arch_setup_pdev_archdata(ecovec_ceu_devices[0]);
  1241. dma_declare_coherent_memory(&ecovec_ceu_devices[0]->dev,
  1242. ceu0_dma_membase, ceu0_dma_membase,
  1243. ceu0_dma_membase +
  1244. CEU_BUFFER_MEMORY_SIZE - 1,
  1245. DMA_MEMORY_EXCLUSIVE);
  1246. platform_device_add(ecovec_ceu_devices[0]);
  1247. device_initialize(&ecovec_ceu_devices[1]->dev);
  1248. arch_setup_pdev_archdata(ecovec_ceu_devices[1]);
  1249. dma_declare_coherent_memory(&ecovec_ceu_devices[1]->dev,
  1250. ceu1_dma_membase, ceu1_dma_membase,
  1251. ceu1_dma_membase +
  1252. CEU_BUFFER_MEMORY_SIZE - 1,
  1253. DMA_MEMORY_EXCLUSIVE);
  1254. platform_device_add(ecovec_ceu_devices[1]);
  1255. return platform_add_devices(ecovec_devices,
  1256. ARRAY_SIZE(ecovec_devices));
  1257. }
  1258. arch_initcall(arch_setup);
  1259. static int __init devices_setup(void)
  1260. {
  1261. sh_eth_init(&sh_eth_plat);
  1262. return 0;
  1263. }
  1264. device_initcall(devices_setup);
  1265. /* Reserve a portion of memory for CEU 0 and CEU 1 buffers */
  1266. static void __init ecovec_mv_mem_reserve(void)
  1267. {
  1268. phys_addr_t phys;
  1269. phys_addr_t size = CEU_BUFFER_MEMORY_SIZE;
  1270. phys = memblock_alloc_base(size, PAGE_SIZE, MEMBLOCK_ALLOC_ANYWHERE);
  1271. memblock_free(phys, size);
  1272. memblock_remove(phys, size);
  1273. ceu0_dma_membase = phys;
  1274. phys = memblock_alloc_base(size, PAGE_SIZE, MEMBLOCK_ALLOC_ANYWHERE);
  1275. memblock_free(phys, size);
  1276. memblock_remove(phys, size);
  1277. ceu1_dma_membase = phys;
  1278. }
  1279. static struct sh_machine_vector mv_ecovec __initmv = {
  1280. .mv_name = "R0P7724 (EcoVec)",
  1281. .mv_mem_reserve = ecovec_mv_mem_reserve,
  1282. };