devs.c 39 KB

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