mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] ARM mxs: Clear USB boot mode during startup
@ 2012-06-29 12:54 Sascha Hauer
  2012-06-29 13:07 ` Juergen Beisert
  2012-07-04  7:15 ` Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Sascha Hauer @ 2012-06-29 12:54 UTC (permalink / raw)
  To: barebox; +Cc: wsa

When the i.MX28 boots from USB, the ROM code sets this bit. When
after a reset the ROM code detects that this bit is set it will
boot from USB again. This means that if we boot once from USB the
chip will continue to boot from USB until the next power cycle.

To prevent this (and boot from the configured bootsource instead)
clear this bit here. This bit is not documented in the datasheets,
it was figured out the hard way. Whether this is the same on i.MX23
is currently not known.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/mach-mxs/imx.c |   26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/arch/arm/mach-mxs/imx.c b/arch/arm/mach-mxs/imx.c
index c64f23c..63b8889 100644
--- a/arch/arm/mach-mxs/imx.c
+++ b/arch/arm/mach-mxs/imx.c
@@ -20,6 +20,32 @@
 #include <common.h>
 #include <command.h>
 #include <complete.h>
+#include <init.h>
+#include <io.h>
+#include <mach/imx-regs.h>
+
+#define HW_RTC_PERSISTENT1     0x070
+
+static int imx_reset_usb_bootstrap(void)
+{
+	/*
+	 * Clear USB boot mode.
+	 *
+	 * When the i.MX28 boots from USB, the ROM code sets this bit. When
+	 * after a reset the ROM code detects that this bit is set it will
+	 * boot from USB again. This means that if we boot once from USB the
+	 * chip will continue to boot from USB until the next power cycle.
+	 *
+	 * To prevent this (and boot from the configured bootsource instead)
+	 * clear this bit here. This bit is not documented in the datasheets,
+	 * it was figured out the hard way. Whether this is the same on i.MX23
+	 * is currently not known.
+	 */
+	writel(0x2, IMX_WDT_BASE + HW_RTC_PERSISTENT1 + BIT_CLR);
+
+	return 0;
+}
+device_initcall(imx_reset_usb_bootstrap);
 
 extern void imx_dump_clocks(void);
 
-- 
1.7.10


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ARM mxs: Clear USB boot mode during startup
  2012-06-29 12:54 [PATCH] ARM mxs: Clear USB boot mode during startup Sascha Hauer
@ 2012-06-29 13:07 ` Juergen Beisert
  2012-07-04  7:15 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Juergen Beisert @ 2012-06-29 13:07 UTC (permalink / raw)
  To: barebox; +Cc: wsa

Sascha Hauer wrote:
> When the i.MX28 boots from USB, the ROM code sets this bit. When
> after a reset the ROM code detects that this bit is set it will
> boot from USB again. This means that if we boot once from USB the
> chip will continue to boot from USB until the next power cycle.

And if the RTC has a battery it will boot from USB forever...

> [...]

jbe

-- 
Pengutronix e.K.                              | Juergen Beisert             |
Linux Solutions for Science and Industry      | http://www.pengutronix.de/  |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ARM mxs: Clear USB boot mode during startup
  2012-06-29 12:54 [PATCH] ARM mxs: Clear USB boot mode during startup Sascha Hauer
  2012-06-29 13:07 ` Juergen Beisert
@ 2012-07-04  7:15 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2012-07-04  7:15 UTC (permalink / raw)
  To: barebox; +Cc: wsa

On Fri, Jun 29, 2012 at 02:54:02PM +0200, Sascha Hauer wrote:
> When the i.MX28 boots from USB, the ROM code sets this bit. When
> after a reset the ROM code detects that this bit is set it will
> boot from USB again. This means that if we boot once from USB the
> chip will continue to boot from USB until the next power cycle.
> 
> To prevent this (and boot from the configured bootsource instead)
> clear this bit here. This bit is not documented in the datasheets,
> it was figured out the hard way. Whether this is the same on i.MX23
> is currently not known.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
>  arch/arm/mach-mxs/imx.c |   26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/arch/arm/mach-mxs/imx.c b/arch/arm/mach-mxs/imx.c
> index c64f23c..63b8889 100644
> --- a/arch/arm/mach-mxs/imx.c
> +++ b/arch/arm/mach-mxs/imx.c
> @@ -20,6 +20,32 @@
>  #include <common.h>
>  #include <command.h>
>  #include <complete.h>
> +#include <init.h>
> +#include <io.h>
> +#include <mach/imx-regs.h>
> +
> +#define HW_RTC_PERSISTENT1     0x070
> +
> +static int imx_reset_usb_bootstrap(void)
> +{
> +	/*
> +	 * Clear USB boot mode.
> +	 *
> +	 * When the i.MX28 boots from USB, the ROM code sets this bit. When
> +	 * after a reset the ROM code detects that this bit is set it will
> +	 * boot from USB again. This means that if we boot once from USB the
> +	 * chip will continue to boot from USB until the next power cycle.
> +	 *
> +	 * To prevent this (and boot from the configured bootsource instead)
> +	 * clear this bit here. This bit is not documented in the datasheets,

It turned out this bit is indeed documented, but in the boot chapter,
not in the rtc chapter.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-07-04  7:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-29 12:54 [PATCH] ARM mxs: Clear USB boot mode during startup Sascha Hauer
2012-06-29 13:07 ` Juergen Beisert
2012-07-04  7:15 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox