Skip to contentSkip to conversation

ARM: OMAP: Beagle: revision detection

PATCH Superseded Robert Nelson 3 participants 7 messages Aug 11, 2010 – Aug 12, 2010

Subsystems (3)

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/3 ARM: OMAP: Beagle: revision detection

Due to the omap3530 ES3.0 Silicon being used on both the B5/B6 and C1/2/3 Beagle we can't use the cpu_is_omap34xx() routines to differentiate the Beagle Boards.

However gpio pins 171,172,173 where setup for this prupose, so lets use them.

Tested on Beagle Revisions: B5, C2, C4, and xMA

---
 arch/arm/mach-omap2/board-omap3beagle.c |   60 +++++++++++++++++++++++++++++++
 arch/arm/plat-omap/include/plat/board.h |   23 ++++++++++++
 2 files changed, 83 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/board-omap3beagle.c +60 -0
index 87969c7..e470336 100644
@@ -50,6 +50,65 @@
 
 #define NAND_BLOCK_SIZE		SZ_128K
 
+static u8 omap3_beagle_version;
+
+u8 get_omap3_beagle_rev(void)
+{
+	return omap3_beagle_version;
+}
+EXPORT_SYMBOL(get_omap3_beagle_rev);
+
+static void __init omap3_beagle_get_revision(void)
+{
+	int ret;
+	u16 beagle_rev = 0;
+
+	ret = gpio_request(171, "rev_id_0");
+	if (ret < 0)
+		goto fail;
+
+	ret = gpio_request(172, "rev_id_1");
+	if (ret < 0)
+		goto fail;
+
+	ret = gpio_request(173, "rev_id_2");
+	if (ret < 0)
+		goto fail;
+
+	gpio_direction_input(171);
+	gpio_direction_input(172);
+	gpio_direction_input(173);
+
+	beagle_rev = gpio_get_value(171) | (gpio_get_value(172) << 1)
+			| (gpio_get_value(173) << 2);
+
+	switch (beagle_rev) {
+	case 7:
+		printk(KERN_INFO "OMAP3 Beagle Rev: Ax/Bx\n");
+		omap3_beagle_version = OMAP3BEAGLE_BOARD_AXBX;
+		break;
+	case 6:
+		printk(KERN_INFO "OMAP3 Beagle Rev: C1/C2/C3\n");
+		omap3_beagle_version = OMAP3BEAGLE_BOARD_C1_3;
+		break;
+	case 5:
+		printk(KERN_INFO "OMAP3 Beagle Rev: C4\n");
+		omap3_beagle_version = OMAP3BEAGLE_BOARD_C4;
+		break;
+	case 0:
+		printk(KERN_INFO "OMAP3 Beagle Rev: xM\n");
+		omap3_beagle_version = OMAP3BEAGLE_BOARD_XM;
+		break;
+	default:
+		printk(KERN_INFO "OMAP3 Beagle Rev: unknown %hd\n", beagle_rev);
+		omap3_beagle_version = OMAP3BEAGLE_BOARD_XM;
+	}
+
+	return;
+fail:
+	printk(KERN_ERR "Unable to get revision detection GPIO pins\n");
+}
+
 static struct mtd_partition omap3beagle_nand_partitions[] = {
 	/* All the partition sizes are listed in terms of NAND block size */
 	{
@@ -464,6 +523,7 @@ static struct omap_musb_board_data musb_board_data = {
 static void __init omap3_beagle_init(void)
 {
 	omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
+	omap3_beagle_get_revision();
 	omap3_beagle_i2c_init();
 	platform_add_devices(omap3_beagle_devices,
 			ARRAY_SIZE(omap3_beagle_devices));
arch/arm/plat-omap/include/plat/board.h +23 -0
index 3cf4fa2..e55a920 100644
@@ -26,6 +26,22 @@ enum {
 	OMAP3EVM_BOARD_GEN_2,		/* EVM Rev >= Rev E */
 };
 
+/*
+ * OMAP3 Beagle revision
+ * Run time detection of Beagle revision is done by reading GPIO.
+ * GPIO ID -
+ *	AXBX	= GPIO173, GPIO172, GPIO171: 1 1 1
+ *	C1_3	= GPIO173, GPIO172, GPIO171: 1 1 0
+ *	C4	= GPIO173, GPIO172, GPIO171: 1 0 1
+ *	XM	= GPIO173, GPIO172, GPIO171: 0 0 0
+ */
+enum {
+	OMAP3BEAGLE_BOARD_AXBX = 0,
+	OMAP3BEAGLE_BOARD_C1_3,
+	OMAP3BEAGLE_BOARD_C4,
+	OMAP3BEAGLE_BOARD_XM,
+};
+
 /* Different peripheral ids */
 #define OMAP_TAG_CLOCK		0x4f01
 #define OMAP_TAG_LCD		0x4f05
@@ -173,4 +189,11 @@ u8 get_omap3_evm_rev(void);
 #else
 #define get_omap3_evm_rev() (-EINVAL)
 #endif
+
+/* Beagle revision */
+#if defined(CONFIG_MACH_OMAP3_BEAGLE)
+u8 get_omap3_beagle_rev(void);
+#else
+#define get_omap3_beagle_rev() (-EINVAL)
+#endif
 #endif
Signature · 1 line
1.7.0.4
#1 lore raw

PATCH v2 2/3 ARM: OMAP: Beagle: only Cx boards use pin 23 for write protect

system_rev comes from u-boot and is a constant 0x20, so Bx boards also fall in this 'if' and will get setup with the wrong gpio_wp pin. Switch to using the Beagle revision routine to correcly set pin 23 only for C1/2/3 and C4 Boards. Bx boards will then use the correct default pin setting.

---
 arch/arm/mach-omap2/board-omap3beagle.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
arch/arm/mach-omap2/board-omap3beagle.c +2 -1
index e470336..08fa68f 100644
@@ -244,7 +244,8 @@ static struct gpio_led gpio_leds[];
 static int beagle_twl_gpio_setup(struct device *dev,
 		unsigned gpio, unsigned ngpio)
 {
-	if (system_rev >= 0x20 && system_rev <= 0x34301000) {
+	if ((get_omap3_beagle_rev() == OMAP3BEAGLE_BOARD_C1_3) ||
+		(get_omap3_beagle_rev() == OMAP3BEAGLE_BOARD_C4)) {
 		omap_mux_init_gpio(23, OMAP_PIN_INPUT);
 		mmc[0].gpio_wp = 23;
 	} else {
Signature · 1 line
1.7.0.4
#2 lore raw

PATCH v2 3/3 ARM: OMAP: Beagle: no gpio_wp pin connection on xM

In reply to Robert Nelson

The omap3630 based BeagleBoard xM uses a MicroSD card slot with no write protection.

---
 arch/arm/mach-omap2/board-omap3beagle.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
arch/arm/mach-omap2/board-omap3beagle.c +3 -1
index 08fa68f..449a776 100644
@@ -244,7 +244,9 @@ static struct gpio_led gpio_leds[];
 static int beagle_twl_gpio_setup(struct device *dev,
 		unsigned gpio, unsigned ngpio)
 {
-	if ((get_omap3_beagle_rev() == OMAP3BEAGLE_BOARD_C1_3) ||
+	if (get_omap3_beagle_rev() == OMAP3BEAGLE_BOARD_XM) {
+		mmc[0].gpio_wp = -EINVAL;
+	} else if ((get_omap3_beagle_rev() == OMAP3BEAGLE_BOARD_C1_3) ||
 		(get_omap3_beagle_rev() == OMAP3BEAGLE_BOARD_C4)) {
 		omap_mux_init_gpio(23, OMAP_PIN_INPUT);
 		mmc[0].gpio_wp = 23;
Signature · 1 line
1.7.0.4
#3 lore raw
In reply to Robert Nelson

Hi

Quoted 15 lines · On Wed, 11 Aug 2010 18:37:40 -0500 Robert Nelson <[email protected]>…

Due to the omap3530 ES3.0 Silicon being used on both the B5/B6 and C1/2/3 Beagle we can't use the cpu_is_omap34xx() routines to differentiate the Beagle Boards.

However gpio pins 171,172,173 where setup for this prupose, so lets use them.

Tested on Beagle Revisions: B5, C2, C4, and xMA

---
 arch/arm/mach-omap2/board-omap3beagle.c |   60 +++++++++++++++++++++++++++++++
 arch/arm/plat-omap/include/plat/board.h |   23 ++++++++++++
 2 files changed, 83 insertions(+), 0 deletions(-)

...

Quoted 14 lines
arch/arm/mach-omap2/board-omap3beagle.c +14 -0
+	beagle_rev = gpio_get_value(171) | (gpio_get_value(172) << 1)
+			| (gpio_get_value(173) << 2);
+
+	switch (beagle_rev) {
+	case 7:
+		printk(KERN_INFO "OMAP3 Beagle Rev: Ax/Bx\n");
+		omap3_beagle_version = OMAP3BEAGLE_BOARD_AXBX;
+		break;
+	case 6:
+		printk(KERN_INFO "OMAP3 Beagle Rev: C1/C2/C3\n");
+		omap3_beagle_version = OMAP3BEAGLE_BOARD_C1_3;
+		break;
+	case 5:
+		printk(KERN_INFO "OMAP3 Beagle Rev: C4\n");

arch/arm/mach-omap2/board-omap3beagle.c line 105

Quoted 10 lines
arch/arm/mach-omap2/board-omap3beagle.c +10 -0
+		omap3_beagle_version = OMAP3BEAGLE_BOARD_C4;
+		break;
+	case 0:
+		printk(KERN_INFO "OMAP3 Beagle Rev: xM\n");
+		omap3_beagle_version = OMAP3BEAGLE_BOARD_XM;
+		break;
+	default:
+		printk(KERN_INFO "OMAP3 Beagle Rev: unknown %hd\n", beagle_rev);
+		omap3_beagle_version = OMAP3BEAGLE_BOARD_XM;
+	}

My C2 reads as 2 and I have U-Boot 2009.01-dirty (Feb 19 2009 - 12:22:31). I believe these pins are not muxed correctly with that U-Boot version.

Therefore kernel should remux those pins so that version is detected right independently of bootloader version. Detections works fine if I add these:

	omap_mux_init_gpio(171, OMAP_PIN_INPUT_PULLUP);
	omap_mux_init_gpio(172, OMAP_PIN_INPUT_PULLUP);
	omap_mux_init_gpio(173, OMAP_PIN_INPUT_PULLUP);
Signature · 1 line
Jarkko
#4 lore raw
Quoted 46 lines · Jarkko Nikula

Hi

Quoted 15 lines · On Wed, 11 Aug 2010 18:37:40 -0500 Robert Nelson <[email protected]>…

Due to the omap3530 ES3.0 Silicon being used on both the B5/B6 and C1/2/3 Beagle we can't use the cpu_is_omap34xx() routines to differentiate the Beagle Boards.

However gpio pins 171,172,173 where setup for this prupose, so lets use them.

Tested on Beagle Revisions: B5, C2, C4, and xMA

---
 arch/arm/mach-omap2/board-omap3beagle.c |   60 +++++++++++++++++++++++++++++++ arch/arm/plat-omap/include/plat/board.h |   23 ++++++++++++

 2 files changed, 83 insertions(+), 0 deletions(-)

...

Quoted 16 lines

+     beagle_rev = gpio_get_value(171) | (gpio_get_value(172) << 1)
+                     | (gpio_get_value(173) << 2);
+
+     switch (beagle_rev) {
+     case 7:
+             printk(KERN_INFO "OMAP3 Beagle Rev: Ax/Bx\n");
+             omap3_beagle_version = OMAP3BEAGLE_BOARD_AXBX;
+             break;
+     case 6:
+             printk(KERN_INFO "OMAP3 Beagle Rev: C1/C2/C3\n");
+             omap3_beagle_version = OMAP3BEAGLE_BOARD_C1_3;
+             break;
+     case 5:
+             printk(KERN_INFO "OMAP3 Beagle Rev: C4\n");
+             omap3_beagle_version = OMAP3BEAGLE_BOARD_C4;
+             break;

Quoted 8 lines

+     case 0:
+             printk(KERN_INFO "OMAP3 Beagle Rev: xM\n");
+             omap3_beagle_version = OMAP3BEAGLE_BOARD_XM;
+             break;
+     default:
+             printk(KERN_INFO "OMAP3 Beagle Rev: unknown %hd\n", beagle_rev);
+             omap3_beagle_version = OMAP3BEAGLE_BOARD_XM;
+     }

Quoted 3 lines

My C2 reads as 2 and I have U-Boot 2009.01-dirty (Feb 19 2009 - 12:22:31). I believe these pins are not muxed correctly with that U-Boot version.

Thanks for testing Jarkko, i had been using U-Boot 2010.03.. So it looked like we could use the more generic gpio routines, but i'll swap to the omap_mux_init_gpio and retest on my systems..

Quoted 13 lines

Therefore kernel should remux those pins so that version is detected right independently of bootloader version. Detections works fine if I add these:

       omap_mux_init_gpio(171, OMAP_PIN_INPUT_PULLUP); omap_mux_init_gpio(172, OMAP_PIN_INPUT_PULLUP); omap_mux_init_gpio(173, OMAP_PIN_INPUT_PULLUP);

--
Jarkko

Signature · 6 lines
Robert Nelson
http://www.rcn-ee.com/
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
maintainer
#5 lore raw
In reply to Robert Nelson
Quoted 6 lines · Robert Nelson

Due to the omap3530 ES3.0 Silicon being used on both the B5/B6 and C1/2/3 Beagle we can't use the cpu_is_omap34xx() routines to differentiate the Beagle Boards.

However gpio pins 171,172,173 where setup for this prupose, so lets use them.

<snip>

Quoted 27 lines
arch/arm/plat-omap/include/plat/board.h +16 -0
@@ -26,6 +26,22 @@ enum {
 	OMAP3EVM_BOARD_GEN_2,		/* EVM Rev >= Rev E */
 };
 
+/*
+ * OMAP3 Beagle revision
+ * Run time detection of Beagle revision is done by reading GPIO.
+ * GPIO ID -
+ *	AXBX	= GPIO173, GPIO172, GPIO171: 1 1 1
+ *	C1_3	= GPIO173, GPIO172, GPIO171: 1 1 0
+ *	C4	= GPIO173, GPIO172, GPIO171: 1 0 1
+ *	XM	= GPIO173, GPIO172, GPIO171: 0 0 0
+ */
+enum {
+	OMAP3BEAGLE_BOARD_AXBX = 0,
+	OMAP3BEAGLE_BOARD_C1_3,
+	OMAP3BEAGLE_BOARD_C4,
+	OMAP3BEAGLE_BOARD_XM,
+};
+
 /* Different peripheral ids */
 #define OMAP_TAG_CLOCK		0x4f01
 #define OMAP_TAG_LCD		0x4f05
@@ -173,4 +189,11 @@ u8 get_omap3_evm_rev(void);
 #else

arch/arm/plat-omap/include/plat/board.h u8 get_omap3_evm_rev(void); · line 199

Quoted 10 lines
arch/arm/plat-omap/include/plat/board.h +7 -0
 #define get_omap3_evm_rev() (-EINVAL)
 #endif
+
+/* Beagle revision */
+#if defined(CONFIG_MACH_OMAP3_BEAGLE)
+u8 get_omap3_beagle_rev(void);
+#else
+#define get_omap3_beagle_rev() (-EINVAL)
+#endif
 #endif

You should be able to keep this all in board-omap3beagle.c, no need for the header. If this header is needed somewhere else, chances are that something is wrong.

For the drivers, you should be able to pass the necessary flags via platform_data if needed.

Regards,

Tony

#6 lore raw
Quoted 39 lines · Tony Lindgren
Quoted 6 lines · Robert Nelson

Due to the omap3530 ES3.0 Silicon being used on both the B5/B6 and C1/2/3 Beagle we can't use the cpu_is_omap34xx() routines to differentiate the Beagle Boards.

However gpio pins 171,172,173 where setup for this prupose, so lets use them.

<snip>

Quoted 29 lines
arch/arm/plat-omap/include/plat/board.h +0 -0
@@ -26,6 +26,22 @@ enum {

      OMAP3EVM_BOARD_GEN_2,           /* EVM Rev >= Rev E */ };

arch/arm/plat-omap/include/plat/board.h +16 -0
+/*
+ * OMAP3 Beagle revision
+ * Run time detection of Beagle revision is done by reading GPIO.
+ * GPIO ID -
+ *   AXBX    = GPIO173, GPIO172, GPIO171: 1 1 1
+ *   C1_3    = GPIO173, GPIO172, GPIO171: 1 1 0
+ *   C4      = GPIO173, GPIO172, GPIO171: 1 0 1
+ *   XM      = GPIO173, GPIO172, GPIO171: 0 0 0
+ */
+enum {
+     OMAP3BEAGLE_BOARD_AXBX = 0,
+     OMAP3BEAGLE_BOARD_C1_3,
+     OMAP3BEAGLE_BOARD_C4,
+     OMAP3BEAGLE_BOARD_XM,
+};
+

 /* Different peripheral ids */
 #define OMAP_TAG_CLOCK               0x4f01
 #define OMAP_TAG_LCD         0x4f05

arch/arm/plat-omap/include/plat/board.h +0 -0
@@ -173,4 +189,11 @@ u8 get_omap3_evm_rev(void);
  #else
  #define get_omap3_evm_rev() (-EINVAL)
  #endif
Quoted 9 lines

arch/arm/plat-omap/include/plat/board.h u8 get_omap3_evm_rev(void); · line 199

Quoted 8 lines
arch/arm/plat-omap/include/plat/board.h +7 -0
+
+/* Beagle revision */
+#if defined(CONFIG_MACH_OMAP3_BEAGLE)
+u8 get_omap3_beagle_rev(void);
+#else
+#define get_omap3_beagle_rev() (-EINVAL)
+#endif
  #endif

(Crap re cc-ing group)

Thanks Tony

Quoted 4 lines

You should be able to keep this all in board-omap3beagle.c, no need for the header. If this header is needed somewhere else, chances are that something is wrong.

Yeah, I can do that instead, i don't see it really leaving board-omap3beagle.c..

I was using the existing "get_omap3_evm_rev" routines as an inspiration and reference..

Regards,

Signature · 6 lines
Robert Nelson
http://www.rcn-ee.com/
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html