pinctrl: mvebu: remove common get/set functions
With every SoC always providing its own get/set callbacks, we can now remove the generic ones, remove the obsolete base address, and always use the provided callbacks. 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>
This commit is contained in:
parent
1217b790ae
commit
faaa8325ad
@ -50,7 +50,6 @@ struct mvebu_pinctrl {
|
|||||||
struct device *dev;
|
struct device *dev;
|
||||||
struct pinctrl_dev *pctldev;
|
struct pinctrl_dev *pctldev;
|
||||||
struct pinctrl_desc desc;
|
struct pinctrl_desc desc;
|
||||||
void __iomem *base;
|
|
||||||
struct mvebu_pinctrl_group *groups;
|
struct mvebu_pinctrl_group *groups;
|
||||||
unsigned num_groups;
|
unsigned num_groups;
|
||||||
struct mvebu_pinctrl_function *functions;
|
struct mvebu_pinctrl_function *functions;
|
||||||
@ -138,43 +137,6 @@ static struct mvebu_pinctrl_function *mvebu_pinctrl_find_function_by_name(
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Common mpp pin configuration registers on MVEBU are
|
|
||||||
* registers of eight 4-bit values for each mpp setting.
|
|
||||||
* Register offset and bit mask are calculated accordingly below.
|
|
||||||
*/
|
|
||||||
static int mvebu_common_mpp_get(struct mvebu_pinctrl *pctl,
|
|
||||||
struct mvebu_pinctrl_group *grp,
|
|
||||||
unsigned long *config)
|
|
||||||
{
|
|
||||||
unsigned pin = grp->gid;
|
|
||||||
unsigned off = (pin / MPPS_PER_REG) * MPP_BITS;
|
|
||||||
unsigned shift = (pin % MPPS_PER_REG) * MPP_BITS;
|
|
||||||
|
|
||||||
*config = readl(pctl->base + off);
|
|
||||||
*config >>= shift;
|
|
||||||
*config &= MPP_MASK;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int mvebu_common_mpp_set(struct mvebu_pinctrl *pctl,
|
|
||||||
struct mvebu_pinctrl_group *grp,
|
|
||||||
unsigned long config)
|
|
||||||
{
|
|
||||||
unsigned pin = grp->gid;
|
|
||||||
unsigned off = (pin / MPPS_PER_REG) * MPP_BITS;
|
|
||||||
unsigned shift = (pin % MPPS_PER_REG) * MPP_BITS;
|
|
||||||
unsigned long reg;
|
|
||||||
|
|
||||||
reg = readl(pctl->base + off);
|
|
||||||
reg &= ~(MPP_MASK << shift);
|
|
||||||
reg |= (config << shift);
|
|
||||||
writel(reg, pctl->base + off);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int mvebu_pinconf_group_get(struct pinctrl_dev *pctldev,
|
static int mvebu_pinconf_group_get(struct pinctrl_dev *pctldev,
|
||||||
unsigned gid, unsigned long *config)
|
unsigned gid, unsigned long *config)
|
||||||
{
|
{
|
||||||
@ -184,10 +146,7 @@ static int mvebu_pinconf_group_get(struct pinctrl_dev *pctldev,
|
|||||||
if (!grp->ctrl)
|
if (!grp->ctrl)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (grp->ctrl->mpp_get)
|
return grp->ctrl->mpp_get(grp->pins[0], config);
|
||||||
return grp->ctrl->mpp_get(grp->pins[0], config);
|
|
||||||
|
|
||||||
return mvebu_common_mpp_get(pctl, grp, config);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mvebu_pinconf_group_set(struct pinctrl_dev *pctldev,
|
static int mvebu_pinconf_group_set(struct pinctrl_dev *pctldev,
|
||||||
@ -202,11 +161,7 @@ static int mvebu_pinconf_group_set(struct pinctrl_dev *pctldev,
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
for (i = 0; i < num_configs; i++) {
|
for (i = 0; i < num_configs; i++) {
|
||||||
if (grp->ctrl->mpp_set)
|
ret = grp->ctrl->mpp_set(grp->pins[0], configs[i]);
|
||||||
ret = grp->ctrl->mpp_set(grp->pins[0], configs[i]);
|
|
||||||
else
|
|
||||||
ret = mvebu_common_mpp_set(pctl, grp, configs[i]);
|
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
} /* for each config */
|
} /* for each config */
|
||||||
|
Loading…
Reference in New Issue
Block a user