mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 00/10] make bootsource an arch independent framework
@ 2013-03-14 17:38 Marc Kleine-Budde
  2013-03-14 17:38 ` [PATCH 01/10] ARM i.MX bootsource: convert enums from enum imx_bootsource to uppercase Marc Kleine-Budde
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2013-03-14 17:38 UTC (permalink / raw)
  To: barebox

Hello,

this series first cleans up the i.mx specific bootsource code. Then the arch
independent code is moved into a seperate file, creating an arch independent
framework. The last patch adds bootsource detection for the i.mx28.

regards,

Marc


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

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

* [PATCH 01/10] ARM i.MX bootsource: convert enums from enum imx_bootsource to uppercase
  2013-03-14 17:38 [PATCH 00/10] make bootsource an arch independent framework Marc Kleine-Budde
@ 2013-03-14 17:38 ` Marc Kleine-Budde
  2013-03-14 17:38 ` [PATCH 02/10] ARM i.MX bootsource: convert all imx*_boot_save_loc functions to void Marc Kleine-Budde
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2013-03-14 17:38 UTC (permalink / raw)
  To: barebox

Enums are in the same way as defines, so write them in uppercase.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 arch/arm/boards/efika-mx-smartbook/board.c |  2 +-
 arch/arm/boards/karo-tx53/board.c          |  4 +-
 arch/arm/boards/pcm038/pcm038.c            |  2 +-
 arch/arm/mach-imx/boot.c                   | 90 +++++++++++++++---------------
 arch/arm/mach-imx/include/mach/generic.h   | 18 +++---
 5 files changed, 58 insertions(+), 58 deletions(-)

diff --git a/arch/arm/boards/efika-mx-smartbook/board.c b/arch/arm/boards/efika-mx-smartbook/board.c
index 5c02689..03399a3 100644
--- a/arch/arm/boards/efika-mx-smartbook/board.c
+++ b/arch/arm/boards/efika-mx-smartbook/board.c
@@ -479,7 +479,7 @@ device_initcall(efikamx_devices_init);
 
 static int efikamx_part_init(void)
 {
-	if (imx_bootsource() == bootsource_mmc) {
+	if (imx_bootsource() == BOOTSOURCE_MMC) {
 		devfs_add_partition("mmc_left", 0x00000, 0x80000,
 				DEVFS_PARTITION_FIXED, "self0");
 		devfs_add_partition("mmc_left", 0x80000, 0x80000,
diff --git a/arch/arm/boards/karo-tx53/board.c b/arch/arm/boards/karo-tx53/board.c
index 8a69e99..3112552 100644
--- a/arch/arm/boards/karo-tx53/board.c
+++ b/arch/arm/boards/karo-tx53/board.c
@@ -235,12 +235,12 @@ static int tx53_part_init(void)
 	const char *envdev;
 
 	switch (imx_bootsource()) {
-	case bootsource_mmc:
+	case BOOTSOURCE_MMC:
 		devfs_add_partition("disk0", 0x00000, SZ_512K, DEVFS_PARTITION_FIXED, "self0");
 		devfs_add_partition("disk0", SZ_512K, SZ_1M, DEVFS_PARTITION_FIXED, "env0");
 		envdev = "MMC";
 		break;
-	case bootsource_nand:
+	case BOOTSOURCE_NAND:
 	default:
 		devfs_add_partition("nand0", 0x00000, 0x80000, DEVFS_PARTITION_FIXED, "self_raw");
 		dev_add_bb_dev("self_raw", "self0");
diff --git a/arch/arm/boards/pcm038/pcm038.c b/arch/arm/boards/pcm038/pcm038.c
index 5e9c0fd..af31414 100644
--- a/arch/arm/boards/pcm038/pcm038.c
+++ b/arch/arm/boards/pcm038/pcm038.c
@@ -296,7 +296,7 @@ static int pcm038_devices_init(void)
 	imx27_add_fec(&fec_info);
 
 	switch (imx_bootsource()) {
-	case bootsource_nand:
+	case BOOTSOURCE_NAND:
 		devfs_add_partition("nand0", 0x00000, 0x80000,
 					DEVFS_PARTITION_FIXED, "self_raw");
 		dev_add_bb_dev("self_raw", "self0");
diff --git a/arch/arm/mach-imx/boot.c b/arch/arm/mach-imx/boot.c
index 8c7f8ee..4c43487 100644
--- a/arch/arm/mach-imx/boot.c
+++ b/arch/arm/mach-imx/boot.c
@@ -20,15 +20,15 @@
 #include <mach/generic.h>
 
 static const char *bootsource_str[] = {
-	[bootsource_unknown] = "unknown",
-	[bootsource_nand] = "nand",
-	[bootsource_nor] = "nor",
-	[bootsource_mmc] = "mmc",
-	[bootsource_i2c] = "i2c",
-	[bootsource_spi] = "spi",
-	[bootsource_serial] = "serial",
-	[bootsource_onenand] = "onenand",
-	[bootsource_hd] = "harddisk",
+	[BOOTSOURCE_UNKNOWN] = "unknown",
+	[BOOTSOURCE_NAND] = "nand",
+	[BOOTSOURCE_NOR] = "nor",
+	[BOOTSOURCE_MMC] = "mmc",
+	[BOOTSOURCE_I2C] = "i2c",
+	[BOOTSOURCE_SPI] = "spi",
+	[BOOTSOURCE_SERIAL] = "serial",
+	[BOOTSOURCE_ONENAND] = "onenand",
+	[BOOTSOURCE_HD] = "harddisk",
 };
 
 static enum imx_bootsource bootsource;
@@ -36,7 +36,7 @@ static enum imx_bootsource bootsource;
 void imx_set_bootsource(enum imx_bootsource src)
 {
 	if (src >= ARRAY_SIZE(bootsource_str))
-		src = bootsource_unknown;
+		src = BOOTSOURCE_UNKNOWN;
 
 	bootsource = src;
 
@@ -54,25 +54,25 @@ BAREBOX_MAGICVAR(barebox_loc, "The source barebox has been booted from");
 /* [CTRL][TYPE] */
 static const enum imx_bootsource locations[4][4] = {
 	{ /* CTRL = WEIM */
-		bootsource_nor,
-		bootsource_unknown,
-		bootsource_onenand,
-		bootsource_unknown,
+		BOOTSOURCE_NOR,
+		BOOTSOURCE_UNKNOWN,
+		BOOTSOURCE_ONENAND,
+		BOOTSOURCE_UNKNOWN,
 	}, { /* CTRL == NAND */
-		bootsource_nand,
-		bootsource_nand,
-		bootsource_nand,
-		bootsource_nand,
+		BOOTSOURCE_NAND,
+		BOOTSOURCE_NAND,
+		BOOTSOURCE_NAND,
+		BOOTSOURCE_NAND,
 	}, { /* CTRL == ATA, (imx35 only) */
-		bootsource_unknown,
-		bootsource_unknown, /* might be p-ata */
-		bootsource_unknown,
-		bootsource_unknown,
+		BOOTSOURCE_UNKNOWN,
+		BOOTSOURCE_UNKNOWN, /* might be p-ata */
+		BOOTSOURCE_UNKNOWN,
+		BOOTSOURCE_UNKNOWN,
 	}, { /* CTRL == expansion */
-		bootsource_mmc, /* note imx25 could also be: movinand, ce-ata */
-		bootsource_unknown,
-		bootsource_i2c,
-		bootsource_spi,
+		BOOTSOURCE_MMC, /* note imx25 could also be: movinand, ce-ata */
+		BOOTSOURCE_UNKNOWN,
+		BOOTSOURCE_I2C,
+		BOOTSOURCE_SPI,
 	}
 };
 
@@ -132,16 +132,16 @@ void imx_27_boot_save_loc(void __iomem *sysctrl_base)
 
 	switch (val) {
 	case IMX27_GPCR_BOOT_UART_USB:
-		src = bootsource_serial;
+		src = BOOTSOURCE_SERIAL;
 		break;
 	case IMX27_GPCR_BOOT_8BIT_NAND_2k:
 	case IMX27_GPCR_BOOT_16BIT_NAND_2k:
 	case IMX27_GPCR_BOOT_16BIT_NAND_512:
 	case IMX27_GPCR_BOOT_8BIT_NAND_512:
-		src = bootsource_nand;
+		src = BOOTSOURCE_NAND;
 		break;
 	default:
-		src = bootsource_nor;
+		src = BOOTSOURCE_NOR;
 		break;
 	}
 
@@ -155,7 +155,7 @@ void imx_27_boot_save_loc(void __iomem *sysctrl_base)
 
 int imx51_boot_save_loc(void __iomem *src_base)
 {
-	enum imx_bootsource src = bootsource_unknown;
+	enum imx_bootsource src = BOOTSOURCE_UNKNOWN;
 	uint32_t reg;
 	unsigned int ctrl, type;
 
@@ -172,10 +172,10 @@ int imx51_boot_save_loc(void __iomem *src_base)
 		break;
 	case 1:
 		/* reserved */
-		src = bootsource_unknown;
+		src = BOOTSOURCE_UNKNOWN;
 		break;
 	case 3:
-		src = bootsource_serial;
+		src = BOOTSOURCE_SERIAL;
 		break;
 
 	}
@@ -188,31 +188,31 @@ int imx51_boot_save_loc(void __iomem *src_base)
 #define IMX53_SRC_SBMR	0x4
 int imx53_boot_save_loc(void __iomem *src_base)
 {
-	enum imx_bootsource src = bootsource_unknown;
+	enum imx_bootsource src = BOOTSOURCE_UNKNOWN;
 	uint32_t cfg1 = readl(src_base + IMX53_SRC_SBMR) & 0xff;
 
 	switch (cfg1 >> 4) {
 	case 2:
-		src = bootsource_hd;
+		src = BOOTSOURCE_HD;
 		break;
 	case 3:
 		if (cfg1 & (1 << 3))
-			src = bootsource_spi;
+			src = BOOTSOURCE_SPI;
 		else
-			src = bootsource_i2c;
+			src = BOOTSOURCE_I2C;
 		break;
 	case 4:
 	case 5:
 	case 6:
 	case 7:
-		src = bootsource_mmc;
+		src = BOOTSOURCE_MMC;
 		break;
 	default:
 		break;
 	}
 
 	if (cfg1 & (1 << 7))
-		src = bootsource_nand;
+		src = BOOTSOURCE_NAND;
 
 	imx_set_bootsource(src);
 
@@ -224,7 +224,7 @@ int imx53_boot_save_loc(void __iomem *src_base)
 
 int imx6_boot_save_loc(void __iomem *src_base)
 {
-	enum imx_bootsource src = bootsource_unknown;
+	enum imx_bootsource src = BOOTSOURCE_UNKNOWN;
 	uint32_t sbmr2 = readl(src_base + IMX6_SRC_SBMR2) >> 24;
 	uint32_t cfg1 = readl(src_base + IMX6_SRC_SBMR1) & 0xff;
 	uint32_t boot_cfg_4_2_0;
@@ -237,7 +237,7 @@ int imx6_boot_save_loc(void __iomem *src_base)
 	case 2: /* internal boot */
 		goto internal_boot;
 	case 1: /* Serial Downloader */
-		src = bootsource_serial;
+		src = BOOTSOURCE_SERIAL;
 		break;
 	case 3: /* reserved */
 		break;
@@ -251,28 +251,28 @@ internal_boot:
 
 	switch (cfg1 >> 4) {
 	case 2:
-		src = bootsource_hd;
+		src = BOOTSOURCE_HD;
 		break;
 	case 3:
 		boot_cfg_4_2_0 = (cfg1 >> 16) & 0x7;
 
 		if (boot_cfg_4_2_0 > 4)
-			src = bootsource_i2c;
+			src = BOOTSOURCE_I2C;
 		else
-			src = bootsource_spi;
+			src = BOOTSOURCE_SPI;
 		break;
 	case 4:
 	case 5:
 	case 6:
 	case 7:
-		src = bootsource_mmc;
+		src = BOOTSOURCE_MMC;
 		break;
 	default:
 		break;
 	}
 
 	if (cfg1 & (1 << 7))
-		src = bootsource_nand;
+		src = BOOTSOURCE_NAND;
 
 	imx_set_bootsource(src);
 
diff --git a/arch/arm/mach-imx/include/mach/generic.h b/arch/arm/mach-imx/include/mach/generic.h
index 5e600a3..a271b5b 100644
--- a/arch/arm/mach-imx/include/mach/generic.h
+++ b/arch/arm/mach-imx/include/mach/generic.h
@@ -2,15 +2,15 @@
 u64 imx_uid(void);
 
 enum imx_bootsource {
-	bootsource_unknown,
-	bootsource_nand,
-	bootsource_nor,
-	bootsource_mmc,
-	bootsource_i2c,
-	bootsource_spi,
-	bootsource_serial,
-	bootsource_onenand,
-	bootsource_hd,
+	BOOTSOURCE_UNKNOWN,
+	BOOTSOURCE_NAND,
+	BOOTSOURCE_NOR,
+	BOOTSOURCE_MMC,
+	BOOTSOURCE_I2C,
+	BOOTSOURCE_SPI,
+	BOOTSOURCE_SERIAL,
+	BOOTSOURCE_ONENAND,
+	BOOTSOURCE_HD,
 };
 
 enum imx_bootsource imx_bootsource(void);
-- 
1.8.2.rc2


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

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

* [PATCH 02/10] ARM i.MX bootsource: convert all imx*_boot_save_loc functions to void
  2013-03-14 17:38 [PATCH 00/10] make bootsource an arch independent framework Marc Kleine-Budde
  2013-03-14 17:38 ` [PATCH 01/10] ARM i.MX bootsource: convert enums from enum imx_bootsource to uppercase Marc Kleine-Budde
@ 2013-03-14 17:38 ` Marc Kleine-Budde
  2013-03-14 17:38 ` [PATCH 03/10] ARM i.MX bootsource: imx_25_35_boot_save_loc: remove leftover do-nothing code Marc Kleine-Budde
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2013-03-14 17:38 UTC (permalink / raw)
  To: barebox

This function gives all functions a common, i.e. void, return value.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 arch/arm/mach-imx/boot.c                 | 18 ++++++------------
 arch/arm/mach-imx/include/mach/generic.h |  8 ++++----
 2 files changed, 10 insertions(+), 16 deletions(-)

diff --git a/arch/arm/mach-imx/boot.c b/arch/arm/mach-imx/boot.c
index 4c43487..068fa22 100644
--- a/arch/arm/mach-imx/boot.c
+++ b/arch/arm/mach-imx/boot.c
@@ -94,7 +94,7 @@ static const enum imx_bootsource locations[4][4] = {
  * Note also that I suspect that the boot source pins are only sampled at
  * power up.
  */
-int imx_25_35_boot_save_loc(unsigned int ctrl, unsigned int type)
+void imx_25_35_boot_save_loc(unsigned int ctrl, unsigned int type)
 {
 	const char *bareboxloc = NULL;
 	enum imx_bootsource src;
@@ -106,8 +106,6 @@ int imx_25_35_boot_save_loc(unsigned int ctrl, unsigned int type)
 		setenv("barebox_loc", bareboxloc);
 		export("barebox_loc");
 	}
-
-	return 0;
 }
 
 #define IMX27_SYSCTRL_GPCR	0x18
@@ -153,7 +151,7 @@ void imx_27_boot_save_loc(void __iomem *sysctrl_base)
 #define IMX51_SBMR_BT_MEM_CTL_SHIFT	0
 #define IMX51_SBMR_BMOD_SHIFT		14
 
-int imx51_boot_save_loc(void __iomem *src_base)
+void imx51_boot_save_loc(void __iomem *src_base)
 {
 	enum imx_bootsource src = BOOTSOURCE_UNKNOWN;
 	uint32_t reg;
@@ -181,12 +179,10 @@ int imx51_boot_save_loc(void __iomem *src_base)
 	}
 
 	imx_set_bootsource(src);
-
-	return 0;
 }
 
 #define IMX53_SRC_SBMR	0x4
-int imx53_boot_save_loc(void __iomem *src_base)
+void imx53_boot_save_loc(void __iomem *src_base)
 {
 	enum imx_bootsource src = BOOTSOURCE_UNKNOWN;
 	uint32_t cfg1 = readl(src_base + IMX53_SRC_SBMR) & 0xff;
@@ -215,14 +211,12 @@ int imx53_boot_save_loc(void __iomem *src_base)
 		src = BOOTSOURCE_NAND;
 
 	imx_set_bootsource(src);
-
-	return 0;
 }
 
 #define IMX6_SRC_SBMR1	0x04
 #define IMX6_SRC_SBMR2	0x1c
 
-int imx6_boot_save_loc(void __iomem *src_base)
+void imx6_boot_save_loc(void __iomem *src_base)
 {
 	enum imx_bootsource src = BOOTSOURCE_UNKNOWN;
 	uint32_t sbmr2 = readl(src_base + IMX6_SRC_SBMR2) >> 24;
@@ -245,7 +239,7 @@ int imx6_boot_save_loc(void __iomem *src_base)
 
 	imx_set_bootsource(src);
 
-	return 0;
+	return;
 
 internal_boot:
 
@@ -276,5 +270,5 @@ internal_boot:
 
 	imx_set_bootsource(src);
 
-	return 0;
+	return;
 }
diff --git a/arch/arm/mach-imx/include/mach/generic.h b/arch/arm/mach-imx/include/mach/generic.h
index a271b5b..e6edb94 100644
--- a/arch/arm/mach-imx/include/mach/generic.h
+++ b/arch/arm/mach-imx/include/mach/generic.h
@@ -16,11 +16,11 @@ enum imx_bootsource {
 enum imx_bootsource imx_bootsource(void);
 void imx_set_bootsource(enum imx_bootsource src);
 
-int imx_25_35_boot_save_loc(unsigned int ctrl, unsigned int type);
+void imx_25_35_boot_save_loc(unsigned int ctrl, unsigned int type);
 void imx_27_boot_save_loc(void __iomem *sysctrl_base);
-int imx51_boot_save_loc(void __iomem *src_base);
-int imx53_boot_save_loc(void __iomem *src_base);
-int imx6_boot_save_loc(void __iomem *src_base);
+void imx51_boot_save_loc(void __iomem *src_base);
+void imx53_boot_save_loc(void __iomem *src_base);
+void imx6_boot_save_loc(void __iomem *src_base);
 
 /* There's a off-by-one betweem the gpio bank number and the gpiochip */
 /* range e.g. GPIO_1_5 is gpio 5 under linux */
-- 
1.8.2.rc2


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

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

* [PATCH 03/10] ARM i.MX bootsource: imx_25_35_boot_save_loc: remove leftover do-nothing code
  2013-03-14 17:38 [PATCH 00/10] make bootsource an arch independent framework Marc Kleine-Budde
  2013-03-14 17:38 ` [PATCH 01/10] ARM i.MX bootsource: convert enums from enum imx_bootsource to uppercase Marc Kleine-Budde
  2013-03-14 17:38 ` [PATCH 02/10] ARM i.MX bootsource: convert all imx*_boot_save_loc functions to void Marc Kleine-Budde
@ 2013-03-14 17:38 ` Marc Kleine-Budde
  2013-03-14 17:38 ` [PATCH 04/10] ARM i.MX bootsource: rename imx_27_boot_save_loc -> imx27_boot_save_loc Marc Kleine-Budde
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2013-03-14 17:38 UTC (permalink / raw)
  To: barebox

This patch removes some code leftover from:
    a029e32 ARM i.MX: rework bootsource setting
which is now a no-op.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 arch/arm/mach-imx/boot.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/arch/arm/mach-imx/boot.c b/arch/arm/mach-imx/boot.c
index 068fa22..37f1180 100644
--- a/arch/arm/mach-imx/boot.c
+++ b/arch/arm/mach-imx/boot.c
@@ -96,16 +96,11 @@ static const enum imx_bootsource locations[4][4] = {
  */
 void imx_25_35_boot_save_loc(unsigned int ctrl, unsigned int type)
 {
-	const char *bareboxloc = NULL;
 	enum imx_bootsource src;
 
 	src = locations[ctrl][type];
 
 	imx_set_bootsource(src);
-	if (bareboxloc) {
-		setenv("barebox_loc", bareboxloc);
-		export("barebox_loc");
-	}
 }
 
 #define IMX27_SYSCTRL_GPCR	0x18
-- 
1.8.2.rc2


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

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

* [PATCH 04/10] ARM i.MX bootsource: rename imx_27_boot_save_loc -> imx27_boot_save_loc
  2013-03-14 17:38 [PATCH 00/10] make bootsource an arch independent framework Marc Kleine-Budde
                   ` (2 preceding siblings ...)
  2013-03-14 17:38 ` [PATCH 03/10] ARM i.MX bootsource: imx_25_35_boot_save_loc: remove leftover do-nothing code Marc Kleine-Budde
@ 2013-03-14 17:38 ` Marc Kleine-Budde
  2013-03-14 17:38 ` [PATCH 05/10] ARM i.MX bootsource: add separate function for mx25 and mx35 Marc Kleine-Budde
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2013-03-14 17:38 UTC (permalink / raw)
  To: barebox

This patch renames imx_27_boot_save_loc() to imx27_boot_save_loc(), so that all
imx*_boot_save_loc() functions follow the same nameing sheme.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 arch/arm/mach-imx/boot.c                 | 2 +-
 arch/arm/mach-imx/imx27.c                | 2 +-
 arch/arm/mach-imx/include/mach/generic.h | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-imx/boot.c b/arch/arm/mach-imx/boot.c
index 37f1180..473b9d1 100644
--- a/arch/arm/mach-imx/boot.c
+++ b/arch/arm/mach-imx/boot.c
@@ -114,7 +114,7 @@ void imx_25_35_boot_save_loc(unsigned int ctrl, unsigned int type)
 #define IMX27_GPCR_BOOT_32BIT_CS0		6
 #define IMX27_GPCR_BOOT_8BIT_NAND_512		7
 
-void imx_27_boot_save_loc(void __iomem *sysctrl_base)
+void imx27_boot_save_loc(void __iomem *sysctrl_base)
 {
 	enum imx_bootsource src;
 	uint32_t val;
diff --git a/arch/arm/mach-imx/imx27.c b/arch/arm/mach-imx/imx27.c
index 6d30276..7615b98 100644
--- a/arch/arm/mach-imx/imx27.c
+++ b/arch/arm/mach-imx/imx27.c
@@ -99,7 +99,7 @@ static void imx27_init_max(void)
 static int imx27_init(void)
 {
 	imx27_silicon_revision();
-	imx_27_boot_save_loc((void *)MX27_SYSCTRL_BASE_ADDR);
+	imx27_boot_save_loc((void *)MX27_SYSCTRL_BASE_ADDR);
 
 	imx_iomuxv1_init((void *)MX27_GPIO1_BASE_ADDR);
 
diff --git a/arch/arm/mach-imx/include/mach/generic.h b/arch/arm/mach-imx/include/mach/generic.h
index e6edb94..d39369b 100644
--- a/arch/arm/mach-imx/include/mach/generic.h
+++ b/arch/arm/mach-imx/include/mach/generic.h
@@ -17,7 +17,7 @@ enum imx_bootsource imx_bootsource(void);
 void imx_set_bootsource(enum imx_bootsource src);
 
 void imx_25_35_boot_save_loc(unsigned int ctrl, unsigned int type);
-void imx_27_boot_save_loc(void __iomem *sysctrl_base);
+void imx27_boot_save_loc(void __iomem *sysctrl_base);
 void imx51_boot_save_loc(void __iomem *src_base);
 void imx53_boot_save_loc(void __iomem *src_base);
 void imx6_boot_save_loc(void __iomem *src_base);
-- 
1.8.2.rc2


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

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

* [PATCH 05/10] ARM i.MX bootsource: add separate function for mx25 and mx35
  2013-03-14 17:38 [PATCH 00/10] make bootsource an arch independent framework Marc Kleine-Budde
                   ` (3 preceding siblings ...)
  2013-03-14 17:38 ` [PATCH 04/10] ARM i.MX bootsource: rename imx_27_boot_save_loc -> imx27_boot_save_loc Marc Kleine-Budde
@ 2013-03-14 17:38 ` Marc Kleine-Budde
  2013-03-14 17:38 ` [PATCH 06/10] bootsource: create arch independent bootsource framework Marc Kleine-Budde
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2013-03-14 17:38 UTC (permalink / raw)
  To: barebox

This patch creates a seperate function for mx25 and mx35 to save it's
bootsource.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 arch/arm/mach-imx/boot.c                 | 22 +++++++++++++++++++++-
 arch/arm/mach-imx/imx25.c                |  6 +-----
 arch/arm/mach-imx/imx35.c                |  6 +-----
 arch/arm/mach-imx/include/mach/generic.h |  3 ++-
 4 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/arch/arm/mach-imx/boot.c b/arch/arm/mach-imx/boot.c
index 473b9d1..95a7673 100644
--- a/arch/arm/mach-imx/boot.c
+++ b/arch/arm/mach-imx/boot.c
@@ -18,6 +18,8 @@
 
 #include <io.h>
 #include <mach/generic.h>
+#include <mach/imx25-regs.h>
+#include <mach/imx35-regs.h>
 
 static const char *bootsource_str[] = {
 	[BOOTSOURCE_UNKNOWN] = "unknown",
@@ -94,7 +96,7 @@ static const enum imx_bootsource locations[4][4] = {
  * Note also that I suspect that the boot source pins are only sampled at
  * power up.
  */
-void imx_25_35_boot_save_loc(unsigned int ctrl, unsigned int type)
+static void imx25_35_boot_save_loc(unsigned int ctrl, unsigned int type)
 {
 	enum imx_bootsource src;
 
@@ -103,6 +105,24 @@ void imx_25_35_boot_save_loc(unsigned int ctrl, unsigned int type)
 	imx_set_bootsource(src);
 }
 
+void imx25_boot_save_loc(void __iomem *ccm_base)
+{
+	uint32_t val;
+
+	val = readl(ccm_base + MX25_CCM_RCSR);
+	imx25_35_boot_save_loc((val >> MX25_CCM_RCSR_MEM_CTRL_SHIFT) & 0x3,
+			       (val >> MX25_CCM_RCSR_MEM_TYPE_SHIFT) & 0x3);
+}
+
+void imx35_boot_save_loc(void __iomem *ccm_base)
+{
+	uint32_t val;
+
+	val = readl(ccm_base + MX35_CCM_RCSR);
+	imx25_35_boot_save_loc((val >> MX35_CCM_RCSR_MEM_CTRL_SHIFT) & 0x3,
+			       (val >> MX35_CCM_RCSR_MEM_TYPE_SHIFT) & 0x3);
+}
+
 #define IMX27_SYSCTRL_GPCR	0x18
 #define IMX27_GPCR_BOOT_SHIFT			16
 #define IMX27_GPCR_BOOT_MASK			(0xf << IMX27_GPCR_BOOT_SHIFT)
diff --git a/arch/arm/mach-imx/imx25.c b/arch/arm/mach-imx/imx25.c
index adcd9d2..5011918 100644
--- a/arch/arm/mach-imx/imx25.c
+++ b/arch/arm/mach-imx/imx25.c
@@ -59,11 +59,7 @@ static struct imx_iim_platform_data imx25_iim_pdata = {
 
 static int imx25_init(void)
 {
-	uint32_t val;
-
-	val = readl(MX25_CCM_BASE_ADDR + MX25_CCM_RCSR);
-	imx_25_35_boot_save_loc((val >> MX25_CCM_RCSR_MEM_CTRL_SHIFT) & 0x3,
-			(val >> MX25_CCM_RCSR_MEM_TYPE_SHIFT) & 0x3);
+	imx25_boot_save_loc((void *)MX25_CCM_BASE_ADDR);
 
 	add_generic_device("imx_iim", 0, NULL, MX25_IIM_BASE_ADDR, SZ_4K,
 			IORESOURCE_MEM, &imx25_iim_pdata);
diff --git a/arch/arm/mach-imx/imx35.c b/arch/arm/mach-imx/imx35.c
index 7b68783..92f6964 100644
--- a/arch/arm/mach-imx/imx35.c
+++ b/arch/arm/mach-imx/imx35.c
@@ -59,13 +59,9 @@ core_initcall(imx35_l2_fix);
 
 static int imx35_init(void)
 {
-	uint32_t val;
-
 	imx35_silicon_revision();
 
-	val = readl(MX35_CCM_BASE_ADDR + MX35_CCM_RCSR);
-	imx_25_35_boot_save_loc((val >> MX35_CCM_RCSR_MEM_CTRL_SHIFT) & 0x3,
-			(val >> MX35_CCM_RCSR_MEM_TYPE_SHIFT) & 0x3);
+	imx35_boot_save_loc((void *)MX35_CCM_BASE_ADDR);
 
 	add_generic_device("imx_iim", 0, NULL, MX35_IIM_BASE_ADDR, SZ_4K,
 			IORESOURCE_MEM, NULL);
diff --git a/arch/arm/mach-imx/include/mach/generic.h b/arch/arm/mach-imx/include/mach/generic.h
index d39369b..f6e9ecf 100644
--- a/arch/arm/mach-imx/include/mach/generic.h
+++ b/arch/arm/mach-imx/include/mach/generic.h
@@ -16,7 +16,8 @@ enum imx_bootsource {
 enum imx_bootsource imx_bootsource(void);
 void imx_set_bootsource(enum imx_bootsource src);
 
-void imx_25_35_boot_save_loc(unsigned int ctrl, unsigned int type);
+void imx25_boot_save_loc(void __iomem *ccm_base);
+void imx35_boot_save_loc(void __iomem *ccm_base);
 void imx27_boot_save_loc(void __iomem *sysctrl_base);
 void imx51_boot_save_loc(void __iomem *src_base);
 void imx53_boot_save_loc(void __iomem *src_base);
-- 
1.8.2.rc2


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

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

* [PATCH 06/10] bootsource: create arch independent bootsource framework
  2013-03-14 17:38 [PATCH 00/10] make bootsource an arch independent framework Marc Kleine-Budde
                   ` (4 preceding siblings ...)
  2013-03-14 17:38 ` [PATCH 05/10] ARM i.MX bootsource: add separate function for mx25 and mx35 Marc Kleine-Budde
@ 2013-03-14 17:38 ` Marc Kleine-Budde
  2013-03-14 17:38 ` [PATCH 07/10] bootsource: use initcall to export bootsource location to environment Marc Kleine-Budde
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2013-03-14 17:38 UTC (permalink / raw)
  To: barebox

This patch seperates the imx independent from the arch independent code. The
following functions and enums are renamed:

- imx_bootsource() -> bootsource_get()
- imx_set_bootsource() -> bootsource_set()
- enum imx_bootsource -> enum bootsource

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 arch/arm/boards/efika-mx-smartbook/board.c |  3 +-
 arch/arm/boards/karo-tx53/board.c          |  3 +-
 arch/arm/boards/pcm038/pcm038.c            |  3 +-
 arch/arm/mach-imx/boot.c                   | 57 +++++++-----------------------
 arch/arm/mach-imx/include/mach/generic.h   | 15 --------
 common/Makefile                            |  1 +
 common/bootsource.c                        | 53 +++++++++++++++++++++++++++
 include/bootsource.h                       | 19 ++++++++++
 8 files changed, 92 insertions(+), 62 deletions(-)
 create mode 100644 common/bootsource.c
 create mode 100644 include/bootsource.h

diff --git a/arch/arm/boards/efika-mx-smartbook/board.c b/arch/arm/boards/efika-mx-smartbook/board.c
index 03399a3..e9b6062 100644
--- a/arch/arm/boards/efika-mx-smartbook/board.c
+++ b/arch/arm/boards/efika-mx-smartbook/board.c
@@ -14,6 +14,7 @@
  */
 
 #include <common.h>
+#include <bootsource.h>
 #include <net.h>
 #include <init.h>
 #include <environment.h>
@@ -479,7 +480,7 @@ device_initcall(efikamx_devices_init);
 
 static int efikamx_part_init(void)
 {
-	if (imx_bootsource() == BOOTSOURCE_MMC) {
+	if (bootsource_get() == BOOTSOURCE_MMC) {
 		devfs_add_partition("mmc_left", 0x00000, 0x80000,
 				DEVFS_PARTITION_FIXED, "self0");
 		devfs_add_partition("mmc_left", 0x80000, 0x80000,
diff --git a/arch/arm/boards/karo-tx53/board.c b/arch/arm/boards/karo-tx53/board.c
index 3112552..7e1ef37 100644
--- a/arch/arm/boards/karo-tx53/board.c
+++ b/arch/arm/boards/karo-tx53/board.c
@@ -13,6 +13,7 @@
  *
  */
 #include <common.h>
+#include <bootsource.h>
 #include <environment.h>
 #include <fcntl.h>
 #include <fec.h>
@@ -234,7 +235,7 @@ static int tx53_part_init(void)
 {
 	const char *envdev;
 
-	switch (imx_bootsource()) {
+	switch (bootsource_get()) {
 	case BOOTSOURCE_MMC:
 		devfs_add_partition("disk0", 0x00000, SZ_512K, DEVFS_PARTITION_FIXED, "self0");
 		devfs_add_partition("disk0", SZ_512K, SZ_1M, DEVFS_PARTITION_FIXED, "env0");
diff --git a/arch/arm/boards/pcm038/pcm038.c b/arch/arm/boards/pcm038/pcm038.c
index af31414..1bd5ffe 100644
--- a/arch/arm/boards/pcm038/pcm038.c
+++ b/arch/arm/boards/pcm038/pcm038.c
@@ -16,6 +16,7 @@
 #define pr_fmt(fmt) "pcm038: " fmt
 
 #include <common.h>
+#include <bootsource.h>
 #include <net.h>
 #include <init.h>
 #include <environment.h>
@@ -295,7 +296,7 @@ static int pcm038_devices_init(void)
 	 */
 	imx27_add_fec(&fec_info);
 
-	switch (imx_bootsource()) {
+	switch (bootsource_get()) {
 	case BOOTSOURCE_NAND:
 		devfs_add_partition("nand0", 0x00000, 0x80000,
 					DEVFS_PARTITION_FIXED, "self_raw");
diff --git a/arch/arm/mach-imx/boot.c b/arch/arm/mach-imx/boot.c
index 95a7673..05730e4 100644
--- a/arch/arm/mach-imx/boot.c
+++ b/arch/arm/mach-imx/boot.c
@@ -12,6 +12,7 @@
  */
 
 #include <common.h>
+#include <bootsource.h>
 #include <environment.h>
 #include <init.h>
 #include <magicvar.h>
@@ -21,40 +22,8 @@
 #include <mach/imx25-regs.h>
 #include <mach/imx35-regs.h>
 
-static const char *bootsource_str[] = {
-	[BOOTSOURCE_UNKNOWN] = "unknown",
-	[BOOTSOURCE_NAND] = "nand",
-	[BOOTSOURCE_NOR] = "nor",
-	[BOOTSOURCE_MMC] = "mmc",
-	[BOOTSOURCE_I2C] = "i2c",
-	[BOOTSOURCE_SPI] = "spi",
-	[BOOTSOURCE_SERIAL] = "serial",
-	[BOOTSOURCE_ONENAND] = "onenand",
-	[BOOTSOURCE_HD] = "harddisk",
-};
-
-static enum imx_bootsource bootsource;
-
-void imx_set_bootsource(enum imx_bootsource src)
-{
-	if (src >= ARRAY_SIZE(bootsource_str))
-		src = BOOTSOURCE_UNKNOWN;
-
-	bootsource = src;
-
-	setenv("barebox_loc", bootsource_str[src]);
-	export("barebox_loc");
-}
-
-enum imx_bootsource imx_bootsource(void)
-{
-	return bootsource;
-}
-
-BAREBOX_MAGICVAR(barebox_loc, "The source barebox has been booted from");
-
 /* [CTRL][TYPE] */
-static const enum imx_bootsource locations[4][4] = {
+static const enum bootsource locations[4][4] = {
 	{ /* CTRL = WEIM */
 		BOOTSOURCE_NOR,
 		BOOTSOURCE_UNKNOWN,
@@ -98,11 +67,11 @@ static const enum imx_bootsource locations[4][4] = {
  */
 static void imx25_35_boot_save_loc(unsigned int ctrl, unsigned int type)
 {
-	enum imx_bootsource src;
+	enum bootsource src;
 
 	src = locations[ctrl][type];
 
-	imx_set_bootsource(src);
+	bootsource_set(src);
 }
 
 void imx25_boot_save_loc(void __iomem *ccm_base)
@@ -136,7 +105,7 @@ void imx35_boot_save_loc(void __iomem *ccm_base)
 
 void imx27_boot_save_loc(void __iomem *sysctrl_base)
 {
-	enum imx_bootsource src;
+	enum bootsource src;
 	uint32_t val;
 
 	val = readl(sysctrl_base + IMX27_SYSCTRL_GPCR);
@@ -158,7 +127,7 @@ void imx27_boot_save_loc(void __iomem *sysctrl_base)
 		break;
 	}
 
-	imx_set_bootsource(src);
+	bootsource_set(src);
 }
 
 #define IMX51_SRC_SBMR			0x4
@@ -168,7 +137,7 @@ void imx27_boot_save_loc(void __iomem *sysctrl_base)
 
 void imx51_boot_save_loc(void __iomem *src_base)
 {
-	enum imx_bootsource src = BOOTSOURCE_UNKNOWN;
+	enum bootsource src = BOOTSOURCE_UNKNOWN;
 	uint32_t reg;
 	unsigned int ctrl, type;
 
@@ -193,13 +162,13 @@ void imx51_boot_save_loc(void __iomem *src_base)
 
 	}
 
-	imx_set_bootsource(src);
+	bootsource_set(src);
 }
 
 #define IMX53_SRC_SBMR	0x4
 void imx53_boot_save_loc(void __iomem *src_base)
 {
-	enum imx_bootsource src = BOOTSOURCE_UNKNOWN;
+	enum bootsource src = BOOTSOURCE_UNKNOWN;
 	uint32_t cfg1 = readl(src_base + IMX53_SRC_SBMR) & 0xff;
 
 	switch (cfg1 >> 4) {
@@ -225,7 +194,7 @@ void imx53_boot_save_loc(void __iomem *src_base)
 	if (cfg1 & (1 << 7))
 		src = BOOTSOURCE_NAND;
 
-	imx_set_bootsource(src);
+	bootsource_set(src);
 }
 
 #define IMX6_SRC_SBMR1	0x04
@@ -233,7 +202,7 @@ void imx53_boot_save_loc(void __iomem *src_base)
 
 void imx6_boot_save_loc(void __iomem *src_base)
 {
-	enum imx_bootsource src = BOOTSOURCE_UNKNOWN;
+	enum bootsource src = BOOTSOURCE_UNKNOWN;
 	uint32_t sbmr2 = readl(src_base + IMX6_SRC_SBMR2) >> 24;
 	uint32_t cfg1 = readl(src_base + IMX6_SRC_SBMR1) & 0xff;
 	uint32_t boot_cfg_4_2_0;
@@ -252,7 +221,7 @@ void imx6_boot_save_loc(void __iomem *src_base)
 		break;
 	};
 
-	imx_set_bootsource(src);
+	bootsource_set(src);
 
 	return;
 
@@ -283,7 +252,7 @@ internal_boot:
 	if (cfg1 & (1 << 7))
 		src = BOOTSOURCE_NAND;
 
-	imx_set_bootsource(src);
+	bootsource_set(src);
 
 	return;
 }
diff --git a/arch/arm/mach-imx/include/mach/generic.h b/arch/arm/mach-imx/include/mach/generic.h
index f6e9ecf..6bce787 100644
--- a/arch/arm/mach-imx/include/mach/generic.h
+++ b/arch/arm/mach-imx/include/mach/generic.h
@@ -1,21 +1,6 @@
 
 u64 imx_uid(void);
 
-enum imx_bootsource {
-	BOOTSOURCE_UNKNOWN,
-	BOOTSOURCE_NAND,
-	BOOTSOURCE_NOR,
-	BOOTSOURCE_MMC,
-	BOOTSOURCE_I2C,
-	BOOTSOURCE_SPI,
-	BOOTSOURCE_SERIAL,
-	BOOTSOURCE_ONENAND,
-	BOOTSOURCE_HD,
-};
-
-enum imx_bootsource imx_bootsource(void);
-void imx_set_bootsource(enum imx_bootsource src);
-
 void imx25_boot_save_loc(void __iomem *ccm_base);
 void imx35_boot_save_loc(void __iomem *ccm_base);
 void imx27_boot_save_loc(void __iomem *sysctrl_base);
diff --git a/common/Makefile b/common/Makefile
index 7206eed..b9ae2e3 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -40,6 +40,7 @@ obj-$(CONFIG_PASSWORD) += password.o
 obj-$(CONFIG_MODULES) += module.o
 obj-$(CONFIG_FLEXIBLE_BOOTARGS) += bootargs.o
 obj-$(CONFIG_BAREBOX_UPDATE) += bbu.o
+obj-y += bootsource.o
 extra-$(CONFIG_MODULES) += module.lds
 extra-y += barebox_default_env barebox_default_env.h
 
diff --git a/common/bootsource.c b/common/bootsource.c
new file mode 100644
index 0000000..2aa0ffa
--- /dev/null
+++ b/common/bootsource.c
@@ -0,0 +1,53 @@
+/*
+ *
+ * Copyright (C) 2011 Marc Reilly <marc@cpdesign.com.au>
+ * Copyright (C) 2013 Marc Kleine-Budde <mkl@pengutronix.de>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <common.h>
+#include <bootsource.h>
+#include <environment.h>
+#include <magicvar.h>
+
+static const char *bootsource_str[] = {
+	[BOOTSOURCE_UNKNOWN] = "unknown",
+	[BOOTSOURCE_NAND] = "nand",
+	[BOOTSOURCE_NOR] = "nor",
+	[BOOTSOURCE_MMC] = "mmc",
+	[BOOTSOURCE_I2C] = "i2c",
+	[BOOTSOURCE_SPI] = "spi",
+	[BOOTSOURCE_SERIAL] = "serial",
+	[BOOTSOURCE_ONENAND] = "onenand",
+	[BOOTSOURCE_HD] = "harddisk",
+};
+
+static enum bootsource bootsource = BOOTSOURCE_UNKNOWN;
+
+void bootsource_set(enum bootsource src)
+{
+	if (src >= ARRAY_SIZE(bootsource_str))
+		src = BOOTSOURCE_UNKNOWN;
+
+	bootsource = src;
+
+	setenv("barebox_loc", bootsource_str[src]);
+	export("barebox_loc");
+}
+
+enum bootsource bootsource_get(void)
+{
+	return bootsource;
+}
+
+BAREBOX_MAGICVAR(barebox_loc, "The source barebox has been booted from");
diff --git a/include/bootsource.h b/include/bootsource.h
new file mode 100644
index 0000000..ecd5938
--- /dev/null
+++ b/include/bootsource.h
@@ -0,0 +1,19 @@
+#ifndef __BOOTSOURCE_H__
+#define __BOOTSOURCE_H__
+
+enum bootsource {
+	BOOTSOURCE_UNKNOWN,
+	BOOTSOURCE_NAND,
+	BOOTSOURCE_NOR,
+	BOOTSOURCE_MMC,
+	BOOTSOURCE_I2C,
+	BOOTSOURCE_SPI,
+	BOOTSOURCE_SERIAL,
+	BOOTSOURCE_ONENAND,
+	BOOTSOURCE_HD,
+};
+
+enum bootsource bootsource_get(void);
+void bootsource_set(enum bootsource src);
+
+#endif	/* __BOOTSOURCE_H__ */
-- 
1.8.2.rc2


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

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

* [PATCH 07/10] bootsource: use initcall to export bootsource location to environment
  2013-03-14 17:38 [PATCH 00/10] make bootsource an arch independent framework Marc Kleine-Budde
                   ` (5 preceding siblings ...)
  2013-03-14 17:38 ` [PATCH 06/10] bootsource: create arch independent bootsource framework Marc Kleine-Budde
@ 2013-03-14 17:38 ` Marc Kleine-Budde
  2013-03-14 17:38 ` [PATCH 08/10] bootsource: add support for bootsource instance information Marc Kleine-Budde
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2013-03-14 17:38 UTC (permalink / raw)
  To: barebox

This way the bootsource is exported to the environment, even if unknown.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 common/bootsource.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/common/bootsource.c b/common/bootsource.c
index 2aa0ffa..ebe4407 100644
--- a/common/bootsource.c
+++ b/common/bootsource.c
@@ -19,6 +19,7 @@
 #include <bootsource.h>
 #include <environment.h>
 #include <magicvar.h>
+#include <init.h>
 
 static const char *bootsource_str[] = {
 	[BOOTSOURCE_UNKNOWN] = "unknown",
@@ -42,7 +43,6 @@ void bootsource_set(enum bootsource src)
 	bootsource = src;
 
 	setenv("barebox_loc", bootsource_str[src]);
-	export("barebox_loc");
 }
 
 enum bootsource bootsource_get(void)
@@ -51,3 +51,12 @@ enum bootsource bootsource_get(void)
 }
 
 BAREBOX_MAGICVAR(barebox_loc, "The source barebox has been booted from");
+
+static int bootsource_init(void)
+{
+	bootsource_set(bootsource);
+	export("barebox_loc");
+
+	return 0;
+}
+coredevice_initcall(bootsource_init);
-- 
1.8.2.rc2


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

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

* [PATCH 08/10] bootsource: add support for bootsource instance information
  2013-03-14 17:38 [PATCH 00/10] make bootsource an arch independent framework Marc Kleine-Budde
                   ` (6 preceding siblings ...)
  2013-03-14 17:38 ` [PATCH 07/10] bootsource: use initcall to export bootsource location to environment Marc Kleine-Budde
@ 2013-03-14 17:38 ` Marc Kleine-Budde
  2013-03-14 17:38 ` [PATCH 09/10] bootsource: add definition for usb and eeprom Marc Kleine-Budde
  2013-03-14 17:38 ` [PATCH 10/10] ARM: mxs: add bootsource detection Marc Kleine-Budde
  9 siblings, 0 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2013-03-14 17:38 UTC (permalink / raw)
  To: barebox

Add a C interface to set and get the bootsource instance:

    int bootsource_get_instance(void);
    void bootsource_set_instance(int instance);

Also export the shell variable "barebox_loc_instance".

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 common/bootsource.c  | 20 ++++++++++++++++++++
 include/bootsource.h |  2 ++
 2 files changed, 22 insertions(+)

diff --git a/common/bootsource.c b/common/bootsource.c
index ebe4407..fae554d 100644
--- a/common/bootsource.c
+++ b/common/bootsource.c
@@ -34,6 +34,7 @@ static const char *bootsource_str[] = {
 };
 
 static enum bootsource bootsource = BOOTSOURCE_UNKNOWN;
+static int bootsource_instance = 0;
 
 void bootsource_set(enum bootsource src)
 {
@@ -45,6 +46,16 @@ void bootsource_set(enum bootsource src)
 	setenv("barebox_loc", bootsource_str[src]);
 }
 
+void bootsource_set_instance(int instance)
+{
+	char buf[32];
+
+	bootsource_instance = instance;
+	snprintf(buf, sizeof(buf), "%d", instance);
+
+	setenv("barebox_loc_instance", buf);
+}
+
 enum bootsource bootsource_get(void)
 {
 	return bootsource;
@@ -52,10 +63,19 @@ enum bootsource bootsource_get(void)
 
 BAREBOX_MAGICVAR(barebox_loc, "The source barebox has been booted from");
 
+int bootsource_get_instance(void)
+{
+	return bootsource_instance;
+}
+
+BAREBOX_MAGICVAR(barebox_loc_instance, "The instance of the source barebox has been booted from");
+
 static int bootsource_init(void)
 {
 	bootsource_set(bootsource);
+	bootsource_set_instance(bootsource_instance);
 	export("barebox_loc");
+	export("barebox_loc_instance");
 
 	return 0;
 }
diff --git a/include/bootsource.h b/include/bootsource.h
index ecd5938..dfcad49 100644
--- a/include/bootsource.h
+++ b/include/bootsource.h
@@ -14,6 +14,8 @@ enum bootsource {
 };
 
 enum bootsource bootsource_get(void);
+int bootsource_get_instance(void);
 void bootsource_set(enum bootsource src);
+void bootsource_set_instance(int instance);
 
 #endif	/* __BOOTSOURCE_H__ */
-- 
1.8.2.rc2


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

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

* [PATCH 09/10] bootsource: add definition for usb and eeprom
  2013-03-14 17:38 [PATCH 00/10] make bootsource an arch independent framework Marc Kleine-Budde
                   ` (7 preceding siblings ...)
  2013-03-14 17:38 ` [PATCH 08/10] bootsource: add support for bootsource instance information Marc Kleine-Budde
@ 2013-03-14 17:38 ` Marc Kleine-Budde
  2013-03-14 17:38 ` [PATCH 10/10] ARM: mxs: add bootsource detection Marc Kleine-Budde
  9 siblings, 0 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2013-03-14 17:38 UTC (permalink / raw)
  To: barebox

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 common/bootsource.c  | 2 ++
 include/bootsource.h | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/common/bootsource.c b/common/bootsource.c
index fae554d..599bcd2 100644
--- a/common/bootsource.c
+++ b/common/bootsource.c
@@ -31,6 +31,8 @@ static const char *bootsource_str[] = {
 	[BOOTSOURCE_SERIAL] = "serial",
 	[BOOTSOURCE_ONENAND] = "onenand",
 	[BOOTSOURCE_HD] = "harddisk",
+	[BOOTSOURCE_USB] = "usb",
+	[BOOTSOURCE_EEPROM] = "eeprom",
 };
 
 static enum bootsource bootsource = BOOTSOURCE_UNKNOWN;
diff --git a/include/bootsource.h b/include/bootsource.h
index dfcad49..84a6696 100644
--- a/include/bootsource.h
+++ b/include/bootsource.h
@@ -11,6 +11,8 @@ enum bootsource {
 	BOOTSOURCE_SERIAL,
 	BOOTSOURCE_ONENAND,
 	BOOTSOURCE_HD,
+	BOOTSOURCE_USB,
+	BOOTSOURCE_EEPROM,
 };
 
 enum bootsource bootsource_get(void);
-- 
1.8.2.rc2


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

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

* [PATCH 10/10] ARM: mxs: add bootsource detection
  2013-03-14 17:38 [PATCH 00/10] make bootsource an arch independent framework Marc Kleine-Budde
                   ` (8 preceding siblings ...)
  2013-03-14 17:38 ` [PATCH 09/10] bootsource: add definition for usb and eeprom Marc Kleine-Budde
@ 2013-03-14 17:38 ` Marc Kleine-Budde
  9 siblings, 0 replies; 11+ messages in thread
From: Marc Kleine-Budde @ 2013-03-14 17:38 UTC (permalink / raw)
  To: barebox

For now only the v1.2 i.MX28 silicon is supported. The actual information is
read from a magic address within the internal SRAM.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 arch/arm/mach-mxs/imx.c                   | 99 +++++++++++++++++++++++++++++++
 arch/arm/mach-mxs/include/mach/revision.h | 24 ++++++++
 2 files changed, 123 insertions(+)
 create mode 100644 arch/arm/mach-mxs/include/mach/revision.h

diff --git a/arch/arm/mach-mxs/imx.c b/arch/arm/mach-mxs/imx.c
index ab32f10..2ddec23 100644
--- a/arch/arm/mach-mxs/imx.c
+++ b/arch/arm/mach-mxs/imx.c
@@ -14,11 +14,15 @@
  */
 
 #include <common.h>
+#include <bootsource.h>
 #include <command.h>
 #include <complete.h>
 #include <init.h>
 #include <io.h>
+
+#include <mach/generic.h>
 #include <mach/imx-regs.h>
+#include <mach/revision.h>
 
 #define HW_RTC_PERSISTENT1     0x070
 
@@ -55,3 +59,98 @@ BAREBOX_CMD_START(dump_clocks)
 	.usage		= "show clock frequencies",
 	BAREBOX_CMD_COMPLETE(empty_complete)
 BAREBOX_CMD_END
+
+
+static int __silicon_revision = SILICON_REVISION_UNKNOWN;
+
+int silicon_revision_get(void)
+{
+	return __silicon_revision;
+}
+
+void silicon_revision_set(const char *soc, int revision)
+{
+	__silicon_revision = revision;
+
+	printf("detected %s revision %d.%d\n", soc,
+	       (revision >> 4) & 0xf, revision & 0xf);
+}
+
+#define HW_DIGCTL_CHIPID	(0x8001c310)
+#define HW_DIGCTL_CHIPID_MASK	(0xffff << 16)
+#define HW_DIGCTL_CHIPID_MX23	(0x3780 << 16)
+#define HW_DIGCTL_CHIPID_MX28	(0x2800 << 16)
+
+static void mxs_silicon_revision(void)
+{
+	enum silicon_revision revision = SILICON_REVISION_UNKNOWN;
+	const char *product = "unknown";
+	uint32_t reg;
+	uint8_t rev;
+
+	reg = readl((void __iomem *)HW_DIGCTL_CHIPID);
+	rev = reg & 0xff;
+
+	switch (reg & HW_DIGCTL_CHIPID_MASK) {
+	case HW_DIGCTL_CHIPID_MX23:
+		product = "i.MX23";
+		switch (rev) {
+		case 0x0: revision = SILICON_REVISION_1_0; break;
+		case 0x1: revision = SILICON_REVISION_1_1; break;
+		case 0x2: revision = SILICON_REVISION_1_2; break;
+		case 0x3: revision = SILICON_REVISION_1_3; break;
+		case 0x4: revision = SILICON_REVISION_1_4; break;
+		}
+	case HW_DIGCTL_CHIPID_MX28:
+		product = "i.MX28";
+		switch (rev) {
+		case 0x1: revision = SILICON_REVISION_1_2; break;
+		}
+	}
+
+	silicon_revision_set(product, revision);
+}
+
+#define MX28_REV_1_0_MODE	(0x0001a7f0)
+#define MX28_REV_1_2_MODE	(0x00019bf0)
+
+static void mxs_boot_save_loc(void)
+{
+	enum bootsource src = BOOTSOURCE_UNKNOWN;
+	int instance = 0;
+	uint32_t mode = 0xff;
+
+	if (cpu_is_mx23()) {
+		/* not implemented yet */
+	} else if (cpu_is_mx28()) {
+		enum silicon_revision rev = silicon_revision_get();
+
+		if (rev == SILICON_REVISION_1_2)
+			mode = *(uint32_t *)MX28_REV_1_2_MODE;
+		else
+			mode = *(uint32_t *)MX28_REV_1_0_MODE;
+	}
+
+	switch (mode & 0xf) {
+	case 0x0: src = BOOTSOURCE_USB; break;		/* "USB" */
+	case 0x1: src = BOOTSOURCE_I2C; break;		/* "I2C, master" */
+	case 0x3: instance = 1;	/* fallthrough */	/* "SSP SPI #2, master, NOR" */
+	case 0x2: src = BOOTSOURCE_NOR; break;		/* "SSP SPI #1, master, NOR" */
+	case 0x4: src = BOOTSOURCE_NAND; break;		/* "NAND" */
+	case 0x8: src = BOOTSOURCE_EEPROM; break;	/* "SSP SPI #3, master, EEPROM" */
+	case 0xa: instance = 1;	/* fallthrough */	/* "SSP SD/MMC #1" */
+	case 0x9: src = BOOTSOURCE_MMC; break;		/* "SSP SD/MMC #0" */
+	}
+
+	bootsource_set(src);
+	bootsource_set_instance(instance);
+}
+
+static int mxs_init(void)
+{
+	mxs_silicon_revision();
+	mxs_boot_save_loc();
+
+	return 0;
+}
+postcore_initcall(mxs_init);
diff --git a/arch/arm/mach-mxs/include/mach/revision.h b/arch/arm/mach-mxs/include/mach/revision.h
new file mode 100644
index 0000000..91f174d
--- /dev/null
+++ b/arch/arm/mach-mxs/include/mach/revision.h
@@ -0,0 +1,24 @@
+#ifndef __MACH_REVISION_H__
+#define __MACH_REVISION_H__
+
+/* silicon revisions  */
+enum silicon_revision {
+	SILICON_REVISION_1_0 = 0x10,
+	SILICON_REVISION_1_1 = 0x11,
+	SILICON_REVISION_1_2 = 0x12,
+	SILICON_REVISION_1_3 = 0x13,
+	SILICON_REVISION_1_4 = 0x14,
+	SILICON_REVISION_2_0 = 0x20,
+	SILICON_REVISION_2_1 = 0x21,
+	SILICON_REVISION_2_2 = 0x22,
+	SILICON_REVISION_2_3 = 0x23,
+	SILICON_REVISION_3_0 = 0x30,
+	SILICON_REVISION_3_1 = 0x31,
+	SILICON_REVISION_3_2 = 0x32,
+	SILICON_REVISION_UNKNOWN =0xff
+};
+
+int silicon_revision_get(void);
+void silicon_revision_set(const char *soc, int revision);
+
+#endif /* __MACH_REVISION_H__ */
-- 
1.8.2.rc2


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

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

end of thread, other threads:[~2013-03-14 17:39 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-14 17:38 [PATCH 00/10] make bootsource an arch independent framework Marc Kleine-Budde
2013-03-14 17:38 ` [PATCH 01/10] ARM i.MX bootsource: convert enums from enum imx_bootsource to uppercase Marc Kleine-Budde
2013-03-14 17:38 ` [PATCH 02/10] ARM i.MX bootsource: convert all imx*_boot_save_loc functions to void Marc Kleine-Budde
2013-03-14 17:38 ` [PATCH 03/10] ARM i.MX bootsource: imx_25_35_boot_save_loc: remove leftover do-nothing code Marc Kleine-Budde
2013-03-14 17:38 ` [PATCH 04/10] ARM i.MX bootsource: rename imx_27_boot_save_loc -> imx27_boot_save_loc Marc Kleine-Budde
2013-03-14 17:38 ` [PATCH 05/10] ARM i.MX bootsource: add separate function for mx25 and mx35 Marc Kleine-Budde
2013-03-14 17:38 ` [PATCH 06/10] bootsource: create arch independent bootsource framework Marc Kleine-Budde
2013-03-14 17:38 ` [PATCH 07/10] bootsource: use initcall to export bootsource location to environment Marc Kleine-Budde
2013-03-14 17:38 ` [PATCH 08/10] bootsource: add support for bootsource instance information Marc Kleine-Budde
2013-03-14 17:38 ` [PATCH 09/10] bootsource: add definition for usb and eeprom Marc Kleine-Budde
2013-03-14 17:38 ` [PATCH 10/10] ARM: mxs: add bootsource detection Marc Kleine-Budde

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