devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/3] dw_mmc-k3 support hi6220
@ 2015-05-14  8:45 Zhangfei Gao
  2015-05-14  8:45 ` [PATCH v3 1/3] Document: dw_mmc-k3: add document of hi6220 mmc Zhangfei Gao
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Zhangfei Gao @ 2015-05-14  8:45 UTC (permalink / raw)
  To: Jaehoon Chung, ulf.hansson; +Cc: linux-mmc, devicetree, Zhangfei Gao

v3:
Suggested by Jaehoon
Add comments about register AO_SCTRL_CTRL3 and remove one unused vector

v2: 
fix comments from Jaehoon
fix some issues in sdr12 & sdr25 mode

Zhangfei Gao (3):
  Document: dw_mmc-k3: add document of hi6220 mmc
  mmc: dw_mmc: add switch_voltage
  mmc: dw_mmc: k3: support hi6220

 .../devicetree/bindings/mmc/k3-dw-mshc.txt         |  28 ++++++
 drivers/mmc/host/dw_mmc-k3.c                       | 103 ++++++++++++++++++++-
 drivers/mmc/host/dw_mmc.c                          |   4 +
 drivers/mmc/host/dw_mmc.h                          |   2 +
 4 files changed, 135 insertions(+), 2 deletions(-)

-- 
1.9.1


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

* [PATCH v3 1/3] Document: dw_mmc-k3: add document of hi6220 mmc
  2015-05-14  8:45 [PATCH v3 0/3] dw_mmc-k3 support hi6220 Zhangfei Gao
@ 2015-05-14  8:45 ` Zhangfei Gao
       [not found] ` <1431593119-31889-1-git-send-email-zhangfei.gao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Zhangfei Gao @ 2015-05-14  8:45 UTC (permalink / raw)
  To: Jaehoon Chung, ulf.hansson; +Cc: linux-mmc, devicetree, Zhangfei Gao

Add bindings for hi6220 mmc support

Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
---
 .../devicetree/bindings/mmc/k3-dw-mshc.txt         | 28 ++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/Documentation/devicetree/bindings/mmc/k3-dw-mshc.txt b/Documentation/devicetree/bindings/mmc/k3-dw-mshc.txt
index 3b35449..df37058 100644
--- a/Documentation/devicetree/bindings/mmc/k3-dw-mshc.txt
+++ b/Documentation/devicetree/bindings/mmc/k3-dw-mshc.txt
@@ -13,6 +13,10 @@ Required Properties:
 
 * compatible: should be one of the following.
   - "hisilicon,hi4511-dw-mshc": for controllers with hi4511 specific extensions.
+  - "hisilicon,hi6220-dw-mshc": for controllers with hi6220 specific extensions.
+
+Optional Properties:
+- hisilicon,peripheral-syscon: phandle of syscon used to control peripheral.
 
 Example:
 
@@ -42,3 +46,27 @@ Example:
 		cap-mmc-highspeed;
 		cap-sd-highspeed;
 	};
+
+	/* for Hi6220 */
+
+	dwmmc_1: dwmmc1@f723e000 {
+		compatible = "hisilicon,hi6220-dw-mshc";
+		num-slots = <0x1>;
+		bus-width = <0x4>;
+		disable-wp;
+		cap-sd-highspeed;
+		sd-uhs-sdr12;
+		sd-uhs-sdr25;
+		card-detect-delay = <200>;
+		hisilicon,peripheral-syscon = <&ao_ctrl>;
+		reg = <0x0 0xf723e000 0x0 0x1000>;
+		interrupts = <0x0 0x49 0x4>;
+		clocks = <&clock_sys HI6220_MMC1_CIUCLK>, <&clock_sys HI6220_MMC1_CLK>;
+		clock-names = "ciu", "biu";
+		cd-gpios = <&gpio1 0 1>;
+		pinctrl-names = "default", "idle";
+		pinctrl-0 = <&sd_pmx_func &sd_clk_cfg_func &sd_cfg_func>;
+		pinctrl-1 = <&sd_pmx_idle &sd_clk_cfg_idle &sd_cfg_idle>;
+		vqmmc-supply = <&ldo7>;
+		vmmc-supply = <&ldo10>;
+	};
-- 
1.9.1


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

* [PATCH v3 2/3] mmc: dw_mmc: add switch_voltage
       [not found] ` <1431593119-31889-1-git-send-email-zhangfei.gao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
@ 2015-05-14  8:45   ` Zhangfei Gao
  0 siblings, 0 replies; 6+ messages in thread
From: Zhangfei Gao @ 2015-05-14  8:45 UTC (permalink / raw)
  To: Jaehoon Chung, ulf.hansson-QSEj5FYQhm4dnm+yROfE0A
  Cc: linux-mmc-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Zhangfei Gao,
	Jorge A. Ramirez-Ortiz, Dan Yuan

switch_voltage is required on some platform since special register accessing

Signed-off-by: Jorge A. Ramirez-Ortiz <jorge.ramirez-ortiz-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Signed-off-by: Dan Yuan <yuandan-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org>
Signed-off-by: Zhangfei Gao <zhangfei.gao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
 drivers/mmc/host/dw_mmc.c | 4 ++++
 drivers/mmc/host/dw_mmc.h | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index 5f5adaf..ce66565 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -1236,11 +1236,15 @@ static int dw_mci_switch_voltage(struct mmc_host *mmc, struct mmc_ios *ios)
 {
 	struct dw_mci_slot *slot = mmc_priv(mmc);
 	struct dw_mci *host = slot->host;
+	const struct dw_mci_drv_data *drv_data = host->drv_data;
 	u32 uhs;
 	u32 v18 = SDMMC_UHS_18V << slot->id;
 	int min_uv, max_uv;
 	int ret;
 
+	if (drv_data && drv_data->switch_voltage)
+		return drv_data->switch_voltage(mmc, ios);
+
 	/*
 	 * Program the voltage.  Note that some instances of dw_mmc may use
 	 * the UHS_REG for this.  For other instances (like exynos) the UHS_REG
diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
index f45ab91..c723617 100644
--- a/drivers/mmc/host/dw_mmc.h
+++ b/drivers/mmc/host/dw_mmc.h
@@ -287,5 +287,7 @@ struct dw_mci_drv_data {
 	int		(*execute_tuning)(struct dw_mci_slot *slot);
 	int		(*prepare_hs400_tuning)(struct dw_mci *host,
 						struct mmc_ios *ios);
+	int		(*switch_voltage)(struct mmc_host *mmc,
+					  struct mmc_ios *ios);
 };
 #endif /* _DW_MMC_H_ */
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v3 3/3] mmc: dw_mmc: k3: support hi6220
  2015-05-14  8:45 [PATCH v3 0/3] dw_mmc-k3 support hi6220 Zhangfei Gao
  2015-05-14  8:45 ` [PATCH v3 1/3] Document: dw_mmc-k3: add document of hi6220 mmc Zhangfei Gao
       [not found] ` <1431593119-31889-1-git-send-email-zhangfei.gao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
@ 2015-05-14  8:45 ` Zhangfei Gao
  2015-05-15  9:41 ` [PATCH v3 0/3] dw_mmc-k3 " Jaehoon Chung
  3 siblings, 0 replies; 6+ messages in thread
From: Zhangfei Gao @ 2015-05-14  8:45 UTC (permalink / raw)
  To: Jaehoon Chung, ulf.hansson
  Cc: linux-mmc, devicetree, Zhangfei Gao, Jorge A. Ramirez-Ortiz,
	Dan Yuan

Support hi6220, tested on hikey board
emmc: support hs
sd: support hs, sdr12, sdr25

Signed-off-by: Jorge A. Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
Signed-off-by: Dan Yuan <yuandan@hisilicon.com>
Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
---
 drivers/mmc/host/dw_mmc-k3.c | 103 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 101 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/dw_mmc-k3.c b/drivers/mmc/host/dw_mmc-k3.c
index 650f9cc..137670b 100644
--- a/drivers/mmc/host/dw_mmc-k3.c
+++ b/drivers/mmc/host/dw_mmc-k3.c
@@ -8,16 +8,30 @@
  * (at your option) any later version.
  */
 
-#include <linux/module.h>
-#include <linux/platform_device.h>
 #include <linux/clk.h>
+#include <linux/mfd/syscon.h>
 #include <linux/mmc/host.h>
 #include <linux/mmc/dw_mmc.h>
+#include <linux/module.h>
 #include <linux/of_address.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+#include <linux/regulator/consumer.h>
 
 #include "dw_mmc.h"
 #include "dw_mmc-pltfm.h"
 
+/*
+ * hi6220 sd only support io voltage 1.8v and 3v
+ * Also need config AO_SCTRL_SEL18 accordingly
+ */
+#define AO_SCTRL_SEL18		BIT(10)
+#define AO_SCTRL_CTRL3		0x40C
+
+struct k3_priv {
+	struct regmap	*reg;
+};
+
 static void dw_mci_k3_set_ios(struct dw_mci *host, struct mmc_ios *ios)
 {
 	int ret;
@@ -33,8 +47,93 @@ static const struct dw_mci_drv_data k3_drv_data = {
 	.set_ios		= dw_mci_k3_set_ios,
 };
 
+static int dw_mci_hi6220_parse_dt(struct dw_mci *host)
+{
+	struct k3_priv *priv;
+
+	priv = devm_kzalloc(host->dev, sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	priv->reg = syscon_regmap_lookup_by_phandle(host->dev->of_node,
+					 "hisilicon,peripheral-syscon");
+	if (IS_ERR(priv->reg))
+		priv->reg = NULL;
+
+	host->priv = priv;
+	return 0;
+}
+
+static int dw_mci_hi6220_switch_voltage(struct mmc_host *mmc, struct mmc_ios *ios)
+{
+	struct dw_mci_slot *slot = mmc_priv(mmc);
+	struct k3_priv *priv;
+	struct dw_mci *host;
+	int min_uv, max_uv;
+	int ret;
+
+	host = slot->host;
+	priv = host->priv;
+
+	if (!priv || !priv->reg)
+		return 0;
+
+	if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_330) {
+		ret = regmap_update_bits(priv->reg, AO_SCTRL_CTRL3,
+					 AO_SCTRL_SEL18, 0);
+		min_uv = 3000000;
+		max_uv = 3000000;
+	} else if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_180) {
+		ret = regmap_update_bits(priv->reg, AO_SCTRL_CTRL3,
+					 AO_SCTRL_SEL18, AO_SCTRL_SEL18);
+		min_uv = 1800000;
+		max_uv = 1800000;
+	} else {
+		dev_dbg(host->dev, "voltage not supported\n");
+		return -EINVAL;
+	}
+
+	if (ret) {
+		dev_dbg(host->dev, "switch voltage failed\n");
+		return ret;
+	}
+
+	if (IS_ERR_OR_NULL(mmc->supply.vqmmc))
+		return 0;
+
+	ret = regulator_set_voltage(mmc->supply.vqmmc, min_uv, max_uv);
+	if (ret) {
+		dev_dbg(host->dev, "Regulator set error %d: %d - %d\n",
+				 ret, min_uv, max_uv);
+		return ret;
+	}
+
+	return 0;
+}
+
+static void dw_mci_hi6220_set_ios(struct dw_mci *host, struct mmc_ios *ios)
+{
+	int ret;
+	unsigned int clock;
+
+	clock = (ios->clock <= 25000000) ? 25000000 : ios->clock;
+
+	ret = clk_set_rate(host->biu_clk, clock);
+	if (ret)
+		dev_warn(host->dev, "failed to set rate %uHz\n", clock);
+
+	host->bus_hz = clk_get_rate(host->biu_clk);
+}
+
+static const struct dw_mci_drv_data hi6220_data = {
+	.switch_voltage		= dw_mci_hi6220_switch_voltage,
+	.set_ios		= dw_mci_hi6220_set_ios,
+	.parse_dt		= dw_mci_hi6220_parse_dt,
+};
+
 static const struct of_device_id dw_mci_k3_match[] = {
 	{ .compatible = "hisilicon,hi4511-dw-mshc", .data = &k3_drv_data, },
+	{ .compatible = "hisilicon,hi6220-dw-mshc", .data = &hi6220_data, },
 	{},
 };
 MODULE_DEVICE_TABLE(of, dw_mci_k3_match);
-- 
1.9.1


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

* Re: [PATCH v3 0/3] dw_mmc-k3 support hi6220
  2015-05-14  8:45 [PATCH v3 0/3] dw_mmc-k3 support hi6220 Zhangfei Gao
                   ` (2 preceding siblings ...)
  2015-05-14  8:45 ` [PATCH v3 3/3] mmc: dw_mmc: k3: support hi6220 Zhangfei Gao
@ 2015-05-15  9:41 ` Jaehoon Chung
  2015-05-18  5:12   ` zhangfei
  3 siblings, 1 reply; 6+ messages in thread
From: Jaehoon Chung @ 2015-05-15  9:41 UTC (permalink / raw)
  To: Zhangfei Gao, Jaehoon Chung, ulf.hansson; +Cc: linux-mmc, devicetree

Hi, Zhangfei.

I will apply this patchset at my dw-mmc tree.
Thanks!

Best Regards,
Jaehoon Chung

On 05/14/2015 05:45 PM, Zhangfei Gao wrote:
> v3:
> Suggested by Jaehoon
> Add comments about register AO_SCTRL_CTRL3 and remove one unused vector
> 
> v2: 
> fix comments from Jaehoon
> fix some issues in sdr12 & sdr25 mode
> 
> Zhangfei Gao (3):
>   Document: dw_mmc-k3: add document of hi6220 mmc
>   mmc: dw_mmc: add switch_voltage
>   mmc: dw_mmc: k3: support hi6220
> 
>  .../devicetree/bindings/mmc/k3-dw-mshc.txt         |  28 ++++++
>  drivers/mmc/host/dw_mmc-k3.c                       | 103 ++++++++++++++++++++-
>  drivers/mmc/host/dw_mmc.c                          |   4 +
>  drivers/mmc/host/dw_mmc.h                          |   2 +
>  4 files changed, 135 insertions(+), 2 deletions(-)
> 


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

* Re: [PATCH v3 0/3] dw_mmc-k3 support hi6220
  2015-05-15  9:41 ` [PATCH v3 0/3] dw_mmc-k3 " Jaehoon Chung
@ 2015-05-18  5:12   ` zhangfei
  0 siblings, 0 replies; 6+ messages in thread
From: zhangfei @ 2015-05-18  5:12 UTC (permalink / raw)
  To: Jaehoon Chung, ulf.hansson; +Cc: linux-mmc, devicetree


Thanks Jaehoon for the help.

On 05/15/2015 05:41 PM, Jaehoon Chung wrote:
> Hi, Zhangfei.
>
> I will apply this patchset at my dw-mmc tree.
> Thanks!
>
> Best Regards,
> Jaehoon Chung


>
> On 05/14/2015 05:45 PM, Zhangfei Gao wrote:
>> v3:
>> Suggested by Jaehoon
>> Add comments about register AO_SCTRL_CTRL3 and remove one unused vector
>>
>> v2:
>> fix comments from Jaehoon
>> fix some issues in sdr12 & sdr25 mode
>>
>> Zhangfei Gao (3):
>>    Document: dw_mmc-k3: add document of hi6220 mmc
>>    mmc: dw_mmc: add switch_voltage
>>    mmc: dw_mmc: k3: support hi6220
>>
>>   .../devicetree/bindings/mmc/k3-dw-mshc.txt         |  28 ++++++
>>   drivers/mmc/host/dw_mmc-k3.c                       | 103 ++++++++++++++++++++-
>>   drivers/mmc/host/dw_mmc.c                          |   4 +
>>   drivers/mmc/host/dw_mmc.h                          |   2 +
>>   4 files changed, 135 insertions(+), 2 deletions(-)
>>
>

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

end of thread, other threads:[~2015-05-18  5:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-14  8:45 [PATCH v3 0/3] dw_mmc-k3 support hi6220 Zhangfei Gao
2015-05-14  8:45 ` [PATCH v3 1/3] Document: dw_mmc-k3: add document of hi6220 mmc Zhangfei Gao
     [not found] ` <1431593119-31889-1-git-send-email-zhangfei.gao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2015-05-14  8:45   ` [PATCH v3 2/3] mmc: dw_mmc: add switch_voltage Zhangfei Gao
2015-05-14  8:45 ` [PATCH v3 3/3] mmc: dw_mmc: k3: support hi6220 Zhangfei Gao
2015-05-15  9:41 ` [PATCH v3 0/3] dw_mmc-k3 " Jaehoon Chung
2015-05-18  5:12   ` zhangfei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).