aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc
diff options
context:
space:
mode:
authorLee Jones <lee.jones@linaro.org>2012-04-16 05:18:43 -0400
committerChris Ball <cjb@laptop.org>2012-05-04 10:08:29 -0400
commit000bc9d5ed296550e7009f56cbdb4b35459beb69 (patch)
tree4ca5c71f49bb9f93f05cff7b65aec8469cc8050d /drivers/mmc
parent6ebaf8f2b0f9e67ac2e00ba7af04a58b39312b3c (diff)
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 <lee.jones@linaro.org> Acked-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Chris Ball <cjb@laptop.org>
Diffstat (limited to 'drivers/mmc')
-rw-r--r--drivers/mmc/host/mmci.c58
1 files changed, 54 insertions, 4 deletions
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 @@
15#include <linux/device.h> 15#include <linux/device.h>
16#include <linux/interrupt.h> 16#include <linux/interrupt.h>
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/slab.h>
18#include <linux/delay.h> 19#include <linux/delay.h>
19#include <linux/err.h> 20#include <linux/err.h>
20#include <linux/highmem.h> 21#include <linux/highmem.h>
@@ -1196,21 +1197,70 @@ static const struct mmc_host_ops mmci_ops = {
1196 .get_cd = mmci_get_cd, 1197 .get_cd = mmci_get_cd,
1197}; 1198};
1198 1199
1200#ifdef CONFIG_OF
1201static void mmci_dt_populate_generic_pdata(struct device_node *np,
1202 struct mmci_platform_data *pdata)
1203{
1204 int bus_width = 0;
1205
1206 of_property_read_u32(np, "wp-gpios", &pdata->gpio_wp);
1207 if (!pdata->gpio_wp)
1208 pdata->gpio_wp = -1;
1209
1210 of_property_read_u32(np, "cd-gpios", &pdata->gpio_cd);
1211 if (!pdata->gpio_cd)
1212 pdata->gpio_cd = -1;
1213
1214 if (of_get_property(np, "cd-inverted", NULL))
1215 pdata->cd_invert = true;
1216 else
1217 pdata->cd_invert = false;
1218
1219 of_property_read_u32(np, "max-frequency", &pdata->f_max);
1220 if (!pdata->f_max)
1221 pr_warn("%s has no 'max-frequency' property\n", np->full_name);
1222
1223 if (of_get_property(np, "mmc-cap-mmc-highspeed", NULL))
1224 pdata->capabilities |= MMC_CAP_MMC_HIGHSPEED;
1225 if (of_get_property(np, "mmc-cap-sd-highspeed", NULL))
1226 pdata->capabilities |= MMC_CAP_SD_HIGHSPEED;
1227
1228 of_property_read_u32(np, "bus-width", &bus_width);
1229 switch (bus_width) {
1230 case 0 :
1231 /* No bus-width supplied. */
1232 break;
1233 case 4 :
1234 pdata->capabilities |= MMC_CAP_4_BIT_DATA;
1235 break;
1236 case 8 :
1237 pdata->capabilities |= MMC_CAP_8_BIT_DATA;
1238 break;
1239 default :
1240 pr_warn("%s: Unsupported bus width\n", np->full_name);
1241 }
1242}
1243#endif
1244
1199static int __devinit mmci_probe(struct amba_device *dev, 1245static int __devinit mmci_probe(struct amba_device *dev,
1200 const struct amba_id *id) 1246 const struct amba_id *id)
1201{ 1247{
1202 struct mmci_platform_data *plat = dev->dev.platform_data; 1248 struct mmci_platform_data *plat = dev->dev.platform_data;
1249 struct device_node *np = dev->dev.of_node;
1203 struct variant_data *variant = id->data; 1250 struct variant_data *variant = id->data;
1204 struct mmci_host *host; 1251 struct mmci_host *host;
1205 struct mmc_host *mmc; 1252 struct mmc_host *mmc;
1206 int ret; 1253 int ret;
1207 1254
1208 /* must have platform data */ 1255 /* Must have platform data or Device Tree. */
1209 if (!plat) { 1256 if (!plat && !np) {
1210 ret = -EINVAL; 1257 dev_err(&dev->dev, "No plat data or DT found\n");
1211 goto out; 1258 return -EINVAL;
1212 } 1259 }
1213 1260
1261 if (np)
1262 mmci_dt_populate_generic_pdata(np, plat);
1263
1214 ret = amba_request_regions(dev, DRIVER_NAME); 1264 ret = amba_request_regions(dev, DRIVER_NAME);
1215 if (ret) 1265 if (ret)
1216 goto out; 1266 goto out;