devs.c 12 KB

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