diff mbox

[U-Boot,v4,3/3] omap_hsmmc: Board-specific TWL4030 MMC power initializations

Message ID 1415476547-17896-4-git-send-email-contact@paulk.fr
State Accepted
Delegated to: Tom Rini
Headers show

Commit Message

Paul Kocialkowski Nov. 8, 2014, 7:55 p.m. UTC
Boards using the TWL4030 regulator may not all use the LDOs the same way
(e.g. MMC2 power can be controlled by another LDO than VMMC2).
This delegates TWL4030 MMC power initializations to board-specific functions,
that may still call twl4030_power_mmc_init for the default behavior.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
---
 board/comelit/dig297/dig297.c          | 5 +++++
 board/compulab/cm_t35/cm_t35.c         | 7 +++++++
 board/corscience/tricorder/tricorder.c | 7 +++++++
 board/isee/igep00x0/igep00x0.c         | 7 +++++++
 board/logicpd/omap3som/omap3logic.c    | 7 +++++++
 board/logicpd/zoom1/zoom1.c            | 5 +++++
 board/matrix_vision/mvblx/mvblx.c      | 6 ++++++
 board/nokia/rx51/rx51.c                | 6 ++++++
 board/overo/overo.c                    | 7 +++++++
 board/pandora/pandora.c                | 5 +++++
 board/technexion/tao3530/tao3530.c     | 7 +++++++
 board/ti/beagle/beagle.c               | 7 +++++++
 board/ti/evm/evm.c                     | 7 +++++++
 board/ti/sdp3430/sdp.c                 | 5 +++++
 board/timll/devkit8000/devkit8000.c    | 7 +++++++
 drivers/mmc/omap_hsmmc.c               | 7 +------
 16 files changed, 96 insertions(+), 6 deletions(-)

Comments

Paul Kocialkowski Nov. 8, 2014, 9:29 p.m. UTC | #1
Le samedi 08 novembre 2014 à 20:55 +0100, Paul Kocialkowski a écrit :
> Boards using the TWL4030 regulator may not all use the LDOs the same way
> (e.g. MMC2 power can be controlled by another LDO than VMMC2).
> This delegates TWL4030 MMC power initializations to board-specific functions,
> that may still call twl4030_power_mmc_init for the default behavior.
> 
> Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
> ---
>  board/comelit/dig297/dig297.c          | 5 +++++
>  board/compulab/cm_t35/cm_t35.c         | 7 +++++++
>  board/corscience/tricorder/tricorder.c | 7 +++++++
>  board/isee/igep00x0/igep00x0.c         | 7 +++++++
>  board/logicpd/omap3som/omap3logic.c    | 7 +++++++
>  board/logicpd/zoom1/zoom1.c            | 5 +++++
>  board/matrix_vision/mvblx/mvblx.c      | 6 ++++++
>  board/nokia/rx51/rx51.c                | 6 ++++++
>  board/overo/overo.c                    | 7 +++++++
>  board/pandora/pandora.c                | 5 +++++
>  board/technexion/tao3530/tao3530.c     | 7 +++++++
>  board/ti/beagle/beagle.c               | 7 +++++++
>  board/ti/evm/evm.c                     | 7 +++++++
>  board/ti/sdp3430/sdp.c                 | 5 +++++
>  board/timll/devkit8000/devkit8000.c    | 7 +++++++
>  drivers/mmc/omap_hsmmc.c               | 7 +------
>  16 files changed, 96 insertions(+), 6 deletions(-)
> 
> diff --git a/board/comelit/dig297/dig297.c b/board/comelit/dig297/dig297.c
> index 2b826df..9d4c41b 100644
> --- a/board/comelit/dig297/dig297.c
> +++ b/board/comelit/dig297/dig297.c
> @@ -133,6 +133,11 @@ int board_mmc_init(bd_t *bis)
>  {
>  	return omap_mmc_init(0, 0, 0, -1, -1);
>  }
> +
> +void board_mmc_power_init(void)
> +{

I just figured, in the context of the SPL, board_mmc_init will be called
from omap3/board.c instead of the board file, so perhaps it would be
worth adding, in board_mmc_power_init: #ifdef CONFIG_SPL_BUILD and then
checking spl_boot_device to only enable the relevant LDO.

In addition (on v4), board_mmc_init may call omap_mmc_init with a
dev_index that is not used in the board's board_mmc_init, hence not
listed to be enabled on board_mmc_power_init, leaving the MMC device
potentially unpowered in that case. This is why we need to treat SPL
context separately.

This should never actually be a problem as spl_boot_device() will return
what the BootROM booted the SPL from, so it must have already enabled
the relevant LDO. However, I'm using peripheral booting on the Optimus
Black so I hardcode omap3_boot_device to MMC 1/2, so the LDOs are not
enabled at all in my case. And after all, we shouldn't rely on what the
BootROM did or didn't do.

While I'm not suggesting harcoding different behavior should happen on
upstream code, we can imagine that omap3's spl_boot_device could become
more flexible and return something else than what the BootROM booted the
SPL from, hence making that case a valid one.

What do you think?

> +	twl4030_power_mmc_init(0);
> +}
>  #endif
>  
>  #ifdef CONFIG_CMD_NET
> diff --git a/board/compulab/cm_t35/cm_t35.c b/board/compulab/cm_t35/cm_t35.c
> index 886c723..43463d5 100644
> --- a/board/compulab/cm_t35/cm_t35.c
> +++ b/board/compulab/cm_t35/cm_t35.c
> @@ -382,6 +382,13 @@ int board_mmc_init(bd_t *bis)
>  }
>  #endif
>  
> +#if defined(CONFIG_GENERIC_MMC)
> +void board_mmc_power_init(void)
> +{
> +	twl4030_power_mmc_init(0);
> +}
> +#endif
> +
>  #ifdef CONFIG_SYS_I2C_OMAP34XX
>  /*
>   * Routine: reset_net_chip
> diff --git a/board/corscience/tricorder/tricorder.c b/board/corscience/tricorder/tricorder.c
> index 9e81bf3..0fddf45 100644
> --- a/board/corscience/tricorder/tricorder.c
> +++ b/board/corscience/tricorder/tricorder.c
> @@ -147,6 +147,13 @@ int board_mmc_init(bd_t *bis)
>  }
>  #endif
>  
> +#if defined(CONFIG_GENERIC_MMC)
> +void board_mmc_power_init(void)
> +{
> +	twl4030_power_mmc_init(0);
> +}
> +#endif
> +
>  /*
>   * Routine: get_board_mem_timings
>   * Description: If we use SPL then there is no x-loader nor config header
> diff --git a/board/isee/igep00x0/igep00x0.c b/board/isee/igep00x0/igep00x0.c
> index 7b87cc2..47522f8 100644
> --- a/board/isee/igep00x0/igep00x0.c
> +++ b/board/isee/igep00x0/igep00x0.c
> @@ -150,6 +150,13 @@ int board_mmc_init(bd_t *bis)
>  }
>  #endif
>  
> +#if defined(CONFIG_GENERIC_MMC)
> +void board_mmc_power_init(void)
> +{
> +	twl4030_power_mmc_init(0);
> +}
> +#endif
> +
>  void set_fdt(void)
>  {
>  	switch (gd->bd->bi_arch_number) {
> diff --git a/board/logicpd/omap3som/omap3logic.c b/board/logicpd/omap3som/omap3logic.c
> index 1fd9f2c..609edf1 100644
> --- a/board/logicpd/omap3som/omap3logic.c
> +++ b/board/logicpd/omap3som/omap3logic.c
> @@ -128,6 +128,13 @@ int board_mmc_init(bd_t *bis)
>  }
>  #endif
>  
> +#if defined(CONFIG_GENERIC_MMC)
> +void board_mmc_power_init(void)
> +{
> +	twl4030_power_mmc_init(0);
> +}
> +#endif
> +
>  #ifdef CONFIG_SMC911X
>  /* GPMC CS1 settings for Logic SOM LV/Torpedo LAN92xx Ethernet chip */
>  static const u32 gpmc_lan92xx_config[] = {
> diff --git a/board/logicpd/zoom1/zoom1.c b/board/logicpd/zoom1/zoom1.c
> index 9ef0026..d39203a 100644
> --- a/board/logicpd/zoom1/zoom1.c
> +++ b/board/logicpd/zoom1/zoom1.c
> @@ -109,6 +109,11 @@ int board_mmc_init(bd_t *bis)
>  {
>  	return omap_mmc_init(0, 0, 0, -1, -1);
>  }
> +
> +void board_mmc_power_init(void)
> +{
> +	twl4030_power_mmc_init(0);
> +}
>  #endif
>  
>  #ifdef CONFIG_CMD_NET
> diff --git a/board/matrix_vision/mvblx/mvblx.c b/board/matrix_vision/mvblx/mvblx.c
> index a69359f..c9d615b 100644
> --- a/board/matrix_vision/mvblx/mvblx.c
> +++ b/board/matrix_vision/mvblx/mvblx.c
> @@ -94,6 +94,12 @@ int board_mmc_init(bd_t *bis)
>  	omap_mmc_init(1, 0, 0, -1, -1);
>  	return 0;
>  }
> +
> +void board_mmc_power_init(void)
> +{
> +	twl4030_power_mmc_init(0);
> +	twl4030_power_mmc_init(1);
> +}
>  #endif
>  
>  #if defined(CONFIG_CMD_NET)
> diff --git a/board/nokia/rx51/rx51.c b/board/nokia/rx51/rx51.c
> index c2e07db..b6b8ad6 100644
> --- a/board/nokia/rx51/rx51.c
> +++ b/board/nokia/rx51/rx51.c
> @@ -659,3 +659,9 @@ int board_mmc_init(bd_t *bis)
>  	omap_mmc_init(1, 0, 0, -1, -1);
>  	return 0;
>  }
> +
> +void board_mmc_power_init(void)
> +{
> +	twl4030_power_mmc_init(0);
> +	twl4030_power_mmc_init(1);
> +}
> diff --git a/board/overo/overo.c b/board/overo/overo.c
> index dfb8602..b7f85e7 100644
> --- a/board/overo/overo.c
> +++ b/board/overo/overo.c
> @@ -493,6 +493,13 @@ int board_mmc_init(bd_t *bis)
>  }
>  #endif
>  
> +#if defined(CONFIG_GENERIC_MMC)
> +void board_mmc_power_init(void)
> +{
> +	twl4030_power_mmc_init(0);
> +}
> +#endif
> +
>  #if defined(CONFIG_USB_EHCI) &&  !defined(CONFIG_SPL_BUILD)
>  static struct omap_usbhs_board_data usbhs_bdata = {
>  	.port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,
> diff --git a/board/pandora/pandora.c b/board/pandora/pandora.c
> index 146dcea..59b5a7e 100644
> --- a/board/pandora/pandora.c
> +++ b/board/pandora/pandora.c
> @@ -126,4 +126,9 @@ int board_mmc_init(bd_t *bis)
>  {
>  	return omap_mmc_init(0, 0, 0, -1, -1);
>  }
> +
> +void board_mmc_power_init(void)
> +{
> +	twl4030_power_mmc_init(0);
> +}
>  #endif
> diff --git a/board/technexion/tao3530/tao3530.c b/board/technexion/tao3530/tao3530.c
> index 44a8240..744ff44 100644
> --- a/board/technexion/tao3530/tao3530.c
> +++ b/board/technexion/tao3530/tao3530.c
> @@ -188,6 +188,13 @@ int board_mmc_init(bd_t *bis)
>  }
>  #endif
>  
> +#if defined(CONFIG_GENERIC_MMC)
> +void board_mmc_power_init(void)
> +{
> +	twl4030_power_mmc_init(0);
> +}
> +#endif
> +
>  #if defined(CONFIG_USB_EHCI) && !defined(CONFIG_SPL_BUILD)
>  /* Call usb_stop() before starting the kernel */
>  void show_boot_progress(int val)
> diff --git a/board/ti/beagle/beagle.c b/board/ti/beagle/beagle.c
> index 4c5e381..7b37fbe 100644
> --- a/board/ti/beagle/beagle.c
> +++ b/board/ti/beagle/beagle.c
> @@ -534,6 +534,13 @@ int board_mmc_init(bd_t *bis)
>  }
>  #endif
>  
> +#if defined(CONFIG_GENERIC_MMC)
> +void board_mmc_power_init(void)
> +{
> +	twl4030_power_mmc_init(0);
> +}
> +#endif
> +
>  #if defined(CONFIG_USB_EHCI) && !defined(CONFIG_SPL_BUILD)
>  /* Call usb_stop() before starting the kernel */
>  void show_boot_progress(int val)
> diff --git a/board/ti/evm/evm.c b/board/ti/evm/evm.c
> index 81dd081..47c023d 100644
> --- a/board/ti/evm/evm.c
> +++ b/board/ti/evm/evm.c
> @@ -264,3 +264,10 @@ int board_mmc_init(bd_t *bis)
>  	return omap_mmc_init(0, 0, 0, -1, -1);
>  }
>  #endif
> +
> +#if defined(CONFIG_GENERIC_MMC)
> +void board_mmc_power_init(void)
> +{
> +	twl4030_power_mmc_init(0);
> +}
> +#endif
> diff --git a/board/ti/sdp3430/sdp.c b/board/ti/sdp3430/sdp.c
> index 957940d..7171363 100644
> --- a/board/ti/sdp3430/sdp.c
> +++ b/board/ti/sdp3430/sdp.c
> @@ -195,4 +195,9 @@ int board_mmc_init(bd_t *bis)
>  {
>  	return omap_mmc_init(0, 0, 0, -1, -1);
>  }
> +
> +void board_mmc_power_init(void)
> +{
> +	twl4030_power_mmc_init(0);
> +}
>  #endif
> diff --git a/board/timll/devkit8000/devkit8000.c b/board/timll/devkit8000/devkit8000.c
> index bcbee73..b978044 100644
> --- a/board/timll/devkit8000/devkit8000.c
> +++ b/board/timll/devkit8000/devkit8000.c
> @@ -124,6 +124,13 @@ int board_mmc_init(bd_t *bis)
>  }
>  #endif
>  
> +#if defined(CONFIG_GENERIC_MMC)
> +void board_mmc_power_init(void)
> +{
> +	twl4030_power_mmc_init(0);
> +}
> +#endif
> +
>  #if defined(CONFIG_DRIVER_DM9000) & !defined(CONFIG_SPL_BUILD)
>  /*
>   * Routine: board_eth_init
> diff --git a/drivers/mmc/omap_hsmmc.c b/drivers/mmc/omap_hsmmc.c
> index ae04939..3fc4698 100644
> --- a/drivers/mmc/omap_hsmmc.c
> +++ b/drivers/mmc/omap_hsmmc.c
> @@ -135,12 +135,7 @@ static unsigned char mmc_board_init(struct mmc *mmc)
>  	pbias_lite = readl(&t2_base->pbias_lite);
>  	pbias_lite &= ~(PBIASLITEPWRDNZ1 | PBIASLITEPWRDNZ0);
>  	writel(pbias_lite, &t2_base->pbias_lite);
> -#endif
> -#if defined(CONFIG_TWL4030_POWER)
> -	twl4030_power_mmc_init(0);
> -	twl4030_power_mmc_init(1);
> -#endif
> -#if defined(CONFIG_OMAP34XX)
> +
>  	writel(pbias_lite | PBIASLITEPWRDNZ1 |
>  		PBIASSPEEDCTRL0 | PBIASLITEPWRDNZ0,
>  		&t2_base->pbias_lite);
Tom Rini Nov. 10, 2014, 6:46 p.m. UTC | #2
On Sat, Nov 08, 2014 at 10:29:24PM +0100, Paul Kocialkowski wrote:
> Le samedi 08 novembre 2014 à 20:55 +0100, Paul Kocialkowski a écrit :
> > Boards using the TWL4030 regulator may not all use the LDOs the same way
> > (e.g. MMC2 power can be controlled by another LDO than VMMC2).
> > This delegates TWL4030 MMC power initializations to board-specific functions,
> > that may still call twl4030_power_mmc_init for the default behavior.
> > 
> > Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
> > ---
> >  board/comelit/dig297/dig297.c          | 5 +++++
> >  board/compulab/cm_t35/cm_t35.c         | 7 +++++++
> >  board/corscience/tricorder/tricorder.c | 7 +++++++
> >  board/isee/igep00x0/igep00x0.c         | 7 +++++++
> >  board/logicpd/omap3som/omap3logic.c    | 7 +++++++
> >  board/logicpd/zoom1/zoom1.c            | 5 +++++
> >  board/matrix_vision/mvblx/mvblx.c      | 6 ++++++
> >  board/nokia/rx51/rx51.c                | 6 ++++++
> >  board/overo/overo.c                    | 7 +++++++
> >  board/pandora/pandora.c                | 5 +++++
> >  board/technexion/tao3530/tao3530.c     | 7 +++++++
> >  board/ti/beagle/beagle.c               | 7 +++++++
> >  board/ti/evm/evm.c                     | 7 +++++++
> >  board/ti/sdp3430/sdp.c                 | 5 +++++
> >  board/timll/devkit8000/devkit8000.c    | 7 +++++++
> >  drivers/mmc/omap_hsmmc.c               | 7 +------
> >  16 files changed, 96 insertions(+), 6 deletions(-)
> > 
> > diff --git a/board/comelit/dig297/dig297.c b/board/comelit/dig297/dig297.c
> > index 2b826df..9d4c41b 100644
> > --- a/board/comelit/dig297/dig297.c
> > +++ b/board/comelit/dig297/dig297.c
> > @@ -133,6 +133,11 @@ int board_mmc_init(bd_t *bis)
> >  {
> >  	return omap_mmc_init(0, 0, 0, -1, -1);
> >  }
> > +
> > +void board_mmc_power_init(void)
> > +{
> 
> I just figured, in the context of the SPL, board_mmc_init will be called
> from omap3/board.c instead of the board file, so perhaps it would be
> worth adding, in board_mmc_power_init: #ifdef CONFIG_SPL_BUILD and then
> checking spl_boot_device to only enable the relevant LDO.

If we get to this point we can do the same thing we do for
board_mmc_init which is have one in say
arch/arm/cpu/armv7/omap-common/boot-common.c that checks
spl_boot_device()
Tom Rini Nov. 10, 2014, 6:46 p.m. UTC | #3
On Sat, Nov 08, 2014 at 08:55:47PM +0100, Paul Kocialkowski wrote:
> Boards using the TWL4030 regulator may not all use the LDOs the same way
> (e.g. MMC2 power can be controlled by another LDO than VMMC2).
> This delegates TWL4030 MMC power initializations to board-specific functions,
> that may still call twl4030_power_mmc_init for the default behavior.
> 
> Signed-off-by: Paul Kocialkowski <contact@paulk.fr>

Reviewed-by: Tom Rini <trini@ti.com>
Paul Kocialkowski Nov. 11, 2014, 11:57 a.m. UTC | #4
Le lundi 10 novembre 2014 à 13:46 -0500, Tom Rini a écrit :
> On Sat, Nov 08, 2014 at 10:29:24PM +0100, Paul Kocialkowski wrote:
> > Le samedi 08 novembre 2014 à 20:55 +0100, Paul Kocialkowski a écrit :
> > > Boards using the TWL4030 regulator may not all use the LDOs the same way
> > > (e.g. MMC2 power can be controlled by another LDO than VMMC2).
> > > This delegates TWL4030 MMC power initializations to board-specific functions,
> > > that may still call twl4030_power_mmc_init for the default behavior.
> > > 
> > > Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
> > > ---
> > >  board/comelit/dig297/dig297.c          | 5 +++++
> > >  board/compulab/cm_t35/cm_t35.c         | 7 +++++++
> > >  board/corscience/tricorder/tricorder.c | 7 +++++++
> > >  board/isee/igep00x0/igep00x0.c         | 7 +++++++
> > >  board/logicpd/omap3som/omap3logic.c    | 7 +++++++
> > >  board/logicpd/zoom1/zoom1.c            | 5 +++++
> > >  board/matrix_vision/mvblx/mvblx.c      | 6 ++++++
> > >  board/nokia/rx51/rx51.c                | 6 ++++++
> > >  board/overo/overo.c                    | 7 +++++++
> > >  board/pandora/pandora.c                | 5 +++++
> > >  board/technexion/tao3530/tao3530.c     | 7 +++++++
> > >  board/ti/beagle/beagle.c               | 7 +++++++
> > >  board/ti/evm/evm.c                     | 7 +++++++
> > >  board/ti/sdp3430/sdp.c                 | 5 +++++
> > >  board/timll/devkit8000/devkit8000.c    | 7 +++++++
> > >  drivers/mmc/omap_hsmmc.c               | 7 +------
> > >  16 files changed, 96 insertions(+), 6 deletions(-)
> > > 
> > > diff --git a/board/comelit/dig297/dig297.c b/board/comelit/dig297/dig297.c
> > > index 2b826df..9d4c41b 100644
> > > --- a/board/comelit/dig297/dig297.c
> > > +++ b/board/comelit/dig297/dig297.c
> > > @@ -133,6 +133,11 @@ int board_mmc_init(bd_t *bis)
> > >  {
> > >  	return omap_mmc_init(0, 0, 0, -1, -1);
> > >  }
> > > +
> > > +void board_mmc_power_init(void)
> > > +{
> > 
> > I just figured, in the context of the SPL, board_mmc_init will be called
> > from omap3/board.c instead of the board file, so perhaps it would be
> > worth adding, in board_mmc_power_init: #ifdef CONFIG_SPL_BUILD and then
> > checking spl_boot_device to only enable the relevant LDO.
> 
> If we get to this point we can do the same thing we do for
> board_mmc_init which is have one in say
> arch/arm/cpu/armv7/omap-common/boot-common.c that checks
> spl_boot_device() 

That wouldn't work for my use case, on the Optimus Black, where
regulators are used in a non-standard way. The whole point of this to me
is to not have platform-common code to handle MMC regulators, because
the way those are wired to MMC devices is not the same for each
platform, but is instead board-specific.

Is there any objection to making a v5 that takes the SPL context in
account on each of those boards?

Thanks
Tom Rini Nov. 11, 2014, 12:33 p.m. UTC | #5
On Tue, Nov 11, 2014 at 12:57:45PM +0100, Paul Kocialkowski wrote:
> Le lundi 10 novembre 2014 à 13:46 -0500, Tom Rini a écrit :
> > On Sat, Nov 08, 2014 at 10:29:24PM +0100, Paul Kocialkowski wrote:
> > > Le samedi 08 novembre 2014 à 20:55 +0100, Paul Kocialkowski a écrit :
> > > > Boards using the TWL4030 regulator may not all use the LDOs the same way
> > > > (e.g. MMC2 power can be controlled by another LDO than VMMC2).
> > > > This delegates TWL4030 MMC power initializations to board-specific functions,
> > > > that may still call twl4030_power_mmc_init for the default behavior.
> > > > 
> > > > Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
> > > > ---
> > > >  board/comelit/dig297/dig297.c          | 5 +++++
> > > >  board/compulab/cm_t35/cm_t35.c         | 7 +++++++
> > > >  board/corscience/tricorder/tricorder.c | 7 +++++++
> > > >  board/isee/igep00x0/igep00x0.c         | 7 +++++++
> > > >  board/logicpd/omap3som/omap3logic.c    | 7 +++++++
> > > >  board/logicpd/zoom1/zoom1.c            | 5 +++++
> > > >  board/matrix_vision/mvblx/mvblx.c      | 6 ++++++
> > > >  board/nokia/rx51/rx51.c                | 6 ++++++
> > > >  board/overo/overo.c                    | 7 +++++++
> > > >  board/pandora/pandora.c                | 5 +++++
> > > >  board/technexion/tao3530/tao3530.c     | 7 +++++++
> > > >  board/ti/beagle/beagle.c               | 7 +++++++
> > > >  board/ti/evm/evm.c                     | 7 +++++++
> > > >  board/ti/sdp3430/sdp.c                 | 5 +++++
> > > >  board/timll/devkit8000/devkit8000.c    | 7 +++++++
> > > >  drivers/mmc/omap_hsmmc.c               | 7 +------
> > > >  16 files changed, 96 insertions(+), 6 deletions(-)
> > > > 
> > > > diff --git a/board/comelit/dig297/dig297.c b/board/comelit/dig297/dig297.c
> > > > index 2b826df..9d4c41b 100644
> > > > --- a/board/comelit/dig297/dig297.c
> > > > +++ b/board/comelit/dig297/dig297.c
> > > > @@ -133,6 +133,11 @@ int board_mmc_init(bd_t *bis)
> > > >  {
> > > >  	return omap_mmc_init(0, 0, 0, -1, -1);
> > > >  }
> > > > +
> > > > +void board_mmc_power_init(void)
> > > > +{
> > > 
> > > I just figured, in the context of the SPL, board_mmc_init will be called
> > > from omap3/board.c instead of the board file, so perhaps it would be
> > > worth adding, in board_mmc_power_init: #ifdef CONFIG_SPL_BUILD and then
> > > checking spl_boot_device to only enable the relevant LDO.
> > 
> > If we get to this point we can do the same thing we do for
> > board_mmc_init which is have one in say
> > arch/arm/cpu/armv7/omap-common/boot-common.c that checks
> > spl_boot_device() 
> 
> That wouldn't work for my use case, on the Optimus Black, where
> regulators are used in a non-standard way. The whole point of this to me
> is to not have platform-common code to handle MMC regulators, because
> the way those are wired to MMC devices is not the same for each
> platform, but is instead board-specific.
> 
> Is there any objection to making a v5 that takes the SPL context in
> account on each of those boards?

Oh that's right, hmm.  I think the answer is that for the SPL case where
we _need_ to do something different, the board can already provide that
and do it, with v4.  The general case is that ROM will have done what
needs doing for MMCSD load and in your case you can always go and turn
it on in the board code.
Paul Kocialkowski Nov. 11, 2014, 1:13 p.m. UTC | #6
Le mardi 11 novembre 2014 à 07:33 -0500, Tom Rini a écrit :
> On Tue, Nov 11, 2014 at 12:57:45PM +0100, Paul Kocialkowski wrote:
> > Le lundi 10 novembre 2014 à 13:46 -0500, Tom Rini a écrit :
> > > On Sat, Nov 08, 2014 at 10:29:24PM +0100, Paul Kocialkowski wrote:
> > > > Le samedi 08 novembre 2014 à 20:55 +0100, Paul Kocialkowski a écrit :
> > > > > Boards using the TWL4030 regulator may not all use the LDOs the same way
> > > > > (e.g. MMC2 power can be controlled by another LDO than VMMC2).
> > > > > This delegates TWL4030 MMC power initializations to board-specific functions,
> > > > > that may still call twl4030_power_mmc_init for the default behavior.
> > > > > 
> > > > > Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
> > > > > ---
> > > > >  board/comelit/dig297/dig297.c          | 5 +++++
> > > > >  board/compulab/cm_t35/cm_t35.c         | 7 +++++++
> > > > >  board/corscience/tricorder/tricorder.c | 7 +++++++
> > > > >  board/isee/igep00x0/igep00x0.c         | 7 +++++++
> > > > >  board/logicpd/omap3som/omap3logic.c    | 7 +++++++
> > > > >  board/logicpd/zoom1/zoom1.c            | 5 +++++
> > > > >  board/matrix_vision/mvblx/mvblx.c      | 6 ++++++
> > > > >  board/nokia/rx51/rx51.c                | 6 ++++++
> > > > >  board/overo/overo.c                    | 7 +++++++
> > > > >  board/pandora/pandora.c                | 5 +++++
> > > > >  board/technexion/tao3530/tao3530.c     | 7 +++++++
> > > > >  board/ti/beagle/beagle.c               | 7 +++++++
> > > > >  board/ti/evm/evm.c                     | 7 +++++++
> > > > >  board/ti/sdp3430/sdp.c                 | 5 +++++
> > > > >  board/timll/devkit8000/devkit8000.c    | 7 +++++++
> > > > >  drivers/mmc/omap_hsmmc.c               | 7 +------
> > > > >  16 files changed, 96 insertions(+), 6 deletions(-)
> > > > > 
> > > > > diff --git a/board/comelit/dig297/dig297.c b/board/comelit/dig297/dig297.c
> > > > > index 2b826df..9d4c41b 100644
> > > > > --- a/board/comelit/dig297/dig297.c
> > > > > +++ b/board/comelit/dig297/dig297.c
> > > > > @@ -133,6 +133,11 @@ int board_mmc_init(bd_t *bis)
> > > > >  {
> > > > >  	return omap_mmc_init(0, 0, 0, -1, -1);
> > > > >  }
> > > > > +
> > > > > +void board_mmc_power_init(void)
> > > > > +{
> > > > 
> > > > I just figured, in the context of the SPL, board_mmc_init will be called
> > > > from omap3/board.c instead of the board file, so perhaps it would be
> > > > worth adding, in board_mmc_power_init: #ifdef CONFIG_SPL_BUILD and then
> > > > checking spl_boot_device to only enable the relevant LDO.
> > > 
> > > If we get to this point we can do the same thing we do for
> > > board_mmc_init which is have one in say
> > > arch/arm/cpu/armv7/omap-common/boot-common.c that checks
> > > spl_boot_device() 
> > 
> > That wouldn't work for my use case, on the Optimus Black, where
> > regulators are used in a non-standard way. The whole point of this to me
> > is to not have platform-common code to handle MMC regulators, because
> > the way those are wired to MMC devices is not the same for each
> > platform, but is instead board-specific.
> > 
> > Is there any objection to making a v5 that takes the SPL context in
> > account on each of those boards?
> 
> Oh that's right, hmm.  I think the answer is that for the SPL case where
> we _need_ to do something different, the board can already provide that
> and do it, with v4.  The general case is that ROM will have done what
> needs doing for MMCSD load and in your case you can always go and turn
> it on in the board code.

That should indeed cover most use cases. So let's let boards enable all
the regulators they may need for MMC in board_mmc_power_init.

I'm good with v4 then!
Tom Rini Dec. 5, 2014, 2:52 p.m. UTC | #7
On Sat, Nov 08, 2014 at 08:55:47PM +0100, Paul Kocialkowski wrote:

> Boards using the TWL4030 regulator may not all use the LDOs the same way
> (e.g. MMC2 power can be controlled by another LDO than VMMC2).
> This delegates TWL4030 MMC power initializations to board-specific functions,
> that may still call twl4030_power_mmc_init for the default behavior.
> 
> Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
> Reviewed-by: Tom Rini <trini@ti.com>

Applied to u-boot-ti/master, thanks!
diff mbox

Patch

diff --git a/board/comelit/dig297/dig297.c b/board/comelit/dig297/dig297.c
index 2b826df..9d4c41b 100644
--- a/board/comelit/dig297/dig297.c
+++ b/board/comelit/dig297/dig297.c
@@ -133,6 +133,11 @@  int board_mmc_init(bd_t *bis)
 {
 	return omap_mmc_init(0, 0, 0, -1, -1);
 }
+
+void board_mmc_power_init(void)
+{
+	twl4030_power_mmc_init(0);
+}
 #endif
 
 #ifdef CONFIG_CMD_NET
diff --git a/board/compulab/cm_t35/cm_t35.c b/board/compulab/cm_t35/cm_t35.c
index 886c723..43463d5 100644
--- a/board/compulab/cm_t35/cm_t35.c
+++ b/board/compulab/cm_t35/cm_t35.c
@@ -382,6 +382,13 @@  int board_mmc_init(bd_t *bis)
 }
 #endif
 
+#if defined(CONFIG_GENERIC_MMC)
+void board_mmc_power_init(void)
+{
+	twl4030_power_mmc_init(0);
+}
+#endif
+
 #ifdef CONFIG_SYS_I2C_OMAP34XX
 /*
  * Routine: reset_net_chip
diff --git a/board/corscience/tricorder/tricorder.c b/board/corscience/tricorder/tricorder.c
index 9e81bf3..0fddf45 100644
--- a/board/corscience/tricorder/tricorder.c
+++ b/board/corscience/tricorder/tricorder.c
@@ -147,6 +147,13 @@  int board_mmc_init(bd_t *bis)
 }
 #endif
 
+#if defined(CONFIG_GENERIC_MMC)
+void board_mmc_power_init(void)
+{
+	twl4030_power_mmc_init(0);
+}
+#endif
+
 /*
  * Routine: get_board_mem_timings
  * Description: If we use SPL then there is no x-loader nor config header
diff --git a/board/isee/igep00x0/igep00x0.c b/board/isee/igep00x0/igep00x0.c
index 7b87cc2..47522f8 100644
--- a/board/isee/igep00x0/igep00x0.c
+++ b/board/isee/igep00x0/igep00x0.c
@@ -150,6 +150,13 @@  int board_mmc_init(bd_t *bis)
 }
 #endif
 
+#if defined(CONFIG_GENERIC_MMC)
+void board_mmc_power_init(void)
+{
+	twl4030_power_mmc_init(0);
+}
+#endif
+
 void set_fdt(void)
 {
 	switch (gd->bd->bi_arch_number) {
diff --git a/board/logicpd/omap3som/omap3logic.c b/board/logicpd/omap3som/omap3logic.c
index 1fd9f2c..609edf1 100644
--- a/board/logicpd/omap3som/omap3logic.c
+++ b/board/logicpd/omap3som/omap3logic.c
@@ -128,6 +128,13 @@  int board_mmc_init(bd_t *bis)
 }
 #endif
 
+#if defined(CONFIG_GENERIC_MMC)
+void board_mmc_power_init(void)
+{
+	twl4030_power_mmc_init(0);
+}
+#endif
+
 #ifdef CONFIG_SMC911X
 /* GPMC CS1 settings for Logic SOM LV/Torpedo LAN92xx Ethernet chip */
 static const u32 gpmc_lan92xx_config[] = {
diff --git a/board/logicpd/zoom1/zoom1.c b/board/logicpd/zoom1/zoom1.c
index 9ef0026..d39203a 100644
--- a/board/logicpd/zoom1/zoom1.c
+++ b/board/logicpd/zoom1/zoom1.c
@@ -109,6 +109,11 @@  int board_mmc_init(bd_t *bis)
 {
 	return omap_mmc_init(0, 0, 0, -1, -1);
 }
+
+void board_mmc_power_init(void)
+{
+	twl4030_power_mmc_init(0);
+}
 #endif
 
 #ifdef CONFIG_CMD_NET
diff --git a/board/matrix_vision/mvblx/mvblx.c b/board/matrix_vision/mvblx/mvblx.c
index a69359f..c9d615b 100644
--- a/board/matrix_vision/mvblx/mvblx.c
+++ b/board/matrix_vision/mvblx/mvblx.c
@@ -94,6 +94,12 @@  int board_mmc_init(bd_t *bis)
 	omap_mmc_init(1, 0, 0, -1, -1);
 	return 0;
 }
+
+void board_mmc_power_init(void)
+{
+	twl4030_power_mmc_init(0);
+	twl4030_power_mmc_init(1);
+}
 #endif
 
 #if defined(CONFIG_CMD_NET)
diff --git a/board/nokia/rx51/rx51.c b/board/nokia/rx51/rx51.c
index c2e07db..b6b8ad6 100644
--- a/board/nokia/rx51/rx51.c
+++ b/board/nokia/rx51/rx51.c
@@ -659,3 +659,9 @@  int board_mmc_init(bd_t *bis)
 	omap_mmc_init(1, 0, 0, -1, -1);
 	return 0;
 }
+
+void board_mmc_power_init(void)
+{
+	twl4030_power_mmc_init(0);
+	twl4030_power_mmc_init(1);
+}
diff --git a/board/overo/overo.c b/board/overo/overo.c
index dfb8602..b7f85e7 100644
--- a/board/overo/overo.c
+++ b/board/overo/overo.c
@@ -493,6 +493,13 @@  int board_mmc_init(bd_t *bis)
 }
 #endif
 
+#if defined(CONFIG_GENERIC_MMC)
+void board_mmc_power_init(void)
+{
+	twl4030_power_mmc_init(0);
+}
+#endif
+
 #if defined(CONFIG_USB_EHCI) &&  !defined(CONFIG_SPL_BUILD)
 static struct omap_usbhs_board_data usbhs_bdata = {
 	.port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,
diff --git a/board/pandora/pandora.c b/board/pandora/pandora.c
index 146dcea..59b5a7e 100644
--- a/board/pandora/pandora.c
+++ b/board/pandora/pandora.c
@@ -126,4 +126,9 @@  int board_mmc_init(bd_t *bis)
 {
 	return omap_mmc_init(0, 0, 0, -1, -1);
 }
+
+void board_mmc_power_init(void)
+{
+	twl4030_power_mmc_init(0);
+}
 #endif
diff --git a/board/technexion/tao3530/tao3530.c b/board/technexion/tao3530/tao3530.c
index 44a8240..744ff44 100644
--- a/board/technexion/tao3530/tao3530.c
+++ b/board/technexion/tao3530/tao3530.c
@@ -188,6 +188,13 @@  int board_mmc_init(bd_t *bis)
 }
 #endif
 
+#if defined(CONFIG_GENERIC_MMC)
+void board_mmc_power_init(void)
+{
+	twl4030_power_mmc_init(0);
+}
+#endif
+
 #if defined(CONFIG_USB_EHCI) && !defined(CONFIG_SPL_BUILD)
 /* Call usb_stop() before starting the kernel */
 void show_boot_progress(int val)
diff --git a/board/ti/beagle/beagle.c b/board/ti/beagle/beagle.c
index 4c5e381..7b37fbe 100644
--- a/board/ti/beagle/beagle.c
+++ b/board/ti/beagle/beagle.c
@@ -534,6 +534,13 @@  int board_mmc_init(bd_t *bis)
 }
 #endif
 
+#if defined(CONFIG_GENERIC_MMC)
+void board_mmc_power_init(void)
+{
+	twl4030_power_mmc_init(0);
+}
+#endif
+
 #if defined(CONFIG_USB_EHCI) && !defined(CONFIG_SPL_BUILD)
 /* Call usb_stop() before starting the kernel */
 void show_boot_progress(int val)
diff --git a/board/ti/evm/evm.c b/board/ti/evm/evm.c
index 81dd081..47c023d 100644
--- a/board/ti/evm/evm.c
+++ b/board/ti/evm/evm.c
@@ -264,3 +264,10 @@  int board_mmc_init(bd_t *bis)
 	return omap_mmc_init(0, 0, 0, -1, -1);
 }
 #endif
+
+#if defined(CONFIG_GENERIC_MMC)
+void board_mmc_power_init(void)
+{
+	twl4030_power_mmc_init(0);
+}
+#endif
diff --git a/board/ti/sdp3430/sdp.c b/board/ti/sdp3430/sdp.c
index 957940d..7171363 100644
--- a/board/ti/sdp3430/sdp.c
+++ b/board/ti/sdp3430/sdp.c
@@ -195,4 +195,9 @@  int board_mmc_init(bd_t *bis)
 {
 	return omap_mmc_init(0, 0, 0, -1, -1);
 }
+
+void board_mmc_power_init(void)
+{
+	twl4030_power_mmc_init(0);
+}
 #endif
diff --git a/board/timll/devkit8000/devkit8000.c b/board/timll/devkit8000/devkit8000.c
index bcbee73..b978044 100644
--- a/board/timll/devkit8000/devkit8000.c
+++ b/board/timll/devkit8000/devkit8000.c
@@ -124,6 +124,13 @@  int board_mmc_init(bd_t *bis)
 }
 #endif
 
+#if defined(CONFIG_GENERIC_MMC)
+void board_mmc_power_init(void)
+{
+	twl4030_power_mmc_init(0);
+}
+#endif
+
 #if defined(CONFIG_DRIVER_DM9000) & !defined(CONFIG_SPL_BUILD)
 /*
  * Routine: board_eth_init
diff --git a/drivers/mmc/omap_hsmmc.c b/drivers/mmc/omap_hsmmc.c
index ae04939..3fc4698 100644
--- a/drivers/mmc/omap_hsmmc.c
+++ b/drivers/mmc/omap_hsmmc.c
@@ -135,12 +135,7 @@  static unsigned char mmc_board_init(struct mmc *mmc)
 	pbias_lite = readl(&t2_base->pbias_lite);
 	pbias_lite &= ~(PBIASLITEPWRDNZ1 | PBIASLITEPWRDNZ0);
 	writel(pbias_lite, &t2_base->pbias_lite);
-#endif
-#if defined(CONFIG_TWL4030_POWER)
-	twl4030_power_mmc_init(0);
-	twl4030_power_mmc_init(1);
-#endif
-#if defined(CONFIG_OMAP34XX)
+
 	writel(pbias_lite | PBIASLITEPWRDNZ1 |
 		PBIASSPEEDCTRL0 | PBIASLITEPWRDNZ0,
 		&t2_base->pbias_lite);