[U-Boot] [v4 1/3] armv8: ls1012ardb: clean up definitions for I2C IO expanders

This patch is to clean up definitions for I2C IO expanders. The value 0x10 of __SW_BOOT_EMU is wrong. It should be 0x2. Fixed it in this patch.
Signed-off-by: Yangbo Lu yangbo.lu@nxp.com --- Changes for v4: - Added this patch. --- board/freescale/ls1012ardb/ls1012ardb.c | 14 +++++++------- include/configs/ls1012ardb.h | 18 ++++++++++-------- 2 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/board/freescale/ls1012ardb/ls1012ardb.c b/board/freescale/ls1012ardb/ls1012ardb.c index c6c1c71202..2f1d63742a 100644 --- a/board/freescale/ls1012ardb/ls1012ardb.c +++ b/board/freescale/ls1012ardb/ls1012ardb.c @@ -35,25 +35,25 @@ int checkboard(void) /* Initialize i2c early for Serial flash bank information */ i2c_set_bus_num(0);
- if (i2c_read(I2C_MUX_IO1_ADDR, 1, 1, &in1, 1) < 0) { + if (i2c_read(I2C_MUX_IO_ADDR, I2C_MUX_IO_1, 1, &in1, 1) < 0) { printf("Error reading i2c boot information!\n"); return 0; /* Don't want to hang() on this error */ }
puts("Version"); - if ((in1 & (~__SW_REV_MASK)) == __SW_REV_A) + if ((in1 & SW_REV_MASK) == SW_REV_A) puts(": RevA"); - else if ((in1 & (~__SW_REV_MASK)) == __SW_REV_B) + else if ((in1 & SW_REV_MASK) == SW_REV_B) puts(": RevB"); else puts(": unknown");
printf(", boot from QSPI"); - if ((in1 & (~__SW_BOOT_MASK)) == __SW_BOOT_EMU) + if ((in1 & SW_BOOT_MASK) == SW_BOOT_EMU) puts(": emu\n"); - else if ((in1 & (~__SW_BOOT_MASK)) == __SW_BOOT_BANK1) + else if ((in1 & SW_BOOT_MASK) == SW_BOOT_BANK1) puts(": bank1\n"); - else if ((in1 & (~__SW_BOOT_MASK)) == __SW_BOOT_BANK2) + else if ((in1 & SW_BOOT_MASK) == SW_BOOT_BANK2) puts(": bank2\n"); else puts("unknown\n"); @@ -152,7 +152,7 @@ int esdhc_status_fixup(void *blob, const char *compat) * 10 - eMMC Memory * 11 - SPI */ - if (i2c_read(I2C_MUX_IO1_ADDR, 0, 1, &io, 1) < 0) { + if (i2c_read(I2C_MUX_IO_ADDR, I2C_MUX_IO_0, 1, &io, 1) < 0) { printf("Error reading i2c boot information!\n"); return 0; /* Don't want to hang() on this error */ } diff --git a/include/configs/ls1012ardb.h b/include/configs/ls1012ardb.h index 794117062f..a1a563cb59 100644 --- a/include/configs/ls1012ardb.h +++ b/include/configs/ls1012ardb.h @@ -24,14 +24,16 @@ * I2C IO expander */
-#define I2C_MUX_IO1_ADDR 0x24 -#define __SW_BOOT_MASK 0xFC -#define __SW_BOOT_EMU 0x10 -#define __SW_BOOT_BANK1 0x00 -#define __SW_BOOT_BANK2 0x01 -#define __SW_REV_MASK 0x07 -#define __SW_REV_A 0xF8 -#define __SW_REV_B 0xF0 +#define I2C_MUX_IO_ADDR 0x24 +#define I2C_MUX_IO_0 0 +#define I2C_MUX_IO_1 1 +#define SW_BOOT_MASK 0x03 +#define SW_BOOT_EMU 0x02 +#define SW_BOOT_BANK1 0x00 +#define SW_BOOT_BANK2 0x01 +#define SW_REV_MASK 0xF8 +#define SW_REV_A 0xF8 +#define SW_REV_B 0xF0
/* MMC */ #ifdef CONFIG_MMC

Add LS1012ARDB RevC/RevC1/RevC2/RevD/RevE information and detect it when u-boot starts up.
Signed-off-by: Yangbo Lu yangbo.lu@nxp.com --- Changes for v4: - Added this patch. --- board/freescale/ls1012ardb/ls1012ardb.c | 26 +++++++++++++++++++++++--- include/configs/ls1012ardb.h | 5 +++++ 2 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/board/freescale/ls1012ardb/ls1012ardb.c b/board/freescale/ls1012ardb/ls1012ardb.c index 2f1d63742a..421b0a7861 100644 --- a/board/freescale/ls1012ardb/ls1012ardb.c +++ b/board/freescale/ls1012ardb/ls1012ardb.c @@ -41,12 +41,32 @@ int checkboard(void) }
puts("Version"); - if ((in1 & SW_REV_MASK) == SW_REV_A) + switch (in1 & SW_REV_MASK) { + case SW_REV_A: puts(": RevA"); - else if ((in1 & SW_REV_MASK) == SW_REV_B) + break; + case SW_REV_B: puts(": RevB"); - else + break; + case SW_REV_C: + puts(": RevC"); + break; + case SW_REV_C1: + puts(": RevC1"); + break; + case SW_REV_C2: + puts(": RevC2"); + break; + case SW_REV_D: + puts(": RevD"); + break; + case SW_REV_E: + puts(": RevE"); + break; + default: puts(": unknown"); + break; + }
printf(", boot from QSPI"); if ((in1 & SW_BOOT_MASK) == SW_BOOT_EMU) diff --git a/include/configs/ls1012ardb.h b/include/configs/ls1012ardb.h index a1a563cb59..9f471663b8 100644 --- a/include/configs/ls1012ardb.h +++ b/include/configs/ls1012ardb.h @@ -34,6 +34,11 @@ #define SW_REV_MASK 0xF8 #define SW_REV_A 0xF8 #define SW_REV_B 0xF0 +#define SW_REV_C 0xE8 +#define SW_REV_C1 0xE0 +#define SW_REV_C2 0xD8 +#define SW_REV_D 0xD0 +#define SW_REV_E 0xC8
/* MMC */ #ifdef CONFIG_MMC

On 12/07/2017 11:54 PM, Yangbo Lu wrote:
Add LS1012ARDB RevC/RevC1/RevC2/RevD/RevE information and detect it when u-boot starts up.
Signed-off-by: Yangbo Lu yangbo.lu@nxp.com
Changes for v4:
- Added this patch.
Applied to fsl-qoriq master. Thanks.
York

I2C reading for DIP switch setting is not reliable for LS1012ARDB RevD and later versions. This patch is to add hwconfig support to enable/disable eSDHC1 manually for these boards. Also drop 'status' fix-up for eSDHC0 and leave it as it is. It shouldn't always be fixed up with 'okay'.
Signed-off-by: Yangbo Lu yangbo.lu@nxp.com --- Changes for v2: - Just used hwconfig() instead of getenv() and hwconfig_f(). Changes for v3: - only applied hwconfig support for RevD and later versions. Changes for v4: - Modified commit message. - reused io variable. - checked CONFIG_HWCONFIG before use it. --- board/freescale/ls1012ardb/ls1012ardb.c | 55 +++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 20 deletions(-)
diff --git a/board/freescale/ls1012ardb/ls1012ardb.c b/board/freescale/ls1012ardb/ls1012ardb.c index 421b0a7861..286f9d8199 100644 --- a/board/freescale/ls1012ardb/ls1012ardb.c +++ b/board/freescale/ls1012ardb/ls1012ardb.c @@ -152,34 +152,49 @@ int board_init(void)
int esdhc_status_fixup(void *blob, const char *compat) { - char esdhc0_path[] = "/soc/esdhc@1560000"; char esdhc1_path[] = "/soc/esdhc@1580000"; - u8 io = 0; + bool sdhc2_en = false; u8 mux_sdhc2; - - do_fixup_by_path(blob, esdhc0_path, "status", "okay", - sizeof("okay"), 1); + u8 io = 0;
i2c_set_bus_num(0);
- /* - * The I2C IO-expander for mux select is used to control the muxing - * of various onboard interfaces. - * - * IO1[3:2] indicates SDHC2 interface demultiplexer select lines. - * 00 - SDIO wifi - * 01 - GPIO (to Arduino) - * 10 - eMMC Memory - * 11 - SPI - */ - if (i2c_read(I2C_MUX_IO_ADDR, I2C_MUX_IO_0, 1, &io, 1) < 0) { + /* IO1[7:3] is the field of board revision info. */ + if (i2c_read(I2C_MUX_IO_ADDR, I2C_MUX_IO_1, 1, &io, 1) < 0) { printf("Error reading i2c boot information!\n"); - return 0; /* Don't want to hang() on this error */ + return 0; + } + + /* hwconfig method is used for RevD and later versions. */ + if ((io & SW_REV_MASK) <= SW_REV_D) { +#ifdef CONFIG_HWCONFIG + if (hwconfig("esdhc1")) + sdhc2_en = true; +#endif + } else { + /* + * The I2C IO-expander for mux select is used to control + * the muxing of various onboard interfaces. + * + * IO0[3:2] indicates SDHC2 interface demultiplexer + * select lines. + * 00 - SDIO wifi + * 01 - GPIO (to Arduino) + * 10 - eMMC Memory + * 11 - SPI + */ + if (i2c_read(I2C_MUX_IO_ADDR, I2C_MUX_IO_0, 1, &io, 1) < 0) { + printf("Error reading i2c boot information!\n"); + return 0; + } + + mux_sdhc2 = (io & 0x0c) >> 2; + /* Enable SDHC2 only when use SDIO wifi and eMMC */ + if (mux_sdhc2 == 2 || mux_sdhc2 == 0) + sdhc2_en = true; }
- mux_sdhc2 = (io & 0x0c) >> 2; - /* Enable SDHC2 only when use SDIO wifi and eMMC */ - if (mux_sdhc2 == 2 || mux_sdhc2 == 0) + if (sdhc2_en) do_fixup_by_path(blob, esdhc1_path, "status", "okay", sizeof("okay"), 1); else

On 12/07/2017 11:54 PM, Yangbo Lu wrote:
I2C reading for DIP switch setting is not reliable for LS1012ARDB RevD and later versions. This patch is to add hwconfig support to enable/disable eSDHC1 manually for these boards. Also drop 'status' fix-up for eSDHC0 and leave it as it is. It shouldn't always be fixed up with 'okay'.
Signed-off-by: Yangbo Lu yangbo.lu@nxp.com
Changes for v2:
- Just used hwconfig() instead of getenv() and hwconfig_f().
Changes for v3:
- only applied hwconfig support for RevD and later versions.
Changes for v4:
- Modified commit message.
- reused io variable.
- checked CONFIG_HWCONFIG before use it.
Applied to fsl-qoriq master. Thanks.
York

On 12/07/2017 11:54 PM, Yangbo Lu wrote:
This patch is to clean up definitions for I2C IO expanders. The value 0x10 of __SW_BOOT_EMU is wrong. It should be 0x2. Fixed it in this patch.
Signed-off-by: Yangbo Lu yangbo.lu@nxp.com
Changes for v4:
- Added this patch.
Applied to fsl-qoriq master. Thanks.
York
participants (2)
-
Yangbo Lu
-
York Sun