diff mbox

[U-Boot,3/3] M28: Disable USB power on boot

Message ID 1337729574-30475-3-git-send-email-marex@denx.de
State Changes Requested
Delegated to: Stefano Babic
Headers show

Commit Message

Marek Vasut May 22, 2012, 11:32 p.m. UTC
This is a precaution to prevent some USB flash drives
from misbehaving in early boot stage.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Fabio Estevam <festevam@gmail.com>
CC: Albert Aribaud <albert.u.boot@aribaud.net>
---
 board/denx/m28evk/m28evk.c   |    3 ---
 board/denx/m28evk/spl_boot.c |   11 +++++++++++
 2 files changed, 11 insertions(+), 3 deletions(-)

Comments

Wolfgang Denk May 23, 2012, 11:14 a.m. UTC | #1
Dear Marek Vasut,

In message <1337729574-30475-3-git-send-email-marex@denx.de> you wrote:
> This is a precaution to prevent some USB flash drives
> from misbehaving in early boot stage.

Tested on M28EVK; sorry, but this commit doesn't change behaviour:
the LED on the stick is still blinking after power-on.

Best regards,

Wolfgang Denk
Marek Vasut May 23, 2012, 11:53 a.m. UTC | #2
Dear Wolfgang Denk,

> Dear Marek Vasut,
> 
> In message <1337729574-30475-3-git-send-email-marex@denx.de> you wrote:
> > This is a precaution to prevent some USB flash drives
> > from misbehaving in early boot stage.
> 
> Tested on M28EVK; sorry, but this commit doesn't change behaviour:
> the LED on the stick is still blinking after power-on.

Dang, this must be related to bootrom somehow then. Fabio, can you confirm the 
following:

If you turn off the mx28 board, connect usb flashdisc, turn it on -- do you see 
the flashdisc led blinking? Any idea what might cause it? This patch forced the 
VBUS off, so very early in uboot, the USB flash has no way to blink (unless 
there's some surge).

> 
> Best regards,
> 
> Wolfgang Denk

Best regards,
Marek Vasut
Fabio Estevam May 23, 2012, 12:48 p.m. UTC | #3
On Wed, May 23, 2012 at 8:53 AM, Marek Vasut <marex@denx.de> wrote:

> Dang, this must be related to bootrom somehow then. Fabio, can you confirm the
> following:
>
> If you turn off the mx28 board, connect usb flashdisc, turn it on -- do you see
> the flashdisc led blinking? Any idea what might cause it? This patch forced the
> VBUS off, so very early in uboot, the USB flash has no way to blink (unless
> there's some surge).

I have just tried it on my mx28evk and I don't see the USB thumb LED to turn on.

Only if I do a "usb reset" that it turns on. Doing a "usb stop" turns
it off as expected.

I would suggest you to compare your USB circuitry  against mx28evk schematics.

Regards,

Fabio Estevam
Fabio Estevam May 23, 2012, 1:01 p.m. UTC | #4
On Tue, May 22, 2012 at 8:32 PM, Marek Vasut <marex@denx.de> wrote:

>  void board_init_ll(void)
>  {
> +       /* Powerdown the USB */
> +       mxs_iomux_setup_pad(MX28_PAD_SSP2_SS1__USB1_OVERCURRENT);
> +       mxs_iomux_setup_pad(MX28_PAD_AUART3_TX__GPIO_3_13 |
> +                       MXS_PAD_12MA | MXS_PAD_3V3 | MXS_PAD_PULLUP);
> +       gpio_direction_output(MX28_PAD_AUART3_TX__GPIO_3_13, 1);

I don't have access to the m28evk schematics, but please double check
if you really need to set this pin to '1' to powerdown the USB, or if
this should be a '0' instead.
Marek Vasut May 23, 2012, 1:07 p.m. UTC | #5
Dear Fabio Estevam,

> On Tue, May 22, 2012 at 8:32 PM, Marek Vasut <marex@denx.de> wrote:
> >  void board_init_ll(void)
> >  {
> > +       /* Powerdown the USB */
> > +       mxs_iomux_setup_pad(MX28_PAD_SSP2_SS1__USB1_OVERCURRENT);
> > +       mxs_iomux_setup_pad(MX28_PAD_AUART3_TX__GPIO_3_13 |
> > +                       MXS_PAD_12MA | MXS_PAD_3V3 | MXS_PAD_PULLUP);
> > +       gpio_direction_output(MX28_PAD_AUART3_TX__GPIO_3_13, 1);
> 
> I don't have access to the m28evk schematics, but please double check
> if you really need to set this pin to '1' to powerdown the USB, or if
> this should be a '0' instead.

This is correct, it should be inverted.

Best regards,
Marek Vasut
Marek Vasut May 23, 2012, 1:08 p.m. UTC | #6
Dear Fabio Estevam,

> On Wed, May 23, 2012 at 8:53 AM, Marek Vasut <marex@denx.de> wrote:
> > Dang, this must be related to bootrom somehow then. Fabio, can you
> > confirm the following:
> > 
> > If you turn off the mx28 board, connect usb flashdisc, turn it on -- do
> > you see the flashdisc led blinking? Any idea what might cause it? This
> > patch forced the VBUS off, so very early in uboot, the USB flash has no
> > way to blink (unless there's some surge).
> 
> I have just tried it on my mx28evk and I don't see the USB thumb LED to
> turn on.
> 
> Only if I do a "usb reset" that it turns on. Doing a "usb stop" turns
> it off as expected.
> 
> I would suggest you to compare your USB circuitry  against mx28evk
> schematics.

Well, what can it be caused by? I disabled the VBUS, so how come it can still be 
on. The usb circuitry maybe then?

> Regards,
> 
> Fabio Estevam

Best regards,
Marek Vasut
Fabio Estevam May 23, 2012, 1:10 p.m. UTC | #7
On Wed, May 23, 2012 at 10:08 AM, Marek Vasut <marex@denx.de> wrote:

> Well, what can it be caused by? I disabled the VBUS, so how come it can still be
> on. The usb circuitry maybe then?

I cannot comment on that, as I never looked at the m28evk schematics.

Please use a mx28evk for comparison.
Fabio Estevam May 23, 2012, 1:15 p.m. UTC | #8
On Wed, May 23, 2012 at 10:07 AM, Marek Vasut <marex@denx.de> wrote:

> This is correct, it should be inverted.

So where in your code you powerup the USB?

There should be a:

gpio_direction_output(MX28_PAD_AUART3_TX__GPIO_3_13, 0);

,somewhere in order to power your USB on then.
Marek Vasut May 23, 2012, 1:20 p.m. UTC | #9
Dear Fabio Estevam,

> On Wed, May 23, 2012 at 10:07 AM, Marek Vasut <marex@denx.de> wrote:
> > This is correct, it should be inverted.
> 
> So where in your code you powerup the USB?
> 
> There should be a:
> 
> gpio_direction_output(MX28_PAD_AUART3_TX__GPIO_3_13, 0);
> 
> ,somewhere in order to power your USB on then.

Sure, board/denx/m28evk/m28evk.c, in board_early_init_f() call. Hm, might as 
well move it to board_init_f() too, but that has no relevance.

Best regards,
Marek Vasut
diff mbox

Patch

diff --git a/board/denx/m28evk/m28evk.c b/board/denx/m28evk/m28evk.c
index 3d28ea8..5068071 100644
--- a/board/denx/m28evk/m28evk.c
+++ b/board/denx/m28evk/m28evk.c
@@ -53,9 +53,6 @@  int board_early_init_f(void)
 	mx28_set_sspclk(MXC_SSPCLK2, 96000, 0);
 
 #ifdef	CONFIG_CMD_USB
-	mxs_iomux_setup_pad(MX28_PAD_SSP2_SS1__USB1_OVERCURRENT);
-	mxs_iomux_setup_pad(MX28_PAD_AUART3_TX__GPIO_3_13 |
-			MXS_PAD_12MA | MXS_PAD_3V3 | MXS_PAD_PULLUP);
 	gpio_direction_output(MX28_PAD_AUART3_TX__GPIO_3_13, 0);
 #endif
 
diff --git a/board/denx/m28evk/spl_boot.c b/board/denx/m28evk/spl_boot.c
index 7a12592..6b51332 100644
--- a/board/denx/m28evk/spl_boot.c
+++ b/board/denx/m28evk/spl_boot.c
@@ -214,9 +214,20 @@  const iomux_cfg_t iomux_setup[] = {
 	MX28_PAD_SSP2_MISO__SSP2_D0 | MUX_CONFIG_SSP2,
 	MX28_PAD_SSP2_SS0__SSP2_D3 |
 		(MXS_PAD_3V3 | MXS_PAD_8MA | MXS_PAD_PULLUP),
+
+	/* USB */
+	MX28_PAD_SSP2_SS1__USB1_OVERCURRENT,
+	MX28_PAD_AUART3_TX__GPIO_3_13 |
+			MXS_PAD_12MA | MXS_PAD_3V3 | MXS_PAD_PULLUP,
 };
 
 void board_init_ll(void)
 {
+	/* Powerdown the USB */
+	mxs_iomux_setup_pad(MX28_PAD_SSP2_SS1__USB1_OVERCURRENT);
+	mxs_iomux_setup_pad(MX28_PAD_AUART3_TX__GPIO_3_13 |
+			MXS_PAD_12MA | MXS_PAD_3V3 | MXS_PAD_PULLUP);
+	gpio_direction_output(MX28_PAD_AUART3_TX__GPIO_3_13, 1);
+
 	mx28_common_spl_init(iomux_setup, ARRAY_SIZE(iomux_setup));
 }