* [PATCH v2 0/3] dw_mmc-k3 support hi6220 @ 2015-05-07 7:56 Zhangfei Gao 2015-05-07 7:56 ` [PATCH v2 1/3] Document: dw_mmc-k3: add document of hi6220 mmc Zhangfei Gao ` (2 more replies) 0 siblings, 3 replies; 10+ messages in thread From: Zhangfei Gao @ 2015-05-07 7:56 UTC (permalink / raw) To: Jaehoon Chung, ulf.hansson; +Cc: linux-mmc, devicetree, Zhangfei Gao 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 | 101 ++++++++++++++++++++- drivers/mmc/host/dw_mmc.c | 4 + drivers/mmc/host/dw_mmc.h | 2 + 4 files changed, 133 insertions(+), 2 deletions(-) -- 1.9.1 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 1/3] Document: dw_mmc-k3: add document of hi6220 mmc 2015-05-07 7:56 [PATCH v2 0/3] dw_mmc-k3 support hi6220 Zhangfei Gao @ 2015-05-07 7:56 ` Zhangfei Gao 2015-05-12 7:36 ` Jaehoon Chung 2015-05-07 7:56 ` [PATCH v2 2/3] mmc: dw_mmc: add switch_voltage Zhangfei Gao [not found] ` <1430985401-12202-1-git-send-email-zhangfei.gao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 2 siblings, 1 reply; 10+ messages in thread From: Zhangfei Gao @ 2015-05-07 7:56 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] 10+ messages in thread
* Re: [PATCH v2 1/3] Document: dw_mmc-k3: add document of hi6220 mmc 2015-05-07 7:56 ` [PATCH v2 1/3] Document: dw_mmc-k3: add document of hi6220 mmc Zhangfei Gao @ 2015-05-12 7:36 ` Jaehoon Chung 2015-05-12 7:59 ` zhangfei 0 siblings, 1 reply; 10+ messages in thread From: Jaehoon Chung @ 2015-05-12 7:36 UTC (permalink / raw) To: Zhangfei Gao, ulf.hansson; +Cc: linux-mmc, devicetree Hi, Zhangfei. On 05/07/2015 04:56 PM, Zhangfei Gao wrote: > 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. > I'm not sure.. but i think this patch could be added just the compatible and optional properties descriptions. If SoC will be added, it need not to add every example, doesn't it? how about removing the below example? This is just my opinion. :) If there is a special reason that add example...let me know, plz. Best Regards, Jaehoon Chung > 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>; > + }; > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/3] Document: dw_mmc-k3: add document of hi6220 mmc 2015-05-12 7:36 ` Jaehoon Chung @ 2015-05-12 7:59 ` zhangfei 2015-05-13 22:17 ` Jaehoon Chung 0 siblings, 1 reply; 10+ messages in thread From: zhangfei @ 2015-05-12 7:59 UTC (permalink / raw) To: Jaehoon Chung, ulf.hansson; +Cc: linux-mmc, devicetree On 05/12/2015 03:36 PM, Jaehoon Chung wrote: > Hi, Zhangfei. > > On 05/07/2015 04:56 PM, Zhangfei Gao wrote: >> 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. >> > I'm not sure.. > but i think this patch could be added just the compatible and optional properties descriptions. > If SoC will be added, it need not to add every example, doesn't it? > > how about removing the below example? This is just my opinion. :) > If there is a special reason that add example...let me know, plz. I am adding this example just for two reasons 1. There is still some components need to be upstreamed before we add to dts, like pinctrl and regulator, which still need some time. So add here for quick reference after the component is enabled. Had experience before that hip04_eth is merged but dts is delayed, thanks to the document, we can add it quickly. 2. sd has some special requirement of "hisilicon,peripheral-syscon", which used for controlling voltage What do you think? Thanks ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/3] Document: dw_mmc-k3: add document of hi6220 mmc 2015-05-12 7:59 ` zhangfei @ 2015-05-13 22:17 ` Jaehoon Chung 0 siblings, 0 replies; 10+ messages in thread From: Jaehoon Chung @ 2015-05-13 22:17 UTC (permalink / raw) To: zhangfei, Jaehoon Chung, ulf.hansson; +Cc: linux-mmc, devicetree On 05/12/2015 04:59 PM, zhangfei wrote: > > > On 05/12/2015 03:36 PM, Jaehoon Chung wrote: >> Hi, Zhangfei. >> >> On 05/07/2015 04:56 PM, Zhangfei Gao wrote: >>> 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. >>> >> I'm not sure.. >> but i think this patch could be added just the compatible and optional properties descriptions. >> If SoC will be added, it need not to add every example, doesn't it? >> >> how about removing the below example? This is just my opinion. :) >> If there is a special reason that add example...let me know, plz. > > I am adding this example just for two reasons > > 1. There is still some components need to be upstreamed before we add to dts, like pinctrl and regulator, which still need some time. > So add here for quick reference after the component is enabled. > Had experience before that hip04_eth is merged but dts is delayed, thanks to the document, we can add it quickly. > > 2. sd has some special requirement of "hisilicon,peripheral-syscon", which used for controlling voltage > > > What do you think? Thanks for kindly explanation! I understood your intention. Best Regards, Jaehoon Chung > > Thanks > -- > To unsubscribe from this list: send the line "unsubscribe linux-mmc" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 2/3] mmc: dw_mmc: add switch_voltage 2015-05-07 7:56 [PATCH v2 0/3] dw_mmc-k3 support hi6220 Zhangfei Gao 2015-05-07 7:56 ` [PATCH v2 1/3] Document: dw_mmc-k3: add document of hi6220 mmc Zhangfei Gao @ 2015-05-07 7:56 ` Zhangfei Gao [not found] ` <1430985401-12202-1-git-send-email-zhangfei.gao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 2 siblings, 0 replies; 10+ messages in thread From: Zhangfei Gao @ 2015-05-07 7:56 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 | 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 ^ permalink raw reply related [flat|nested] 10+ messages in thread
[parent not found: <1430985401-12202-1-git-send-email-zhangfei.gao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>]
* [PATCH v2 3/3] mmc: dw_mmc: k3: support hi6220 [not found] ` <1430985401-12202-1-git-send-email-zhangfei.gao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> @ 2015-05-07 7:56 ` Zhangfei Gao 2015-05-13 22:17 ` Jaehoon Chung 0 siblings, 1 reply; 10+ messages in thread From: Zhangfei Gao @ 2015-05-07 7:56 UTC (permalink / raw) To: Jaehoon Chung, ulf.hansson-QSEj5FYQhm4dnm+yROfE0A Cc: linux-mmc-u79uwXL29TY76Z2rM5mHXA, devicetree-u79uwXL29TY76Z2rM5mHXA, 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-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-k3.c | 101 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 99 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/host/dw_mmc-k3.c b/drivers/mmc/host/dw_mmc-k3.c index 650f9cc..bc16bee 100644 --- a/drivers/mmc/host/dw_mmc-k3.c +++ b/drivers/mmc/host/dw_mmc-k3.c @@ -8,16 +8,28 @@ * (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" +#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 +45,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 -- 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] 10+ messages in thread
* Re: [PATCH v2 3/3] mmc: dw_mmc: k3: support hi6220 2015-05-07 7:56 ` [PATCH v2 3/3] mmc: dw_mmc: k3: support hi6220 Zhangfei Gao @ 2015-05-13 22:17 ` Jaehoon Chung 2015-05-14 5:52 ` zhangfei 0 siblings, 1 reply; 10+ messages in thread From: Jaehoon Chung @ 2015-05-13 22:17 UTC (permalink / raw) To: Zhangfei Gao, ulf.hansson Cc: linux-mmc, devicetree, Jorge A. Ramirez-Ortiz, Dan Yuan On 05/07/2015 04:56 PM, Zhangfei Gao wrote: > 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 | 101 ++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 99 insertions(+), 2 deletions(-) > > diff --git a/drivers/mmc/host/dw_mmc-k3.c b/drivers/mmc/host/dw_mmc-k3.c > index 650f9cc..bc16bee 100644 > --- a/drivers/mmc/host/dw_mmc-k3.c > +++ b/drivers/mmc/host/dw_mmc-k3.c > @@ -8,16 +8,28 @@ > * (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" > > +#define AO_SCTRL_SEL18 BIT(10) > +#define AO_SCTRL_CTRL3 0x40C how about adding the comment? > + > +#define SDMMC_CMD_DISABLE_BOOT BIT(26) I can't find where this define is used. > + > +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 +45,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; Is it right that return to 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; max_uv and min_uv are fixed as 3.0v and 1.8V? > + } 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); > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 3/3] mmc: dw_mmc: k3: support hi6220 2015-05-13 22:17 ` Jaehoon Chung @ 2015-05-14 5:52 ` zhangfei 0 siblings, 0 replies; 10+ messages in thread From: zhangfei @ 2015-05-14 5:52 UTC (permalink / raw) To: Jaehoon Chung, ulf.hansson Cc: linux-mmc, devicetree, Jorge A. Ramirez-Ortiz, Dan Yuan On 05/14/2015 06:17 AM, Jaehoon Chung wrote: > On 05/07/2015 04:56 PM, Zhangfei Gao wrote: >> 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 | 101 ++++++++++++++++++++++++++++++++++++++++++- >> 1 file changed, 99 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/mmc/host/dw_mmc-k3.c b/drivers/mmc/host/dw_mmc-k3.c >> index 650f9cc..bc16bee 100644 >> --- a/drivers/mmc/host/dw_mmc-k3.c >> +++ b/drivers/mmc/host/dw_mmc-k3.c >> @@ -8,16 +8,28 @@ >> * (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" >> >> +#define AO_SCTRL_SEL18 BIT(10) >> +#define AO_SCTRL_CTRL3 0x40C > > how about adding the comment? Sure > >> + >> +#define SDMMC_CMD_DISABLE_BOOT BIT(26) > > I can't find where this define is used. My bad, the usage is removed for simple, will remove this as well > >> + >> +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 +45,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; > > Is it right that return to 0? Since only sd need voltage switch and the register AO_SCTRL only takes care of sd. While emmc directly use 1.8v single voltage, so directly 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; > > max_uv and min_uv are fixed as 3.0v and 1.8V? Double confirmed with hisilicon, their controller has to be set 3v or 1.8v for io voltage. Otherwise it can not work. Thanks ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 0/3] dw_mmc-k3 support hi6220 @ 2015-05-07 7:51 Zhangfei Gao 0 siblings, 0 replies; 10+ messages in thread From: Zhangfei Gao @ 2015-05-07 7:51 UTC (permalink / raw) To: Jaehoon Chung, ulf.hansson; +Cc: linux-mmc, devicetree, Zhangfei Gao 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 | 101 ++++++++++++++++++++- drivers/mmc/host/dw_mmc.c | 4 + drivers/mmc/host/dw_mmc.h | 2 + 4 files changed, 133 insertions(+), 2 deletions(-) -- 1.9.1 ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2015-05-14 5:52 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-05-07 7:56 [PATCH v2 0/3] dw_mmc-k3 support hi6220 Zhangfei Gao 2015-05-07 7:56 ` [PATCH v2 1/3] Document: dw_mmc-k3: add document of hi6220 mmc Zhangfei Gao 2015-05-12 7:36 ` Jaehoon Chung 2015-05-12 7:59 ` zhangfei 2015-05-13 22:17 ` Jaehoon Chung 2015-05-07 7:56 ` [PATCH v2 2/3] mmc: dw_mmc: add switch_voltage Zhangfei Gao [not found] ` <1430985401-12202-1-git-send-email-zhangfei.gao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 2015-05-07 7:56 ` [PATCH v2 3/3] mmc: dw_mmc: k3: support hi6220 Zhangfei Gao 2015-05-13 22:17 ` Jaehoon Chung 2015-05-14 5:52 ` zhangfei -- strict thread matches above, loose matches on Subject: below -- 2015-05-07 7:51 [PATCH v2 0/3] dw_mmc-k3 " Zhangfei Gao
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).