devs.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. /* linux/arch/arm/plat-s3c24xx/devs.c
  2. *
  3. * Copyright (c) 2004 Simtec Electronics
  4. * Ben Dooks <ben@simtec.co.uk>
  5. *
  6. * Base S3C24XX 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. */
  13. #include <linux/kernel.h>
  14. #include <linux/types.h>
  15. #include <linux/interrupt.h>
  16. #include <linux/list.h>
  17. #include <linux/timer.h>
  18. #include <linux/init.h>
  19. #include <linux/serial_core.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/io.h>
  22. #include <linux/slab.h>
  23. #include <linux/string.h>
  24. #include <asm/mach/arch.h>
  25. #include <asm/mach/map.h>
  26. #include <asm/mach/irq.h>
  27. #include <mach/fb.h>
  28. #include <mach/hardware.h>
  29. #include <mach/dma.h>
  30. #include <mach/irqs.h>
  31. #include <asm/irq.h>
  32. #include <plat/regs-serial.h>
  33. #include <plat/udc.h>
  34. #include <plat/mci.h>
  35. #include <plat/devs.h>
  36. #include <plat/cpu.h>
  37. #include <plat/regs-spi.h>
  38. #include <plat/ts.h>
  39. /* Serial port registrations */
  40. static struct resource s3c2410_uart0_resource[] = {
  41. [0] = {
  42. .start = S3C2410_PA_UART0,
  43. .end = S3C2410_PA_UART0 + 0x3fff,
  44. .flags = IORESOURCE_MEM,
  45. },
  46. [1] = {
  47. .start = IRQ_S3CUART_RX0,
  48. .end = IRQ_S3CUART_ERR0,
  49. .flags = IORESOURCE_IRQ,
  50. }
  51. };
  52. static struct resource s3c2410_uart1_resource[] = {
  53. [0] = {
  54. .start = S3C2410_PA_UART1,
  55. .end = S3C2410_PA_UART1 + 0x3fff,
  56. .flags = IORESOURCE_MEM,
  57. },
  58. [1] = {
  59. .start = IRQ_S3CUART_RX1,
  60. .end = IRQ_S3CUART_ERR1,
  61. .flags = IORESOURCE_IRQ,
  62. }
  63. };
  64. static struct resource s3c2410_uart2_resource[] = {
  65. [0] = {
  66. .start = S3C2410_PA_UART2,
  67. .end = S3C2410_PA_UART2 + 0x3fff,
  68. .flags = IORESOURCE_MEM,
  69. },
  70. [1] = {
  71. .start = IRQ_S3CUART_RX2,
  72. .end = IRQ_S3CUART_ERR2,
  73. .flags = IORESOURCE_IRQ,
  74. }
  75. };
  76. static struct resource s3c2410_uart3_resource[] = {
  77. [0] = {
  78. .start = S3C2443_PA_UART3,
  79. .end = S3C2443_PA_UART3 + 0x3fff,
  80. .flags = IORESOURCE_MEM,
  81. },
  82. [1] = {
  83. .start = IRQ_S3CUART_RX3,
  84. .end = IRQ_S3CUART_ERR3,
  85. .flags = IORESOURCE_IRQ,
  86. },
  87. };
  88. struct s3c24xx_uart_resources s3c2410_uart_resources[] __initdata = {
  89. [0] = {
  90. .resources = s3c2410_uart0_resource,
  91. .nr_resources = ARRAY_SIZE(s3c2410_uart0_resource),
  92. },
  93. [1] = {
  94. .resources = s3c2410_uart1_resource,
  95. .nr_resources = ARRAY_SIZE(s3c2410_uart1_resource),
  96. },
  97. [2] = {
  98. .resources = s3c2410_uart2_resource,
  99. .nr_resources = ARRAY_SIZE(s3c2410_uart2_resource),
  100. },
  101. [3] = {
  102. .resources = s3c2410_uart3_resource,
  103. .nr_resources = ARRAY_SIZE(s3c2410_uart3_resource),
  104. },
  105. };
  106. /* LCD Controller */
  107. static struct resource s3c_lcd_resource[] = {
  108. [0] = {
  109. .start = S3C24XX_PA_LCD,
  110. .end = S3C24XX_PA_LCD + S3C24XX_SZ_LCD - 1,
  111. .flags = IORESOURCE_MEM,
  112. },
  113. [1] = {
  114. .start = IRQ_LCD,
  115. .end = IRQ_LCD,
  116. .flags = IORESOURCE_IRQ,
  117. }
  118. };
  119. static u64 s3c_device_lcd_dmamask = 0xffffffffUL;
  120. struct platform_device s3c_device_lcd = {
  121. .name = "s3c2410-lcd",
  122. .id = -1,
  123. .num_resources = ARRAY_SIZE(s3c_lcd_resource),
  124. .resource = s3c_lcd_resource,
  125. .dev = {
  126. .dma_mask = &s3c_device_lcd_dmamask,
  127. .coherent_dma_mask = 0xffffffffUL
  128. }
  129. };
  130. EXPORT_SYMBOL(s3c_device_lcd);
  131. void __init s3c24xx_fb_set_platdata(struct s3c2410fb_mach_info *pd)
  132. {
  133. struct s3c2410fb_mach_info *npd;
  134. npd = kmemdup(pd, sizeof(*npd), GFP_KERNEL);
  135. if (npd) {
  136. s3c_device_lcd.dev.platform_data = npd;
  137. npd->displays = kmemdup(pd->displays,
  138. sizeof(struct s3c2410fb_display) * npd->num_displays,
  139. GFP_KERNEL);
  140. if (!npd->displays)
  141. printk(KERN_ERR "no memory for LCD display data\n");
  142. } else {
  143. printk(KERN_ERR "no memory for LCD platform data\n");
  144. }
  145. }
  146. /* Touchscreen */
  147. static struct resource s3c_ts_resource[] = {
  148. [0] = {
  149. .start = S3C24XX_PA_ADC,
  150. .end = S3C24XX_PA_ADC + S3C24XX_SZ_ADC - 1,
  151. .flags = IORESOURCE_MEM,
  152. },
  153. [1] = {
  154. .start = IRQ_TC,
  155. .end = IRQ_TC,
  156. .flags = IORESOURCE_IRQ,
  157. },
  158. };
  159. struct platform_device s3c_device_ts = {
  160. .name = "s3c2410-ts",
  161. .id = -1,
  162. .dev.parent = &s3c_device_adc.dev,
  163. .num_resources = ARRAY_SIZE(s3c_ts_resource),
  164. .resource = s3c_ts_resource,
  165. };
  166. EXPORT_SYMBOL(s3c_device_ts);
  167. static struct s3c2410_ts_mach_info s3c2410ts_info;
  168. void __init s3c24xx_ts_set_platdata(struct s3c2410_ts_mach_info *hard_s3c2410ts_info)
  169. {
  170. memcpy(&s3c2410ts_info, hard_s3c2410ts_info, sizeof(struct s3c2410_ts_mach_info));
  171. s3c_device_ts.dev.platform_data = &s3c2410ts_info;
  172. }
  173. /* USB Device (Gadget)*/
  174. static struct resource s3c_usbgadget_resource[] = {
  175. [0] = {
  176. .start = S3C24XX_PA_USBDEV,
  177. .end = S3C24XX_PA_USBDEV + S3C24XX_SZ_USBDEV - 1,
  178. .flags = IORESOURCE_MEM,
  179. },
  180. [1] = {
  181. .start = IRQ_USBD,
  182. .end = IRQ_USBD,
  183. .flags = IORESOURCE_IRQ,
  184. }
  185. };
  186. struct platform_device s3c_device_usbgadget = {
  187. .name = "s3c2410-usbgadget",
  188. .id = -1,
  189. .num_resources = ARRAY_SIZE(s3c_usbgadget_resource),
  190. .resource = s3c_usbgadget_resource,
  191. };
  192. EXPORT_SYMBOL(s3c_device_usbgadget);
  193. void __init s3c24xx_udc_set_platdata(struct s3c2410_udc_mach_info *pd)
  194. {
  195. struct s3c2410_udc_mach_info *npd;
  196. npd = kmalloc(sizeof(*npd), GFP_KERNEL);
  197. if (npd) {
  198. memcpy(npd, pd, sizeof(*npd));
  199. s3c_device_usbgadget.dev.platform_data = npd;
  200. } else {
  201. printk(KERN_ERR "no memory for udc platform data\n");
  202. }
  203. }
  204. /* IIS */
  205. static struct resource s3c_iis_resource[] = {
  206. [0] = {
  207. .start = S3C24XX_PA_IIS,
  208. .end = S3C24XX_PA_IIS + S3C24XX_SZ_IIS -1,
  209. .flags = IORESOURCE_MEM,
  210. }
  211. };
  212. static u64 s3c_device_iis_dmamask = 0xffffffffUL;
  213. struct platform_device s3c_device_iis = {
  214. .name = "s3c24xx-iis",
  215. .id = -1,
  216. .num_resources = ARRAY_SIZE(s3c_iis_resource),
  217. .resource = s3c_iis_resource,
  218. .dev = {
  219. .dma_mask = &s3c_device_iis_dmamask,
  220. .coherent_dma_mask = 0xffffffffUL
  221. }
  222. };
  223. EXPORT_SYMBOL(s3c_device_iis);
  224. /* ASoC PCM DMA */
  225. static u64 s3c_device_audio_dmamask = 0xffffffffUL;
  226. struct platform_device s3c_device_pcm = {
  227. .name = "s3c24xx-pcm-audio",
  228. .id = -1,
  229. .dev = {
  230. .dma_mask = &s3c_device_audio_dmamask,
  231. .coherent_dma_mask = 0xffffffffUL
  232. }
  233. };
  234. EXPORT_SYMBOL(s3c_device_pcm);
  235. /* RTC */
  236. static struct resource s3c_rtc_resource[] = {
  237. [0] = {
  238. .start = S3C24XX_PA_RTC,
  239. .end = S3C24XX_PA_RTC + 0xff,
  240. .flags = IORESOURCE_MEM,
  241. },
  242. [1] = {
  243. .start = IRQ_RTC,
  244. .end = IRQ_RTC,
  245. .flags = IORESOURCE_IRQ,
  246. },
  247. [2] = {
  248. .start = IRQ_TICK,
  249. .end = IRQ_TICK,
  250. .flags = IORESOURCE_IRQ
  251. }
  252. };
  253. struct platform_device s3c_device_rtc = {
  254. .name = "s3c2410-rtc",
  255. .id = -1,
  256. .num_resources = ARRAY_SIZE(s3c_rtc_resource),
  257. .resource = s3c_rtc_resource,
  258. };
  259. EXPORT_SYMBOL(s3c_device_rtc);
  260. /* ADC */
  261. static struct resource s3c_adc_resource[] = {
  262. [0] = {
  263. .start = S3C24XX_PA_ADC,
  264. .end = S3C24XX_PA_ADC + S3C24XX_SZ_ADC - 1,
  265. .flags = IORESOURCE_MEM,
  266. },
  267. [1] = {
  268. .start = IRQ_TC,
  269. .end = IRQ_TC,
  270. .flags = IORESOURCE_IRQ,
  271. },
  272. [2] = {
  273. .start = IRQ_ADC,
  274. .end = IRQ_ADC,
  275. .flags = IORESOURCE_IRQ,
  276. }
  277. };
  278. struct platform_device s3c_device_adc = {
  279. .name = "s3c24xx-adc",
  280. .id = -1,
  281. .num_resources = ARRAY_SIZE(s3c_adc_resource),
  282. .resource = s3c_adc_resource,
  283. };
  284. /* SDI */
  285. static struct resource s3c_sdi_resource[] = {
  286. [0] = {
  287. .start = S3C24XX_PA_SDI,
  288. .end = S3C24XX_PA_SDI + S3C24XX_SZ_SDI - 1,
  289. .flags = IORESOURCE_MEM,
  290. },
  291. [1] = {
  292. .start = IRQ_SDI,
  293. .end = IRQ_SDI,
  294. .flags = IORESOURCE_IRQ,
  295. }
  296. };
  297. struct platform_device s3c_device_sdi = {
  298. .name = "s3c2410-sdi",
  299. .id = -1,
  300. .num_resources = ARRAY_SIZE(s3c_sdi_resource),
  301. .resource = s3c_sdi_resource,
  302. };
  303. EXPORT_SYMBOL(s3c_device_sdi);
  304. void __init s3c24xx_mci_set_platdata(struct s3c24xx_mci_pdata *pdata)
  305. {
  306. struct s3c24xx_mci_pdata *npd;
  307. npd = kmemdup(pdata, sizeof(struct s3c24xx_mci_pdata), GFP_KERNEL);
  308. if (!npd)
  309. printk(KERN_ERR "%s: no memory to copy pdata", __func__);
  310. s3c_device_sdi.dev.platform_data = npd;
  311. }
  312. /* SPI (0) */
  313. static struct resource s3c_spi0_resource[] = {
  314. [0] = {
  315. .start = S3C24XX_PA_SPI,
  316. .end = S3C24XX_PA_SPI + 0x1f,
  317. .flags = IORESOURCE_MEM,
  318. },
  319. [1] = {
  320. .start = IRQ_SPI0,
  321. .end = IRQ_SPI0,
  322. .flags = IORESOURCE_IRQ,
  323. }
  324. };
  325. static u64 s3c_device_spi0_dmamask = 0xffffffffUL;
  326. struct platform_device s3c_device_spi0 = {
  327. .name = "s3c2410-spi",
  328. .id = 0,
  329. .num_resources = ARRAY_SIZE(s3c_spi0_resource),
  330. .resource = s3c_spi0_resource,
  331. .dev = {
  332. .dma_mask = &s3c_device_spi0_dmamask,
  333. .coherent_dma_mask = 0xffffffffUL
  334. }
  335. };
  336. EXPORT_SYMBOL(s3c_device_spi0);
  337. /* SPI (1) */
  338. static struct resource s3c_spi1_resource[] = {
  339. [0] = {
  340. .start = S3C24XX_PA_SPI + S3C2410_SPI1,
  341. .end = S3C24XX_PA_SPI + S3C2410_SPI1 + 0x1f,
  342. .flags = IORESOURCE_MEM,
  343. },
  344. [1] = {
  345. .start = IRQ_SPI1,
  346. .end = IRQ_SPI1,
  347. .flags = IORESOURCE_IRQ,
  348. }
  349. };
  350. static u64 s3c_device_spi1_dmamask = 0xffffffffUL;
  351. struct platform_device s3c_device_spi1 = {
  352. .name = "s3c2410-spi",
  353. .id = 1,
  354. .num_resources = ARRAY_SIZE(s3c_spi1_resource),
  355. .resource = s3c_spi1_resource,
  356. .dev = {
  357. .dma_mask = &s3c_device_spi1_dmamask,
  358. .coherent_dma_mask = 0xffffffffUL
  359. }
  360. };
  361. EXPORT_SYMBOL(s3c_device_spi1);
  362. #ifdef CONFIG_CPU_S3C2440
  363. /* Camif Controller */
  364. static struct resource s3c_camif_resource[] = {
  365. [0] = {
  366. .start = S3C2440_PA_CAMIF,
  367. .end = S3C2440_PA_CAMIF + S3C2440_SZ_CAMIF - 1,
  368. .flags = IORESOURCE_MEM,
  369. },
  370. [1] = {
  371. .start = IRQ_CAM,
  372. .end = IRQ_CAM,
  373. .flags = IORESOURCE_IRQ,
  374. }
  375. };
  376. static u64 s3c_device_camif_dmamask = 0xffffffffUL;
  377. struct platform_device s3c_device_camif = {
  378. .name = "s3c2440-camif",
  379. .id = -1,
  380. .num_resources = ARRAY_SIZE(s3c_camif_resource),
  381. .resource = s3c_camif_resource,
  382. .dev = {
  383. .dma_mask = &s3c_device_camif_dmamask,
  384. .coherent_dma_mask = 0xffffffffUL
  385. }
  386. };
  387. EXPORT_SYMBOL(s3c_device_camif);
  388. /* AC97 */
  389. static struct resource s3c_ac97_resource[] = {
  390. [0] = {
  391. .start = S3C2440_PA_AC97,
  392. .end = S3C2440_PA_AC97 + S3C2440_SZ_AC97 -1,
  393. .flags = IORESOURCE_MEM,
  394. },
  395. [1] = {
  396. .start = IRQ_S3C244x_AC97,
  397. .end = IRQ_S3C244x_AC97,
  398. .flags = IORESOURCE_IRQ,
  399. },
  400. [2] = {
  401. .name = "PCM out",
  402. .start = DMACH_PCM_OUT,
  403. .end = DMACH_PCM_OUT,
  404. .flags = IORESOURCE_DMA,
  405. },
  406. [3] = {
  407. .name = "PCM in",
  408. .start = DMACH_PCM_IN,
  409. .end = DMACH_PCM_IN,
  410. .flags = IORESOURCE_DMA,
  411. },
  412. [4] = {
  413. .name = "Mic in",
  414. .start = DMACH_MIC_IN,
  415. .end = DMACH_MIC_IN,
  416. .flags = IORESOURCE_DMA,
  417. },
  418. };
  419. struct platform_device s3c_device_ac97 = {
  420. .name = "s3c-ac97",
  421. .id = -1,
  422. .num_resources = ARRAY_SIZE(s3c_ac97_resource),
  423. .resource = s3c_ac97_resource,
  424. .dev = {
  425. .dma_mask = &s3c_device_audio_dmamask,
  426. .coherent_dma_mask = 0xffffffffUL
  427. }
  428. };
  429. EXPORT_SYMBOL(s3c_device_ac97);
  430. /* ASoC I2S */
  431. struct platform_device s3c2412_device_iis = {
  432. .name = "s3c2412-iis",
  433. .id = -1,
  434. .dev = {
  435. .dma_mask = &s3c_device_audio_dmamask,
  436. .coherent_dma_mask = 0xffffffffUL
  437. }
  438. };
  439. EXPORT_SYMBOL(s3c2412_device_iis);
  440. #endif // CONFIG_CPU_S32440