Commit 17bdec67 authored by Sebastian Hesselbarth's avatar Sebastian Hesselbarth

pinctrl: mvebu: dove: provide generic mpp callbacks

We want to get rid of passing register addresses to common pinctrl
driver, so provide set/get callbacks that use generic mpp pins helper
and will be used later. While at it, also make use of globally defined
MPP macros.
Signed-off-by: default avatarSebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
parent f5b85e42
...@@ -49,48 +49,56 @@ ...@@ -49,48 +49,56 @@
#define DOVE_SD1_GPIO_SEL BIT(1) #define DOVE_SD1_GPIO_SEL BIT(1)
#define DOVE_SD0_GPIO_SEL BIT(0) #define DOVE_SD0_GPIO_SEL BIT(0)
#define MPPS_PER_REG 8
#define MPP_BITS 4
#define MPP_MASK 0xf
#define CONFIG_PMU BIT(4) #define CONFIG_PMU BIT(4)
static void __iomem *mpp_base;
static int dove_mpp_ctrl_get(unsigned pid, unsigned long *config)
{
return default_mpp_ctrl_get(mpp_base, pid, config);
}
static int dove_mpp_ctrl_set(unsigned pid, unsigned long config)
{
return default_mpp_ctrl_set(mpp_base, pid, config);
}
static int dove_pmu_mpp_ctrl_get(unsigned pid, unsigned long *config) static int dove_pmu_mpp_ctrl_get(unsigned pid, unsigned long *config)
{ {
unsigned off = (pid / MPPS_PER_REG) * MPP_BITS; unsigned off = (pid / MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS;
unsigned shift = (pid % MPPS_PER_REG) * MPP_BITS; unsigned shift = (pid % MVEBU_MPPS_PER_REG) * MVEBU_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 << 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) & MVEBU_MPP_MASK;
*config |= CONFIG_PMU; *config |= CONFIG_PMU;
} else { } else {
func = readl(DOVE_MPP_VIRT_BASE + off); func = readl(DOVE_MPP_VIRT_BASE + off);
*config = (func >> shift) & MPP_MASK; *config = (func >> shift) & MVEBU_MPP_MASK;
} }
return 0; return 0;
} }
static int dove_pmu_mpp_ctrl_set(unsigned pid, unsigned long config) static int dove_pmu_mpp_ctrl_set(unsigned pid, unsigned long config)
{ {
unsigned off = (pid / MPPS_PER_REG) * MPP_BITS; unsigned off = (pid / MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS;
unsigned shift = (pid % MPPS_PER_REG) * MPP_BITS; unsigned shift = (pid % MVEBU_MPPS_PER_REG) * MVEBU_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 << 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 &= ~(MVEBU_MPP_MASK << shift);
func |= (config & MPP_MASK) << shift; func |= (config & MVEBU_MPP_MASK) << shift;
writel(func, DOVE_PMU_SIGNAL_SELECT_0 + off); writel(func, DOVE_PMU_SIGNAL_SELECT_0 + off);
} else { } else {
writel(pmu & ~(1 << 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 &= ~(MVEBU_MPP_MASK << shift);
func |= (config & MPP_MASK) << shift; func |= (config & MVEBU_MPP_MASK) << shift;
writel(func, DOVE_MPP_VIRT_BASE + off); writel(func, DOVE_MPP_VIRT_BASE + off);
} }
return 0; return 0;
......
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