wandboard: Add board revision detection support
authorFabio Estevam <fabio.estevam@freescale.com>
Thu, 21 May 2015 22:24:05 +0000 (19:24 -0300)
committerStefano Babic <sbabic@denx.de>
Mon, 8 Jun 2015 06:34:38 +0000 (08:34 +0200)
There are two revisions of wandboard: version B1 and C1.

Add the revision detection support, so that the correct dtb file can
be automatically loaded.

Based on the patch from Richard Hu <hakahu@gmail.com>.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Reviewed-by: Stefano Babic <sbabic@denx.de>
Tested-By: Vagrant Cascadian <vagrant@aikidev.net>
board/wandboard/wandboard.c
include/configs/wandboard.h

index 90625ab9e0690b41858f44c6bdd7273b038aeafa..0af63d291fe6dca605393160ae039d96b0adc078 100644 (file)
@@ -50,6 +50,7 @@ DECLARE_GLOBAL_DATA_PTR;
 #define USDHC1_CD_GPIO         IMX_GPIO_NR(1, 2)
 #define USDHC3_CD_GPIO         IMX_GPIO_NR(3, 9)
 #define ETH_PHY_RESET          IMX_GPIO_NR(3, 29)
+#define REV_DETECTION          IMX_GPIO_NR(2, 28)
 
 int dram_init(void)
 {
@@ -105,6 +106,10 @@ static iomux_v3_cfg_t const enet_pads[] = {
        IOMUX_PADS(PAD_EIM_D29__GPIO3_IO29    | MUX_PAD_CTRL(NO_PAD_CTRL)),
 };
 
+static iomux_v3_cfg_t const rev_detection_pad[] = {
+       IOMUX_PADS(PAD_EIM_EB0__GPIO2_IO28  | MUX_PAD_CTRL(NO_PAD_CTRL)),
+};
+
 static void setup_iomux_uart(void)
 {
        SETUP_IOMUX_PADS(uart1_pads);
@@ -393,6 +398,17 @@ static const struct boot_mode board_boot_modes[] = {
 };
 #endif
 
+static bool is_revc1(void)
+{
+       SETUP_IOMUX_PADS(rev_detection_pad);
+       gpio_direction_input(REV_DETECTION);
+
+       if (gpio_get_value(REV_DETECTION))
+               return true;
+       else
+               return false;
+}
+
 int board_late_init(void)
 {
 #ifdef CONFIG_CMD_BMODE
@@ -404,6 +420,11 @@ int board_late_init(void)
                setenv("board_rev", "MX6Q");
        else
                setenv("board_rev", "MX6DL");
+
+       if (is_revc1())
+               setenv("board_name", "C1");
+       else
+               setenv("board_name", "B1");
 #endif
        return 0;
 }
@@ -424,7 +445,10 @@ int board_init(void)
 
 int checkboard(void)
 {
-       puts("Board: Wandboard\n");
+       if (is_revc1())
+               puts("Board: Wandboard rev C1\n");
+       else
+               puts("Board: Wandboard rev B1\n");
 
        return 0;
 }
index 69590ad884d12623b86873a124b2cf096f35aec5..0cc0f034ac1bd7a9f170e62d87845196effcd713 100644 (file)
                        "bootz; " \
                "fi;\0" \
        "findfdt="\
-               "if test $board_rev = MX6Q ; then " \
+               "if test $board_name = C1 && test $board_rev = MX6Q ; then " \
                        "setenv fdtfile imx6q-wandboard.dtb; fi; " \
-               "if test $board_rev = MX6DL ; then " \
+               "if test $board_name = C1 && test $board_rev = MX6DL ; then " \
                        "setenv fdtfile imx6dl-wandboard.dtb; fi; " \
+               "if test $board_name = B1 && test $board_rev = MX6Q ; then " \
+                       "setenv fdtfile imx6q-wandboard-revb1.dtb; fi; " \
+               "if test $board_name = B1 && test $board_rev = MX6DL ; then " \
+                       "setenv fdtfile imx6dl-wandboard-revb1.dtb; fi; " \
                "if test $fdtfile = undefined; then " \
                        "echo WARNING: Could not determine dtb to use; fi; \0" \