aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/host
diff options
context:
space:
mode:
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>2013-02-15 10:13:56 -0500
committerChris Ball <cjb@laptop.org>2013-02-24 14:37:22 -0500
commit5a00a971a2b12edf52825fb196b146b5fb6335a3 (patch)
tree1c6fa1628df0335ba5431b5b4fa6e28e8d0f630a /drivers/mmc/host
parentd804820fa3302cb3d11f68a840e718d082967ad4 (diff)
mmc: tmio-mmc: parse device-tree bindings
Add parsing of common and driver-specific DT bindings to the tmio-mmc MMC host driver and the sh_mobile_sdhi interface layer. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Chris Ball <cjb@laptop.org>
Diffstat (limited to 'drivers/mmc/host')
-rw-r--r--drivers/mmc/host/sh_mobile_sdhi.c32
-rw-r--r--drivers/mmc/host/tmio_mmc_pio.c20
2 files changed, 44 insertions, 8 deletions
diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c
index e0ca0abba0e5..06e1bc98c536 100644
--- a/drivers/mmc/host/sh_mobile_sdhi.c
+++ b/drivers/mmc/host/sh_mobile_sdhi.c
@@ -23,6 +23,7 @@
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/mod_devicetable.h> 24#include <linux/mod_devicetable.h>
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/of_device.h>
26#include <linux/platform_device.h> 27#include <linux/platform_device.h>
27#include <linux/mmc/host.h> 28#include <linux/mmc/host.h>
28#include <linux/mmc/sh_mobile_sdhi.h> 29#include <linux/mmc/sh_mobile_sdhi.h>
@@ -32,6 +33,16 @@
32 33
33#include "tmio_mmc.h" 34#include "tmio_mmc.h"
34 35
36struct sh_mobile_sdhi_of_data {
37 unsigned long tmio_flags;
38};
39
40static const struct sh_mobile_sdhi_of_data sh_mobile_sdhi_of_cfg[] = {
41 {
42 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT,
43 },
44};
45
35struct sh_mobile_sdhi { 46struct sh_mobile_sdhi {
36 struct clk *clk; 47 struct clk *clk;
37 struct tmio_mmc_data mmc_data; 48 struct tmio_mmc_data mmc_data;
@@ -117,8 +128,18 @@ static const struct sh_mobile_sdhi_ops sdhi_ops = {
117 .cd_wakeup = sh_mobile_sdhi_cd_wakeup, 128 .cd_wakeup = sh_mobile_sdhi_cd_wakeup,
118}; 129};
119 130
131static const struct of_device_id sh_mobile_sdhi_of_match[] = {
132 { .compatible = "renesas,shmobile-sdhi" },
133 { .compatible = "renesas,sh7372-sdhi" },
134 { .compatible = "renesas,r8a7740-sdhi", .data = &sh_mobile_sdhi_of_cfg[0], },
135 {},
136};
137MODULE_DEVICE_TABLE(of, sh_mobile_sdhi_of_match);
138
120static int sh_mobile_sdhi_probe(struct platform_device *pdev) 139static int sh_mobile_sdhi_probe(struct platform_device *pdev)
121{ 140{
141 const struct of_device_id *of_id =
142 of_match_device(sh_mobile_sdhi_of_match, &pdev->dev);
122 struct sh_mobile_sdhi *priv; 143 struct sh_mobile_sdhi *priv;
123 struct tmio_mmc_data *mmc_data; 144 struct tmio_mmc_data *mmc_data;
124 struct sh_mobile_sdhi_info *p = pdev->dev.platform_data; 145 struct sh_mobile_sdhi_info *p = pdev->dev.platform_data;
@@ -186,6 +207,11 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
186 */ 207 */
187 mmc_data->flags |= TMIO_MMC_SDIO_IRQ; 208 mmc_data->flags |= TMIO_MMC_SDIO_IRQ;
188 209
210 if (of_id && of_id->data) {
211 const struct sh_mobile_sdhi_of_data *of_data = of_id->data;
212 mmc_data->flags |= of_data->tmio_flags;
213 }
214
189 ret = tmio_mmc_host_probe(&host, pdev, mmc_data); 215 ret = tmio_mmc_host_probe(&host, pdev, mmc_data);
190 if (ret < 0) 216 if (ret < 0)
191 goto eprobe; 217 goto eprobe;
@@ -313,12 +339,6 @@ static const struct dev_pm_ops tmio_mmc_dev_pm_ops = {
313 .runtime_resume = tmio_mmc_host_runtime_resume, 339 .runtime_resume = tmio_mmc_host_runtime_resume,
314}; 340};
315 341
316static const struct of_device_id sh_mobile_sdhi_of_match[] = {
317 { .compatible = "renesas,shmobile-sdhi" },
318 { }
319};
320MODULE_DEVICE_TABLE(of, sh_mobile_sdhi_of_match);
321
322static struct platform_driver sh_mobile_sdhi_driver = { 342static struct platform_driver sh_mobile_sdhi_driver = {
323 .driver = { 343 .driver = {
324 .name = "sh_mobile_sdhi", 344 .name = "sh_mobile_sdhi",
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index b25adb4160f5..e5b3fcf55c4c 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -918,6 +918,17 @@ static void tmio_mmc_init_ocr(struct tmio_mmc_host *host)
918 dev_warn(mmc_dev(mmc), "Platform OCR mask is ignored\n"); 918 dev_warn(mmc_dev(mmc), "Platform OCR mask is ignored\n");
919} 919}
920 920
921static void tmio_mmc_of_parse(struct platform_device *pdev,
922 struct tmio_mmc_data *pdata)
923{
924 const struct device_node *np = pdev->dev.of_node;
925 if (!np)
926 return;
927
928 if (of_get_property(np, "toshiba,mmc-wrprotect-disable", NULL))
929 pdata->flags |= TMIO_MMC_WRPROTECT_DISABLE;
930}
931
921int tmio_mmc_host_probe(struct tmio_mmc_host **host, 932int tmio_mmc_host_probe(struct tmio_mmc_host **host,
922 struct platform_device *pdev, 933 struct platform_device *pdev,
923 struct tmio_mmc_data *pdata) 934 struct tmio_mmc_data *pdata)
@@ -928,6 +939,8 @@ int tmio_mmc_host_probe(struct tmio_mmc_host **host,
928 int ret; 939 int ret;
929 u32 irq_mask = TMIO_MASK_CMD; 940 u32 irq_mask = TMIO_MASK_CMD;
930 941
942 tmio_mmc_of_parse(pdev, pdata);
943
931 if (!(pdata->flags & TMIO_MMC_HAS_IDLE_WAIT)) 944 if (!(pdata->flags & TMIO_MMC_HAS_IDLE_WAIT))
932 pdata->write16_hook = NULL; 945 pdata->write16_hook = NULL;
933 946
@@ -939,6 +952,8 @@ int tmio_mmc_host_probe(struct tmio_mmc_host **host,
939 if (!mmc) 952 if (!mmc)
940 return -ENOMEM; 953 return -ENOMEM;
941 954
955 mmc_of_parse(mmc);
956
942 pdata->dev = &pdev->dev; 957 pdata->dev = &pdev->dev;
943 _host = mmc_priv(mmc); 958 _host = mmc_priv(mmc);
944 _host->pdata = pdata; 959 _host->pdata = pdata;
@@ -959,7 +974,7 @@ int tmio_mmc_host_probe(struct tmio_mmc_host **host,
959 } 974 }
960 975
961 mmc->ops = &tmio_mmc_ops; 976 mmc->ops = &tmio_mmc_ops;
962 mmc->caps = MMC_CAP_4_BIT_DATA | pdata->capabilities; 977 mmc->caps |= MMC_CAP_4_BIT_DATA | pdata->capabilities;
963 mmc->caps2 = pdata->capabilities2; 978 mmc->caps2 = pdata->capabilities2;
964 mmc->max_segs = 32; 979 mmc->max_segs = 32;
965 mmc->max_blk_size = 512; 980 mmc->max_blk_size = 512;
@@ -971,7 +986,8 @@ int tmio_mmc_host_probe(struct tmio_mmc_host **host,
971 986
972 _host->native_hotplug = !(pdata->flags & TMIO_MMC_USE_GPIO_CD || 987 _host->native_hotplug = !(pdata->flags & TMIO_MMC_USE_GPIO_CD ||
973 mmc->caps & MMC_CAP_NEEDS_POLL || 988 mmc->caps & MMC_CAP_NEEDS_POLL ||
974 mmc->caps & MMC_CAP_NONREMOVABLE); 989 mmc->caps & MMC_CAP_NONREMOVABLE ||
990 mmc->slot.cd_irq >= 0);
975 991
976 _host->power = false; 992 _host->power = false;
977 pm_runtime_enable(&pdev->dev); 993 pm_runtime_enable(&pdev->dev);