rtuDataAnalysis.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. /*
  2. * AP4EVB board support
  3. *
  4. * Copyright (C) 2010 Magnus Damm
  5. * Copyright (C) 2008 Yoshihiro Shimoda
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; version 2 of the License.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include <linux/clk.h>
  21. #include <linux/kernel.h>
  22. #include <linux/init.h>
  23. #include <linux/interrupt.h>
  24. #include <linux/irq.h>
  25. #include <linux/platform_device.h>
  26. #include <linux/delay.h>
  27. #include <linux/mfd/tmio.h>
  28. #include <linux/mmc/host.h>
  29. #include <linux/mmc/sh_mobile_sdhi.h>
  30. #include <linux/mtd/mtd.h>
  31. #include <linux/mtd/partitions.h>
  32. #include <linux/mtd/physmap.h>
  33. #include <linux/mmc/sh_mmcif.h>
  34. #include <linux/i2c.h>
  35. #include <linux/i2c/tsc2007.h>
  36. #include <linux/io.h>
  37. #include <linux/regulator/fixed.h>
  38. #include <linux/regulator/machine.h>
  39. #include <linux/smsc911x.h>
  40. #include <linux/sh_intc.h>
  41. #include <linux/sh_clk.h>
  42. #include <linux/gpio.h>
  43. #include <linux/input.h>
  44. #include <linux/leds.h>
  45. #include <linux/input/sh_keysc.h>
  46. #include <linux/usb/r8a66597.h>
  47. #include <linux/pm_clock.h>
  48. #include <linux/dma-mapping.h>
  49. #include <media/sh_mobile_ceu.h>
  50. #include <media/sh_mobile_csi2.h>
  51. #include <media/soc_camera.h>
  52. #include <sound/sh_fsi.h>
  53. #include <sound/simple_card.h>
  54. #include <video/sh_mobile_hdmi.h>
  55. #include <video/sh_mobile_lcdc.h>
  56. #include <video/sh_mipi_dsi.h>
  57. #include <mach/common.h>
  58. #include <mach/irqs.h>
  59. #include <mach/sh7372.h>
  60. #include <asm/mach-types.h>
  61. #include <asm/mach/arch.h>
  62. #include <asm/setup.h>
  63. #include "sh-gpio.h"
  64. /*
  65. * Address Interface BusWidth note
  66. * ------------------------------------------------------------------
  67. * 0x0000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = ON
  68. * 0x0800_0000 user area -
  69. * 0x1000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = OFF
  70. * 0x1400_0000 Ether (LAN9220) 16bit
  71. * 0x1600_0000 user area - cannot use with NAND
  72. * 0x1800_0000 user area -
  73. * 0x1A00_0000 -
  74. * 0x4000_0000 LPDDR2-SDRAM (POP) 32bit
  75. */
  76. /*
  77. * NOR Flash ROM
  78. *
  79. * SW1 | SW2 | SW7 | NOR Flash ROM
  80. * bit1 | bit1 bit2 | bit1 | Memory allocation
  81. * ------+------------+------+------------------
  82. * OFF | ON OFF | ON | Area 0
  83. * OFF | ON OFF | OFF | Area 4
  84. */
  85. /*
  86. * NAND Flash ROM
  87. *
  88. * SW1 | SW2 | SW7 | NAND Flash ROM
  89. * bit1 | bit1 bit2 | bit2 | Memory allocation
  90. * ------+------------+------+------------------
  91. * OFF | ON OFF | ON | FCE 0
  92. * OFF | ON OFF | OFF | FCE 1
  93. */
  94. /*
  95. * SMSC 9220
  96. *
  97. * SW1 SMSC 9220
  98. * -----------------------
  99. * ON access disable
  100. * OFF access enable
  101. */
  102. /*
  103. * LCD / IRQ / KEYSC / IrDA
  104. *
  105. * IRQ = IRQ26 (TS), IRQ27 (VIO), IRQ28 (QHD-TouchScreen)
  106. * LCD = 2nd LCDC (WVGA)
  107. *
  108. * | SW43 |
  109. * SW3 | ON | OFF |
  110. * -------------+-----------------------+---------------+
  111. * ON | KEY / IrDA | LCD |
  112. * OFF | KEY / IrDA / IRQ | IRQ |
  113. *
  114. *
  115. * QHD / WVGA display
  116. *
  117. * You can choice display type on menuconfig.
  118. * Then, check above dip-switch.
  119. */
  120. /*
  121. * USB
  122. *
  123. * J7 : 1-2 MAX3355E VBUS
  124. * 2-3 DC 5.0V
  125. *
  126. * S39: bit2: off
  127. */
  128. /*
  129. * FSI/FSMI
  130. *
  131. * SW41 : ON : SH-Mobile AP4 Audio Mode
  132. * : OFF : Bluetooth Audio Mode
  133. */
  134. /*
  135. * MMC0/SDHI1 (CN7)
  136. *
  137. * J22 : select card voltage
  138. * 1-2 pin : 1.8v
  139. * 2-3 pin : 3.3v
  140. *
  141. * SW1 | SW33
  142. * | bit1 | bit2 | bit3 | bit4
  143. * ------------+------+------+------+-------
  144. * MMC0 OFF | OFF | ON | ON | X
  145. * SDHI1 OFF | ON | X | OFF | ON
  146. *
  147. * voltage lebel
  148. * CN7 : 1.8v
  149. * CN12: 3.3v
  150. */
  151. /* Dummy supplies, where voltage doesn't matter */
  152. static struct regulator_consumer_supply fixed1v8_power_consumers[] =
  153. {
  154. /* J22 default position: 1.8V */
  155. REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.1"),
  156. REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.1"),
  157. REGULATOR_SUPPLY("vmmc", "sh_mmcif.0"),
  158. REGULATOR_SUPPLY("vqmmc", "sh_mmcif.0"),
  159. };
  160. static struct regulator_consumer_supply fixed3v3_power_consumers[] =
  161. {
  162. REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
  163. REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
  164. };
  165. static struct regulator_consumer_supply dummy_supplies[] = {
  166. REGULATOR_SUPPLY("vddvario", "smsc911x"),
  167. REGULATOR_SUPPLY("vdd33a", "smsc911x"),
  168. };
  169. /* MTD */
  170. static struct mtd_partition nor_flash_partitions[] = {
  171. {
  172. .name = "loader",
  173. .offset = 0x00000000,
  174. .size = 512 * 1024,
  175. .mask_flags = MTD_WRITEABLE,
  176. },
  177. {
  178. .name = "bootenv",
  179. .offset = MTDPART_OFS_APPEND,
  180. .size = 512 * 1024,
  181. .mask_flags = MTD_WRITEABLE,
  182. },
  183. {
  184. .name = "kernel_ro",
  185. .offset = MTDPART_OFS_APPEND,
  186. .size = 8 * 1024 * 1024,
  187. .mask_flags = MTD_WRITEABLE,
  188. },
  189. {
  190. .name = "kernel",
  191. .offset = MTDPART_OFS_APPEND,
  192. .size = 8 * 1024 * 1024,
  193. },
  194. {
  195. .name = "data",
  196. .offset = MTDPART_OFS_APPEND,
  197. .size = MTDPART_SIZ_FULL,
  198. },
  199. };
  200. static struct physmap_flash_data nor_flash_data = {
  201. .width = 2,
  202. .parts = nor_flash_partitions,
  203. .nr_parts = ARRAY_SIZE(nor_flash_partitions),
  204. };
  205. static struct resource nor_flash_resources[] = {
  206. [0] = {
  207. .start = 0x20000000, /* CS0 shadow instead of regular CS0 */
  208. .end = 0x28000000 - 1, /* needed by USB MASK ROM boot */
  209. .flags = IORESOURCE_MEM,
  210. }
  211. };
  212. static struct platform_device nor_flash_device = {
  213. .name = "physmap-flash",
  214. .dev = {
  215. .platform_data = &nor_flash_data,
  216. },
  217. .num_resources = ARRAY_SIZE(nor_flash_resources),
  218. .resource = nor_flash_resources,
  219. };
  220. /* SMSC 9220 */
  221. static struct resource smc911x_resources[] = {
  222. {
  223. .start = 0x14000000,
  224. .end = 0x16000000 - 1,
  225. .flags = IORESOURCE_MEM,
  226. }, {
  227. .start = evt2irq(0x02c0) /* IRQ6A */,
  228. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  229. },
  230. };
  231. static struct smsc911x_platform_config smsc911x_info = {
  232. .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS,
  233. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  234. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  235. };
  236. static struct platform_device smc911x_device = {
  237. .name = "smsc911x",
  238. .id = -1,
  239. .num_resources = ARRAY_SIZE(smc911x_resources),
  240. .resource = smc911x_resources,
  241. .dev = {
  242. .platform_data = &smsc911x_info,
  243. },
  244. };
  245. /*
  246. * The card detect pin of the top SD/MMC slot (CN7) is active low and is
  247. * connected to GPIO A22 of SH7372 (GPIO_PORT41).
  248. */
  249. static int slot_cn7_get_cd(struct platform_device *pdev)
  250. {
  251. return !gpio_get_value(GPIO_PORT41);
  252. }
  253. /* MERAM */
  254. static struct sh_mobile_meram_info meram_info = {
  255. .addr_mode = SH_MOBILE_MERAM_MODE1,
  256. };
  257. static struct resource meram_resources[] = {
  258. [0] = {
  259. .name = "regs",
  260. .start = 0xe8000000,
  261. .end = 0xe807ffff,
  262. .flags = IORESOURCE_MEM,
  263. },
  264. [1] = {
  265. .name = "meram",
  266. .start = 0xe8080000,
  267. .end = 0xe81fffff,
  268. .flags = IORESOURCE_MEM,
  269. },
  270. };
  271. static struct platform_device meram_device = {
  272. .name = "sh_mobile_meram",
  273. .id = 0,
  274. .num_resources = ARRAY_SIZE(meram_resources),
  275. .resource = meram_resources,
  276. .dev = {
  277. .platform_data = &meram_info,
  278. },
  279. };
  280. /* SH_MMCIF */
  281. static struct resource sh_mmcif_resources[] = {
  282. [0] = {
  283. .name = "MMCIF",
  284. .start = 0xE6BD0000,
  285. .end = 0xE6BD00FF,
  286. .flags = IORESOURCE_MEM,
  287. },
  288. [1] = {
  289. /* MMC ERR */
  290. .start = evt2irq(0x1ac0),
  291. .flags = IORESOURCE_IRQ,
  292. },
  293. [2] = {
  294. /* MMC NOR */
  295. .start = evt2irq(0x1ae0),
  296. .flags = IORESOURCE_IRQ,
  297. },
  298. };
  299. static struct sh_mmcif_plat_data sh_mmcif_plat = {
  300. .sup_pclk = 0,
  301. .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
  302. .caps = MMC_CAP_4_BIT_DATA |
  303. MMC_CAP_8_BIT_DATA |
  304. MMC_CAP_NEEDS_POLL,
  305. .get_cd = slot_cn7_get_cd,
  306. .slave_id_tx = SHDMA_SLAVE_MMCIF_TX,
  307. .slave_id_rx = SHDMA_SLAVE_MMCIF_RX,
  308. };
  309. static struct platform_device sh_mmcif_device = {
  310. .name = "sh_mmcif",
  311. .id = 0,
  312. .dev = {
  313. .dma_mask = NULL,
  314. .coherent_dma_mask = 0xffffffff,
  315. .platform_data = &sh_mmcif_plat,
  316. },
  317. .num_resources = ARRAY_SIZE(sh_mmcif_resources),
  318. .resource = sh_mmcif_resources,
  319. };
  320. /* SDHI0 */
  321. static struct sh_mobile_sdhi_info sdhi0_info = {
  322. .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
  323. .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
  324. .tmio_caps = MMC_CAP_SDIO_IRQ,
  325. };
  326. static struct resource sdhi0_resources[] = {
  327. [0] = {
  328. .name = "SDHI0",
  329. .start = 0xe6850000,
  330. .end = 0xe68500ff,
  331. .flags = IORESOURCE_MEM,
  332. },
  333. [1] = {
  334. .start = evt2irq(0x0e00) /* SDHI0_SDHI0I0 */,
  335. .flags = IORESOURCE_IRQ,
  336. },
  337. [2] = {
  338. .start = evt2irq(0x0e20) /* SDHI0_SDHI0I1 */,
  339. .flags = IORESOURCE_IRQ,
  340. },
  341. [3] = {
  342. .start = evt2irq(0x0e40) /* SDHI0_SDHI0I2 */,
  343. .flags = IORESOURCE_IRQ,
  344. },
  345. };
  346. static struct platform_device sdhi0_device = {
  347. .name = "sh_mobile_sdhi",
  348. .num_resources = ARRAY_SIZE(sdhi0_resources),
  349. .resource = sdhi0_resources,
  350. .id = 0,
  351. .dev = {
  352. .platform_data = &sdhi0_info,
  353. },
  354. };
  355. /* SDHI1 */
  356. static struct sh_mobile_sdhi_info sdhi1_info = {
  357. .dma_slave_tx = SHDMA_SLAVE_SDHI1_TX,
  358. .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX,
  359. .tmio_ocr_mask = MMC_VDD_165_195,
  360. .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE,
  361. .tmio_caps = MMC_CAP_NEEDS_POLL | MMC_CAP_SDIO_IRQ,
  362. .get_cd = slot_cn7_get_cd,
  363. };
  364. static struct resource sdhi1_resources[] = {
  365. [0] = {
  366. .name = "SDHI1",
  367. .start = 0xe6860000,
  368. .end = 0xe68600ff,
  369. .flags = IORESOURCE_MEM,
  370. },
  371. [1] = {
  372. .start = evt2irq(0x0e80), /* SDHI1_SDHI1I0 */
  373. .flags = IORESOURCE_IRQ,
  374. },
  375. [2] = {
  376. .start = evt2irq(0x0ea0), /* SDHI1_SDHI1I1 */
  377. .flags = IORESOURCE_IRQ,
  378. },
  379. [3] = {
  380. .start = evt2irq(0x0ec0), /* SDHI1_SDHI1I2 */
  381. .flags = IORESOURCE_IRQ,
  382. },
  383. };
  384. static struct platform_device sdhi1_device = {
  385. .name = "sh_mobile_sdhi",
  386. .num_resources = ARRAY_SIZE(sdhi1_resources),
  387. .resource = sdhi1_resources,
  388. .id = 1,
  389. .dev = {
  390. .platform_data = &sdhi1_info,
  391. },
  392. };
  393. /* USB1 */
  394. static void usb1_host_port_power(int port, int power)
  395. {
  396. if (!power) /* only power-on supported for now */
  397. return;
  398. /* set VBOUT/PWEN and EXTLP1 in DVSTCTR */
  399. __raw_writew(__raw_readw(IOMEM(0xE68B0008)) | 0x600, IOMEM(0xE68B0008));
  400. }
  401. static struct r8a66597_platdata usb1_host_data = {
  402. .on_chip = 1,
  403. .port_power = usb1_host_port_power,
  404. };
  405. static struct resource usb1_host_resources[] = {