mmc: introduce mmc_power_init and pwrup hook function
RFC 1/2 mmc: introduce mmc_power_init and pwrup hook function
In device tree, there is vmmc-supply property for SD/MMC. Introduce mmc_power_init function and pwrup hook function to let the specific drivers handle vmmc-supply.
mmc_power_init will first invoke board_mmc_power_init to avoid break boards which already implement board_mmc_power_init.
Then if pwrup hook functions have been implemented for different mmc drivers, pwrup will be invoked.
--- drivers/mmc/mmc.c | 15 ++++++++++++++- include/mmc.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-)
drivers/mmc/mmc.c +14 -1
@@ -1594,6 +1594,16 @@ __weak void board_mmc_power_init(void) { } +__weak int mmc_power_init (struct mmc *mmc) +{ +board_mmc_power_init (); + +if (mmc->cfg->ops->pwrup) +return mmc->cfg->ops->pwrup (mmc); + +return 0 ; +} +int mmc_start_init (struct mmc *mmc) {int err;
@@ -1613,7 +1623,10 @@ int mmc_start_init(struct mmc *mmc)#ifdef CONFIG_FSL_ESDHC_ADAPTER_IDENT mmc_adapter_card_type_ident ();#endif -board_mmc_power_init (); + + err =mmc_power_init (mmc); +if (err) +return err;/* made sure it's not NULL earlier */ err = mmc->cfg->ops->init (mmc);
include/mmc.h +1 -0
@@ -329,6 +329,7 @@ struct mmc_ops {int (*init)(struct mmc *mmc);int (*getcd)(struct mmc *mmc);int (*getwp)(struct mmc *mmc); +int (*pwrup)(struct mmc *mmc); };struct mmc_config {
Signature · 1 line
2.6.2
RFC 2/2 dm: mmc: implement pwrup function
If vmmc-supply property is provided, then enable it. If vmmc-supply is not provided, just ignore it. For now, only fixed regulator is supported.
In device tree:
"
reg_sd1_vmmc: regulator at 1 {
compatible = "regulator-fixed";
regulator-name = "VSD_3V3";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
gpio = <&gpio1 9 GPIO_ACTIVE_HIGH>;
enable-active-high;
};&usdhc1 {
pinctrl-names = "default", "state_100mhz", "state_200mhz";
pinctrl-0 = <&pinctrl_usdhc1>;
pinctrl-1 = <&pinctrl_usdhc1_100mhz>;
pinctrl-2 = <&pinctrl_usdhc1_200mhz>;
cd-gpios = <&gpio1 19 GPIO_ACTIVE_LOW>;
keep-power-in-suspend;
enable-sdio-wakeup;
vmmc-supply = <®_sd1_vmmc>;
status = "okay";
};"
--- drivers/mmc/fsl_esdhc.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
drivers/mmc/fsl_esdhc.c +25 -0
@@ -23,6 +23,7 @@#include <dm.h> #include <asm/arch/clock.h> #include <asm-generic/gpio.h> +#include <power/regulator.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -671,6 +672,29 @@ static int esdhc_getcd(struct mmc *mmc)return timeout >0 ; } +static int esdhc_pwrup (struct mmc *mmc) +{ +#ifdef CONFIG_DM_MMC +struct fsl_esdhc_priv *priv = mmc->priv; +struct udevice *vmmc_supply; +int ret; + + ret =device_get_supply_regulator (priv->dev,"vmmc-supply" , + &vmmc_supply); +if (ret) { +debug ("No vmmc supply\n" ); +return 0 ; + } + + ret =regulator_set_enable (vmmc_supply, true); +if (ret) { +puts ("Error enabling VMMC supply\n" ); +return ret; + } +#endif +return 0 ; +} +static void esdhc_reset (struct fsl_esdhc *regs) {unsigned long timeout =100 ;/* wait max 100 ms */
@@ -690,6 +714,7 @@ static const struct mmc_ops esdhc_ops = { .set_ios = esdhc_set_ios, .init = esdhc_init, .getcd = esdhc_getcd, + .pwrup = esdhc_pwrup, }; static int fsl_esdhc_cfg_to_priv(struct fsl_esdhc_cfg *cfg,
Signature · 1 line
2.6.2
RFC 2/2 dm: mmc: implement pwrup function
Quoted 35 lines · Peng Fan
If vmmc-supply property is provided, then enable it. If vmmc-supply is not provided, just ignore it. For now, only fixed regulator is supported.
In device tree:
"reg_sd1_vmmc: regulator at 1 { compatible = "regulator-fixed"; regulator-name = "VSD_3V3"; regulator-min-microvolt = <3300000>; regulator-max-microvolt = <3300000>; gpio = <&gpio1 9 GPIO_ACTIVE_HIGH>; enable-active-high; };&usdhc1 { pinctrl-names = "default", "state_100mhz", "state_200mhz"; pinctrl-0 = <&pinctrl_usdhc1>; pinctrl-1 = <&pinctrl_usdhc1_100mhz>; pinctrl-2 = <&pinctrl_usdhc1_200mhz>; cd-gpios = <&gpio1 19 GPIO_ACTIVE_LOW>; keep-power-in-suspend; enable-sdio-wakeup; vmmc-supply = <®_sd1_vmmc>; status = "okay"; };"
Signed-off-by Peng Fan <[email protected]>Cc Pantelis Antoniou <[email protected]>Cc Simon Glass <[email protected]>Cc Eric Nelson <[email protected]>Cc York Sun <[email protected]>Cc Stefano Babic <[email protected]>Cc Fabio Estevam <[email protected]>
Quoted 3 lines
--- drivers/mmc/fsl_esdhc.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
RFC 1/2 mmc: introduce mmc_power_init and pwrup hook function
In reply to Peng FanHi Peng,
Quoted 19 lines · Peng Fan
In device tree, there is vmmc-supply property for SD/MMC. Introduce
mmc_power_initfunction and pwrup hook function to let the specific drivers handle vmmc-supply.
mmc_power_initwill first invokeboard_mmc_power_initto avoid break boards which already implementboard_mmc_power_init.Then if pwrup hook functions have been implemented for different mmc drivers, pwrup will be invoked.
Signed-off-by Peng Fan <[email protected]>Cc Pantelis Antoniou <[email protected]>Cc Andrew Gabbasov <[email protected]>Cc Simon Glass <[email protected]>Cc Stephen Warren <[email protected]>Cc Clemens Gruber <[email protected]>Cc Eric Nelson <[email protected]>Cc Stefano Babic <[email protected]>Cc Fabio Estevam <[email protected]>
Quoted 4 lines
--- drivers/mmc/mmc.c | 15 ++++++++++++++- include/mmc.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-)
I wonder if there is a way to handle this property generically?
Regards,
Simon
RFC 1/2 mmc: introduce mmc_power_init and pwrup hook function
Hi Simon,
Quoted 27 lines · Simon Glass
Hi Peng,
Quoted 19 lines · Peng Fan
In device tree, there is vmmc-supply property for SD/MMC. Introduce
mmc_power_initfunction and pwrup hook function to let the specific drivers handle vmmc-supply.
mmc_power_initwill first invokeboard_mmc_power_initto avoid break boards which already implementboard_mmc_power_init.Then if pwrup hook functions have been implemented for different mmc drivers, pwrup will be invoked.
Signed-off-by Peng Fan <[email protected]>Cc Pantelis Antoniou <[email protected]>Cc Andrew Gabbasov <[email protected]>Cc Simon Glass <[email protected]>Cc Stephen Warren <[email protected]>Cc Clemens Gruber <[email protected]>Cc Eric Nelson <[email protected]>Cc Stefano Babic <[email protected]>Cc Fabio Estevam <[email protected]>Quoted 4 lines
--- drivers/mmc/mmc.c | 15 ++++++++++++++- include/mmc.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-)
Quoted 3 lines
Acked-by Simon Glass <[email protected]>I wonder if there is a way to handle this property generically?
Now I do not have a better idea for this (:
Or we directly more the following piece code to driver/mmc/mmc.c? And Add a device entry for struct mmc.
static int xxx_pwrup(struct mmc *mmc)
{
#ifdef CONFIG_DM_MMC
struct udevice *vmmc_supply;
int ret;
ret = device_get_supply_regulator(mmc->dev, "vmmc-supply",
&vmmc_supply);
if (ret) {
debug("No vmmc supply\n");
return 0;
}
ret = regulator_set_enable(vmmc_supply, true);
if (ret) {
puts("Error enabling VMMC supply\n");
return ret;
}
#endif
return 0;
}Thanks,
Peng.
Quoted 3 lines
Regards,
Simon
RFC 1/2 mmc: introduce mmc_power_init and pwrup hook function
Hi Peng,
Quoted 52 lines · Peng Fan
Hi Simon,
Quoted 27 lines · Simon Glass
Hi Peng,
Quoted 19 lines · Peng Fan
In device tree, there is vmmc-supply property for SD/MMC. Introduce
mmc_power_initfunction and pwrup hook function to let the specific drivers handle vmmc-supply.
mmc_power_initwill first invokeboard_mmc_power_initto avoid break boards which already implementboard_mmc_power_init.Then if pwrup hook functions have been implemented for different mmc drivers, pwrup will be invoked.
Signed-off-by Peng Fan <[email protected]>Cc Pantelis Antoniou <[email protected]>Cc Andrew Gabbasov <[email protected]>Cc Simon Glass <[email protected]>Cc Stephen Warren <[email protected]>Cc Clemens Gruber <[email protected]>Cc Eric Nelson <[email protected]>Cc Stefano Babic <[email protected]>Cc Fabio Estevam <[email protected]>Quoted 4 lines
--- drivers/mmc/mmc.c | 15 ++++++++++++++- include/mmc.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-)Quoted 3 lines
Acked-by Simon Glass <[email protected]>I wonder if there is a way to handle this property generically?
Now I do not have a better idea for this (:
Or we directly more the following piece code to
driver/mmc/mmc.c? And Add a device entry for struct mmc.static int
xxx_pwrup(struct mmc *mmc)
{#ifdef CONFIG_DM_MMC struct udevice *vmmc_supply; int ret; ret = device_get_supply_regulator(mmc->dev, "vmmc-supply", &vmmc_supply); if (ret) { debug("No vmmc supply\n"); return 0; }
Quoted 9 lines
ret = regulator_set_enable(vmmc_supply, true);
if (ret) {
puts("Error enabling VMMC supply\n");
return ret;
}
#endif
return 0;
}That seems better to me.
Regards,
Simon
RFC 1/2 mmc: introduce mmc_power_init and pwrup hook function
Hi Simon,
Quoted 65 lines · Simon Glass
Hi Peng,
Quoted 52 lines · Peng Fan
Hi Simon,
Quoted 27 lines · Simon Glass
Hi Peng,
Quoted 19 lines · Peng Fan
In device tree, there is vmmc-supply property for SD/MMC. Introduce
mmc_power_initfunction and pwrup hook function to let the specific drivers handle vmmc-supply.
mmc_power_initwill first invokeboard_mmc_power_initto avoid break boards which already implementboard_mmc_power_init.Then if pwrup hook functions have been implemented for different mmc drivers, pwrup will be invoked.
Signed-off-by Peng Fan <[email protected]>Cc Pantelis Antoniou <[email protected]>Cc Andrew Gabbasov <[email protected]>Cc Simon Glass <[email protected]>Cc Stephen Warren <[email protected]>Cc Clemens Gruber <[email protected]>Cc Eric Nelson <[email protected]>Cc Stefano Babic <[email protected]>Cc Fabio Estevam <[email protected]>Quoted 4 lines
--- drivers/mmc/mmc.c | 15 ++++++++++++++- include/mmc.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-)Quoted 3 lines
Acked-by Simon Glass <[email protected]>I wonder if there is a way to handle this property generically?
Now I do not have a better idea for this (:
Or we directly more the following piece code to
driver/mmc/mmc.c? And Add a device entry for struct mmc.static int
xxx_pwrup(struct mmc *mmc)
{#ifdef CONFIG_DM_MMC struct udevice *vmmc_supply; int ret; ret = device_get_supply_regulator(mmc->dev, "vmmc-supply", &vmmc_supply); if (ret) { debug("No vmmc supply\n"); return 0; }Quoted 9 lines
ret = regulator_set_enable(vmmc_supply, true); if (ret) { puts("Error enabling VMMC supply\n"); return ret; } #endif return 0; }
Quoted 1 line
That seems better to me.
Ok, I'll try this new way.
"
we directly more the following piece code to driver/mmc/mmc.c? And Add a device entry for struct mmc.
"
Thanks,
Peng.
Quoted 3 lines
Regards,
Simon