* [U-Boot] [PATCH 0/3] ARM: keystone2: Cleanup macros
@ 2016-03-15 15:25 Nishanth Menon
2016-03-15 15:25 ` [U-Boot] [PATCH 1/3] ARM: keystone2: Convert BOOTBITMASK to static inline function Nishanth Menon
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Nishanth Menon @ 2016-03-15 15:25 UTC (permalink / raw)
To: u-boot
As reported by Tom in [1], macros in psc definitions are just too painful to
readup on.. so convert it into static inline of equivalent functionality.
Based on
master 4d339a9e8a75 Merge branch 'master' of git://git.denx.de/u-boot-video
Testing:
K2g: http://pastebin.ubuntu.com/15392362/
k2hk: http://pastebin.ubuntu.com/15392337/
Nishanth Menon (3):
ARM: keystone2: Convert BOOTBITMASK to static inline function
ARM: keystone2: Convert BOOT_READ_BITFIELD into static inline function
ARM: keystone2: Convert BOOT_SET_BITFIELD into static inline function
arch/arm/mach-keystone/include/mach/psc_defs.h | 51 ++++++++++++++++----------
1 file changed, 32 insertions(+), 19 deletions(-)
[1] https://patchwork.ozlabs.org/patch/588338/
--
2.7.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH 1/3] ARM: keystone2: Convert BOOTBITMASK to static inline function
2016-03-15 15:25 [U-Boot] [PATCH 0/3] ARM: keystone2: Cleanup macros Nishanth Menon
@ 2016-03-15 15:25 ` Nishanth Menon
2016-03-17 2:10 ` Tom Rini
2016-03-27 22:23 ` [U-Boot] [U-Boot, " Tom Rini
2016-03-15 15:25 ` [U-Boot] [PATCH 2/3] ARM: keystone2: Convert BOOT_READ_BITFIELD into " Nishanth Menon
2016-03-15 15:25 ` [U-Boot] [PATCH 3/3] ARM: keystone2: Convert BOOT_SET_BITFIELD " Nishanth Menon
2 siblings, 2 replies; 10+ messages in thread
From: Nishanth Menon @ 2016-03-15 15:25 UTC (permalink / raw)
To: u-boot
BOOTBITMASK is almost impossible to decode, so convert it into a simpler
static line functions of equivalent solution.
Reported-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Nishanth Menon <nm@ti.com>
---
arch/arm/mach-keystone/include/mach/psc_defs.h | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/arch/arm/mach-keystone/include/mach/psc_defs.h b/arch/arm/mach-keystone/include/mach/psc_defs.h
index 6e6e7fd433a1..9681175938d4 100644
--- a/arch/arm/mach-keystone/include/mach/psc_defs.h
+++ b/arch/arm/mach-keystone/include/mach/psc_defs.h
@@ -27,12 +27,16 @@
#define PSC_REG_MDSTAT(x) (0x800 + (4 * (x)))
#define PSC_REG_MDCTL(x) (0xa00 + (4 * (x)))
-#define BOOTBITMASK(x, y) ((((((u32)1 << (((u32)x) - ((u32)y) + (u32)1)) - \
- (u32)1)) << ((u32)y)))
-#define BOOT_READ_BITFIELD(z, x, y) ((((u32)z) & BOOTBITMASK(x, y)) >> (y))
-#define BOOT_SET_BITFIELD(z, f, x, y) ((((u32)z) & ~BOOTBITMASK(x, y)) | \
- ((((u32)f) << (y)) & BOOTBITMASK(x, y)))
+static inline u32 _boot_bit_mask(u32 x, u32 y)
+{
+ u32 val = (1 << (x - y + 1)) - 1;
+ return val << y;
+}
+
+#define BOOT_READ_BITFIELD(z, x, y) ((((u32)z) & _boot_bit_mask(x, y)) >> (y))
+#define BOOT_SET_BITFIELD(z, f, x, y) ((((u32)z) & ~_boot_bit_mask(x, y)) | \
+ ((((u32)f) << (y)) & _boot_bit_mask(x, y)))
/* PDCTL */
#define PSC_REG_PDCTL_SET_NEXT(x, y) BOOT_SET_BITFIELD((x), (y), 0, 0)
--
2.7.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH 2/3] ARM: keystone2: Convert BOOT_READ_BITFIELD into static inline function
2016-03-15 15:25 [U-Boot] [PATCH 0/3] ARM: keystone2: Cleanup macros Nishanth Menon
2016-03-15 15:25 ` [U-Boot] [PATCH 1/3] ARM: keystone2: Convert BOOTBITMASK to static inline function Nishanth Menon
@ 2016-03-15 15:25 ` Nishanth Menon
2016-03-17 2:10 ` Tom Rini
2016-03-27 22:23 ` [U-Boot] [U-Boot, " Tom Rini
2016-03-15 15:25 ` [U-Boot] [PATCH 3/3] ARM: keystone2: Convert BOOT_SET_BITFIELD " Nishanth Menon
2 siblings, 2 replies; 10+ messages in thread
From: Nishanth Menon @ 2016-03-15 15:25 UTC (permalink / raw)
To: u-boot
BOOT_READ_BITFIELD can easily be a static inline function and be a
little more readable with the same functionality.
Reported-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Nishanth Menon <nm@ti.com>
---
arch/arm/mach-keystone/include/mach/psc_defs.h | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/arch/arm/mach-keystone/include/mach/psc_defs.h b/arch/arm/mach-keystone/include/mach/psc_defs.h
index 9681175938d4..671b1d64d69f 100644
--- a/arch/arm/mach-keystone/include/mach/psc_defs.h
+++ b/arch/arm/mach-keystone/include/mach/psc_defs.h
@@ -34,7 +34,12 @@ static inline u32 _boot_bit_mask(u32 x, u32 y)
return val << y;
}
-#define BOOT_READ_BITFIELD(z, x, y) ((((u32)z) & _boot_bit_mask(x, y)) >> (y))
+static inline u32 boot_read_bitfield(u32 z, u32 x, u32 y)
+{
+ u32 val = z & _boot_bit_mask(x, y);
+ return val >> y;
+}
+
#define BOOT_SET_BITFIELD(z, f, x, y) ((((u32)z) & ~_boot_bit_mask(x, y)) | \
((((u32)f) << (y)) & _boot_bit_mask(x, y)))
@@ -43,25 +48,25 @@ static inline u32 _boot_bit_mask(u32 x, u32 y)
#define PSC_REG_PDCTL_SET_PDMODE(x, y) BOOT_SET_BITFIELD((x), (y), 15, 12)
/* PDSTAT */
-#define PSC_REG_PDSTAT_GET_STATE(x) BOOT_READ_BITFIELD((x), 4, 0)
+#define PSC_REG_PDSTAT_GET_STATE(x) boot_read_bitfield((x), 4, 0)
/* MDCFG */
-#define PSC_REG_MDCFG_GET_PD(x) BOOT_READ_BITFIELD((x), 20, 16)
-#define PSC_REG_MDCFG_GET_RESET_ISO(x) BOOT_READ_BITFIELD((x), 14, 14)
+#define PSC_REG_MDCFG_GET_PD(x) boot_read_bitfield((x), 20, 16)
+#define PSC_REG_MDCFG_GET_RESET_ISO(x) boot_read_bitfield((x), 14, 14)
/* MDCTL */
#define PSC_REG_MDCTL_SET_NEXT(x, y) BOOT_SET_BITFIELD((x), (y), 4, 0)
#define PSC_REG_MDCTL_SET_LRSTZ(x, y) BOOT_SET_BITFIELD((x), (y), 8, 8)
-#define PSC_REG_MDCTL_GET_LRSTZ(x) BOOT_READ_BITFIELD((x), 8, 8)
+#define PSC_REG_MDCTL_GET_LRSTZ(x) boot_read_bitfield((x), 8, 8)
#define PSC_REG_MDCTL_SET_RESET_ISO(x, y) BOOT_SET_BITFIELD((x), (y), \
12, 12)
/* MDSTAT */
-#define PSC_REG_MDSTAT_GET_STATUS(x) BOOT_READ_BITFIELD((x), 5, 0)
-#define PSC_REG_MDSTAT_GET_LRSTZ(x) BOOT_READ_BITFIELD((x), 8, 8)
-#define PSC_REG_MDSTAT_GET_LRSTDONE(x) BOOT_READ_BITFIELD((x), 9, 9)
-#define PSC_REG_MDSTAT_GET_MRSTZ(x) BOOT_READ_BITFIELD((x), 10, 10)
-#define PSC_REG_MDSTAT_GET_MRSTDONE(x) BOOT_READ_BITFIELD((x), 11, 11)
+#define PSC_REG_MDSTAT_GET_STATUS(x) boot_read_bitfield((x), 5, 0)
+#define PSC_REG_MDSTAT_GET_LRSTZ(x) boot_read_bitfield((x), 8, 8)
+#define PSC_REG_MDSTAT_GET_LRSTDONE(x) boot_read_bitfield((x), 9, 9)
+#define PSC_REG_MDSTAT_GET_MRSTZ(x) boot_read_bitfield((x), 10, 10)
+#define PSC_REG_MDSTAT_GET_MRSTDONE(x) boot_read_bitfield((x), 11, 11)
/* PDCTL states */
#define PSC_REG_VAL_PDCTL_NEXT_ON 1
--
2.7.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH 3/3] ARM: keystone2: Convert BOOT_SET_BITFIELD into static inline function
2016-03-15 15:25 [U-Boot] [PATCH 0/3] ARM: keystone2: Cleanup macros Nishanth Menon
2016-03-15 15:25 ` [U-Boot] [PATCH 1/3] ARM: keystone2: Convert BOOTBITMASK to static inline function Nishanth Menon
2016-03-15 15:25 ` [U-Boot] [PATCH 2/3] ARM: keystone2: Convert BOOT_READ_BITFIELD into " Nishanth Menon
@ 2016-03-15 15:25 ` Nishanth Menon
2016-03-17 2:11 ` Tom Rini
2016-03-27 22:23 ` [U-Boot] [U-Boot, " Tom Rini
2 siblings, 2 replies; 10+ messages in thread
From: Nishanth Menon @ 2016-03-15 15:25 UTC (permalink / raw)
To: u-boot
Fix up BOOT_SET_BITFIELD to be a static inline function to be readable
with the same functionality.
Reported-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Nishanth Menon <nm@ti.com>
---
arch/arm/mach-keystone/include/mach/psc_defs.h | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/arch/arm/mach-keystone/include/mach/psc_defs.h b/arch/arm/mach-keystone/include/mach/psc_defs.h
index 671b1d64d69f..18499386a321 100644
--- a/arch/arm/mach-keystone/include/mach/psc_defs.h
+++ b/arch/arm/mach-keystone/include/mach/psc_defs.h
@@ -40,12 +40,16 @@ static inline u32 boot_read_bitfield(u32 z, u32 x, u32 y)
return val >> y;
}
-#define BOOT_SET_BITFIELD(z, f, x, y) ((((u32)z) & ~_boot_bit_mask(x, y)) | \
- ((((u32)f) << (y)) & _boot_bit_mask(x, y)))
+static inline u32 boot_set_bitfield(u32 z, u32 f, u32 x, u32 y)
+{
+ u32 mask = _boot_bit_mask(x, y);
+
+ return (z & ~mask) | ((f << y) & mask);
+}
/* PDCTL */
-#define PSC_REG_PDCTL_SET_NEXT(x, y) BOOT_SET_BITFIELD((x), (y), 0, 0)
-#define PSC_REG_PDCTL_SET_PDMODE(x, y) BOOT_SET_BITFIELD((x), (y), 15, 12)
+#define PSC_REG_PDCTL_SET_NEXT(x, y) boot_set_bitfield((x), (y), 0, 0)
+#define PSC_REG_PDCTL_SET_PDMODE(x, y) boot_set_bitfield((x), (y), 15, 12)
/* PDSTAT */
#define PSC_REG_PDSTAT_GET_STATE(x) boot_read_bitfield((x), 4, 0)
@@ -55,10 +59,10 @@ static inline u32 boot_read_bitfield(u32 z, u32 x, u32 y)
#define PSC_REG_MDCFG_GET_RESET_ISO(x) boot_read_bitfield((x), 14, 14)
/* MDCTL */
-#define PSC_REG_MDCTL_SET_NEXT(x, y) BOOT_SET_BITFIELD((x), (y), 4, 0)
-#define PSC_REG_MDCTL_SET_LRSTZ(x, y) BOOT_SET_BITFIELD((x), (y), 8, 8)
+#define PSC_REG_MDCTL_SET_NEXT(x, y) boot_set_bitfield((x), (y), 4, 0)
+#define PSC_REG_MDCTL_SET_LRSTZ(x, y) boot_set_bitfield((x), (y), 8, 8)
#define PSC_REG_MDCTL_GET_LRSTZ(x) boot_read_bitfield((x), 8, 8)
-#define PSC_REG_MDCTL_SET_RESET_ISO(x, y) BOOT_SET_BITFIELD((x), (y), \
+#define PSC_REG_MDCTL_SET_RESET_ISO(x, y) boot_set_bitfield((x), (y), \
12, 12)
/* MDSTAT */
--
2.7.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH 1/3] ARM: keystone2: Convert BOOTBITMASK to static inline function
2016-03-15 15:25 ` [U-Boot] [PATCH 1/3] ARM: keystone2: Convert BOOTBITMASK to static inline function Nishanth Menon
@ 2016-03-17 2:10 ` Tom Rini
2016-03-27 22:23 ` [U-Boot] [U-Boot, " Tom Rini
1 sibling, 0 replies; 10+ messages in thread
From: Tom Rini @ 2016-03-17 2:10 UTC (permalink / raw)
To: u-boot
On Tue, Mar 15, 2016 at 10:25:51AM -0500, Nishanth Menon wrote:
> BOOTBITMASK is almost impossible to decode, so convert it into a simpler
> static line functions of equivalent solution.
>
> Reported-by: Tom Rini <trini@konsulko.com>
> Signed-off-by: Nishanth Menon <nm@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160316/0400c4e6/attachment.sig>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH 2/3] ARM: keystone2: Convert BOOT_READ_BITFIELD into static inline function
2016-03-15 15:25 ` [U-Boot] [PATCH 2/3] ARM: keystone2: Convert BOOT_READ_BITFIELD into " Nishanth Menon
@ 2016-03-17 2:10 ` Tom Rini
2016-03-27 22:23 ` [U-Boot] [U-Boot, " Tom Rini
1 sibling, 0 replies; 10+ messages in thread
From: Tom Rini @ 2016-03-17 2:10 UTC (permalink / raw)
To: u-boot
On Tue, Mar 15, 2016 at 10:25:52AM -0500, Nishanth Menon wrote:
> BOOT_READ_BITFIELD can easily be a static inline function and be a
> little more readable with the same functionality.
>
> Reported-by: Tom Rini <trini@konsulko.com>
> Signed-off-by: Nishanth Menon <nm@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160316/3d8b5f4a/attachment.sig>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH 3/3] ARM: keystone2: Convert BOOT_SET_BITFIELD into static inline function
2016-03-15 15:25 ` [U-Boot] [PATCH 3/3] ARM: keystone2: Convert BOOT_SET_BITFIELD " Nishanth Menon
@ 2016-03-17 2:11 ` Tom Rini
2016-03-27 22:23 ` [U-Boot] [U-Boot, " Tom Rini
1 sibling, 0 replies; 10+ messages in thread
From: Tom Rini @ 2016-03-17 2:11 UTC (permalink / raw)
To: u-boot
On Tue, Mar 15, 2016 at 10:25:53AM -0500, Nishanth Menon wrote:
> Fix up BOOT_SET_BITFIELD to be a static inline function to be readable
> with the same functionality.
>
> Reported-by: Tom Rini <trini@konsulko.com>
> Signed-off-by: Nishanth Menon <nm@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160316/888e100d/attachment.sig>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [U-Boot] [U-Boot, 1/3] ARM: keystone2: Convert BOOTBITMASK to static inline function
2016-03-15 15:25 ` [U-Boot] [PATCH 1/3] ARM: keystone2: Convert BOOTBITMASK to static inline function Nishanth Menon
2016-03-17 2:10 ` Tom Rini
@ 2016-03-27 22:23 ` Tom Rini
1 sibling, 0 replies; 10+ messages in thread
From: Tom Rini @ 2016-03-27 22:23 UTC (permalink / raw)
To: u-boot
On Tue, Mar 15, 2016 at 10:25:51AM -0500, Nishanth Menon wrote:
> BOOTBITMASK is almost impossible to decode, so convert it into a simpler
> static line functions of equivalent solution.
>
> Reported-by: Tom Rini <trini@konsulko.com>
> Signed-off-by: Nishanth Menon <nm@ti.com>
> Reviewed-by: Tom Rini <trini@konsulko.com>
Applied to u-boot/master, thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160327/87b46452/attachment.sig>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [U-Boot] [U-Boot, 2/3] ARM: keystone2: Convert BOOT_READ_BITFIELD into static inline function
2016-03-15 15:25 ` [U-Boot] [PATCH 2/3] ARM: keystone2: Convert BOOT_READ_BITFIELD into " Nishanth Menon
2016-03-17 2:10 ` Tom Rini
@ 2016-03-27 22:23 ` Tom Rini
1 sibling, 0 replies; 10+ messages in thread
From: Tom Rini @ 2016-03-27 22:23 UTC (permalink / raw)
To: u-boot
On Tue, Mar 15, 2016 at 10:25:52AM -0500, Nishanth Menon wrote:
> BOOT_READ_BITFIELD can easily be a static inline function and be a
> little more readable with the same functionality.
>
> Reported-by: Tom Rini <trini@konsulko.com>
> Signed-off-by: Nishanth Menon <nm@ti.com>
> Reviewed-by: Tom Rini <trini@konsulko.com>
Applied to u-boot/master, thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160327/cde96fef/attachment.sig>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [U-Boot] [U-Boot, 3/3] ARM: keystone2: Convert BOOT_SET_BITFIELD into static inline function
2016-03-15 15:25 ` [U-Boot] [PATCH 3/3] ARM: keystone2: Convert BOOT_SET_BITFIELD " Nishanth Menon
2016-03-17 2:11 ` Tom Rini
@ 2016-03-27 22:23 ` Tom Rini
1 sibling, 0 replies; 10+ messages in thread
From: Tom Rini @ 2016-03-27 22:23 UTC (permalink / raw)
To: u-boot
On Tue, Mar 15, 2016 at 10:25:53AM -0500, Nishanth Menon wrote:
> Fix up BOOT_SET_BITFIELD to be a static inline function to be readable
> with the same functionality.
>
> Reported-by: Tom Rini <trini@konsulko.com>
> Signed-off-by: Nishanth Menon <nm@ti.com>
> Reviewed-by: Tom Rini <trini@konsulko.com>
Applied to u-boot/master, thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160327/76480ba3/attachment.sig>
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2016-03-27 22:23 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-15 15:25 [U-Boot] [PATCH 0/3] ARM: keystone2: Cleanup macros Nishanth Menon
2016-03-15 15:25 ` [U-Boot] [PATCH 1/3] ARM: keystone2: Convert BOOTBITMASK to static inline function Nishanth Menon
2016-03-17 2:10 ` Tom Rini
2016-03-27 22:23 ` [U-Boot] [U-Boot, " Tom Rini
2016-03-15 15:25 ` [U-Boot] [PATCH 2/3] ARM: keystone2: Convert BOOT_READ_BITFIELD into " Nishanth Menon
2016-03-17 2:10 ` Tom Rini
2016-03-27 22:23 ` [U-Boot] [U-Boot, " Tom Rini
2016-03-15 15:25 ` [U-Boot] [PATCH 3/3] ARM: keystone2: Convert BOOT_SET_BITFIELD " Nishanth Menon
2016-03-17 2:11 ` Tom Rini
2016-03-27 22:23 ` [U-Boot] [U-Boot, " Tom Rini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.