mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/3] at91: add boot mode detection support
@ 2013-02-05 17:59 Jean-Christophe PLAGNIOL-VILLARD
  2013-02-05 18:02 ` [PATCH 1/3] " Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 9+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-02-05 17:59 UTC (permalink / raw)
  To: barebox

Hi,

The following changes since commit e43e1498f65fe03cfc6b2744247eeccf27b26876:

  MIPS: pbl: fix none compression support (2013-02-05 09:43:17 +0100)

are available in the git repository at:

  git://git.jcrosoft.org/barebox.git delivery/sama5d3_bootmode

for you to fetch changes up to ce538beef9fabea8c461a206bf0335eb582a9eee:

  sama5d3: detect boot mode (2013-02-05 11:29:18 +0800)

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (3):
      at91: add boot mode detection support
      sama5d3: add boot mode supprot
      sama5d3: detect boot mode

 arch/arm/boards/sama5d3xek/init.c                  |   24 ++++++++++++++++--------
 arch/arm/mach-at91/Kconfig                         |    9 +++++++++
 arch/arm/mach-at91/Makefile                        |    2 ++
 arch/arm/mach-at91/bootmode.c                      |   57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-at91/include/mach/bootmode.h         |   70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-at91/include/mach/sama5d3.h          |    1 +
 arch/arm/mach-at91/include/mach/sama5d3_bootmode.h |   45 +++++++++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-at91/sama5d3.c                       |   81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-at91/setup.c                         |    3 +++
 9 files changed, 284 insertions(+), 8 deletions(-)
 create mode 100644 arch/arm/mach-at91/bootmode.c
 create mode 100644 arch/arm/mach-at91/include/mach/bootmode.h
 create mode 100644 arch/arm/mach-at91/include/mach/sama5d3_bootmode.h

Best Regards,
J.

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

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

* [PATCH 1/3] at91: add boot mode detection support
  2013-02-05 17:59 [PATCH 0/3] at91: add boot mode detection support Jean-Christophe PLAGNIOL-VILLARD
@ 2013-02-05 18:02 ` Jean-Christophe PLAGNIOL-VILLARD
  2013-02-05 18:02   ` [PATCH 2/3] sama5d3: add boot mode supprot Jean-Christophe PLAGNIOL-VILLARD
                     ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-02-05 18:02 UTC (permalink / raw)
  To: barebox

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 arch/arm/mach-at91/Kconfig                 |    8 ++++
 arch/arm/mach-at91/Makefile                |    2 +
 arch/arm/mach-at91/bootmode.c              |   57 ++++++++++++++++++++++
 arch/arm/mach-at91/include/mach/bootmode.h |   70 ++++++++++++++++++++++++++++
 arch/arm/mach-at91/setup.c                 |    3 ++
 5 files changed, 140 insertions(+)
 create mode 100644 arch/arm/mach-at91/bootmode.c
 create mode 100644 arch/arm/mach-at91/include/mach/bootmode.h

diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index b8528d0..f5c995d 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -9,6 +9,9 @@ config HAVE_AT91_DBGU1
 config HAVE_AT91_LOWLEVEL_INIT
 	bool
 
+config HAVE_AT91_BOOTMODE
+	bool
+
 config AT91SAM9_SMC
 	bool
 
@@ -573,4 +576,9 @@ config AT91_LOAD_BAREBOX_SRAM
 	depends on SHELL_NONE || HAVE_AT91_LOAD_BAREBOX_SRAM
 	default y if SHELL_NONE
 
+config AT91_BOOTMODE
+	bool "at91 bootmode detect and export"
+	depends on HAVE_AT91_BOOTMODE
+	default y
+
 endif
diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
index 53ca570..82b4e86 100644
--- a/arch/arm/mach-at91/Makefile
+++ b/arch/arm/mach-at91/Makefile
@@ -22,6 +22,8 @@ obj-$(CONFIG_AT91SAM9G45_RESET) += at91sam9g45_reset.o
 obj-$(CONFIG_AT91SAM9_SMC) += sam9_smc.o
 obj-$(CONFIG_AT91SAM9_TIMER) += at91sam926x_time.o
 
+obj-$(CONFIG_AT91_BOOTMODE) += bootmode.o
+
 # CPU-specific support
 obj-$(CONFIG_ARCH_AT91RM9200)	+= at91rm9200.o at91rm9200_time.o at91rm9200_devices.o
 obj-$(CONFIG_ARCH_AT91SAM9260) += at91sam9260.o at91sam9260_devices.o
diff --git a/arch/arm/mach-at91/bootmode.c b/arch/arm/mach-at91/bootmode.c
new file mode 100644
index 0000000..c731da9
--- /dev/null
+++ b/arch/arm/mach-at91/bootmode.c
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2013 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
+ *
+ * GPLv2 only
+ */
+
+#include <common.h>
+#include <mach/bootmode.h>
+
+struct at91_boot_mode at91_soc_boot_mode;
+
+static const char *soc_boot_from[] = {
+	[AT91_BOOT_FROM_SPI]		= "spi",
+	[AT91_BOOT_FROM_MCI]		= "mci",
+	[AT91_BOOT_FROM_SMC]		= "smc",
+	[AT91_BOOT_FROM_TWD]		= "twd",
+	[AT91_BOOT_FROM_UNKNOWN]	= "Unknown"
+};
+
+static const char *soc_boot_media[] = {
+	[AT91_BOOT_MEDIA_SD]		= "SD",
+	[AT91_BOOT_MEDIA_MMC]		= "MMC",
+	[AT91_BOOT_MEDIA_EMMC]		= "eMMC",
+	[AT91_BOOT_MEDIA_AT45]		= "at45",
+	[AT91_BOOT_MEDIA_AT25]		= "at25",
+	[AT91_BOOT_MEDIA_NAND]		= "NAND",
+	[AT91_BOOT_MEDIA_NOR]		= "NOR",
+	[AT91_BOOT_MEDIA_UNKNOWN]	= "Unknown"
+};
+
+void at91_bootmode_device_register(void)
+{
+	struct device_d *dev;
+	const char *name;
+	char str[16];
+
+	dev = add_generic_device_res("bootloc", DEVICE_ID_SINGLE, NULL, 0, NULL);
+
+	if (at91_soc_boot_mode.from > ARRAY_SIZE(soc_boot_from))
+		name = soc_boot_from[AT91_BOOT_FROM_UNKNOWN];
+	else
+		name = soc_boot_from[at91_soc_boot_mode.from];
+
+	dev_add_param_fixed(dev, "from", (char*)name);
+
+	if (at91_soc_boot_mode.media > ARRAY_SIZE(soc_boot_media))
+		name = soc_boot_media[AT91_BOOT_MEDIA_UNKNOWN];
+	else
+		name = soc_boot_media[at91_soc_boot_mode.media];
+
+	dev_add_param_fixed(dev, "media", (char*)name);
+	sprintf(str, "%d", at91_soc_boot_mode.interface);
+	dev_add_param_fixed(dev, "interface", str);
+	sprintf(str, "%d", at91_soc_boot_mode.cs);
+	dev_add_param_fixed(dev, "cs", str);
+
+}
diff --git a/arch/arm/mach-at91/include/mach/bootmode.h b/arch/arm/mach-at91/include/mach/bootmode.h
new file mode 100644
index 0000000..eb2f948
--- /dev/null
+++ b/arch/arm/mach-at91/include/mach/bootmode.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2013 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
+ *
+ * GPLv2 only
+ */
+
+#ifndef __BOOTMODE_H__
+#define __BOOTMODE_H__
+
+extern struct at91_boot_mode at91_soc_boot_mode;
+
+struct at91_boot_mode {
+	u16 from;
+	u16 interface;
+	u16 media;
+	u16 cs;
+};
+
+enum at91_soc_boot_from {
+	AT91_BOOT_FROM_UNKNOWN,
+	AT91_BOOT_FROM_SPI,
+	AT91_BOOT_FROM_MCI,
+	AT91_BOOT_FROM_SMC,
+	AT91_BOOT_FROM_TWD,
+};
+
+enum at91_soc_boot_media {
+	AT91_BOOT_MEDIA_UNKNOWN,
+	AT91_BOOT_MEDIA_SD,
+	AT91_BOOT_MEDIA_MMC,
+	AT91_BOOT_MEDIA_EMMC,
+	AT91_BOOT_MEDIA_AT45,
+	AT91_BOOT_MEDIA_AT25,
+	AT91_BOOT_MEDIA_NAND,
+	AT91_BOOT_MEDIA_NOR,
+};
+
+#ifdef CONFIG_AT91_BOOTMODE
+void at91_bootmode_device_register(void);
+
+#define at91_boot_from_spi()	(at91_soc_boot_mode.from == AT91_BOOT_FROM_SPI)
+#define at91_boot_from_mci()	(at91_soc_boot_mode.from == AT91_BOOT_FROM_MCI)
+#define at91_boot_from_smc()	(at91_soc_boot_mode.from == AT91_BOOT_FROM_SMC)
+#define at91_boot_from_twd()	(at91_soc_boot_mode.from == AT91_BOOT_FROM_TWD)
+
+#define at91_boot_media_sd()	(at91_soc_boot_mode.media == AT91_BOOT_MEDIA_SD)
+#define at91_boot_media_mmc()	(at91_soc_boot_mode.media == AT91_BOOT_MEDIA_MMC)
+#define at91_boot_media_emmc()	(at91_soc_boot_mode.media == AT91_BOOT_MEDIA_EMMC)
+#define at91_boot_media_at45()	(at91_soc_boot_mode.media == AT91_BOOT_MEDIA_AT45)
+#define at91_boot_media_at25()	(at91_soc_boot_mode.media == AT91_BOOT_MEDIA_AT25)
+#define at91_boot_media_nand()	(at91_soc_boot_mode.media == AT91_BOOT_MEDIA_NAND)
+#define at91_boot_media_nor()	(at91_soc_boot_mode.media == AT91_BOOT_MEDIA_NOR)
+#else
+static void inline void at91_bootmode_device_register(void) {}
+
+#define at91_boot_from_spi()	(0)
+#define at91_boot_from_mci()	(0)
+#define at91_boot_from_smc()	(0)
+#define at91_boot_from_twd()	(0)
+
+#define at91_boot_media_sd()	(0)
+#define at91_boot_media_mmc()	(0)
+#define at91_boot_media_emmc()	(0)
+#define at91_boot_media_at45()	(0)
+#define at91_boot_media_at25()	(0)
+#define at91_boot_media_nand()	(0)
+#define at91_boot_media_nor()	(0)
+#endif
+
+#endif /* __BOOTMODE_H__ */
diff --git a/arch/arm/mach-at91/setup.c b/arch/arm/mach-at91/setup.c
index 0444a5f..d5dc943 100644
--- a/arch/arm/mach-at91/setup.c
+++ b/arch/arm/mach-at91/setup.c
@@ -12,6 +12,7 @@
 #include <mach/hardware.h>
 #include <mach/cpu.h>
 #include <mach/at91_dbgu.h>
+#include <mach/bootmode.h>
 
 #include "soc.h"
 
@@ -248,6 +249,8 @@ static int at91_soc_device(void)
 	dev_add_param_fixed(dev, "name", (char*)at91_get_soc_type(&at91_soc_initdata));
 	dev_add_param_fixed(dev, "subname", (char*)at91_get_soc_subtype(&at91_soc_initdata));
 
+	at91_bootmode_device_register();
+
 	return 0;
 }
 coredevice_initcall(at91_soc_device);
-- 
1.7.10.4


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

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

* [PATCH 2/3] sama5d3: add boot mode supprot
  2013-02-05 18:02 ` [PATCH 1/3] " Jean-Christophe PLAGNIOL-VILLARD
@ 2013-02-05 18:02   ` Jean-Christophe PLAGNIOL-VILLARD
  2013-02-05 18:03   ` [PATCH 3/3] sama5d3: detect boot mode Jean-Christophe PLAGNIOL-VILLARD
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-02-05 18:02 UTC (permalink / raw)
  To: barebox

on sama5d3 the bootmode is pass by the rom code via the register r4
so in the at91bootstrap we save the content of r4 in the 2nd gpbr and repass it
via r4 to barebox

you need to last at91bootstrap

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 arch/arm/mach-at91/Kconfig                         |    1 +
 arch/arm/mach-at91/include/mach/sama5d3.h          |    1 +
 arch/arm/mach-at91/include/mach/sama5d3_bootmode.h |   45 +++++++++++
 arch/arm/mach-at91/sama5d3.c                       |   81 ++++++++++++++++++++
 4 files changed, 128 insertions(+)
 create mode 100644 arch/arm/mach-at91/include/mach/sama5d3_bootmode.h

diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index f5c995d..f6ac9cd 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -197,6 +197,7 @@ config ARCH_SAMA5D3
 	select HAVE_AT91_DBGU1
 	select HAS_MACB
 	select AT91SAM9G45_RESET
+	select HAVE_AT91_BOOTMODE
 
 endchoice
 
diff --git a/arch/arm/mach-at91/include/mach/sama5d3.h b/arch/arm/mach-at91/include/mach/sama5d3.h
index 6884ff6..4d1868e 100644
--- a/arch/arm/mach-at91/include/mach/sama5d3.h
+++ b/arch/arm/mach-at91/include/mach/sama5d3.h
@@ -102,6 +102,7 @@
 #define	SAMA5D3_BASE_HSMC	0xffffc000
 #define SAMA5D3_BASE_PIT	0xfffffe30
 #define SAMA5D3_BASE_WDT	0xfffffe40
+#define SAMA5D3_BASE_GPBR	0xfffffe60
 
 #define SAMA5D3_BASE_PMECC	0xffffc070
 #define SAMA5D3_BASE_PMERRLOC	0xffffc500
diff --git a/arch/arm/mach-at91/include/mach/sama5d3_bootmode.h b/arch/arm/mach-at91/include/mach/sama5d3_bootmode.h
new file mode 100644
index 0000000..5ab2895
--- /dev/null
+++ b/arch/arm/mach-at91/include/mach/sama5d3_bootmode.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2013 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
+ *
+ * GPLv2 only
+ */
+
+#ifndef __SAMA5D3_BOOTMODE_H__
+#define __SAMA5D3_BOOTMODE_H__
+
+#include <mach/sama5d3.h>
+
+#define SAMA5D3_BOOT_FROM_GPBR		(SAMA5D3_BASE_GPBR + 4)
+
+#define SAMA5D3_BOOT_FROM_KEY		(0xba << 24)
+
+#define SAMA5D3_BOOT_FROM		(0xf << 0)
+#define		SAMA5D3_BOOT_FROM_SPI		(0 << 0)
+#define		SAMA5D3_BOOT_FROM_MCI		(1 << 0)
+#define		SAMA5D3_BOOT_FROM_SMC		(2 << 0)
+#define		SAMA5D3_BOOT_FROM_TWD		(3 << 0)
+
+#define SAMA5D3_BOOT_FROM_INTERFACE	(0xf << 4)
+#define 	SAMA5D3_BOOT_FROM_INTERFACE_SHIFT	4
+#define		SAMA5D3_BOOT_FROM_INTERFACE_0	(0 << 4)
+#define		SAMA5D3_BOOT_FROM_INTERFACE_1	(1 << 4)
+#define		SAMA5D3_BOOT_FROM_INTERFACE_2	(2 << 4)
+#define		SAMA5D3_BOOT_FROM_INTERFACE_3	(3 << 4)
+#define		SAMA5D3_BOOT_FROM_INTERFACE_4	(4 << 4)
+
+#define SAMA5D3_BOOT_FROM_MEDIA_TYPE	(0xf << 8)
+#define		SAMA5D3_BOOT_FROM_MEDIA_SD	(0 << 8)
+#define		SAMA5D3_BOOT_FROM_MEDIA_MMC	(1 << 8)
+#define		SAMA5D3_BOOT_FROM_MEDIA_EMMC	(2 << 8)
+#define		SAMA5D3_BOOT_FROM_MEDIA_AT25	(0 << 8)
+#define		SAMA5D3_BOOT_FROM_MEDIA_AT45	(1 << 8)
+
+#define SAMA5D3_BOOT_FROM_CS		(0xf << 12)
+#define 	SAMA5D3_BOOT_FROM_CS_SHIFT	12
+#define		SAMA5D3_BOOT_FROM_CS_0		(0 << 12)
+#define		SAMA5D3_BOOT_FROM_CS_1		(1 << 12)
+#define		SAMA5D3_BOOT_FROM_CS_2		(2 << 12)
+#define		SAMA5D3_BOOT_FROM_CS_3		(3 << 12)
+#define		SAMA5D3_BOOT_FROM_CS_4		(4 << 12)
+
+#endif /* __SAMA5D3_BOOTMODE_H__ */
diff --git a/arch/arm/mach-at91/sama5d3.c b/arch/arm/mach-at91/sama5d3.c
index 0eec696..054683b 100644
--- a/arch/arm/mach-at91/sama5d3.c
+++ b/arch/arm/mach-at91/sama5d3.c
@@ -5,6 +5,8 @@
 #include <mach/at91_pmc.h>
 #include <mach/io.h>
 #include <mach/cpu.h>
+#include <mach/bootmode.h>
+#include <mach/sama5d3_bootmode.h>
 #include <linux/clk.h>
 
 #include "soc.h"
@@ -369,6 +371,82 @@ static void __init sama5d3_register_clocks(void)
 	//clk_enable(&dma1_clk);
 }
 
+static void sama5_boot_form_mci(uint32_t gpbr)
+{
+	switch (gpbr & SAMA5D3_BOOT_FROM_MEDIA_TYPE) {
+	case SAMA5D3_BOOT_FROM_MEDIA_SD:
+		at91_soc_boot_mode.media = AT91_BOOT_MEDIA_SD;
+		break;
+	case SAMA5D3_BOOT_FROM_MEDIA_MMC:
+		at91_soc_boot_mode.media = AT91_BOOT_MEDIA_MMC;
+		break;
+	case SAMA5D3_BOOT_FROM_MEDIA_EMMC:
+		at91_soc_boot_mode.media = AT91_BOOT_MEDIA_EMMC;
+		break;
+	}
+}
+
+static void sama5_boot_form_smc(void)
+{
+	switch (at91_soc_boot_mode.cs) {
+	case 0:
+		at91_soc_boot_mode.media = AT91_BOOT_MEDIA_NOR;
+		break;
+	case 3:
+		at91_soc_boot_mode.media = AT91_BOOT_MEDIA_NAND;
+		break;
+	}
+}
+
+static void sama5_boot_form_spi(uint32_t gpbr)
+{
+	switch (gpbr & SAMA5D3_BOOT_FROM_MEDIA_TYPE) {
+	case SAMA5D3_BOOT_FROM_MEDIA_SD:
+		at91_soc_boot_mode.media = AT91_BOOT_MEDIA_SD;
+		break;
+	case SAMA5D3_BOOT_FROM_MEDIA_MMC:
+		at91_soc_boot_mode.media = AT91_BOOT_MEDIA_MMC;
+		break;
+	case SAMA5D3_BOOT_FROM_MEDIA_EMMC:
+		at91_soc_boot_mode.media = AT91_BOOT_MEDIA_EMMC;
+		break;
+	}
+}
+
+static void sama5d3_boot_from(void)
+{
+	uint32_t gpbr = __raw_readl(SAMA5D3_BOOT_FROM_GPBR);
+
+	at91_soc_boot_mode.cs = 0;
+	at91_soc_boot_mode.media = AT91_BOOT_MEDIA_UNKNOWN;
+
+	if ((gpbr & SAMA5D3_BOOT_FROM_KEY) != SAMA5D3_BOOT_FROM_KEY) {
+		pr_warn("gpbr: boot from invalid\n");
+		return;
+	}
+
+	at91_soc_boot_mode.interface = (gpbr & SAMA5D3_BOOT_FROM_INTERFACE) >> SAMA5D3_BOOT_FROM_INTERFACE_SHIFT;
+	at91_soc_boot_mode.cs = (gpbr & SAMA5D3_BOOT_FROM_CS) >> SAMA5D3_BOOT_FROM_CS_SHIFT;
+
+	switch (gpbr & SAMA5D3_BOOT_FROM) {
+	case SAMA5D3_BOOT_FROM_SPI:
+		at91_soc_boot_mode.from = AT91_BOOT_FROM_SPI;
+		sama5_boot_form_spi(gpbr);
+		break;
+	case SAMA5D3_BOOT_FROM_MCI:
+		at91_soc_boot_mode.from = AT91_BOOT_FROM_MCI;
+		sama5_boot_form_mci(gpbr);
+		break;
+	case SAMA5D3_BOOT_FROM_SMC:
+		at91_soc_boot_mode.from = AT91_BOOT_FROM_SMC;
+		sama5_boot_form_smc();
+		break;
+	case SAMA5D3_BOOT_FROM_TWD:
+		at91_soc_boot_mode.from = AT91_BOOT_FROM_TWD;
+		break;
+	}
+}
+
 /* --------------------------------------------------------------------
  *  AT91SAM9x5 processor initialization
  * -------------------------------------------------------------------- */
@@ -381,6 +459,9 @@ static void sama5d3_initialize(void)
 	/* Register the processor-specific clocks */
 	sama5d3_register_clocks();
 
+	if (IS_ENABLED(CONFIG_AT91_BOOTMODE))
+		sama5d3_boot_from();
+
 	/* Register GPIO subsystem */
 	at91_add_sam9x5_gpio(0, SAMA5D3_BASE_PIOA);
 	at91_add_sam9x5_gpio(1, SAMA5D3_BASE_PIOB);
-- 
1.7.10.4


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

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

* [PATCH 3/3] sama5d3: detect boot mode
  2013-02-05 18:02 ` [PATCH 1/3] " Jean-Christophe PLAGNIOL-VILLARD
  2013-02-05 18:02   ` [PATCH 2/3] sama5d3: add boot mode supprot Jean-Christophe PLAGNIOL-VILLARD
@ 2013-02-05 18:03   ` Jean-Christophe PLAGNIOL-VILLARD
  2013-02-06 10:05     ` Alexander Aring
  2013-02-05 18:08   ` [PATCH 1/3] at91: add boot mode detection support Marc Kleine-Budde
  2013-02-06 18:27   ` Sascha Hauer
  3 siblings, 1 reply; 9+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-02-05 18:03 UTC (permalink / raw)
  To: barebox

and dynamised where we are stored

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 arch/arm/boards/sama5d3xek/init.c |   24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/arch/arm/boards/sama5d3xek/init.c b/arch/arm/boards/sama5d3xek/init.c
index 110a83f..165aaac 100644
--- a/arch/arm/boards/sama5d3xek/init.c
+++ b/arch/arm/boards/sama5d3xek/init.c
@@ -36,6 +36,7 @@
 #include <mach/at91_pmc.h>
 #include <mach/at91_rstc.h>
 #include <mach/at91sam9x5_matrix.h>
+#include <mach/bootmode.h>
 #include <input/qt1070.h>
 #include <readkey.h>
 #include <poller.h>
@@ -381,14 +382,21 @@ static int at91sama5d3xek_devices_init(void)
 
 	armlinux_set_bootparams((void *)(SAMA5_DDRCS + 0x100));
 
-	devfs_add_partition("nand0", 0x00000, SZ_256K, DEVFS_PARTITION_FIXED, "at91bootstrap_raw");
-	dev_add_bb_dev("at91bootstrap_raw", "at91bootstrap");
-	devfs_add_partition("nand0", SZ_256K, SZ_256K + SZ_128K, DEVFS_PARTITION_FIXED, "self_raw");
-	dev_add_bb_dev("self_raw", "self0");
-	devfs_add_partition("nand0", SZ_512K + SZ_256K, SZ_256K, DEVFS_PARTITION_FIXED, "env_raw");
-	dev_add_bb_dev("env_raw", "env0");
-	devfs_add_partition("nand0", SZ_1M, SZ_256K, DEVFS_PARTITION_FIXED, "env_raw1");
-	dev_add_bb_dev("env_raw1", "env1");
+	if (at91_boot_media_at25() && IS_ENABLED(CONFIG_DRIVER_SPI_ATMEL)) {
+		devfs_add_partition("m25p0", 0x00000, SZ_64K, DEVFS_PARTITION_FIXED, "at91bootstrap_raw");
+		devfs_add_partition("m25p0", SZ_64K, SZ_256K + SZ_128K, DEVFS_PARTITION_FIXED, "self_raw");
+		devfs_add_partition("m25p0", SZ_64K + SZ_256K + SZ_128K, SZ_256K, DEVFS_PARTITION_FIXED, "env_raw");
+		devfs_add_partition("m25p0", SZ_64K + SZ_512K + SZ_128K, SZ_256K, DEVFS_PARTITION_FIXED, "env_raw1");
+	} else {
+		devfs_add_partition("nand0", 0x00000, SZ_256K, DEVFS_PARTITION_FIXED, "at91bootstrap_raw");
+		dev_add_bb_dev("at91bootstrap_raw", "at91bootstrap");
+		devfs_add_partition("nand0", SZ_256K, SZ_256K + SZ_128K, DEVFS_PARTITION_FIXED, "self_raw");
+		dev_add_bb_dev("self_raw", "self0");
+		devfs_add_partition("nand0", SZ_512K + SZ_256K, SZ_256K, DEVFS_PARTITION_FIXED, "env_raw");
+		dev_add_bb_dev("env_raw", "env0");
+		devfs_add_partition("nand0", SZ_1M, SZ_256K, DEVFS_PARTITION_FIXED, "env_raw1");
+		dev_add_bb_dev("env_raw1", "env1");
+	}
 
 	return 0;
 }
-- 
1.7.10.4


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

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

* Re: [PATCH 1/3] at91: add boot mode detection support
  2013-02-05 18:02 ` [PATCH 1/3] " Jean-Christophe PLAGNIOL-VILLARD
  2013-02-05 18:02   ` [PATCH 2/3] sama5d3: add boot mode supprot Jean-Christophe PLAGNIOL-VILLARD
  2013-02-05 18:03   ` [PATCH 3/3] sama5d3: detect boot mode Jean-Christophe PLAGNIOL-VILLARD
@ 2013-02-05 18:08   ` Marc Kleine-Budde
  2013-02-06 18:27   ` Sascha Hauer
  3 siblings, 0 replies; 9+ messages in thread
From: Marc Kleine-Budde @ 2013-02-05 18:08 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox


[-- Attachment #1.1: Type: text/plain, Size: 719 bytes --]

On 02/05/2013 07:02 PM, Jean-Christophe PLAGNIOL-VILLARD wrote:
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
>  arch/arm/mach-at91/Kconfig                 |    8 ++++
>  arch/arm/mach-at91/Makefile                |    2 +
>  arch/arm/mach-at91/bootmode.c              |   57 ++++++++++++++++++++++

what about making this a common bootmode helper, which can be used on
other platforms too?

Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 263 bytes --]

[-- Attachment #2: Type: text/plain, Size: 149 bytes --]

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

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

* Re: [PATCH 3/3] sama5d3: detect boot mode
  2013-02-05 18:03   ` [PATCH 3/3] sama5d3: detect boot mode Jean-Christophe PLAGNIOL-VILLARD
@ 2013-02-06 10:05     ` Alexander Aring
  2013-02-06 13:14       ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 9+ messages in thread
From: Alexander Aring @ 2013-02-06 10:05 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

Hi,

On Tue, Feb 05, 2013 at 07:03:00PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> and dynamised where we are stored
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
>  arch/arm/boards/sama5d3xek/init.c |   24 ++++++++++++++++--------
>  1 file changed, 16 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/arm/boards/sama5d3xek/init.c b/arch/arm/boards/sama5d3xek/init.c
> index 110a83f..165aaac 100644
> --- a/arch/arm/boards/sama5d3xek/init.c
> +++ b/arch/arm/boards/sama5d3xek/init.c
> @@ -36,6 +36,7 @@
>  #include <mach/at91_pmc.h>
>  #include <mach/at91_rstc.h>
>  #include <mach/at91sam9x5_matrix.h>
> +#include <mach/bootmode.h>
>  #include <input/qt1070.h>
>  #include <readkey.h>
>  #include <poller.h>
> @@ -381,14 +382,21 @@ static int at91sama5d3xek_devices_init(void)
>  
>  	armlinux_set_bootparams((void *)(SAMA5_DDRCS + 0x100));
>  
> -	devfs_add_partition("nand0", 0x00000, SZ_256K, DEVFS_PARTITION_FIXED, "at91bootstrap_raw");
> -	dev_add_bb_dev("at91bootstrap_raw", "at91bootstrap");
> -	devfs_add_partition("nand0", SZ_256K, SZ_256K + SZ_128K, DEVFS_PARTITION_FIXED, "self_raw");
> -	dev_add_bb_dev("self_raw", "self0");
> -	devfs_add_partition("nand0", SZ_512K + SZ_256K, SZ_256K, DEVFS_PARTITION_FIXED, "env_raw");
> -	dev_add_bb_dev("env_raw", "env0");
> -	devfs_add_partition("nand0", SZ_1M, SZ_256K, DEVFS_PARTITION_FIXED, "env_raw1");
> -	dev_add_bb_dev("env_raw1", "env1");
> +	if (at91_boot_media_at25() && IS_ENABLED(CONFIG_DRIVER_SPI_ATMEL)) {

I don't know, but is it better to use (at91_boot_media_at25() && at91_boot_from_spi())
instead of checking if SPI driver is enabled at compile time?

Regards
Alex

> +		devfs_add_partition("m25p0", 0x00000, SZ_64K, DEVFS_PARTITION_FIXED, "at91bootstrap_raw");
> +		devfs_add_partition("m25p0", SZ_64K, SZ_256K + SZ_128K, DEVFS_PARTITION_FIXED, "self_raw");
> +		devfs_add_partition("m25p0", SZ_64K + SZ_256K + SZ_128K, SZ_256K, DEVFS_PARTITION_FIXED, "env_raw");
> +		devfs_add_partition("m25p0", SZ_64K + SZ_512K + SZ_128K, SZ_256K, DEVFS_PARTITION_FIXED, "env_raw1");
> +	} else {
> +		devfs_add_partition("nand0", 0x00000, SZ_256K, DEVFS_PARTITION_FIXED, "at91bootstrap_raw");
> +		dev_add_bb_dev("at91bootstrap_raw", "at91bootstrap");
> +		devfs_add_partition("nand0", SZ_256K, SZ_256K + SZ_128K, DEVFS_PARTITION_FIXED, "self_raw");
> +		dev_add_bb_dev("self_raw", "self0");
> +		devfs_add_partition("nand0", SZ_512K + SZ_256K, SZ_256K, DEVFS_PARTITION_FIXED, "env_raw");
> +		dev_add_bb_dev("env_raw", "env0");
> +		devfs_add_partition("nand0", SZ_1M, SZ_256K, DEVFS_PARTITION_FIXED, "env_raw1");
> +		dev_add_bb_dev("env_raw1", "env1");
> +	}
>  
>  	return 0;
>  }
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

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

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

* Re: [PATCH 3/3] sama5d3: detect boot mode
  2013-02-06 10:05     ` Alexander Aring
@ 2013-02-06 13:14       ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 9+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-02-06 13:14 UTC (permalink / raw)
  To: Alexander Aring; +Cc: barebox

On 11:05 Wed 06 Feb     , Alexander Aring wrote:
> Hi,
> 
> On Tue, Feb 05, 2013 at 07:03:00PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > and dynamised where we are stored
> > 
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> > ---
> >  arch/arm/boards/sama5d3xek/init.c |   24 ++++++++++++++++--------
> >  1 file changed, 16 insertions(+), 8 deletions(-)
> > 
> > diff --git a/arch/arm/boards/sama5d3xek/init.c b/arch/arm/boards/sama5d3xek/init.c
> > index 110a83f..165aaac 100644
> > --- a/arch/arm/boards/sama5d3xek/init.c
> > +++ b/arch/arm/boards/sama5d3xek/init.c
> > @@ -36,6 +36,7 @@
> >  #include <mach/at91_pmc.h>
> >  #include <mach/at91_rstc.h>
> >  #include <mach/at91sam9x5_matrix.h>
> > +#include <mach/bootmode.h>
> >  #include <input/qt1070.h>
> >  #include <readkey.h>
> >  #include <poller.h>
> > @@ -381,14 +382,21 @@ static int at91sama5d3xek_devices_init(void)
> >  
> >  	armlinux_set_bootparams((void *)(SAMA5_DDRCS + 0x100));
> >  
> > -	devfs_add_partition("nand0", 0x00000, SZ_256K, DEVFS_PARTITION_FIXED, "at91bootstrap_raw");
> > -	dev_add_bb_dev("at91bootstrap_raw", "at91bootstrap");
> > -	devfs_add_partition("nand0", SZ_256K, SZ_256K + SZ_128K, DEVFS_PARTITION_FIXED, "self_raw");
> > -	dev_add_bb_dev("self_raw", "self0");
> > -	devfs_add_partition("nand0", SZ_512K + SZ_256K, SZ_256K, DEVFS_PARTITION_FIXED, "env_raw");
> > -	dev_add_bb_dev("env_raw", "env0");
> > -	devfs_add_partition("nand0", SZ_1M, SZ_256K, DEVFS_PARTITION_FIXED, "env_raw1");
> > -	dev_add_bb_dev("env_raw1", "env1");
> > +	if (at91_boot_media_at25() && IS_ENABLED(CONFIG_DRIVER_SPI_ATMEL)) {
> 
> I don't know, but is it better to use (at91_boot_media_at25() && at91_boot_from_spi())
> instead of checking if SPI driver is enabled at compile time?

simple I want one binary whtat work when we boot from mmc/spi/nand

so all the drivers are enabled

Best Regards,
J.
> 
> Regards
> Alex
> 
> > +		devfs_add_partition("m25p0", 0x00000, SZ_64K, DEVFS_PARTITION_FIXED, "at91bootstrap_raw");
> > +		devfs_add_partition("m25p0", SZ_64K, SZ_256K + SZ_128K, DEVFS_PARTITION_FIXED, "self_raw");
> > +		devfs_add_partition("m25p0", SZ_64K + SZ_256K + SZ_128K, SZ_256K, DEVFS_PARTITION_FIXED, "env_raw");
> > +		devfs_add_partition("m25p0", SZ_64K + SZ_512K + SZ_128K, SZ_256K, DEVFS_PARTITION_FIXED, "env_raw1");
> > +	} else {
> > +		devfs_add_partition("nand0", 0x00000, SZ_256K, DEVFS_PARTITION_FIXED, "at91bootstrap_raw");
> > +		dev_add_bb_dev("at91bootstrap_raw", "at91bootstrap");
> > +		devfs_add_partition("nand0", SZ_256K, SZ_256K + SZ_128K, DEVFS_PARTITION_FIXED, "self_raw");
> > +		dev_add_bb_dev("self_raw", "self0");
> > +		devfs_add_partition("nand0", SZ_512K + SZ_256K, SZ_256K, DEVFS_PARTITION_FIXED, "env_raw");
> > +		dev_add_bb_dev("env_raw", "env0");
> > +		devfs_add_partition("nand0", SZ_1M, SZ_256K, DEVFS_PARTITION_FIXED, "env_raw1");
> > +		dev_add_bb_dev("env_raw1", "env1");
> > +	}
> >  
> >  	return 0;
> >  }
> > -- 
> > 1.7.10.4
> > 
> > 
> > _______________________________________________
> > barebox mailing list
> > barebox@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/barebox

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

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

* Re: [PATCH 1/3] at91: add boot mode detection support
  2013-02-05 18:02 ` [PATCH 1/3] " Jean-Christophe PLAGNIOL-VILLARD
                     ` (2 preceding siblings ...)
  2013-02-05 18:08   ` [PATCH 1/3] at91: add boot mode detection support Marc Kleine-Budde
@ 2013-02-06 18:27   ` Sascha Hauer
  2013-02-06 18:45     ` Jean-Christophe PLAGNIOL-VILLARD
  3 siblings, 1 reply; 9+ messages in thread
From: Sascha Hauer @ 2013-02-06 18:27 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

+1 for getting something common. On i.MX we currently use the
barebox_loc environment variable. Not that I you should do the same for
Atmel, but we should come up with something both i.MX and Atmel can be
converted to.

> +
> +	dev = add_generic_device_res("bootloc", DEVICE_ID_SINGLE, NULL, 0, NULL);

I know you are concerned about performance when the single 'global'
device has many variables. I think the performance can be greatly
improved by making sure the global device is the first one to be
registered.

IMO adding a new device for every fart in the system does not improve the
situation.

> +enum at91_soc_boot_from {
> +	AT91_BOOT_FROM_UNKNOWN,
> +	AT91_BOOT_FROM_SPI,
> +	AT91_BOOT_FROM_MCI,
> +	AT91_BOOT_FROM_SMC,
> +	AT91_BOOT_FROM_TWD,
> +};
> +
> +enum at91_soc_boot_media {
> +	AT91_BOOT_MEDIA_UNKNOWN,
> +	AT91_BOOT_MEDIA_SD,
> +	AT91_BOOT_MEDIA_MMC,
> +	AT91_BOOT_MEDIA_EMMC,
> +	AT91_BOOT_MEDIA_AT45,
> +	AT91_BOOT_MEDIA_AT25,
> +	AT91_BOOT_MEDIA_NAND,
> +	AT91_BOOT_MEDIA_NOR,
> +};

Hm. For NAND/NOR the first array does not contain useful information,
for MCI the second array does not contain useful information. For
I2C/SPI both arrays seem redundant.

Why not merge them into one?

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] 9+ messages in thread

* Re: [PATCH 1/3] at91: add boot mode detection support
  2013-02-06 18:27   ` Sascha Hauer
@ 2013-02-06 18:45     ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 9+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-02-06 18:45 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On 19:27 Wed 06 Feb     , Sascha Hauer wrote:
> +1 for getting something common. On i.MX we currently use the
> barebox_loc environment variable. Not that I you should do the same for
> Atmel, but we should come up with something both i.MX and Atmel can be
> converted to.
> 
> > +
> > +	dev = add_generic_device_res("bootloc", DEVICE_ID_SINGLE, NULL, 0, NULL);
> 
> I know you are concerned about performance when the single 'global'
> device has many variables. I think the performance can be greatly
> improved by making sure the global device is the first one to be
> registered.
> 
> IMO adding a new device for every fart in the system does not improve the
> situation.
because this is RO data and I do not like global for specific stuff

global need to be for shell var create

and via specific dev with devinfo you can see to params quick and clear
> 
> > +enum at91_soc_boot_from {
> > +	AT91_BOOT_FROM_UNKNOWN,
> > +	AT91_BOOT_FROM_SPI,
> > +	AT91_BOOT_FROM_MCI,
> > +	AT91_BOOT_FROM_SMC,
> > +	AT91_BOOT_FROM_TWD,
> > +};
> > +
> > +enum at91_soc_boot_media {
> > +	AT91_BOOT_MEDIA_UNKNOWN,
> > +	AT91_BOOT_MEDIA_SD,
> > +	AT91_BOOT_MEDIA_MMC,
> > +	AT91_BOOT_MEDIA_EMMC,
> > +	AT91_BOOT_MEDIA_AT45,
> > +	AT91_BOOT_MEDIA_AT25,
> > +	AT91_BOOT_MEDIA_NAND,
> > +	AT91_BOOT_MEDIA_NOR,
> > +};
> 
> Hm. For NAND/NOR the first array does not contain useful information,
> for MCI the second array does not contain useful information. For
> I2C/SPI both arrays seem redundant.
> 
> Why not merge them into one?

no because SMC is for NAND & NOR
SPI => at25/at45
MCI => SD/MMC/eMMC

we have the different information in the register I want to expose it

use full for IC debug as example and boot strategie

Best Regards,
J.
> 
> 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] 9+ messages in thread

end of thread, other threads:[~2013-02-06 18:46 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-05 17:59 [PATCH 0/3] at91: add boot mode detection support Jean-Christophe PLAGNIOL-VILLARD
2013-02-05 18:02 ` [PATCH 1/3] " Jean-Christophe PLAGNIOL-VILLARD
2013-02-05 18:02   ` [PATCH 2/3] sama5d3: add boot mode supprot Jean-Christophe PLAGNIOL-VILLARD
2013-02-05 18:03   ` [PATCH 3/3] sama5d3: detect boot mode Jean-Christophe PLAGNIOL-VILLARD
2013-02-06 10:05     ` Alexander Aring
2013-02-06 13:14       ` Jean-Christophe PLAGNIOL-VILLARD
2013-02-05 18:08   ` [PATCH 1/3] at91: add boot mode detection support Marc Kleine-Budde
2013-02-06 18:27   ` Sascha Hauer
2013-02-06 18:45     ` Jean-Christophe PLAGNIOL-VILLARD

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