aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrice Chotard <patrice.chotard@st.com>2018-01-18 09:34:20 -0500
committerUlf Hansson <ulf.hansson@linaro.org>2018-01-18 12:14:45 -0500
commitf9bb304ce855fad615c5adffae5e129941ff0b48 (patch)
treecdb5db383ea605f4733fcb9314d96295d6378ac5
parent11dfb9701175ead45be9f6621619fc67598ed4ec (diff)
mmc: mmci: Add support for setting pad type via pinctrl
If variant hasn't the control bit to switch pads in opendrain mode, we can achieve the same result by asking to the pinmux driver to configure pins for us. This patch make the mmci driver able to do this whenever needed. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: Patrice Chotard <patrice.chotard@st.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
-rw-r--r--drivers/mmc/host/mmci.c41
-rw-r--r--drivers/mmc/host/mmci.h5
2 files changed, 44 insertions, 2 deletions
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index c1123f644959..f8a21f3c3b51 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -1465,8 +1465,19 @@ static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
1465 ~MCI_ST_DATA2DIREN); 1465 ~MCI_ST_DATA2DIREN);
1466 } 1466 }
1467 1467
1468 if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN && variant->opendrain) 1468 if (variant->opendrain) {
1469 pwr |= variant->opendrain; 1469 if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN)
1470 pwr |= variant->opendrain;
1471 } else {
1472 /*
1473 * If the variant cannot configure the pads by its own, then we
1474 * expect the pinctrl to be able to do that for us
1475 */
1476 if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN)
1477 pinctrl_select_state(host->pinctrl, host->pins_opendrain);
1478 else
1479 pinctrl_select_state(host->pinctrl, host->pins_default);
1480 }
1470 1481
1471 /* 1482 /*
1472 * If clock = 0 and the variant requires the MMCIPOWER to be used for 1483 * If clock = 0 and the variant requires the MMCIPOWER to be used for
@@ -1610,6 +1621,32 @@ static int mmci_probe(struct amba_device *dev,
1610 host = mmc_priv(mmc); 1621 host = mmc_priv(mmc);
1611 host->mmc = mmc; 1622 host->mmc = mmc;
1612 1623
1624 /*
1625 * Some variant (STM32) doesn't have opendrain bit, nevertheless
1626 * pins can be set accordingly using pinctrl
1627 */
1628 if (!variant->opendrain) {
1629 host->pinctrl = devm_pinctrl_get(&dev->dev);
1630 if (IS_ERR(host->pinctrl)) {
1631 dev_err(&dev->dev, "failed to get pinctrl");
1632 goto host_free;
1633 }
1634
1635 host->pins_default = pinctrl_lookup_state(host->pinctrl,
1636 PINCTRL_STATE_DEFAULT);
1637 if (IS_ERR(host->pins_default)) {
1638 dev_err(mmc_dev(mmc), "Can't select default pins\n");
1639 goto host_free;
1640 }
1641
1642 host->pins_opendrain = pinctrl_lookup_state(host->pinctrl,
1643 MMCI_PINCTRL_STATE_OPENDRAIN);
1644 if (IS_ERR(host->pins_opendrain)) {
1645 dev_err(mmc_dev(mmc), "Can't select opendrain pins\n");
1646 goto host_free;
1647 }
1648 }
1649
1613 host->hw_designer = amba_manf(dev); 1650 host->hw_designer = amba_manf(dev);
1614 host->hw_revision = amba_rev(dev); 1651 host->hw_revision = amba_rev(dev);
1615 dev_dbg(mmc_dev(mmc), "designer ID = 0x%02x\n", host->hw_designer); 1652 dev_dbg(mmc_dev(mmc), "designer ID = 0x%02x\n", host->hw_designer);
diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h
index 83160a9c4c77..f91cdf7f6dae 100644
--- a/drivers/mmc/host/mmci.h
+++ b/drivers/mmc/host/mmci.h
@@ -192,6 +192,8 @@
192 192
193#define NR_SG 128 193#define NR_SG 128
194 194
195#define MMCI_PINCTRL_STATE_OPENDRAIN "opendrain"
196
195struct clk; 197struct clk;
196struct variant_data; 198struct variant_data;
197struct dma_chan; 199struct dma_chan;
@@ -227,6 +229,9 @@ struct mmci_host {
227 bool vqmmc_enabled; 229 bool vqmmc_enabled;
228 struct mmci_platform_data *plat; 230 struct mmci_platform_data *plat;
229 struct variant_data *variant; 231 struct variant_data *variant;
232 struct pinctrl *pinctrl;
233 struct pinctrl_state *pins_default;
234 struct pinctrl_state *pins_opendrain;
230 235
231 u8 hw_designer; 236 u8 hw_designer;
232 u8 hw_revision:4; 237 u8 hw_revision:4;