aboutsummaryrefslogtreecommitdiffstats
path: root/arch/blackfin/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'arch/blackfin/kernel')
-rw-r--r--arch/blackfin/kernel/bfin_gpio.c23
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)