Merge branch 'regmap-5.3' into regmap-next
[linux-2.6-block.git] / arch / arm / mach-imx / devices / platform-sdhci-esdhc-imx.c
CommitLineData
d2912cb1 1// SPDX-License-Identifier: GPL-2.0-only
124bf94a 2/*
61b8c7b5 3 * Copyright (C) 2010 Pengutronix, Wolfram Sang <kernel@pengutronix.de>
124bf94a
UKK
4 */
5
82906b13 6#include <linux/platform_data/mmc-esdhc-imx.h>
50f2de61
SG
7
8#include "../hardware.h"
e0557c0d 9#include "devices-common.h"
124bf94a 10
57ed3314 11#define imx_sdhci_esdhc_imx_data_entry_single(soc, _devid, _id, hwid) \
124bf94a 12 { \
57ed3314 13 .devid = _devid, \
124bf94a
UKK
14 .id = _id, \
15 .iobase = soc ## _ESDHC ## hwid ## _BASE_ADDR, \
16 .irq = soc ## _INT_ESDHC ## hwid, \
17 }
18
57ed3314
SG
19#define imx_sdhci_esdhc_imx_data_entry(soc, devid, id, hwid) \
20 [id] = imx_sdhci_esdhc_imx_data_entry_single(soc, devid, id, hwid)
124bf94a 21
124bf94a
UKK
22#ifdef CONFIG_SOC_IMX35
23const struct imx_sdhci_esdhc_imx_data
24imx35_sdhci_esdhc_imx_data[] __initconst = {
25#define imx35_sdhci_esdhc_imx_data_entry(_id, _hwid) \
57ed3314 26 imx_sdhci_esdhc_imx_data_entry(MX35, "sdhci-esdhc-imx35", _id, _hwid)
124bf94a
UKK
27 imx35_sdhci_esdhc_imx_data_entry(0, 1),
28 imx35_sdhci_esdhc_imx_data_entry(1, 2),
29 imx35_sdhci_esdhc_imx_data_entry(2, 3),
30};
31#endif /* ifdef CONFIG_SOC_IMX35 */
32
913413c3
SG
33static const struct esdhc_platform_data default_esdhc_pdata __initconst = {
34 .wp_type = ESDHC_WP_NONE,
35 .cd_type = ESDHC_CD_NONE,
36};
37
124bf94a
UKK
38struct platform_device *__init imx_add_sdhci_esdhc_imx(
39 const struct imx_sdhci_esdhc_imx_data *data,
40 const struct esdhc_platform_data *pdata)
41{
42 struct resource res[] = {
43 {
44 .start = data->iobase,
45 .end = data->iobase + SZ_16K - 1,
46 .flags = IORESOURCE_MEM,
47 }, {
48 .start = data->irq,
49 .end = data->irq,
50 .flags = IORESOURCE_IRQ,
51 },
52 };
53
913413c3
SG
54 /*
55 * If machine does not provide pdata, use the default one
56 * which means no WP/CD support
57 */
58 if (!pdata)
59 pdata = &default_esdhc_pdata;
60
fc26fe9c
AK
61 return imx_add_platform_device_dmamask(data->devid, data->id, res,
62 ARRAY_SIZE(res), pdata, sizeof(*pdata),
63 DMA_BIT_MASK(32));
124bf94a 64}