devs.c 39 KB

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