diff options
| author | Andrew Lunn <andrew@lunn.ch> | 2011-05-15 07:32:54 -0400 |
|---|---|---|
| committer | Nicolas Pitre <nico@fluxnic.net> | 2011-05-16 15:49:31 -0400 |
| commit | 3cff484d4b264ff467a3b45c544cbbbab69f0bf8 (patch) | |
| tree | 8e647ab4b9549859e74269163da09de8b66168a1 | |
| parent | 554cdaefd1cf7bb54b209c4e68c7cec87ce442a9 (diff) | |
ARM: dove: Consolidate mpp code with platform mpp.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
| -rw-r--r-- | arch/arm/mach-dove/mpp.c | 134 | ||||
| -rw-r--r-- | arch/arm/mach-dove/mpp.h | 362 | ||||
| -rw-r--r-- | arch/arm/plat-orion/mpp.c | 5 |
3 files changed, 213 insertions, 288 deletions
diff --git a/arch/arm/mach-dove/mpp.c b/arch/arm/mach-dove/mpp.c index c66c76346904..51e0e411c9cb 100644 --- a/arch/arm/mach-dove/mpp.c +++ b/arch/arm/mach-dove/mpp.c | |||
| @@ -11,24 +11,17 @@ | |||
| 11 | #include <linux/kernel.h> | 11 | #include <linux/kernel.h> |
| 12 | #include <linux/gpio.h> | 12 | #include <linux/gpio.h> |
| 13 | #include <linux/io.h> | 13 | #include <linux/io.h> |
| 14 | 14 | #include <plat/mpp.h> | |
| 15 | #include <mach/dove.h> | 15 | #include <mach/dove.h> |
| 16 | |||
| 17 | #include "mpp.h" | 16 | #include "mpp.h" |
| 18 | 17 | ||
| 19 | #define MPP_NR_REGS 4 | ||
| 20 | #define MPP_CTRL(i) ((i) == 3 ? \ | ||
| 21 | DOVE_MPP_CTRL4_VIRT_BASE : \ | ||
| 22 | DOVE_MPP_VIRT_BASE + (i) * 4) | ||
| 23 | #define PMU_SIG_REGS 2 | ||
| 24 | #define PMU_SIG_CTRL(i) (DOVE_PMU_SIG_CTRL + (i) * 4) | ||
| 25 | |||
| 26 | struct dove_mpp_grp { | 18 | struct dove_mpp_grp { |
| 27 | int start; | 19 | int start; |
| 28 | int end; | 20 | int end; |
| 29 | }; | 21 | }; |
| 30 | 22 | ||
| 31 | static struct dove_mpp_grp dove_mpp_grp[] = { | 23 | /* Map a group to a range of GPIO pins in that group */ |
| 24 | static const struct dove_mpp_grp dove_mpp_grp[] = { | ||
| 32 | [MPP_24_39] = { | 25 | [MPP_24_39] = { |
| 33 | .start = 24, | 26 | .start = 24, |
| 34 | .end = 39, | 27 | .end = 39, |
| @@ -38,8 +31,8 @@ static struct dove_mpp_grp dove_mpp_grp[] = { | |||
| 38 | .end = 45, | 31 | .end = 45, |
| 39 | }, | 32 | }, |
| 40 | [MPP_46_51] = { | 33 | [MPP_46_51] = { |
| 41 | .start = 40, | 34 | .start = 46, |
| 42 | .end = 45, | 35 | .end = 51, |
| 43 | }, | 36 | }, |
| 44 | [MPP_58_61] = { | 37 | [MPP_58_61] = { |
| 45 | .start = 58, | 38 | .start = 58, |
| @@ -51,6 +44,8 @@ static struct dove_mpp_grp dove_mpp_grp[] = { | |||
| 51 | }, | 44 | }, |
| 52 | }; | 45 | }; |
| 53 | 46 | ||
| 47 | /* Enable gpio for a range of pins. mode should be a combination of | ||
| 48 | GPIO_OUTPUT_OK | GPIO_INPUT_OK */ | ||
| 54 | static void dove_mpp_gpio_mode(int start, int end, int gpio_mode) | 49 | static void dove_mpp_gpio_mode(int start, int end, int gpio_mode) |
| 55 | { | 50 | { |
| 56 | int i; | 51 | int i; |
| @@ -59,24 +54,17 @@ static void dove_mpp_gpio_mode(int start, int end, int gpio_mode) | |||
| 59 | orion_gpio_set_valid(i, gpio_mode); | 54 | orion_gpio_set_valid(i, gpio_mode); |
| 60 | } | 55 | } |
| 61 | 56 | ||
| 57 | /* Dump all the extra MPP registers. The platform code will dump the | ||
| 58 | registers for pins 0-23. */ | ||
| 62 | static void dove_mpp_dump_regs(void) | 59 | static void dove_mpp_dump_regs(void) |
| 63 | { | 60 | { |
| 64 | #ifdef DEBUG | 61 | pr_debug("PMU_CTRL4_CTRL: %08x\n", |
| 65 | int i; | 62 | readl(DOVE_MPP_CTRL4_VIRT_BASE)); |
| 66 | 63 | ||
| 67 | pr_debug("MPP_CTRL regs:"); | 64 | pr_debug("PMU_MPP_GENERAL_CTRL: %08x\n", |
| 68 | for (i = 0; i < MPP_NR_REGS; i++) | 65 | readl(DOVE_PMU_MPP_GENERAL_CTRL)); |
| 69 | printk(" %08x", readl(MPP_CTRL(i))); | ||
| 70 | printk("\n"); | ||
| 71 | 66 | ||
| 72 | pr_debug("PMU_SIG_CTRL regs:"); | ||
| 73 | for (i = 0; i < PMU_SIG_REGS; i++) | ||
| 74 | printk(" %08x", readl(PMU_SIG_CTRL(i))); | ||
| 75 | printk("\n"); | ||
| 76 | |||
| 77 | pr_debug("PMU_MPP_GENERAL_CTRL: %08x\n", readl(DOVE_PMU_MPP_GENERAL_CTRL)); | ||
| 78 | pr_debug("MPP_GENERAL: %08x\n", readl(DOVE_MPP_GENERAL_VIRT_BASE)); | 67 | pr_debug("MPP_GENERAL: %08x\n", readl(DOVE_MPP_GENERAL_VIRT_BASE)); |
| 79 | #endif | ||
| 80 | } | 68 | } |
| 81 | 69 | ||
| 82 | static void dove_mpp_cfg_nfc(int sel) | 70 | static void dove_mpp_cfg_nfc(int sel) |
| @@ -92,7 +80,7 @@ static void dove_mpp_cfg_nfc(int sel) | |||
| 92 | 80 | ||
| 93 | static void dove_mpp_cfg_au1(int sel) | 81 | static void dove_mpp_cfg_au1(int sel) |
| 94 | { | 82 | { |
| 95 | u32 mpp_ctrl4 = readl(DOVE_MPP_CTRL4_VIRT_BASE); | 83 | u32 mpp_ctrl4 = readl(DOVE_MPP_CTRL4_VIRT_BASE); |
| 96 | u32 ssp_ctrl1 = readl(DOVE_SSP_CTRL_STATUS_1); | 84 | u32 ssp_ctrl1 = readl(DOVE_SSP_CTRL_STATUS_1); |
| 97 | u32 mpp_gen_ctrl = readl(DOVE_MPP_GENERAL_VIRT_BASE); | 85 | u32 mpp_gen_ctrl = readl(DOVE_MPP_GENERAL_VIRT_BASE); |
| 98 | u32 global_cfg_2 = readl(DOVE_GLOBAL_CONFIG_2); | 86 | u32 global_cfg_2 = readl(DOVE_GLOBAL_CONFIG_2); |
| @@ -128,82 +116,46 @@ static void dove_mpp_cfg_au1(int sel) | |||
| 128 | writel(global_cfg_2, DOVE_GLOBAL_CONFIG_2); | 116 | writel(global_cfg_2, DOVE_GLOBAL_CONFIG_2); |
| 129 | } | 117 | } |
| 130 | 118 | ||
| 131 | static void dove_mpp_conf_grp(int num, int sel, u32 *mpp_ctrl) | 119 | /* Configure the group registers, enabling GPIO if sel indicates the |
| 132 | { | 120 | pin is to be used for GPIO */ |
| 133 | int start = dove_mpp_grp[num].start; | 121 | static void dove_mpp_conf_grp(unsigned int *mpp_grp_list) |
| 134 | int end = dove_mpp_grp[num].end; | ||
| 135 | int gpio_mode = sel ? GPIO_OUTPUT_OK | GPIO_INPUT_OK : 0; | ||
| 136 | |||
| 137 | *mpp_ctrl &= ~(0x1 << num); | ||
| 138 | *mpp_ctrl |= sel << num; | ||
| 139 | |||
| 140 | dove_mpp_gpio_mode(start, end, gpio_mode); | ||
| 141 | } | ||
| 142 | |||
| 143 | void __init dove_mpp_conf(unsigned int *mpp_list) | ||
| 144 | { | 122 | { |
| 145 | u32 mpp_ctrl[MPP_NR_REGS]; | 123 | u32 mpp_ctrl4 = readl(DOVE_MPP_CTRL4_VIRT_BASE); |
| 146 | u32 pmu_mpp_ctrl = 0; | 124 | int gpio_mode; |
| 147 | u32 pmu_sig_ctrl[PMU_SIG_REGS]; | ||
| 148 | int i; | ||
| 149 | |||
| 150 | for (i = 0; i < MPP_NR_REGS; i++) | ||
| 151 | mpp_ctrl[i] = readl(MPP_CTRL(i)); | ||
| 152 | |||
| 153 | for (i = 0; i < PMU_SIG_REGS; i++) | ||
| 154 | pmu_sig_ctrl[i] = readl(PMU_SIG_CTRL(i)); | ||
| 155 | |||
| 156 | pmu_mpp_ctrl = readl(DOVE_PMU_MPP_GENERAL_CTRL); | ||
| 157 | 125 | ||
| 158 | dove_mpp_dump_regs(); | 126 | for ( ; *mpp_grp_list; mpp_grp_list++) { |
| 159 | 127 | unsigned int num = MPP_NUM(*mpp_grp_list); | |
| 160 | for ( ; *mpp_list != MPP_END; mpp_list++) { | 128 | unsigned int sel = MPP_SEL(*mpp_grp_list); |
| 161 | unsigned int num = MPP_NUM(*mpp_list); | ||
| 162 | unsigned int sel = MPP_SEL(*mpp_list); | ||
| 163 | int shift, gpio_mode; | ||
| 164 | |||
| 165 | if (num > MPP_MAX) { | ||
| 166 | pr_err("dove: invalid MPP number (%u)\n", num); | ||
| 167 | continue; | ||
| 168 | } | ||
| 169 | |||
| 170 | if (*mpp_list & MPP_NFC_MASK) { | ||
| 171 | dove_mpp_cfg_nfc(sel); | ||
| 172 | continue; | ||
| 173 | } | ||
| 174 | 129 | ||
| 175 | if (*mpp_list & MPP_AU1_MASK) { | 130 | if (num > MPP_GRP_MAX) { |
| 176 | dove_mpp_cfg_au1(sel); | 131 | pr_err("dove: invalid MPP GRP number (%u)\n", num); |
| 177 | continue; | 132 | continue; |
| 178 | } | 133 | } |
| 179 | 134 | ||
| 180 | if (*mpp_list & MPP_GRP_MASK) { | 135 | mpp_ctrl4 &= ~(0x1 << num); |
| 181 | dove_mpp_conf_grp(num, sel, &mpp_ctrl[3]); | 136 | mpp_ctrl4 |= sel << num; |
| 182 | continue; | ||
| 183 | } | ||
| 184 | |||
| 185 | shift = (num & 7) << 2; | ||
| 186 | if (*mpp_list & MPP_PMU_MASK) { | ||
| 187 | pmu_mpp_ctrl |= (0x1 << num); | ||
| 188 | pmu_sig_ctrl[num / 8] &= ~(0xf << shift); | ||
| 189 | pmu_sig_ctrl[num / 8] |= 0xf << shift; | ||
| 190 | gpio_mode = 0; | ||
| 191 | } else { | ||
| 192 | mpp_ctrl[num / 8] &= ~(0xf << shift); | ||
| 193 | mpp_ctrl[num / 8] |= sel << shift; | ||
| 194 | gpio_mode = GPIO_OUTPUT_OK | GPIO_INPUT_OK; | ||
| 195 | } | ||
| 196 | 137 | ||
| 197 | orion_gpio_set_valid(num, gpio_mode); | 138 | gpio_mode = sel ? GPIO_OUTPUT_OK | GPIO_INPUT_OK : 0; |
| 139 | dove_mpp_gpio_mode(dove_mpp_grp[num].start, | ||
| 140 | dove_mpp_grp[num].end, gpio_mode); | ||
| 198 | } | 141 | } |
| 142 | writel(mpp_ctrl4, DOVE_MPP_CTRL4_VIRT_BASE); | ||
| 143 | } | ||
| 199 | 144 | ||
| 200 | for (i = 0; i < MPP_NR_REGS; i++) | 145 | /* Configure the various MPP pins on Dove */ |
| 201 | writel(mpp_ctrl[i], MPP_CTRL(i)); | 146 | void __init dove_mpp_conf(unsigned int *mpp_list, |
| 147 | unsigned int *mpp_grp_list, | ||
| 148 | unsigned int grp_au1_52_57, | ||
| 149 | unsigned int grp_nfc_64_71) | ||
| 150 | { | ||
| 151 | dove_mpp_dump_regs(); | ||
| 202 | 152 | ||
| 203 | for (i = 0; i < PMU_SIG_REGS; i++) | 153 | /* Use platform code for pins 0-23 */ |
| 204 | writel(pmu_sig_ctrl[< | ||
