aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ramips/patches-3.10/999-pinctrl_fixes.patch
blob: d7ad676f096672bf4747ad4fa03f5a477fe5207c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
--- a/drivers/pinctrl/pinctrl-rt2880.c
+++ b/drivers/pinctrl/pinctrl-rt2880.c
@@ -204,6 +204,7 @@ static int rt2880_pmx_group_enable(struc
 {
 	struct rt2880_priv *p = pinctrl_dev_get_drvdata(pctrldev);
         u32 mode = 0;
+	int i;
 
 	/* dont allow double use */
 	if (p->groups[group].enabled) {
@@ -217,16 +218,16 @@ static int rt2880_pmx_group_enable(struc
 	mode = rt_sysc_r32(SYSC_REG_GPIO_MODE);
 	mode &= ~(p->groups[group].mask << p->groups[group].shift);
 
+	/* mark the pins as gpio */
+	for (i = 0; i < p->groups[group].func[0].pin_count; i++)
+		p->gpio[p->groups[group].func[0].pins[i]] = 1;
+
 	/* function 0 is gpio and needs special handling */
 	if (func == 0) {
-		int i;
-
-
 		mode |= p->groups[group].gpio << p->groups[group].shift;
-		/* mark the pins as gpio */
-		for (i = 0; i < p->groups[group].func[0].pin_count; i++)
-			p->gpio[p->groups[group].func[0].pins[i]] = 1;
 	} else {
+		for (i = 0; i < p->func[func]->pin_count; i++)
+			p->gpio[p->func[func]->pins[i]] = 0;
 		mode |= p->func[func]->value << p->groups[group].shift;
 	}
 	rt_sysc_w32(mode, SYSC_REG_GPIO_MODE);