Skip to contentSkip to conversation

ARM: imx: Fix bmode detection from grp10

PATCH New Fabio Estevam 3 participants 6 messages Oct 16, 2019 – Oct 21, 2019 5 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

PATCH 2/3 ARM: imx: Fix bmode detection from grp10

Hi Claudius,

Quoted 16 lines · Claudius Heine

imx6_is_bmode_from_gpr10 always returns false, because IMX6_SRC_GPR10_BMODE is 1<<28 and gets casted to u8 on return.

Instead cast them to a boolean value before return of the function.

---
 arch/arm/include/asm/mach-imx/sys_proto.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/include/asm/mach-imx/sys_proto.h +0 -0
index 96530e563e..b6105d0798 100644

arch/arm/include/asm/mach-imx/sys_proto.h enum imx6_bmode { · line 92

Quoted 2 lines
arch/arm/include/asm/mach-imx/sys_proto.h +0 -0
@@ -91,7 +91,7 @@ enum imx6_bmode {
 
 static inline u8 imx6_is_bmode_from_gpr10(void)

Would it make more sense to convert imx6_is_bmode_from_gpr10() to return bool instead of u8?

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#9 lore raw

PATCH 1/3 ARM: imx: Rename imx6_is_bmode_from_gpr9 to imx6_is_bmode_from_gpr10

In reply to a message not in the archive

Hi Claudius,

Quoted 2 lines · Claudius Heine

The only register used in that function is gpr10, which is used to store the flag. So naming it after this makes sense.

I think the old name had a reason: The _value_ for bmode is stored in GPR9 if this function returns true. But I agree that the name is a bit confusing.

Maybe it would make more sense to call it imx6_is_bmode_from_gpr, without any specific register name and add a comment documenting that if bit (GPR10 & IMX6_SRC_GPR10_BMODE) is set, the bmode value is stored in GPR9?

Quoted 32 lines
---
 arch/arm/include/asm/mach-imx/sys_proto.h | 2 +-
 arch/arm/mach-imx/init.c                  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/include/asm/mach-imx/sys_proto.h +1 -1
index 4925dd7894..96530e563e 100644
@@ -89,7 +89,7 @@ enum imx6_bmode {
 	IMX6_BMODE_NAND_MAX = 0xf,
 };
 
-static inline u8 imx6_is_bmode_from_gpr9(void)
+static inline u8 imx6_is_bmode_from_gpr10(void)
 {
 	return readl(&src_base->gpr10) & IMX6_SRC_GPR10_BMODE;
 }
arch/arm/mach-imx/init.c +1 -1
index b8d8d12372..b2e72d0dbd 100644
@@ -118,7 +118,7 @@ void boot_mode_apply(unsigned cfg_val)
 #if defined(CONFIG_MX6)
 u32 imx6_src_get_boot_mode(void)
 {
-	if (imx6_is_bmode_from_gpr9())
+	if (imx6_is_bmode_from_gpr10())
 		return readl(&src_base->gpr9);
 	else
 		return readl(&src_base->sbmr1);
Signature · 5 lines
Harald

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-62  Fax: +49-8142-66989-80   Email: hws at denx.de
#10 lore raw

PATCH 1/3 ARM: imx: Rename imx6_is_bmode_from_gpr9 to imx6_is_bmode_from_gpr10

Hi Harald,

Quoted 9 lines · Harald Seiler

Hi Claudius,

Quoted 2 lines · Claudius Heine

The only register used in that function is gpr10, which is used to store the flag. So naming it after this makes sense.

I think the old name had a reason: The _value_ for bmode is stored in GPR9 if this function returns true. But I agree that the name is a bit confusing.

Hmm.. imx6_is_bmode_from_gprX is only used once and where it is used direct register access happens anyway, so maybe we could just remove it and do it directly in boot_mode_apply.

I will do that in v3 if its ok.

regards,
Claudius

Quoted 39 lines

Maybe it would make more sense to call it imx6_is_bmode_from_gpr, without any specific register name and add a comment documenting that if bit (GPR10 & IMX6_SRC_GPR10_BMODE) is set, the bmode value is stored in GPR9?

Quoted 32 lines
---
 arch/arm/include/asm/mach-imx/sys_proto.h | 2 +-
 arch/arm/mach-imx/init.c                  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/include/asm/mach-imx/sys_proto.h +1 -1
index 4925dd7894..96530e563e 100644
@@ -89,7 +89,7 @@ enum imx6_bmode {
 	IMX6_BMODE_NAND_MAX = 0xf,
 };
 
-static inline u8 imx6_is_bmode_from_gpr9(void)
+static inline u8 imx6_is_bmode_from_gpr10(void)
 {
 	return readl(&src_base->gpr10) & IMX6_SRC_GPR10_BMODE;
 }
arch/arm/mach-imx/init.c +1 -1
index b8d8d12372..b2e72d0dbd 100644
@@ -118,7 +118,7 @@ void boot_mode_apply(unsigned cfg_val)
 #if defined(CONFIG_MX6)
 u32 imx6_src_get_boot_mode(void)
 {
-	if (imx6_is_bmode_from_gpr9())
+	if (imx6_is_bmode_from_gpr10())
 		return readl(&src_base->gpr9);
 	else
 		return readl(&src_base->sbmr1);
Signature · 14 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-54 Fax: (+49)-8142-66989-80 Email: ch at denx.de

           PGP key: 6FF2 E59F 00C6 BC28 31D8 64C1 1173 CB19 9808 B153
                             Keyserver: hkp://pool.sks-keyservers.net

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20191021/523d00a0/attachment.sig>