devs.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  1. /* linux/arch/arm/mach-s3c2410/devs.c
  2. *
  3. * Copyright (c) 2004 Simtec Electronics
  4. * Ben Dooks <ben@simtec.co.uk>
  5. *
  6. * Base S3C2410 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. * Modifications:
  13. * 15-Jan-2006 LCVR Using S3C24XX_PA_##x macro for common S3C24XX devices
  14. * 10-Mar-2005 LCVR Changed S3C2410_{VA,SZ} to S3C24XX_{VA,SZ}
  15. * 10-Feb-2005 BJD Added camera from guillaume.gourat@nexvision.tv
  16. * 29-Aug-2004 BJD Added timers 0 through 3
  17. * 29-Aug-2004 BJD Changed index of devices we only have one of to -1
  18. * 21-Aug-2004 BJD Added IRQ_TICK to RTC resources
  19. * 18-Aug-2004 BJD Created initial version
  20. */
  21. #include <linux/kernel.h>
  22. #include <linux/types.h>
  23. #include <linux/interrupt.h>
  24. #include <linux/list.h>
  25. #include <linux/timer.h>
  26. #include <linux/init.h>
  27. #include <linux/platform_device.h>
  28. #include <asm/mach/arch.h>
  29. #include <asm/mach/map.h>
  30. #include <asm/mach/irq.h>
  31. #include <asm/arch/fb.h>
  32. #include <asm/hardware.h>
  33. #include <asm/io.h>
  34. #include <asm/irq.h>
  35. #include <asm/arch/regs-serial.h>
  36. #include "devs.h"
  37. #include "cpu.h"
  38. /* Serial port registrations */
  39. static struct resource s3c2410_uart0_resource[] = {
  40. [0] = {
  41. .start = S3C2410_PA_UART0,
  42. .end = S3C2410_PA_UART0 + 0x3fff,
  43. .flags = IORESOURCE_MEM,
  44. },
  45. [1] = {
  46. .start = IRQ_S3CUART_RX0,
  47. .end = IRQ_S3CUART_ERR0,
  48. .flags = IORESOURCE_IRQ,
  49. }
  50. };
  51. static struct resource s3c2410_uart1_resource[] = {
  52. [0] = {
  53. .start = S3C2410_PA_UART1,
  54. .end = S3C2410_PA_UART1 + 0x3fff,
  55. .flags = IORESOURCE_MEM,
  56. },
  57. [1] = {
  58. .start = IRQ_S3CUART_RX1,
  59. .end = IRQ_S3CUART_ERR1,
  60. .flags = IORESOURCE_IRQ,
  61. }
  62. };
  63. static struct resource s3c2410_uart2_resource[] = {
  64. [0] = {
  65. .start = S3C2410_PA_UART2,
  66. .end = S3C2410_PA_UART2 + 0x3fff,
  67. .flags = IORESOURCE_MEM,
  68. },
  69. [1] = {
  70. .start = IRQ_S3CUART_RX2,
  71. .end = IRQ_S3CUART_ERR2,
  72. .flags = IORESOURCE_IRQ,
  73. }
  74. };
  75. struct s3c24xx_uart_resources s3c2410_uart_resources[] __initdata = {
  76. [0] = {
  77. .resources = s3c2410_uart0_resource,
  78. .nr_resources = ARRAY_SIZE(s3c2410_uart0_resource),
  79. },
  80. [1] = {
  81. .resources = s3c2410_uart1_resource,
  82. .nr_resources = ARRAY_SIZE(s3c2410_uart1_resource),
  83. },
  84. [2] = {
  85. .resources = s3c2410_uart2_resource,
  86. .nr_resources = ARRAY_SIZE(s3c2410_uart2_resource),
  87. },
  88. };
  89. /* yart devices */
  90. static struct platform_device s3c24xx_uart_device0 = {
  91. .id = 0,
  92. };
  93. static struct platform_device s3c24xx_uart_device1 = {
  94. .id = 1,
  95. };
  96. static struct platform_device s3c24xx_uart_device2 = {
  97. .id = 2,
  98. };
  99. struct platform_device *s3c24xx_uart_src[3] = {
  100. &s3c24xx_uart_device0,
  101. &s3c24xx_uart_device1,
  102. &s3c24xx_uart_device2,
  103. };
  104. struct platform_device *s3c24xx_uart_devs[3] = {
  105. };
  106. /* USB Host Controller */
  107. static struct resource s3c_usb_resource[] = {
  108. [0] = {
  109. .start = S3C24XX_PA_USBHOST,
  110. .end = S3C24XX_PA_USBHOST + S3C24XX_SZ_USBHOST - 1,
  111. .flags = IORESOURCE_MEM,
  112. },
  113. [1] = {
  114. .start = IRQ_USBH,
  115. .end = IRQ_USBH,
  116. .flags = IORESOURCE_IRQ,
  117. }
  118. };
  119. static u64 s3c_device_usb_dmamask = 0xffffffffUL;
  120. struct platform_device s3c_device_usb = {
  121. .name = "s3c2410-ohci",
  122. .id = -1,
  123. .num_resources = ARRAY_SIZE(s3c_usb_resource),
  124. .resource = s3c_usb_resource,
  125. .dev = {
  126. .dma_mask = &s3c_device_usb_dmamask,
  127. .coherent_dma_mask = 0xffffffffUL
  128. }
  129. };
  130. EXPORT_SYMBOL(s3c_device_usb);
  131. /* LCD Controller */
  132. static struct resource s3c_lcd_resource[] = {
  133. [0] = {
  134. .start = S3C24XX_PA_LCD,
  135. .end = S3C24XX_PA_LCD + S3C24XX_SZ_LCD - 1,
  136. .flags = IORESOURCE_MEM,
  137. },
  138. [1] = {
  139. .start = IRQ_LCD,
  140. .end = IRQ_LCD,
  141. .flags = IORESOURCE_IRQ,
  142. }
  143. };
  144. static u64 s3c_device_lcd_dmamask = 0xffffffffUL;
  145. struct platform_device s3c_device_lcd = {
  146. .name = "s3c2410-lcd",
  147. .id = -1,
  148. .num_resources = ARRAY_SIZE(s3c_lcd_resource),
  149. .resource = s3c_lcd_resource,
  150. .dev = {
  151. .dma_mask = &s3c_device_lcd_dmamask,
  152. .coherent_dma_mask = 0xffffffffUL
  153. }
  154. };
  155. EXPORT_SYMBOL(s3c_device_lcd);
  156. void __init s3c24xx_fb_set_platdata(struct s3c2410fb_mach_info *pd)
  157. {
  158. struct s3c2410fb_mach_info *npd;
  159. npd = kmalloc(sizeof(*npd), GFP_KERNEL);
  160. if (npd) {
  161. memcpy(npd, pd, sizeof(*npd));
  162. s3c_device_lcd.dev.platform_data = npd;
  163. } else {
  164. printk(KERN_ERR "no memory for LCD platform data\n");
  165. }
  166. }
  167. /* NAND Controller */
  168. static struct resource s3c_nand_resource[] = {
  169. [0] = {
  170. .start = S3C2410_PA_NAND,
  171. .end = S3C2410_PA_NAND + S3C24XX_SZ_NAND - 1,
  172. .flags = IORESOURCE_MEM,
  173. }
  174. };
  175. struct platform_device s3c_device_nand = {
  176. .name = "s3c2410-nand",
  177. .id = -1,
  178. .num_resources = ARRAY_SIZE(s3c_nand_resource),
  179. .resource = s3c_nand_resource,
  180. };
  181. EXPORT_SYMBOL(s3c_device_nand);
  182. /* USB Device (Gadget)*/
  183. static struct resource s3c_usbgadget_resource[] = {
  184. [0] = {
  185. .start = S3C24XX_PA_USBDEV,
  186. .end = S3C24XX_PA_USBDEV + S3C24XX_SZ_USBDEV - 1,
  187. .flags = IORESOURCE_MEM,
  188. },
  189. [1] = {
  190. .start = IRQ_USBD,
  191. .end = IRQ_USBD,
  192. .flags = IORESOURCE_IRQ,
  193. }
  194. };
  195. struct platform_device s3c_device_usbgadget = {
  196. .name = "s3c2410-usbgadget",
  197. .id = -1,
  198. .num_resources = ARRAY_SIZE(s3c_usbgadget_resource),
  199. .resource = s3c_usbgadget_resource,
  200. };
  201. EXPORT_SYMBOL(s3c_device_usbgadget);
  202. /* Watchdog */
  203. static struct resource s3c_wdt_resource[] = {
  204. [0] = {
  205. .start = S3C24XX_PA_WATCHDOG,
  206. .end = S3C24XX_PA_WATCHDOG + S3C24XX_SZ_WATCHDOG - 1,
  207. .flags = IORESOURCE_MEM,
  208. },
  209. [1] = {
  210. .start = IRQ_WDT,
  211. .end = IRQ_WDT,
  212. .flags = IORESOURCE_IRQ,
  213. }
  214. };
  215. struct platform_device s3c_device_wdt = {
  216. .name = "s3c2410-wdt",
  217. .id = -1,
  218. .num_resources = ARRAY_SIZE(s3c_wdt_resource),
  219. .resource = s3c_wdt_resource,
  220. };
  221. EXPORT_SYMBOL(s3c_device_wdt);
  222. /* I2C */
  223. static struct resource s3c_i2c_resource[] = {
  224. [0] = {
  225. .start = S3C24XX_PA_IIC,
  226. .end = S3C24XX_PA_IIC + S3C24XX_SZ_IIC - 1,
  227. .flags = IORESOURCE_MEM,
  228. },
  229. [1] = {
  230. .start = IRQ_IIC,
  231. .end = IRQ_IIC,
  232. .flags = IORESOURCE_IRQ,
  233. }
  234. };
  235. struct platform_device s3c_device_i2c = {
  236. .name = "s3c2410-i2c",
  237. .id = -1,
  238. .num_resources = ARRAY_SIZE(s3c_i2c_resource),
  239. .resource = s3c_i2c_resource,
  240. };
  241. EXPORT_SYMBOL(s3c_device_i2c);
  242. /* IIS */
  243. static struct resource s3c_iis_resource[] = {
  244. [0] = {
  245. .start = S3C24XX_PA_IIS,
  246. .end = S3C24XX_PA_IIS + S3C24XX_SZ_IIS -1,
  247. .flags = IORESOURCE_MEM,
  248. }
  249. };
  250. static u64 s3c_device_iis_dmamask = 0xffffffffUL;
  251. struct platform_device s3c_device_iis = {
  252. .name = "s3c2410-iis",
  253. .id = -1,
  254. .num_resources = ARRAY_SIZE(s3c_iis_resource),
  255. .resource = s3c_iis_resource,
  256. .dev = {
  257. .dma_mask = &s3c_device_iis_dmamask,
  258. .coherent_dma_mask = 0xffffffffUL
  259. }
  260. };
  261. EXPORT_SYMBOL(s3c_device_iis);
  262. /* RTC */
  263. static struct resource s3c_rtc_resource[] = {
  264. [0] = {
  265. .start = S3C24XX_PA_RTC,
  266. .end = S3C24XX_PA_RTC + 0xff,
  267. .flags = IORESOURCE_MEM,
  268. },
  269. [1] = {
  270. .start = IRQ_RTC,
  271. .end = IRQ_RTC,
  272. .flags = IORESOURCE_IRQ,
  273. },
  274. [2] = {
  275. .start = IRQ_TICK,
  276. .end = IRQ_TICK,
  277. .flags = IORESOURCE_IRQ
  278. }
  279. };
  280. struct platform_device s3c_device_rtc = {
  281. .name = "s3c2410-rtc",
  282. .id = -1,
  283. .num_resources = ARRAY_SIZE(s3c_rtc_resource),
  284. .resource = s3c_rtc_resource,
  285. };
  286. EXPORT_SYMBOL(s3c_device_rtc);
  287. /* ADC */
  288. static struct resource s3c_adc_resource[] = {
  289. [0] = {
  290. .start = S3C24XX_PA_ADC,
  291. .end = S3C24XX_PA_ADC + S3C24XX_SZ_ADC - 1,
  292. .flags = IORESOURCE_MEM,
  293. },
  294. [1] = {
  295. .start = IRQ_TC,
  296. .end = IRQ_TC,
  297. .flags = IORESOURCE_IRQ,
  298. },
  299. [2] = {
  300. .start = IRQ_ADC,
  301. .end = IRQ_ADC,
  302. .flags = IORESOURCE_IRQ,
  303. }
  304. };
  305. struct platform_device s3c_device_adc = {
  306. .name = "s3c2410-adc",
  307. .id = -1,
  308. .num_resources = ARRAY_SIZE(s3c_adc_resource),
  309. .resource = s3c_adc_resource,
  310. };
  311. /* SDI */
  312. static struct resource s3c_sdi_resource[] = {
  313. [0] = {
  314. .start = S3C2410_PA_SDI,
  315. .end = S3C2410_PA_SDI + S3C24XX_SZ_SDI - 1,
  316. .flags = IORESOURCE_MEM,
  317. },
  318. [1] = {
  319. .start = IRQ_SDI,
  320. .end = IRQ_SDI,
  321. .flags = IORESOURCE_IRQ,
  322. }
  323. };
  324. struct platform_device s3c_device_sdi = {
  325. .name = "s3c2410-sdi",
  326. .id = -1,
  327. .num_resources = ARRAY_SIZE(s3c_sdi_resource),
  328. .resource = s3c_sdi_resource,
  329. };
  330. EXPORT_SYMBOL(s3c_device_sdi);
  331. /* SPI (0) */
  332. static struct resource s3c_spi0_resource[] = {
  333. [0] = {
  334. .start = S3C24XX_PA_SPI,
  335. .end = S3C24XX_PA_SPI + 0x1f,
  336. .flags = IORESOURCE_MEM,
  337. },
  338. [1] = {
  339. .start = IRQ_SPI0,
  340. .end = IRQ_SPI0,
  341. .flags = IORESOURCE_IRQ,
  342. }
  343. };
  344. static u64 s3c_device_spi0_dmamask = 0xffffffffUL;
  345. struct platform_device s3c_device_spi0 = {
  346. .name = "s3c2410-spi",
  347. .id = 0,
  348. .num_resources = ARRAY_SIZE(s3c_spi0_resource),
  349. .resource = s3c_spi0_resource,
  350. .dev = {
  351. .dma_mask = &s3c_device_spi0_dmamask,
  352. .coherent_dma_mask = 0xffffffffUL
  353. }
  354. };
  355. EXPORT_SYMBOL(s3c_device_spi0);
  356. /* SPI (1) */
  357. static struct resource s3c_spi1_resource[] = {
  358. [0] = {
  359. .start = S3C24XX_PA_SPI + 0x20,
  360. .end = S3C24XX_PA_SPI + 0x20 + 0x1f,
  361. .flags = IORESOURCE_MEM,
  362. },
  363. [1] = {
  364. .start = IRQ_SPI1,
  365. .end = IRQ_SPI1,
  366. .flags = IORESOURCE_IRQ,
  367. }
  368. };
  369. static u64 s3c_device_spi1_dmamask = 0xffffffffUL;
  370. struct platform_device s3c_device_spi1 = {
  371. .name = "s3c2410-spi",
  372. .id = 1,
  373. .num_resources = ARRAY_SIZE(s3c_spi1_resource),
  374. .resource = s3c_spi1_resource,
  375. .dev = {
  376. .dma_mask = &s3c_device_spi1_dmamask,
  377. .coherent_dma_mask = 0xffffffffUL
  378. }
  379. };
  380. EXPORT_SYMBOL(s3c_device_spi1);
  381. /* pwm timer blocks */
  382. static struct resource s3c_timer0_resource[] = {
  383. [0] = {
  384. .start = S3C24XX_PA_TIMER + 0x0C,
  385. .end = S3C24XX_PA_TIMER + 0x0C + 0xB,
  386. .flags = IORESOURCE_MEM,
  387. },
  388. [1] = {
  389. .start = IRQ_TIMER0,
  390. .end = IRQ_TIMER0,
  391. .flags = IORESOURCE_IRQ,
  392. }
  393. };
  394. struct platform_device s3c_device_timer0 = {
  395. .name = "s3c2410-timer",
  396. .id = 0,
  397. .num_resources = ARRAY_SIZE(s3c_timer0_resource),
  398. .resource = s3c_timer0_resource,
  399. };
  400. EXPORT_SYMBOL(s3c_device_timer0);
  401. /* timer 1 */
  402. static struct resource s3c_timer1_resource[] = {
  403. [0] = {
  404. .start = S3C24XX_PA_TIMER + 0x18,
  405. .end = S3C24XX_PA_TIMER + 0x23,
  406. .flags = IORESOURCE_MEM,
  407. },
  408. [1] = {
  409. .start = IRQ_TIMER1,
  410. .end = IRQ_TIMER1,
  411. .flags = IORESOURCE_IRQ,
  412. }
  413. };
  414. struct platform_device s3c_device_timer1 = {
  415. .name = "s3c2410-timer",
  416. .id = 1,
  417. .num_resources = ARRAY_SIZE(s3c_timer1_resource),
  418. .resource = s3c_timer1_resource,
  419. };
  420. EXPORT_SYMBOL(s3c_device_timer1);
  421. /* timer 2 */
  422. static struct resource s3c_timer2_resource[] = {
  423. [0] = {
  424. .start = S3C24XX_PA_TIMER + 0x24,
  425. .end = S3C24XX_PA_TIMER + 0x2F,
  426. .flags = IORESOURCE_MEM,
  427. },
  428. [1] = {
  429. .start = IRQ_TIMER2,
  430. .end = IRQ_TIMER2,
  431. .flags = IORESOURCE_IRQ,
  432. }
  433. };
  434. struct platform_device s3c_device_timer2 = {
  435. .name = "s3c2410-timer",
  436. .id = 2,
  437. .num_resources = ARRAY_SIZE(s3c_timer2_resource),
  438. .resource = s3c_timer2_resource,
  439. };
  440. EXPORT_SYMBOL(s3c_device_timer2);
  441. /* timer 3 */
  442. static struct resource s3c_timer3_resource[] = {
  443. [0] = {
  444. .start = S3C24XX_PA_TIMER + 0x30,
  445. .end = S3C24XX_PA_TIMER + 0x3B,
  446. .flags = IORESOURCE_MEM,
  447. },
  448. [1] = {
  449. .start = IRQ_TIMER3,
  450. .end = IRQ_TIMER3,
  451. .flags = IORESOURCE_IRQ,
  452. }
  453. };
  454. struct platform_device s3c_device_timer3 = {
  455. .name = "s3c2410-timer",
  456. .id = 3,
  457. .num_resources = ARRAY_SIZE(s3c_timer3_resource),
  458. .resource = s3c_timer3_resource,
  459. };
  460. EXPORT_SYMBOL(s3c_device_timer3);
  461. #ifdef CONFIG_CPU_S3C2440
  462. /* Camif Controller */
  463. static struct resource s3c_camif_resource[] = {
  464. [0] = {
  465. .start = S3C2440_PA_CAMIF,
  466. .end = S3C2440_PA_CAMIF + S3C2440_SZ_CAMIF - 1,
  467. .flags = IORESOURCE_MEM,
  468. },
  469. [1] = {
  470. .start = IRQ_CAM,
  471. .end = IRQ_CAM,
  472. .flags = IORESOURCE_IRQ,
  473. }
  474. };
  475. static u64 s3c_device_camif_dmamask = 0xffffffffUL;
  476. struct platform_device s3c_device_camif = {
  477. .name = "s3c2440-camif",
  478. .id = -1,
  479. .num_resources = ARRAY_SIZE(s3c_camif_resource),
  480. .resource = s3c_camif_resource,
  481. .dev = {
  482. .dma_mask = &s3c_device_camif_dmamask,
  483. .coherent_dma_mask = 0xffffffffUL
  484. }
  485. };
  486. EXPORT_SYMBOL(s3c_device_camif);
  487. #endif // CONFIG_CPU_S32440