diff options
author | Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> | 2014-01-30 19:31:21 -0500 |
---|---|---|
committer | Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> | 2014-02-25 12:35:24 -0500 |
commit | 17bdec677053e3b0ffee65f0bb80373816349d7f (patch) | |
tree | 569e95beb0c22dcf7b9d76cec058c6bd80f5068a /drivers/pinctrl/mvebu/pinctrl-dove.c | |
parent | f5b85e42d46978ec6f73704f8370005f9ac54239 (diff) |
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: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Diffstat (limited to 'drivers/pinctrl/mvebu/pinctrl-dove.c')
-rw-r--r-- | drivers/pinctrl/mvebu/pinctrl-dove.c | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/drivers/pinctrl/mvebu/pinctrl-dove.c b/drivers/pinctrl/mvebu/pinctrl-dove.c index c7d365f9009c..0a4afe4bc97e 100644 --- a/drivers/pinctrl/mvebu/pinctrl-dove.c +++ b/drivers/pinctrl/mvebu/pinctrl-dove.c | |||
@@ -49,48 +49,56 @@ | |||
49 | #define DOVE_SD1_GPIO_SEL BIT(1) | 49 | #define DOVE_SD1_GPIO_SEL BIT(1) |
50 | #define DOVE_SD0_GPIO_SEL BIT(0) | 50 | #define DOVE_SD0_GPIO_SEL BIT(0) |
51 | 51 | ||
52 | #define MPPS_PER_REG 8 | ||
53 | #define MPP_BITS 4 | ||
54 | #define MPP_MASK 0xf | ||
55 | |||
56 | #define CONFIG_PMU BIT(4) | 52 | #define CONFIG_PMU BIT(4) |
57 | 53 | ||
54 | static void __iomem *mpp_base; | ||
55 | |||
56 | static int dove_mpp_ctrl_get(unsigned pid, unsigned long *config) | ||
57 | { | ||
58 | return default_mpp_ctrl_get(mpp_base, pid, config); | ||
59 | } | ||
60 | |||
61 | static int dove_mpp_ctrl_set(unsigned pid, unsigned long config) | ||
62 | { | ||
63 | return default_mpp_ctrl_set(mpp_base, pid, config); | ||
64 | } | ||
65 | |||
58 | static int dove_pmu_mpp_ctrl_get(unsigned pid, unsigned long *config) | 66 | static int dove_pmu_mpp_ctrl_get(unsigned pid, unsigned long *config) |
59 | { | 67 | { |
60 | unsigned off = (pid / MPPS_PER_REG) * MPP_BITS; | 68 | unsigned off = (pid / MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS; |
61 | unsigned shift = (pid % MPPS_PER_REG) * MPP_BITS; | 69 | unsigned shift = (pid % MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS; |
62 | unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL); | 70 | unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL); |
63 | unsigned long func; | 71 | unsigned long func; |
64 | 72 | ||
65 | if (pmu & (1 << pid)) { | 73 | if (pmu & (1 << pid)) { |
66 | func = readl(DOVE_PMU_SIGNAL_SELECT_0 + off); | 74 | func = readl(DOVE_PMU_SIGNAL_SELECT_0 + off); |
67 | *config = (func >> shift) & MPP_MASK; | 75 | *config = (func >> shift) & MVEBU_MPP_MASK; |
68 | *config |= CONFIG_PMU; | 76 | *config |= CONFIG_PMU; |
69 | } else { | 77 | } else { |
70 | func = readl(DOVE_MPP_VIRT_BASE + off); | 78 | func = readl(DOVE_MPP_VIRT_BASE + off); |
71 | *config = (func >> shift) & MPP_MASK; | 79 | *config = (func >> shift) & MVEBU_MPP_MASK; |
72 | } | 80 | } |
73 | return 0; | 81 | return 0; |
74 | } | 82 | } |
75 | 83 | ||
76 | static int dove_pmu_mpp_ctrl_set(unsigned pid, unsigned long config) | 84 | static int dove_pmu_mpp_ctrl_set(unsigned pid, unsigned long config) |
77 | { | 85 | { |
78 | unsigned off = (pid / MPPS_PER_REG) * MPP_BITS; | 86 | unsigned off = (pid / MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS; |
79 | unsigned shift = (pid % MPPS_PER_REG) * MPP_BITS; | 87 | unsigned shift = (pid % MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS; |
80 | unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL); | 88 | unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL); |
81 | unsigned long func; | 89 | unsigned long func; |
82 | 90 | ||
83 | if (config & CONFIG_PMU) { | 91 | if (config & CONFIG_PMU) { |
84 | writel(pmu | (1 << pid), DOVE_PMU_MPP_GENERAL_CTRL); | 92 | writel(pmu | (1 << pid), DOVE_PMU_MPP_GENERAL_CTRL); |
85 | func = readl(DOVE_PMU_SIGNAL_SELECT_0 + off); | 93 | func = readl(DOVE_PMU_SIGNAL_SELECT_0 + off); |
86 | func &= ~(MPP_MASK << shift); | 94 | func &= ~(MVEBU_MPP_MASK << shift); |
87 | func |= (config & MPP_MASK) << shift; | 95 | func |= (config & MVEBU_MPP_MASK) << shift; |
88 | writel(func, DOVE_PMU_SIGNAL_SELECT_0 + off); | 96 | writel(func, DOVE_PMU_SIGNAL_SELECT_0 + off); |
89 | } else { | 97 | } else { |
90 | writel(pmu & ~(1 << pid), DOVE_PMU_MPP_GENERAL_CTRL); | 98 | writel(pmu & ~(1 << pid), DOVE_PMU_MPP_GENERAL_CTRL); |
91 | func = readl(DOVE_MPP_VIRT_BASE + off); | 99 | func = readl(DOVE_MPP_VIRT_BASE + off); |
92 | func &= ~(MPP_MASK << shift); | 100 | func &= ~(MVEBU_MPP_MASK << shift); |
93 | func |= (config & MPP_MASK) << shift; | 101 | func |= (config & MVEBU_MPP_MASK) << shift; |
94 | writel(func, DOVE_MPP_VIRT_BASE + off); | 102 | writel(func, DOVE_MPP_VIRT_BASE + off); |
95 | } | 103 | } |
96 | return 0; | 104 | return 0; |