Skip to content

Commit 2c4b229

Browse files
committed
pinctrl: mvebu: dove: use remapped mpp4 register
Now that we have an ioremapped mpp4 register, get rid of hardcoded physical addresses. While at it, also remove DOVE_ prefix from those macros. Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Acked-by: Linus Walleij <linus.walleij@linaro.org>
1 parent 00202b0 commit 2c4b229

1 file changed

Lines changed: 27 additions & 26 deletions

File tree

‎drivers/pinctrl/mvebu/pinctrl-dove.c‎

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,19 @@
4646
#define DOVE_AU1_SPDIFO_GPIO_EN BIT(1)
4747
#define DOVE_NAND_GPIO_EN BIT(0)
4848
#define DOVE_GPIO_LO_VIRT_BASE (DOVE_SB_REGS_VIRT_BASE + 0xd0400)
49-
#define DOVE_MPP_CTRL4_VIRT_BASE (DOVE_GPIO_LO_VIRT_BASE + 0x40)
50-
#define DOVE_SPI_GPIO_SEL BIT(5)
51-
#define DOVE_UART1_GPIO_SEL BIT(4)
52-
#define DOVE_AU1_GPIO_SEL BIT(3)
53-
#define DOVE_CAM_GPIO_SEL BIT(2)
54-
#define DOVE_SD1_GPIO_SEL BIT(1)
55-
#define DOVE_SD0_GPIO_SEL BIT(0)
5649

5750
/* MPP Base registers */
5851
#define PMU_MPP_GENERAL_CTRL 0x10
5952
#define AU0_AC97_SEL BIT(16)
6053

54+
/* MPP Control 4 register */
55+
#define SPI_GPIO_SEL BIT(5)
56+
#define UART1_GPIO_SEL BIT(4)
57+
#define AU1_GPIO_SEL BIT(3)
58+
#define CAM_GPIO_SEL BIT(2)
59+
#define SD1_GPIO_SEL BIT(1)
60+
#define SD0_GPIO_SEL BIT(0)
61+
6162
#define CONFIG_PMU BIT(4)
6263

6364
static void __iomem *mpp_base;
@@ -115,24 +116,24 @@ static int dove_pmu_mpp_ctrl_set(unsigned pid, unsigned long config)
115116

116117
static int dove_mpp4_ctrl_get(unsigned pid, unsigned long *config)
117118
{
118-
unsigned long mpp4 = readl(DOVE_MPP_CTRL4_VIRT_BASE);
119+
unsigned long mpp4 = readl(mpp4_base);
119120
unsigned long mask;
120121

121122
switch (pid) {
122123
case 24: /* mpp_camera */
123-
mask = DOVE_CAM_GPIO_SEL;
124+
mask = CAM_GPIO_SEL;
124125
break;
125126
case 40: /* mpp_sdio0 */
126-
mask = DOVE_SD0_GPIO_SEL;
127+
mask = SD0_GPIO_SEL;
127128
break;
128129
case 46: /* mpp_sdio1 */
129-
mask = DOVE_SD1_GPIO_SEL;
130+
mask = SD1_GPIO_SEL;
130131
break;
131132
case 58: /* mpp_spi0 */
132-
mask = DOVE_SPI_GPIO_SEL;
133+
mask = SPI_GPIO_SEL;
133134
break;
134135
case 62: /* mpp_uart1 */
135-
mask = DOVE_UART1_GPIO_SEL;
136+
mask = UART1_GPIO_SEL;
136137
break;
137138
default:
138139
return -EINVAL;
@@ -145,24 +146,24 @@ static int dove_mpp4_ctrl_get(unsigned pid, unsigned long *config)
145146

146147
static int dove_mpp4_ctrl_set(unsigned pid, unsigned long config)
147148
{
148-
unsigned long mpp4 = readl(DOVE_MPP_CTRL4_VIRT_BASE);
149+
unsigned long mpp4 = readl(mpp4_base);
149150
unsigned long mask;
150151

151152
switch (pid) {
152153
case 24: /* mpp_camera */
153-
mask = DOVE_CAM_GPIO_SEL;
154+
mask = CAM_GPIO_SEL;
154155
break;
155156
case 40: /* mpp_sdio0 */
156-
mask = DOVE_SD0_GPIO_SEL;
157+
mask = SD0_GPIO_SEL;
157158
break;
158159
case 46: /* mpp_sdio1 */
159-
mask = DOVE_SD1_GPIO_SEL;
160+
mask = SD1_GPIO_SEL;
160161
break;
161162
case 58: /* mpp_spi0 */
162-
mask = DOVE_SPI_GPIO_SEL;
163+
mask = SPI_GPIO_SEL;
163164
break;
164165
case 62: /* mpp_uart1 */
165-
mask = DOVE_UART1_GPIO_SEL;
166+
mask = UART1_GPIO_SEL;
166167
break;
167168
default:
168169
return -EINVAL;
@@ -172,7 +173,7 @@ static int dove_mpp4_ctrl_set(unsigned pid, unsigned long config)
172173
if (config)
173174
mpp4 |= mask;
174175

175-
writel(mpp4, DOVE_MPP_CTRL4_VIRT_BASE);
176+
writel(mpp4, mpp4_base);
176177

177178
return 0;
178179
}
@@ -222,13 +223,13 @@ static int dove_audio0_ctrl_set(unsigned pid, unsigned long config)
222223

223224
static int dove_audio1_ctrl_get(unsigned pid, unsigned long *config)
224225
{
225-
unsigned long mpp4 = readl(DOVE_MPP_CTRL4_VIRT_BASE);
226+
unsigned int mpp4 = readl(mpp4_base);
226227
unsigned long sspc1 = readl(DOVE_SSP_CTRL_STATUS_1);
227228
unsigned long gmpp = readl(DOVE_MPP_GENERAL_VIRT_BASE);
228229
unsigned long gcfg2 = readl(DOVE_GLOBAL_CONFIG_2);
229230

230231
*config = 0;
231-
if (mpp4 & DOVE_AU1_GPIO_SEL)
232+
if (mpp4 & AU1_GPIO_SEL)
232233
*config |= BIT(3);
233234
if (sspc1 & DOVE_SSP_ON_AU1)
234235
*config |= BIT(2);
@@ -248,7 +249,7 @@ static int dove_audio1_ctrl_get(unsigned pid, unsigned long *config)
248249

249250
static int dove_audio1_ctrl_set(unsigned pid, unsigned long config)
250251
{
251-
unsigned long mpp4 = readl(DOVE_MPP_CTRL4_VIRT_BASE);
252+
unsigned int mpp4 = readl(mpp4_base);
252253
unsigned long sspc1 = readl(DOVE_SSP_CTRL_STATUS_1);
253254
unsigned long gmpp = readl(DOVE_MPP_GENERAL_VIRT_BASE);
254255
unsigned long gcfg2 = readl(DOVE_GLOBAL_CONFIG_2);
@@ -259,7 +260,7 @@ static int dove_audio1_ctrl_set(unsigned pid, unsigned long config)
259260
gcfg2 &= ~DOVE_TWSI_OPTION3_GPIO;
260261
gmpp &= ~DOVE_AU1_SPDIFO_GPIO_EN;
261262
sspc1 &= ~DOVE_SSP_ON_AU1;
262-
mpp4 &= ~DOVE_AU1_GPIO_SEL;
263+
mpp4 &= ~AU1_GPIO_SEL;
263264

264265
if (config & BIT(0))
265266
gcfg2 |= DOVE_TWSI_OPTION3_GPIO;
@@ -268,9 +269,9 @@ static int dove_audio1_ctrl_set(unsigned pid, unsigned long config)
268269
if (config & BIT(2))
269270
sspc1 |= DOVE_SSP_ON_AU1;
270271
if (config & BIT(3))
271-
mpp4 |= DOVE_AU1_GPIO_SEL;
272+
mpp4 |= AU1_GPIO_SEL;
272273

273-
writel(mpp4, DOVE_MPP_CTRL4_VIRT_BASE);
274+
writel(mpp4, mpp4_base);
274275
writel(sspc1, DOVE_SSP_CTRL_STATUS_1);
275276
writel(gmpp, DOVE_MPP_GENERAL_VIRT_BASE);
276277
writel(gcfg2, DOVE_GLOBAL_CONFIG_2);

0 commit comments

Comments
 (0)