This set of changes makes u-boot detect hardware revisions >= GTA02v5 at run time instead of build time. The revision tag and the boot prompt are adjusted accordingly. Note that new code should use gta02_revision for feature tests, not CONFIG_GTA02_REVISION ! For backward-compatibility, "make gta02v6_config" is still supported (and yields exactly the same result as "make gta02v5_config". Index: u-boot/Makefile =================================================================== --- u-boot.orig/Makefile +++ u-boot/Makefile @@ -2437,7 +2437,8 @@ gta02v2_config \ gta02v3_config \ gta02v4_config \ -gta02v5_config: unconfig +gta02v5_config \ +gta02v6_config: unconfig @sh board/neo1973/gta02/split_by_variant.sh $@ gta01_config \ Index: u-boot/board/neo1973/gta02/gta02.c =================================================================== --- u-boot.orig/board/neo1973/gta02/gta02.c +++ u-boot/board/neo1973/gta02/gta02.c @@ -67,6 +67,13 @@ extern unsigned char booted_from_nand; extern unsigned char booted_from_nor; extern int nobootdelay; +char __cfg_prompt[20] = "GTA02vXX # "; + +/* + * In >GTA02v5, use gta02_revision to test for features, not + * CONFIG_GTA02_REVISION or CONFIG_ARCH_GTA02_vX ! + */ +int gta02_revision; int gta02_get_pcb_revision(void); @@ -253,6 +260,37 @@ return 0; } +static void set_revision(void) +{ + int rev = gta02_get_pcb_revision(); + char buf[32]; + + if (CONFIG_GTA02_REVISION < 5) + gta02_revision = CONFIG_GTA02_REVISION; + else { + switch (rev) { + case 0x000: + gta02_revision = 5; + break; + case 0x001: + gta02_revision = 6; + break; + default: + printf("Unrecognized hardware revision 0x%03x. " + "Defaulting to GTA02v6.\n", rev); + gta02_revision = 6; + } + } + sprintf(__cfg_prompt, "GTA02v%d # ", gta02_revision); + +#if 1 /* remove these after checking that Andy doesn't need them anymore */ + printf("PCB rev: 0x%03X\n", rev); + /* expose in the env so we can add to kernel commandline */ + sprintf(buf, "0x%03X", rev); + setenv("pcb_rev", buf); +#endif +} + int board_late_init(void) { S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO(); @@ -260,12 +298,8 @@ char buf[32]; int menu_vote = 0; /* <= 0: no, > 0: yes */ int seconds = 0; - int rev = gta02_get_pcb_revision(); - printf("PCB rev: 0x%03X\n", rev); - /* expose in the env so we can add to kernel commandline */ - sprintf(buf, "0x%03X", rev); - setenv("pcb_rev", buf); + set_revision(); /* Initialize the Power Management Unit with a safe register set */ pcf50633_init(); @@ -378,7 +412,7 @@ u_int32_t get_board_rev(void) { - return 0x300+0x10*CONFIG_GTA02_REVISION; + return 0x300+0x10*gta02_revision; } void neo1973_poweroff(void) @@ -546,7 +580,7 @@ /** * returns PCB revision information in b9,b8 and b2,b1,b0 * Pre-GTA02 A6 returns 0x000 - * GTA02 A6 returns 0x101 + * GTA02 A6 returns 0x001 */ int gta02_get_pcb_revision(void) Index: u-boot/board/neo1973/gta02/split_by_variant.sh =================================================================== --- u-boot.orig/board/neo1973/gta02/split_by_variant.sh +++ u-boot/board/neo1973/gta02/split_by_variant.sh @@ -42,19 +42,12 @@ echo "CONFIG_USB_DFU_REVISION=0x0340" > $CFGTMP ;; - gta02v5_config) + gta02v5_config|gta02v6_config) echo "#define CONFIG_ARCH_GTA02_v5" > $CFGINC echo "#define CONFIG_GTA02_REVISION 5" >> $CFGINC echo "CONFIG_USB_DFU_REVISION=0x0350" > $CFGTMP ;; - gta02v6_config) - echo "#define CONFIG_ARCH_GTA02_v6" > $CFGINC - echo "#define CONFIG_GTA02_REVISION 6" >> $CFGINC - echo "CONFIG_USB_DFU_REVISION=0x0360" > $CFGTMP - ;; - - *) echo "$0:: Unrecognised config - using GTA02v5 config" echo "#define CONFIG_ARCH_GTA02_v5" > $CFGINC @@ -65,6 +58,7 @@ esac fi +sed 's/^/#define /;s/=/ /' <$CFGTMP >>$CFGINC # --------------------------------------------------------- # Complete the configuration # --------------------------------------------------------- Index: u-boot/include/configs/neo1973_gta02.h =================================================================== --- u-boot.orig/include/configs/neo1973_gta02.h +++ u-boot/include/configs/neo1973_gta02.h @@ -127,8 +127,12 @@ #define STRINGIFY(s) DO_STRINGIFY(s) /* expand the argument */ #define DO_STRINGIFY(s) #s /* quote it */ -#define CFG_PROMPT "GTA02v" STRINGIFY(CONFIG_GTA02_REVISION) " # " +#define CFG_PROMPT __cfg_prompt /* Monitor Command Prompt */ +#ifndef __ASSEMBLY__ +extern char __cfg_prompt[20]; +#endif + #if defined(CONFIG_ARCH_GTA02_v1) #define CONFIG_S3C2440 1 /* SAMSUNG S3C2440 SoC */ #else @@ -293,4 +297,8 @@ #define DFU_NUM_ALTERNATES 7 +#ifndef __ASSEMBLY__ +extern int gta02_revision; /* use this instead of CONFIG_GTA02_REVISION */ +#endif + #endif /* __CONFIG_H */ Index: u-boot/drivers/usb/usbdfu.c =================================================================== --- u-boot.orig/drivers/usb/usbdfu.c +++ u-boot/drivers/usb/usbdfu.c @@ -101,7 +101,7 @@ trailer->product != CONFIG_USBD_PRODUCTID_GSERIAL)) return 0; #ifdef CONFIG_REVISION_TAG - if (trailer->revision != get_board_rev()) + if (trailer->revision != CONFIG_USB_DFU_REVISION) return 0; #endif Index: u-boot/board/neo1973/gta01/split_by_variant.sh =================================================================== --- u-boot.orig/board/neo1973/gta01/split_by_variant.sh +++ u-boot/board/neo1973/gta01/split_by_variant.sh @@ -58,6 +58,7 @@ esac fi +sed 's/^/#define /;s/=/ /' <$CFGTMP >>$CFGINC # --------------------------------------------------------- # Complete the configuration # ---------------------------------------------------------