devs.c 11 KB

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