Re: [U-Boot] [PATCH V2 11/11] exynos5-dt-types: add board detection for Odroid XU3/XU3L/XU4.
Hi Premyslaw, On 13 October 2015 at 05:59, Przemyslaw Marczakwrote: > Hello Simon, > > > On 10/03/2015 04:28 PM, Simon Glass wrote: >> >> Hi Przemyslaw, >> >> On 21 September 2015 at 13:26, Przemyslaw Marczak >> wrote: >>> >>> This commit adds additional file with implementation of board >>> detection code for Odroid-XU3/XU4. >>> >>> The detection depends on compatible found in fdt: >>> - "samsung,exynos5" - uses Exynos5 generic code >>> - "samsung,odroidxu3" - try detect XU3 revision >>> >>> There are few revisions of Odroid XU3/XU4, each can be detected >>> by checking the value of channel 9 of built-in ADC: >>> Rev ADC Board >>> 0.1 0 XU3 0.1 >>> 0.2 372 XU3 0.2 | XU3L - no DISPLAYPORT >>> 0.3 1280 XU4 0.1 >>> >>> The detection code depends on the ADC+10% value. >>> >>> Implementation of functions: >>> - set_board_type() - read ADC and set type >>> - get_board_rev() - returns board revision: 1..3 >>> - get_board_type() - returns board type string >>> >>> Additional functions with return values of bool: >>> - board_is_generic() - true if found compatible "samsung,exynos5" >>> but not "samsung,odroidxu3" >>> - board_is_odroidxu3() - true if found compatible "samsung,odroidxu3" >>> and one of XU3 revision. >>> - board_is_odroidxu4() - true if found compatible "samsung,odroidxu3" >>> and XU4 revision. >>> >>> After I2C controller init, the get_board_type() can check >>> if the XU3 board is a "Lite" variant, by probing chip >>> 0x40 on I2C0 (INA231 - exists only on non-lite). >>> This is useful for setting fdt file name at misc_init_r(). >>> >>> Enabled configs: >>> - CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG >>> - CONFIG_ODROID_REV_AIN >>> - CONFIG_REVISION_TAG >>> - CONFIG_BOARD_TYPES >>> >>> Signed-off-by: Przemyslaw Marczak >>> --- >>> Changes V2: >>> - move detection code from exynos5-dt.c to exynos5-dt-types.c >>> - add header with board type function declarations >>> - check for compatible before do the detection >>> - update the ADC max values with 20% tolerance >>> - fix XU4 adc value, related to mistake from table in XU4 schematic >>> - return "Not supported" for XU4 when calls one of: >>>--dfu_get_alt_boot() >>>--dfu_get_alt_system() >>> - extend ${dfu_alt_system} by strings: >>>-- 'exynos5422-odroidxu3-lite.dtb' >>>-- 'exynos5422-odroidxu4.dtb' - allows prepare card on XU3 >>> --- >>> board/samsung/common/Makefile | 5 +- >>> board/samsung/common/exynos5-dt-types.c | 196 >>> >>> board/samsung/common/exynos5-dt.c | 12 ++ >>> configs/odroid-xu3_defconfig| 2 + >>> include/configs/odroid_xu3.h| 12 ++ >>> include/samsung/exynos5-dt-types.h | 27 + >>> 6 files changed, 253 insertions(+), 1 deletion(-) >>> create mode 100644 board/samsung/common/exynos5-dt-types.c >>> create mode 100644 include/samsung/exynos5-dt-types.h >> >> >> Reviewed-by: Simon Glass >> >> See nits below. >> > > Ok. > > >>> >>> diff --git a/board/samsung/common/Makefile >>> b/board/samsung/common/Makefile >>> index 6cbd906..ef1a8f3 100644 >>> --- a/board/samsung/common/Makefile >>> +++ b/board/samsung/common/Makefile >>> @@ -11,5 +11,8 @@ obj-$(CONFIG_MISC_COMMON) += misc.o >>> >>> ifndef CONFIG_SPL_BUILD >>> obj-$(CONFIG_BOARD_COMMON) += board.o >>> -obj-$(CONFIG_EXYNOS5_DT) += exynos5-dt.o >>> +ifdef CONFIG_EXYNOS5_DT >>> +obj-y += exynos5-dt.o >>> +obj-$(CONFIG_BOARD_TYPES) += exynos5-dt-types.o >>> +endif >>> endif >>> diff --git a/board/samsung/common/exynos5-dt-types.c >>> b/board/samsung/common/exynos5-dt-types.c >>> new file mode 100644 >>> index 000..1364e98 >>> --- /dev/null >>> +++ b/board/samsung/common/exynos5-dt-types.c >>> @@ -0,0 +1,196 @@ >>> +/* >>> + * Copyright (C) 2015 Samsung Electronics >>> + * Przemyslaw Marczak >>> + * >>> + * SPDX-License-Identifier:GPL-2.0+ >>> + */ >>> + >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> + >>> +DECLARE_GLOBAL_DATA_PTR; >>> + >>> +static const struct udevice_id board_ids[] = { >>> + { .compatible = "samsung,odroidxu3", .data = >>> EXYNOS5_BOARD_ODROID_XU3 }, >>> + { .compatible = "samsung,exynos5", .data = EXYNOS5_BOARD_GENERIC >>> }, >>> + { }, >>> +}; >>> + >>> +/** >>> + * Odroix XU3/4 board revisions: >>> + * Rev ADCmax Board >>> + * 0.1 0 XU3 0.1 >>> + * 0.2 410 XU3 0.2 | XU3L - no DISPLAYPORT (probe I2C0:0x40 / >>> INA231) >>> + * 0.3 1408 XU4 0.1 >>> + * Use +10 % for ADC value tolerance. >>> + */ >>> +struct odroid_rev_info odroid_info[] = { >>> + { EXYNOS5_BOARD_ODROID_XU3_REV01, 1, 10, "xu3" }, >>> + { EXYNOS5_BOARD_ODROID_XU3_REV02, 2, 410,
Re: [U-Boot] [PATCH V2 11/11] exynos5-dt-types: add board detection for Odroid XU3/XU3L/XU4.
Hello Simon, On 10/03/2015 04:28 PM, Simon Glass wrote: Hi Przemyslaw, On 21 September 2015 at 13:26, Przemyslaw Marczakwrote: This commit adds additional file with implementation of board detection code for Odroid-XU3/XU4. The detection depends on compatible found in fdt: - "samsung,exynos5" - uses Exynos5 generic code - "samsung,odroidxu3" - try detect XU3 revision There are few revisions of Odroid XU3/XU4, each can be detected by checking the value of channel 9 of built-in ADC: Rev ADC Board 0.1 0 XU3 0.1 0.2 372 XU3 0.2 | XU3L - no DISPLAYPORT 0.3 1280 XU4 0.1 The detection code depends on the ADC+10% value. Implementation of functions: - set_board_type() - read ADC and set type - get_board_rev() - returns board revision: 1..3 - get_board_type() - returns board type string Additional functions with return values of bool: - board_is_generic() - true if found compatible "samsung,exynos5" but not "samsung,odroidxu3" - board_is_odroidxu3() - true if found compatible "samsung,odroidxu3" and one of XU3 revision. - board_is_odroidxu4() - true if found compatible "samsung,odroidxu3" and XU4 revision. After I2C controller init, the get_board_type() can check if the XU3 board is a "Lite" variant, by probing chip 0x40 on I2C0 (INA231 - exists only on non-lite). This is useful for setting fdt file name at misc_init_r(). Enabled configs: - CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG - CONFIG_ODROID_REV_AIN - CONFIG_REVISION_TAG - CONFIG_BOARD_TYPES Signed-off-by: Przemyslaw Marczak --- Changes V2: - move detection code from exynos5-dt.c to exynos5-dt-types.c - add header with board type function declarations - check for compatible before do the detection - update the ADC max values with 20% tolerance - fix XU4 adc value, related to mistake from table in XU4 schematic - return "Not supported" for XU4 when calls one of: --dfu_get_alt_boot() --dfu_get_alt_system() - extend ${dfu_alt_system} by strings: -- 'exynos5422-odroidxu3-lite.dtb' -- 'exynos5422-odroidxu4.dtb' - allows prepare card on XU3 --- board/samsung/common/Makefile | 5 +- board/samsung/common/exynos5-dt-types.c | 196 board/samsung/common/exynos5-dt.c | 12 ++ configs/odroid-xu3_defconfig| 2 + include/configs/odroid_xu3.h| 12 ++ include/samsung/exynos5-dt-types.h | 27 + 6 files changed, 253 insertions(+), 1 deletion(-) create mode 100644 board/samsung/common/exynos5-dt-types.c create mode 100644 include/samsung/exynos5-dt-types.h Reviewed-by: Simon Glass See nits below. Ok. diff --git a/board/samsung/common/Makefile b/board/samsung/common/Makefile index 6cbd906..ef1a8f3 100644 --- a/board/samsung/common/Makefile +++ b/board/samsung/common/Makefile @@ -11,5 +11,8 @@ obj-$(CONFIG_MISC_COMMON) += misc.o ifndef CONFIG_SPL_BUILD obj-$(CONFIG_BOARD_COMMON) += board.o -obj-$(CONFIG_EXYNOS5_DT) += exynos5-dt.o +ifdef CONFIG_EXYNOS5_DT +obj-y += exynos5-dt.o +obj-$(CONFIG_BOARD_TYPES) += exynos5-dt-types.o +endif endif diff --git a/board/samsung/common/exynos5-dt-types.c b/board/samsung/common/exynos5-dt-types.c new file mode 100644 index 000..1364e98 --- /dev/null +++ b/board/samsung/common/exynos5-dt-types.c @@ -0,0 +1,196 @@ +/* + * Copyright (C) 2015 Samsung Electronics + * Przemyslaw Marczak + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +static const struct udevice_id board_ids[] = { + { .compatible = "samsung,odroidxu3", .data = EXYNOS5_BOARD_ODROID_XU3 }, + { .compatible = "samsung,exynos5", .data = EXYNOS5_BOARD_GENERIC }, + { }, +}; + +/** + * Odroix XU3/4 board revisions: + * Rev ADCmax Board + * 0.1 0 XU3 0.1 + * 0.2 410 XU3 0.2 | XU3L - no DISPLAYPORT (probe I2C0:0x40 / INA231) + * 0.3 1408 XU4 0.1 + * Use +10 % for ADC value tolerance. + */ +struct odroid_rev_info odroid_info[] = { + { EXYNOS5_BOARD_ODROID_XU3_REV01, 1, 10, "xu3" }, + { EXYNOS5_BOARD_ODROID_XU3_REV02, 2, 410, "xu3" }, + { EXYNOS5_BOARD_ODROID_XU4_REV01, 1, 1408, "xu4" }, + { EXYNOS5_BOARD_ODROID_UNKNOWN, 0, 4095, "unknown" }, +}; + +static unsigned int odroid_get_rev(void) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(odroid_info); i++) { + if (odroid_info[i].board_type == gd->board_type) + return odroid_info[i].board_rev; + } + + return 0; +} + +static int odroid_get_board_type(void) +{ + unsigned int adcval; + int ret, i; + + ret = adc_channel_single_shot("adc", CONFIG_ODROID_REV_AIN, ); + if (ret) + goto rev_default; + +
Re: [U-Boot] [PATCH V2 11/11] exynos5-dt-types: add board detection for Odroid XU3/XU3L/XU4.
Hi Przemyslaw, On 21 September 2015 at 13:26, Przemyslaw Marczakwrote: > This commit adds additional file with implementation of board > detection code for Odroid-XU3/XU4. > > The detection depends on compatible found in fdt: > - "samsung,exynos5" - uses Exynos5 generic code > - "samsung,odroidxu3" - try detect XU3 revision > > There are few revisions of Odroid XU3/XU4, each can be detected > by checking the value of channel 9 of built-in ADC: > Rev ADC Board > 0.1 0 XU3 0.1 > 0.2 372 XU3 0.2 | XU3L - no DISPLAYPORT > 0.3 1280 XU4 0.1 > > The detection code depends on the ADC+10% value. > > Implementation of functions: > - set_board_type() - read ADC and set type > - get_board_rev() - returns board revision: 1..3 > - get_board_type() - returns board type string > > Additional functions with return values of bool: > - board_is_generic() - true if found compatible "samsung,exynos5" > but not "samsung,odroidxu3" > - board_is_odroidxu3() - true if found compatible "samsung,odroidxu3" > and one of XU3 revision. > - board_is_odroidxu4() - true if found compatible "samsung,odroidxu3" > and XU4 revision. > > After I2C controller init, the get_board_type() can check > if the XU3 board is a "Lite" variant, by probing chip > 0x40 on I2C0 (INA231 - exists only on non-lite). > This is useful for setting fdt file name at misc_init_r(). > > Enabled configs: > - CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG > - CONFIG_ODROID_REV_AIN > - CONFIG_REVISION_TAG > - CONFIG_BOARD_TYPES > > Signed-off-by: Przemyslaw Marczak > --- > Changes V2: > - move detection code from exynos5-dt.c to exynos5-dt-types.c > - add header with board type function declarations > - check for compatible before do the detection > - update the ADC max values with 20% tolerance > - fix XU4 adc value, related to mistake from table in XU4 schematic > - return "Not supported" for XU4 when calls one of: > --dfu_get_alt_boot() > --dfu_get_alt_system() > - extend ${dfu_alt_system} by strings: > -- 'exynos5422-odroidxu3-lite.dtb' > -- 'exynos5422-odroidxu4.dtb' - allows prepare card on XU3 > --- > board/samsung/common/Makefile | 5 +- > board/samsung/common/exynos5-dt-types.c | 196 > > board/samsung/common/exynos5-dt.c | 12 ++ > configs/odroid-xu3_defconfig| 2 + > include/configs/odroid_xu3.h| 12 ++ > include/samsung/exynos5-dt-types.h | 27 + > 6 files changed, 253 insertions(+), 1 deletion(-) > create mode 100644 board/samsung/common/exynos5-dt-types.c > create mode 100644 include/samsung/exynos5-dt-types.h Reviewed-by: Simon Glass See nits below. > > diff --git a/board/samsung/common/Makefile b/board/samsung/common/Makefile > index 6cbd906..ef1a8f3 100644 > --- a/board/samsung/common/Makefile > +++ b/board/samsung/common/Makefile > @@ -11,5 +11,8 @@ obj-$(CONFIG_MISC_COMMON) += misc.o > > ifndef CONFIG_SPL_BUILD > obj-$(CONFIG_BOARD_COMMON) += board.o > -obj-$(CONFIG_EXYNOS5_DT) += exynos5-dt.o > +ifdef CONFIG_EXYNOS5_DT > +obj-y += exynos5-dt.o > +obj-$(CONFIG_BOARD_TYPES) += exynos5-dt-types.o > +endif > endif > diff --git a/board/samsung/common/exynos5-dt-types.c > b/board/samsung/common/exynos5-dt-types.c > new file mode 100644 > index 000..1364e98 > --- /dev/null > +++ b/board/samsung/common/exynos5-dt-types.c > @@ -0,0 +1,196 @@ > +/* > + * Copyright (C) 2015 Samsung Electronics > + * Przemyslaw Marczak > + * > + * SPDX-License-Identifier:GPL-2.0+ > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +DECLARE_GLOBAL_DATA_PTR; > + > +static const struct udevice_id board_ids[] = { > + { .compatible = "samsung,odroidxu3", .data = EXYNOS5_BOARD_ODROID_XU3 > }, > + { .compatible = "samsung,exynos5", .data = EXYNOS5_BOARD_GENERIC }, > + { }, > +}; > + > +/** > + * Odroix XU3/4 board revisions: > + * Rev ADCmax Board > + * 0.1 0 XU3 0.1 > + * 0.2 410 XU3 0.2 | XU3L - no DISPLAYPORT (probe I2C0:0x40 / INA231) > + * 0.3 1408 XU4 0.1 > + * Use +10 % for ADC value tolerance. > + */ > +struct odroid_rev_info odroid_info[] = { > + { EXYNOS5_BOARD_ODROID_XU3_REV01, 1, 10, "xu3" }, > + { EXYNOS5_BOARD_ODROID_XU3_REV02, 2, 410, "xu3" }, > + { EXYNOS5_BOARD_ODROID_XU4_REV01, 1, 1408, "xu4" }, > + { EXYNOS5_BOARD_ODROID_UNKNOWN, 0, 4095, "unknown" }, > +}; > + > +static unsigned int odroid_get_rev(void) > +{ > + int i; > + > + for (i = 0; i < ARRAY_SIZE(odroid_info); i++) { > + if (odroid_info[i].board_type == gd->board_type) > + return odroid_info[i].board_rev; > + } > + > + return 0; > +} > + > +static int odroid_get_board_type(void) >
[U-Boot] [PATCH V2 11/11] exynos5-dt-types: add board detection for Odroid XU3/XU3L/XU4.
This commit adds additional file with implementation of board detection code for Odroid-XU3/XU4. The detection depends on compatible found in fdt: - "samsung,exynos5" - uses Exynos5 generic code - "samsung,odroidxu3" - try detect XU3 revision There are few revisions of Odroid XU3/XU4, each can be detected by checking the value of channel 9 of built-in ADC: Rev ADC Board 0.1 0 XU3 0.1 0.2 372 XU3 0.2 | XU3L - no DISPLAYPORT 0.3 1280 XU4 0.1 The detection code depends on the ADC+10% value. Implementation of functions: - set_board_type() - read ADC and set type - get_board_rev() - returns board revision: 1..3 - get_board_type() - returns board type string Additional functions with return values of bool: - board_is_generic() - true if found compatible "samsung,exynos5" but not "samsung,odroidxu3" - board_is_odroidxu3() - true if found compatible "samsung,odroidxu3" and one of XU3 revision. - board_is_odroidxu4() - true if found compatible "samsung,odroidxu3" and XU4 revision. After I2C controller init, the get_board_type() can check if the XU3 board is a "Lite" variant, by probing chip 0x40 on I2C0 (INA231 - exists only on non-lite). This is useful for setting fdt file name at misc_init_r(). Enabled configs: - CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG - CONFIG_ODROID_REV_AIN - CONFIG_REVISION_TAG - CONFIG_BOARD_TYPES Signed-off-by: Przemyslaw Marczak--- Changes V2: - move detection code from exynos5-dt.c to exynos5-dt-types.c - add header with board type function declarations - check for compatible before do the detection - update the ADC max values with 20% tolerance - fix XU4 adc value, related to mistake from table in XU4 schematic - return "Not supported" for XU4 when calls one of: --dfu_get_alt_boot() --dfu_get_alt_system() - extend ${dfu_alt_system} by strings: -- 'exynos5422-odroidxu3-lite.dtb' -- 'exynos5422-odroidxu4.dtb' - allows prepare card on XU3 --- board/samsung/common/Makefile | 5 +- board/samsung/common/exynos5-dt-types.c | 196 board/samsung/common/exynos5-dt.c | 12 ++ configs/odroid-xu3_defconfig| 2 + include/configs/odroid_xu3.h| 12 ++ include/samsung/exynos5-dt-types.h | 27 + 6 files changed, 253 insertions(+), 1 deletion(-) create mode 100644 board/samsung/common/exynos5-dt-types.c create mode 100644 include/samsung/exynos5-dt-types.h diff --git a/board/samsung/common/Makefile b/board/samsung/common/Makefile index 6cbd906..ef1a8f3 100644 --- a/board/samsung/common/Makefile +++ b/board/samsung/common/Makefile @@ -11,5 +11,8 @@ obj-$(CONFIG_MISC_COMMON) += misc.o ifndef CONFIG_SPL_BUILD obj-$(CONFIG_BOARD_COMMON) += board.o -obj-$(CONFIG_EXYNOS5_DT) += exynos5-dt.o +ifdef CONFIG_EXYNOS5_DT +obj-y += exynos5-dt.o +obj-$(CONFIG_BOARD_TYPES) += exynos5-dt-types.o +endif endif diff --git a/board/samsung/common/exynos5-dt-types.c b/board/samsung/common/exynos5-dt-types.c new file mode 100644 index 000..1364e98 --- /dev/null +++ b/board/samsung/common/exynos5-dt-types.c @@ -0,0 +1,196 @@ +/* + * Copyright (C) 2015 Samsung Electronics + * Przemyslaw Marczak + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +static const struct udevice_id board_ids[] = { + { .compatible = "samsung,odroidxu3", .data = EXYNOS5_BOARD_ODROID_XU3 }, + { .compatible = "samsung,exynos5", .data = EXYNOS5_BOARD_GENERIC }, + { }, +}; + +/** + * Odroix XU3/4 board revisions: + * Rev ADCmax Board + * 0.1 0 XU3 0.1 + * 0.2 410 XU3 0.2 | XU3L - no DISPLAYPORT (probe I2C0:0x40 / INA231) + * 0.3 1408 XU4 0.1 + * Use +10 % for ADC value tolerance. + */ +struct odroid_rev_info odroid_info[] = { + { EXYNOS5_BOARD_ODROID_XU3_REV01, 1, 10, "xu3" }, + { EXYNOS5_BOARD_ODROID_XU3_REV02, 2, 410, "xu3" }, + { EXYNOS5_BOARD_ODROID_XU4_REV01, 1, 1408, "xu4" }, + { EXYNOS5_BOARD_ODROID_UNKNOWN, 0, 4095, "unknown" }, +}; + +static unsigned int odroid_get_rev(void) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(odroid_info); i++) { + if (odroid_info[i].board_type == gd->board_type) + return odroid_info[i].board_rev; + } + + return 0; +} + +static int odroid_get_board_type(void) +{ + unsigned int adcval; + int ret, i; + + ret = adc_channel_single_shot("adc", CONFIG_ODROID_REV_AIN, ); + if (ret) + goto rev_default; + + for (i = 0; i < ARRAY_SIZE(odroid_info); i++) { + /* ADC tolerance: +20 % */ + if (adcval < odroid_info[i].adc_val) + return odroid_info[i].board_type; + } + +rev_default: + return