aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl/mvebu
diff options
context:
space:
mode:
authorSebastian Hesselbarth <sebastian.hesselbarth@gmail.com>2014-01-30 16:25:05 -0500
committerSebastian Hesselbarth <sebastian.hesselbarth@gmail.com>2014-02-25 12:34:51 -0500
commit2035d39da18feba072bb49067b9984454dc4c07b (patch)
tree6b6b85ae2396c4b5835a9f35267ebe3d2a3fd212 /drivers/pinctrl/mvebu
parente310b745443e3142bcb268492409eeda3373f232 (diff)
pinctrl: mvebu: remove passing mvebu_mpp_ctrl to callbacks
The only valuable information a special callback can derive from mvebu_mpp_ctrl passed to it, is the pin id. Instead of passing the struct, pass the pid directly. Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Tested-by: Andrew Lunn <andrew@lunn.ch> Tested-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Diffstat (limited to 'drivers/pinctrl/mvebu')
-rw-r--r--drivers/pinctrl/mvebu/pinctrl-dove.c61
-rw-r--r--drivers/pinctrl/mvebu/pinctrl-mvebu.c8
-rw-r--r--drivers/pinctrl/mvebu/pinctrl-mvebu.h8
3 files changed, 32 insertions, 45 deletions
diff --git a/drivers/pinctrl/mvebu/pinctrl-dove.c b/drivers/pinctrl/mvebu/pinctrl-dove.c
index 47268393af34..c7d365f9009c 100644
--- a/drivers/pinctrl/mvebu/pinctrl-dove.c
+++ b/drivers/pinctrl/mvebu/pinctrl-dove.c
@@ -55,15 +55,14 @@
55 55
56#define CONFIG_PMU BIT(4) 56#define CONFIG_PMU BIT(4)
57 57
58static int dove_pmu_mpp_ctrl_get(struct mvebu_mpp_ctrl *ctrl, 58static int dove_pmu_mpp_ctrl_get(unsigned pid, unsigned long *config)
59 unsigned long *config)
60{ 59{
61 unsigned off = (ctrl->pid / MPPS_PER_REG) * MPP_BITS; 60 unsigned off = (pid / MPPS_PER_REG) * MPP_BITS;
62 unsigned shift = (ctrl->pid % MPPS_PER_REG) * MPP_BITS; 61 unsigned shift = (pid % MPPS_PER_REG) * MPP_BITS;
63 unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL); 62 unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL);
64 unsigned long func; 63 unsigned long func;
65 64
66 if (pmu & (1 << ctrl->pid)) { 65 if (pmu & (1 << pid)) {
67 func = readl(DOVE_PMU_SIGNAL_SELECT_0 + off); 66 func = readl(DOVE_PMU_SIGNAL_SELECT_0 + off);
68 *config = (func >> shift) & MPP_MASK; 67 *config = (func >> shift) & MPP_MASK;
69 *config |= CONFIG_PMU; 68 *config |= CONFIG_PMU;
@@ -74,22 +73,21 @@ static int dove_pmu_mpp_ctrl_get(struct mvebu_mpp_ctrl *ctrl,
74 return 0; 73 return 0;
75} 74}
76 75
77static int dove_pmu_mpp_ctrl_set(struct mvebu_mpp_ctrl *ctrl, 76static int dove_pmu_mpp_ctrl_set(unsigned pid, unsigned long config)
78 unsigned long config)
79{ 77{
80 unsigned off = (ctrl->pid / MPPS_PER_REG) * MPP_BITS; 78 unsigned off = (pid / MPPS_PER_REG) * MPP_BITS;
81 unsigned shift = (ctrl->pid % MPPS_PER_REG) * MPP_BITS; 79 unsigned shift = (pid % MPPS_PER_REG) * MPP_BITS;
82 unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL); 80 unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL);
83 unsigned long func; 81 unsigned long func;
84 82
85 if (config & CONFIG_PMU) { 83 if (config & CONFIG_PMU) {
86 writel(pmu | (1 << ctrl->pid), DOVE_PMU_MPP_GENERAL_CTRL); 84 writel(pmu | (1 << pid), DOVE_PMU_MPP_GENERAL_CTRL);
87 func = readl(DOVE_PMU_SIGNAL_SELECT_0 + off); 85 func = readl(DOVE_PMU_SIGNAL_SELECT_0 + off);
88 func &= ~(MPP_MASK << shift); 86 func &= ~(MPP_MASK << shift);
89 func |= (config & MPP_MASK) << shift; 87 func |= (config & MPP_MASK) << shift;
90 writel(func, DOVE_PMU_SIGNAL_SELECT_0 + off); 88 writel(func, DOVE_PMU_SIGNAL_SELECT_0 + off);
91 } else { 89 } else {
92 writel(pmu & ~(1 << ctrl->pid), DOVE_PMU_MPP_GENERAL_CTRL); 90 writel(pmu & ~(1 << pid), DOVE_PMU_MPP_GENERAL_CTRL);
93 func = readl(DOVE_MPP_VIRT_BASE + off); 91 func = readl(DOVE_MPP_VIRT_BASE + off);
94 func &= ~(MPP_MASK << shift); 92 func &= ~(MPP_MASK << shift);
95 func |= (config & MPP_MASK) << shift; 93 func |= (config & MPP_MASK) << shift;
@@ -98,13 +96,12 @@ static int dove_pmu_mpp_ctrl_set(struct mvebu_mpp_ctrl *ctrl,
98 return 0; 96 return 0;
99} 97}
100 98
101static int dove_mpp4_ctrl_get(struct mvebu_mpp_ctrl *ctrl, 99static int dove_mpp4_ctrl_get(unsigned pid, unsigned long *config)
102 unsigned long *config)
103{ 100{
104 unsigned long mpp4 = readl(DOVE_MPP_CTRL4_VIRT_BASE); 101 unsigned long mpp4 = readl(DOVE_MPP_CTRL4_VIRT_BASE);
105 unsigned long mask; 102 unsigned long mask;
106 103
107 switch (ctrl->pid) { 104 switch (pid) {
108 case 24: /* mpp_camera */ 105 case 24: /* mpp_camera */
109 mask = DOVE_CAM_GPIO_SEL; 106 mask = DOVE_CAM_GPIO_SEL;
110 break; 107 break;
@@ -129,13 +126,12 @@ static int dove_mpp4_ctrl_get(struct mvebu_mpp_ctrl *ctrl,
129 return 0; 126 return 0;
130} 127}
131 128
132static int dove_mpp4_ctrl_set(struct mvebu_mpp_ctrl *ctrl, 129static int dove_mpp4_ctrl_set(unsigned pid, unsigned long config)
133 unsigned long config)
134{ 130{
135 unsigned long mpp4 = readl(DOVE_MPP_CTRL4_VIRT_BASE); 131 unsigned long mpp4 = readl(DOVE_MPP_CTRL4_VIRT_BASE);
136 unsigned long mask; 132 unsigned long mask;
137 133
138 switch (ctrl->pid) { 134 switch (pid) {
139 case 24: /* mpp_camera */ 135 case 24: /* mpp_camera */
140 mask = DOVE_CAM_GPIO_SEL; 136 mask = DOVE_CAM_GPIO_SEL;
141 break; 137 break;
@@ -164,8 +160,7 @@ static int dove_mpp4_ctrl_set(struct mvebu_mpp_ctrl *ctrl,
164 return 0; 160 return 0;
165} 161}
166 162
167static int dove_nand_ctrl_get(struct mvebu_mpp_ctrl *ctrl, 163static int dove_nand_ctrl_get(unsigned pid, unsigned long *config)
168 unsigned long *config)
169{ 164{
170 unsigned long gmpp = readl(DOVE_MPP_GENERAL_VIRT_BASE); 165 unsigned long gmpp = readl(DOVE_MPP_GENERAL_VIRT_BASE);
171 166
@@ -174,8 +169,7 @@ static int dove_nand_ctrl_get(struct mvebu_mpp_ctrl *ctrl,
174 return 0; 169 return 0;
175} 170}
176 171
177static int dove_nand_ctrl_set(struct mvebu_mpp_ctrl *ctrl, 172static int dove_nand_ctrl_set(unsigned pid, unsigned long config)
178 unsigned long config)
179{ 173{
180 unsigned long gmpp = readl(DOVE_MPP_GENERAL_VIRT_BASE); 174 unsigned long gmpp = readl(DOVE_MPP_GENERAL_VIRT_BASE);
181 175
@@ -188,8 +182,7 @@ static int dove_nand_ctrl_set(struct mvebu_mpp_ctrl *ctrl,
188 return 0; 182 return 0;
189} 183}
190 184
191static int dove_audio0_ctrl_get(struct mvebu_mpp_ctrl *ctrl, 185static int dove_audio0_ctrl_get(unsigned pid, unsigned long *config)
192 unsigned long *config)
193{ 186{
194 unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL); 187 unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL);
195 188
@@ -198,8 +191,7 @@ static int dove_audio0_ctrl_get(struct mvebu_mpp_ctrl *ctrl,
198 return 0; 191 return 0;
199} 192}
200 193
201static int dove_audio0_ctrl_set(struct mvebu_mpp_ctrl *ctrl, 194static int dove_audio0_ctrl_set(unsigned pid, unsigned long config)
202 unsigned long config)
203{ 195{
204 unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL); 196 unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL);
205 197
@@ -211,8 +203,7 @@ static int dove_audio0_ctrl_set(struct mvebu_mpp_ctrl *ctrl,
211 return 0; 203 return 0;
212} 204}
213 205
214static int dove_audio1_ctrl_get(struct mvebu_mpp_ctrl *ctrl, 206static int dove_audio1_ctrl_get(unsigned pid, unsigned long *config)
215 unsigned long *config)
216{ 207{
217 unsigned long mpp4 = readl(DOVE_MPP_CTRL4_VIRT_BASE); 208 unsigned long mpp4 = readl(DOVE_MPP_CTRL4_VIRT_BASE);
218 unsigned long sspc1 = readl(DOVE_SSP_CTRL_STATUS_1); 209 unsigned long sspc1 = readl(DOVE_SSP_CTRL_STATUS_1);
@@ -238,8 +229,7 @@ static int dove_audio1_ctrl_get(struct mvebu_mpp_ctrl *ctrl,
238 return 0; 229 return 0;
239} 230}
240 231
241static int dove_audio1_ctrl_set(struct mvebu_mpp_ctrl *ctrl, 232static int dove_audio1_ctrl_set(unsigned pid, unsigned long config)
242 unsigned long config)
243{ 233{
244 unsigned long mpp4 = readl(DOVE_MPP_CTRL4_VIRT_BASE); 234 unsigned long mpp4 = readl(DOVE_MPP_CTRL4_VIRT_BASE);
245 unsigned long sspc1 = readl(DOVE_SSP_CTRL_STATUS_1); 235 unsigned long sspc1 = readl(DOVE_SSP_CTRL_STATUS_1);
@@ -276,11 +266,11 @@ static int dove_audio1_ctrl_set(struct mvebu_mpp_ctrl *ctrl,
276 * break other functions. If you require all mpps as gpio 266 * break other functions. If you require all mpps as gpio
277 * enforce gpio setting by pinctrl mapping. 267 * enforce gpio setting by pinctrl mapping.
278 */ 268 */
279static int dove_audio1_ctrl_gpio_req(struct mvebu_mpp_ctrl *ctrl, u8 pid) 269static int dove_audio1_ctrl_gpio_req(unsigned pid)
280{ 270{
281 unsigned long config; 271 unsigned long config;
282 272
283 dove_audio1_ctrl_get(ctrl, &config); 273 dove_audio1_ctrl_get(pid, &config);
284 274
285 switch (config) { 275 switch (config) {
286 case 0x02: /* i2s1 : gpio[56:57] */ 276 case 0x02: /* i2s1 : gpio[56:57] */
@@ -303,16 +293,14 @@ static int dove_audio1_ctrl_gpio_req(struct mvebu_mpp_ctrl *ctrl, u8 pid)
303} 293}
304 294
305/* mpp[52:57] has gpio pins capable of in and out */ 295/* mpp[52:57] has gpio pins capable of in and out */
306static int dove_audio1_ctrl_gpio_dir(struct mvebu_mpp_ctrl *ctrl, u8 pid, 296static int dove_audio1_ctrl_gpio_dir(unsigned pid, bool input)
307 bool input)
308{ 297{
309 if (pid < 52 || pid > 57) 298 if (pid < 52 || pid > 57)
310 return -ENOTSUPP; 299 return -ENOTSUPP;
311 return 0; 300 return 0;
312} 301}
313 302
314static int dove_twsi_ctrl_get(struct mvebu_mpp_ctrl *ctrl, 303static int dove_twsi_ctrl_get(unsigned pid, unsigned long *config)
315 unsigned long *config)
316{ 304{
317 unsigned long gcfg1 = readl(DOVE_GLOBAL_CONFIG_1); 305 unsigned long gcfg1 = readl(DOVE_GLOBAL_CONFIG_1);
318 unsigned long gcfg2 = readl(DOVE_GLOBAL_CONFIG_2); 306 unsigned long gcfg2 = readl(DOVE_GLOBAL_CONFIG_2);
@@ -328,8 +316,7 @@ static int dove_twsi_ctrl_get(struct mvebu_mpp_ctrl *ctrl,
328 return 0; 316 return 0;
329} 317}
330 318
331static int dove_twsi_ctrl_set(struct mvebu_mpp_ctrl *ctrl, 319static int dove_twsi_ctrl_set(unsigned pid, unsigned long config)
332 unsigned long config)
333{ 320{
334 unsigned long gcfg1 = readl(DOVE_GLOBAL_CONFIG_1); 321 unsigned long gcfg1 = readl(DOVE_GLOBAL_CONFIG_1);
335 unsigned long gcfg2 = readl(DOVE_GLOBAL_CONFIG_2); 322 unsigned long gcfg2 = readl(DOVE_GLOBAL_CONFIG_2);
diff --git a/drivers/pinctrl/mvebu/pinctrl-mvebu.c b/drivers/pinctrl/mvebu/pinctrl-mvebu.c
index 2be432444124..873aef5bdd9c 100644
--- a/drivers/pinctrl/mvebu/pinctrl-mvebu.c
+++ b/drivers/pinctrl/mvebu/pinctrl-mvebu.c
@@ -185,7 +185,7 @@ static int mvebu_pinconf_group_get(struct pinctrl_dev *pctldev,
185 return -EINVAL; 185 return -EINVAL;
186 186
187 if (grp->ctrl->mpp_get) 187 if (grp->ctrl->mpp_get)
188 return grp->ctrl->mpp_get(grp->ctrl, config); 188 return grp->ctrl->mpp_get(grp->pins[0], config);
189 189
190 return mvebu_common_mpp_get(pctl, grp, config); 190 return mvebu_common_mpp_get(pctl, grp, config);
191} 191}
@@ -203,7 +203,7 @@ static int mvebu_pinconf_group_set(struct pinctrl_dev *pctldev,
203 203
204 for (i = 0; i < num_configs; i++) { 204 for (i = 0; i < num_configs; i++) {
205 if (grp->ctrl->mpp_set) 205 if (grp->ctrl->mpp_set)
206 ret = grp->ctrl->mpp_set(grp->ctrl, configs[i]); 206 ret = grp->ctrl->mpp_set(grp->pins[0], configs[i]);
207 else 207 else
208 ret = mvebu_common_mpp_set(pctl, grp, configs[i]); 208 ret = mvebu_common_mpp_set(pctl, grp, configs[i]);
209 209
@@ -347,7 +347,7 @@ static int mvebu_pinmux_gpio_request_enable(struct pinctrl_dev *pctldev,
347 return -EINVAL; 347 return -EINVAL;
348 348
349 if (grp->ctrl->mpp_gpio_req) 349 if (grp->ctrl->mpp_gpio_req)
350 return grp->ctrl->mpp_gpio_req(grp->ctrl, offset); 350 return grp->ctrl->mpp_gpio_req(offset);
351 351
352 setting = mvebu_pinctrl_find_gpio_setting(pctl, grp); 352 setting = mvebu_pinctrl_find_gpio_setting(pctl, grp);
353 if (!setting) 353 if (!setting)
@@ -370,7 +370,7 @@ static int mvebu_pinmux_gpio_set_direction(struct pinctrl_dev *pctldev,
370 return -EINVAL; 370 return -EINVAL;
371 371
372 if (grp->ctrl->mpp_gpio_dir) 372 if (grp->ctrl->mpp_gpio_dir)
373 return grp->ctrl->mpp_gpio_dir(grp->ctrl, offset, input); 373 return grp->ctrl->mpp_gpio_dir(offset, input);
374 374
375 setting = mvebu_pinctrl_find_gpio_setting(pctl, grp); 375 setting = mvebu_pinctrl_find_gpio_setting(pctl, grp);
376 if (!setting) 376 if (!setting)
diff --git a/drivers/pinctrl/mvebu/pinctrl-mvebu.h b/drivers/pinctrl/mvebu/pinctrl-mvebu.h
index 90bd3beee860..b20d1d778c75 100644
--- a/drivers/pinctrl/mvebu/pinctrl-mvebu.h
+++ b/drivers/pinctrl/mvebu/pinctrl-mvebu.h
@@ -38,10 +38,10 @@ struct mvebu_mpp_ctrl {
38 u8 pid; 38 u8 pid;
39 u8 npins; 39 u8 npins;
40 unsigned *pins; 40 unsigned *pins;
41 int (*mpp_get)(struct mvebu_mpp_ctrl *ctrl, unsigned long *config); 41 int (*mpp_get)(unsigned pid, unsigned long *config);
42 int (*mpp_set)(struct mvebu_mpp_ctrl *ctrl, unsigned long config); 42 int (*mpp_set)(unsigned pid, unsigned long config);
43 int (*mpp_gpio_req)(struct mvebu_mpp_ctrl *ctrl, u8 pid); 43 int (*mpp_gpio_req)(unsigned pid);
44 int (*mpp_gpio_dir)(struct mvebu_mpp_ctrl *ctrl, u8 pid, bool input); 44 int (*mpp_gpio_dir)(unsigned pid, bool input);
45}; 45};
46 46
47/** 47/**