From 000bc9d5ed296550e7009f56cbdb4b35459beb69 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 16 Apr 2012 10:18:43 +0100 Subject: mmc: mmci: Enable Device Tree support for ux500 variants Provide a means to collect attributes specific to ST-Ericsson's ux500 variant series. This patch registers itself as the AMBA driver to be called during the probe process. Once all attributes and ux500 specifics are are collected the normal mmci core probe is called. Signed-off-by: Lee Jones Acked-by: Linus Walleij Acked-by: Arnd Bergmann Signed-off-by: Chris Ball --- drivers/mmc/host/mmci.c | 58 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 4 deletions(-) (limited to 'drivers/mmc/host/mmci.c') diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index 032b84791a16..5a7da175201c 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -1196,21 +1197,70 @@ static const struct mmc_host_ops mmci_ops = { .get_cd = mmci_get_cd, }; +#ifdef CONFIG_OF +static void mmci_dt_populate_generic_pdata(struct device_node *np, + struct mmci_platform_data *pdata) +{ + int bus_width = 0; + + of_property_read_u32(np, "wp-gpios", &pdata->gpio_wp); + if (!pdata->gpio_wp) + pdata->gpio_wp = -1; + + of_property_read_u32(np, "cd-gpios", &pdata->gpio_cd); + if (!pdata->gpio_cd) + pdata->gpio_cd = -1; + + if (of_get_property(np, "cd-inverted", NULL)) + pdata->cd_invert = true; + else + pdata->cd_invert = false; + + of_property_read_u32(np, "max-frequency", &pdata->f_max); + if (!pdata->f_max) + pr_warn("%s has no 'max-frequency' property\n", np->full_name); + + if (of_get_property(np, "mmc-cap-mmc-highspeed", NULL)) + pdata->capabilities |= MMC_CAP_MMC_HIGHSPEED; + if (of_get_property(np, "mmc-cap-sd-highspeed", NULL)) + pdata->capabilities |= MMC_CAP_SD_HIGHSPEED; + + of_property_read_u32(np, "bus-width", &bus_width); + switch (bus_width) { + case 0 : + /* No bus-width supplied. */ + break; + case 4 : + pdata->capabilities |= MMC_CAP_4_BIT_DATA; + break; + case 8 : + pdata->capabilities |= MMC_CAP_8_BIT_DATA; + break; + default : + pr_warn("%s: Unsupported bus width\n", np->full_name); + } +} +#endif + static int __devinit mmci_probe(struct amba_device *dev, const struct amba_id *id) { struct mmci_platform_data *plat = dev->dev.platform_data; + struct device_node *np = dev->dev.of_node; struct variant_data *variant = id->data; struct mmci_host *host; struct mmc_host *mmc; int ret; - /* must have platform data */ - if (!plat) { - ret = -EINVAL; - goto out; + /* Must have platform data or Device Tree. */ + if (!plat && !np) { + dev_err(&dev->dev, "No plat data or DT found\n"); + return -EINVAL; } + if (np) + mmci_dt_populate_generic_pdata(np, plat); + ret = amba_request_regions(dev, DRIVER_NAME); if (ret) goto out; -- cgit v1.2.3 From 9a597016058520665452390df919428e4edd7770 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Thu, 12 Apr 2012 16:51:13 +0100 Subject: mmc: mmci: Use correct GPIO binding for IRQ requests Now there are irqdomains in place for Snowball, we can request GPIO IRQs directly by their binding. This replaces the previous method of hard-coding the hwirq using u32 values in the DT. Signed-off-by: Lee Jones Signed-off-by: Chris Ball --- drivers/mmc/host/mmci.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers/mmc/host/mmci.c') diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index 5a7da175201c..2303a16263ef 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -1203,11 +1204,11 @@ static void mmci_dt_populate_generic_pdata(struct device_node *np, { int bus_width = 0; - of_property_read_u32(np, "wp-gpios", &pdata->gpio_wp); + pdata->gpio_wp = of_get_named_gpio(np, "wp-gpios", 0); if (!pdata->gpio_wp) pdata->gpio_wp = -1; - of_property_read_u32(np, "cd-gpios", &pdata->gpio_cd); + pdata->gpio_cd = of_get_named_gpio(np, "cd-gpios", 0); if (!pdata->gpio_cd) pdata->gpio_cd = -1; -- cgit v1.2.3 From c0a120a4bc68f5dc5f5238e76013cc18bac0ffed Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Tue, 8 May 2012 13:59:38 +0100 Subject: mmc: mmci: Fix compiler error when CONFIG_OF is not set error: implicit declaration of function 'mmci_dt_populate_generic_pdata' This is due to the '#if CONFIG_OF' guards placed around mmci_dt_populate_generic_pdata(), but not around the call to it. We repair this by inserting a stub which elegantly returns when CONFIG_OF is not set. Reported-by: Paul Gortmaker Signed-off-by: Lee Jones Signed-off-by: Chris Ball --- drivers/mmc/host/mmci.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'drivers/mmc/host/mmci.c') diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index 2303a16263ef..efc822df4b75 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -1241,6 +1241,12 @@ static void mmci_dt_populate_generic_pdata(struct device_node *np, pr_warn("%s: Unsupported bus width\n", np->full_name); } } +#else +static void mmci_dt_populate_generic_pdata(struct device_node *np, + struct mmci_platform_data *pdata) +{ + return; +} #endif static int __devinit mmci_probe(struct amba_device *dev, -- cgit v1.2.3