xref: /linux/drivers/pinctrl/mvebu/pinctrl-dove.c (revision 18e6f28e9c0db9ce0cbe0d3717235e8c7bc07b9c)
106763c74SThomas Petazzoni /*
206763c74SThomas Petazzoni  * Marvell Dove pinctrl driver based on mvebu pinctrl core
306763c74SThomas Petazzoni  *
406763c74SThomas Petazzoni  * Author: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
506763c74SThomas Petazzoni  *
606763c74SThomas Petazzoni  * This program is free software; you can redistribute it and/or modify
706763c74SThomas Petazzoni  * it under the terms of the GNU General Public License as published by
806763c74SThomas Petazzoni  * the Free Software Foundation; either version 2 of the License, or
906763c74SThomas Petazzoni  * (at your option) any later version.
1006763c74SThomas Petazzoni  */
1106763c74SThomas Petazzoni 
1206763c74SThomas Petazzoni #include <linux/err.h>
1306763c74SThomas Petazzoni #include <linux/init.h>
1406763c74SThomas Petazzoni #include <linux/io.h>
1506763c74SThomas Petazzoni #include <linux/module.h>
1606763c74SThomas Petazzoni #include <linux/bitops.h>
1706763c74SThomas Petazzoni #include <linux/platform_device.h>
1806763c74SThomas Petazzoni #include <linux/clk.h>
1906763c74SThomas Petazzoni #include <linux/of.h>
2006763c74SThomas Petazzoni #include <linux/of_device.h>
21e91f7916SSebastian Hesselbarth #include <linux/mfd/syscon.h>
2206763c74SThomas Petazzoni #include <linux/pinctrl/pinctrl.h>
23e91f7916SSebastian Hesselbarth #include <linux/regmap.h>
2406763c74SThomas Petazzoni 
2506763c74SThomas Petazzoni #include "pinctrl-mvebu.h"
2606763c74SThomas Petazzoni 
274d73fc77SSebastian Hesselbarth /* Internal registers can be configured at any 1 MiB aligned address */
284d73fc77SSebastian Hesselbarth #define INT_REGS_MASK		~(SZ_1M - 1)
294d73fc77SSebastian Hesselbarth #define MPP4_REGS_OFFS		0xd0440
304d73fc77SSebastian Hesselbarth #define PMU_REGS_OFFS		0xd802c
31e91f7916SSebastian Hesselbarth #define GC_REGS_OFFS		0xe802c
324d73fc77SSebastian Hesselbarth 
3378f9f3b1SSebastian Hesselbarth #define DOVE_SB_REGS_VIRT_BASE		IOMEM(0xfde00000)
34bbd7b275SSebastian Hesselbarth #define DOVE_GLOBAL_CONFIG_1		(DOVE_SB_REGS_VIRT_BASE + 0xe802C)
3578f9f3b1SSebastian Hesselbarth #define DOVE_GLOBAL_CONFIG_1		(DOVE_SB_REGS_VIRT_BASE + 0xe802C)
3606763c74SThomas Petazzoni #define  DOVE_TWSI_ENABLE_OPTION1	BIT(7)
3778f9f3b1SSebastian Hesselbarth #define DOVE_GLOBAL_CONFIG_2		(DOVE_SB_REGS_VIRT_BASE + 0xe8030)
3806763c74SThomas Petazzoni #define  DOVE_TWSI_ENABLE_OPTION2	BIT(20)
3906763c74SThomas Petazzoni #define  DOVE_TWSI_ENABLE_OPTION3	BIT(21)
4006763c74SThomas Petazzoni #define  DOVE_TWSI_OPTION3_GPIO		BIT(22)
4178f9f3b1SSebastian Hesselbarth #define DOVE_SSP_CTRL_STATUS_1		(DOVE_SB_REGS_VIRT_BASE + 0xe8034)
4206763c74SThomas Petazzoni #define  DOVE_SSP_ON_AU1		BIT(0)
4378f9f3b1SSebastian Hesselbarth #define DOVE_MPP_GENERAL_VIRT_BASE	(DOVE_SB_REGS_VIRT_BASE + 0xe803c)
4406763c74SThomas Petazzoni #define  DOVE_AU1_SPDIFO_GPIO_EN	BIT(1)
4506763c74SThomas Petazzoni #define  DOVE_NAND_GPIO_EN		BIT(0)
4678f9f3b1SSebastian Hesselbarth #define DOVE_GPIO_LO_VIRT_BASE		(DOVE_SB_REGS_VIRT_BASE + 0xd0400)
4706763c74SThomas Petazzoni 
4800202b01SSebastian Hesselbarth /* MPP Base registers */
4900202b01SSebastian Hesselbarth #define PMU_MPP_GENERAL_CTRL	0x10
5000202b01SSebastian Hesselbarth #define  AU0_AC97_SEL		BIT(16)
5100202b01SSebastian Hesselbarth 
522c4b229bSSebastian Hesselbarth /* MPP Control 4 register */
532c4b229bSSebastian Hesselbarth #define SPI_GPIO_SEL		BIT(5)
542c4b229bSSebastian Hesselbarth #define UART1_GPIO_SEL		BIT(4)
552c4b229bSSebastian Hesselbarth #define AU1_GPIO_SEL		BIT(3)
562c4b229bSSebastian Hesselbarth #define CAM_GPIO_SEL		BIT(2)
572c4b229bSSebastian Hesselbarth #define SD1_GPIO_SEL		BIT(1)
582c4b229bSSebastian Hesselbarth #define SD0_GPIO_SEL		BIT(0)
592c4b229bSSebastian Hesselbarth 
60*18e6f28eSSebastian Hesselbarth /* PMU Signal Select registers */
61*18e6f28eSSebastian Hesselbarth #define PMU_SIGNAL_SELECT_0	0x00
62*18e6f28eSSebastian Hesselbarth #define PMU_SIGNAL_SELECT_1	0x04
63*18e6f28eSSebastian Hesselbarth 
6406763c74SThomas Petazzoni #define CONFIG_PMU	BIT(4)
6506763c74SThomas Petazzoni 
6617bdec67SSebastian Hesselbarth static void __iomem *mpp_base;
674d73fc77SSebastian Hesselbarth static void __iomem *mpp4_base;
684d73fc77SSebastian Hesselbarth static void __iomem *pmu_base;
69e91f7916SSebastian Hesselbarth static struct regmap *gconfmap;
7017bdec67SSebastian Hesselbarth 
7117bdec67SSebastian Hesselbarth static int dove_mpp_ctrl_get(unsigned pid, unsigned long *config)
7217bdec67SSebastian Hesselbarth {
7317bdec67SSebastian Hesselbarth 	return default_mpp_ctrl_get(mpp_base, pid, config);
7417bdec67SSebastian Hesselbarth }
7517bdec67SSebastian Hesselbarth 
7617bdec67SSebastian Hesselbarth static int dove_mpp_ctrl_set(unsigned pid, unsigned long config)
7717bdec67SSebastian Hesselbarth {
7817bdec67SSebastian Hesselbarth 	return default_mpp_ctrl_set(mpp_base, pid, config);
7917bdec67SSebastian Hesselbarth }
8017bdec67SSebastian Hesselbarth 
812035d39dSSebastian Hesselbarth static int dove_pmu_mpp_ctrl_get(unsigned pid, unsigned long *config)
8206763c74SThomas Petazzoni {
8317bdec67SSebastian Hesselbarth 	unsigned off = (pid / MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS;
8417bdec67SSebastian Hesselbarth 	unsigned shift = (pid % MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS;
8500202b01SSebastian Hesselbarth 	unsigned long pmu = readl(mpp_base + PMU_MPP_GENERAL_CTRL);
86bbd7b275SSebastian Hesselbarth 	unsigned long func;
8706763c74SThomas Petazzoni 
8878c2c3d3SSebastian Hesselbarth 	if ((pmu & BIT(pid)) == 0)
8978c2c3d3SSebastian Hesselbarth 		return default_mpp_ctrl_get(mpp_base, pid, config);
9078c2c3d3SSebastian Hesselbarth 
91*18e6f28eSSebastian Hesselbarth 	func = readl(pmu_base + PMU_SIGNAL_SELECT_0 + off);
9217bdec67SSebastian Hesselbarth 	*config = (func >> shift) & MVEBU_MPP_MASK;
93bbd7b275SSebastian Hesselbarth 	*config |= CONFIG_PMU;
9478c2c3d3SSebastian Hesselbarth 
9506763c74SThomas Petazzoni 	return 0;
9606763c74SThomas Petazzoni }
9706763c74SThomas Petazzoni 
982035d39dSSebastian Hesselbarth static int dove_pmu_mpp_ctrl_set(unsigned pid, unsigned long config)
9906763c74SThomas Petazzoni {
10017bdec67SSebastian Hesselbarth 	unsigned off = (pid / MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS;
10117bdec67SSebastian Hesselbarth 	unsigned shift = (pid % MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS;
10200202b01SSebastian Hesselbarth 	unsigned long pmu = readl(mpp_base + PMU_MPP_GENERAL_CTRL);
103bbd7b275SSebastian Hesselbarth 	unsigned long func;
10406763c74SThomas Petazzoni 
10578c2c3d3SSebastian Hesselbarth 	if ((config & CONFIG_PMU) == 0) {
10600202b01SSebastian Hesselbarth 		writel(pmu & ~BIT(pid), mpp_base + PMU_MPP_GENERAL_CTRL);
10778c2c3d3SSebastian Hesselbarth 		return default_mpp_ctrl_set(mpp_base, pid, config);
10878c2c3d3SSebastian Hesselbarth 	}
10978c2c3d3SSebastian Hesselbarth 
11000202b01SSebastian Hesselbarth 	writel(pmu | BIT(pid), mpp_base + PMU_MPP_GENERAL_CTRL);
111*18e6f28eSSebastian Hesselbarth 	func = readl(pmu_base + PMU_SIGNAL_SELECT_0 + off);
11217bdec67SSebastian Hesselbarth 	func &= ~(MVEBU_MPP_MASK << shift);
11317bdec67SSebastian Hesselbarth 	func |= (config & MVEBU_MPP_MASK) << shift;
114*18e6f28eSSebastian Hesselbarth 	writel(func, pmu_base + PMU_SIGNAL_SELECT_0 + off);
11578c2c3d3SSebastian Hesselbarth 
11606763c74SThomas Petazzoni 	return 0;
11706763c74SThomas Petazzoni }
11806763c74SThomas Petazzoni 
1192035d39dSSebastian Hesselbarth static int dove_mpp4_ctrl_get(unsigned pid, unsigned long *config)
12006763c74SThomas Petazzoni {
1212c4b229bSSebastian Hesselbarth 	unsigned long mpp4 = readl(mpp4_base);
12206763c74SThomas Petazzoni 	unsigned long mask;
12306763c74SThomas Petazzoni 
1242035d39dSSebastian Hesselbarth 	switch (pid) {
12506763c74SThomas Petazzoni 	case 24: /* mpp_camera */
1262c4b229bSSebastian Hesselbarth 		mask = CAM_GPIO_SEL;
12706763c74SThomas Petazzoni 		break;
12806763c74SThomas Petazzoni 	case 40: /* mpp_sdio0 */
1292c4b229bSSebastian Hesselbarth 		mask = SD0_GPIO_SEL;
13006763c74SThomas Petazzoni 		break;
13106763c74SThomas Petazzoni 	case 46: /* mpp_sdio1 */
1322c4b229bSSebastian Hesselbarth 		mask = SD1_GPIO_SEL;
13306763c74SThomas Petazzoni 		break;
13406763c74SThomas Petazzoni 	case 58: /* mpp_spi0 */
1352c4b229bSSebastian Hesselbarth 		mask = SPI_GPIO_SEL;
13606763c74SThomas Petazzoni 		break;
13706763c74SThomas Petazzoni 	case 62: /* mpp_uart1 */
1382c4b229bSSebastian Hesselbarth 		mask = UART1_GPIO_SEL;
13906763c74SThomas Petazzoni 		break;
14006763c74SThomas Petazzoni 	default:
14106763c74SThomas Petazzoni 		return -EINVAL;
14206763c74SThomas Petazzoni 	}
14306763c74SThomas Petazzoni 
14406763c74SThomas Petazzoni 	*config = ((mpp4 & mask) != 0);
14506763c74SThomas Petazzoni 
14606763c74SThomas Petazzoni 	return 0;
14706763c74SThomas Petazzoni }
14806763c74SThomas Petazzoni 
1492035d39dSSebastian Hesselbarth static int dove_mpp4_ctrl_set(unsigned pid, unsigned long config)
15006763c74SThomas Petazzoni {
1512c4b229bSSebastian Hesselbarth 	unsigned long mpp4 = readl(mpp4_base);
15206763c74SThomas Petazzoni 	unsigned long mask;
15306763c74SThomas Petazzoni 
1542035d39dSSebastian Hesselbarth 	switch (pid) {
15506763c74SThomas Petazzoni 	case 24: /* mpp_camera */
1562c4b229bSSebastian Hesselbarth 		mask = CAM_GPIO_SEL;
15706763c74SThomas Petazzoni 		break;
15806763c74SThomas Petazzoni 	case 40: /* mpp_sdio0 */
1592c4b229bSSebastian Hesselbarth 		mask = SD0_GPIO_SEL;
16006763c74SThomas Petazzoni 		break;
16106763c74SThomas Petazzoni 	case 46: /* mpp_sdio1 */
1622c4b229bSSebastian Hesselbarth 		mask = SD1_GPIO_SEL;
16306763c74SThomas Petazzoni 		break;
16406763c74SThomas Petazzoni 	case 58: /* mpp_spi0 */
1652c4b229bSSebastian Hesselbarth 		mask = SPI_GPIO_SEL;
16606763c74SThomas Petazzoni 		break;
16706763c74SThomas Petazzoni 	case 62: /* mpp_uart1 */
1682c4b229bSSebastian Hesselbarth 		mask = UART1_GPIO_SEL;
16906763c74SThomas Petazzoni 		break;
17006763c74SThomas Petazzoni 	default:
17106763c74SThomas Petazzoni 		return -EINVAL;
17206763c74SThomas Petazzoni 	}
17306763c74SThomas Petazzoni 
17406763c74SThomas Petazzoni 	mpp4 &= ~mask;
17506763c74SThomas Petazzoni 	if (config)
17606763c74SThomas Petazzoni 		mpp4 |= mask;
17706763c74SThomas Petazzoni 
1782c4b229bSSebastian Hesselbarth 	writel(mpp4, mpp4_base);
17906763c74SThomas Petazzoni 
18006763c74SThomas Petazzoni 	return 0;
18106763c74SThomas Petazzoni }
18206763c74SThomas Petazzoni 
1832035d39dSSebastian Hesselbarth static int dove_nand_ctrl_get(unsigned pid, unsigned long *config)
18406763c74SThomas Petazzoni {
18506763c74SThomas Petazzoni 	unsigned long gmpp = readl(DOVE_MPP_GENERAL_VIRT_BASE);
18606763c74SThomas Petazzoni 
18706763c74SThomas Petazzoni 	*config = ((gmpp & DOVE_NAND_GPIO_EN) != 0);
18806763c74SThomas Petazzoni 
18906763c74SThomas Petazzoni 	return 0;
19006763c74SThomas Petazzoni }
19106763c74SThomas Petazzoni 
1922035d39dSSebastian Hesselbarth static int dove_nand_ctrl_set(unsigned pid, unsigned long config)
19306763c74SThomas Petazzoni {
19406763c74SThomas Petazzoni 	unsigned long gmpp = readl(DOVE_MPP_GENERAL_VIRT_BASE);
19506763c74SThomas Petazzoni 
19606763c74SThomas Petazzoni 	gmpp &= ~DOVE_NAND_GPIO_EN;
19706763c74SThomas Petazzoni 	if (config)
19806763c74SThomas Petazzoni 		gmpp |= DOVE_NAND_GPIO_EN;
19906763c74SThomas Petazzoni 
20006763c74SThomas Petazzoni 	writel(gmpp, DOVE_MPP_GENERAL_VIRT_BASE);
20106763c74SThomas Petazzoni 
20206763c74SThomas Petazzoni 	return 0;
20306763c74SThomas Petazzoni }
20406763c74SThomas Petazzoni 
2052035d39dSSebastian Hesselbarth static int dove_audio0_ctrl_get(unsigned pid, unsigned long *config)
20606763c74SThomas Petazzoni {
20700202b01SSebastian Hesselbarth 	unsigned long pmu = readl(mpp_base + PMU_MPP_GENERAL_CTRL);
20806763c74SThomas Petazzoni 
20900202b01SSebastian Hesselbarth 	*config = ((pmu & AU0_AC97_SEL) != 0);
21006763c74SThomas Petazzoni 
21106763c74SThomas Petazzoni 	return 0;
21206763c74SThomas Petazzoni }
21306763c74SThomas Petazzoni 
2142035d39dSSebastian Hesselbarth static int dove_audio0_ctrl_set(unsigned pid, unsigned long config)
21506763c74SThomas Petazzoni {
21600202b01SSebastian Hesselbarth 	unsigned long pmu = readl(mpp_base + PMU_MPP_GENERAL_CTRL);
21706763c74SThomas Petazzoni 
21800202b01SSebastian Hesselbarth 	pmu &= ~AU0_AC97_SEL;
21906763c74SThomas Petazzoni 	if (config)
22000202b01SSebastian Hesselbarth 		pmu |= AU0_AC97_SEL;
22100202b01SSebastian Hesselbarth 	writel(pmu, mpp_base + PMU_MPP_GENERAL_CTRL);
22206763c74SThomas Petazzoni 
22306763c74SThomas Petazzoni 	return 0;
22406763c74SThomas Petazzoni }
22506763c74SThomas Petazzoni 
2262035d39dSSebastian Hesselbarth static int dove_audio1_ctrl_get(unsigned pid, unsigned long *config)
22706763c74SThomas Petazzoni {
2282c4b229bSSebastian Hesselbarth 	unsigned int mpp4 = readl(mpp4_base);
22906763c74SThomas Petazzoni 	unsigned long sspc1 = readl(DOVE_SSP_CTRL_STATUS_1);
23006763c74SThomas Petazzoni 	unsigned long gmpp = readl(DOVE_MPP_GENERAL_VIRT_BASE);
23106763c74SThomas Petazzoni 	unsigned long gcfg2 = readl(DOVE_GLOBAL_CONFIG_2);
23206763c74SThomas Petazzoni 
23306763c74SThomas Petazzoni 	*config = 0;
2342c4b229bSSebastian Hesselbarth 	if (mpp4 & AU1_GPIO_SEL)
23506763c74SThomas Petazzoni 		*config |= BIT(3);
23606763c74SThomas Petazzoni 	if (sspc1 & DOVE_SSP_ON_AU1)
23706763c74SThomas Petazzoni 		*config |= BIT(2);
23806763c74SThomas Petazzoni 	if (gmpp & DOVE_AU1_SPDIFO_GPIO_EN)
23906763c74SThomas Petazzoni 		*config |= BIT(1);
24006763c74SThomas Petazzoni 	if (gcfg2 & DOVE_TWSI_OPTION3_GPIO)
24106763c74SThomas Petazzoni 		*config |= BIT(0);
24206763c74SThomas Petazzoni 
24306763c74SThomas Petazzoni 	/* SSP/TWSI only if I2S1 not set*/
24406763c74SThomas Petazzoni 	if ((*config & BIT(3)) == 0)
24506763c74SThomas Petazzoni 		*config &= ~(BIT(2) | BIT(0));
24606763c74SThomas Petazzoni 	/* TWSI only if SPDIFO not set*/
24706763c74SThomas Petazzoni 	if ((*config & BIT(1)) == 0)
24806763c74SThomas Petazzoni 		*config &= ~BIT(0);
24906763c74SThomas Petazzoni 	return 0;
25006763c74SThomas Petazzoni }
25106763c74SThomas Petazzoni 
2522035d39dSSebastian Hesselbarth static int dove_audio1_ctrl_set(unsigned pid, unsigned long config)
25306763c74SThomas Petazzoni {
2542c4b229bSSebastian Hesselbarth 	unsigned int mpp4 = readl(mpp4_base);
25506763c74SThomas Petazzoni 	unsigned long sspc1 = readl(DOVE_SSP_CTRL_STATUS_1);
25606763c74SThomas Petazzoni 	unsigned long gmpp = readl(DOVE_MPP_GENERAL_VIRT_BASE);
25706763c74SThomas Petazzoni 	unsigned long gcfg2 = readl(DOVE_GLOBAL_CONFIG_2);
25806763c74SThomas Petazzoni 
25963ace077SAxel Lin 	/*
26063ace077SAxel Lin 	 * clear all audio1 related bits before configure
26163ace077SAxel Lin 	 */
26263ace077SAxel Lin 	gcfg2 &= ~DOVE_TWSI_OPTION3_GPIO;
26363ace077SAxel Lin 	gmpp &= ~DOVE_AU1_SPDIFO_GPIO_EN;
26463ace077SAxel Lin 	sspc1 &= ~DOVE_SSP_ON_AU1;
2652c4b229bSSebastian Hesselbarth 	mpp4 &= ~AU1_GPIO_SEL;
26663ace077SAxel Lin 
26706763c74SThomas Petazzoni 	if (config & BIT(0))
26806763c74SThomas Petazzoni 		gcfg2 |= DOVE_TWSI_OPTION3_GPIO;
26906763c74SThomas Petazzoni 	if (config & BIT(1))
27006763c74SThomas Petazzoni 		gmpp |= DOVE_AU1_SPDIFO_GPIO_EN;
27106763c74SThomas Petazzoni 	if (config & BIT(2))
27206763c74SThomas Petazzoni 		sspc1 |= DOVE_SSP_ON_AU1;
27306763c74SThomas Petazzoni 	if (config & BIT(3))
2742c4b229bSSebastian Hesselbarth 		mpp4 |= AU1_GPIO_SEL;
27506763c74SThomas Petazzoni 
2762c4b229bSSebastian Hesselbarth 	writel(mpp4, mpp4_base);
27706763c74SThomas Petazzoni 	writel(sspc1, DOVE_SSP_CTRL_STATUS_1);
27806763c74SThomas Petazzoni 	writel(gmpp, DOVE_MPP_GENERAL_VIRT_BASE);
27906763c74SThomas Petazzoni 	writel(gcfg2, DOVE_GLOBAL_CONFIG_2);
28006763c74SThomas Petazzoni 
28106763c74SThomas Petazzoni 	return 0;
28206763c74SThomas Petazzoni }
28306763c74SThomas Petazzoni 
28406763c74SThomas Petazzoni /* mpp[52:57] gpio pins depend heavily on current config;
28506763c74SThomas Petazzoni  * gpio_req does not try to mux in gpio capabilities to not
28606763c74SThomas Petazzoni  * break other functions. If you require all mpps as gpio
28706763c74SThomas Petazzoni  * enforce gpio setting by pinctrl mapping.
28806763c74SThomas Petazzoni  */
2892035d39dSSebastian Hesselbarth static int dove_audio1_ctrl_gpio_req(unsigned pid)
29006763c74SThomas Petazzoni {
29106763c74SThomas Petazzoni 	unsigned long config;
29206763c74SThomas Petazzoni 
2932035d39dSSebastian Hesselbarth 	dove_audio1_ctrl_get(pid, &config);
29406763c74SThomas Petazzoni 
29506763c74SThomas Petazzoni 	switch (config) {
29606763c74SThomas Petazzoni 	case 0x02: /* i2s1 : gpio[56:57] */
29706763c74SThomas Petazzoni 	case 0x0e: /* ssp  : gpio[56:57] */
29806763c74SThomas Petazzoni 		if (pid >= 56)
29906763c74SThomas Petazzoni 			return 0;
30006763c74SThomas Petazzoni 		return -ENOTSUPP;
30106763c74SThomas Petazzoni 	case 0x08: /* spdifo : gpio[52:55] */
30206763c74SThomas Petazzoni 	case 0x0b: /* twsi   : gpio[52:55] */
30306763c74SThomas Petazzoni 		if (pid <= 55)
30406763c74SThomas Petazzoni 			return 0;
30506763c74SThomas Petazzoni 		return -ENOTSUPP;
30606763c74SThomas Petazzoni 	case 0x0a: /* all gpio */
30706763c74SThomas Petazzoni 		return 0;
30806763c74SThomas Petazzoni 	/* 0x00 : i2s1/spdifo : no gpio */
30906763c74SThomas Petazzoni 	/* 0x0c : ssp/spdifo  : no gpio */
31006763c74SThomas Petazzoni 	/* 0x0f : ssp/twsi    : no gpio */
31106763c74SThomas Petazzoni 	}
31206763c74SThomas Petazzoni 	return -ENOTSUPP;
31306763c74SThomas Petazzoni }
31406763c74SThomas Petazzoni 
31506763c74SThomas Petazzoni /* mpp[52:57] has gpio pins capable of in and out */
3162035d39dSSebastian Hesselbarth static int dove_audio1_ctrl_gpio_dir(unsigned pid, bool input)
31706763c74SThomas Petazzoni {
31806763c74SThomas Petazzoni 	if (pid < 52 || pid > 57)
31906763c74SThomas Petazzoni 		return -ENOTSUPP;
32006763c74SThomas Petazzoni 	return 0;
32106763c74SThomas Petazzoni }
32206763c74SThomas Petazzoni 
3232035d39dSSebastian Hesselbarth static int dove_twsi_ctrl_get(unsigned pid, unsigned long *config)
32406763c74SThomas Petazzoni {
32506763c74SThomas Petazzoni 	unsigned long gcfg1 = readl(DOVE_GLOBAL_CONFIG_1);
32606763c74SThomas Petazzoni 	unsigned long gcfg2 = readl(DOVE_GLOBAL_CONFIG_2);
32706763c74SThomas Petazzoni 
32806763c74SThomas Petazzoni 	*config = 0;
32906763c74SThomas Petazzoni 	if (gcfg1 & DOVE_TWSI_ENABLE_OPTION1)
33006763c74SThomas Petazzoni 		*config = 1;
33106763c74SThomas Petazzoni 	else if (gcfg2 & DOVE_TWSI_ENABLE_OPTION2)
33206763c74SThomas Petazzoni 		*config = 2;
33306763c74SThomas Petazzoni 	else if (gcfg2 & DOVE_TWSI_ENABLE_OPTION3)
33406763c74SThomas Petazzoni 		*config = 3;
33506763c74SThomas Petazzoni 
33606763c74SThomas Petazzoni 	return 0;
33706763c74SThomas Petazzoni }
33806763c74SThomas Petazzoni 
3392035d39dSSebastian Hesselbarth static int dove_twsi_ctrl_set(unsigned pid, unsigned long config)
34006763c74SThomas Petazzoni {
34106763c74SThomas Petazzoni 	unsigned long gcfg1 = readl(DOVE_GLOBAL_CONFIG_1);
34206763c74SThomas Petazzoni 	unsigned long gcfg2 = readl(DOVE_GLOBAL_CONFIG_2);
34306763c74SThomas Petazzoni 
34406763c74SThomas Petazzoni 	gcfg1 &= ~DOVE_TWSI_ENABLE_OPTION1;
3456d0a4ed2SRoel Kluin 	gcfg2 &= ~(DOVE_TWSI_ENABLE_OPTION2 | DOVE_TWSI_ENABLE_OPTION3);
34606763c74SThomas Petazzoni 
34706763c74SThomas Petazzoni 	switch (config) {
34806763c74SThomas Petazzoni 	case 1:
34906763c74SThomas Petazzoni 		gcfg1 |= DOVE_TWSI_ENABLE_OPTION1;
35006763c74SThomas Petazzoni 		break;
35106763c74SThomas Petazzoni 	case 2:
35206763c74SThomas Petazzoni 		gcfg2 |= DOVE_TWSI_ENABLE_OPTION2;
35306763c74SThomas Petazzoni 		break;
35406763c74SThomas Petazzoni 	case 3:
35506763c74SThomas Petazzoni 		gcfg2 |= DOVE_TWSI_ENABLE_OPTION3;
35606763c74SThomas Petazzoni 		break;
35706763c74SThomas Petazzoni 	}
35806763c74SThomas Petazzoni 
35906763c74SThomas Petazzoni 	writel(gcfg1, DOVE_GLOBAL_CONFIG_1);
36006763c74SThomas Petazzoni 	writel(gcfg2, DOVE_GLOBAL_CONFIG_2);
36106763c74SThomas Petazzoni 
36206763c74SThomas Petazzoni 	return 0;
36306763c74SThomas Petazzoni }
36406763c74SThomas Petazzoni 
36506763c74SThomas Petazzoni static struct mvebu_mpp_ctrl dove_mpp_controls[] = {
366c2f082feSSebastian Hesselbarth 	MPP_FUNC_CTRL(0, 15, NULL, dove_pmu_mpp_ctrl),
3671217b790SSebastian Hesselbarth 	MPP_FUNC_CTRL(16, 23, NULL, dove_mpp_ctrl),
36806763c74SThomas Petazzoni 	MPP_FUNC_CTRL(24, 39, "mpp_camera", dove_mpp4_ctrl),
36906763c74SThomas Petazzoni 	MPP_FUNC_CTRL(40, 45, "mpp_sdio0", dove_mpp4_ctrl),
37006763c74SThomas Petazzoni 	MPP_FUNC_CTRL(46, 51, "mpp_sdio1", dove_mpp4_ctrl),
37106763c74SThomas Petazzoni 	MPP_FUNC_GPIO_CTRL(52, 57, "mpp_audio1", dove_audio1_ctrl),
37206763c74SThomas Petazzoni 	MPP_FUNC_CTRL(58, 61, "mpp_spi0", dove_mpp4_ctrl),
37306763c74SThomas Petazzoni 	MPP_FUNC_CTRL(62, 63, "mpp_uart1", dove_mpp4_ctrl),
37406763c74SThomas Petazzoni 	MPP_FUNC_CTRL(64, 71, "mpp_nand", dove_nand_ctrl),
37506763c74SThomas Petazzoni 	MPP_FUNC_CTRL(72, 72, "audio0", dove_audio0_ctrl),
37606763c74SThomas Petazzoni 	MPP_FUNC_CTRL(73, 73, "twsi", dove_twsi_ctrl),
37706763c74SThomas Petazzoni };
37806763c74SThomas Petazzoni 
37906763c74SThomas Petazzoni static struct mvebu_mpp_mode dove_mpp_modes[] = {
38006763c74SThomas Petazzoni 	MPP_MODE(0,
38106763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
38206763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart2", "rts"),
38306763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio0", "cd"),
38406763c74SThomas Petazzoni 		MPP_FUNCTION(0x0f, "lcd0", "pwm"),
385bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
386bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
387bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
388bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
389bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
390bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
391bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
392bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
393bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
394bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
395bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
396bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
39706763c74SThomas Petazzoni 	MPP_MODE(1,
39806763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
39906763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart2", "cts"),
40006763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio0", "wp"),
40106763c74SThomas Petazzoni 		MPP_FUNCTION(0x0f, "lcd1", "pwm"),
402bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
403bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
404bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
405bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
406bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
407bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
408bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
409bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
410bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
411bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
412bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
413bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
41406763c74SThomas Petazzoni 	MPP_MODE(2,
41506763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
41606763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "sata", "prsnt"),
41706763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart2", "txd"),
41806763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio0", "buspwr"),
41906763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "uart1", "rts"),
420bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
421bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
422bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
423bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
424bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
425bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
426bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
427bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
428bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
429bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
430bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
431bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
43206763c74SThomas Petazzoni 	MPP_MODE(3,
43306763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
43406763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "sata", "act"),
43506763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart2", "rxd"),
43606763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio0", "ledctrl"),
43706763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "uart1", "cts"),
43806763c74SThomas Petazzoni 		MPP_FUNCTION(0x0f, "lcd-spi", "cs1"),
439bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
440bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
441bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
442bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
443bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
444bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
445bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
446bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
447bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
448bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
449bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
450bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
45106763c74SThomas Petazzoni 	MPP_MODE(4,
45206763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
45306763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart3", "rts"),
45406763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio1", "cd"),
45506763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "spi1", "miso"),
456bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
457bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
458bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
459bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
460bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
461bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
462bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
463bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
464bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
465bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
466bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
467bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
46806763c74SThomas Petazzoni 	MPP_MODE(5,
46906763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
47006763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart3", "cts"),
47106763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio1", "wp"),
47206763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "spi1", "cs"),
473bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
474bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
475bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
476bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
477bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
478bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
479bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
480bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
481bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
482bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
483bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
484bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
48506763c74SThomas Petazzoni 	MPP_MODE(6,
48606763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
48706763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart3", "txd"),
48806763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio1", "buspwr"),
48906763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "spi1", "mosi"),
490bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
491bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
492bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
493bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
494bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
495bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
496bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
497bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
498bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
499bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
500bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
501bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
50206763c74SThomas Petazzoni 	MPP_MODE(7,
50306763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
50406763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart3", "rxd"),
50506763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio1", "ledctrl"),
50606763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "spi1", "sck"),
507bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
508bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
509bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
510bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
511bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
512bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
513bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
514bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
515bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
516bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
517bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
518bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
51906763c74SThomas Petazzoni 	MPP_MODE(8,
52006763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
52106763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "watchdog", "rstout"),
522bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
523bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
524bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
525bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
526bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
527bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
528bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
529bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
530bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
531bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
532bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
533bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
53406763c74SThomas Petazzoni 	MPP_MODE(9,
53506763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
53606763c74SThomas Petazzoni 		MPP_FUNCTION(0x05, "pex1", "clkreq"),
537bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
538bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
539bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
540bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
541bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
542bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
543bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
544bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
545bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
546bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
547bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
548bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
54906763c74SThomas Petazzoni 	MPP_MODE(10,
55006763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
55106763c74SThomas Petazzoni 		MPP_FUNCTION(0x05, "ssp", "sclk"),
552bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
553bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
554bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
555bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
556bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
557bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
558bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
559bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
560bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
561bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
562bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
563bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
56406763c74SThomas Petazzoni 	MPP_MODE(11,
56506763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
56606763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "sata", "prsnt"),
56706763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "sata-1", "act"),
56806763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio0", "ledctrl"),
56906763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "sdio1", "ledctrl"),
57006763c74SThomas Petazzoni 		MPP_FUNCTION(0x05, "pex0", "clkreq"),
571bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
572bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
573bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
574bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
575bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
576bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
577bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
578bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
579bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
580bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
581bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
582bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
58306763c74SThomas Petazzoni 	MPP_MODE(12,
58406763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
58506763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "sata", "act"),
58606763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart2", "rts"),
58706763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "audio0", "extclk"),
58806763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "sdio1", "cd"),
589bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
590bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
591bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
592bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
593bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
594bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
595bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
596bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
597bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
598bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
599bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
600bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
60106763c74SThomas Petazzoni 	MPP_MODE(13,
60206763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
60306763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart2", "cts"),
60406763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "audio1", "extclk"),
60506763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "sdio1", "wp"),
60606763c74SThomas Petazzoni 		MPP_FUNCTION(0x05, "ssp", "extclk"),
607bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
608bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
609bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
610bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
611bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
612bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
613bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
614bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
615bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
616bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
617bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
618bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
61906763c74SThomas Petazzoni 	MPP_MODE(14,
62006763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
62106763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart2", "txd"),
62206763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "sdio1", "buspwr"),
62306763c74SThomas Petazzoni 		MPP_FUNCTION(0x05, "ssp", "rxd"),
624bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
625bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
626bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
627bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
628bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
629bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
630bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
631bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
632bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
633bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
634bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
635bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
63606763c74SThomas Petazzoni 	MPP_MODE(15,
63706763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
63806763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart2", "rxd"),
63906763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "sdio1", "ledctrl"),
64006763c74SThomas Petazzoni 		MPP_FUNCTION(0x05, "ssp", "sfrm"),
641bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
642bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
643bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
644bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
645bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
646bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
647bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
648bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
649bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
650bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
651bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
652bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
65306763c74SThomas Petazzoni 	MPP_MODE(16,
65406763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
65506763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart3", "rts"),
65606763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio0", "cd"),
65706763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "lcd-spi", "cs1"),
65806763c74SThomas Petazzoni 		MPP_FUNCTION(0x05, "ac97", "sdi1")),
65906763c74SThomas Petazzoni 	MPP_MODE(17,
66006763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
66106763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "ac97-1", "sysclko"),
66206763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart3", "cts"),
66306763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio0", "wp"),
66406763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "twsi", "sda"),
66506763c74SThomas Petazzoni 		MPP_FUNCTION(0x05, "ac97", "sdi2")),
66606763c74SThomas Petazzoni 	MPP_MODE(18,
66706763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
66806763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart3", "txd"),
66906763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio0", "buspwr"),
67006763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "lcd0", "pwm"),
67106763c74SThomas Petazzoni 		MPP_FUNCTION(0x05, "ac97", "sdi3")),
67206763c74SThomas Petazzoni 	MPP_MODE(19,
67306763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
67406763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart3", "rxd"),
67506763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio0", "ledctrl"),
67606763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "twsi", "sck")),
67706763c74SThomas Petazzoni 	MPP_MODE(20,
67806763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
67906763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "ac97", "sysclko"),
68006763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "lcd-spi", "miso"),
68106763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio1", "cd"),
68206763c74SThomas Petazzoni 		MPP_FUNCTION(0x05, "sdio0", "cd"),
68306763c74SThomas Petazzoni 		MPP_FUNCTION(0x06, "spi1", "miso")),
68406763c74SThomas Petazzoni 	MPP_MODE(21,
68506763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
68606763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "uart1", "rts"),
68706763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "lcd-spi", "cs0"),
68806763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio1", "wp"),
68906763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "ssp", "sfrm"),
69006763c74SThomas Petazzoni 		MPP_FUNCTION(0x05, "sdio0", "wp"),
69106763c74SThomas Petazzoni 		MPP_FUNCTION(0x06, "spi1", "cs")),
69206763c74SThomas Petazzoni 	MPP_MODE(22,
69306763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
69406763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "uart1", "cts"),
69506763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "lcd-spi", "mosi"),
69606763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio1", "buspwr"),
69706763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "ssp", "txd"),
69806763c74SThomas Petazzoni 		MPP_FUNCTION(0x05, "sdio0", "buspwr"),
69906763c74SThomas Petazzoni 		MPP_FUNCTION(0x06, "spi1", "mosi")),
70006763c74SThomas Petazzoni 	MPP_MODE(23,
70106763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
70206763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "lcd-spi", "sck"),
70306763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio1", "ledctrl"),
70406763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "ssp", "sclk"),
70506763c74SThomas Petazzoni 		MPP_FUNCTION(0x05, "sdio0", "ledctrl"),
70606763c74SThomas Petazzoni 		MPP_FUNCTION(0x06, "spi1", "sck")),
70706763c74SThomas Petazzoni 	MPP_MODE(24,
70806763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "camera", NULL),
70906763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "gpio", NULL)),
71006763c74SThomas Petazzoni 	MPP_MODE(40,
71106763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "sdio0", NULL),
71206763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "gpio", NULL)),
71306763c74SThomas Petazzoni 	MPP_MODE(46,
71406763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "sdio1", NULL),
71506763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "gpio", NULL)),
71606763c74SThomas Petazzoni 	MPP_MODE(52,
71706763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "i2s1/spdifo", NULL),
71806763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "i2s1", NULL),
71906763c74SThomas Petazzoni 		MPP_FUNCTION(0x08, "spdifo", NULL),
72006763c74SThomas Petazzoni 		MPP_FUNCTION(0x0a, "gpio", NULL),
72106763c74SThomas Petazzoni 		MPP_FUNCTION(0x0b, "twsi", NULL),
72206763c74SThomas Petazzoni 		MPP_FUNCTION(0x0c, "ssp/spdifo", NULL),
72306763c74SThomas Petazzoni 		MPP_FUNCTION(0x0e, "ssp", NULL),
72406763c74SThomas Petazzoni 		MPP_FUNCTION(0x0f, "ssp/twsi", NULL)),
72506763c74SThomas Petazzoni 	MPP_MODE(58,
72606763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "spi0", NULL),
72706763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "gpio", NULL)),
72806763c74SThomas Petazzoni 	MPP_MODE(62,
72906763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "uart1", NULL),
73006763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "gpio", NULL)),
73106763c74SThomas Petazzoni 	MPP_MODE(64,
73206763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "nand", NULL),
73306763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "gpo", NULL)),
73406763c74SThomas Petazzoni 	MPP_MODE(72,
73506763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "i2s", NULL),
73606763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "ac97", NULL)),
73706763c74SThomas Petazzoni 	MPP_MODE(73,
73806763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "twsi-none", NULL),
73906763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "twsi-opt1", NULL),
74006763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "twsi-opt2", NULL),
74106763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "twsi-opt3", NULL)),
74206763c74SThomas Petazzoni };
74306763c74SThomas Petazzoni 
74406763c74SThomas Petazzoni static struct pinctrl_gpio_range dove_mpp_gpio_ranges[] = {
74506763c74SThomas Petazzoni 	MPP_GPIO_RANGE(0,  0,  0, 32),
74606763c74SThomas Petazzoni 	MPP_GPIO_RANGE(1, 32, 32, 32),
74706763c74SThomas Petazzoni 	MPP_GPIO_RANGE(2, 64, 64,  8),
74806763c74SThomas Petazzoni };
74906763c74SThomas Petazzoni 
75006763c74SThomas Petazzoni static struct mvebu_pinctrl_soc_info dove_pinctrl_info = {
75106763c74SThomas Petazzoni 	.controls = dove_mpp_controls,
75206763c74SThomas Petazzoni 	.ncontrols = ARRAY_SIZE(dove_mpp_controls),
75306763c74SThomas Petazzoni 	.modes = dove_mpp_modes,
75406763c74SThomas Petazzoni 	.nmodes = ARRAY_SIZE(dove_mpp_modes),
75506763c74SThomas Petazzoni 	.gpioranges = dove_mpp_gpio_ranges,
75606763c74SThomas Petazzoni 	.ngpioranges = ARRAY_SIZE(dove_mpp_gpio_ranges),
75706763c74SThomas Petazzoni 	.variant = 0,
75806763c74SThomas Petazzoni };
75906763c74SThomas Petazzoni 
76006763c74SThomas Petazzoni static struct clk *clk;
76106763c74SThomas Petazzoni 
762150632b0SGreg Kroah-Hartman static struct of_device_id dove_pinctrl_of_match[] = {
76306763c74SThomas Petazzoni 	{ .compatible = "marvell,dove-pinctrl", .data = &dove_pinctrl_info },
76406763c74SThomas Petazzoni 	{ }
76506763c74SThomas Petazzoni };
76606763c74SThomas Petazzoni 
767e91f7916SSebastian Hesselbarth static struct regmap_config gc_regmap_config = {
768e91f7916SSebastian Hesselbarth 	.reg_bits = 32,
769e91f7916SSebastian Hesselbarth 	.val_bits = 32,
770e91f7916SSebastian Hesselbarth 	.reg_stride = 4,
771e91f7916SSebastian Hesselbarth 	.max_register = 5,
772e91f7916SSebastian Hesselbarth };
773e91f7916SSebastian Hesselbarth 
774150632b0SGreg Kroah-Hartman static int dove_pinctrl_probe(struct platform_device *pdev)
77506763c74SThomas Petazzoni {
7764d73fc77SSebastian Hesselbarth 	struct resource *res, *mpp_res;
7774d73fc77SSebastian Hesselbarth 	struct resource fb_res;
77806763c74SThomas Petazzoni 	const struct of_device_id *match =
77906763c74SThomas Petazzoni 		of_match_device(dove_pinctrl_of_match, &pdev->dev);
78016fa36beSAndrew Lunn 	pdev->dev.platform_data = (void *)match->data;
78106763c74SThomas Petazzoni 
78206763c74SThomas Petazzoni 	/*
78306763c74SThomas Petazzoni 	 * General MPP Configuration Register is part of pdma registers.
78406763c74SThomas Petazzoni 	 * grab clk to make sure it is ticking.
78506763c74SThomas Petazzoni 	 */
78606763c74SThomas Petazzoni 	clk = devm_clk_get(&pdev->dev, NULL);
787ba607b62SSebastian Hesselbarth 	if (IS_ERR(clk)) {
788ba607b62SSebastian Hesselbarth 		dev_err(&pdev->dev, "Unable to get pdma clock");
7895795c6acSRusty Russell 		return PTR_ERR(clk);
790ba607b62SSebastian Hesselbarth 	}
79106763c74SThomas Petazzoni 	clk_prepare_enable(clk);
79206763c74SThomas Petazzoni 
7934d73fc77SSebastian Hesselbarth 	mpp_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
7944d73fc77SSebastian Hesselbarth 	mpp_base = devm_ioremap_resource(&pdev->dev, mpp_res);
7951217b790SSebastian Hesselbarth 	if (IS_ERR(mpp_base))
7961217b790SSebastian Hesselbarth 		return PTR_ERR(mpp_base);
7971217b790SSebastian Hesselbarth 
7984d73fc77SSebastian Hesselbarth 	/* prepare fallback resource */
7994d73fc77SSebastian Hesselbarth 	memcpy(&fb_res, mpp_res, sizeof(struct resource));
8004d73fc77SSebastian Hesselbarth 	fb_res.start = 0;
8014d73fc77SSebastian Hesselbarth 
8024d73fc77SSebastian Hesselbarth 	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
8034d73fc77SSebastian Hesselbarth 	if (!res) {
8044d73fc77SSebastian Hesselbarth 		dev_warn(&pdev->dev, "falling back to hardcoded MPP4 resource\n");
8054d73fc77SSebastian Hesselbarth 		adjust_resource(&fb_res,
8064d73fc77SSebastian Hesselbarth 			(mpp_res->start & INT_REGS_MASK) + MPP4_REGS_OFFS, 0x4);
8074d73fc77SSebastian Hesselbarth 		res = &fb_res;
8084d73fc77SSebastian Hesselbarth 	}
8094d73fc77SSebastian Hesselbarth 
8104d73fc77SSebastian Hesselbarth 	mpp4_base = devm_ioremap_resource(&pdev->dev, res);
8114d73fc77SSebastian Hesselbarth 	if (IS_ERR(mpp4_base))
8124d73fc77SSebastian Hesselbarth 		return PTR_ERR(mpp4_base);
8134d73fc77SSebastian Hesselbarth 
8144d73fc77SSebastian Hesselbarth 	res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
8154d73fc77SSebastian Hesselbarth 	if (!res) {
8164d73fc77SSebastian Hesselbarth 		dev_warn(&pdev->dev, "falling back to hardcoded PMU resource\n");
8174d73fc77SSebastian Hesselbarth 		adjust_resource(&fb_res,
8184d73fc77SSebastian Hesselbarth 			(mpp_res->start & INT_REGS_MASK) + PMU_REGS_OFFS, 0x8);
8194d73fc77SSebastian Hesselbarth 		res = &fb_res;
8204d73fc77SSebastian Hesselbarth 	}
8214d73fc77SSebastian Hesselbarth 
8224d73fc77SSebastian Hesselbarth 	pmu_base = devm_ioremap_resource(&pdev->dev, res);
8234d73fc77SSebastian Hesselbarth 	if (IS_ERR(pmu_base))
8244d73fc77SSebastian Hesselbarth 		return PTR_ERR(pmu_base);
8254d73fc77SSebastian Hesselbarth 
826e91f7916SSebastian Hesselbarth 	gconfmap = syscon_regmap_lookup_by_compatible("marvell,dove-global-config");
827e91f7916SSebastian Hesselbarth 	if (IS_ERR(gconfmap)) {
828e91f7916SSebastian Hesselbarth 		void __iomem *gc_base;
829e91f7916SSebastian Hesselbarth 
830e91f7916SSebastian Hesselbarth 		dev_warn(&pdev->dev, "falling back to hardcoded global registers\n");
831e91f7916SSebastian Hesselbarth 		adjust_resource(&fb_res,
832e91f7916SSebastian Hesselbarth 			(mpp_res->start & INT_REGS_MASK) + GC_REGS_OFFS, 0x14);
833e91f7916SSebastian Hesselbarth 		gc_base = devm_ioremap_resource(&pdev->dev, &fb_res);
834e91f7916SSebastian Hesselbarth 		if (IS_ERR(gc_base))
835e91f7916SSebastian Hesselbarth 			return PTR_ERR(gc_base);
836e91f7916SSebastian Hesselbarth 		gconfmap = devm_regmap_init_mmio(&pdev->dev,
837e91f7916SSebastian Hesselbarth 						 gc_base, &gc_regmap_config);
838e91f7916SSebastian Hesselbarth 		if (IS_ERR(gconfmap))
839e91f7916SSebastian Hesselbarth 			return PTR_ERR(gconfmap);
840e91f7916SSebastian Hesselbarth 	}
841e91f7916SSebastian Hesselbarth 
8424d73fc77SSebastian Hesselbarth 	/* Warn on any missing DT resource */
8434d73fc77SSebastian Hesselbarth 	WARN(fb_res.start, FW_BUG "Missing pinctrl regs in DTB. Please update your firmware.\n");
8444d73fc77SSebastian Hesselbarth 
84506763c74SThomas Petazzoni 	return mvebu_pinctrl_probe(pdev);
84606763c74SThomas Petazzoni }
84706763c74SThomas Petazzoni 
848150632b0SGreg Kroah-Hartman static int dove_pinctrl_remove(struct platform_device *pdev)
84906763c74SThomas Petazzoni {
85006763c74SThomas Petazzoni 	int ret;
85106763c74SThomas Petazzoni 
85206763c74SThomas Petazzoni 	ret = mvebu_pinctrl_remove(pdev);
85306763c74SThomas Petazzoni 	if (!IS_ERR(clk))
85406763c74SThomas Petazzoni 		clk_disable_unprepare(clk);
85506763c74SThomas Petazzoni 	return ret;
85606763c74SThomas Petazzoni }
85706763c74SThomas Petazzoni 
85806763c74SThomas Petazzoni static struct platform_driver dove_pinctrl_driver = {
85906763c74SThomas Petazzoni 	.driver = {
86006763c74SThomas Petazzoni 		.name = "dove-pinctrl",
86106763c74SThomas Petazzoni 		.owner = THIS_MODULE,
862f2e9394dSSachin Kamat 		.of_match_table = dove_pinctrl_of_match,
86306763c74SThomas Petazzoni 	},
86406763c74SThomas Petazzoni 	.probe = dove_pinctrl_probe,
865150632b0SGreg Kroah-Hartman 	.remove = dove_pinctrl_remove,
86606763c74SThomas Petazzoni };
86706763c74SThomas Petazzoni 
86806763c74SThomas Petazzoni module_platform_driver(dove_pinctrl_driver);
86906763c74SThomas Petazzoni 
87006763c74SThomas Petazzoni MODULE_AUTHOR("Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>");
87106763c74SThomas Petazzoni MODULE_DESCRIPTION("Marvell Dove pinctrl driver");
87206763c74SThomas Petazzoni MODULE_LICENSE("GPL v2");
873