* [PATCH 0/3] dw_mmc-k3 support hi6220
@ 2015-05-01 1:46 Zhangfei Gao
2015-05-01 1:46 ` [PATCH 1/3] Document: dw_mmc-k3: add document of hi6220 mmc Zhangfei Gao
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Zhangfei Gao @ 2015-05-01 1:46 UTC (permalink / raw)
To: Jaehoon Chung, Ulf Hansson
Cc: linux-mmc-u79uwXL29TY76Z2rM5mHXA,
devicetree-u79uwXL29TY76Z2rM5mHXA, Zhangfei Gao
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 | 50 ++++++++++
drivers/mmc/host/dw_mmc-k3.c | 104 ++++++++++++++++++++-
drivers/mmc/host/dw_mmc.c | 6 ++
drivers/mmc/host/dw_mmc.h | 2 +
4 files changed, 160 insertions(+), 2 deletions(-)
--
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 [flat|nested] 7+ messages in thread
* [PATCH 1/3] Document: dw_mmc-k3: add document of hi6220 mmc
2015-05-01 1:46 [PATCH 0/3] dw_mmc-k3 support hi6220 Zhangfei Gao
@ 2015-05-01 1:46 ` Zhangfei Gao
2015-05-04 0:15 ` Jaehoon Chung
2015-05-01 1:46 ` [PATCH 2/3] mmc: dw_mmc: add switch_voltage Zhangfei Gao
2015-05-01 1:46 ` [PATCH 3/3] mmc: dw_mmc: k3: support hi6220 Zhangfei Gao
2 siblings, 1 reply; 7+ messages in thread
From: Zhangfei Gao @ 2015-05-01 1:46 UTC (permalink / raw)
To: Jaehoon Chung, Ulf Hansson; +Cc: linux-mmc, devicetree, Zhangfei Gao
Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
---
.../devicetree/bindings/mmc/k3-dw-mshc.txt | 50 ++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/Documentation/devicetree/bindings/mmc/k3-dw-mshc.txt b/Documentation/devicetree/bindings/mmc/k3-dw-mshc.txt
index 3b35449..a353d0b 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,49 @@ Example:
cap-mmc-highspeed;
cap-sd-highspeed;
};
+
+ /* for Hi6220 */
+
+ /* SoC portion */
+ dwmmc_0: dwmmc0@f723d000 {
+ compatible = "hisilicon,hi6220-dw-mshc";
+ num-slots = <0x1>;
+ board-mmc-bus-clk = <0x0>;
+ reg = <0x0 0xf723d000 0x0 0x1000>;
+ interrupts = <0x0 0x48 0x4>;
+ clocks = <&clock_sys HI6220_MMC0_CIUCLK>, <&clock_sys HI6220_MMC0_CLK>;
+ clock-names = "ciu", "biu";
+ };
+
+ dwmmc_1: dwmmc1@f723e000 {
+ compatible = "hisilicon,hi6220-dw-mshc";
+ num-slots = <0x1>;
+ board-mmc-bus-clk = <0x0>;
+ 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";
+ };
+
+ /* Board portion */
+ dwmmc_0: dwmmc0@f723d000 {
+ bus-width = <0x8>;
+ broken-cd;
+ vmmc-supply = <&ldo19>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&emmc_pmx_func &emmc_clk_cfg_func
+ &emmc_cfg_func &emmc_rst_cfg_func>;
+ };
+
+ dwmmc_1: dwmmc1@f723e000 {
+ bus-width = <0x4>;
+ disable-wp;
+ 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] 7+ messages in thread
* [PATCH 2/3] mmc: dw_mmc: add switch_voltage
2015-05-01 1:46 [PATCH 0/3] dw_mmc-k3 support hi6220 Zhangfei Gao
2015-05-01 1:46 ` [PATCH 1/3] Document: dw_mmc-k3: add document of hi6220 mmc Zhangfei Gao
@ 2015-05-01 1:46 ` Zhangfei Gao
2015-05-04 0:25 ` Jaehoon Chung
2015-05-01 1:46 ` [PATCH 3/3] mmc: dw_mmc: k3: support hi6220 Zhangfei Gao
2 siblings, 1 reply; 7+ messages in thread
From: Zhangfei Gao @ 2015-05-01 1:46 UTC (permalink / raw)
To: Jaehoon Chung, Ulf Hansson
Cc: linux-mmc, devicetree, 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@linaro.org>
Signed-off-by: Dan Yuan <yuandan@hisilicon.com>
Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
---
drivers/mmc/host/dw_mmc.c | 6 ++++++
drivers/mmc/host/dw_mmc.h | 2 ++
2 files changed, 8 insertions(+)
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index 69952b2..488a8af 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -1236,11 +1236,17 @@ 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) {
+ ret = drv_data->switch_voltage(mmc, ios);
+ return ret;
+ }
+
/*
* 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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/3] mmc: dw_mmc: k3: support hi6220
2015-05-01 1:46 [PATCH 0/3] dw_mmc-k3 support hi6220 Zhangfei Gao
2015-05-01 1:46 ` [PATCH 1/3] Document: dw_mmc-k3: add document of hi6220 mmc Zhangfei Gao
2015-05-01 1:46 ` [PATCH 2/3] mmc: dw_mmc: add switch_voltage Zhangfei Gao
@ 2015-05-01 1:46 ` Zhangfei Gao
2015-05-04 0:56 ` Jaehoon Chung
2 siblings, 1 reply; 7+ messages in thread
From: Zhangfei Gao @ 2015-05-01 1:46 UTC (permalink / raw)
To: Jaehoon Chung, Ulf Hansson
Cc: linux-mmc, devicetree, Zhangfei Gao, Jorge A. Ramirez-Ortiz,
Dan Yuan
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 | 104 ++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 102 insertions(+), 2 deletions(-)
diff --git a/drivers/mmc/host/dw_mmc-k3.c b/drivers/mmc/host/dw_mmc-k3.c
index 650f9cc..ab3dc59 100644
--- a/drivers/mmc/host/dw_mmc-k3.c
+++ b/drivers/mmc/host/dw_mmc-k3.c
@@ -8,16 +8,29 @@
* (at your option) any later version.
*/
-#include <linux/module.h>
-#include <linux/platform_device.h>
#include <linux/clk.h>
+#include <linux/delay.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"
+#define AO_SCTRL_SEL18 BIT(10)
+#define AO_SCTRL_CTRL3 0x40C
+
+#define SDMMC_CMD_DISABLE_BOOT BIT(26)
+
+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 +46,95 @@ 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;
+
+ min_uv = 1800000;
+ max_uv = 1800000;
+
+ if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_330) {
+ ret = regmap_update_bits(priv->reg, AO_SCTRL_CTRL3,
+ AO_SCTRL_SEL18, 0);
+ if (ret) {
+ dev_dbg(host->dev, "switch voltage failed\n");
+ return ret;
+ }
+ min_uv = 3000000;
+ max_uv = 3000000;
+ }
+
+ 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;
+ }
+
+ ret = regulator_enable(mmc->supply.vqmmc);
+ if (ret) {
+ dev_dbg(host->dev, "Regulator enable error %d\n", ret);
+ return ret;
+ }
+
+ usleep_range(5000, 5500);
+
+ 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] 7+ messages in thread
* Re: [PATCH 1/3] Document: dw_mmc-k3: add document of hi6220 mmc
2015-05-01 1:46 ` [PATCH 1/3] Document: dw_mmc-k3: add document of hi6220 mmc Zhangfei Gao
@ 2015-05-04 0:15 ` Jaehoon Chung
0 siblings, 0 replies; 7+ messages in thread
From: Jaehoon Chung @ 2015-05-04 0:15 UTC (permalink / raw)
To: Zhangfei Gao, Ulf Hansson; +Cc: linux-mmc, devicetree
Hi, Zhangfei.
Is there no commit message for this patch?
On 05/01/2015 10:46 AM, Zhangfei Gao wrote:
> Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
> ---
> .../devicetree/bindings/mmc/k3-dw-mshc.txt | 50 ++++++++++++++++++++++
> 1 file changed, 50 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/mmc/k3-dw-mshc.txt b/Documentation/devicetree/bindings/mmc/k3-dw-mshc.txt
> index 3b35449..a353d0b 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,49 @@ Example:
> cap-mmc-highspeed;
> cap-sd-highspeed;
> };
> +
> + /* for Hi6220 */
> +
> + /* SoC portion */
> + dwmmc_0: dwmmc0@f723d000 {
> + compatible = "hisilicon,hi6220-dw-mshc";
> + num-slots = <0x1>;
> + board-mmc-bus-clk = <0x0>;
> + reg = <0x0 0xf723d000 0x0 0x1000>;
> + interrupts = <0x0 0x48 0x4>;
> + clocks = <&clock_sys HI6220_MMC0_CIUCLK>, <&clock_sys HI6220_MMC0_CLK>;
> + clock-names = "ciu", "biu";
> + };
> +
> + dwmmc_1: dwmmc1@f723e000 {
> + compatible = "hisilicon,hi6220-dw-mshc";
> + num-slots = <0x1>;
> + board-mmc-bus-clk = <0x0>;
> + 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";
> + };
this is example, so i think it doesn't need to add dwmmc_1's case.
> +
> + /* Board portion */
What are Board portion and SoC portion?
This should be merged to one node. why do you separate this?
Best Regards,
Jaehoon Chung
> + dwmmc_0: dwmmc0@f723d000 {
> + bus-width = <0x8>;
> + broken-cd;
> + vmmc-supply = <&ldo19>;
> + pinctrl-names = "default";
> + pinctrl-0 = <&emmc_pmx_func &emmc_clk_cfg_func
> + &emmc_cfg_func &emmc_rst_cfg_func>;
> + };
> +
> + dwmmc_1: dwmmc1@f723e000 {
> + bus-width = <0x4>;
> + disable-wp;
> + 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>;
> + };
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/3] mmc: dw_mmc: add switch_voltage
2015-05-01 1:46 ` [PATCH 2/3] mmc: dw_mmc: add switch_voltage Zhangfei Gao
@ 2015-05-04 0:25 ` Jaehoon Chung
0 siblings, 0 replies; 7+ messages in thread
From: Jaehoon Chung @ 2015-05-04 0:25 UTC (permalink / raw)
To: Zhangfei Gao, Ulf Hansson
Cc: linux-mmc, devicetree, Jorge A. Ramirez-Ortiz, Dan Yuan
Hi, Zhangfei.
On 05/01/2015 10:46 AM, Zhangfei Gao wrote:
> switch_voltage is required on some platform since special register accessing
>
> 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.c | 6 ++++++
> drivers/mmc/host/dw_mmc.h | 2 ++
> 2 files changed, 8 insertions(+)
>
> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
> index 69952b2..488a8af 100644
> --- a/drivers/mmc/host/dw_mmc.c
> +++ b/drivers/mmc/host/dw_mmc.c
> @@ -1236,11 +1236,17 @@ 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) {
> + ret = drv_data->switch_voltage(mmc, ios);
> + return ret;
Just use "return drv_data->switch_voltage(mmc, ios);"
Best Regards,
Jaehoon Chung
> + }
> +
> /*
> * 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_ */
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 3/3] mmc: dw_mmc: k3: support hi6220
2015-05-01 1:46 ` [PATCH 3/3] mmc: dw_mmc: k3: support hi6220 Zhangfei Gao
@ 2015-05-04 0:56 ` Jaehoon Chung
0 siblings, 0 replies; 7+ messages in thread
From: Jaehoon Chung @ 2015-05-04 0:56 UTC (permalink / raw)
To: Zhangfei Gao, Ulf Hansson
Cc: linux-mmc, devicetree, Jorge A. Ramirez-Ortiz, Dan Yuan
Hi, Zhangfei.
Could you add the commit message for this patch?
On 05/01/2015 10:46 AM, Zhangfei Gao wrote:
> 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 | 104 ++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 102 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/host/dw_mmc-k3.c b/drivers/mmc/host/dw_mmc-k3.c
> index 650f9cc..ab3dc59 100644
> --- a/drivers/mmc/host/dw_mmc-k3.c
> +++ b/drivers/mmc/host/dw_mmc-k3.c
> @@ -8,16 +8,29 @@
> * (at your option) any later version.
> */
>
> -#include <linux/module.h>
> -#include <linux/platform_device.h>
> #include <linux/clk.h>
> +#include <linux/delay.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"
>
> +#define AO_SCTRL_SEL18 BIT(10)
> +#define AO_SCTRL_CTRL3 0x40C
Does it use these at all K3 SoC?
> +
> +#define SDMMC_CMD_DISABLE_BOOT BIT(26)
> +
> +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 +46,95 @@ 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 returned at this point, switch_voltage don't do nothing.
See voltage_switch into dw_mmc.c.
"return 0" is meaning that switch_voltage was done.
How about using the error number?
> +
> + min_uv = 1800000;
> + max_uv = 1800000;
> +
> + if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_330) {
> + ret = regmap_update_bits(priv->reg, AO_SCTRL_CTRL3,
> + AO_SCTRL_SEL18, 0);
> + if (ret) {
> + dev_dbg(host->dev, "switch voltage failed\n");
> + return ret;
> + }
> + min_uv = 3000000;
> + max_uv = 3000000;
> + }
> +
> + if (IS_ERR_OR_NULL(mmc->supply.vqmmc))
> + return 0;
ditto.
> +
> + 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;
> + }
> +
> + ret = regulator_enable(mmc->supply.vqmmc);
> + if (ret) {
> + dev_dbg(host->dev, "Regulator enable error %d\n", ret);
> + return ret;
> + }
> +
> + usleep_range(5000, 5500);
What's delay?
> +
> + 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;
Even though ios->clock is 400KHz, is it set to 25MHz?
Best Regards,
Jaehoon Chung
> +
> + 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);
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-05-04 0:56 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-01 1:46 [PATCH 0/3] dw_mmc-k3 support hi6220 Zhangfei Gao
2015-05-01 1:46 ` [PATCH 1/3] Document: dw_mmc-k3: add document of hi6220 mmc Zhangfei Gao
2015-05-04 0:15 ` Jaehoon Chung
2015-05-01 1:46 ` [PATCH 2/3] mmc: dw_mmc: add switch_voltage Zhangfei Gao
2015-05-04 0:25 ` Jaehoon Chung
2015-05-01 1:46 ` [PATCH 3/3] mmc: dw_mmc: k3: support hi6220 Zhangfei Gao
2015-05-04 0:56 ` Jaehoon Chung
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).