[U-Boot] [PATCH 2/7] OMAP3: Beagle: Add board revision detection

Dirk Behme dirk.behme at googlemail.com
Mon Feb 2 06:53:26 CET 2009


With BeagleBoard revision C some HW changes are introduced (e.g. PinMUX)
which might need different software handling. For this, GPIO pin 171 (GPIO
module 6, offset 11) can be used to check for board revision. If this pin
is low, we have a rev C board. Else it must be a revision Ax or Bx board.

Global variable beagle_revision_c can be used later to handle board
differences. E.g.

if (beagle_revision_c) {

 /* do special revision C stuff here */

}

Signed-off-by: Dirk Behme <dirk.behme at googlemail.com>

---
 board/omap3/beagle/beagle.c        |   28 ++++++++++++++++++++++++++++
 board/omap3/beagle/beagle.h        |    4 ++++
 include/asm-arm/arch-omap3/omap3.h |    3 ++-
 3 files changed, 34 insertions(+), 1 deletion(-)

Index: u-boot-main/board/omap3/beagle/beagle.c
===================================================================
--- u-boot-main.orig/board/omap3/beagle/beagle.c
+++ u-boot-main/board/omap3/beagle/beagle.c
@@ -54,6 +54,32 @@ int board_init(void)
 }
 
 /******************************************************************************
+ * Routine: board_identify
+ * Description: Detect if we are running on a Beagle revision Ax/Bx or
+ *              Cx. This can be done by GPIO_171. If this is low, we are
+ *              running on a revision C board.
+ *****************************************************************************/
+void board_identify(void)
+{
+	gpio_t *gpio6_base = (gpio_t *)OMAP34XX_GPIO6_BASE;
+
+	/* Configure GPIO 171 as input */
+	writel(readl(&gpio6_base->oe) | GPIO11, &gpio6_base->oe);
+
+	/* Get value of GPIO 171 */
+	beagle_revision_c = readl(&gpio6_base->datain) & BOARD_REVISION_MASK;
+
+	printf("Board revision ");
+	if (beagle_revision_c) {
+		printf("Ax/Bx\n");
+		beagle_revision_c = 0;
+	} else {
+		printf("C\n");
+		beagle_revision_c = 1;
+	}
+}
+
+/******************************************************************************
  * Routine: misc_init_r
  * Description: Configure board specific parts
  *****************************************************************************/
@@ -75,6 +101,8 @@ int misc_init_r(void)
 	writel(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
 		GPIO15 | GPIO14 | GPIO13 | GPIO12, &gpio5_base->setdataout);
 
+	board_identify();
+
 	return 0;
 }
 
Index: u-boot-main/board/omap3/beagle/beagle.h
===================================================================
--- u-boot-main.orig/board/omap3/beagle/beagle.h
+++ u-boot-main/board/omap3/beagle/beagle.h
@@ -36,6 +36,10 @@ const omap3_sysinfo sysinfo = {
 #endif
 };
 
+#define BOARD_REVISION_MASK	(0x1 << 11)
+
+unsigned int beagle_revision_c;
+
 /*
  * IEN  - Input Enable
  * IDIS - Input Disable
Index: u-boot-main/include/asm-arm/arch-omap3/omap3.h
===================================================================
--- u-boot-main.orig/include/asm-arm/arch-omap3/omap3.h
+++ u-boot-main/include/asm-arm/arch-omap3/omap3.h
@@ -97,7 +97,8 @@ typedef struct s32ktimer {
 typedef struct gpio {
 	unsigned char res1[0x34];
 	unsigned int oe;		/* 0x34 */
-	unsigned char res2[0x58];
+	unsigned int datain;		/* 0x38 */
+	unsigned char res2[0x54];
 	unsigned int cleardataout;	/* 0x90 */
 	unsigned int setdataout;	/* 0x94 */
 } gpio_t;


More information about the U-Boot mailing list