devs.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  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 = "s3c2410-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. /* RTC */
  226. static struct resource s3c_rtc_resource[] = {
  227. [0] = {
  228. .start = S3C24XX_PA_RTC,
  229. .end = S3C24XX_PA_RTC + 0xff,
  230. .flags = IORESOURCE_MEM,
  231. },
  232. [1] = {
  233. .start = IRQ_RTC,
  234. .end = IRQ_RTC,
  235. .flags = IORESOURCE_IRQ,
  236. },
  237. [2] = {
  238. .start = IRQ_TICK,
  239. .end = IRQ_TICK,
  240. .flags = IORESOURCE_IRQ
  241. }
  242. };
  243. struct platform_device s3c_device_rtc = {
  244. .name = "s3c2410-rtc",
  245. .id = -1,
  246. .num_resources = ARRAY_SIZE(s3c_rtc_resource),
  247. .resource = s3c_rtc_resource,
  248. };
  249. EXPORT_SYMBOL(s3c_device_rtc);
  250. /* ADC */
  251. static struct resource s3c_adc_resource[] = {
  252. [0] = {
  253. .start = S3C24XX_PA_ADC,
  254. .end = S3C24XX_PA_ADC + S3C24XX_SZ_ADC - 1,
  255. .flags = IORESOURCE_MEM,
  256. },
  257. [1] = {
  258. .start = IRQ_TC,
  259. .end = IRQ_TC,
  260. .flags = IORESOURCE_IRQ,
  261. },
  262. [2] = {
  263. .start = IRQ_ADC,
  264. .end = IRQ_ADC,
  265. .flags = IORESOURCE_IRQ,
  266. }
  267. };
  268. struct platform_device s3c_device_adc = {
  269. .name = "s3c24xx-adc",
  270. .id = -1,
  271. .num_resources = ARRAY_SIZE(s3c_adc_resource),
  272. .resource = s3c_adc_resource,
  273. };
  274. /* SDI */
  275. static struct resource s3c_sdi_resource[] = {
  276. [0] = {
  277. .start = S3C24XX_PA_SDI,
  278. .end = S3C24XX_PA_SDI + S3C24XX_SZ_SDI - 1,
  279. .flags = IORESOURCE_MEM,
  280. },
  281. [1] = {
  282. .start = IRQ_SDI,
  283. .end = IRQ_SDI,
  284. .flags = IORESOURCE_IRQ,
  285. }
  286. };
  287. struct platform_device s3c_device_sdi = {
  288. .name = "s3c2410-sdi",
  289. .id = -1,
  290. .num_resources = ARRAY_SIZE(s3c_sdi_resource),
  291. .resource = s3c_sdi_resource,
  292. };
  293. EXPORT_SYMBOL(s3c_device_sdi);
  294. void __init s3c24xx_mci_set_platdata(struct s3c24xx_mci_pdata *pdata)
  295. {
  296. struct s3c24xx_mci_pdata *npd;
  297. npd = kmemdup(pdata, sizeof(struct s3c24xx_mci_pdata), GFP_KERNEL);
  298. if (!npd)
  299. printk(KERN_ERR "%s: no memory to copy pdata", __func__);
  300. s3c_device_sdi.dev.platform_data = npd;
  301. }
  302. /* SPI (0) */
  303. static struct resource s3c_spi0_resource[] = {
  304. [0] = {
  305. .start = S3C24XX_PA_SPI,
  306. .end = S3C24XX_PA_SPI + 0x1f,
  307. .flags = IORESOURCE_MEM,
  308. },
  309. [1] = {
  310. .start = IRQ_SPI0,
  311. .end = IRQ_SPI0,
  312. .flags = IORESOURCE_IRQ,
  313. }
  314. };
  315. static u64 s3c_device_spi0_dmamask = 0xffffffffUL;
  316. struct platform_device s3c_device_spi0 = {
  317. .name = "s3c2410-spi",
  318. .id = 0,
  319. .num_resources = ARRAY_SIZE(s3c_spi0_resource),
  320. .resource = s3c_spi0_resource,
  321. .dev = {
  322. .dma_mask = &s3c_device_spi0_dmamask,
  323. .coherent_dma_mask = 0xffffffffUL
  324. }
  325. };
  326. EXPORT_SYMBOL(s3c_device_spi0);
  327. /* SPI (1) */
  328. static struct resource s3c_spi1_resource[] = {
  329. [0] = {
  330. .start = S3C24XX_PA_SPI + S3C2410_SPI1,
  331. .end = S3C24XX_PA_SPI + S3C2410_SPI1 + 0x1f,
  332. .flags = IORESOURCE_MEM,
  333. },
  334. [1] = {
  335. .start = IRQ_SPI1,
  336. .end = IRQ_SPI1,
  337. .flags = IORESOURCE_IRQ,
  338. }
  339. };
  340. static u64 s3c_device_spi1_dmamask = 0xffffffffUL;
  341. struct platform_device s3c_device_spi1 = {
  342. .name = "s3c2410-spi",
  343. .id = 1,
  344. .num_resources = ARRAY_SIZE(s3c_spi1_resource),
  345. .resource = s3c_spi1_resource,
  346. .dev = {
  347. .dma_mask = &s3c_device_spi1_dmamask,
  348. .coherent_dma_mask = 0xffffffffUL
  349. }
  350. };
  351. EXPORT_SYMBOL(s3c_device_spi1);
  352. #ifdef CONFIG_CPU_S3C2440
  353. /* Camif Controller */
  354. static struct resource s3c_camif_resource[] = {
  355. [0] = {
  356. .start = S3C2440_PA_CAMIF,
  357. .end = S3C2440_PA_CAMIF + S3C2440_SZ_CAMIF - 1,
  358. .flags = IORESOURCE_MEM,
  359. },
  360. [1] = {
  361. .start = IRQ_CAM,
  362. .end = IRQ_CAM,
  363. .flags = IORESOURCE_IRQ,
  364. }
  365. };
  366. static u64 s3c_device_camif_dmamask = 0xffffffffUL;
  367. struct platform_device s3c_device_camif = {
  368. .name = "s3c2440-camif",
  369. .id = -1,
  370. .num_resources = ARRAY_SIZE(s3c_camif_resource),
  371. .resource = s3c_camif_resource,
  372. .dev = {
  373. .dma_mask = &s3c_device_camif_dmamask,
  374. .coherent_dma_mask = 0xffffffffUL
  375. }
  376. };
  377. EXPORT_SYMBOL(s3c_device_camif);
  378. /* AC97 */
  379. static struct resource s3c_ac97_resource[] = {
  380. [0] = {
  381. .start = S3C2440_PA_AC97,
  382. .end = S3C2440_PA_AC97 + S3C2440_SZ_AC97 -1,
  383. .flags = IORESOURCE_MEM,
  384. },
  385. [1] = {
  386. .start = IRQ_S3C244x_AC97,
  387. .end = IRQ_S3C244x_AC97,
  388. .flags = IORESOURCE_IRQ,
  389. },
  390. [2] = {
  391. .name = "PCM out",
  392. .start = DMACH_PCM_OUT,
  393. .end = DMACH_PCM_OUT,
  394. .flags = IORESOURCE_DMA,
  395. },
  396. [3] = {
  397. .name = "PCM in",
  398. .start = DMACH_PCM_IN,
  399. .end = DMACH_PCM_IN,
  400. .flags = IORESOURCE_DMA,
  401. },
  402. [4] = {
  403. .name = "Mic in",
  404. .start = DMACH_MIC_IN,
  405. .end = DMACH_MIC_IN,
  406. .flags = IORESOURCE_DMA,
  407. },
  408. };
  409. static u64 s3c_device_ac97_dmamask = 0xffffffffUL;
  410. struct platform_device s3c_device_ac97 = {
  411. .name = "s3c-ac97",
  412. .id = -1,
  413. .num_resources = ARRAY_SIZE(s3c_ac97_resource),
  414. .resource = s3c_ac97_resource,
  415. .dev = {
  416. .dma_mask = &s3c_device_ac97_dmamask,
  417. .coherent_dma_mask = 0xffffffffUL
  418. }
  419. };
  420. EXPORT_SYMBOL(s3c_device_ac97);
  421. #endif // CONFIG_CPU_S32440