devs.c 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582
  1. /* linux/arch/arm/plat-samsung/devs.c
  2. *
  3. * Copyright (c) 2011 Samsung Electronics Co., Ltd.
  4. * http://www.samsung.com
  5. *
  6. * Base SAMSUNG 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. #include <linux/kernel.h>
  13. #include <linux/types.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/list.h>
  16. #include <linux/timer.h>
  17. #include <linux/init.h>
  18. #include <linux/serial_core.h>
  19. #include <linux/platform_device.h>
  20. #include <linux/io.h>
  21. #include <linux/slab.h>
  22. #include <linux/string.h>
  23. #include <linux/dma-mapping.h>
  24. #include <linux/fb.h>
  25. #include <linux/gfp.h>
  26. #include <linux/mtd/mtd.h>
  27. #include <linux/mtd/onenand.h>
  28. #include <linux/mtd/partitions.h>
  29. #include <linux/mmc/host.h>
  30. #include <linux/ioport.h>
  31. #include <linux/platform_data/s3c-hsudc.h>
  32. #include <asm/irq.h>
  33. #include <asm/pmu.h>
  34. #include <asm/mach/arch.h>
  35. #include <asm/mach/map.h>
  36. #include <asm/mach/irq.h>
  37. #include <mach/hardware.h>
  38. #include <mach/dma.h>
  39. #include <mach/irqs.h>
  40. #include <mach/map.h>
  41. #include <plat/cpu.h>
  42. #include <plat/devs.h>
  43. #include <plat/adc.h>
  44. #include <plat/ata.h>
  45. #include <plat/ehci.h>
  46. #include <plat/fb.h>
  47. #include <plat/fb-s3c2410.h>
  48. #include <plat/hwmon.h>
  49. #include <plat/iic.h>
  50. #include <plat/keypad.h>
  51. #include <plat/mci.h>
  52. #include <plat/nand.h>
  53. #include <plat/sdhci.h>
  54. #include <plat/ts.h>
  55. #include <plat/udc.h>
  56. #include <plat/usb-control.h>
  57. #include <plat/usb-phy.h>
  58. #include <plat/regs-iic.h>
  59. #include <plat/regs-serial.h>
  60. #include <plat/regs-spi.h>
  61. #include <plat/s3c64xx-spi.h>
  62. static u64 samsung_device_dma_mask = DMA_BIT_MASK(32);
  63. /* AC97 */
  64. #ifdef CONFIG_CPU_S3C2440
  65. static struct resource s3c_ac97_resource[] = {
  66. [0] = DEFINE_RES_MEM(S3C2440_PA_AC97, S3C2440_SZ_AC97),
  67. [1] = DEFINE_RES_IRQ(IRQ_S3C244X_AC97),
  68. [2] = DEFINE_RES_DMA_NAMED(DMACH_PCM_OUT, "PCM out"),
  69. [3] = DEFINE_RES_DMA_NAMED(DMACH_PCM_IN, "PCM in"),
  70. [4] = DEFINE_RES_DMA_NAMED(DMACH_MIC_IN, "Mic in"),
  71. };
  72. struct platform_device s3c_device_ac97 = {
  73. .name = "samsung-ac97",
  74. .id = -1,
  75. .num_resources = ARRAY_SIZE(s3c_ac97_resource),
  76. .resource = s3c_ac97_resource,
  77. .dev = {
  78. .dma_mask = &samsung_device_dma_mask,
  79. .coherent_dma_mask = DMA_BIT_MASK(32),
  80. }
  81. };
  82. #endif /* CONFIG_CPU_S3C2440 */
  83. /* ADC */
  84. #ifdef CONFIG_PLAT_S3C24XX
  85. static struct resource s3c_adc_resource[] = {
  86. [0] = DEFINE_RES_MEM(S3C24XX_PA_ADC, S3C24XX_SZ_ADC),
  87. [1] = DEFINE_RES_IRQ(IRQ_TC),
  88. [2] = DEFINE_RES_IRQ(IRQ_ADC),
  89. };
  90. struct platform_device s3c_device_adc = {
  91. .name = "s3c24xx-adc",
  92. .id = -1,
  93. .num_resources = ARRAY_SIZE(s3c_adc_resource),
  94. .resource = s3c_adc_resource,
  95. };
  96. #endif /* CONFIG_PLAT_S3C24XX */
  97. #if defined(CONFIG_SAMSUNG_DEV_ADC)
  98. static struct resource s3c_adc_resource[] = {
  99. [0] = DEFINE_RES_MEM(SAMSUNG_PA_ADC, SZ_256),
  100. [1] = DEFINE_RES_IRQ(IRQ_TC),
  101. [2] = DEFINE_RES_IRQ(IRQ_ADC),
  102. };
  103. struct platform_device s3c_device_adc = {
  104. .name = "samsung-adc",
  105. .id = -1,
  106. .num_resources = ARRAY_SIZE(s3c_adc_resource),
  107. .resource = s3c_adc_resource,
  108. };
  109. #endif /* CONFIG_SAMSUNG_DEV_ADC */
  110. /* Camif Controller */
  111. #ifdef CONFIG_CPU_S3C2440
  112. static struct resource s3c_camif_resource[] = {
  113. [0] = DEFINE_RES_MEM(S3C2440_PA_CAMIF, S3C2440_SZ_CAMIF),
  114. [1] = DEFINE_RES_IRQ(IRQ_CAM),
  115. };
  116. struct platform_device s3c_device_camif = {
  117. .name = "s3c2440-camif",
  118. .id = -1,
  119. .num_resources = ARRAY_SIZE(s3c_camif_resource),
  120. .resource = s3c_camif_resource,
  121. .dev = {
  122. .dma_mask = &samsung_device_dma_mask,
  123. .coherent_dma_mask = DMA_BIT_MASK(32),
  124. }
  125. };
  126. #endif /* CONFIG_CPU_S3C2440 */
  127. /* ASOC DMA */
  128. struct platform_device samsung_asoc_dma = {
  129. .name = "samsung-audio",
  130. .id = -1,
  131. .dev = {
  132. .dma_mask = &samsung_device_dma_mask,
  133. .coherent_dma_mask = DMA_BIT_MASK(32),
  134. }
  135. };
  136. struct platform_device samsung_asoc_idma = {
  137. .name = "samsung-idma",
  138. .id = -1,
  139. .dev = {
  140. .dma_mask = &samsung_device_dma_mask,
  141. .coherent_dma_mask = DMA_BIT_MASK(32),
  142. }
  143. };
  144. /* FB */
  145. #ifdef CONFIG_S3C_DEV_FB
  146. static struct resource s3c_fb_resource[] = {
  147. [0] = DEFINE_RES_MEM(S3C_PA_FB, SZ_16K),
  148. [1] = DEFINE_RES_IRQ(IRQ_LCD_VSYNC),
  149. [2] = DEFINE_RES_IRQ(IRQ_LCD_FIFO),
  150. [3] = DEFINE_RES_IRQ(IRQ_LCD_SYSTEM),
  151. };
  152. struct platform_device s3c_device_fb = {
  153. .name = "s3c-fb",
  154. .id = -1,
  155. .num_resources = ARRAY_SIZE(s3c_fb_resource),
  156. .resource = s3c_fb_resource,
  157. .dev = {
  158. .dma_mask = &samsung_device_dma_mask,
  159. .coherent_dma_mask = DMA_BIT_MASK(32),
  160. },
  161. };
  162. void __init s3c_fb_set_platdata(struct s3c_fb_platdata *pd)
  163. {
  164. s3c_set_platdata(pd, sizeof(struct s3c_fb_platdata),
  165. &s3c_device_fb);
  166. }
  167. #endif /* CONFIG_S3C_DEV_FB */
  168. /* FIMC */
  169. #ifdef CONFIG_S5P_DEV_FIMC0
  170. static struct resource s5p_fimc0_resource[] = {
  171. [0] = DEFINE_RES_MEM(S5P_PA_FIMC0, SZ_4K),
  172. [1] = DEFINE_RES_IRQ(IRQ_FIMC0),
  173. };
  174. struct platform_device s5p_device_fimc0 = {
  175. .name = "s5p-fimc",
  176. .id = 0,
  177. .num_resources = ARRAY_SIZE(s5p_fimc0_resource),
  178. .resource = s5p_fimc0_resource,
  179. .dev = {
  180. .dma_mask = &samsung_device_dma_mask,
  181. .coherent_dma_mask = DMA_BIT_MASK(32),
  182. },
  183. };
  184. struct platform_device s5p_device_fimc_md = {
  185. .name = "s5p-fimc-md",
  186. .id = -1,
  187. };
  188. #endif /* CONFIG_S5P_DEV_FIMC0 */
  189. #ifdef CONFIG_S5P_DEV_FIMC1
  190. static struct resource s5p_fimc1_resource[] = {
  191. [0] = DEFINE_RES_MEM(S5P_PA_FIMC1, SZ_4K),
  192. [1] = DEFINE_RES_IRQ(IRQ_FIMC1),
  193. };
  194. struct platform_device s5p_device_fimc1 = {
  195. .name = "s5p-fimc",
  196. .id = 1,
  197. .num_resources = ARRAY_SIZE(s5p_fimc1_resource),
  198. .resource = s5p_fimc1_resource,
  199. .dev = {
  200. .dma_mask = &samsung_device_dma_mask,
  201. .coherent_dma_mask = DMA_BIT_MASK(32),
  202. },
  203. };
  204. #endif /* CONFIG_S5P_DEV_FIMC1 */
  205. #ifdef CONFIG_S5P_DEV_FIMC2
  206. static struct resource s5p_fimc2_resource[] = {
  207. [0] = DEFINE_RES_MEM(S5P_PA_FIMC2, SZ_4K),
  208. [1] = DEFINE_RES_IRQ(IRQ_FIMC2),
  209. };
  210. struct platform_device s5p_device_fimc2 = {
  211. .name = "s5p-fimc",
  212. .id = 2,
  213. .num_resources = ARRAY_SIZE(s5p_fimc2_resource),
  214. .resource = s5p_fimc2_resource,
  215. .dev = {
  216. .dma_mask = &samsung_device_dma_mask,
  217. .coherent_dma_mask = DMA_BIT_MASK(32),
  218. },
  219. };
  220. #endif /* CONFIG_S5P_DEV_FIMC2 */
  221. #ifdef CONFIG_S5P_DEV_FIMC3
  222. static struct resource s5p_fimc3_resource[] = {
  223. [0] = DEFINE_RES_MEM(S5P_PA_FIMC3, SZ_4K),
  224. [1] = DEFINE_RES_IRQ(IRQ_FIMC3),
  225. };
  226. struct platform_device s5p_device_fimc3 = {
  227. .name = "s5p-fimc",
  228. .id = 3,
  229. .num_resources = ARRAY_SIZE(s5p_fimc3_resource),
  230. .resource = s5p_fimc3_resource,
  231. .dev = {
  232. .dma_mask = &samsung_device_dma_mask,
  233. .coherent_dma_mask = DMA_BIT_MASK(32),
  234. },
  235. };
  236. #endif /* CONFIG_S5P_DEV_FIMC3 */
  237. /* FIMD0 */
  238. #ifdef CONFIG_S5P_DEV_FIMD0
  239. static struct resource s5p_fimd0_resource[] = {
  240. [0] = DEFINE_RES_MEM(S5P_PA_FIMD0, SZ_32K),
  241. [1] = DEFINE_RES_IRQ(IRQ_FIMD0_VSYNC),
  242. [2] = DEFINE_RES_IRQ(IRQ_FIMD0_FIFO),
  243. [3] = DEFINE_RES_IRQ(IRQ_FIMD0_SYSTEM),
  244. };
  245. struct platform_device s5p_device_fimd0 = {
  246. .name = "s5p-fb",
  247. .id = 0,
  248. .num_resources = ARRAY_SIZE(s5p_fimd0_resource),
  249. .resource = s5p_fimd0_resource,
  250. .dev = {
  251. .dma_mask = &samsung_device_dma_mask,
  252. .coherent_dma_mask = DMA_BIT_MASK(32),
  253. },
  254. };
  255. void __init s5p_fimd0_set_platdata(struct s3c_fb_platdata *pd)
  256. {
  257. s3c_set_platdata(pd, sizeof(struct s3c_fb_platdata),
  258. &s5p_device_fimd0);
  259. }
  260. #endif /* CONFIG_S5P_DEV_FIMD0 */
  261. /* HWMON */
  262. #ifdef CONFIG_S3C_DEV_HWMON
  263. struct platform_device s3c_device_hwmon = {
  264. .name = "s3c-hwmon",
  265. .id = -1,
  266. .dev.parent = &s3c_device_adc.dev,
  267. };
  268. void __init s3c_hwmon_set_platdata(struct s3c_hwmon_pdata *pd)
  269. {
  270. s3c_set_platdata(pd, sizeof(struct s3c_hwmon_pdata),
  271. &s3c_device_hwmon);
  272. }
  273. #endif /* CONFIG_S3C_DEV_HWMON */
  274. /* HSMMC */
  275. #ifdef CONFIG_S3C_DEV_HSMMC
  276. static struct resource s3c_hsmmc_resource[] = {
  277. [0] = DEFINE_RES_MEM(S3C_PA_HSMMC0, SZ_4K),
  278. [1] = DEFINE_RES_IRQ(IRQ_HSMMC0),
  279. };
  280. struct s3c_sdhci_platdata s3c_hsmmc0_def_platdata = {
  281. .max_width = 4,
  282. .host_caps = (MMC_CAP_4_BIT_DATA |
  283. MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
  284. .clk_type = S3C_SDHCI_CLK_DIV_INTERNAL,
  285. };
  286. struct platform_device s3c_device_hsmmc0 = {
  287. .name = "s3c-sdhci",
  288. .id = 0,
  289. .num_resources = ARRAY_SIZE(s3c_hsmmc_resource),
  290. .resource = s3c_hsmmc_resource,
  291. .dev = {
  292. .dma_mask = &samsung_device_dma_mask,
  293. .coherent_dma_mask = DMA_BIT_MASK(32),
  294. .platform_data = &s3c_hsmmc0_def_platdata,
  295. },
  296. };
  297. void s3c_sdhci0_set_platdata(struct s3c_sdhci_platdata *pd)
  298. {
  299. s3c_sdhci_set_platdata(pd, &s3c_hsmmc0_def_platdata);
  300. }
  301. #endif /* CONFIG_S3C_DEV_HSMMC */
  302. #ifdef CONFIG_S3C_DEV_HSMMC1
  303. static struct resource s3c_hsmmc1_resource[] = {
  304. [0] = DEFINE_RES_MEM(S3C_PA_HSMMC1, SZ_4K),
  305. [1] = DEFINE_RES_IRQ(IRQ_HSMMC1),
  306. };
  307. struct s3c_sdhci_platdata s3c_hsmmc1_def_platdata = {
  308. .max_width = 4,
  309. .host_caps = (MMC_CAP_4_BIT_DATA |
  310. MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
  311. .clk_type = S3C_SDHCI_CLK_DIV_INTERNAL,
  312. };
  313. struct platform_device s3c_device_hsmmc1 = {
  314. .name = "s3c-sdhci",
  315. .id = 1,
  316. .num_resources = ARRAY_SIZE(s3c_hsmmc1_resource),
  317. .resource = s3c_hsmmc1_resource,
  318. .dev = {
  319. .dma_mask = &samsung_device_dma_mask,
  320. .coherent_dma_mask = DMA_BIT_MASK(32),
  321. .platform_data = &s3c_hsmmc1_def_platdata,
  322. },
  323. };
  324. void s3c_sdhci1_set_platdata(struct s3c_sdhci_platdata *pd)
  325. {
  326. s3c_sdhci_set_platdata(pd, &s3c_hsmmc1_def_platdata);
  327. }
  328. #endif /* CONFIG_S3C_DEV_HSMMC1 */
  329. /* HSMMC2 */
  330. #ifdef CONFIG_S3C_DEV_HSMMC2
  331. static struct resource s3c_hsmmc2_resource[] = {
  332. [0] = DEFINE_RES_MEM(S3C_PA_HSMMC2, SZ_4K),
  333. [1] = DEFINE_RES_IRQ(IRQ_HSMMC2),
  334. };
  335. struct s3c_sdhci_platdata s3c_hsmmc2_def_platdata = {
  336. .max_width = 4,
  337. .host_caps = (MMC_CAP_4_BIT_DATA |
  338. MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
  339. .clk_type = S3C_SDHCI_CLK_DIV_INTERNAL,
  340. };
  341. struct platform_device s3c_device_hsmmc2 = {
  342. .name = "s3c-sdhci",
  343. .id = 2,
  344. .num_resources = ARRAY_SIZE(s3c_hsmmc2_resource),
  345. .resource = s3c_hsmmc2_resource,
  346. .dev = {
  347. .dma_mask = &samsung_device_dma_mask,
  348. .coherent_dma_mask = DMA_BIT_MASK(32),
  349. .platform_data = &s3c_hsmmc2_def_platdata,
  350. },
  351. };
  352. void s3c_sdhci2_set_platdata(struct s3c_sdhci_platdata *pd)
  353. {
  354. s3c_sdhci_set_platdata(pd, &s3c_hsmmc2_def_platdata);
  355. }
  356. #endif /* CONFIG_S3C_DEV_HSMMC2 */
  357. #ifdef CONFIG_S3C_DEV_HSMMC3
  358. static struct resource s3c_hsmmc3_resource[] = {
  359. [0] = DEFINE_RES_MEM(S3C_PA_HSMMC3, SZ_4K),
  360. [1] = DEFINE_RES_IRQ(IRQ_HSMMC3),
  361. };
  362. struct s3c_sdhci_platdata s3c_hsmmc3_def_platdata = {
  363. .max_width = 4,
  364. .host_caps = (MMC_CAP_4_BIT_DATA |
  365. MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
  366. .clk_type = S3C_SDHCI_CLK_DIV_INTERNAL,
  367. };
  368. struct platform_device s3c_device_hsmmc3 = {
  369. .name = "s3c-sdhci",
  370. .id = 3,
  371. .num_resources = ARRAY_SIZE(s3c_hsmmc3_resource),
  372. .resource = s3c_hsmmc3_resource,
  373. .dev = {
  374. .dma_mask = &samsung_device_dma_mask,
  375. .coherent_dma_mask = DMA_BIT_MASK(32),
  376. .platform_data = &s3c_hsmmc3_def_platdata,
  377. },
  378. };
  379. void s3c_sdhci3_set_platdata(struct s3c_sdhci_platdata *pd)
  380. {
  381. s3c_sdhci_set_platdata(pd, &s3c_hsmmc3_def_platdata);
  382. }
  383. #endif /* CONFIG_S3C_DEV_HSMMC3 */
  384. /* I2C */
  385. static struct resource s3c_i2c0_resource[] = {
  386. [0] = DEFINE_RES_MEM(S3C_PA_IIC, SZ_4K),
  387. [1] = DEFINE_RES_IRQ(IRQ_IIC),
  388. };
  389. struct platform_device s3c_device_i2c0 = {
  390. .name = "s3c2410-i2c",
  391. #ifdef CONFIG_S3C_DEV_I2C1
  392. .id = 0,
  393. #else
  394. .id = -1,
  395. #endif
  396. .num_resources = ARRAY_SIZE(s3c_i2c0_resource),
  397. .resource = s3c_i2c0_resource,
  398. };
  399. struct s3c2410_platform_i2c default_i2c_data __initdata = {
  400. .flags = 0,
  401. .slave_addr = 0x10,
  402. .frequency = 100*1000,
  403. .sda_delay = 100,
  404. };
  405. void __init s3c_i2c0_set_platdata(struct s3c2410_platform_i2c *pd)
  406. {
  407. struct s3c2410_platform_i2c *npd;
  408. if (!pd) {
  409. pd = &default_i2c_data;
  410. pd->bus_num = 0;
  411. }
  412. npd = s3c_set_platdata(pd, sizeof(struct s3c2410_platform_i2c),
  413. &s3c_device_i2c0);
  414. if (!npd->cfg_gpio)
  415. npd->cfg_gpio = s3c_i2c0_cfg_gpio;
  416. }
  417. #ifdef CONFIG_S3C_DEV_I2C1
  418. static struct resource s3c_i2c1_resource[] = {
  419. [0] = DEFINE_RES_MEM(S3C_PA_IIC1, SZ_4K),
  420. [1] = DEFINE_RES_IRQ(IRQ_IIC1),
  421. };
  422. struct platform_device s3c_device_i2c1 = {
  423. .name = "s3c2410-i2c",
  424. .id = 1,
  425. .num_resources = ARRAY_SIZE(s3c_i2c1_resource),
  426. .resource = s3c_i2c1_resource,
  427. };
  428. void __init s3c_i2c1_set_platdata(struct s3c2410_platform_i2c *pd)
  429. {
  430. struct s3c2410_platform_i2c *npd;
  431. if (!pd) {
  432. pd = &default_i2c_data;
  433. pd->bus_num = 1;
  434. }
  435. npd = s3c_set_platdata(pd, sizeof(struct s3c2410_platform_i2c),
  436. &s3c_device_i2c1);
  437. if (!npd->cfg_gpio)
  438. npd->cfg_gpio = s3c_i2c1_cfg_gpio;
  439. }
  440. #endif /* CONFIG_S3C_DEV_I2C1 */
  441. #ifdef CONFIG_S3C_DEV_I2C2
  442. static struct resource s3c_i2c2_resource[] = {
  443. [0] = DEFINE_RES_MEM(S3C_PA_IIC2, SZ_4K),
  444. [1] = DEFINE_RES_IRQ(IRQ_IIC2),
  445. };
  446. struct platform_device s3c_device_i2c2 = {
  447. .name = "s3c2410-i2c",
  448. .id = 2,
  449. .num_resources = ARRAY_SIZE(s3c_i2c2_resource),
  450. .resource = s3c_i2c2_resource,
  451. };
  452. void __init s3c_i2c2_set_platdata(struct s3c2410_platform_i2c *pd)
  453. {
  454. struct s3c2410_platform_i2c *npd;
  455. if (!pd) {
  456. pd = &default_i2c_data;
  457. pd->bus_num = 2;
  458. }
  459. npd = s3c_set_platdata(pd, sizeof(struct s3c2410_platform_i2c),
  460. &s3c_device_i2c2);
  461. if (!npd->cfg_gpio)
  462. npd->cfg_gpio = s3c_i2c2_cfg_gpio;
  463. }
  464. #endif /* CONFIG_S3C_DEV_I2C2 */
  465. #ifdef CONFIG_S3C_DEV_I2C3
  466. static struct resource s3c_i2c3_resource[] = {
  467. [0] = DEFINE_RES_MEM(S3C_PA_IIC3, SZ_4K),
  468. [1] = DEFINE_RES_IRQ(IRQ_IIC3),
  469. };
  470. struct platform_device s3c_device_i2c3 = {
  471. .name = "s3c2440-i2c",
  472. .id = 3,
  473. .num_resources = ARRAY_SIZE(s3c_i2c3_resource),
  474. .resource = s3c_i2c3_resource,
  475. };
  476. void __init s3c_i2c3_set_platdata(struct s3c2410_platform_i2c *pd)
  477. {
  478. struct s3c2410_platform_i2c *npd;
  479. if (!pd) {
  480. pd = &default_i2c_data;
  481. pd->bus_num = 3;
  482. }
  483. npd = s3c_set_platdata(pd, sizeof(struct s3c2410_platform_i2c),
  484. &s3c_device_i2c3);
  485. if (!npd->cfg_gpio)
  486. npd->cfg_gpio = s3c_i2c3_cfg_gpio;
  487. }
  488. #endif /*CONFIG_S3C_DEV_I2C3 */
  489. #ifdef CONFIG_S3C_DEV_I2C4
  490. static struct resource s3c_i2c4_resource[] = {
  491. [0] = DEFINE_RES_MEM(S3C_PA_IIC4, SZ_4K),
  492. [1] = DEFINE_RES_IRQ(IRQ_IIC4),
  493. };
  494. struct platform_device s3c_device_i2c4 = {
  495. .name = "s3c2440-i2c",
  496. .id = 4,
  497. .num_resources = ARRAY_SIZE(s3c_i2c4_resource),
  498. .resource = s3c_i2c4_resource,
  499. };
  500. void __init s3c_i2c4_set_platdata(struct s3c2410_platform_i2c *pd)
  501. {
  502. struct s3c2410_platform_i2c *npd;
  503. if (!pd) {
  504. pd = &default_i2c_data;
  505. pd->bus_num = 4;
  506. }
  507. npd = s3c_set_platdata(pd, sizeof(struct s3c2410_platform_i2c),
  508. &s3c_device_i2c4);
  509. if (!npd->cfg_gpio)
  510. npd->cfg_gpio = s3c_i2c4_cfg_gpio;
  511. }
  512. #endif /*CONFIG_S3C_DEV_I2C4 */
  513. #ifdef CONFIG_S3C_DEV_I2C5
  514. static struct resource s3c_i2c5_resource[] = {
  515. [0] = DEFINE_RES_MEM(S3C_PA_IIC5, SZ_4K),
  516. [1] = DEFINE_RES_IRQ(IRQ_IIC5),
  517. };
  518. struct platform_device s3c_device_i2c5 = {
  519. .name = "s3c2440-i2c",
  520. .id = 5,
  521. .num_resources = ARRAY_SIZE(s3c_i2c5_resource),
  522. .resource = s3c_i2c5_resource,
  523. };
  524. void __init s3c_i2c5_set_platdata(struct s3c2410_platform_i2c *pd)
  525. {
  526. struct s3c2410_platform_i2c *npd;
  527. if (!pd) {
  528. pd = &default_i2c_data;
  529. pd->bus_num = 5;
  530. }
  531. npd = s3c_set_platdata(pd, sizeof(struct s3c2410_platform_i2c),
  532. &s3c_device_i2c5);
  533. if (!npd->cfg_gpio)
  534. npd->cfg_gpio = s3c_i2c5_cfg_gpio;
  535. }
  536. #endif /*CONFIG_S3C_DEV_I2C5 */
  537. #ifdef CONFIG_S3C_DEV_I2C6
  538. static struct resource s3c_i2c6_resource[] = {
  539. [0] = DEFINE_RES_MEM(S3C_PA_IIC6, SZ_4K),
  540. [1] = DEFINE_RES_IRQ(IRQ_IIC6),
  541. };
  542. struct platform_device s3c_device_i2c6 = {
  543. .name = "s3c2440-i2c",
  544. .id = 6,
  545. .num_resources = ARRAY_SIZE(s3c_i2c6_resource),
  546. .resource = s3c_i2c6_resource,
  547. };
  548. void __init s3c_i2c6_set_platdata(struct s3c2410_platform_i2c *pd)
  549. {
  550. struct s3c2410_platform_i2c *npd;
  551. if (!pd) {
  552. pd = &default_i2c_data;
  553. pd->bus_num = 6;
  554. }
  555. npd = s3c_set_platdata(pd, sizeof(struct s3c2410_platform_i2c),
  556. &s3c_device_i2c6);
  557. if (!npd->cfg_gpio)
  558. npd->cfg_gpio = s3c_i2c6_cfg_gpio;
  559. }
  560. #endif /* CONFIG_S3C_DEV_I2C6 */
  561. #ifdef CONFIG_S3C_DEV_I2C7
  562. static struct resource s3c_i2c7_resource[] = {
  563. [0] = DEFINE_RES_MEM(S3C_PA_IIC7, SZ_4K),
  564. [1] = DEFINE_RES_IRQ(IRQ_IIC7),
  565. };
  566. struct platform_device s3c_device_i2c7 = {
  567. .name = "s3c2440-i2c",
  568. .id = 7,
  569. .num_resources = ARRAY_SIZE(s3c_i2c7_resource),
  570. .resource = s3c_i2c7_resource,
  571. };
  572. void __init s3c_i2c7_set_platdata(struct s3c2410_platform_i2c *pd)
  573. {
  574. struct s3c2410_platform_i2c *npd;
  575. if (!pd) {
  576. pd = &default_i2c_data;
  577. pd->bus_num = 7;
  578. }
  579. npd = s3c_set_platdata(pd, sizeof(struct s3c2410_platform_i2c),
  580. &s3c_device_i2c7);
  581. if (!npd->cfg_gpio)
  582. npd->cfg_gpio = s3c_i2c7_cfg_gpio;
  583. }
  584. #endif /* CONFIG_S3C_DEV_I2C7 */
  585. /* I2C HDMIPHY */
  586. #ifdef CONFIG_S5P_DEV_I2C_HDMIPHY
  587. static struct resource s5p_i2c_resource[] = {
  588. [0] = DEFINE_RES_MEM(S5P_PA_IIC_HDMIPHY, SZ_4K),
  589. [1] = DEFINE_RES_IRQ(IRQ_IIC_HDMIPHY),
  590. };
  591. struct platform_device s5p_device_i2c_hdmiphy = {
  592. .name = "s3c2440-hdmiphy-i2c",
  593. .id = -1,
  594. .num_resources = ARRAY_SIZE(s5p_i2c_resource),
  595. .resource = s5p_i2c_resource,
  596. };
  597. void __init s5p_i2c_hdmiphy_set_platdata(struct s3c2410_platform_i2c *pd)
  598. {
  599. struct s3c2410_platform_i2c *npd;
  600. if (!pd) {
  601. pd = &default_i2c_data;
  602. if (soc_is_exynos4210())
  603. pd->bus_num = 8;
  604. else if (soc_is_s5pv210())
  605. pd->bus_num = 3;
  606. else
  607. pd->bus_num = 0;
  608. }
  609. npd = s3c_set_platdata(pd, sizeof(struct s3c2410_platform_i2c),
  610. &s5p_device_i2c_hdmiphy);
  611. }
  612. #endif /* CONFIG_S5P_DEV_I2C_HDMIPHY */
  613. /* I2S */
  614. #ifdef CONFIG_PLAT_S3C24XX
  615. static struct resource s3c_iis_resource[] = {
  616. [0] = DEFINE_RES_MEM(S3C24XX_PA_IIS, S3C24XX_SZ_IIS),
  617. };
  618. struct platform_device s3c_device_iis = {
  619. .name = "s3c24xx-iis",
  620. .id = -1,
  621. .num_resources = ARRAY_SIZE(s3c_iis_resource),
  622. .resource = s3c_iis_resource,
  623. .dev = {
  624. .dma_mask = &samsung_device_dma_mask,
  625. .coherent_dma_mask = DMA_BIT_MASK(32),
  626. }
  627. };
  628. #endif /* CONFIG_PLAT_S3C24XX */
  629. /* IDE CFCON */
  630. #ifdef CONFIG_SAMSUNG_DEV_IDE
  631. static struct resource s3c_cfcon_resource[] = {
  632. [0] = DEFINE_RES_MEM(SAMSUNG_PA_CFCON, SZ_16K),
  633. [1] = DEFINE_RES_IRQ(IRQ_CFCON),
  634. };
  635. struct platform_device s3c_device_cfcon = {
  636. .id = 0,
  637. .num_resources = ARRAY_SIZE(s3c_cfcon_resource),
  638. .resource = s3c_cfcon_resource,
  639. };
  640. void s3c_ide_set_platdata(struct s3c_ide_platdata *pdata)
  641. {
  642. s3c_set_platdata(pdata, sizeof(struct s3c_ide_platdata),
  643. &s3c_device_cfcon);
  644. }
  645. #endif /* CONFIG_SAMSUNG_DEV_IDE */
  646. /* KEYPAD */
  647. #ifdef CONFIG_SAMSUNG_DEV_KEYPAD
  648. static struct resource samsung_keypad_resources[] = {
  649. [0] = DEFINE_RES_MEM(SAMSUNG_PA_KEYPAD, SZ_32),
  650. [1] = DEFINE_RES_IRQ(IRQ_KEYPAD),
  651. };
  652. struct platform_device samsung_device_keypad = {
  653. .name = "samsung-keypad",
  654. .id = -1,
  655. .num_resources = ARRAY_SIZE(samsung_keypad_resources),
  656. .resource = samsung_keypad_resources,
  657. };
  658. void __init samsung_keypad_set_platdata(struct samsung_keypad_platdata *pd)
  659. {
  660. struct samsung_keypad_platdata *npd;
  661. npd = s3c_set_platdata(pd, sizeof(struct samsung_keypad_platdata),
  662. &samsung_device_keypad);
  663. if (!npd->cfg_gpio)
  664. npd->cfg_gpio = samsung_keypad_cfg_gpio;
  665. }
  666. #endif /* CONFIG_SAMSUNG_DEV_KEYPAD */
  667. /* LCD Controller */
  668. #ifdef CONFIG_PLAT_S3C24XX
  669. static struct resource s3c_lcd_resource[] = {
  670. [0] = DEFINE_RES_MEM(S3C24XX_PA_LCD, S3C24XX_SZ_LCD),
  671. [1] = DEFINE_RES_IRQ(IRQ_LCD),
  672. };
  673. struct platform_device s3c_device_lcd = {
  674. .name = "s3c2410-lcd",
  675. .id = -1,
  676. .num_resources = ARRAY_SIZE(s3c_lcd_resource),
  677. .resource = s3c_lcd_resource,
  678. .dev = {
  679. .dma_mask = &samsung_device_dma_mask,
  680. .coherent_dma_mask = DMA_BIT_MASK(32),
  681. }
  682. };
  683. void __init s3c24xx_fb_set_platdata(struct s3c2410fb_mach_info *pd)
  684. {
  685. struct s3c2410fb_mach_info *npd;
  686. npd = s3c_set_platdata(pd, sizeof(*npd), &s3c_device_lcd);
  687. if (npd) {
  688. npd->displays = kmemdup(pd->displays,
  689. sizeof(struct s3c2410fb_display) * npd->num_displays,
  690. GFP_KERNEL);
  691. if (!npd->displays)
  692. printk(KERN_ERR "no memory for LCD display data\n");
  693. } else {
  694. printk(KERN_ERR "no memory for LCD platform data\n");
  695. }
  696. }
  697. #endif /* CONFIG_PLAT_S3C24XX */
  698. /* MFC */
  699. #ifdef CONFIG_S5P_DEV_MFC
  700. static struct resource s5p_mfc_resource[] = {
  701. [0] = DEFINE_RES_MEM(S5P_PA_MFC, SZ_64K),
  702. [1] = DEFINE_RES_IRQ(IRQ_MFC),
  703. };
  704. struct platform_device s5p_device_mfc = {
  705. .name = "s5p-mfc",
  706. .id = -1,
  707. .num_resources = ARRAY_SIZE(s5p_mfc_resource),
  708. .resource = s5p_mfc_resource,
  709. };
  710. /*
  711. * MFC hardware has 2 memory interfaces which are modelled as two separate
  712. * platform devices to let dma-mapping distinguish between them.
  713. *
  714. * MFC parent device (s5p_device_mfc) must be registered before memory
  715. * interface specific devices (s5p_device_mfc_l and s5p_device_mfc_r).
  716. */
  717. struct platform_device s5p_device_mfc_l = {
  718. .name = "s5p-mfc-l",
  719. .id = -1,
  720. .dev = {
  721. .parent = &s5p_device_mfc.dev,
  722. .dma_mask = &samsung_device_dma_mask,
  723. .coherent_dma_mask = DMA_BIT_MASK(32),
  724. },
  725. };
  726. struct platform_device s5p_device_mfc_r = {
  727. .name = "s5p-mfc-r",
  728. .id = -1,
  729. .dev = {
  730. .parent = &s5p_device_mfc.dev,
  731. .dma_mask = &samsung_device_dma_mask,
  732. .coherent_dma_mask = DMA_BIT_MASK(32),
  733. },
  734. };
  735. #endif /* CONFIG_S5P_DEV_MFC */
  736. /* MIPI CSIS */
  737. #ifdef CONFIG_S5P_DEV_CSIS0
  738. static struct resource s5p_mipi_csis0_resource[] = {
  739. [0] = DEFINE_RES_MEM(S5P_PA_MIPI_CSIS0, SZ_4K),
  740. [1] = DEFINE_RES_IRQ(IRQ_MIPI_CSIS0),
  741. };
  742. struct platform_device s5p_device_mipi_csis0 = {
  743. .name = "s5p-mipi-csis",
  744. .id = 0,
  745. .num_resources = ARRAY_SIZE(s5p_mipi_csis0_resource),
  746. .resource = s5p_mipi_csis0_resource,
  747. };
  748. #endif /* CONFIG_S5P_DEV_CSIS0 */
  749. #ifdef CONFIG_S5P_DEV_CSIS1
  750. static struct resource s5p_mipi_csis1_resource[] = {
  751. [0] = DEFINE_RES_MEM(S5P_PA_MIPI_CSIS1, SZ_4K),
  752. [1] = DEFINE_RES_IRQ(IRQ_MIPI_CSIS1),
  753. };
  754. struct platform_device s5p_device_mipi_csis1 = {
  755. .name = "s5p-mipi-csis",
  756. .id = 1,
  757. .num_resources = ARRAY_SIZE(s5p_mipi_csis1_resource),
  758. .resource = s5p_mipi_csis1_resource,
  759. };
  760. #endif
  761. /* NAND */
  762. #ifdef CONFIG_S3C_DEV_NAND
  763. static struct resource s3c_nand_resource[] = {
  764. [0] = DEFINE_RES_MEM(S3C_PA_NAND, SZ_1M),
  765. };
  766. struct platform_device s3c_device_nand = {
  767. .name = "s3c2410-nand",
  768. .id = -1,
  769. .num_resources = ARRAY_SIZE(s3c_nand_resource),
  770. .resource = s3c_nand_resource,
  771. };
  772. /*
  773. * s3c_nand_copy_set() - copy nand set data
  774. * @set: The new structure, directly copied from the old.
  775. *
  776. * Copy all the fields from the NAND set field from what is probably __initdata
  777. * to new kernel memory. The code returns 0 if the copy happened correctly or
  778. * an error code for the calling function to display.
  779. *
  780. * Note, we currently do not try and look to see if we've already copied the
  781. * data in a previous set.
  782. */
  783. static int __init s3c_nand_copy_set(struct s3c2410_nand_set *set)
  784. {
  785. void *ptr;
  786. int size;
  787. size = sizeof(struct mtd_partition) * set->nr_partitions;
  788. if (size) {
  789. ptr = kmemdup(set->partitions, size, GFP_KERNEL);
  790. set->partitions = ptr;
  791. if (!ptr)
  792. return -ENOMEM;
  793. }
  794. if (set->nr_map && set->nr_chips) {
  795. size = sizeof(int) * set->nr_chips;
  796. ptr = kmemdup(set->nr_map, size, GFP_KERNEL);
  797. set->nr_map = ptr;
  798. if (!ptr)
  799. return -ENOMEM;
  800. }
  801. if (set->ecc_layout) {
  802. ptr = kmemdup(set->ecc_layout,
  803. sizeof(struct nand_ecclayout), GFP_KERNEL);
  804. set->ecc_layout = ptr;
  805. if (!ptr)
  806. return -ENOMEM;
  807. }
  808. return 0;
  809. }
  810. void __init s3c_nand_set_platdata(struct s3c2410_platform_nand *nand)
  811. {
  812. struct s3c2410_platform_nand *npd;
  813. int size;
  814. int ret;
  815. /* note, if we get a failure in allocation, we simply drop out of the
  816. * function. If there is so little memory available at initialisation
  817. * time then there is little chance the system is going to run.
  818. */
  819. npd = s3c_set_platdata(nand, sizeof(struct s3c2410_platform_nand),
  820. &s3c_device_nand);
  821. if (!npd)
  822. return;
  823. /* now see if we need to copy any of the nand set data */
  824. size = sizeof(struct s3c2410_nand_set) * npd->nr_sets;
  825. if (size) {
  826. struct s3c2410_nand_set *from = npd->sets;
  827. struct s3c2410_nand_set *to;
  828. int i;
  829. to = kmemdup(from, size, GFP_KERNEL);
  830. npd->sets = to; /* set, even if we failed */
  831. if (!to) {
  832. printk(KERN_ERR "%s: no memory for sets\n", __func__);
  833. return;
  834. }
  835. for (i = 0; i < npd->nr_sets; i++) {
  836. ret = s3c_nand_copy_set(to);
  837. if (ret) {
  838. printk(KERN_ERR "%s: failed to copy set %d\n",
  839. __func__, i);
  840. return;
  841. }
  842. to++;
  843. }
  844. }
  845. }
  846. #endif /* CONFIG_S3C_DEV_NAND */
  847. /* ONENAND */
  848. #ifdef CONFIG_S3C_DEV_ONENAND
  849. static struct resource s3c_onenand_resources[] = {
  850. [0] = DEFINE_RES_MEM(S3C_PA_ONENAND, SZ_1K),
  851. [1] = DEFINE_RES_MEM(S3C_PA_ONENAND_BUF, S3C_SZ_ONENAND_BUF),
  852. [2] = DEFINE_RES_IRQ(IRQ_ONENAND),
  853. };
  854. struct platform_device s3c_device_onenand = {
  855. .name = "samsung-onenand",
  856. .id = 0,
  857. .num_resources = ARRAY_SIZE(s3c_onenand_resources),
  858. .resource = s3c_onenand_resources,
  859. };
  860. #endif /* CONFIG_S3C_DEV_ONENAND */
  861. #ifdef CONFIG_S3C64XX_DEV_ONENAND1
  862. static struct resource s3c64xx_onenand1_resources[] = {
  863. [0] = DEFINE_RES_MEM(S3C64XX_PA_ONENAND1, SZ_1K),
  864. [1] = DEFINE_RES_MEM(S3C64XX_PA_ONENAND1_BUF, S3C64XX_SZ_ONENAND1_BUF),
  865. [2] = DEFINE_RES_IRQ(IRQ_ONENAND1),
  866. };
  867. struct platform_device s3c64xx_device_onenand1 = {
  868. .name = "samsung-onenand",
  869. .id = 1,
  870. .num_resources = ARRAY_SIZE(s3c64xx_onenand1_resources),
  871. .resource = s3c64xx_onenand1_resources,
  872. };
  873. void s3c64xx_onenand1_set_platdata(struct onenand_platform_data *pdata)
  874. {
  875. s3c_set_platdata(pdata, sizeof(struct onenand_platform_data),
  876. &s3c64xx_device_onenand1);
  877. }
  878. #endif /* CONFIG_S3C64XX_DEV_ONENAND1 */
  879. #ifdef CONFIG_S5P_DEV_ONENAND
  880. static struct resource s5p_onenand_resources[] = {
  881. [0] = DEFINE_RES_MEM(S5P_PA_ONENAND, SZ_128K),
  882. [1] = DEFINE_RES_MEM(S5P_PA_ONENAND_DMA, SZ_8K),
  883. [2] = DEFINE_RES_IRQ(IRQ_ONENAND_AUDI),
  884. };
  885. struct platform_device s5p_device_onenand = {
  886. .name = "s5pc110-onenand",
  887. .id = -1,
  888. .num_resources = ARRAY_SIZE(s5p_onenand_resources),
  889. .resource = s5p_onenand_resources,
  890. };
  891. #endif /* CONFIG_S5P_DEV_ONENAND */
  892. /* PMU */
  893. #ifdef CONFIG_PLAT_S5P
  894. static struct resource s5p_pmu_resource[] = {
  895. DEFINE_RES_IRQ(IRQ_PMU)
  896. };
  897. static struct platform_device s5p_device_pmu = {
  898. .name = "arm-pmu",
  899. .id = ARM_PMU_DEVICE_CPU,
  900. .num_resources = ARRAY_SIZE(s5p_pmu_resource),
  901. .resource = s5p_pmu_resource,
  902. };
  903. static int __init s5p_pmu_init(void)
  904. {
  905. platform_device_register(&s5p_device_pmu);
  906. return 0;
  907. }
  908. arch_initcall(s5p_pmu_init);
  909. #endif /* CONFIG_PLAT_S5P */
  910. /* PWM Timer */
  911. #ifdef CONFIG_SAMSUNG_DEV_PWM
  912. #define TIMER_RESOURCE_SIZE (1)
  913. #define TIMER_RESOURCE(_tmr, _irq) \
  914. (struct resource [TIMER_RESOURCE_SIZE]) { \
  915. [0] = { \
  916. .start = _irq, \
  917. .end = _irq, \
  918. .flags = IORESOURCE_IRQ \
  919. } \
  920. }
  921. #define DEFINE_S3C_TIMER(_tmr_no, _irq) \
  922. .name = "s3c24xx-pwm", \
  923. .id = _tmr_no, \
  924. .num_resources = TIMER_RESOURCE_SIZE, \
  925. .resource = TIMER_RESOURCE(_tmr_no, _irq), \
  926. /*
  927. * since we already have an static mapping for the timer,
  928. * we do not bother setting any IO resource for the base.
  929. */
  930. struct platform_device s3c_device_timer[] = {
  931. [0] = { DEFINE_S3C_TIMER(0, IRQ_TIMER0) },
  932. [1] = { DEFINE_S3C_TIMER(1, IRQ_TIMER1) },
  933. [2] = { DEFINE_S3C_TIMER(2, IRQ_TIMER2) },
  934. [3] = { DEFINE_S3C_TIMER(3, IRQ_TIMER3) },
  935. [4] = { DEFINE_S3C_TIMER(4, IRQ_TIMER4) },
  936. };
  937. #endif /* CONFIG_SAMSUNG_DEV_PWM */
  938. /* RTC */
  939. #ifdef CONFIG_PLAT_S3C24XX
  940. static struct resource s3c_rtc_resource[] = {
  941. [0] = DEFINE_RES_MEM(S3C24XX_PA_RTC, SZ_256),
  942. [1] = DEFINE_RES_IRQ(IRQ_RTC),
  943. [2] = DEFINE_RES_IRQ(IRQ_TICK),
  944. };
  945. struct platform_device s3c_device_rtc = {
  946. .name = "s3c2410-rtc",
  947. .id = -1,
  948. .num_resources = ARRAY_SIZE(s3c_rtc_resource),
  949. .resource = s3c_rtc_resource,
  950. };
  951. #endif /* CONFIG_PLAT_S3C24XX */
  952. #ifdef CONFIG_S3C_DEV_RTC
  953. static struct resource s3c_rtc_resource[] = {
  954. [0] = DEFINE_RES_MEM(S3C_PA_RTC, SZ_256),
  955. [1] = DEFINE_RES_IRQ(IRQ_RTC_ALARM),
  956. [2] = DEFINE_RES_IRQ(IRQ_RTC_TIC),
  957. };
  958. struct platform_device s3c_device_rtc = {
  959. .name = "s3c64xx-rtc",
  960. .id = -1,
  961. .num_resources = ARRAY_SIZE(s3c_rtc_resource),
  962. .resource = s3c_rtc_resource,
  963. };
  964. #endif /* CONFIG_S3C_DEV_RTC */
  965. /* SDI */
  966. #ifdef CONFIG_PLAT_S3C24XX
  967. static struct resource s3c_sdi_resource[] = {
  968. [0] = DEFINE_RES_MEM(S3C24XX_PA_SDI, S3C24XX_SZ_SDI),
  969. [1] = DEFINE_RES_IRQ(IRQ_SDI),
  970. };
  971. struct platform_device s3c_device_sdi = {
  972. .name = "s3c2410-sdi",
  973. .id = -1,
  974. .num_resources = ARRAY_SIZE(s3c_sdi_resource),
  975. .resource = s3c_sdi_resource,
  976. };
  977. void __init s3c24xx_mci_set_platdata(struct s3c24xx_mci_pdata *pdata)
  978. {
  979. s3c_set_platdata(pdata, sizeof(struct s3c24xx_mci_pdata),
  980. &s3c_device_sdi);
  981. }
  982. #endif /* CONFIG_PLAT_S3C24XX */
  983. /* SPI */
  984. #ifdef CONFIG_PLAT_S3C24XX
  985. static struct resource s3c_spi0_resource[] = {
  986. [0] = DEFINE_RES_MEM(S3C24XX_PA_SPI, SZ_32),
  987. [1] = DEFINE_RES_IRQ(IRQ_SPI0),
  988. };
  989. struct platform_device s3c_device_spi0 = {
  990. .name = "s3c2410-spi",
  991. .id = 0,
  992. .num_resources = ARRAY_SIZE(s3c_spi0_resource),
  993. .resource = s3c_spi0_resource,
  994. .dev = {
  995. .dma_mask = &samsung_device_dma_mask,
  996. .coherent_dma_mask = DMA_BIT_MASK(32),
  997. }
  998. };
  999. static struct resource s3c_spi1_resource[] = {
  1000. [0] = DEFINE_RES_MEM(S3C24XX_PA_SPI1, SZ_32),
  1001. [1] = DEFINE_RES_IRQ(IRQ_SPI1),
  1002. };
  1003. struct platform_device s3c_device_spi1 = {
  1004. .name = "s3c2410-spi",
  1005. .id = 1,
  1006. .num_resources = ARRAY_SIZE(s3c_spi1_resource),
  1007. .resource = s3c_spi1_resource,
  1008. .dev = {
  1009. .dma_mask = &samsung_device_dma_mask,
  1010. .coherent_dma_mask = DMA_BIT_MASK(32),
  1011. }
  1012. };
  1013. #endif /* CONFIG_PLAT_S3C24XX */
  1014. /* Touchscreen */
  1015. #ifdef CONFIG_PLAT_S3C24XX
  1016. static struct resource s3c_ts_resource[] = {
  1017. [0] = DEFINE_RES_MEM(S3C24XX_PA_ADC, S3C24XX_SZ_ADC),
  1018. [1] = DEFINE_RES_IRQ(IRQ_TC),
  1019. };
  1020. struct platform_device s3c_device_ts = {
  1021. .name = "s3c2410-ts",
  1022. .id = -1,
  1023. .dev.parent = &s3c_device_adc.dev,
  1024. .num_resources = ARRAY_SIZE(s3c_ts_resource),
  1025. .resource = s3c_ts_resource,
  1026. };
  1027. void __init s3c24xx_ts_set_platdata(struct s3c2410_ts_mach_info *hard_s3c2410ts_info)
  1028. {
  1029. s3c_set_platdata(hard_s3c2410ts_info,
  1030. sizeof(struct s3c2410_ts_mach_info), &s3c_device_ts);
  1031. }
  1032. #endif /* CONFIG_PLAT_S3C24XX */
  1033. #ifdef CONFIG_SAMSUNG_DEV_TS
  1034. static struct resource s3c_ts_resource[] = {
  1035. [0] = DEFINE_RES_MEM(SAMSUNG_PA_ADC, SZ_256),
  1036. [1] = DEFINE_RES_IRQ(IRQ_TC),
  1037. };
  1038. static struct s3c2410_ts_mach_info default_ts_data __initdata = {
  1039. .delay = 10000,
  1040. .presc = 49,
  1041. .oversampling_shift = 2,
  1042. };
  1043. struct platform_device s3c_device_ts = {
  1044. .name = "s3c64xx-ts",
  1045. .id = -1,
  1046. .num_resources = ARRAY_SIZE(s3c_ts_resource),
  1047. .resource = s3c_ts_resource,
  1048. };
  1049. void __init s3c24xx_ts_set_platdata(struct s3c2410_ts_mach_info *pd)
  1050. {
  1051. if (!pd)
  1052. pd = &default_ts_data;
  1053. s3c_set_platdata(pd, sizeof(struct s3c2410_ts_mach_info),
  1054. &s3c_device_ts);
  1055. }
  1056. #endif /* CONFIG_SAMSUNG_DEV_TS */
  1057. /* TV */
  1058. #ifdef CONFIG_S5P_DEV_TV
  1059. static struct resource s5p_hdmi_resources[] = {
  1060. [0] = DEFINE_RES_MEM(S5P_PA_HDMI, SZ_1M),
  1061. [1] = DEFINE_RES_IRQ(IRQ_HDMI),
  1062. };
  1063. struct platform_device s5p_device_hdmi = {
  1064. .name = "s5p-hdmi",
  1065. .id = -1,
  1066. .num_resources = ARRAY_SIZE(s5p_hdmi_resources),
  1067. .resource = s5p_hdmi_resources,
  1068. };
  1069. static struct resource s5p_sdo_resources[] = {
  1070. [0] = DEFINE_RES_MEM(S5P_PA_SDO, SZ_64K),
  1071. [1] = DEFINE_RES_IRQ(IRQ_SDO),
  1072. };
  1073. struct platform_device s5p_device_sdo = {
  1074. .name = "s5p-sdo",
  1075. .id = -1,
  1076. .num_resources = ARRAY_SIZE(s5p_sdo_resources),
  1077. .resource = s5p_sdo_resources,
  1078. };
  1079. static struct resource s5p_mixer_resources[] = {
  1080. [0] = DEFINE_RES_MEM_NAMED(S5P_PA_MIXER, SZ_64K, "mxr"),
  1081. [1] = DEFINE_RES_MEM_NAMED(S5P_PA_VP, SZ_64K, "vp"),
  1082. [2] = DEFINE_RES_IRQ_NAMED(IRQ_MIXER, "irq"),
  1083. };
  1084. struct platform_device s5p_device_mixer = {
  1085. .name = "s5p-mixer",
  1086. .id = -1,
  1087. .num_resources = ARRAY_SIZE(s5p_mixer_resources),
  1088. .resource = s5p_mixer_resources,
  1089. .dev = {
  1090. .dma_mask = &samsung_device_dma_mask,
  1091. .coherent_dma_mask = DMA_BIT_MASK(32),
  1092. }
  1093. };
  1094. #endif /* CONFIG_S5P_DEV_TV */
  1095. /* USB */
  1096. #ifdef CONFIG_S3C_DEV_USB_HOST
  1097. static struct resource s3c_usb_resource[] = {
  1098. [0] = DEFINE_RES_MEM(S3C_PA_USBHOST, SZ_256),
  1099. [1] = DEFINE_RES_IRQ(IRQ_USBH),
  1100. };
  1101. struct platform_device s3c_device_ohci = {
  1102. .name = "s3c2410-ohci",
  1103. .id = -1,
  1104. .num_resources = ARRAY_SIZE(s3c_usb_resource),
  1105. .resource = s3c_usb_resource,
  1106. .dev = {
  1107. .dma_mask = &samsung_device_dma_mask,
  1108. .coherent_dma_mask = DMA_BIT_MASK(32),
  1109. }
  1110. };
  1111. /*
  1112. * s3c_ohci_set_platdata - initialise OHCI device platform data
  1113. * @info: The platform data.
  1114. *
  1115. * This call copies the @info passed in and sets the device .platform_data
  1116. * field to that copy. The @info is copied so that the original can be marked
  1117. * __initdata.
  1118. */
  1119. void __init s3c_ohci_set_platdata(struct s3c2410_hcd_info *info)
  1120. {
  1121. s3c_set_platdata(info, sizeof(struct s3c2410_hcd_info),
  1122. &s3c_device_ohci);
  1123. }
  1124. #endif /* CONFIG_S3C_DEV_USB_HOST */
  1125. /* USB Device (Gadget) */
  1126. #ifdef CONFIG_PLAT_S3C24XX
  1127. static struct resource s3c_usbgadget_resource[] = {
  1128. [0] = DEFINE_RES_MEM(S3C24XX_PA_USBDEV, S3C24XX_SZ_USBDEV),
  1129. [1] = DEFINE_RES_IRQ(IRQ_USBD),
  1130. };
  1131. struct platform_device s3c_device_usbgadget = {
  1132. .name = "s3c2410-usbgadget",
  1133. .id = -1,
  1134. .num_resources = ARRAY_SIZE(s3c_usbgadget_resource),
  1135. .resource = s3c_usbgadget_resource,
  1136. };
  1137. void __init s3c24xx_udc_set_platdata(struct s3c2410_udc_mach_info *pd)
  1138. {
  1139. s3c_set_platdata(pd, sizeof(*pd), &s3c_device_usbgadget);
  1140. }
  1141. #endif /* CONFIG_PLAT_S3C24XX */
  1142. /* USB EHCI Host Controller */
  1143. #ifdef CONFIG_S5P_DEV_USB_EHCI
  1144. static struct resource s5p_ehci_resource[] = {
  1145. [0] = DEFINE_RES_MEM(S5P_PA_EHCI, SZ_256),
  1146. [1] = DEFINE_RES_IRQ(IRQ_USB_HOST),
  1147. };
  1148. struct platform_device s5p_device_ehci = {
  1149. .name = "s5p-ehci",
  1150. .id = -1,
  1151. .num_resources = ARRAY_SIZE(s5p_ehci_resource),
  1152. .resource = s5p_ehci_resource,
  1153. .dev = {
  1154. .dma_mask = &samsung_device_dma_mask,
  1155. .coherent_dma_mask = DMA_BIT_MASK(32),
  1156. }
  1157. };
  1158. void __init s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd)
  1159. {
  1160. struct s5p_ehci_platdata *npd;
  1161. npd = s3c_set_platdata(pd, sizeof(struct s5p_ehci_platdata),
  1162. &s5p_device_ehci);
  1163. if (!npd->phy_init)
  1164. npd->phy_init = s5p_usb_phy_init;
  1165. if (!npd->phy_exit)
  1166. npd->phy_exit = s5p_usb_phy_exit;
  1167. }
  1168. #endif /* CONFIG_S5P_DEV_USB_EHCI */
  1169. /* USB HSOTG */
  1170. #ifdef CONFIG_S3C_DEV_USB_HSOTG
  1171. static struct resource s3c_usb_hsotg_resources[] = {
  1172. [0] = DEFINE_RES_MEM(S3C_PA_USB_HSOTG, SZ_128K),
  1173. [1] = DEFINE_RES_IRQ(IRQ_OTG),
  1174. };
  1175. struct platform_device s3c_device_usb_hsotg = {
  1176. .name = "s3c-hsotg",
  1177. .id = -1,
  1178. .num_resources = ARRAY_SIZE(s3c_usb_hsotg_resources),
  1179. .resource = s3c_usb_hsotg_resources,
  1180. .dev = {
  1181. .dma_mask = &samsung_device_dma_mask,
  1182. .coherent_dma_mask = DMA_BIT_MASK(32),
  1183. },
  1184. };
  1185. #endif /* CONFIG_S3C_DEV_USB_HSOTG */
  1186. /* USB High Spped 2.0 Device (Gadget) */
  1187. #ifdef CONFIG_PLAT_S3C24XX
  1188. static struct resource s3c_hsudc_resource[] = {
  1189. [0] = DEFINE_RES_MEM(S3C2416_PA_HSUDC, S3C2416_SZ_HSUDC),
  1190. [1] = DEFINE_RES_IRQ(IRQ_USBD),
  1191. };
  1192. struct platform_device s3c_device_usb_hsudc = {
  1193. .name = "s3c-hsudc",
  1194. .id = -1,
  1195. .num_resources = ARRAY_SIZE(s3c_hsudc_resource),
  1196. .resource = s3c_hsudc_resource,
  1197. .dev = {
  1198. .dma_mask = &samsung_device_dma_mask,
  1199. .coherent_dma_mask = DMA_BIT_MASK(32),
  1200. },
  1201. };
  1202. void __init s3c24xx_hsudc_set_platdata(struct s3c24xx_hsudc_platdata *pd)
  1203. {
  1204. s3c_set_platdata(pd, sizeof(*pd), &s3c_device_usb_hsudc);
  1205. }
  1206. #endif /* CONFIG_PLAT_S3C24XX */
  1207. /* WDT */
  1208. #ifdef CONFIG_S3C_DEV_WDT
  1209. static struct resource s3c_wdt_resource[] = {
  1210. [0] = DEFINE_RES_MEM(S3C_PA_WDT, SZ_1K),
  1211. [1] = DEFINE_RES_IRQ(IRQ_WDT),
  1212. };
  1213. struct platform_device s3c_device_wdt = {
  1214. .name = "s3c2410-wdt",
  1215. .id = -1,
  1216. .num_resources = ARRAY_SIZE(s3c_wdt_resource),
  1217. .resource = s3c_wdt_resource,
  1218. };
  1219. #endif /* CONFIG_S3C_DEV_WDT */
  1220. #ifdef CONFIG_S3C64XX_DEV_SPI0
  1221. static struct resource s3c64xx_spi0_resource[] = {
  1222. [0] = DEFINE_RES_MEM(S3C_PA_SPI0, SZ_256),
  1223. [1] = DEFINE_RES_DMA(DMACH_SPI0_TX),
  1224. [2] = DEFINE_RES_DMA(DMACH_SPI0_RX),
  1225. [3] = DEFINE_RES_IRQ(IRQ_SPI0),
  1226. };
  1227. struct platform_device s3c64xx_device_spi0 = {
  1228. .name = "s3c64xx-spi",
  1229. .id = 0,
  1230. .num_resources = ARRAY_SIZE(s3c64xx_spi0_resource),
  1231. .resource = s3c64xx_spi0_resource,
  1232. .dev = {
  1233. .dma_mask = &samsung_device_dma_mask,
  1234. .coherent_dma_mask = DMA_BIT_MASK(32),
  1235. },
  1236. };
  1237. void __init s3c64xx_spi0_set_platdata(struct s3c64xx_spi_info *pd,
  1238. int src_clk_nr, int num_cs)
  1239. {
  1240. if (!pd) {
  1241. pr_err("%s:Need to pass platform data\n", __func__);
  1242. return;
  1243. }
  1244. /* Reject invalid configuration */
  1245. if (!num_cs || src_clk_nr < 0) {
  1246. pr_err("%s: Invalid SPI configuration\n", __func__);
  1247. return;
  1248. }
  1249. pd->num_cs = num_cs;
  1250. pd->src_clk_nr = src_clk_nr;
  1251. if (!pd->cfg_gpio)
  1252. pd->cfg_gpio = s3c64xx_spi0_cfg_gpio;
  1253. s3c_set_platdata(pd, sizeof(*pd), &s3c64xx_device_spi0);
  1254. }
  1255. #endif /* CONFIG_S3C64XX_DEV_SPI0 */
  1256. #ifdef CONFIG_S3C64XX_DEV_SPI1
  1257. static struct resource s3c64xx_spi1_resource[] = {
  1258. [0] = DEFINE_RES_MEM(S3C_PA_SPI1, SZ_256),
  1259. [1] = DEFINE_RES_DMA(DMACH_SPI1_TX),
  1260. [2] = DEFINE_RES_DMA(DMACH_SPI1_RX),
  1261. [3] = DEFINE_RES_IRQ(IRQ_SPI1),
  1262. };
  1263. struct platform_device s3c64xx_device_spi1 = {
  1264. .name = "s3c64xx-spi",
  1265. .id = 1,
  1266. .num_resources = ARRAY_SIZE(s3c64xx_spi1_resource),
  1267. .resource = s3c64xx_spi1_resource,
  1268. .dev = {
  1269. .dma_mask = &samsung_device_dma_mask,
  1270. .coherent_dma_mask = DMA_BIT_MASK(32),
  1271. },
  1272. };
  1273. void __init s3c64xx_spi1_set_platdata(struct s3c64xx_spi_info *pd,
  1274. int src_clk_nr, int num_cs)
  1275. {
  1276. if (!pd) {
  1277. pr_err("%s:Need to pass platform data\n", __func__);
  1278. return;
  1279. }
  1280. /* Reject invalid configuration */
  1281. if (!num_cs || src_clk_nr < 0) {
  1282. pr_err("%s: Invalid SPI configuration\n", __func__);
  1283. return;
  1284. }
  1285. pd->num_cs = num_cs;
  1286. pd->src_clk_nr = src_clk_nr;
  1287. if (!pd->cfg_gpio)
  1288. pd->cfg_gpio = s3c64xx_spi1_cfg_gpio;
  1289. s3c_set_platdata(pd, sizeof(*pd), &s3c64xx_device_spi1);
  1290. }
  1291. #endif /* CONFIG_S3C64XX_DEV_SPI1 */
  1292. #ifdef CONFIG_S3C64XX_DEV_SPI2
  1293. static struct resource s3c64xx_spi2_resource[] = {
  1294. [0] = DEFINE_RES_MEM(S3C_PA_SPI2, SZ_256),
  1295. [1] = DEFINE_RES_DMA(DMACH_SPI2_TX),
  1296. [2] = DEFINE_RES_DMA(DMACH_SPI2_RX),
  1297. [3] = DEFINE_RES_IRQ(IRQ_SPI2),
  1298. };
  1299. struct platform_device s3c64xx_device_spi2 = {
  1300. .name = "s3c64xx-spi",
  1301. .id = 2,
  1302. .num_resources = ARRAY_SIZE(s3c64xx_spi2_resource),
  1303. .resource = s3c64xx_spi2_resource,
  1304. .dev = {
  1305. .dma_mask = &samsung_device_dma_mask,
  1306. .coherent_dma_mask = DMA_BIT_MASK(32),
  1307. },
  1308. };
  1309. void __init s3c64xx_spi2_set_platdata(struct s3c64xx_spi_info *pd,
  1310. int src_clk_nr, int num_cs)
  1311. {
  1312. if (!pd) {
  1313. pr_err("%s:Need to pass platform data\n", __func__);
  1314. return;
  1315. }
  1316. /* Reject invalid configuration */
  1317. if (!num_cs || src_clk_nr < 0) {
  1318. pr_err("%s: Invalid SPI configuration\n", __func__);
  1319. return;
  1320. }
  1321. pd->num_cs = num_cs;
  1322. pd->src_clk_nr = src_clk_nr;
  1323. if (!pd->cfg_gpio)
  1324. pd->cfg_gpio = s3c64xx_spi2_cfg_gpio;
  1325. s3c_set_platdata(pd, sizeof(*pd), &s3c64xx_device_spi2);
  1326. }
  1327. #endif /* CONFIG_S3C64XX_DEV_SPI2 */