devs.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  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. EXPORT_SYMBOL(s3c24xx_ts_set_platdata);
  174. /* USB Device (Gadget)*/
  175. static struct resource s3c_usbgadget_resource[] = {
  176. [0] = {
  177. .start = S3C24XX_PA_USBDEV,
  178. .end = S3C24XX_PA_USBDEV + S3C24XX_SZ_USBDEV - 1,
  179. .flags = IORESOURCE_MEM,
  180. },
  181. [1] = {
  182. .start = IRQ_USBD,
  183. .end = IRQ_USBD,
  184. .flags = IORESOURCE_IRQ,
  185. }
  186. };
  187. struct platform_device s3c_device_usbgadget = {
  188. .name = "s3c2410-usbgadget",
  189. .id = -1,
  190. .num_resources = ARRAY_SIZE(s3c_usbgadget_resource),
  191. .resource = s3c_usbgadget_resource,
  192. };
  193. EXPORT_SYMBOL(s3c_device_usbgadget);
  194. void __init s3c24xx_udc_set_platdata(struct s3c2410_udc_mach_info *pd)
  195. {
  196. struct s3c2410_udc_mach_info *npd;
  197. npd = kmalloc(sizeof(*npd), GFP_KERNEL);
  198. if (npd) {
  199. memcpy(npd, pd, sizeof(*npd));
  200. s3c_device_usbgadget.dev.platform_data = npd;
  201. } else {
  202. printk(KERN_ERR "no memory for udc platform data\n");
  203. }
  204. }
  205. /* IIS */
  206. static struct resource s3c_iis_resource[] = {
  207. [0] = {
  208. .start = S3C24XX_PA_IIS,
  209. .end = S3C24XX_PA_IIS + S3C24XX_SZ_IIS -1,
  210. .flags = IORESOURCE_MEM,
  211. }
  212. };
  213. static u64 s3c_device_iis_dmamask = 0xffffffffUL;
  214. struct platform_device s3c_device_iis = {
  215. .name = "s3c24xx-iis",
  216. .id = -1,
  217. .num_resources = ARRAY_SIZE(s3c_iis_resource),
  218. .resource = s3c_iis_resource,
  219. .dev = {
  220. .dma_mask = &s3c_device_iis_dmamask,
  221. .coherent_dma_mask = 0xffffffffUL
  222. }
  223. };
  224. EXPORT_SYMBOL(s3c_device_iis);
  225. /* ASoC PCM DMA */
  226. static u64 s3c_device_audio_dmamask = 0xffffffffUL;
  227. struct platform_device s3c_device_pcm = {
  228. .name = "s3c24xx-pcm-audio",
  229. .id = -1,
  230. .dev = {
  231. .dma_mask = &s3c_device_audio_dmamask,
  232. .coherent_dma_mask = 0xffffffffUL
  233. }
  234. };
  235. EXPORT_SYMBOL(s3c_device_pcm);
  236. /* RTC */
  237. static struct resource s3c_rtc_resource[] = {
  238. [0] = {
  239. .start = S3C24XX_PA_RTC,
  240. .end = S3C24XX_PA_RTC + 0xff,
  241. .flags = IORESOURCE_MEM,
  242. },
  243. [1] = {
  244. .start = IRQ_RTC,
  245. .end = IRQ_RTC,
  246. .flags = IORESOURCE_IRQ,
  247. },
  248. [2] = {
  249. .start = IRQ_TICK,
  250. .end = IRQ_TICK,
  251. .flags = IORESOURCE_IRQ
  252. }
  253. };
  254. struct platform_device s3c_device_rtc = {
  255. .name = "s3c2410-rtc",
  256. .id = -1,
  257. .num_resources = ARRAY_SIZE(s3c_rtc_resource),
  258. .resource = s3c_rtc_resource,
  259. };
  260. EXPORT_SYMBOL(s3c_device_rtc);
  261. /* ADC */
  262. static struct resource s3c_adc_resource[] = {
  263. [0] = {
  264. .start = S3C24XX_PA_ADC,
  265. .end = S3C24XX_PA_ADC + S3C24XX_SZ_ADC - 1,
  266. .flags = IORESOURCE_MEM,
  267. },
  268. [1] = {
  269. .start = IRQ_TC,
  270. .end = IRQ_TC,
  271. .flags = IORESOURCE_IRQ,
  272. },
  273. [2] = {
  274. .start = IRQ_ADC,
  275. .end = IRQ_ADC,
  276. .flags = IORESOURCE_IRQ,
  277. }
  278. };
  279. struct platform_device s3c_device_adc = {
  280. .name = "s3c24xx-adc",
  281. .id = -1,
  282. .num_resources = ARRAY_SIZE(s3c_adc_resource),
  283. .resource = s3c_adc_resource,
  284. };
  285. /* SDI */
  286. static struct resource s3c_sdi_resource[] = {
  287. [0] = {
  288. .start = S3C24XX_PA_SDI,
  289. .end = S3C24XX_PA_SDI + S3C24XX_SZ_SDI - 1,
  290. .flags = IORESOURCE_MEM,
  291. },
  292. [1] = {
  293. .start = IRQ_SDI,
  294. .end = IRQ_SDI,
  295. .flags = IORESOURCE_IRQ,
  296. }
  297. };
  298. struct platform_device s3c_device_sdi = {
  299. .name = "s3c2410-sdi",
  300. .id = -1,
  301. .num_resources = ARRAY_SIZE(s3c_sdi_resource),
  302. .resource = s3c_sdi_resource,
  303. };
  304. EXPORT_SYMBOL(s3c_device_sdi);
  305. void __init s3c24xx_mci_set_platdata(struct s3c24xx_mci_pdata *pdata)
  306. {
  307. struct s3c24xx_mci_pdata *npd;
  308. npd = kmemdup(pdata, sizeof(struct s3c24xx_mci_pdata), GFP_KERNEL);
  309. if (!npd)
  310. printk(KERN_ERR "%s: no memory to copy pdata", __func__);
  311. s3c_device_sdi.dev.platform_data = npd;
  312. }
  313. /* SPI (0) */
  314. static struct resource s3c_spi0_resource[] = {
  315. [0] = {
  316. .start = S3C24XX_PA_SPI,
  317. .end = S3C24XX_PA_SPI + 0x1f,
  318. .flags = IORESOURCE_MEM,
  319. },
  320. [1] = {
  321. .start = IRQ_SPI0,
  322. .end = IRQ_SPI0,
  323. .flags = IORESOURCE_IRQ,
  324. }
  325. };
  326. static u64 s3c_device_spi0_dmamask = 0xffffffffUL;
  327. struct platform_device s3c_device_spi0 = {
  328. .name = "s3c2410-spi",
  329. .id = 0,
  330. .num_resources = ARRAY_SIZE(s3c_spi0_resource),
  331. .resource = s3c_spi0_resource,
  332. .dev = {
  333. .dma_mask = &s3c_device_spi0_dmamask,
  334. .coherent_dma_mask = 0xffffffffUL
  335. }
  336. };
  337. EXPORT_SYMBOL(s3c_device_spi0);
  338. /* SPI (1) */
  339. static struct resource s3c_spi1_resource[] = {
  340. [0] = {
  341. .start = S3C24XX_PA_SPI + S3C2410_SPI1,
  342. .end = S3C24XX_PA_SPI + S3C2410_SPI1 + 0x1f,
  343. .flags = IORESOURCE_MEM,
  344. },
  345. [1] = {
  346. .start = IRQ_SPI1,
  347. .end = IRQ_SPI1,
  348. .flags = IORESOURCE_IRQ,
  349. }
  350. };
  351. static u64 s3c_device_spi1_dmamask = 0xffffffffUL;
  352. struct platform_device s3c_device_spi1 = {
  353. .name = "s3c2410-spi",
  354. .id = 1,
  355. .num_resources = ARRAY_SIZE(s3c_spi1_resource),
  356. .resource = s3c_spi1_resource,
  357. .dev = {
  358. .dma_mask = &s3c_device_spi1_dmamask,
  359. .coherent_dma_mask = 0xffffffffUL
  360. }
  361. };
  362. EXPORT_SYMBOL(s3c_device_spi1);
  363. #ifdef CONFIG_CPU_S3C2440
  364. /* Camif Controller */
  365. static struct resource s3c_camif_resource[] = {
  366. [0] = {
  367. .start = S3C2440_PA_CAMIF,
  368. .end = S3C2440_PA_CAMIF + S3C2440_SZ_CAMIF - 1,
  369. .flags = IORESOURCE_MEM,
  370. },
  371. [1] = {
  372. .start = IRQ_CAM,
  373. .end = IRQ_CAM,
  374. .flags = IORESOURCE_IRQ,
  375. }
  376. };
  377. static u64 s3c_device_camif_dmamask = 0xffffffffUL;
  378. struct platform_device s3c_device_camif = {
  379. .name = "s3c2440-camif",
  380. .id = -1,
  381. .num_resources = ARRAY_SIZE(s3c_camif_resource),
  382. .resource = s3c_camif_resource,
  383. .dev = {
  384. .dma_mask = &s3c_device_camif_dmamask,
  385. .coherent_dma_mask = 0xffffffffUL
  386. }
  387. };
  388. EXPORT_SYMBOL(s3c_device_camif);
  389. /* AC97 */
  390. static struct resource s3c_ac97_resource[] = {
  391. [0] = {
  392. .start = S3C2440_PA_AC97,
  393. .end = S3C2440_PA_AC97 + S3C2440_SZ_AC97 -1,
  394. .flags = IORESOURCE_MEM,
  395. },
  396. [1] = {
  397. .start = IRQ_S3C244x_AC97,
  398. .end = IRQ_S3C244x_AC97,
  399. .flags = IORESOURCE_IRQ,
  400. },
  401. [2] = {
  402. .name = "PCM out",
  403. .start = DMACH_PCM_OUT,
  404. .end = DMACH_PCM_OUT,
  405. .flags = IORESOURCE_DMA,
  406. },
  407. [3] = {
  408. .name = "PCM in",
  409. .start = DMACH_PCM_IN,
  410. .end = DMACH_PCM_IN,
  411. .flags = IORESOURCE_DMA,
  412. },
  413. [4] = {
  414. .name = "Mic in",
  415. .start = DMACH_MIC_IN,
  416. .end = DMACH_MIC_IN,
  417. .flags = IORESOURCE_DMA,
  418. },
  419. };
  420. struct platform_device s3c_device_ac97 = {
  421. .name = "s3c-ac97",
  422. .id = -1,
  423. .num_resources = ARRAY_SIZE(s3c_ac97_resource),
  424. .resource = s3c_ac97_resource,
  425. .dev = {
  426. .dma_mask = &s3c_device_audio_dmamask,
  427. .coherent_dma_mask = 0xffffffffUL
  428. }
  429. };
  430. EXPORT_SYMBOL(s3c_device_ac97);
  431. /* ASoC I2S */
  432. struct platform_device s3c2412_device_iis = {
  433. .name = "s3c2412-iis",
  434. .id = -1,
  435. .dev = {
  436. .dma_mask = &s3c_device_audio_dmamask,
  437. .coherent_dma_mask = 0xffffffffUL
  438. }
  439. };
  440. EXPORT_SYMBOL(s3c2412_device_iis);
  441. #endif // CONFIG_CPU_S32440