1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * mach-davinci/devices.c
5 * DaVinci platform device setup/initialization
8 #include <linux/init.h>
9 #include <linux/platform_device.h>
10 #include <linux/platform_data/i2c-davinci.h>
11 #include <linux/platform_data/mmc-davinci.h>
12 #include <linux/platform_data/edma.h>
13 #include <linux/dma-mapping.h>
15 #include <linux/reboot.h>
17 #include <mach/hardware.h>
18 #include <mach/cputype.h>
24 #define DAVINCI_I2C_BASE 0x01C21000
25 #define DAVINCI_ATA_BASE 0x01C66000
26 #define DAVINCI_MMCSD0_BASE 0x01E10000
27 #define DM355_MMCSD0_BASE 0x01E11000
28 #define DM355_MMCSD1_BASE 0x01E00000
29 #define DM365_MMCSD0_BASE 0x01D11000
30 #define DM365_MMCSD1_BASE 0x01D00000
32 void __iomem
*davinci_sysmod_base
;
34 void davinci_map_sysmod(void)
36 davinci_sysmod_base
= ioremap(DAVINCI_SYSTEM_MODULE_BASE
,
39 * Throw a bug since a lot of board initialization code depends
40 * on system module availability. ioremap() failing this early
41 * need careful looking into anyway.
43 BUG_ON(!davinci_sysmod_base
);
46 static struct resource i2c_resources
[] = {
48 .start
= DAVINCI_I2C_BASE
,
49 .end
= DAVINCI_I2C_BASE
+ 0x40,
50 .flags
= IORESOURCE_MEM
,
53 .start
= DAVINCI_INTC_IRQ(IRQ_I2C
),
54 .flags
= IORESOURCE_IRQ
,
58 static struct platform_device davinci_i2c_device
= {
59 .name
= "i2c_davinci",
61 .num_resources
= ARRAY_SIZE(i2c_resources
),
62 .resource
= i2c_resources
,
65 void __init
davinci_init_i2c(struct davinci_i2c_platform_data
*pdata
)
67 if (cpu_is_davinci_dm644x())
68 davinci_cfg_reg(DM644X_I2C
);
70 davinci_i2c_device
.dev
.platform_data
= pdata
;
71 (void) platform_device_register(&davinci_i2c_device
);
74 static struct resource ide_resources
[] = {
76 .start
= DAVINCI_ATA_BASE
,
77 .end
= DAVINCI_ATA_BASE
+ 0x7ff,
78 .flags
= IORESOURCE_MEM
,
81 .start
= DAVINCI_INTC_IRQ(IRQ_IDE
),
82 .end
= DAVINCI_INTC_IRQ(IRQ_IDE
),
83 .flags
= IORESOURCE_IRQ
,
87 static u64 ide_dma_mask
= DMA_BIT_MASK(32);
89 static struct platform_device ide_device
= {
90 .name
= "palm_bk3710",
92 .resource
= ide_resources
,
93 .num_resources
= ARRAY_SIZE(ide_resources
),
95 .dma_mask
= &ide_dma_mask
,
96 .coherent_dma_mask
= DMA_BIT_MASK(32),
100 void __init
davinci_init_ide(void)
102 if (cpu_is_davinci_dm644x()) {
103 davinci_cfg_reg(DM644X_HPIEN_DISABLE
);
104 davinci_cfg_reg(DM644X_ATAEN
);
105 davinci_cfg_reg(DM644X_HDIREN
);
106 } else if (cpu_is_davinci_dm646x()) {
107 /* IRQ_DM646X_IDE is the same as IRQ_IDE */
108 davinci_cfg_reg(DM646X_ATAEN
);
114 platform_device_register(&ide_device
);
117 #if IS_ENABLED(CONFIG_MMC_DAVINCI)
119 static u64 mmcsd0_dma_mask
= DMA_BIT_MASK(32);
121 static struct resource mmcsd0_resources
[] = {
123 /* different on dm355 */
124 .start
= DAVINCI_MMCSD0_BASE
,
125 .end
= DAVINCI_MMCSD0_BASE
+ SZ_4K
- 1,
126 .flags
= IORESOURCE_MEM
,
128 /* IRQs: MMC/SD, then SDIO */
130 .start
= DAVINCI_INTC_IRQ(IRQ_MMCINT
),
131 .flags
= IORESOURCE_IRQ
,
133 /* different on dm355 */
134 .start
= DAVINCI_INTC_IRQ(IRQ_SDIOINT
),
135 .flags
= IORESOURCE_IRQ
,
139 static struct platform_device davinci_mmcsd0_device
= {
140 .name
= "dm6441-mmc",
143 .dma_mask
= &mmcsd0_dma_mask
,
144 .coherent_dma_mask
= DMA_BIT_MASK(32),
146 .num_resources
= ARRAY_SIZE(mmcsd0_resources
),
147 .resource
= mmcsd0_resources
,
150 static u64 mmcsd1_dma_mask
= DMA_BIT_MASK(32);
152 static struct resource mmcsd1_resources
[] = {
154 .start
= DM355_MMCSD1_BASE
,
155 .end
= DM355_MMCSD1_BASE
+ SZ_4K
- 1,
156 .flags
= IORESOURCE_MEM
,
158 /* IRQs: MMC/SD, then SDIO */
160 .start
= DAVINCI_INTC_IRQ(IRQ_DM355_MMCINT1
),
161 .flags
= IORESOURCE_IRQ
,
163 .start
= DAVINCI_INTC_IRQ(IRQ_DM355_SDIOINT1
),
164 .flags
= IORESOURCE_IRQ
,
168 static struct platform_device davinci_mmcsd1_device
= {
169 .name
= "dm6441-mmc",
172 .dma_mask
= &mmcsd1_dma_mask
,
173 .coherent_dma_mask
= DMA_BIT_MASK(32),
175 .num_resources
= ARRAY_SIZE(mmcsd1_resources
),
176 .resource
= mmcsd1_resources
,
180 void __init
davinci_setup_mmc(int module
, struct davinci_mmc_config
*config
)
182 struct platform_device
*pdev
= NULL
;
184 if (WARN_ON(cpu_is_davinci_dm646x()))
187 /* REVISIT: update PINMUX, ARM_IRQMUX, and EDMA_EVTMUX here too;
188 * for example if MMCSD1 is used for SDIO, maybe DAT2 is unused.
190 * FIXME dm6441 (no MMC/SD), dm357 (one), and dm335 (two) are
191 * not handled right here ...
195 if (cpu_is_davinci_dm355()) {
196 /* REVISIT we may not need all these pins if e.g. this
197 * is a hard-wired SDIO device...
199 davinci_cfg_reg(DM355_SD1_CMD
);
200 davinci_cfg_reg(DM355_SD1_CLK
);
201 davinci_cfg_reg(DM355_SD1_DATA0
);
202 davinci_cfg_reg(DM355_SD1_DATA1
);
203 davinci_cfg_reg(DM355_SD1_DATA2
);
204 davinci_cfg_reg(DM355_SD1_DATA3
);
205 } else if (cpu_is_davinci_dm365()) {
206 /* Configure pull down control */
209 v
= __raw_readl(DAVINCI_SYSMOD_VIRT(SYSMOD_PUPDCTL1
));
210 __raw_writel(v
& ~0xfc0,
211 DAVINCI_SYSMOD_VIRT(SYSMOD_PUPDCTL1
));
213 mmcsd1_resources
[0].start
= DM365_MMCSD1_BASE
;
214 mmcsd1_resources
[0].end
= DM365_MMCSD1_BASE
+
216 mmcsd1_resources
[2].start
= DAVINCI_INTC_IRQ(
218 davinci_mmcsd1_device
.name
= "da830-mmc";
222 pdev
= &davinci_mmcsd1_device
;
225 if (cpu_is_davinci_dm355()) {
226 mmcsd0_resources
[0].start
= DM355_MMCSD0_BASE
;
227 mmcsd0_resources
[0].end
= DM355_MMCSD0_BASE
+ SZ_4K
- 1;
228 mmcsd0_resources
[2].start
= DAVINCI_INTC_IRQ(
231 /* expose all 6 MMC0 signals: CLK, CMD, DATA[0..3] */
232 davinci_cfg_reg(DM355_MMCSD0
);
235 davinci_cfg_reg(DM355_EVT26_MMC0_RX
);
236 } else if (cpu_is_davinci_dm365()) {
237 mmcsd0_resources
[0].start
= DM365_MMCSD0_BASE
;
238 mmcsd0_resources
[0].end
= DM365_MMCSD0_BASE
+
240 mmcsd0_resources
[2].start
= DAVINCI_INTC_IRQ(
242 davinci_mmcsd0_device
.name
= "da830-mmc";
243 } else if (cpu_is_davinci_dm644x()) {
244 /* REVISIT: should this be in board-init code? */
245 /* Power-on 3.3V IO cells */
247 DAVINCI_SYSMOD_VIRT(SYSMOD_VDD3P3VPWDN
));
248 /*Set up the pull regiter for MMC */
249 davinci_cfg_reg(DM644X_MSTK
);
252 pdev
= &davinci_mmcsd0_device
;
259 pdev
->dev
.platform_data
= config
;
260 platform_device_register(pdev
);
265 void __init
davinci_setup_mmc(int module
, struct davinci_mmc_config
*config
)
271 /*-------------------------------------------------------------------------*/
273 static struct resource wdt_resources
[] = {
275 .start
= DAVINCI_WDOG_BASE
,
276 .end
= DAVINCI_WDOG_BASE
+ SZ_1K
- 1,
277 .flags
= IORESOURCE_MEM
,
281 static struct platform_device davinci_wdt_device
= {
282 .name
= "davinci-wdt",
284 .num_resources
= ARRAY_SIZE(wdt_resources
),
285 .resource
= wdt_resources
,
288 int davinci_init_wdt(void)
290 return platform_device_register(&davinci_wdt_device
);
293 static struct platform_device davinci_gpio_device
= {
294 .name
= "davinci_gpio",
298 int davinci_gpio_register(struct resource
*res
, int size
, void *pdata
)
300 davinci_gpio_device
.resource
= res
;
301 davinci_gpio_device
.num_resources
= size
;
302 davinci_gpio_device
.dev
.platform_data
= pdata
;
303 return platform_device_register(&davinci_gpio_device
);