diff options
author | Sonic Zhang <sonic.zhang@analog.com> | 2013-06-30 23:24:46 -0400 |
---|---|---|
committer | Steven Miao <realmz6@gmail.com> | 2013-11-15 04:33:41 -0500 |
commit | f70de486b2dd21b60705e57afecdc5f6a79be4e7 (patch) | |
tree | 636ec819180492fc6d6f2947e111fda26a35efde /arch/blackfin/kernel | |
parent | 5e01dc7b26d9f24f39abace5da98ccbd6a5ceb52 (diff) |
Blackfin: bfin_gpio: Use proper mask for comparing pfunc
For BF537_FAMILY, when offset != 1, the mask is 1.
Thus add proper mask for comparing pfunc with function.
Also has small refactor for better readability.
In portmux_setup(), it looks odd having "pmux &= ~(3 << 1);"
while in current code we do pmux |= (function << offset);.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
Diffstat (limited to 'arch/blackfin/kernel')
-rw-r--r-- | arch/blackfin/kernel/bfin_gpio.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/arch/blackfin/kernel/bfin_gpio.c b/arch/blackfin/kernel/bfin_gpio.c index ed978f1c5cb9..780d27db1257 100644 --- a/arch/blackfin/kernel/bfin_gpio.c +++ b/arch/blackfin/kernel/bfin_gpio.c | |||
@@ -255,7 +255,7 @@ static int portmux_group_check(unsigned short per) | |||
255 | u16 ident = P_IDENT(per); | 255 | u16 ident = P_IDENT(per); |
256 | u16 function = P_FUNCT2MUX(per); | 256 | u16 function = P_FUNCT2MUX(per); |
257 | s8 offset = port_mux[ident]; | 257 | s8 offset = port_mux[ident]; |
258 | u16 m, pmux, pfunc; | 258 | u16 m, pmux, pfunc, mask; |
259 | 259 | ||
260 | if (offset < 0) | 260 | if (offset < 0) |
261 | return 0; | 261 | return 0; |
@@ -270,10 +270,12 @@ static int portmux_group_check(unsigned short per) | |||
270 | continue; | 270 | continue; |
271 | 271 | ||
272 | if (offset == 1) | 272 | if (offset == 1) |
273 | pfunc = (pmux >> offset) & 3; | 273 | mask = 3; |
274 | else | 274 | else |
275 | pfunc = (pmux >> offset) & 1; | 275 | mask = 1; |
276 | if (pfunc != function) { | 276 | |
277 | pfunc = (pmux >> offset) & mask; | ||
278 | if (pfunc != (function & mask)) { | ||
277 | pr_err("pin group conflict! request pin %d func %d conflict with pin %d func %d\n", | 279 | pr_err("pin group conflict! request pin %d func %d conflict with pin %d func %d\n", |
278 | ident, function, m, pfunc); | 280 | ident, function, m, pfunc); |
279 | return -EINVAL; | 281 | return -EINVAL; |
@@ -288,17 +290,20 @@ static void portmux_setup(unsigned short per) | |||
288 | u16 ident = P_IDENT(per); | 290 | u16 ident = P_IDENT(per); |
289 | u16 function = P_FUNCT2MUX(per); | 291 | u16 function = P_FUNCT2MUX(per); |
290 | s8 offset = port_mux[ident]; | 292 | s8 offset = port_mux[ident]; |
291 | u16 pmux; | 293 | u16 pmux, mask; |
292 | 294 | ||
293 | if (offset == -1) | 295 | if (offset == -1) |
294 | return; | 296 | return; |
295 | 297 | ||
296 | pmux = bfin_read_PORT_MUX(); | 298 | pmux = bfin_read_PORT_MUX(); |
297 | if (offset != 1) | 299 | if (offset == 1) |
298 | pmux &= ~(1 << offset); | 300 | mask = 3; |
299 | else | 301 | else |
300 | pmux &= ~(3 << 1); | 302 | mask = 1; |
301 | pmux |= (function << offset); | 303 | |
304 | pmux &= ~(mask << offset); | ||
305 | pmux |= ((function & mask) << offset); | ||
306 | |||
302 | bfin_write_PORT_MUX(pmux); | 307 | bfin_write_PORT_MUX(pmux); |
303 | } | 308 | } |
304 | #elif defined(CONFIG_BF54x) || defined(CONFIG_BF60x) | 309 | #elif defined(CONFIG_BF54x) || defined(CONFIG_BF60x) |