devs.c 9.1 KB

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