* [U-Boot] [PATCH] blackfin: gpio: Use proper mask for comparing function
@ 2013-06-28 6:45 Axel Lin
2013-07-01 3:17 ` Sonic Zhang
0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2013-06-28 6:45 UTC (permalink / raw)
To: u-boot
The function return from P_FUNCT2MUX(per) takes 2 bits, however
for BF537_FAMILY with offset != 1 the function is 1 bit.
Also has small refactor for better readability.
In portmux_setup(), it looks odd having "muxreg &= ~(3 << 1);"
while in current code we do muxreg |= (function << offset);.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
arch/blackfin/cpu/gpio.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/arch/blackfin/cpu/gpio.c b/arch/blackfin/cpu/gpio.c
index f74a0b7..c4cddaf 100644
--- a/arch/blackfin/cpu/gpio.c
+++ b/arch/blackfin/cpu/gpio.c
@@ -247,7 +247,7 @@ static struct {
static void portmux_setup(unsigned short per)
{
- u16 y, offset, muxreg;
+ u16 y, offset, muxreg, mask;
u16 function = P_FUNCT2MUX(per);
for (y = 0; y < ARRAY_SIZE(port_mux_lut); y++) {
@@ -258,12 +258,13 @@ static void portmux_setup(unsigned short per)
offset = port_mux_lut[y].offset;
muxreg = bfin_read_PORT_MUX();
- if (offset != 1)
- muxreg &= ~(1 << offset);
+ if (offset == 1)
+ mask = 3;
else
- muxreg &= ~(3 << 1);
+ mask = 1;
- muxreg |= (function << offset);
+ muxreg &= ~(mask << offset);
+ muxreg |= ((function & mask) << offset);
bfin_write_PORT_MUX(muxreg);
}
}
--
1.8.1.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [U-Boot] [PATCH] blackfin: gpio: Use proper mask for comparing function
2013-06-28 6:45 [U-Boot] [PATCH] blackfin: gpio: Use proper mask for comparing function Axel Lin
@ 2013-07-01 3:17 ` Sonic Zhang
0 siblings, 0 replies; 2+ messages in thread
From: Sonic Zhang @ 2013-07-01 3:17 UTC (permalink / raw)
To: u-boot
Acked-by: Sonic Zhang <sonic.zhang@analog.com>
On Fri, Jun 28, 2013 at 2:45 PM, Axel Lin <axel.lin@ingics.com> wrote:
> The function return from P_FUNCT2MUX(per) takes 2 bits, however
> for BF537_FAMILY with offset != 1 the function is 1 bit.
>
> Also has small refactor for better readability.
> In portmux_setup(), it looks odd having "muxreg &= ~(3 << 1);"
> while in current code we do muxreg |= (function << offset);.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
> arch/blackfin/cpu/gpio.c | 11 ++++++-----
> 1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/arch/blackfin/cpu/gpio.c b/arch/blackfin/cpu/gpio.c
> index f74a0b7..c4cddaf 100644
> --- a/arch/blackfin/cpu/gpio.c
> +++ b/arch/blackfin/cpu/gpio.c
> @@ -247,7 +247,7 @@ static struct {
>
> static void portmux_setup(unsigned short per)
> {
> - u16 y, offset, muxreg;
> + u16 y, offset, muxreg, mask;
> u16 function = P_FUNCT2MUX(per);
>
> for (y = 0; y < ARRAY_SIZE(port_mux_lut); y++) {
> @@ -258,12 +258,13 @@ static void portmux_setup(unsigned short per)
> offset = port_mux_lut[y].offset;
> muxreg = bfin_read_PORT_MUX();
>
> - if (offset != 1)
> - muxreg &= ~(1 << offset);
> + if (offset == 1)
> + mask = 3;
> else
> - muxreg &= ~(3 << 1);
> + mask = 1;
>
> - muxreg |= (function << offset);
> + muxreg &= ~(mask << offset);
> + muxreg |= ((function & mask) << offset);
> bfin_write_PORT_MUX(muxreg);
> }
> }
> --
> 1.8.1.2
>
>
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-07-01 3:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-28 6:45 [U-Boot] [PATCH] blackfin: gpio: Use proper mask for comparing function Axel Lin
2013-07-01 3:17 ` Sonic Zhang
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.