Message ID | 20220425141216.2140-1-pali@kernel.org |
---|---|
State | Superseded |
Delegated to: | Peng Fan |
Headers | show |
Series | [v2] board: freescale: p1_p2_rdb_pc: Fix parsing inverted bits from boot input data | expand |
在 2022/4/25 22:12, Pali Rohár 写道: > On some boards upper 4 bits of i2c boot input data (register 0) are > inverted. Information which bits are inverted is stored in register 2. > > So invert read input data back according to register 2 prior processing > them. This fixes printing "rom_loc: value" line during booting. > > Signed-off-by: Pali Rohár <pali@kernel.org> Not able to apply this with next branch. Please rebase. Thanks, Peng. > --- > Changes in v2: > * Use register 2 for detecting which bits needs to be inverted > --- > board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c b/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c > index 29502a5c05c2..cdbff03ac45c 100644 > --- a/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c > +++ b/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c > @@ -164,7 +164,7 @@ int checkboard(void) > { > struct cpld_data *cpld_data = (void *)(CONFIG_SYS_CPLD_BASE); > ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); > - u8 in, out, io_config, val; > + u8 in, out, invert, io_config, val; > int bus_num = CONFIG_SYS_SPD_BUS_NUM; > > printf("Board: %s CPLD: V%d.%d PCBA: V%d.0\n", CONFIG_BOARDNAME, > @@ -187,6 +187,7 @@ int checkboard(void) > > if (dm_i2c_read(dev, 0, &in, 1) < 0 || > dm_i2c_read(dev, 1, &out, 1) < 0 || > + dm_i2c_read(dev, 2, &invert, 1) < 0 || > dm_i2c_read(dev, 3, &io_config, 1) < 0) { > printf("Error reading i2c boot information!\n"); > return 0; /* Don't want to hang() on this error */ > @@ -196,13 +197,14 @@ int checkboard(void) > > if (i2c_read(CONFIG_SYS_I2C_PCA9557_ADDR, 0, 1, &in, 1) < 0 || > i2c_read(CONFIG_SYS_I2C_PCA9557_ADDR, 1, 1, &out, 1) < 0 || > + i2c_read(CONFIG_SYS_I2C_PCA9557_ADDR, 2, 1, &invert, 1) < 0 || > i2c_read(CONFIG_SYS_I2C_PCA9557_ADDR, 3, 1, &io_config, 1) < 0) { > printf("Error reading i2c boot information!\n"); > return 0; /* Don't want to hang() on this error */ > } > #endif > > - val = (in & io_config) | (out & (~io_config)); > + val = ((in ^ invert) & io_config) | (out & (~io_config)); > > puts("rom_loc: "); > if ((val & (~__SW_BOOT_MASK)) == __SW_BOOT_SD) {
diff --git a/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c b/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c index 29502a5c05c2..cdbff03ac45c 100644 --- a/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c +++ b/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c @@ -164,7 +164,7 @@ int checkboard(void) { struct cpld_data *cpld_data = (void *)(CONFIG_SYS_CPLD_BASE); ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); - u8 in, out, io_config, val; + u8 in, out, invert, io_config, val; int bus_num = CONFIG_SYS_SPD_BUS_NUM; printf("Board: %s CPLD: V%d.%d PCBA: V%d.0\n", CONFIG_BOARDNAME, @@ -187,6 +187,7 @@ int checkboard(void) if (dm_i2c_read(dev, 0, &in, 1) < 0 || dm_i2c_read(dev, 1, &out, 1) < 0 || + dm_i2c_read(dev, 2, &invert, 1) < 0 || dm_i2c_read(dev, 3, &io_config, 1) < 0) { printf("Error reading i2c boot information!\n"); return 0; /* Don't want to hang() on this error */ @@ -196,13 +197,14 @@ int checkboard(void) if (i2c_read(CONFIG_SYS_I2C_PCA9557_ADDR, 0, 1, &in, 1) < 0 || i2c_read(CONFIG_SYS_I2C_PCA9557_ADDR, 1, 1, &out, 1) < 0 || + i2c_read(CONFIG_SYS_I2C_PCA9557_ADDR, 2, 1, &invert, 1) < 0 || i2c_read(CONFIG_SYS_I2C_PCA9557_ADDR, 3, 1, &io_config, 1) < 0) { printf("Error reading i2c boot information!\n"); return 0; /* Don't want to hang() on this error */ } #endif - val = (in & io_config) | (out & (~io_config)); + val = ((in ^ invert) & io_config) | (out & (~io_config)); puts("rom_loc: "); if ((val & (~__SW_BOOT_MASK)) == __SW_BOOT_SD) {
On some boards upper 4 bits of i2c boot input data (register 0) are inverted. Information which bits are inverted is stored in register 2. So invert read input data back according to register 2 prior processing them. This fixes printing "rom_loc: value" line during booting. Signed-off-by: Pali Rohár <pali@kernel.org> --- Changes in v2: * Use register 2 for detecting which bits needs to be inverted --- board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)