From mboxrd@z Thu Jan 1 00:00:00 1970 From: lee.jones@linaro.org (Lee Jones) Date: Wed, 14 Mar 2012 14:20:01 +0000 Subject: [PATCH 3/5] MMC: mmci: Add generic Device Tree bindings to mmci core code In-Reply-To: <1331734803-17954-1-git-send-email-lee.jones@linaro.org> References: <1331734803-17954-1-git-send-email-lee.jones@linaro.org> Message-ID: <1331734803-17954-4-git-send-email-lee.jones@linaro.org> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org This adds the necessary bindings for collection of shared attributes used in the mmci driver. Signed-off-by: Lee Jones --- drivers/mmc/host/mmci.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 43 insertions(+), 0 deletions(-) diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index 23b41a5..9132ca8 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -1056,11 +1057,47 @@ 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) +{ + const void *prop; + int len; + + 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-invert", NULL)) + pdata->cd_invert = true; + else + pdata->cd_invert = false; + + of_property_read_u32(np, "clock_frequency", &pdata->f_max); + if (!pdata->f_max) + pr_warning("%s has no 'clock_frequency' property\n", np->full_name); + + if (of_get_property(np, "mmc_cap_4_bit_data", NULL)) + pdata->capabilities |= MMC_CAP_4_BIT_DATA; + if (of_get_property(np, "mmc_cap_8_bit_data", NULL)) + pdata->capabilities |= MMC_CAP_8_BIT_DATA; + 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; +} +#endif + extern int __devinit mmci_probe(struct amba_device *dev, const struct amba_id *id) { struct mmci_platform_data *plat = dev->dev.platform_data; struct variant_data *variant = id->data; + struct device_node *np = dev->dev.of_node; struct mmci_host *host; struct mmc_host *mmc; int ret; @@ -1071,6 +1108,12 @@ extern int __devinit mmci_probe(struct amba_device *dev, goto out; } +#ifdef CONFIG_OF + if (np) + /* GPIOs, card detect invert, max freq, capabilites etc ... */ + mmci_dt_populate_generic_pdata(np, plat); +#endif + ret = amba_request_regions(dev, DRIVER_NAME); if (ret) goto out; -- 1.7.5.4