1 // SPDX-License-Identifier: GPL-2.0
3 // Copyright (c) 2011 Samsung Electronics Co., Ltd.
4 // http://www.samsung.com
6 // Base Samsung platform device definitions
8 #include <linux/gpio.h>
9 #include <linux/kernel.h>
10 #include <linux/types.h>
11 #include <linux/interrupt.h>
12 #include <linux/list.h>
13 #include <linux/timer.h>
14 #include <linux/init.h>
15 #include <linux/serial_core.h>
16 #include <linux/serial_s3c.h>
17 #include <linux/platform_device.h>
19 #include <linux/slab.h>
20 #include <linux/string.h>
21 #include <linux/dma-mapping.h>
23 #include <linux/gfp.h>
24 #include <linux/mmc/host.h>
25 #include <linux/ioport.h>
26 #include <linux/sizes.h>
27 #include <linux/platform_data/s3c-hsotg.h>
30 #include <asm/mach/arch.h>
31 #include <asm/mach/map.h>
32 #include <asm/mach/irq.h>
36 #include "gpio-samsung.h"
42 #include <linux/platform_data/i2c-s3c2410.h>
47 #include <linux/platform_data/asoc-s3c.h>
48 #include <linux/platform_data/spi-s3c64xx.h>
50 #define samsung_device_dma_mask (*((u64[]) { DMA_BIT_MASK(32) }))
54 #ifdef CONFIG_S3C_DEV_FB
55 static struct resource s3c_fb_resource
[] = {
56 [0] = DEFINE_RES_MEM(S3C_PA_FB
, SZ_16K
),
57 [1] = DEFINE_RES_IRQ(IRQ_LCD_VSYNC
),
58 [2] = DEFINE_RES_IRQ(IRQ_LCD_FIFO
),
59 [3] = DEFINE_RES_IRQ(IRQ_LCD_SYSTEM
),
62 struct platform_device s3c_device_fb
= {
65 .num_resources
= ARRAY_SIZE(s3c_fb_resource
),
66 .resource
= s3c_fb_resource
,
68 .dma_mask
= &samsung_device_dma_mask
,
69 .coherent_dma_mask
= DMA_BIT_MASK(32),
73 void __init
s3c_fb_set_platdata(struct s3c_fb_platdata
*pd
)
75 s3c_set_platdata(pd
, sizeof(struct s3c_fb_platdata
),
78 #endif /* CONFIG_S3C_DEV_FB */
82 #ifdef CONFIG_S3C_DEV_HSMMC
83 static struct resource s3c_hsmmc_resource
[] = {
84 [0] = DEFINE_RES_MEM(S3C_PA_HSMMC0
, SZ_4K
),
85 [1] = DEFINE_RES_IRQ(IRQ_HSMMC0
),
88 struct s3c_sdhci_platdata s3c_hsmmc0_def_platdata
= {
90 .host_caps
= (MMC_CAP_4_BIT_DATA
|
91 MMC_CAP_MMC_HIGHSPEED
| MMC_CAP_SD_HIGHSPEED
),
94 struct platform_device s3c_device_hsmmc0
= {
97 .num_resources
= ARRAY_SIZE(s3c_hsmmc_resource
),
98 .resource
= s3c_hsmmc_resource
,
100 .dma_mask
= &samsung_device_dma_mask
,
101 .coherent_dma_mask
= DMA_BIT_MASK(32),
102 .platform_data
= &s3c_hsmmc0_def_platdata
,
106 void s3c_sdhci0_set_platdata(struct s3c_sdhci_platdata
*pd
)
108 s3c_sdhci_set_platdata(pd
, &s3c_hsmmc0_def_platdata
);
110 #endif /* CONFIG_S3C_DEV_HSMMC */
112 #ifdef CONFIG_S3C_DEV_HSMMC1
113 static struct resource s3c_hsmmc1_resource
[] = {
114 [0] = DEFINE_RES_MEM(S3C_PA_HSMMC1
, SZ_4K
),
115 [1] = DEFINE_RES_IRQ(IRQ_HSMMC1
),
118 struct s3c_sdhci_platdata s3c_hsmmc1_def_platdata
= {
120 .host_caps
= (MMC_CAP_4_BIT_DATA
|
121 MMC_CAP_MMC_HIGHSPEED
| MMC_CAP_SD_HIGHSPEED
),
124 struct platform_device s3c_device_hsmmc1
= {
127 .num_resources
= ARRAY_SIZE(s3c_hsmmc1_resource
),
128 .resource
= s3c_hsmmc1_resource
,
130 .dma_mask
= &samsung_device_dma_mask
,
131 .coherent_dma_mask
= DMA_BIT_MASK(32),
132 .platform_data
= &s3c_hsmmc1_def_platdata
,
136 void s3c_sdhci1_set_platdata(struct s3c_sdhci_platdata
*pd
)
138 s3c_sdhci_set_platdata(pd
, &s3c_hsmmc1_def_platdata
);
140 #endif /* CONFIG_S3C_DEV_HSMMC1 */
144 #ifdef CONFIG_S3C_DEV_HSMMC2
145 static struct resource s3c_hsmmc2_resource
[] = {
146 [0] = DEFINE_RES_MEM(S3C_PA_HSMMC2
, SZ_4K
),
147 [1] = DEFINE_RES_IRQ(IRQ_HSMMC2
),
150 struct s3c_sdhci_platdata s3c_hsmmc2_def_platdata
= {
152 .host_caps
= (MMC_CAP_4_BIT_DATA
|
153 MMC_CAP_MMC_HIGHSPEED
| MMC_CAP_SD_HIGHSPEED
),
156 struct platform_device s3c_device_hsmmc2
= {
159 .num_resources
= ARRAY_SIZE(s3c_hsmmc2_resource
),
160 .resource
= s3c_hsmmc2_resource
,
162 .dma_mask
= &samsung_device_dma_mask
,
163 .coherent_dma_mask
= DMA_BIT_MASK(32),
164 .platform_data
= &s3c_hsmmc2_def_platdata
,
168 void s3c_sdhci2_set_platdata(struct s3c_sdhci_platdata
*pd
)
170 s3c_sdhci_set_platdata(pd
, &s3c_hsmmc2_def_platdata
);
172 #endif /* CONFIG_S3C_DEV_HSMMC2 */
174 #ifdef CONFIG_S3C_DEV_HSMMC3
175 static struct resource s3c_hsmmc3_resource
[] = {
176 [0] = DEFINE_RES_MEM(S3C_PA_HSMMC3
, SZ_4K
),
177 [1] = DEFINE_RES_IRQ(IRQ_HSMMC3
),
180 struct s3c_sdhci_platdata s3c_hsmmc3_def_platdata
= {
182 .host_caps
= (MMC_CAP_4_BIT_DATA
|
183 MMC_CAP_MMC_HIGHSPEED
| MMC_CAP_SD_HIGHSPEED
),
186 struct platform_device s3c_device_hsmmc3
= {
189 .num_resources
= ARRAY_SIZE(s3c_hsmmc3_resource
),
190 .resource
= s3c_hsmmc3_resource
,
192 .dma_mask
= &samsung_device_dma_mask
,
193 .coherent_dma_mask
= DMA_BIT_MASK(32),
194 .platform_data
= &s3c_hsmmc3_def_platdata
,
198 void s3c_sdhci3_set_platdata(struct s3c_sdhci_platdata
*pd
)
200 s3c_sdhci_set_platdata(pd
, &s3c_hsmmc3_def_platdata
);
202 #endif /* CONFIG_S3C_DEV_HSMMC3 */
206 static struct resource s3c_i2c0_resource
[] = {
207 [0] = DEFINE_RES_MEM(S3C_PA_IIC
, SZ_4K
),
208 [1] = DEFINE_RES_IRQ(IRQ_IIC
),
211 struct platform_device s3c_device_i2c0
= {
212 .name
= "s3c2410-i2c",
214 .num_resources
= ARRAY_SIZE(s3c_i2c0_resource
),
215 .resource
= s3c_i2c0_resource
,
218 struct s3c2410_platform_i2c default_i2c_data __initdata
= {
221 .frequency
= 100*1000,
225 void __init
s3c_i2c0_set_platdata(struct s3c2410_platform_i2c
*pd
)
227 struct s3c2410_platform_i2c
*npd
;
230 pd
= &default_i2c_data
;
234 npd
= s3c_set_platdata(pd
, sizeof(*npd
), &s3c_device_i2c0
);
237 npd
->cfg_gpio
= s3c_i2c0_cfg_gpio
;
240 #ifdef CONFIG_S3C_DEV_I2C1
241 static struct resource s3c_i2c1_resource
[] = {
242 [0] = DEFINE_RES_MEM(S3C_PA_IIC1
, SZ_4K
),
243 [1] = DEFINE_RES_IRQ(IRQ_IIC1
),
246 struct platform_device s3c_device_i2c1
= {
247 .name
= "s3c2410-i2c",
249 .num_resources
= ARRAY_SIZE(s3c_i2c1_resource
),
250 .resource
= s3c_i2c1_resource
,
253 void __init
s3c_i2c1_set_platdata(struct s3c2410_platform_i2c
*pd
)
255 struct s3c2410_platform_i2c
*npd
;
258 pd
= &default_i2c_data
;
262 npd
= s3c_set_platdata(pd
, sizeof(*npd
), &s3c_device_i2c1
);
265 npd
->cfg_gpio
= s3c_i2c1_cfg_gpio
;
267 #endif /* CONFIG_S3C_DEV_I2C1 */
271 #ifdef CONFIG_SAMSUNG_DEV_KEYPAD
272 static struct resource samsung_keypad_resources
[] = {
273 [0] = DEFINE_RES_MEM(SAMSUNG_PA_KEYPAD
, SZ_32
),
274 [1] = DEFINE_RES_IRQ(IRQ_KEYPAD
),
277 struct platform_device samsung_device_keypad
= {
278 .name
= "samsung-keypad",
280 .num_resources
= ARRAY_SIZE(samsung_keypad_resources
),
281 .resource
= samsung_keypad_resources
,
284 void __init
samsung_keypad_set_platdata(struct samsung_keypad_platdata
*pd
)
286 struct samsung_keypad_platdata
*npd
;
288 npd
= s3c_set_platdata(pd
, sizeof(*npd
), &samsung_device_keypad
);
291 npd
->cfg_gpio
= samsung_keypad_cfg_gpio
;
293 #endif /* CONFIG_SAMSUNG_DEV_KEYPAD */
297 #ifdef CONFIG_SAMSUNG_DEV_PWM
298 static struct resource samsung_pwm_resource
[] = {
299 DEFINE_RES_MEM(SAMSUNG_PA_TIMER
, SZ_4K
),
302 struct platform_device samsung_device_pwm
= {
303 .name
= "samsung-pwm",
305 .num_resources
= ARRAY_SIZE(samsung_pwm_resource
),
306 .resource
= samsung_pwm_resource
,
309 void __init
samsung_pwm_set_platdata(struct samsung_pwm_variant
*pd
)
311 samsung_device_pwm
.dev
.platform_data
= pd
;
313 #endif /* CONFIG_SAMSUNG_DEV_PWM */
317 #ifdef CONFIG_S3C_DEV_USB_HOST
318 static struct resource s3c_usb_resource
[] = {
319 [0] = DEFINE_RES_MEM(S3C_PA_USBHOST
, SZ_256
),
320 [1] = DEFINE_RES_IRQ(IRQ_USBH
),
323 struct platform_device s3c_device_ohci
= {
324 .name
= "s3c2410-ohci",
326 .num_resources
= ARRAY_SIZE(s3c_usb_resource
),
327 .resource
= s3c_usb_resource
,
329 .dma_mask
= &samsung_device_dma_mask
,
330 .coherent_dma_mask
= DMA_BIT_MASK(32),
333 #endif /* CONFIG_S3C_DEV_USB_HOST */
337 #ifdef CONFIG_S3C_DEV_USB_HSOTG
338 static struct resource s3c_usb_hsotg_resources
[] = {
339 [0] = DEFINE_RES_MEM(S3C_PA_USB_HSOTG
, SZ_128K
),
340 [1] = DEFINE_RES_IRQ(IRQ_OTG
),
343 struct platform_device s3c_device_usb_hsotg
= {
346 .num_resources
= ARRAY_SIZE(s3c_usb_hsotg_resources
),
347 .resource
= s3c_usb_hsotg_resources
,
349 .dma_mask
= &samsung_device_dma_mask
,
350 .coherent_dma_mask
= DMA_BIT_MASK(32),
354 void __init
dwc2_hsotg_set_platdata(struct dwc2_hsotg_plat
*pd
)
356 struct dwc2_hsotg_plat
*npd
;
358 npd
= s3c_set_platdata(pd
, sizeof(*npd
), &s3c_device_usb_hsotg
);
361 npd
->phy_init
= s3c_usb_phy_init
;
363 npd
->phy_exit
= s3c_usb_phy_exit
;
365 #endif /* CONFIG_S3C_DEV_USB_HSOTG */
367 #ifdef CONFIG_S3C64XX_DEV_SPI0
368 static struct resource s3c64xx_spi0_resource
[] = {
369 [0] = DEFINE_RES_MEM(S3C_PA_SPI0
, SZ_256
),
370 [1] = DEFINE_RES_IRQ(IRQ_SPI0
),
373 struct platform_device s3c64xx_device_spi0
= {
374 .name
= "s3c6410-spi",
376 .num_resources
= ARRAY_SIZE(s3c64xx_spi0_resource
),
377 .resource
= s3c64xx_spi0_resource
,
379 .dma_mask
= &samsung_device_dma_mask
,
380 .coherent_dma_mask
= DMA_BIT_MASK(32),
384 void __init
s3c64xx_spi0_set_platdata(int src_clk_nr
, int num_cs
)
386 struct s3c64xx_spi_info pd
;
388 /* Reject invalid configuration */
389 if (!num_cs
|| src_clk_nr
< 0) {
390 pr_err("%s: Invalid SPI configuration\n", __func__
);
395 pd
.src_clk_nr
= src_clk_nr
;
396 pd
.cfg_gpio
= s3c64xx_spi0_cfg_gpio
;
398 s3c_set_platdata(&pd
, sizeof(pd
), &s3c64xx_device_spi0
);
400 #endif /* CONFIG_S3C64XX_DEV_SPI0 */