[U-Boot] [PATCH 7/7] exynos5-dt: add board detection for Odroid XU3/XU3L/XU4.

Simon Glass sjg at chromium.org
Tue Sep 1 02:33:32 CEST 2015


Hi Przemyslaw,

On 28 August 2015 at 07:59, Przemyslaw Marczak <p.marczak at samsung.com> wrote:
> There are few revisions of Odroid XU3/XU4:
>  Rev   ADC   Board
>  0.1     0   XU3 0.1
>  0.2   372   XU3 0.2 | XU3L - no DISPLAYPORT
>  0.3   739   XU4 0.1
>
> This commit adds implementation of functions:
> - set_board_type()     - read ADC and set type
> - get_board_rev()      - returns board revision: 1..3
> - board_is_odroidxu3() - returns bool
> - board_is_odroidxu4() - returns bool
> - get_board_type()     - returns board type string
>
> After I2C controller init, the last function can check
> if the board is "Lite" variant for XU3, by probing chip
> 0x40 on I2C0 (INA231 - exists only on non-lite).
> This is useful for setting fdt file name at misc_init_r().
>
> The enabled configs:
> - CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
> - CONFIG_ODROID_REV_AIN
> - CONFIG_REVISION_TAG
> - CONFIG_MISC_INIT_R
> - CONFIG_BOARD_TYPES
>
> This also redefines CONFIG_SYS_BOARD to "odroid".
>
> Signed-off-by: Przemyslaw Marczak <p.marczak at samsung.com>
> ---
>  board/samsung/common/exynos5-dt.c | 114 ++++++++++++++++++++++++++++++++++++++
>  include/configs/odroid_xu3.h      |  12 ++++
>  2 files changed, 126 insertions(+)
>
> diff --git a/board/samsung/common/exynos5-dt.c b/board/samsung/common/exynos5-dt.c
> index 7d1b88a..41141df 100644
> --- a/board/samsung/common/exynos5-dt.c
> +++ b/board/samsung/common/exynos5-dt.c
> @@ -18,6 +18,7 @@
>  #include <usb.h>
>  #include <video_bridge.h>
>  #include <asm/gpio.h>
> +#include <asm/arch/adc.h>
>  #include <asm/arch/cpu.h>
>  #include <asm/arch/dwmmc.h>
>  #include <asm/arch/mmc.h>
> @@ -28,6 +29,7 @@
>  #include <power/max77686_pmic.h>
>  #include <power/regulator.h>
>  #include <power/s5m8767.h>
> +#include <power/s2mps11.h>
>  #include <tmu.h>
>
>  DECLARE_GLOBAL_DATA_PTR;
> @@ -360,3 +362,115 @@ char *get_dfu_alt_boot(char *interface, char *devstr)
>         return alt_boot;
>  }
>  #endif
> +
> +#ifdef CONFIG_REVISION_TAG

Can we check the compatible string instead? It would be good to avoid
#ifdef in common code.

> +/**
> + * Odroix XU3/4 board revisions:
> + * Rev   ADC   Board
> + * 0.1     0   XU3 0.1
> + * 0.2   372   XU3 0.2 | XU3L - no DISPLAYPORT (probe I2C0:0x40 / INA231)
> + * 0.3   739   XU4 0.1
> + * Use +/-20 for ADC value tolerance.
> + */
> +enum {
> +       ODROID_XU3_REV01,
> +       ODROID_XU3_REV02,
> +       ODROID_XU4_REV01,
> +       ODROID_UNKNOWN_REV,
> +       ODROID_REV_COUNT,
> +};
> +
> +struct odroid_type {
> +       int board_type;
> +       int rev;
> +       int adc_val;
> +       const char *name;
> +};
> +
> +struct odroid_type odroid_type[] = {
> +       { ODROID_XU3_REV01, 1, 0, "xu3" },
> +       { ODROID_XU3_REV02, 2, 372, "xu3" },
> +       { ODROID_XU4_REV01, 1, 739, "xu4" },
> +       { ODROID_UNKNOWN_REV, 0, 4095, "unknown" },
> +};
> +
> +bool board_is_odroidxu3(void)
> +{
> +       if (gd->board_type < ODROID_XU4_REV01)
> +               return true;
> +
> +       return false;
> +}
> +
> +bool board_is_odroidxu4(void)
> +{
> +       if (gd->board_type > ODROID_XU3_REV02)
> +               return true;
> +
> +       return false;
> +}
> +
> +int set_board_type(void)
> +{
> +       int adcval, i;
> +
> +       adcval = exynos_adc_read_channel(CONFIG_ODROID_REV_AIN);
> +       if (adcval < 0)
> +               return adcval;
> +
> +       for (i = 0; i < ODROID_REV_COUNT; i++) {
> +               /* ADC tolerance: +20 */
> +               if (adcval < odroid_type[i].adc_val + 20) {
> +                       gd->board_type = i;
> +                       return i;
> +               }
> +       }
> +
> +       return ODROID_UNKNOWN_REV;
> +}
> +
> +int get_board_rev(void)
> +{
> +       return odroid_type[gd->board_type].rev;
> +}
> +
> +/**
> + * get_board_type - returns pointer to one of the board type string.
> + * Board types: "xu3", "xu3-lite", "xu4". However the "xu3itel" can be
> + * detected only when the i2c controller is ready to use. Fortunately,
> + * XU3 and XU3L are compatible, and the information about board lite
> + * revision is needed before boot linux, to set proper environment
> + * variable: $fdtfile.
> + */
> +const char *get_board_type(void)
> +{
> +       const char *type_xu3l = "xu3-lite";
> +       struct udevice *dev, *chip;
> +       int ret;
> +
> +       if (gd->board_type != ODROID_XU3_REV02)
> +               goto exit;
> +
> +       ret = pmic_get("s2mps11", &dev);
> +       if (ret)
> +               goto exit;
> +
> +       /* Enable LDO26: 3.0V */
> +       ret = pmic_reg_write(dev, S2MPS11_REG_L26CTRL,
> +                            S2MPS11_LDO26_ENABLE);
> +       if (ret)
> +               goto exit;
> +
> +       /* Check XU3Lite by probe INA231 I2C0:0x40 */
> +       ret = uclass_get_device(UCLASS_I2C, 0, &dev);
> +       if (ret)
> +               goto exit;
> +
> +       ret = dm_i2c_probe(dev, 0x40, 0x0, &chip);
> +       if (ret)
> +               return type_xu3l;
> +
> +exit:
> +       return odroid_type[gd->board_type].name;
> +}
> +#endif
> diff --git a/include/configs/odroid_xu3.h b/include/configs/odroid_xu3.h
> index 3c70158..648e48b 100644
> --- a/include/configs/odroid_xu3.h
> +++ b/include/configs/odroid_xu3.h
> @@ -94,6 +94,8 @@
>         "boot.scr fat 0 1;"                 \
>         "boot.cmd fat 0 1;"                 \
>         "exynos5422-odroidxu3.dtb fat 0 1;" \
> +       "exynos5422-odroidxu3-lite.dtb fat 0 1;" \
> +       "exynos5422-odroidxu4.dtb fat 0 1;" \
>         "boot part 0 1;"                    \
>         "root part 0 2\0"
>
> @@ -113,9 +115,19 @@
>
>  /* Enable: board/samsung/common/misc.c to use set_dfu_alt_info() */
>  #define CONFIG_MISC_COMMON
> +#define CONFIG_MISC_INIT_R
>  #define CONFIG_SET_DFU_ALT_INFO
>  #define CONFIG_SET_DFU_ALT_BUF_LEN     (SZ_1K)
>
> +/* Set soc_rev, soc_id, board_rev, boardname, fdtfile */
> +#define CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
> +#define CONFIG_ODROID_REV_AIN                  9
> +#define CONFIG_REVISION_TAG
> +#define CONFIG_BOARD_TYPES
> +
> +#undef CONFIG_SYS_BOARD
> +#define CONFIG_SYS_BOARD       "odroid"
> +
>  /* Define new extra env settings, including DFU settings */
>  #undef CONFIG_EXTRA_ENV_SETTINGS
>  #define CONFIG_EXTRA_ENV_SETTINGS \
> --
> 1.9.1
>

Regards,
Simon


More information about the U-Boot mailing list