summaryrefslogtreecommitdiffstats
path: root/configs/platform-v7a/patches/barebox-2017.08.0/0005-mci-mmci-add-DT-support.patch
blob: 256464414db997d2d5f8fff781e7a3364e80b3a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
From: Lucas Stach <l.stach@pengutronix.de>
Date: Mon, 4 Sep 2017 11:43:38 +0200
Subject: [PATCH] mci: mmci: add DT support

Just adds the minimal implementation to fill platform_data from
the DT properties with Linux binding.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/mci/mmci.c | 39 ++++++++++++++++++++++++++++++++++++---
 1 file changed, 36 insertions(+), 3 deletions(-)

diff --git a/drivers/mci/mmci.c b/drivers/mci/mmci.c
index 7489ee03a13c..f45557d4f7be 100644
--- a/drivers/mci/mmci.c
+++ b/drivers/mci/mmci.c
@@ -532,9 +532,37 @@ static void mci_set_ios(struct mci_host *mci, struct mci_ios *ios)
 	udelay(CLK_CHANGE_DELAY);
 }
 
+static int mmci_of_parse(struct device_node *np,
+			 struct mmci_platform_data *plat)
+{
+	if (!IS_ENABLED(CONFIG_OFDEVICE))
+		return 0;
+
+	if (of_get_property(np, "st,sig-dir-dat0", NULL))
+		plat->sigdir |= MCI_ST_DATA0DIREN;
+	if (of_get_property(np, "st,sig-dir-dat2", NULL))
+		plat->sigdir |= MCI_ST_DATA2DIREN;
+	if (of_get_property(np, "st,sig-dir-dat31", NULL))
+		plat->sigdir |= MCI_ST_DATA31DIREN;
+	if (of_get_property(np, "st,sig-dir-dat74", NULL))
+		plat->sigdir |= MCI_ST_DATA74DIREN;
+	if (of_get_property(np, "st,sig-dir-cmd", NULL))
+		plat->sigdir |= MCI_ST_CMDDIREN;
+	if (of_get_property(np, "st,sig-pin-fbclk", NULL))
+		plat->sigdir |= MCI_ST_FBCLKEN;
+
+	if (of_get_property(np, "mmc-cap-mmc-highspeed", NULL))
+		plat->capabilities |= MMC_CAP_MMC_HIGHSPEED;
+	if (of_get_property(np, "mmc-cap-sd-highspeed", NULL))
+		plat->capabilities |= MMC_CAP_SD_HIGHSPEED;
+
+	return 0;
+}
+
 static int mmci_probe(struct amba_device *dev, const struct amba_id *id)
 {
 	struct device_d *hw_dev = &dev->dev;
+	struct device_node *np = hw_dev->device_node;
 	struct mmci_platform_data *plat = hw_dev->platform_data;
 	struct variant_data *variant = id->data;
 	u32 sdi_u32;
@@ -542,11 +570,16 @@ static int mmci_probe(struct amba_device *dev, const struct amba_id *id)
 	struct clk *clk;
 	int ret;
 
-	if (!plat) {
-		dev_err(hw_dev, "missing platform data\n");
+	if (!plat && !np) {
+		dev_err(hw_dev, "missing platform data or DT node\n");
 		return -EINVAL;
 	}
 
+	if (!plat)
+		plat = xzalloc(sizeof(*plat));
+
+	mmci_of_parse(np, plat);
+
 	host = xzalloc(sizeof(*host));
 
 	host->base = amba_get_mem_region(dev);
@@ -625,7 +658,7 @@ static int mmci_probe(struct amba_device *dev, const struct amba_id *id)
 	host->mci.max_req_size = (1 << variant->datalength_bits) - 1;
 
 	host->mci.host_caps = plat->capabilities;
-	host->mci.voltages = plat->ocr_mask;
+	host->mci.voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | plat->ocr_mask;
 
 	mci_register(&host->mci);