Commit 06b23ca0 authored by Faiz Abbas's avatar Faiz Abbas Committed by Ulf Hansson

mmc: sdhci-of-arasan: Add a single data structure to incorporate pdata and soc_ctl_map

Currently, the driver passes platform data as a global structure
and uses the .data of of_device_id to pass the soc_ctl_map. To
make the implementation more flexible add a single data structure
that incorporates both of the above and pass it in the .data of
of_device_id.
Signed-off-by: default avatarFaiz Abbas <faiz_abbas@ti.com>
Signed-off-by: default avatarSekhar Nori <nsekhar@ti.com>
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent 26a4f38d
...@@ -107,6 +107,11 @@ struct sdhci_arasan_data { ...@@ -107,6 +107,11 @@ struct sdhci_arasan_data {
#define SDHCI_ARASAN_QUIRK_CLOCK_UNSTABLE BIT(1) #define SDHCI_ARASAN_QUIRK_CLOCK_UNSTABLE BIT(1)
}; };
struct sdhci_arasan_of_data {
const struct sdhci_arasan_soc_ctl_map *soc_ctl_map;
const struct sdhci_pltfm_data *pdata;
};
static const struct sdhci_arasan_soc_ctl_map rk3399_soc_ctl_map = { static const struct sdhci_arasan_soc_ctl_map rk3399_soc_ctl_map = {
.baseclkfreq = { .reg = 0xf000, .width = 8, .shift = 8 }, .baseclkfreq = { .reg = 0xf000, .width = 8, .shift = 8 },
.clockmultiplier = { .reg = 0xf02c, .width = 8, .shift = 0}, .clockmultiplier = { .reg = 0xf02c, .width = 8, .shift = 0},
...@@ -307,6 +312,10 @@ static const struct sdhci_pltfm_data sdhci_arasan_pdata = { ...@@ -307,6 +312,10 @@ static const struct sdhci_pltfm_data sdhci_arasan_pdata = {
SDHCI_QUIRK2_STOP_WITH_TC, SDHCI_QUIRK2_STOP_WITH_TC,
}; };
static struct sdhci_arasan_of_data sdhci_arasan_data = {
.pdata = &sdhci_arasan_pdata,
};
static u32 sdhci_arasan_cqhci_irq(struct sdhci_host *host, u32 intmask) static u32 sdhci_arasan_cqhci_irq(struct sdhci_host *host, u32 intmask)
{ {
int cmd_error = 0; int cmd_error = 0;
...@@ -363,6 +372,11 @@ static const struct sdhci_pltfm_data sdhci_arasan_cqe_pdata = { ...@@ -363,6 +372,11 @@ static const struct sdhci_pltfm_data sdhci_arasan_cqe_pdata = {
SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN, SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN,
}; };
static struct sdhci_arasan_of_data sdhci_arasan_rk3399_data = {
.soc_ctl_map = &rk3399_soc_ctl_map,
.pdata = &sdhci_arasan_cqe_pdata,
};
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
/** /**
* sdhci_arasan_suspend - Suspend method for the driver * sdhci_arasan_suspend - Suspend method for the driver
...@@ -462,14 +476,21 @@ static const struct of_device_id sdhci_arasan_of_match[] = { ...@@ -462,14 +476,21 @@ static const struct of_device_id sdhci_arasan_of_match[] = {
/* SoC-specific compatible strings w/ soc_ctl_map */ /* SoC-specific compatible strings w/ soc_ctl_map */
{ {
.compatible = "rockchip,rk3399-sdhci-5.1", .compatible = "rockchip,rk3399-sdhci-5.1",
.data = &rk3399_soc_ctl_map, .data = &sdhci_arasan_rk3399_data,
}, },
/* Generic compatible below here */ /* Generic compatible below here */
{ .compatible = "arasan,sdhci-8.9a" }, {
{ .compatible = "arasan,sdhci-5.1" }, .compatible = "arasan,sdhci-8.9a",
{ .compatible = "arasan,sdhci-4.9a" }, .data = &sdhci_arasan_data,
},
{
.compatible = "arasan,sdhci-5.1",
.data = &sdhci_arasan_data,
},
{
.compatible = "arasan,sdhci-4.9a",
.data = &sdhci_arasan_data,
},
{ /* sentinel */ } { /* sentinel */ }
}; };
MODULE_DEVICE_TABLE(of, sdhci_arasan_of_match); MODULE_DEVICE_TABLE(of, sdhci_arasan_of_match);
...@@ -707,14 +728,11 @@ static int sdhci_arasan_probe(struct platform_device *pdev) ...@@ -707,14 +728,11 @@ static int sdhci_arasan_probe(struct platform_device *pdev)
struct sdhci_pltfm_host *pltfm_host; struct sdhci_pltfm_host *pltfm_host;
struct sdhci_arasan_data *sdhci_arasan; struct sdhci_arasan_data *sdhci_arasan;
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
const struct sdhci_pltfm_data *pdata; const struct sdhci_arasan_of_data *data;
if (of_device_is_compatible(pdev->dev.of_node, "arasan,sdhci-5.1"))
pdata = &sdhci_arasan_cqe_pdata;
else
pdata = &sdhci_arasan_pdata;
host = sdhci_pltfm_init(pdev, pdata, sizeof(*sdhci_arasan)); match = of_match_node(sdhci_arasan_of_match, pdev->dev.of_node);
data = match->data;
host = sdhci_pltfm_init(pdev, data->pdata, sizeof(*sdhci_arasan));
if (IS_ERR(host)) if (IS_ERR(host))
return PTR_ERR(host); return PTR_ERR(host);
...@@ -723,8 +741,7 @@ static int sdhci_arasan_probe(struct platform_device *pdev) ...@@ -723,8 +741,7 @@ static int sdhci_arasan_probe(struct platform_device *pdev)
sdhci_arasan = sdhci_pltfm_priv(pltfm_host); sdhci_arasan = sdhci_pltfm_priv(pltfm_host);
sdhci_arasan->host = host; sdhci_arasan->host = host;
match = of_match_node(sdhci_arasan_of_match, pdev->dev.of_node); sdhci_arasan->soc_ctl_map = data->soc_ctl_map;
sdhci_arasan->soc_ctl_map = match->data;
node = of_parse_phandle(pdev->dev.of_node, "arasan,soc-ctl-syscon", 0); node = of_parse_phandle(pdev->dev.of_node, "arasan,soc-ctl-syscon", 0);
if (node) { if (node) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment