Message ID | 1458091947-10397-1-git-send-email-van.freenix@gmail.com |
---|---|
State | RFC |
Delegated to: | Pantelis Antoniou |
Headers | show |
Hi Peng, On 15 March 2016 at 19:32, Peng Fan <van.freenix@gmail.com> wrote: > 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. > > Signed-off-by: Peng Fan <van.freenix@gmail.com> > Cc: Pantelis Antoniou <panto@antoniou-consulting.com> > Cc: Andrew Gabbasov <andrew_gabbasov@mentor.com> > Cc: Simon Glass <sjg@chromium.org> > Cc: Stephen Warren <swarren@nvidia.com> > Cc: Clemens Gruber <clemens.gruber@pqgruber.com> > Cc: Eric Nelson <eric@nelint.com> > Cc: Stefano Babic <sbabic@denx.de> > Cc: Fabio Estevam <fabio.estevam@nxp.com> > --- > drivers/mmc/mmc.c | 15 ++++++++++++++- > include/mmc.h | 1 + > 2 files changed, 15 insertions(+), 1 deletion(-) Acked-by: Simon Glass <sjg@chromium.org> I wonder if there is a way to handle this property generically? Regards, Simon
Hi Simon, On Sat, Apr 09, 2016 at 12:34:13PM -0600, Simon Glass wrote: >Hi Peng, > >On 15 March 2016 at 19:32, Peng Fan <van.freenix@gmail.com> wrote: >> 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. >> >> Signed-off-by: Peng Fan <van.freenix@gmail.com> >> Cc: Pantelis Antoniou <panto@antoniou-consulting.com> >> Cc: Andrew Gabbasov <andrew_gabbasov@mentor.com> >> Cc: Simon Glass <sjg@chromium.org> >> Cc: Stephen Warren <swarren@nvidia.com> >> Cc: Clemens Gruber <clemens.gruber@pqgruber.com> >> Cc: Eric Nelson <eric@nelint.com> >> Cc: Stefano Babic <sbabic@denx.de> >> Cc: Fabio Estevam <fabio.estevam@nxp.com> >> --- >> drivers/mmc/mmc.c | 15 ++++++++++++++- >> include/mmc.h | 1 + >> 2 files changed, 15 insertions(+), 1 deletion(-) > >Acked-by: Simon Glass <sjg@chromium.org> > >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. > >Regards, >Simon
Hi Peng, On 10 April 2016 at 23:34, Peng Fan <van.freenix@gmail.com> wrote: > Hi Simon, > > On Sat, Apr 09, 2016 at 12:34:13PM -0600, Simon Glass wrote: >>Hi Peng, >> >>On 15 March 2016 at 19:32, Peng Fan <van.freenix@gmail.com> wrote: >>> 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. >>> >>> Signed-off-by: Peng Fan <van.freenix@gmail.com> >>> Cc: Pantelis Antoniou <panto@antoniou-consulting.com> >>> Cc: Andrew Gabbasov <andrew_gabbasov@mentor.com> >>> Cc: Simon Glass <sjg@chromium.org> >>> Cc: Stephen Warren <swarren@nvidia.com> >>> Cc: Clemens Gruber <clemens.gruber@pqgruber.com> >>> Cc: Eric Nelson <eric@nelint.com> >>> Cc: Stefano Babic <sbabic@denx.de> >>> Cc: Fabio Estevam <fabio.estevam@nxp.com> >>> --- >>> drivers/mmc/mmc.c | 15 ++++++++++++++- >>> include/mmc.h | 1 + >>> 2 files changed, 15 insertions(+), 1 deletion(-) >> >>Acked-by: Simon Glass <sjg@chromium.org> >> >>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; > } > That seems better to me. Regards, Simon
Hi Simon, On Wed, Apr 20, 2016 at 08:40:10AM -0600, Simon Glass wrote: >Hi Peng, > >On 10 April 2016 at 23:34, Peng Fan <van.freenix@gmail.com> wrote: >> Hi Simon, >> >> On Sat, Apr 09, 2016 at 12:34:13PM -0600, Simon Glass wrote: >>>Hi Peng, >>> >>>On 15 March 2016 at 19:32, Peng Fan <van.freenix@gmail.com> wrote: >>>> 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. >>>> >>>> Signed-off-by: Peng Fan <van.freenix@gmail.com> >>>> Cc: Pantelis Antoniou <panto@antoniou-consulting.com> >>>> Cc: Andrew Gabbasov <andrew_gabbasov@mentor.com> >>>> Cc: Simon Glass <sjg@chromium.org> >>>> Cc: Stephen Warren <swarren@nvidia.com> >>>> Cc: Clemens Gruber <clemens.gruber@pqgruber.com> >>>> Cc: Eric Nelson <eric@nelint.com> >>>> Cc: Stefano Babic <sbabic@denx.de> >>>> Cc: Fabio Estevam <fabio.estevam@nxp.com> >>>> --- >>>> drivers/mmc/mmc.c | 15 ++++++++++++++- >>>> include/mmc.h | 1 + >>>> 2 files changed, 15 insertions(+), 1 deletion(-) >>> >>>Acked-by: Simon Glass <sjg@chromium.org> >>> >>>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; >> } >> > >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. > >Regards, >Simon
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index ede5d6e..f6d5c6f 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -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); diff --git a/include/mmc.h b/include/mmc.h index d652c14..111ff75 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -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 {
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. Signed-off-by: Peng Fan <van.freenix@gmail.com> Cc: Pantelis Antoniou <panto@antoniou-consulting.com> Cc: Andrew Gabbasov <andrew_gabbasov@mentor.com> Cc: Simon Glass <sjg@chromium.org> Cc: Stephen Warren <swarren@nvidia.com> Cc: Clemens Gruber <clemens.gruber@pqgruber.com> Cc: Eric Nelson <eric@nelint.com> Cc: Stefano Babic <sbabic@denx.de> Cc: Fabio Estevam <fabio.estevam@nxp.com> --- drivers/mmc/mmc.c | 15 ++++++++++++++- include/mmc.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-)