All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V5 0/2] mmc: sdhci-msm: Configuring IO_PAD support for sdhci-msm
@ 2018-04-20 12:15 Vijay Viswanath
  2018-04-20 12:15 ` [PATCH V5 1/2] mmc: sdhci-msm: Add support to store supported vdd-io voltages Vijay Viswanath
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Vijay Viswanath @ 2018-04-20 12:15 UTC (permalink / raw)
  To: adrian.hunter, ulf.hansson
  Cc: linux-mmc, linux-kernel, shawn.lin, linux-arm-msm, georgi.djakov,
	asutoshd, stummala, venkatg, pramod.gurav, jeremymc, vviswana,
	bjorn.andersson, riteshh, vbadigan

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=y, Size: 1705 bytes --]

>From the HPG:
In some platform, SDCC controller can be connected to either an eMMC device or
an SD card. The PADs for SD card are dual-voltage that support 3v/1.8v. Those
PADs have a control signal  (io_pad_pwr_switch/mode18 ) that indicates whether
the PAD works in 3v or 1.8v.

For SD usage the default value of this signal is ‘0’, and SD driver changes it
to ‘1’ as a part of voltage switching sequence.
For eMMC usage, SW should configure this signal to ‘1’ and supply 1.8v to PADs
before starting any activity on the eMMC BUS.

To set this signal, write the following in the
SDC1_SDCC_HC_VENDOR_SPECIFIC_FUNC register:
	HC_IO_PAD_PWR_SWITCH: bit 16
		HC_IO_PAD_PWR_SWITCH_EN: bit 15

Changes since v1:
	Modified comments on io_pad related changes.
	Split some read+modify+write commands to multiple lines

Changes since v2:
	IO_PAD_PWR_SWITCH_EN will be set only if we have info regarding what
	voltage is supported by the regulators.
	Replaced regulator_list_voltage() API with
	regulator_is_supported_voltage().

Changes since v3:
	Removed unnecessary prints and extra lines.

Changes since v4:
	Removed unnecessary mb() within sdhci_msm_handle_pwr_irq() since
	wakeup calls have implicit write barriers.

Krishna Konda (1):
  mmc: sdhci-msm: support voltage pad switching

Vijay Viswanath (1):
  mmc: sdhci-msm: Add support to store supported vdd-io voltages

 drivers/mmc/host/sdhci-msm.c | 99 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 97 insertions(+), 2 deletions(-)

-- 
 Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH V5 1/2] mmc: sdhci-msm: Add support to store supported vdd-io voltages
  2018-04-20 12:15 [PATCH V5 0/2] mmc: sdhci-msm: Configuring IO_PAD support for sdhci-msm Vijay Viswanath
@ 2018-04-20 12:15 ` Vijay Viswanath
  2018-04-22 17:26   ` Bjorn Andersson
  2018-04-20 12:15 ` [PATCH V5 2/2] mmc: sdhci-msm: support voltage pad switching Vijay Viswanath
  2018-04-23  9:18 ` [PATCH V5 0/2] mmc: sdhci-msm: Configuring IO_PAD support for sdhci-msm Ulf Hansson
  2 siblings, 1 reply; 6+ messages in thread
From: Vijay Viswanath @ 2018-04-20 12:15 UTC (permalink / raw)
  To: adrian.hunter, ulf.hansson
  Cc: linux-mmc, linux-kernel, shawn.lin, linux-arm-msm, georgi.djakov,
	asutoshd, stummala, venkatg, pramod.gurav, jeremymc, vviswana,
	bjorn.andersson, riteshh, vbadigan

During probe check whether the vdd-io regulator of sdhc platform device
can support 1.8V and 3V and store this information as a capability of
platform device.

Signed-off-by: Vijay Viswanath <vviswana@codeaurora.org>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
---
 drivers/mmc/host/sdhci-msm.c | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
index c283291..edd30a2 100644
--- a/drivers/mmc/host/sdhci-msm.c
+++ b/drivers/mmc/host/sdhci-msm.c
@@ -21,6 +21,7 @@
 #include <linux/pm_runtime.h>
 #include <linux/slab.h>
 #include <linux/iopoll.h>
+#include <linux/regulator/consumer.h>
 
 #include "sdhci-pltfm.h"
 
@@ -81,6 +82,9 @@
 #define CORE_HC_SELECT_IN_HS400	(6 << 19)
 #define CORE_HC_SELECT_IN_MASK	(7 << 19)
 
+#define CORE_3_0V_SUPPORT	(1 << 25)
+#define CORE_1_8V_SUPPORT	(1 << 26)
+
 #define CORE_CSR_CDC_CTLR_CFG0		0x130
 #define CORE_SW_TRIG_FULL_CALIB		BIT(16)
 #define CORE_HW_AUTOCAL_ENA		BIT(17)
@@ -148,6 +152,7 @@ struct sdhci_msm_host {
 	u32 curr_io_level;
 	wait_queue_head_t pwr_irq_wait;
 	bool pwr_irq_flag;
+	u32 caps_0;
 };
 
 static unsigned int msm_get_clock_rate_for_bus_mode(struct sdhci_host *host,
@@ -1103,7 +1108,7 @@ static void sdhci_msm_handle_pwr_irq(struct sdhci_host *host, int irq)
 	struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host);
 	u32 irq_status, irq_ack = 0;
 	int retry = 10;
-	int pwr_state = 0, io_level = 0;
+	u32 pwr_state = 0, io_level = 0;
 
 
 	irq_status = readl_relaxed(msm_host->core_mem + CORE_PWRCTL_STATUS);
@@ -1313,6 +1318,27 @@ static void sdhci_msm_writeb(struct sdhci_host *host, u8 val, int reg)
 		sdhci_msm_check_power_status(host, req_type);
 }
 
+static void sdhci_msm_set_regulator_caps(struct sdhci_msm_host *msm_host)
+{
+	struct mmc_host *mmc = msm_host->mmc;
+	struct regulator *supply = mmc->supply.vqmmc;
+	u32 caps = 0;
+
+	if (!IS_ERR(mmc->supply.vqmmc)) {
+		if (regulator_is_supported_voltage(supply, 1700000, 1950000))
+			caps |= CORE_1_8V_SUPPORT;
+		if (regulator_is_supported_voltage(supply, 2700000, 3600000))
+			caps |= CORE_3_0V_SUPPORT;
+
+		if (!caps)
+			pr_warn("%s: 1.8/3V not supported for vqmmc\n",
+					mmc_hostname(mmc));
+	}
+
+	msm_host->caps_0 |= caps;
+	pr_debug("%s: supported caps: 0x%08x\n", mmc_hostname(mmc), caps);
+}
+
 static const struct of_device_id sdhci_msm_dt_match[] = {
 	{ .compatible = "qcom,sdhci-msm-v4" },
 	{},
@@ -1530,6 +1556,7 @@ static int sdhci_msm_probe(struct platform_device *pdev)
 	ret = sdhci_add_host(host);
 	if (ret)
 		goto pm_runtime_disable;
+	sdhci_msm_set_regulator_caps(msm_host);
 
 	pm_runtime_mark_last_busy(&pdev->dev);
 	pm_runtime_put_autosuspend(&pdev->dev);
-- 
 Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH V5 2/2] mmc: sdhci-msm: support voltage pad switching
  2018-04-20 12:15 [PATCH V5 0/2] mmc: sdhci-msm: Configuring IO_PAD support for sdhci-msm Vijay Viswanath
  2018-04-20 12:15 ` [PATCH V5 1/2] mmc: sdhci-msm: Add support to store supported vdd-io voltages Vijay Viswanath
@ 2018-04-20 12:15 ` Vijay Viswanath
  2018-04-22 17:26   ` Bjorn Andersson
  2018-04-23  9:18 ` [PATCH V5 0/2] mmc: sdhci-msm: Configuring IO_PAD support for sdhci-msm Ulf Hansson
  2 siblings, 1 reply; 6+ messages in thread
From: Vijay Viswanath @ 2018-04-20 12:15 UTC (permalink / raw)
  To: adrian.hunter, ulf.hansson
  Cc: linux-mmc, linux-kernel, shawn.lin, linux-arm-msm, georgi.djakov,
	asutoshd, stummala, venkatg, pramod.gurav, jeremymc, vviswana,
	bjorn.andersson, riteshh, vbadigan, Krishna Konda

The PADs for SD card are dual-voltage that support 3v/1.8v. Those PADs
have a control signal  (io_pad_pwr_switch/mode18 ) that indicates
whether the PAD works in 3v or 1.8v.

SDHC core on msm platforms should have IO_PAD_PWR_SWITCH bit set/unset
based on actual voltage used for IO lines. So when power irq is
triggered for io high or io low, the driver should check the voltages
supported and set the pad accordingly.

Signed-off-by: Krishna Konda <kkonda@codeaurora.org>
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
Signed-off-by: Vijay Viswanath <vviswana@codeaurora.org>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
---
 drivers/mmc/host/sdhci-msm.c | 57 ++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 55 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
index edd30a2..bb11916 100644
--- a/drivers/mmc/host/sdhci-msm.c
+++ b/drivers/mmc/host/sdhci-msm.c
@@ -78,12 +78,15 @@
 #define CORE_HC_MCLK_SEL_DFLT	(2 << 8)
 #define CORE_HC_MCLK_SEL_HS400	(3 << 8)
 #define CORE_HC_MCLK_SEL_MASK	(3 << 8)
+#define CORE_IO_PAD_PWR_SWITCH_EN	(1 << 15)
+#define CORE_IO_PAD_PWR_SWITCH  (1 << 16)
 #define CORE_HC_SELECT_IN_EN	BIT(18)
 #define CORE_HC_SELECT_IN_HS400	(6 << 19)
 #define CORE_HC_SELECT_IN_MASK	(7 << 19)
 
 #define CORE_3_0V_SUPPORT	(1 << 25)
 #define CORE_1_8V_SUPPORT	(1 << 26)
+#define CORE_VOLT_SUPPORT	(CORE_3_0V_SUPPORT | CORE_1_8V_SUPPORT)
 
 #define CORE_CSR_CDC_CTLR_CFG0		0x130
 #define CORE_SW_TRIG_FULL_CALIB		BIT(16)
@@ -1109,7 +1112,7 @@ static void sdhci_msm_handle_pwr_irq(struct sdhci_host *host, int irq)
 	u32 irq_status, irq_ack = 0;
 	int retry = 10;
 	u32 pwr_state = 0, io_level = 0;
-
+	u32 config;
 
 	irq_status = readl_relaxed(msm_host->core_mem + CORE_PWRCTL_STATUS);
 	irq_status &= INT_MASK;
@@ -1166,6 +1169,38 @@ static void sdhci_msm_handle_pwr_irq(struct sdhci_host *host, int irq)
 	 */
 	writel_relaxed(irq_ack, msm_host->core_mem + CORE_PWRCTL_CTL);
 
+	/*
+	 * If we don't have info regarding the voltage levels supported by
+	 * regulators, don't change the IO PAD PWR SWITCH.
+	 */
+	if (msm_host->caps_0 & CORE_VOLT_SUPPORT) {
+		u32 new_config;
+		/*
+		 * We should unset IO PAD PWR switch only if the register write
+		 * can set IO lines high and the regulator also switches to 3 V.
+		 * Else, we should keep the IO PAD PWR switch set.
+		 * This is applicable to certain targets where eMMC vccq supply
+		 * is only 1.8V. In such targets, even during REQ_IO_HIGH, the
+		 * IO PAD PWR switch must be kept set to reflect actual
+		 * regulator voltage. This way, during initialization of
+		 * controllers with only 1.8V, we will set the IO PAD bit
+		 * without waiting for a REQ_IO_LOW.
+		 */
+		config = readl_relaxed(host->ioaddr + CORE_VENDOR_SPEC);
+		new_config = config;
+
+		if ((io_level & REQ_IO_HIGH) &&
+				(msm_host->caps_0 & CORE_3_0V_SUPPORT))
+			new_config &= ~CORE_IO_PAD_PWR_SWITCH;
+		else if ((io_level & REQ_IO_LOW) ||
+				(msm_host->caps_0 & CORE_1_8V_SUPPORT))
+			new_config |= CORE_IO_PAD_PWR_SWITCH;
+
+		if (config ^ new_config)
+			writel_relaxed(new_config,
+					host->ioaddr + CORE_VENDOR_SPEC);
+	}
+
 	if (pwr_state)
 		msm_host->curr_pwr_state = pwr_state;
 	if (io_level)
@@ -1322,7 +1357,8 @@ static void sdhci_msm_set_regulator_caps(struct sdhci_msm_host *msm_host)
 {
 	struct mmc_host *mmc = msm_host->mmc;
 	struct regulator *supply = mmc->supply.vqmmc;
-	u32 caps = 0;
+	u32 caps = 0, config;
+	struct sdhci_host *host = mmc_priv(mmc);
 
 	if (!IS_ERR(mmc->supply.vqmmc)) {
 		if (regulator_is_supported_voltage(supply, 1700000, 1950000))
@@ -1335,6 +1371,23 @@ static void sdhci_msm_set_regulator_caps(struct sdhci_msm_host *msm_host)
 					mmc_hostname(mmc));
 	}
 
+	if (caps) {
+		/*
+		 * Set the PAD_PWR_SWITCH_EN bit so that the PAD_PWR_SWITCH
+		 * bit can be used as required later on.
+		 */
+		u32 io_level = msm_host->curr_io_level;
+
+		config = readl_relaxed(host->ioaddr + CORE_VENDOR_SPEC);
+		config |= CORE_IO_PAD_PWR_SWITCH_EN;
+
+		if ((io_level & REQ_IO_HIGH) && (caps &	CORE_3_0V_SUPPORT))
+			config &= ~CORE_IO_PAD_PWR_SWITCH;
+		else if ((io_level & REQ_IO_LOW) || (caps & CORE_1_8V_SUPPORT))
+			config |= CORE_IO_PAD_PWR_SWITCH;
+
+		writel_relaxed(config, host->ioaddr + CORE_VENDOR_SPEC);
+	}
 	msm_host->caps_0 |= caps;
 	pr_debug("%s: supported caps: 0x%08x\n", mmc_hostname(mmc), caps);
 }
-- 
 Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH V5 1/2] mmc: sdhci-msm: Add support to store supported vdd-io voltages
  2018-04-20 12:15 ` [PATCH V5 1/2] mmc: sdhci-msm: Add support to store supported vdd-io voltages Vijay Viswanath
@ 2018-04-22 17:26   ` Bjorn Andersson
  0 siblings, 0 replies; 6+ messages in thread
From: Bjorn Andersson @ 2018-04-22 17:26 UTC (permalink / raw)
  To: Vijay Viswanath
  Cc: adrian.hunter, ulf.hansson, linux-mmc, linux-kernel, shawn.lin,
	linux-arm-msm, georgi.djakov, asutoshd, stummala, venkatg,
	pramod.gurav, jeremymc, riteshh, vbadigan

On Fri 20 Apr 05:15 PDT 2018, Vijay Viswanath wrote:

> During probe check whether the vdd-io regulator of sdhc platform device
> can support 1.8V and 3V and store this information as a capability of
> platform device.
> 
> Signed-off-by: Vijay Viswanath <vviswana@codeaurora.org>
> Reviewed-by: Douglas Anderson <dianders@chromium.org>

Sorry for the delay, I've boot tested this on 8974 and 8916 now and eMMC
still works. 

Acked-by: Bjorn Andersson <bjorn.andersson@linaro.org>

Regards,
Bjorn

> ---
>  drivers/mmc/host/sdhci-msm.c | 29 ++++++++++++++++++++++++++++-
>  1 file changed, 28 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
> index c283291..edd30a2 100644
> --- a/drivers/mmc/host/sdhci-msm.c
> +++ b/drivers/mmc/host/sdhci-msm.c
> @@ -21,6 +21,7 @@
>  #include <linux/pm_runtime.h>
>  #include <linux/slab.h>
>  #include <linux/iopoll.h>
> +#include <linux/regulator/consumer.h>
>  
>  #include "sdhci-pltfm.h"
>  
> @@ -81,6 +82,9 @@
>  #define CORE_HC_SELECT_IN_HS400	(6 << 19)
>  #define CORE_HC_SELECT_IN_MASK	(7 << 19)
>  
> +#define CORE_3_0V_SUPPORT	(1 << 25)
> +#define CORE_1_8V_SUPPORT	(1 << 26)
> +
>  #define CORE_CSR_CDC_CTLR_CFG0		0x130
>  #define CORE_SW_TRIG_FULL_CALIB		BIT(16)
>  #define CORE_HW_AUTOCAL_ENA		BIT(17)
> @@ -148,6 +152,7 @@ struct sdhci_msm_host {
>  	u32 curr_io_level;
>  	wait_queue_head_t pwr_irq_wait;
>  	bool pwr_irq_flag;
> +	u32 caps_0;
>  };
>  
>  static unsigned int msm_get_clock_rate_for_bus_mode(struct sdhci_host *host,
> @@ -1103,7 +1108,7 @@ static void sdhci_msm_handle_pwr_irq(struct sdhci_host *host, int irq)
>  	struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host);
>  	u32 irq_status, irq_ack = 0;
>  	int retry = 10;
> -	int pwr_state = 0, io_level = 0;
> +	u32 pwr_state = 0, io_level = 0;
>  
>  
>  	irq_status = readl_relaxed(msm_host->core_mem + CORE_PWRCTL_STATUS);
> @@ -1313,6 +1318,27 @@ static void sdhci_msm_writeb(struct sdhci_host *host, u8 val, int reg)
>  		sdhci_msm_check_power_status(host, req_type);
>  }
>  
> +static void sdhci_msm_set_regulator_caps(struct sdhci_msm_host *msm_host)
> +{
> +	struct mmc_host *mmc = msm_host->mmc;
> +	struct regulator *supply = mmc->supply.vqmmc;
> +	u32 caps = 0;
> +
> +	if (!IS_ERR(mmc->supply.vqmmc)) {
> +		if (regulator_is_supported_voltage(supply, 1700000, 1950000))
> +			caps |= CORE_1_8V_SUPPORT;
> +		if (regulator_is_supported_voltage(supply, 2700000, 3600000))
> +			caps |= CORE_3_0V_SUPPORT;
> +
> +		if (!caps)
> +			pr_warn("%s: 1.8/3V not supported for vqmmc\n",
> +					mmc_hostname(mmc));
> +	}
> +
> +	msm_host->caps_0 |= caps;
> +	pr_debug("%s: supported caps: 0x%08x\n", mmc_hostname(mmc), caps);
> +}
> +
>  static const struct of_device_id sdhci_msm_dt_match[] = {
>  	{ .compatible = "qcom,sdhci-msm-v4" },
>  	{},
> @@ -1530,6 +1556,7 @@ static int sdhci_msm_probe(struct platform_device *pdev)
>  	ret = sdhci_add_host(host);
>  	if (ret)
>  		goto pm_runtime_disable;
> +	sdhci_msm_set_regulator_caps(msm_host);
>  
>  	pm_runtime_mark_last_busy(&pdev->dev);
>  	pm_runtime_put_autosuspend(&pdev->dev);
> -- 
>  Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. 
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH V5 2/2] mmc: sdhci-msm: support voltage pad switching
  2018-04-20 12:15 ` [PATCH V5 2/2] mmc: sdhci-msm: support voltage pad switching Vijay Viswanath
@ 2018-04-22 17:26   ` Bjorn Andersson
  0 siblings, 0 replies; 6+ messages in thread
From: Bjorn Andersson @ 2018-04-22 17:26 UTC (permalink / raw)
  To: Vijay Viswanath
  Cc: adrian.hunter, ulf.hansson, linux-mmc, linux-kernel, shawn.lin,
	linux-arm-msm, georgi.djakov, asutoshd, stummala, venkatg,
	pramod.gurav, jeremymc, riteshh, vbadigan, Krishna Konda

On Fri 20 Apr 05:15 PDT 2018, Vijay Viswanath wrote:

> The PADs for SD card are dual-voltage that support 3v/1.8v. Those PADs
> have a control signal  (io_pad_pwr_switch/mode18 ) that indicates
> whether the PAD works in 3v or 1.8v.
> 
> SDHC core on msm platforms should have IO_PAD_PWR_SWITCH bit set/unset
> based on actual voltage used for IO lines. So when power irq is
> triggered for io high or io low, the driver should check the voltages
> supported and set the pad accordingly.
> 
> Signed-off-by: Krishna Konda <kkonda@codeaurora.org>
> Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
> Signed-off-by: Vijay Viswanath <vviswana@codeaurora.org>
> Reviewed-by: Douglas Anderson <dianders@chromium.org>

Acked-by: Bjorn Andersson <bjorn.andersson@linaro.org>

Regards,
Bjorn

> ---
>  drivers/mmc/host/sdhci-msm.c | 57 ++++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 55 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
> index edd30a2..bb11916 100644
> --- a/drivers/mmc/host/sdhci-msm.c
> +++ b/drivers/mmc/host/sdhci-msm.c
> @@ -78,12 +78,15 @@
>  #define CORE_HC_MCLK_SEL_DFLT	(2 << 8)
>  #define CORE_HC_MCLK_SEL_HS400	(3 << 8)
>  #define CORE_HC_MCLK_SEL_MASK	(3 << 8)
> +#define CORE_IO_PAD_PWR_SWITCH_EN	(1 << 15)
> +#define CORE_IO_PAD_PWR_SWITCH  (1 << 16)
>  #define CORE_HC_SELECT_IN_EN	BIT(18)
>  #define CORE_HC_SELECT_IN_HS400	(6 << 19)
>  #define CORE_HC_SELECT_IN_MASK	(7 << 19)
>  
>  #define CORE_3_0V_SUPPORT	(1 << 25)
>  #define CORE_1_8V_SUPPORT	(1 << 26)
> +#define CORE_VOLT_SUPPORT	(CORE_3_0V_SUPPORT | CORE_1_8V_SUPPORT)
>  
>  #define CORE_CSR_CDC_CTLR_CFG0		0x130
>  #define CORE_SW_TRIG_FULL_CALIB		BIT(16)
> @@ -1109,7 +1112,7 @@ static void sdhci_msm_handle_pwr_irq(struct sdhci_host *host, int irq)
>  	u32 irq_status, irq_ack = 0;
>  	int retry = 10;
>  	u32 pwr_state = 0, io_level = 0;
> -
> +	u32 config;
>  
>  	irq_status = readl_relaxed(msm_host->core_mem + CORE_PWRCTL_STATUS);
>  	irq_status &= INT_MASK;
> @@ -1166,6 +1169,38 @@ static void sdhci_msm_handle_pwr_irq(struct sdhci_host *host, int irq)
>  	 */
>  	writel_relaxed(irq_ack, msm_host->core_mem + CORE_PWRCTL_CTL);
>  
> +	/*
> +	 * If we don't have info regarding the voltage levels supported by
> +	 * regulators, don't change the IO PAD PWR SWITCH.
> +	 */
> +	if (msm_host->caps_0 & CORE_VOLT_SUPPORT) {
> +		u32 new_config;
> +		/*
> +		 * We should unset IO PAD PWR switch only if the register write
> +		 * can set IO lines high and the regulator also switches to 3 V.
> +		 * Else, we should keep the IO PAD PWR switch set.
> +		 * This is applicable to certain targets where eMMC vccq supply
> +		 * is only 1.8V. In such targets, even during REQ_IO_HIGH, the
> +		 * IO PAD PWR switch must be kept set to reflect actual
> +		 * regulator voltage. This way, during initialization of
> +		 * controllers with only 1.8V, we will set the IO PAD bit
> +		 * without waiting for a REQ_IO_LOW.
> +		 */
> +		config = readl_relaxed(host->ioaddr + CORE_VENDOR_SPEC);
> +		new_config = config;
> +
> +		if ((io_level & REQ_IO_HIGH) &&
> +				(msm_host->caps_0 & CORE_3_0V_SUPPORT))
> +			new_config &= ~CORE_IO_PAD_PWR_SWITCH;
> +		else if ((io_level & REQ_IO_LOW) ||
> +				(msm_host->caps_0 & CORE_1_8V_SUPPORT))
> +			new_config |= CORE_IO_PAD_PWR_SWITCH;
> +
> +		if (config ^ new_config)
> +			writel_relaxed(new_config,
> +					host->ioaddr + CORE_VENDOR_SPEC);
> +	}
> +
>  	if (pwr_state)
>  		msm_host->curr_pwr_state = pwr_state;
>  	if (io_level)
> @@ -1322,7 +1357,8 @@ static void sdhci_msm_set_regulator_caps(struct sdhci_msm_host *msm_host)
>  {
>  	struct mmc_host *mmc = msm_host->mmc;
>  	struct regulator *supply = mmc->supply.vqmmc;
> -	u32 caps = 0;
> +	u32 caps = 0, config;
> +	struct sdhci_host *host = mmc_priv(mmc);
>  
>  	if (!IS_ERR(mmc->supply.vqmmc)) {
>  		if (regulator_is_supported_voltage(supply, 1700000, 1950000))
> @@ -1335,6 +1371,23 @@ static void sdhci_msm_set_regulator_caps(struct sdhci_msm_host *msm_host)
>  					mmc_hostname(mmc));
>  	}
>  
> +	if (caps) {
> +		/*
> +		 * Set the PAD_PWR_SWITCH_EN bit so that the PAD_PWR_SWITCH
> +		 * bit can be used as required later on.
> +		 */
> +		u32 io_level = msm_host->curr_io_level;
> +
> +		config = readl_relaxed(host->ioaddr + CORE_VENDOR_SPEC);
> +		config |= CORE_IO_PAD_PWR_SWITCH_EN;
> +
> +		if ((io_level & REQ_IO_HIGH) && (caps &	CORE_3_0V_SUPPORT))
> +			config &= ~CORE_IO_PAD_PWR_SWITCH;
> +		else if ((io_level & REQ_IO_LOW) || (caps & CORE_1_8V_SUPPORT))
> +			config |= CORE_IO_PAD_PWR_SWITCH;
> +
> +		writel_relaxed(config, host->ioaddr + CORE_VENDOR_SPEC);
> +	}
>  	msm_host->caps_0 |= caps;
>  	pr_debug("%s: supported caps: 0x%08x\n", mmc_hostname(mmc), caps);
>  }
> -- 
>  Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. 
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH V5 0/2] mmc: sdhci-msm: Configuring IO_PAD support for sdhci-msm
  2018-04-20 12:15 [PATCH V5 0/2] mmc: sdhci-msm: Configuring IO_PAD support for sdhci-msm Vijay Viswanath
  2018-04-20 12:15 ` [PATCH V5 1/2] mmc: sdhci-msm: Add support to store supported vdd-io voltages Vijay Viswanath
  2018-04-20 12:15 ` [PATCH V5 2/2] mmc: sdhci-msm: support voltage pad switching Vijay Viswanath
@ 2018-04-23  9:18 ` Ulf Hansson
  2 siblings, 0 replies; 6+ messages in thread
From: Ulf Hansson @ 2018-04-23  9:18 UTC (permalink / raw)
  To: Vijay Viswanath
  Cc: Adrian Hunter, linux-mmc, Linux Kernel Mailing List, Shawn Lin,
	linux-arm-msm, Georgi Djakov, Asutosh Das, Sahitya Tummala,
	Venkat Gopalakrishnan, Pramod Gurav, Jeremy McNicoll,
	Bjorn Andersson, Harjani Ritesh, vbadigan

On 20 April 2018 at 14:15, Vijay Viswanath <vviswana@codeaurora.org> wrote:
> From the HPG:
> In some platform, SDCC controller can be connected to either an eMMC device or
> an SD card. The PADs for SD card are dual-voltage that support 3v/1.8v. Those
> PADs have a control signal  (io_pad_pwr_switch/mode18 ) that indicates whether
> the PAD works in 3v or 1.8v.
>
> For SD usage the default value of this signal is ‘0’, and SD driver changes it
> to ‘1’ as a part of voltage switching sequence.
> For eMMC usage, SW should configure this signal to ‘1’ and supply 1.8v to PADs
> before starting any activity on the eMMC BUS.
>
> To set this signal, write the following in the
> SDC1_SDCC_HC_VENDOR_SPECIFIC_FUNC register:
>         HC_IO_PAD_PWR_SWITCH: bit 16
>                 HC_IO_PAD_PWR_SWITCH_EN: bit 15
>

Thanks, applied for next!

Kind regards
Uffe

> Changes since v1:
>         Modified comments on io_pad related changes.
>         Split some read+modify+write commands to multiple lines
>
> Changes since v2:
>         IO_PAD_PWR_SWITCH_EN will be set only if we have info regarding what
>         voltage is supported by the regulators.
>         Replaced regulator_list_voltage() API with
>         regulator_is_supported_voltage().
>
> Changes since v3:
>         Removed unnecessary prints and extra lines.
>
> Changes since v4:
>         Removed unnecessary mb() within sdhci_msm_handle_pwr_irq() since
>         wakeup calls have implicit write barriers.
>
> Krishna Konda (1):
>   mmc: sdhci-msm: support voltage pad switching
>
> Vijay Viswanath (1):
>   mmc: sdhci-msm: Add support to store supported vdd-io voltages
>
>  drivers/mmc/host/sdhci-msm.c | 99 +++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 97 insertions(+), 2 deletions(-)
>
> --
>  Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc.
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-04-23  9:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-20 12:15 [PATCH V5 0/2] mmc: sdhci-msm: Configuring IO_PAD support for sdhci-msm Vijay Viswanath
2018-04-20 12:15 ` [PATCH V5 1/2] mmc: sdhci-msm: Add support to store supported vdd-io voltages Vijay Viswanath
2018-04-22 17:26   ` Bjorn Andersson
2018-04-20 12:15 ` [PATCH V5 2/2] mmc: sdhci-msm: support voltage pad switching Vijay Viswanath
2018-04-22 17:26   ` Bjorn Andersson
2018-04-23  9:18 ` [PATCH V5 0/2] mmc: sdhci-msm: Configuring IO_PAD support for sdhci-msm Ulf Hansson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.