Commit 2035d39d authored by Sebastian Hesselbarth's avatar Sebastian Hesselbarth

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: default avatarSebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Tested-by: default avatarAndrew Lunn <andrew@lunn.ch>
Tested-by: default avatarThomas Petazzoni <thomas.petazzoni@free-electrons.com>
parent e310b745
...@@ -55,15 +55,14 @@ ...@@ -55,15 +55,14 @@
#define CONFIG_PMU BIT(4) #define CONFIG_PMU BIT(4)
static int dove_pmu_mpp_ctrl_get(struct mvebu_mpp_ctrl *ctrl, static int dove_pmu_mpp_ctrl_get(unsigned pid, unsigned long *config)
unsigned long *config)
{ {
unsigned off = (ctrl->pid / MPPS_PER_REG) * MPP_BITS; unsigned off = (pid / MPPS_PER_REG) * MPP_BITS;
unsigned shift = (ctrl->pid % MPPS_PER_REG) * MPP_BITS; unsigned shift = (pid % MPPS_PER_REG) * MPP_BITS;
unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL); unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL);
unsigned long func; unsigned long func;
if (pmu & (1 << ctrl->pid)) { if (pmu & (1 << pid)) {
func = readl(DOVE_PMU_SIGNAL_SELECT_0 + off); func = readl(DOVE_PMU_SIGNAL_SELECT_0 + off);
*config = (func >> shift) & MPP_MASK; *config = (func >> shift) & MPP_MASK;
*config |= CONFIG_PMU; *config |= CONFIG_PMU;
...@@ -74,22 +73,21 @@ static int dove_pmu_mpp_ctrl_get(struct mvebu_mpp_ctrl *ctrl, ...@@ -74,22 +73,21 @@ static int dove_pmu_mpp_ctrl_get(struct mvebu_mpp_ctrl *ctrl,
return 0; return 0;
} }
static int dove_pmu_mpp_ctrl_set(struct mvebu_mpp_ctrl *ctrl, static int dove_pmu_mpp_ctrl_set(unsigned pid, unsigned long config)
unsigned long config)
{ {
unsigned off = (ctrl->pid / MPPS_PER_REG) * MPP_BITS; unsigned off = (pid / MPPS_PER_REG) * MPP_BITS;
unsigned shift = (ctrl->pid % MPPS_PER_REG) * MPP_BITS; unsigned shift = (pid % MPPS_PER_REG) * MPP_BITS;
unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL); unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL);
unsigned long func; unsigned long func;
if (config & CONFIG_PMU) { if (config & CONFIG_PMU) {
writel(pmu | (1 << ctrl->pid), DOVE_PMU_MPP_GENERAL_CTRL); writel(pmu | (1 << pid), DOVE_PMU_MPP_GENERAL_CTRL);
func = readl(DOVE_PMU_SIGNAL_SELECT_0 + off); func = readl(DOVE_PMU_SIGNAL_SELECT_0 + off);
func &= ~(MPP_MASK << shift); func &= ~(MPP_MASK << shift);
func |= (config & MPP_MASK) << shift; func |= (config & MPP_MASK) << shift;
writel(func, DOVE_PMU_SIGNAL_SELECT_0 + off); writel(func, DOVE_PMU_SIGNAL_SELECT_0 + off);
} else { } else {
writel(pmu & ~(1 << ctrl->pid), DOVE_PMU_MPP_GENERAL_CTRL); writel(pmu & ~(1 << pid), DOVE_PMU_MPP_GENERAL_CTRL);
func = readl(DOVE_MPP_VIRT_BASE + off); func = readl(DOVE_MPP_VIRT_BASE + off);
func &= ~(MPP_MASK << shift); func &= ~(MPP_MASK << shift);
func |= (config & MPP_MASK) << shift; func |= (config & MPP_MASK) << shift;
...@@ -98,13 +96,12 @@ static int dove_pmu_mpp_ctrl_set(struct mvebu_mpp_ctrl *ctrl, ...@@ -98,13 +96,12 @@ static int dove_pmu_mpp_ctrl_set(struct mvebu_mpp_ctrl *ctrl,
return 0; return 0;
} }
static int dove_mpp4_ctrl_get(struct mvebu_mpp_ctrl *ctrl, static int dove_mpp4_ctrl_get(unsigned pid, unsigned long *config)
unsigned long *config)
{ {
unsigned long mpp4 = readl(DOVE_MPP_CTRL4_VIRT_BASE); unsigned long mpp4 = readl(DOVE_MPP_CTRL4_VIRT_BASE);
unsigned long mask; unsigned long mask;
switch (ctrl->pid) { switch (pid) {
case 24: /* mpp_camera */ case 24: /* mpp_camera */
mask = DOVE_CAM_GPIO_SEL; mask = DOVE_CAM_GPIO_SEL;
break; break;
...@@ -129,13 +126,12 @@ static int dove_mpp4_ctrl_get(struct mvebu_mpp_ctrl *ctrl, ...@@ -129,13 +126,12 @@ static int dove_mpp4_ctrl_get(struct mvebu_mpp_ctrl *ctrl,
return 0; return 0;
} }
static int dove_mpp4_ctrl_set(struct mvebu_mpp_ctrl *ctrl, static int dove_mpp4_ctrl_set(unsigned pid, unsigned long config)
unsigned long config)
{ {
unsigned long mpp4 = readl(DOVE_MPP_CTRL4_VIRT_BASE); unsigned long mpp4 = readl(DOVE_MPP_CTRL4_VIRT_BASE);
unsigned long mask; unsigned long mask;
switch (ctrl->pid) { switch (pid) {
case 24: /* mpp_camera */ case 24: /* mpp_camera */
mask = DOVE_CAM_GPIO_SEL; mask = DOVE_CAM_GPIO_SEL;
break; break;
...@@ -164,8 +160,7 @@ static int dove_mpp4_ctrl_set(struct mvebu_mpp_ctrl *ctrl, ...@@ -164,8 +160,7 @@ static int dove_mpp4_ctrl_set(struct mvebu_mpp_ctrl *ctrl,
return 0; return 0;
} }
static int dove_nand_ctrl_get(struct mvebu_mpp_ctrl *ctrl, static int dove_nand_ctrl_get(unsigned pid, unsigned long *config)
unsigned long *config)
{ {
unsigned long gmpp = readl(DOVE_MPP_GENERAL_VIRT_BASE); unsigned long gmpp = readl(DOVE_MPP_GENERAL_VIRT_BASE);
...@@ -174,8 +169,7 @@ static int dove_nand_ctrl_get(struct mvebu_mpp_ctrl *ctrl, ...@@ -174,8 +169,7 @@ static int dove_nand_ctrl_get(struct mvebu_mpp_ctrl *ctrl,
return 0; return 0;
} }
static int dove_nand_ctrl_set(struct mvebu_mpp_ctrl *ctrl, static int dove_nand_ctrl_set(unsigned pid, unsigned long config)
unsigned long config)
{ {
unsigned long gmpp = readl(DOVE_MPP_GENERAL_VIRT_BASE); unsigned long gmpp = readl(DOVE_MPP_GENERAL_VIRT_BASE);
...@@ -188,8 +182,7 @@ static int dove_nand_ctrl_set(struct mvebu_mpp_ctrl *ctrl, ...@@ -188,8 +182,7 @@ static int dove_nand_ctrl_set(struct mvebu_mpp_ctrl *ctrl,
return 0; return 0;
} }
static int dove_audio0_ctrl_get(struct mvebu_mpp_ctrl *ctrl, static int dove_audio0_ctrl_get(unsigned pid, unsigned long *config)
unsigned long *config)
{ {
unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL); unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL);
...@@ -198,8 +191,7 @@ static int dove_audio0_ctrl_get(struct mvebu_mpp_ctrl *ctrl, ...@@ -198,8 +191,7 @@ static int dove_audio0_ctrl_get(struct mvebu_mpp_ctrl *ctrl,
return 0; return 0;
} }
static int dove_audio0_ctrl_set(struct mvebu_mpp_ctrl *ctrl, static int dove_audio0_ctrl_set(unsigned pid, unsigned long config)
unsigned long config)
{ {
unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL); unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL);
...@@ -211,8 +203,7 @@ static int dove_audio0_ctrl_set(struct mvebu_mpp_ctrl *ctrl, ...@@ -211,8 +203,7 @@ static int dove_audio0_ctrl_set(struct mvebu_mpp_ctrl *ctrl,
return 0; return 0;
} }
static int dove_audio1_ctrl_get(struct mvebu_mpp_ctrl *ctrl, static int dove_audio1_ctrl_get(unsigned pid, unsigned long *config)
unsigned long *config)
{ {
unsigned long mpp4 = readl(DOVE_MPP_CTRL4_VIRT_BASE); unsigned long mpp4 = readl(DOVE_MPP_CTRL4_VIRT_BASE);
unsigned long sspc1 = readl(DOVE_SSP_CTRL_STATUS_1); 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,8 +229,7 @@ static int dove_audio1_ctrl_get(struct mvebu_mpp_ctrl *ctrl,
return 0; return 0;
} }
static int dove_audio1_ctrl_set(struct mvebu_mpp_ctrl *ctrl, static int dove_audio1_ctrl_set(unsigned pid, unsigned long config)
unsigned long config)
{ {
unsigned long mpp4 = readl(DOVE_MPP_CTRL4_VIRT_BASE); unsigned long mpp4 = readl(DOVE_MPP_CTRL4_VIRT_BASE);
unsigned long sspc1 = readl(DOVE_SSP_CTRL_STATUS_1); 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,11 +266,11 @@ static int dove_audio1_ctrl_set(struct mvebu_mpp_ctrl *ctrl,
* break other functions. If you require all mpps as gpio * break other functions. If you require all mpps as gpio
* enforce gpio setting by pinctrl mapping. * enforce gpio setting by pinctrl mapping.
*/ */
static int dove_audio1_ctrl_gpio_req(struct mvebu_mpp_ctrl *ctrl, u8 pid) static int dove_audio1_ctrl_gpio_req(unsigned pid)
{ {
unsigned long config; unsigned long config;
dove_audio1_ctrl_get(ctrl, &config); dove_audio1_ctrl_get(pid, &config);
switch (config) { switch (config) {
case 0x02: /* i2s1 : gpio[56:57] */ 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,16 +293,14 @@ static int dove_audio1_ctrl_gpio_req(struct mvebu_mpp_ctrl *ctrl, u8 pid)
} }
/* mpp[52:57] has gpio pins capable of in and out */ /* mpp[52:57] has gpio pins capable of in and out */
static int dove_audio1_ctrl_gpio_dir(struct mvebu_mpp_ctrl *ctrl, u8 pid, static int dove_audio1_ctrl_gpio_dir(unsigned pid, bool input)
bool input)
{ {
if (pid < 52 || pid > 57) if (pid < 52 || pid > 57)
return -ENOTSUPP; return -ENOTSUPP;
return 0; return 0;
} }
static int dove_twsi_ctrl_get(struct mvebu_mpp_ctrl *ctrl, static int dove_twsi_ctrl_get(unsigned pid, unsigned long *config)
unsigned long *config)
{ {
unsigned long gcfg1 = readl(DOVE_GLOBAL_CONFIG_1); unsigned long gcfg1 = readl(DOVE_GLOBAL_CONFIG_1);
unsigned long gcfg2 = readl(DOVE_GLOBAL_CONFIG_2); unsigned long gcfg2 = readl(DOVE_GLOBAL_CONFIG_2);
...@@ -328,8 +316,7 @@ static int dove_twsi_ctrl_get(struct mvebu_mpp_ctrl *ctrl, ...@@ -328,8 +316,7 @@ static int dove_twsi_ctrl_get(struct mvebu_mpp_ctrl *ctrl,
return 0; return 0;
} }
static int dove_twsi_ctrl_set(struct mvebu_mpp_ctrl *ctrl, static int dove_twsi_ctrl_set(unsigned pid, unsigned long config)
unsigned long config)
{ {
unsigned long gcfg1 = readl(DOVE_GLOBAL_CONFIG_1); unsigned long gcfg1 = readl(DOVE_GLOBAL_CONFIG_1);
unsigned long gcfg2 = readl(DOVE_GLOBAL_CONFIG_2); unsigned long gcfg2 = readl(DOVE_GLOBAL_CONFIG_2);
......
...@@ -185,7 +185,7 @@ static int mvebu_pinconf_group_get(struct pinctrl_dev *pctldev, ...@@ -185,7 +185,7 @@ static int mvebu_pinconf_group_get(struct pinctrl_dev *pctldev,
return -EINVAL; return -EINVAL;
if (grp->ctrl->mpp_get) if (grp->ctrl->mpp_get)
return grp->ctrl->mpp_get(grp->ctrl, config); return grp->ctrl->mpp_get(grp->pins[0], config);
return mvebu_common_mpp_get(pctl, grp, config); return mvebu_common_mpp_get(pctl, grp, config);
} }
...@@ -203,7 +203,7 @@ static int mvebu_pinconf_group_set(struct pinctrl_dev *pctldev, ...@@ -203,7 +203,7 @@ static int mvebu_pinconf_group_set(struct pinctrl_dev *pctldev,
for (i = 0; i < num_configs; i++) { for (i = 0; i < num_configs; i++) {
if (grp->ctrl->mpp_set) if (grp->ctrl->mpp_set)
ret = grp->ctrl->mpp_set(grp->ctrl, configs[i]); ret = grp->ctrl->mpp_set(grp->pins[0], configs[i]);
else else
ret = mvebu_common_mpp_set(pctl, grp, configs[i]); ret = mvebu_common_mpp_set(pctl, grp, configs[i]);
...@@ -347,7 +347,7 @@ static int mvebu_pinmux_gpio_request_enable(struct pinctrl_dev *pctldev, ...@@ -347,7 +347,7 @@ static int mvebu_pinmux_gpio_request_enable(struct pinctrl_dev *pctldev,
return -EINVAL; return -EINVAL;
if (grp->ctrl->mpp_gpio_req) if (grp->ctrl->mpp_gpio_req)
return grp->ctrl->mpp_gpio_req(grp->ctrl, offset); return grp->ctrl->mpp_gpio_req(offset);
setting = mvebu_pinctrl_find_gpio_setting(pctl, grp); setting = mvebu_pinctrl_find_gpio_setting(pctl, grp);
if (!setting) if (!setting)
...@@ -370,7 +370,7 @@ static int mvebu_pinmux_gpio_set_direction(struct pinctrl_dev *pctldev, ...@@ -370,7 +370,7 @@ static int mvebu_pinmux_gpio_set_direction(struct pinctrl_dev *pctldev,
return -EINVAL; return -EINVAL;
if (grp->ctrl->mpp_gpio_dir) if (grp->ctrl->mpp_gpio_dir)
return grp->ctrl->mpp_gpio_dir(grp->ctrl, offset, input); return grp->ctrl->mpp_gpio_dir(offset, input);
setting = mvebu_pinctrl_find_gpio_setting(pctl, grp); setting = mvebu_pinctrl_find_gpio_setting(pctl, grp);
if (!setting) if (!setting)
......
...@@ -38,10 +38,10 @@ struct mvebu_mpp_ctrl { ...@@ -38,10 +38,10 @@ struct mvebu_mpp_ctrl {
u8 pid; u8 pid;
u8 npins; u8 npins;
unsigned *pins; unsigned *pins;
int (*mpp_get)(struct mvebu_mpp_ctrl *ctrl, unsigned long *config); int (*mpp_get)(unsigned pid, unsigned long *config);
int (*mpp_set)(struct mvebu_mpp_ctrl *ctrl, unsigned long config); int (*mpp_set)(unsigned pid, unsigned long config);
int (*mpp_gpio_req)(struct mvebu_mpp_ctrl *ctrl, u8 pid); int (*mpp_gpio_req)(unsigned pid);
int (*mpp_gpio_dir)(struct mvebu_mpp_ctrl *ctrl, u8 pid, bool input); int (*mpp_gpio_dir)(unsigned pid, bool input);
}; };
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment