devs.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. /* linux/arch/arm/plat-samsung/devs.c
  2. *
  3. * Copyright (c) 2011 Samsung Electronics Co., Ltd.
  4. * http://www.samsung.com
  5. *
  6. * Base SAMSUNG platform device definitions
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #include <linux/kernel.h>
  13. #include <linux/types.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/list.h>
  16. #include <linux/timer.h>
  17. #include <linux/init.h>
  18. #include <linux/serial_core.h>
  19. #include <linux/platform_device.h>
  20. #include <linux/io.h>
  21. #include <linux/slab.h>
  22. #include <linux/string.h>
  23. #include <linux/dma-mapping.h>
  24. #include <linux/mtd/mtd.h>
  25. #include <linux/mtd/onenand.h>
  26. #include <asm/irq.h>
  27. #include <asm/mach/arch.h>
  28. #include <asm/mach/map.h>
  29. #include <asm/mach/irq.h>
  30. #include <mach/hardware.h>
  31. #include <mach/dma.h>
  32. #include <mach/irqs.h>
  33. #include <mach/map.h>
  34. #include <plat/cpu.h>
  35. #include <plat/devs.h>
  36. #include <plat/fb.h>
  37. #include <plat/fb-s3c2410.h>
  38. #include <plat/mci.h>
  39. #include <plat/ts.h>
  40. #include <plat/udc.h>
  41. #include <plat/regs-serial.h>
  42. #include <plat/regs-spi.h>
  43. static u64 samsung_device_dma_mask = DMA_BIT_MASK(32);
  44. /* AC97 */
  45. #ifdef CONFIG_CPU_S3C2440
  46. static struct resource s3c_ac97_resource[] = {
  47. [0] = {
  48. .start = S3C2440_PA_AC97,
  49. .end = S3C2440_PA_AC97 + S3C2440_SZ_AC97 - 1,
  50. .flags = IORESOURCE_MEM,
  51. },
  52. [1] = {
  53. .start = IRQ_S3C244x_AC97,
  54. .end = IRQ_S3C244x_AC97,
  55. .flags = IORESOURCE_IRQ,
  56. },
  57. [2] = {
  58. .name = "PCM out",
  59. .start = DMACH_PCM_OUT,
  60. .end = DMACH_PCM_OUT,
  61. .flags = IORESOURCE_DMA,
  62. },
  63. [3] = {
  64. .name = "PCM in",
  65. .start = DMACH_PCM_IN,
  66. .end = DMACH_PCM_IN,
  67. .flags = IORESOURCE_DMA,
  68. },
  69. [4] = {
  70. .name = "Mic in",
  71. .start = DMACH_MIC_IN,
  72. .end = DMACH_MIC_IN,
  73. .flags = IORESOURCE_DMA,
  74. },
  75. };
  76. struct platform_device s3c_device_ac97 = {
  77. .name = "samsung-ac97",
  78. .id = -1,
  79. .num_resources = ARRAY_SIZE(s3c_ac97_resource),
  80. .resource = s3c_ac97_resource,
  81. .dev = {
  82. .dma_mask = &samsung_device_dma_mask,
  83. .coherent_dma_mask = DMA_BIT_MASK(32),
  84. }
  85. };
  86. #endif /* CONFIG_CPU_S3C2440 */
  87. /* ADC */
  88. #ifdef CONFIG_PLAT_S3C24XX
  89. static struct resource s3c_adc_resource[] = {
  90. [0] = {
  91. .start = S3C24XX_PA_ADC,
  92. .end = S3C24XX_PA_ADC + S3C24XX_SZ_ADC - 1,
  93. .flags = IORESOURCE_MEM,
  94. },
  95. [1] = {
  96. .start = IRQ_TC,
  97. .end = IRQ_TC,
  98. .flags = IORESOURCE_IRQ,
  99. },
  100. [2] = {
  101. .start = IRQ_ADC,
  102. .end = IRQ_ADC,
  103. .flags = IORESOURCE_IRQ,
  104. }
  105. };
  106. struct platform_device s3c_device_adc = {
  107. .name = "s3c24xx-adc",
  108. .id = -1,
  109. .num_resources = ARRAY_SIZE(s3c_adc_resource),
  110. .resource = s3c_adc_resource,
  111. };
  112. #endif /* CONFIG_PLAT_S3C24XX */
  113. /* Camif Controller */
  114. #ifdef CONFIG_CPU_S3C2440
  115. static struct resource s3c_camif_resource[] = {
  116. [0] = {
  117. .start = S3C2440_PA_CAMIF,
  118. .end = S3C2440_PA_CAMIF + S3C2440_SZ_CAMIF - 1,
  119. .flags = IORESOURCE_MEM,
  120. },
  121. [1] = {
  122. .start = IRQ_CAM,
  123. .end = IRQ_CAM,
  124. .flags = IORESOURCE_IRQ,
  125. }
  126. };
  127. struct platform_device s3c_device_camif = {
  128. .name = "s3c2440-camif",
  129. .id = -1,
  130. .num_resources = ARRAY_SIZE(s3c_camif_resource),
  131. .resource = s3c_camif_resource,
  132. .dev = {
  133. .dma_mask = &samsung_device_dma_mask,
  134. .coherent_dma_mask = DMA_BIT_MASK(32),
  135. }
  136. };
  137. #endif /* CONFIG_CPU_S3C2440 */
  138. /* I2S */
  139. #ifdef CONFIG_PLAT_S3C24XX
  140. static struct resource s3c_iis_resource[] = {
  141. [0] = {
  142. .start = S3C24XX_PA_IIS,
  143. .end = S3C24XX_PA_IIS + S3C24XX_SZ_IIS - 1,
  144. .flags = IORESOURCE_MEM,
  145. }
  146. };
  147. struct platform_device s3c_device_iis = {
  148. .name = "s3c24xx-iis",
  149. .id = -1,
  150. .num_resources = ARRAY_SIZE(s3c_iis_resource),
  151. .resource = s3c_iis_resource,
  152. .dev = {
  153. .dma_mask = &samsung_device_dma_mask,
  154. .coherent_dma_mask = DMA_BIT_MASK(32),
  155. }
  156. };
  157. #endif /* CONFIG_PLAT_S3C24XX */
  158. #ifdef CONFIG_CPU_S3C2440
  159. struct platform_device s3c2412_device_iis = {
  160. .name = "s3c2412-iis",
  161. .id = -1,
  162. .dev = {
  163. .dma_mask = &samsung_device_dma_mask,
  164. .coherent_dma_mask = DMA_BIT_MASK(32),
  165. }
  166. };
  167. #endif /* CONFIG_CPU_S3C2440 */
  168. /* LCD Controller */
  169. #ifdef CONFIG_PLAT_S3C24XX
  170. static struct resource s3c_lcd_resource[] = {
  171. [0] = {
  172. .start = S3C24XX_PA_LCD,
  173. .end = S3C24XX_PA_LCD + S3C24XX_SZ_LCD - 1,
  174. .flags = IORESOURCE_MEM,
  175. },
  176. [1] = {
  177. .start = IRQ_LCD,
  178. .end = IRQ_LCD,
  179. .flags = IORESOURCE_IRQ,
  180. }
  181. };
  182. struct platform_device s3c_device_lcd = {
  183. .name = "s3c2410-lcd",
  184. .id = -1,
  185. .num_resources = ARRAY_SIZE(s3c_lcd_resource),
  186. .resource = s3c_lcd_resource,
  187. .dev = {
  188. .dma_mask = &samsung_device_dma_mask,
  189. .coherent_dma_mask = DMA_BIT_MASK(32),
  190. }
  191. };
  192. void __init s3c24xx_fb_set_platdata(struct s3c2410fb_mach_info *pd)
  193. {
  194. struct s3c2410fb_mach_info *npd;
  195. npd = s3c_set_platdata(pd, sizeof(*npd), &s3c_device_lcd);
  196. if (npd) {
  197. npd->displays = kmemdup(pd->displays,
  198. sizeof(struct s3c2410fb_display) * npd->num_displays,
  199. GFP_KERNEL);
  200. if (!npd->displays)
  201. printk(KERN_ERR "no memory for LCD display data\n");
  202. } else {
  203. printk(KERN_ERR "no memory for LCD platform data\n");
  204. }
  205. }
  206. #endif /* CONFIG_PLAT_S3C24XX */
  207. #ifdef CONFIG_S3C64XX_DEV_ONENAND1
  208. static struct resource s3c64xx_onenand1_resources[] = {
  209. [0] = {
  210. .start = S3C64XX_PA_ONENAND1,
  211. .end = S3C64XX_PA_ONENAND1 + 0x400 - 1,
  212. .flags = IORESOURCE_MEM,
  213. },
  214. [1] = {
  215. .start = S3C64XX_PA_ONENAND1_BUF,
  216. .end = S3C64XX_PA_ONENAND1_BUF + S3C64XX_SZ_ONENAND1_BUF - 1,
  217. .flags = IORESOURCE_MEM,
  218. },
  219. [2] = {
  220. .start = IRQ_ONENAND1,
  221. .end = IRQ_ONENAND1,
  222. .flags = IORESOURCE_IRQ,
  223. },
  224. };
  225. struct platform_device s3c64xx_device_onenand1 = {
  226. .name = "samsung-onenand",
  227. .id = 1,
  228. .num_resources = ARRAY_SIZE(s3c64xx_onenand1_resources),
  229. .resource = s3c64xx_onenand1_resources,
  230. };
  231. void s3c64xx_onenand1_set_platdata(struct onenand_platform_data *pdata)
  232. {
  233. s3c_set_platdata(pdata, sizeof(struct onenand_platform_data),
  234. &s3c64xx_device_onenand1);
  235. }
  236. #endif /* CONFIG_S3C64XX_DEV_ONENAND1 */
  237. /* RTC */
  238. #ifdef CONFIG_PLAT_S3C24XX
  239. static struct resource s3c_rtc_resource[] = {
  240. [0] = {
  241. .start = S3C24XX_PA_RTC,
  242. .end = S3C24XX_PA_RTC + 0xff,
  243. .flags = IORESOURCE_MEM,
  244. },
  245. [1] = {
  246. .start = IRQ_RTC,
  247. .end = IRQ_RTC,
  248. .flags = IORESOURCE_IRQ,
  249. },
  250. [2] = {
  251. .start = IRQ_TICK,
  252. .end = IRQ_TICK,
  253. .flags = IORESOURCE_IRQ
  254. }
  255. };
  256. struct platform_device s3c_device_rtc = {
  257. .name = "s3c2410-rtc",
  258. .id = -1,
  259. .num_resources = ARRAY_SIZE(s3c_rtc_resource),
  260. .resource = s3c_rtc_resource,
  261. };
  262. #endif /* CONFIG_PLAT_S3C24XX */
  263. /* SDI */
  264. #ifdef CONFIG_PLAT_S3C24XX
  265. static struct resource s3c_sdi_resource[] = {
  266. [0] = {
  267. .start = S3C24XX_PA_SDI,
  268. .end = S3C24XX_PA_SDI + S3C24XX_SZ_SDI - 1,
  269. .flags = IORESOURCE_MEM,
  270. },
  271. [1] = {
  272. .start = IRQ_SDI,
  273. .end = IRQ_SDI,
  274. .flags = IORESOURCE_IRQ,
  275. }
  276. };
  277. struct platform_device s3c_device_sdi = {
  278. .name = "s3c2410-sdi",
  279. .id = -1,
  280. .num_resources = ARRAY_SIZE(s3c_sdi_resource),
  281. .resource = s3c_sdi_resource,
  282. };
  283. void __init s3c24xx_mci_set_platdata(struct s3c24xx_mci_pdata *pdata)
  284. {
  285. s3c_set_platdata(pdata, sizeof(struct s3c24xx_mci_pdata),
  286. &s3c_device_sdi);
  287. }
  288. #endif /* CONFIG_PLAT_S3C24XX */
  289. /* SPI */
  290. #ifdef CONFIG_PLAT_S3C24XX
  291. static struct resource s3c_spi0_resource[] = {
  292. [0] = {
  293. .start = S3C24XX_PA_SPI,
  294. .end = S3C24XX_PA_SPI + 0x1f,
  295. .flags = IORESOURCE_MEM,
  296. },
  297. [1] = {
  298. .start = IRQ_SPI0,
  299. .end = IRQ_SPI0,
  300. .flags = IORESOURCE_IRQ,
  301. }
  302. };
  303. struct platform_device s3c_device_spi0 = {
  304. .name = "s3c2410-spi",
  305. .id = 0,
  306. .num_resources = ARRAY_SIZE(s3c_spi0_resource),
  307. .resource = s3c_spi0_resource,
  308. .dev = {
  309. .dma_mask = &samsung_device_dma_mask,
  310. .coherent_dma_mask = DMA_BIT_MASK(32),
  311. }
  312. };
  313. static struct resource s3c_spi1_resource[] = {
  314. [0] = {
  315. .start = S3C24XX_PA_SPI + S3C2410_SPI1,
  316. .end = S3C24XX_PA_SPI + S3C2410_SPI1 + 0x1f,
  317. .flags = IORESOURCE_MEM,
  318. },
  319. [1] = {
  320. .start = IRQ_SPI1,
  321. .end = IRQ_SPI1,
  322. .flags = IORESOURCE_IRQ,
  323. }
  324. };
  325. struct platform_device s3c_device_spi1 = {
  326. .name = "s3c2410-spi",
  327. .id = 1,
  328. .num_resources = ARRAY_SIZE(s3c_spi1_resource),
  329. .resource = s3c_spi1_resource,
  330. .dev = {
  331. .dma_mask = &samsung_device_dma_mask,
  332. .coherent_dma_mask = DMA_BIT_MASK(32),
  333. }
  334. };
  335. #endif /* CONFIG_PLAT_S3C24XX */
  336. /* Touchscreen */
  337. #ifdef CONFIG_PLAT_S3C24XX
  338. static struct resource s3c_ts_resource[] = {
  339. [0] = {
  340. .start = S3C24XX_PA_ADC,
  341. .end = S3C24XX_PA_ADC + S3C24XX_SZ_ADC - 1,
  342. .flags = IORESOURCE_MEM,
  343. },
  344. [1] = {
  345. .start = IRQ_TC,
  346. .end = IRQ_TC,
  347. .flags = IORESOURCE_IRQ,
  348. },
  349. };
  350. struct platform_device s3c_device_ts = {
  351. .name = "s3c2410-ts",
  352. .id = -1,
  353. .dev.parent = &s3c_device_adc.dev,
  354. .num_resources = ARRAY_SIZE(s3c_ts_resource),
  355. .resource = s3c_ts_resource,
  356. };
  357. void __init s3c24xx_ts_set_platdata(struct s3c2410_ts_mach_info *hard_s3c2410ts_info)
  358. {
  359. s3c_set_platdata(hard_s3c2410ts_info,
  360. sizeof(struct s3c2410_ts_mach_info), &s3c_device_ts);
  361. }
  362. #endif /* CONFIG_PLAT_S3C24XX */
  363. /* USB Device (Gadget) */
  364. #ifdef CONFIG_PLAT_S3C24XX
  365. static struct resource s3c_usbgadget_resource[] = {
  366. [0] = {
  367. .start = S3C24XX_PA_USBDEV,
  368. .end = S3C24XX_PA_USBDEV + S3C24XX_SZ_USBDEV - 1,
  369. .flags = IORESOURCE_MEM,
  370. },
  371. [1] = {
  372. .start = IRQ_USBD,
  373. .end = IRQ_USBD,
  374. .flags = IORESOURCE_IRQ,
  375. }
  376. };
  377. struct platform_device s3c_device_usbgadget = {
  378. .name = "s3c2410-usbgadget",
  379. .id = -1,
  380. .num_resources = ARRAY_SIZE(s3c_usbgadget_resource),
  381. .resource = s3c_usbgadget_resource,
  382. };
  383. void __init s3c24xx_udc_set_platdata(struct s3c2410_udc_mach_info *pd)
  384. {
  385. s3c_set_platdata(pd, sizeof(*pd), &s3c_device_usbgadget);
  386. }
  387. #endif /* CONFIG_PLAT_S3C24XX */
  388. /* USB High Spped 2.0 Device (Gadget) */
  389. #ifdef CONFIG_PLAT_S3C24XX
  390. static struct resource s3c_hsudc_resource[] = {
  391. [0] = {
  392. .start = S3C2416_PA_HSUDC,
  393. .end = S3C2416_PA_HSUDC + S3C2416_SZ_HSUDC - 1,
  394. .flags = IORESOURCE_MEM,
  395. },
  396. [1] = {
  397. .start = IRQ_USBD,
  398. .end = IRQ_USBD,
  399. .flags = IORESOURCE_IRQ,
  400. }
  401. };
  402. struct platform_device s3c_device_usb_hsudc = {
  403. .name = "s3c-hsudc",
  404. .id = -1,
  405. .num_resources = ARRAY_SIZE(s3c_hsudc_resource),
  406. .resource = s3c_hsudc_resource,
  407. .dev = {
  408. .dma_mask = &samsung_device_dma_mask,
  409. .coherent_dma_mask = DMA_BIT_MASK(32),
  410. },
  411. };
  412. void __init s3c24xx_hsudc_set_platdata(struct s3c24xx_hsudc_platdata *pd)
  413. {
  414. s3c_set_platdata(pd, sizeof(*pd), &s3c_device_usb_hsudc);
  415. }
  416. #endif /* CONFIG_PLAT_S3C24XX */