Subject: [RFC][PATCH U-Boot v1] OMAP3: Add Beagle board revision detection From: Dirk Behme With BeagleBoard revision >= C2 some HW changes are introduced (e.g. PinMUX) which need different software handling. For this, GPIO pins 171 and 172 (GPIO module 6, offset 11 and 12) can be used to check for board revision. If both these pins are low, we have a board >= C2. Else it must be a revision Ax or Bx board. Global variable beagle_revision can be used later to handle board differences. E.g. if (beagle_revision == REVISION_C) { /* do special revision C stuff here */ } See http://groups.google.com/group/beagleboard/msg/ceb2751f9dde458f for more details. Signed-off-by: Dirk Behme --- * This patch is against recent Steve's U-Boot v1 git http://www.sakoman.net/cgi-bin/gitweb.cgi?p=u-boot-omap3.git;a=shortlog;h=refs/heads/omap3-dev * This patch is RFC only. For final patch, printf marked with Debug has to be removed. * I have no C2, so I can't test. Anybody with a board, please test and send resulting ouput. board/omap3/beagle/beagle.c | 33 +++++++++++++++++++++++++++++++++ board/omap3/beagle/beagle.h | 15 +++++++++++++-- include/asm-arm/arch-omap3/omap3.h | 3 ++- 3 files changed, 48 insertions(+), 3 deletions(-) Index: u-boot-steve-omap3/board/omap3/beagle/beagle.c =================================================================== --- u-boot-steve-omap3.orig/board/omap3/beagle/beagle.c +++ u-boot-steve-omap3/board/omap3/beagle/beagle.c @@ -54,6 +54,37 @@ 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 and GPIO_172. If these + * both GPIOs are low, we are running at a revision C2 board + * or newer. + *****************************************************************************/ +void board_identify(void) +{ + gpio_t *gpio6_base = (gpio_t *)OMAP34XX_GPIO6_BASE; + unsigned int revision; + + /* Configure GPIO 171 and 172 as input */ + writel(readl(&gpio6_base->oe) | GPIO12 | GPIO11, &gpio6_base->oe); + + /* Get value of GPIO 171 and 172 */ + revision = (readl(&gpio6_base->datain) >> 11) & BOARD_REVISION_MASK; + + printf("Board revision: "); + if(revision == 0) { + printf(">= C2\n"); + beagle_revision = REVISION_C; + } else { + printf("Ax/Bx\n"); + beagle_revision = REVISION_A_B; + } + + /* Remove: Debug only */ + printf("Debug (GPIO6 datain): 0x%08x\n", readl(&gpio6_base->datain)); +} + +/****************************************************************************** * Routine: misc_init_r * Description: Configure board specific parts *****************************************************************************/ @@ -74,6 +105,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-steve-omap3/board/omap3/beagle/beagle.h =================================================================== --- u-boot-steve-omap3.orig/board/omap3/beagle/beagle.h +++ u-boot-steve-omap3/board/omap3/beagle/beagle.h @@ -36,6 +36,17 @@ const omap3_sysinfo sysinfo = { #endif }; +#define BOARD_REVISION_MASK 0x3 + +enum beagle_rev { + REVISION_A_B = 0, + REVISION_C, + UNUSED1, + UNUSED2, +}; + +unsigned int beagle_revision; + /* * IEN - Input Enable * IDIS - Input Disable @@ -267,8 +278,8 @@ const omap3_sysinfo sysinfo = { MUX_VAL(CP(I2C4_SCL), (IEN | PTU | EN | M0)) /*I2C4_SCL*/\ MUX_VAL(CP(I2C4_SDA), (IEN | PTU | EN | M0)) /*I2C4_SDA*/\ MUX_VAL(CP(HDQ_SIO), (IDIS | PTU | EN | M4)) /*HDQ_SIO*/\ - MUX_VAL(CP(MCSPI1_CLK), (IEN | PTD | DIS | M0)) /*McSPI1_CLK*/\ - MUX_VAL(CP(MCSPI1_SIMO), (IEN | PTD | DIS | M0)) /*McSPI1_SIMO*/\ + MUX_VAL(CP(MCSPI1_CLK), (IEN | PTU | EN | M4)) /*GPIO_171*/\ + MUX_VAL(CP(MCSPI1_SIMO), (IEN | PTU | EN | M4)) /*GPIO_172*/\ MUX_VAL(CP(MCSPI1_SOMI), (IEN | PTD | DIS | M0)) /*McSPI1_SOMI*/\ MUX_VAL(CP(MCSPI1_CS0), (IEN | PTD | EN | M0)) /*McSPI1_CS0*/\ MUX_VAL(CP(MCSPI1_CS1), (IDIS | PTD | EN | M0)) /*McSPI1_CS1*/\ Index: u-boot-steve-omap3/include/asm-arm/arch-omap3/omap3.h =================================================================== --- u-boot-steve-omap3.orig/include/asm-arm/arch-omap3/omap3.h +++ u-boot-steve-omap3/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;