Skip to content

Commit 2035d39

Browse files
committed
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>
1 parent e310b74 commit 2035d39

3 files changed

Lines changed: 32 additions & 45 deletions

File tree

‎drivers/pinctrl/mvebu/pinctrl-dove.c‎

Lines changed: 24 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,14 @@
5555

5656
#define CONFIG_PMU BIT(4)
5757

58-
static int dove_pmu_mpp_ctrl_get(struct mvebu_mpp_ctrl *ctrl,
59-
unsigned long *config)
58+
static int dove_pmu_mpp_ctrl_get(unsigned pid, unsigned long *config)
6059
{
61-
unsigned off = (ctrl->pid / MPPS_PER_REG) * MPP_BITS;
62-
unsigned shift = (ctrl->pid % MPPS_PER_REG) * MPP_BITS;
60+
unsigned off = (pid / MPPS_PER_REG) * MPP_BITS;
61+
unsigned shift = (pid % MPPS_PER_REG) * MPP_BITS;
6362
unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL);
6463
unsigned long func;
6564

66-
if (pmu & (1 << ctrl->pid)) {
65+
if (pmu & (1 << pid)) {
6766
func = readl(DOVE_PMU_SIGNAL_SELECT_0 + off);
6867
*config = (func >> shift) & MPP_MASK;
6968
*config |= CONFIG_PMU;
@@ -74,22 +73,21 @@ static int dove_pmu_mpp_ctrl_get(struct mvebu_mpp_ctrl *ctrl,
7473
return 0;
7574
}
7675

77-
static int dove_pmu_mpp_ctrl_set(struct mvebu_mpp_ctrl *ctrl,
78-
unsigned long config)
76+
static int dove_pmu_mpp_ctrl_set(unsigned pid, unsigned long config)
7977
{
80-
unsigned off = (ctrl->pid / MPPS_PER_REG) * MPP_BITS;
81-
unsigned shift = (ctrl->pid % MPPS_PER_REG) * MPP_BITS;
78+
unsigned off = (pid / MPPS_PER_REG) * MPP_BITS;
79+
unsigned shift = (pid % MPPS_PER_REG) * MPP_BITS;
8280
unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL);
8381
unsigned long func;
8482

8583
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);
8785
func = readl(DOVE_PMU_SIGNAL_SELECT_0 + off);
8886
func &= ~(MPP_MASK << shift);
8987
func |= (config & MPP_MASK) << shift;
9088
writel(func, DOVE_PMU_SIGNAL_SELECT_0 + off);
9189
} else {
92-
writel(pmu & ~(1 << ctrl->pid), DOVE_PMU_MPP_GENERAL_CTRL);
90+
writel(pmu & ~(1 << pid), DOVE_PMU_MPP_GENERAL_CTRL);
9391
func = readl(DOVE_MPP_VIRT_BASE + off);
9492
func &= ~(MPP_MASK << shift);
9593
func |= (config & MPP_MASK) << shift;
@@ -98,13 +96,12 @@ static int dove_pmu_mpp_ctrl_set(struct mvebu_mpp_ctrl *ctrl,
9896
return 0;
9997
}
10098

101-
static int dove_mpp4_ctrl_get(struct mvebu_mpp_ctrl *ctrl,
102-
unsigned long *config)
99+
static int dove_mpp4_ctrl_get(unsigned pid, unsigned long *config)
103100
{
104101
unsigned long mpp4 = readl(DOVE_MPP_CTRL4_VIRT_BASE);
105102
unsigned long mask;
106103

107-
switch (ctrl->pid) {
104+
switch (pid) {
108105
case 24: /* mpp_camera */
109106
mask = DOVE_CAM_GPIO_SEL;
110107
break;
@@ -129,13 +126,12 @@ static int dove_mpp4_ctrl_get(struct mvebu_mpp_ctrl *ctrl,
129126
return 0;
130127
}
131128

132-
static int dove_mpp4_ctrl_set(struct mvebu_mpp_ctrl *ctrl,
133-
unsigned long config)
129+
static int dove_mpp4_ctrl_set(unsigned pid, unsigned long config)
134130
{
135131
unsigned long mpp4 = readl(DOVE_MPP_CTRL4_VIRT_BASE);
136132
unsigned long mask;
137133

138-
switch (ctrl->pid) {
134+
switch (pid) {
139135
case 24: /* mpp_camera */
140136
mask = DOVE_CAM_GPIO_SEL;
141137
break;
@@ -164,8 +160,7 @@ static int dove_mpp4_ctrl_set(struct mvebu_mpp_ctrl *ctrl,
164160
return 0;
165161
}
166162

167-
static int dove_nand_ctrl_get(struct mvebu_mpp_ctrl *ctrl,
168-
unsigned long *config)
163+
static int dove_nand_ctrl_get(unsigned pid, unsigned long *config)
169164
{
170165
unsigned long gmpp = readl(DOVE_MPP_GENERAL_VIRT_BASE);
171166

@@ -174,8 +169,7 @@ static int dove_nand_ctrl_get(struct mvebu_mpp_ctrl *ctrl,
174169
return 0;
175170
}
176171

177-
static int dove_nand_ctrl_set(struct mvebu_mpp_ctrl *ctrl,
178-
unsigned long config)
172+
static int dove_nand_ctrl_set(unsigned pid, unsigned long config)
179173
{
180174
unsigned long gmpp = readl(DOVE_MPP_GENERAL_VIRT_BASE);
181175

@@ -188,8 +182,7 @@ static int dove_nand_ctrl_set(struct mvebu_mpp_ctrl *ctrl,
188182
return 0;
189183
}
190184

191-
static int dove_audio0_ctrl_get(struct mvebu_mpp_ctrl *ctrl,
192-
unsigned long *config)
185+
static int dove_audio0_ctrl_get(unsigned pid, unsigned long *config)
193186
{
194187
unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL);
195188

@@ -198,8 +191,7 @@ static int dove_audio0_ctrl_get(struct mvebu_mpp_ctrl *ctrl,
198191
return 0;
199192
}
200193

201-
static int dove_audio0_ctrl_set(struct mvebu_mpp_ctrl *ctrl,
202-
unsigned long config)
194+
static int dove_audio0_ctrl_set(unsigned pid, unsigned long config)
203195
{
204196
unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL);
205197

@@ -211,8 +203,7 @@ static int dove_audio0_ctrl_set(struct mvebu_mpp_ctrl *ctrl,
211203
return 0;
212204
}
213205

214-
static int dove_audio1_ctrl_get(struct mvebu_mpp_ctrl *ctrl,
215-
unsigned long *config)
206+
static int dove_audio1_ctrl_get(unsigned pid, unsigned long *config)
216207
{
217208
unsigned long mpp4 = readl(DOVE_MPP_CTRL4_VIRT_BASE);
218209
unsigned long sspc1 = readl(DOVE_SSP_CTRL_STATUS_1);
@@ -238,8 +229,7 @@ static int dove_audio1_ctrl_get(struct mvebu_mpp_ctrl *ctrl,
238229
return 0;
239230
}
240231

241-
static int dove_audio1_ctrl_set(struct mvebu_mpp_ctrl *ctrl,
242-
unsigned long config)
232+
static int dove_audio1_ctrl_set(unsigned pid, unsigned long config)
243233
{
244234
unsigned long mpp4 = readl(DOVE_MPP_CTRL4_VIRT_BASE);
245235
unsigned long sspc1 = readl(DOVE_SSP_CTRL_STATUS_1);
@@ -276,11 +266,11 @@ static int dove_audio1_ctrl_set(struct mvebu_mpp_ctrl *ctrl,
276266
* break other functions. If you require all mpps as gpio
277267
* enforce gpio setting by pinctrl mapping.
278268
*/
279-
static int dove_audio1_ctrl_gpio_req(struct mvebu_mpp_ctrl *ctrl, u8 pid)
269+
static int dove_audio1_ctrl_gpio_req(unsigned pid)
280270
{
281271
unsigned long config;
282272

283-
dove_audio1_ctrl_get(ctrl, &config);
273+
dove_audio1_ctrl_get(pid, &config);
284274

285275
switch (config) {
286276
case 0x02: /* i2s1 : gpio[56:57] */
@@ -303,16 +293,14 @@ static int dove_audio1_ctrl_gpio_req(struct mvebu_mpp_ctrl *ctrl, u8 pid)
303293
}
304294

305295
/* mpp[52:57] has gpio pins capable of in and out */
306-
static int dove_audio1_ctrl_gpio_dir(struct mvebu_mpp_ctrl *ctrl, u8 pid,
307-
bool input)
296+
static int dove_audio1_ctrl_gpio_dir(unsigned pid, bool input)
308297
{
309298
if (pid < 52 || pid > 57)
310299
return -ENOTSUPP;
311300
return 0;
312301
}
313302

314-
static int dove_twsi_ctrl_get(struct mvebu_mpp_ctrl *ctrl,
315-
unsigned long *config)
303+
static int dove_twsi_ctrl_get(unsigned pid, unsigned long *config)
316304
{
317305
unsigned long gcfg1 = readl(DOVE_GLOBAL_CONFIG_1);
318306
unsigned long gcfg2 = readl(DOVE_GLOBAL_CONFIG_2);
@@ -328,8 +316,7 @@ static int dove_twsi_ctrl_get(struct mvebu_mpp_ctrl *ctrl,
328316
return 0;
329317
}
330318

331-
static int dove_twsi_ctrl_set(struct mvebu_mpp_ctrl *ctrl,
332-
unsigned long config)
319+
static int dove_twsi_ctrl_set(unsigned pid, unsigned long config)
333320
{
334321
unsigned long gcfg1 = readl(DOVE_GLOBAL_CONFIG_1);
335322
unsigned long gcfg2 = readl(DOVE_GLOBAL_CONFIG_2);

‎drivers/pinctrl/mvebu/pinctrl-mvebu.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ static int mvebu_pinconf_group_get(struct pinctrl_dev *pctldev,
185185
return -EINVAL;
186186

187187
if (grp->ctrl->mpp_get)
188-
return grp->ctrl->mpp_get(grp->ctrl, config);
188+
return grp->ctrl->mpp_get(grp->pins[0], config);
189189

190190
return mvebu_common_mpp_get(pctl, grp, config);
191191
}
@@ -203,7 +203,7 @@ static int mvebu_pinconf_group_set(struct pinctrl_dev *pctldev,
203203

204204
for (i = 0; i < num_configs; i++) {
205205
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]);
207207
else
208208
ret = mvebu_common_mpp_set(pctl, grp, configs[i]);
209209

@@ -347,7 +347,7 @@ static int mvebu_pinmux_gpio_request_enable(struct pinctrl_dev *pctldev,
347347
return -EINVAL;
348348

349349
if (grp->ctrl->mpp_gpio_req)
350-
return grp->ctrl->mpp_gpio_req(grp->ctrl, offset);
350+
return grp->ctrl->mpp_gpio_req(offset);
351351

352352
setting = mvebu_pinctrl_find_gpio_setting(pctl, grp);
353353
if (!setting)
@@ -370,7 +370,7 @@ static int mvebu_pinmux_gpio_set_direction(struct pinctrl_dev *pctldev,
370370
return -EINVAL;
371371

372372
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);
374374

375375
setting = mvebu_pinctrl_find_gpio_setting(pctl, grp);
376376
if (!setting)

‎drivers/pinctrl/mvebu/pinctrl-mvebu.h‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ struct mvebu_mpp_ctrl {
3838
u8 pid;
3939
u8 npins;
4040
unsigned *pins;
41-
int (*mpp_get)(struct mvebu_mpp_ctrl *ctrl, unsigned long *config);
42-
int (*mpp_set)(struct mvebu_mpp_ctrl *ctrl, unsigned long config);
43-
int (*mpp_gpio_req)(struct mvebu_mpp_ctrl *ctrl, u8 pid);
44-
int (*mpp_gpio_dir)(struct mvebu_mpp_ctrl *ctrl, u8 pid, bool input);
41+
int (*mpp_get)(unsigned pid, unsigned long *config);
42+
int (*mpp_set)(unsigned pid, unsigned long config);
43+
int (*mpp_gpio_req)(unsigned pid);
44+
int (*mpp_gpio_dir)(unsigned pid, bool input);
4545
};
4646

4747
/**

0 commit comments

Comments
 (0)