summaryrefslogtreecommitdiff
path: root/arch/blackfin/cpu
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@ingics.com>2013-06-28 14:45:06 +0800
committerSonic Zhang <sonic.zhang@analog.com>2013-07-31 16:56:03 +0800
commit9868b1426315fc5ac4883b5267d5337b2dfcbd95 (patch)
treeefbdc234058f9534633c840c00db8129f77b02d4 /arch/blackfin/cpu
parent2ced773a1ac20de2bf3d642944eb8de028420573 (diff)
downloadu-boot-imx-9868b1426315fc5ac4883b5267d5337b2dfcbd95.zip
u-boot-imx-9868b1426315fc5ac4883b5267d5337b2dfcbd95.tar.gz
u-boot-imx-9868b1426315fc5ac4883b5267d5337b2dfcbd95.tar.bz2
blackfin: gpio: Use proper mask for comparing function
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>
Diffstat (limited to 'arch/blackfin/cpu')
-rw-r--r--arch/blackfin/cpu/gpio.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/arch/blackfin/cpu/gpio.c b/arch/blackfin/cpu/gpio.c
index a4d10d5..f9aff4d 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);
}
}