diff options
author | Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> | 2014-01-30 20:29:16 -0500 |
---|---|---|
committer | Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> | 2014-02-25 12:38:41 -0500 |
commit | 78c2c3d3dad07cfdc8f9d9bc3dff03a3ec1acfd2 (patch) | |
tree | 422381a0f0e635a5315b6909751529887b2777d1 | |
parent | c2f082fe97fb973c655edc181de593b95b88fcfb (diff) |
pinctrl: mvebu: dove: reuse mpp_{set,get} in pmu callbacks
Dove has pins that can be switched between normal and pmu functions.
Rework pmu_mpp callbacks to reuse default mpp ctrl helpers.
Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
-rw-r--r-- | drivers/pinctrl/mvebu/pinctrl-dove.c | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/drivers/pinctrl/mvebu/pinctrl-dove.c b/drivers/pinctrl/mvebu/pinctrl-dove.c index 89fd3a5a1df1..da9ca26360fd 100644 --- a/drivers/pinctrl/mvebu/pinctrl-dove.c +++ b/drivers/pinctrl/mvebu/pinctrl-dove.c | |||
@@ -70,14 +70,13 @@ static int dove_pmu_mpp_ctrl_get(unsigned pid, unsigned long *config) | |||
70 | unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL); | 70 | unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL); |
71 | unsigned long func; | 71 | unsigned long func; |
72 | 72 | ||
73 | if (pmu & (1 << pid)) { | 73 | if ((pmu & BIT(pid)) == 0) |
74 | func = readl(DOVE_PMU_SIGNAL_SELECT_0 + off); | 74 | return default_mpp_ctrl_get(mpp_base, pid, config); |
75 | *config = (func >> shift) & MVEBU_MPP_MASK; | 75 | |
76 | *config |= CONFIG_PMU; | 76 | func = readl(DOVE_PMU_SIGNAL_SELECT_0 + off); |
77 | } else { | 77 | *config = (func >> shift) & MVEBU_MPP_MASK; |
78 | func = readl(DOVE_MPP_VIRT_BASE + off); | 78 | *config |= CONFIG_PMU; |
79 | *config = (func >> shift) & MVEBU_MPP_MASK; | 79 | |
80 | } | ||
81 | return 0; | 80 | return 0; |
82 | } | 81 | } |
83 | 82 | ||
@@ -88,19 +87,17 @@ static int dove_pmu_mpp_ctrl_set(unsigned pid, unsigned long config) | |||
88 | unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL); | 87 | unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL); |
89 | unsigned long func; | 88 | unsigned long func; |
90 | 89 | ||
91 | if (config & CONFIG_PMU) { | 90 | if ((config & CONFIG_PMU) == 0) { |
92 | writel(pmu | (1 << pid), DOVE_PMU_MPP_GENERAL_CTRL); | 91 | writel(pmu & ~BIT(pid), DOVE_PMU_MPP_GENERAL_CTRL); |
93 | func = readl(DOVE_PMU_SIGNAL_SELECT_0 + off); | 92 | return default_mpp_ctrl_set(mpp_base, pid, config); |
94 | func &= ~(MVEBU_MPP_MASK << shift); | ||
95 | func |= (config & MVEBU_MPP_MASK) << shift; | ||
96 | writel(func, DOVE_PMU_SIGNAL_SELECT_0 + off); | ||
97 | } else { | ||
98 | writel(pmu & ~(1 << pid), DOVE_PMU_MPP_GENERAL_CTRL); | ||
99 | func = readl(DOVE_MPP_VIRT_BASE + off); | ||
100 | func &= ~(MVEBU_MPP_MASK << shift); | ||
101 | func |= (config & MVEBU_MPP_MASK) << shift; | ||
102 | writel(func, DOVE_MPP_VIRT_BASE + off); | ||
103 | } | 93 | } |
94 | |||
95 | writel(pmu | BIT(pid), DOVE_PMU_MPP_GENERAL_CTRL); | ||
96 | func = readl(DOVE_PMU_SIGNAL_SELECT_0 + off); | ||
97 | func &= ~(MVEBU_MPP_MASK << shift); | ||
98 | func |= (config & MVEBU_MPP_MASK) << shift; | ||
99 | writel(func, DOVE_PMU_SIGNAL_SELECT_0 + off); | ||
100 | |||
104 | return 0; | 101 | return 0; |
105 | } | 102 | } |
106 | 103 | ||