aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>2012-05-01 12:18:16 -0400
committerChris Ball <cjb@laptop.org>2012-07-21 00:02:21 -0400
commitbf68a812f06ca40bccfa2e792055141f2c3948c7 (patch)
treebecf790d34b3d971bae3285f9eeff44ac8444430 /drivers
parentc7bb4487a3474c03986758595fcae1cfb771b3b0 (diff)
mmc: sh-mmcif: add OF support, make platform data optional
Add primitive OF support to the sh-mmcif driver, which also makes it necessary to be able to run without platform data. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Chris Ball <cjb@laptop.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mmc/host/sh_mmcif.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c
index 204bcedc2164..68b31f7c290b 100644
--- a/drivers/mmc/host/sh_mmcif.c
+++ b/drivers/mmc/host/sh_mmcif.c
@@ -54,6 +54,7 @@
54#include <linux/mmc/mmc.h> 54#include <linux/mmc/mmc.h>
55#include <linux/mmc/sdio.h> 55#include <linux/mmc/sdio.h>
56#include <linux/mmc/sh_mmcif.h> 56#include <linux/mmc/sh_mmcif.h>
57#include <linux/mod_devicetable.h>
57#include <linux/pagemap.h> 58#include <linux/pagemap.h>
58#include <linux/platform_device.h> 59#include <linux/platform_device.h>
59#include <linux/pm_qos.h> 60#include <linux/pm_qos.h>
@@ -384,6 +385,9 @@ static void sh_mmcif_request_dma(struct sh_mmcif_host *host,
384 struct sh_dmae_slave *tx, *rx; 385 struct sh_dmae_slave *tx, *rx;
385 host->dma_active = false; 386 host->dma_active = false;
386 387
388 if (!pdata)
389 return;
390
387 /* We can only either use DMA for both Tx and Rx or not use it at all */ 391 /* We can only either use DMA for both Tx and Rx or not use it at all */
388 if (pdata->dma) { 392 if (pdata->dma) {
389 dev_warn(&host->pd->dev, 393 dev_warn(&host->pd->dev,
@@ -444,13 +448,14 @@ static void sh_mmcif_release_dma(struct sh_mmcif_host *host)
444static void sh_mmcif_clock_control(struct sh_mmcif_host *host, unsigned int clk) 448static void sh_mmcif_clock_control(struct sh_mmcif_host *host, unsigned int clk)
445{ 449{
446 struct sh_mmcif_plat_data *p = host->pd->dev.platform_data; 450 struct sh_mmcif_plat_data *p = host->pd->dev.platform_data;
451 bool sup_pclk = p ? p->sup_pclk : false;
447 452
448 sh_mmcif_bitclr(host, MMCIF_CE_CLK_CTRL, CLK_ENABLE); 453 sh_mmcif_bitclr(host, MMCIF_CE_CLK_CTRL, CLK_ENABLE);
449 sh_mmcif_bitclr(host, MMCIF_CE_CLK_CTRL, CLK_CLEAR); 454 sh_mmcif_bitclr(host, MMCIF_CE_CLK_CTRL, CLK_CLEAR);
450 455
451 if (!clk) 456 if (!clk)
452 return; 457 return;
453 if (p->sup_pclk && clk == host->clk) 458 if (sup_pclk && clk == host->clk)
454 sh_mmcif_bitset(host, MMCIF_CE_CLK_CTRL, CLK_SUP_PCLK); 459 sh_mmcif_bitset(host, MMCIF_CE_CLK_CTRL, CLK_SUP_PCLK);
455 else 460 else
456 sh_mmcif_bitset(host, MMCIF_CE_CLK_CTRL, CLK_CLEAR & 461 sh_mmcif_bitset(host, MMCIF_CE_CLK_CTRL, CLK_CLEAR &
@@ -928,7 +933,7 @@ static void sh_mmcif_set_power(struct sh_mmcif_host *host, struct mmc_ios *ios)
928 struct sh_mmcif_plat_data *pd = host->pd->dev.platform_data; 933 struct sh_mmcif_plat_data *pd = host->pd->dev.platform_data;
929 struct mmc_host *mmc = host->mmc; 934 struct mmc_host *mmc = host->mmc;
930 935
931 if (pd->set_pwr) 936 if (pd && pd->set_pwr)
932 pd->set_pwr(host->pd, ios->power_mode != MMC_POWER_OFF); 937 pd->set_pwr(host->pd, ios->power_mode != MMC_POWER_OFF);
933 if (!IS_ERR(mmc->supply.vmmc)) 938 if (!IS_ERR(mmc->supply.vmmc))
934 /* Errors ignored... */ 939 /* Errors ignored... */
@@ -996,7 +1001,7 @@ static int sh_mmcif_get_cd(struct mmc_host *mmc)
996 struct sh_mmcif_host *host = mmc_priv(mmc); 1001 struct sh_mmcif_host *host = mmc_priv(mmc);
997 struct sh_mmcif_plat_data *p = host->pd->dev.platform_data; 1002 struct sh_mmcif_plat_data *p = host->pd->dev.platform_data;
998 1003
999 if (!p->get_cd) 1004 if (!p || !p->get_cd)
1000 return -ENOSYS; 1005 return -ENOSYS;
1001 else 1006 else
1002 return p->get_cd(host->pd); 1007 return p->get_cd(host->pd);
@@ -1269,6 +1274,9 @@ static void sh_mmcif_init_ocr(struct sh_mmcif_host *host)
1269 1274
1270 mmc_regulator_get_supply(mmc); 1275 mmc_regulator_get_supply(mmc);
1271 1276
1277 if (!pd)
1278 return;
1279
1272 if (!mmc->ocr_avail) 1280 if (!mmc->ocr_avail)
1273 mmc->ocr_avail = pd->ocr; 1281 mmc->ocr_avail = pd->ocr;
1274 else if (pd->ocr) 1282 else if (pd->ocr)
@@ -1285,11 +1293,6 @@ static int __devinit sh_mmcif_probe(struct platform_device *pdev)
1285 void __iomem *reg; 1293 void __iomem *reg;
1286 char clk_name[8]; 1294 char clk_name[8];
1287 1295
1288 if (!pd) {
1289 dev_err(&pdev->dev, "sh_mmcif plat data error.\n");
1290 return -ENXIO;
1291 }
1292
1293 irq[0] = platform_get_irq(pdev, 0); 1296 irq[0] = platform_get_irq(pdev, 0);
1294 irq[1] = platform_get_irq(pdev, 1); 1297 irq[1] = platform_get_irq(pdev, 1);
1295 if (irq[0] < 0 || irq[1] < 0) { 1298 if (irq[0] < 0 || irq[1] < 0) {
@@ -1325,7 +1328,7 @@ static int __devinit sh_mmcif_probe(struct platform_device *pdev)
1325 sh_mmcif_init_ocr(host); 1328 sh_mmcif_init_ocr(host);
1326 1329
1327 mmc->caps = MMC_CAP_MMC_HIGHSPEED; 1330 mmc->caps = MMC_CAP_MMC_HIGHSPEED;
1328 if (pd->caps) 1331 if (pd && pd->caps)
1329 mmc->caps |= pd->caps; 1332 mmc->caps |= pd->caps;
1330 mmc->max_segs = 32; 1333 mmc->max_segs = 32;
1331 mmc->max_blk_size = 512; 1334 mmc->max_blk_size = 512;
@@ -1462,6 +1465,12 @@ static int sh_mmcif_resume(struct device *dev)
1462#define sh_mmcif_resume NULL 1465#define sh_mmcif_resume NULL
1463#endif /* CONFIG_PM */ 1466#endif /* CONFIG_PM */
1464 1467
1468static const struct of_device_id mmcif_of_match[] = {
1469 { .compatible = "renesas,sh-mmcif" },
1470 { }
1471};
1472MODULE_DEVICE_TABLE(of, mmcif_of_match);
1473
1465static const struct dev_pm_ops sh_mmcif_dev_pm_ops = { 1474static const struct dev_pm_ops sh_mmcif_dev_pm_ops = {
1466 .suspend = sh_mmcif_suspend, 1475 .suspend = sh_mmcif_suspend,
1467 .resume = sh_mmcif_resume, 1476 .resume = sh_mmcif_resume,
@@ -1473,6 +1482,8 @@ static struct platform_driver sh_mmcif_driver = {
1473 .driver = { 1482 .driver = {
1474 .name = DRIVER_NAME, 1483 .name = DRIVER_NAME,
1475 .pm = &sh_mmcif_dev_pm_ops, 1484 .pm = &sh_mmcif_dev_pm_ops,
1485 .owner = THIS_MODULE,
1486 .of_match_table = mmcif_of_match,
1476 }, 1487 },
1477}; 1488};
1478 1489