diff mbox series

[U-Boot,v2,3/5] mmc: arm_pl180_mmci: add bus_width DT property support

Message ID 1508749054-28369-4-git-send-email-patrice.chotard@st.com
State Accepted
Commit 9035bb7432d33014fd131390c635e634aaacd4d0
Delegated to: Tom Rini
Headers show
Series Extend ARM_PL180_MMCI | expand

Commit Message

Patrice CHOTARD Oct. 23, 2017, 8:57 a.m. UTC
From: Patrice Chotard <patrice.chotard@st.com>

Allow to get "bus-width" property from device tree

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
---

v2: _ remove useless return in bus_width switch case


 drivers/mmc/arm_pl180_mmci.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Tom Rini Nov. 17, 2017, 3:44 p.m. UTC | #1
On Mon, Oct 23, 2017 at 10:57:32AM +0200, patrice.chotard@st.com wrote:

> From: Patrice Chotard <patrice.chotard@st.com>
> 
> Allow to get "bus-width" property from device tree
> 
> Signed-off-by: Patrice Chotard <patrice.chotard@st.com>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/drivers/mmc/arm_pl180_mmci.c b/drivers/mmc/arm_pl180_mmci.c
index b3c1f0d..fd57b55 100644
--- a/drivers/mmc/arm_pl180_mmci.c
+++ b/drivers/mmc/arm_pl180_mmci.c
@@ -408,6 +408,7 @@  static int arm_pl180_mmc_probe(struct udevice *dev)
 	struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
 	struct mmc *mmc = &pdata->mmc;
 	struct pl180_mmc_host *host = mmc->priv;
+	u32 bus_width;
 	int ret;
 
 	strcpy(host->name, "MMC");
@@ -421,6 +422,21 @@  static int arm_pl180_mmc_probe(struct udevice *dev)
 	host->clock_max = dev_read_u32_default(dev, "max-frequency",
 					       MMC_CLOCK_MAX);
 	host->version2 = dev_get_driver_data(dev);
+
+	bus_width = dev_read_u32_default(dev, "bus-width", 1);
+	switch (bus_width) {
+	case 8:
+		host->caps |= MMC_MODE_8BIT;
+		/* Hosts capable of 8-bit transfers can also do 4 bits */
+	case 4:
+		host->caps |= MMC_MODE_4BIT;
+		break;
+	case 1:
+		break;
+	default:
+		dev_err(dev, "Invalid bus-width value %u\n", bus_width);
+	}
+
 	ret = arm_pl180_mmci_init(host, &mmc);
 	if (ret) {
 		dev_err(dev, "arm_pl180_mmci init failed\n");