xref: /linux/drivers/pinctrl/mvebu/pinctrl-dove.c (revision 6da67cab4b7dd1bf49392886f0809292470b70e7)
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 
3300202b01SSebastian Hesselbarth /* MPP Base registers */
3400202b01SSebastian Hesselbarth #define PMU_MPP_GENERAL_CTRL	0x10
3500202b01SSebastian Hesselbarth #define  AU0_AC97_SEL		BIT(16)
3600202b01SSebastian Hesselbarth 
372c4b229bSSebastian Hesselbarth /* MPP Control 4 register */
382c4b229bSSebastian Hesselbarth #define SPI_GPIO_SEL		BIT(5)
392c4b229bSSebastian Hesselbarth #define UART1_GPIO_SEL		BIT(4)
402c4b229bSSebastian Hesselbarth #define AU1_GPIO_SEL		BIT(3)
412c4b229bSSebastian Hesselbarth #define CAM_GPIO_SEL		BIT(2)
422c4b229bSSebastian Hesselbarth #define SD1_GPIO_SEL		BIT(1)
432c4b229bSSebastian Hesselbarth #define SD0_GPIO_SEL		BIT(0)
442c4b229bSSebastian Hesselbarth 
4518e6f28eSSebastian Hesselbarth /* PMU Signal Select registers */
4618e6f28eSSebastian Hesselbarth #define PMU_SIGNAL_SELECT_0	0x00
4718e6f28eSSebastian Hesselbarth #define PMU_SIGNAL_SELECT_1	0x04
4818e6f28eSSebastian Hesselbarth 
49*6da67cabSSebastian Hesselbarth /* Global Config regmap registers */
50*6da67cabSSebastian Hesselbarth #define GLOBAL_CONFIG_1		0x00
51*6da67cabSSebastian Hesselbarth #define  TWSI_ENABLE_OPTION1	BIT(7)
52*6da67cabSSebastian Hesselbarth #define GLOBAL_CONFIG_2		0x04
53*6da67cabSSebastian Hesselbarth #define  TWSI_ENABLE_OPTION2	BIT(20)
54*6da67cabSSebastian Hesselbarth #define  TWSI_ENABLE_OPTION3	BIT(21)
55*6da67cabSSebastian Hesselbarth #define  TWSI_OPTION3_GPIO	BIT(22)
56*6da67cabSSebastian Hesselbarth #define SSP_CTRL_STATUS_1	0x08
57*6da67cabSSebastian Hesselbarth #define  SSP_ON_AU1		BIT(0)
58*6da67cabSSebastian Hesselbarth #define MPP_GENERAL_CONFIG	0x10
59*6da67cabSSebastian Hesselbarth #define  AU1_SPDIFO_GPIO_EN	BIT(1)
60*6da67cabSSebastian Hesselbarth #define  NAND_GPIO_EN		BIT(0)
61*6da67cabSSebastian Hesselbarth 
6206763c74SThomas Petazzoni #define CONFIG_PMU	BIT(4)
6306763c74SThomas Petazzoni 
6417bdec67SSebastian Hesselbarth static void __iomem *mpp_base;
654d73fc77SSebastian Hesselbarth static void __iomem *mpp4_base;
664d73fc77SSebastian Hesselbarth static void __iomem *pmu_base;
67e91f7916SSebastian Hesselbarth static struct regmap *gconfmap;
6817bdec67SSebastian Hesselbarth 
6917bdec67SSebastian Hesselbarth static int dove_mpp_ctrl_get(unsigned pid, unsigned long *config)
7017bdec67SSebastian Hesselbarth {
7117bdec67SSebastian Hesselbarth 	return default_mpp_ctrl_get(mpp_base, pid, config);
7217bdec67SSebastian Hesselbarth }
7317bdec67SSebastian Hesselbarth 
7417bdec67SSebastian Hesselbarth static int dove_mpp_ctrl_set(unsigned pid, unsigned long config)
7517bdec67SSebastian Hesselbarth {
7617bdec67SSebastian Hesselbarth 	return default_mpp_ctrl_set(mpp_base, pid, config);
7717bdec67SSebastian Hesselbarth }
7817bdec67SSebastian Hesselbarth 
792035d39dSSebastian Hesselbarth static int dove_pmu_mpp_ctrl_get(unsigned pid, unsigned long *config)
8006763c74SThomas Petazzoni {
8117bdec67SSebastian Hesselbarth 	unsigned off = (pid / MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS;
8217bdec67SSebastian Hesselbarth 	unsigned shift = (pid % MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS;
8300202b01SSebastian Hesselbarth 	unsigned long pmu = readl(mpp_base + PMU_MPP_GENERAL_CTRL);
84bbd7b275SSebastian Hesselbarth 	unsigned long func;
8506763c74SThomas Petazzoni 
8678c2c3d3SSebastian Hesselbarth 	if ((pmu & BIT(pid)) == 0)
8778c2c3d3SSebastian Hesselbarth 		return default_mpp_ctrl_get(mpp_base, pid, config);
8878c2c3d3SSebastian Hesselbarth 
8918e6f28eSSebastian Hesselbarth 	func = readl(pmu_base + PMU_SIGNAL_SELECT_0 + off);
9017bdec67SSebastian Hesselbarth 	*config = (func >> shift) & MVEBU_MPP_MASK;
91bbd7b275SSebastian Hesselbarth 	*config |= CONFIG_PMU;
9278c2c3d3SSebastian Hesselbarth 
9306763c74SThomas Petazzoni 	return 0;
9406763c74SThomas Petazzoni }
9506763c74SThomas Petazzoni 
962035d39dSSebastian Hesselbarth static int dove_pmu_mpp_ctrl_set(unsigned pid, unsigned long config)
9706763c74SThomas Petazzoni {
9817bdec67SSebastian Hesselbarth 	unsigned off = (pid / MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS;
9917bdec67SSebastian Hesselbarth 	unsigned shift = (pid % MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS;
10000202b01SSebastian Hesselbarth 	unsigned long pmu = readl(mpp_base + PMU_MPP_GENERAL_CTRL);
101bbd7b275SSebastian Hesselbarth 	unsigned long func;
10206763c74SThomas Petazzoni 
10378c2c3d3SSebastian Hesselbarth 	if ((config & CONFIG_PMU) == 0) {
10400202b01SSebastian Hesselbarth 		writel(pmu & ~BIT(pid), mpp_base + PMU_MPP_GENERAL_CTRL);
10578c2c3d3SSebastian Hesselbarth 		return default_mpp_ctrl_set(mpp_base, pid, config);
10678c2c3d3SSebastian Hesselbarth 	}
10778c2c3d3SSebastian Hesselbarth 
10800202b01SSebastian Hesselbarth 	writel(pmu | BIT(pid), mpp_base + PMU_MPP_GENERAL_CTRL);
10918e6f28eSSebastian Hesselbarth 	func = readl(pmu_base + PMU_SIGNAL_SELECT_0 + off);
11017bdec67SSebastian Hesselbarth 	func &= ~(MVEBU_MPP_MASK << shift);
11117bdec67SSebastian Hesselbarth 	func |= (config & MVEBU_MPP_MASK) << shift;
11218e6f28eSSebastian Hesselbarth 	writel(func, pmu_base + PMU_SIGNAL_SELECT_0 + off);
11378c2c3d3SSebastian Hesselbarth 
11406763c74SThomas Petazzoni 	return 0;
11506763c74SThomas Petazzoni }
11606763c74SThomas Petazzoni 
1172035d39dSSebastian Hesselbarth static int dove_mpp4_ctrl_get(unsigned pid, unsigned long *config)
11806763c74SThomas Petazzoni {
1192c4b229bSSebastian Hesselbarth 	unsigned long mpp4 = readl(mpp4_base);
12006763c74SThomas Petazzoni 	unsigned long mask;
12106763c74SThomas Petazzoni 
1222035d39dSSebastian Hesselbarth 	switch (pid) {
12306763c74SThomas Petazzoni 	case 24: /* mpp_camera */
1242c4b229bSSebastian Hesselbarth 		mask = CAM_GPIO_SEL;
12506763c74SThomas Petazzoni 		break;
12606763c74SThomas Petazzoni 	case 40: /* mpp_sdio0 */
1272c4b229bSSebastian Hesselbarth 		mask = SD0_GPIO_SEL;
12806763c74SThomas Petazzoni 		break;
12906763c74SThomas Petazzoni 	case 46: /* mpp_sdio1 */
1302c4b229bSSebastian Hesselbarth 		mask = SD1_GPIO_SEL;
13106763c74SThomas Petazzoni 		break;
13206763c74SThomas Petazzoni 	case 58: /* mpp_spi0 */
1332c4b229bSSebastian Hesselbarth 		mask = SPI_GPIO_SEL;
13406763c74SThomas Petazzoni 		break;
13506763c74SThomas Petazzoni 	case 62: /* mpp_uart1 */
1362c4b229bSSebastian Hesselbarth 		mask = UART1_GPIO_SEL;
13706763c74SThomas Petazzoni 		break;
13806763c74SThomas Petazzoni 	default:
13906763c74SThomas Petazzoni 		return -EINVAL;
14006763c74SThomas Petazzoni 	}
14106763c74SThomas Petazzoni 
14206763c74SThomas Petazzoni 	*config = ((mpp4 & mask) != 0);
14306763c74SThomas Petazzoni 
14406763c74SThomas Petazzoni 	return 0;
14506763c74SThomas Petazzoni }
14606763c74SThomas Petazzoni 
1472035d39dSSebastian Hesselbarth static int dove_mpp4_ctrl_set(unsigned pid, unsigned long config)
14806763c74SThomas Petazzoni {
1492c4b229bSSebastian Hesselbarth 	unsigned long mpp4 = readl(mpp4_base);
15006763c74SThomas Petazzoni 	unsigned long mask;
15106763c74SThomas Petazzoni 
1522035d39dSSebastian Hesselbarth 	switch (pid) {
15306763c74SThomas Petazzoni 	case 24: /* mpp_camera */
1542c4b229bSSebastian Hesselbarth 		mask = CAM_GPIO_SEL;
15506763c74SThomas Petazzoni 		break;
15606763c74SThomas Petazzoni 	case 40: /* mpp_sdio0 */
1572c4b229bSSebastian Hesselbarth 		mask = SD0_GPIO_SEL;
15806763c74SThomas Petazzoni 		break;
15906763c74SThomas Petazzoni 	case 46: /* mpp_sdio1 */
1602c4b229bSSebastian Hesselbarth 		mask = SD1_GPIO_SEL;
16106763c74SThomas Petazzoni 		break;
16206763c74SThomas Petazzoni 	case 58: /* mpp_spi0 */
1632c4b229bSSebastian Hesselbarth 		mask = SPI_GPIO_SEL;
16406763c74SThomas Petazzoni 		break;
16506763c74SThomas Petazzoni 	case 62: /* mpp_uart1 */
1662c4b229bSSebastian Hesselbarth 		mask = UART1_GPIO_SEL;
16706763c74SThomas Petazzoni 		break;
16806763c74SThomas Petazzoni 	default:
16906763c74SThomas Petazzoni 		return -EINVAL;
17006763c74SThomas Petazzoni 	}
17106763c74SThomas Petazzoni 
17206763c74SThomas Petazzoni 	mpp4 &= ~mask;
17306763c74SThomas Petazzoni 	if (config)
17406763c74SThomas Petazzoni 		mpp4 |= mask;
17506763c74SThomas Petazzoni 
1762c4b229bSSebastian Hesselbarth 	writel(mpp4, mpp4_base);
17706763c74SThomas Petazzoni 
17806763c74SThomas Petazzoni 	return 0;
17906763c74SThomas Petazzoni }
18006763c74SThomas Petazzoni 
1812035d39dSSebastian Hesselbarth static int dove_nand_ctrl_get(unsigned pid, unsigned long *config)
18206763c74SThomas Petazzoni {
183*6da67cabSSebastian Hesselbarth 	unsigned int gmpp;
18406763c74SThomas Petazzoni 
185*6da67cabSSebastian Hesselbarth 	regmap_read(gconfmap, MPP_GENERAL_CONFIG, &gmpp);
186*6da67cabSSebastian Hesselbarth 	*config = ((gmpp & NAND_GPIO_EN) != 0);
18706763c74SThomas Petazzoni 
18806763c74SThomas Petazzoni 	return 0;
18906763c74SThomas Petazzoni }
19006763c74SThomas Petazzoni 
1912035d39dSSebastian Hesselbarth static int dove_nand_ctrl_set(unsigned pid, unsigned long config)
19206763c74SThomas Petazzoni {
193*6da67cabSSebastian Hesselbarth 	regmap_update_bits(gconfmap, MPP_GENERAL_CONFIG,
194*6da67cabSSebastian Hesselbarth 			   NAND_GPIO_EN,
195*6da67cabSSebastian Hesselbarth 			   (config) ? NAND_GPIO_EN : 0);
19606763c74SThomas Petazzoni 	return 0;
19706763c74SThomas Petazzoni }
19806763c74SThomas Petazzoni 
1992035d39dSSebastian Hesselbarth static int dove_audio0_ctrl_get(unsigned pid, unsigned long *config)
20006763c74SThomas Petazzoni {
20100202b01SSebastian Hesselbarth 	unsigned long pmu = readl(mpp_base + PMU_MPP_GENERAL_CTRL);
20206763c74SThomas Petazzoni 
20300202b01SSebastian Hesselbarth 	*config = ((pmu & AU0_AC97_SEL) != 0);
20406763c74SThomas Petazzoni 
20506763c74SThomas Petazzoni 	return 0;
20606763c74SThomas Petazzoni }
20706763c74SThomas Petazzoni 
2082035d39dSSebastian Hesselbarth static int dove_audio0_ctrl_set(unsigned pid, unsigned long config)
20906763c74SThomas Petazzoni {
21000202b01SSebastian Hesselbarth 	unsigned long pmu = readl(mpp_base + PMU_MPP_GENERAL_CTRL);
21106763c74SThomas Petazzoni 
21200202b01SSebastian Hesselbarth 	pmu &= ~AU0_AC97_SEL;
21306763c74SThomas Petazzoni 	if (config)
21400202b01SSebastian Hesselbarth 		pmu |= AU0_AC97_SEL;
21500202b01SSebastian Hesselbarth 	writel(pmu, mpp_base + PMU_MPP_GENERAL_CTRL);
21606763c74SThomas Petazzoni 
21706763c74SThomas Petazzoni 	return 0;
21806763c74SThomas Petazzoni }
21906763c74SThomas Petazzoni 
2202035d39dSSebastian Hesselbarth static int dove_audio1_ctrl_get(unsigned pid, unsigned long *config)
22106763c74SThomas Petazzoni {
2222c4b229bSSebastian Hesselbarth 	unsigned int mpp4 = readl(mpp4_base);
223*6da67cabSSebastian Hesselbarth 	unsigned int sspc1;
224*6da67cabSSebastian Hesselbarth 	unsigned int gmpp;
225*6da67cabSSebastian Hesselbarth 	unsigned int gcfg2;
226*6da67cabSSebastian Hesselbarth 
227*6da67cabSSebastian Hesselbarth 	regmap_read(gconfmap, SSP_CTRL_STATUS_1, &sspc1);
228*6da67cabSSebastian Hesselbarth 	regmap_read(gconfmap, MPP_GENERAL_CONFIG, &gmpp);
229*6da67cabSSebastian Hesselbarth 	regmap_read(gconfmap, GLOBAL_CONFIG_2, &gcfg2);
23006763c74SThomas Petazzoni 
23106763c74SThomas Petazzoni 	*config = 0;
2322c4b229bSSebastian Hesselbarth 	if (mpp4 & AU1_GPIO_SEL)
23306763c74SThomas Petazzoni 		*config |= BIT(3);
234*6da67cabSSebastian Hesselbarth 	if (sspc1 & SSP_ON_AU1)
23506763c74SThomas Petazzoni 		*config |= BIT(2);
236*6da67cabSSebastian Hesselbarth 	if (gmpp & AU1_SPDIFO_GPIO_EN)
23706763c74SThomas Petazzoni 		*config |= BIT(1);
238*6da67cabSSebastian Hesselbarth 	if (gcfg2 & TWSI_OPTION3_GPIO)
23906763c74SThomas Petazzoni 		*config |= BIT(0);
24006763c74SThomas Petazzoni 
24106763c74SThomas Petazzoni 	/* SSP/TWSI only if I2S1 not set*/
24206763c74SThomas Petazzoni 	if ((*config & BIT(3)) == 0)
24306763c74SThomas Petazzoni 		*config &= ~(BIT(2) | BIT(0));
24406763c74SThomas Petazzoni 	/* TWSI only if SPDIFO not set*/
24506763c74SThomas Petazzoni 	if ((*config & BIT(1)) == 0)
24606763c74SThomas Petazzoni 		*config &= ~BIT(0);
24706763c74SThomas Petazzoni 	return 0;
24806763c74SThomas Petazzoni }
24906763c74SThomas Petazzoni 
2502035d39dSSebastian Hesselbarth static int dove_audio1_ctrl_set(unsigned pid, unsigned long config)
25106763c74SThomas Petazzoni {
2522c4b229bSSebastian Hesselbarth 	unsigned int mpp4 = readl(mpp4_base);
25306763c74SThomas Petazzoni 
2542c4b229bSSebastian Hesselbarth 	mpp4 &= ~AU1_GPIO_SEL;
25506763c74SThomas Petazzoni 	if (config & BIT(3))
2562c4b229bSSebastian Hesselbarth 		mpp4 |= AU1_GPIO_SEL;
2572c4b229bSSebastian Hesselbarth 	writel(mpp4, mpp4_base);
258*6da67cabSSebastian Hesselbarth 
259*6da67cabSSebastian Hesselbarth 	regmap_update_bits(gconfmap, SSP_CTRL_STATUS_1,
260*6da67cabSSebastian Hesselbarth 			   SSP_ON_AU1,
261*6da67cabSSebastian Hesselbarth 			   (config & BIT(2)) ? SSP_ON_AU1 : 0);
262*6da67cabSSebastian Hesselbarth 	regmap_update_bits(gconfmap, MPP_GENERAL_CONFIG,
263*6da67cabSSebastian Hesselbarth 			   AU1_SPDIFO_GPIO_EN,
264*6da67cabSSebastian Hesselbarth 			   (config & BIT(1)) ? AU1_SPDIFO_GPIO_EN : 0);
265*6da67cabSSebastian Hesselbarth 	regmap_update_bits(gconfmap, GLOBAL_CONFIG_2,
266*6da67cabSSebastian Hesselbarth 			   TWSI_OPTION3_GPIO,
267*6da67cabSSebastian Hesselbarth 			   (config & BIT(0)) ? TWSI_OPTION3_GPIO : 0);
26806763c74SThomas Petazzoni 
26906763c74SThomas Petazzoni 	return 0;
27006763c74SThomas Petazzoni }
27106763c74SThomas Petazzoni 
27206763c74SThomas Petazzoni /* mpp[52:57] gpio pins depend heavily on current config;
27306763c74SThomas Petazzoni  * gpio_req does not try to mux in gpio capabilities to not
27406763c74SThomas Petazzoni  * break other functions. If you require all mpps as gpio
27506763c74SThomas Petazzoni  * enforce gpio setting by pinctrl mapping.
27606763c74SThomas Petazzoni  */
2772035d39dSSebastian Hesselbarth static int dove_audio1_ctrl_gpio_req(unsigned pid)
27806763c74SThomas Petazzoni {
27906763c74SThomas Petazzoni 	unsigned long config;
28006763c74SThomas Petazzoni 
2812035d39dSSebastian Hesselbarth 	dove_audio1_ctrl_get(pid, &config);
28206763c74SThomas Petazzoni 
28306763c74SThomas Petazzoni 	switch (config) {
28406763c74SThomas Petazzoni 	case 0x02: /* i2s1 : gpio[56:57] */
28506763c74SThomas Petazzoni 	case 0x0e: /* ssp  : gpio[56:57] */
28606763c74SThomas Petazzoni 		if (pid >= 56)
28706763c74SThomas Petazzoni 			return 0;
28806763c74SThomas Petazzoni 		return -ENOTSUPP;
28906763c74SThomas Petazzoni 	case 0x08: /* spdifo : gpio[52:55] */
29006763c74SThomas Petazzoni 	case 0x0b: /* twsi   : gpio[52:55] */
29106763c74SThomas Petazzoni 		if (pid <= 55)
29206763c74SThomas Petazzoni 			return 0;
29306763c74SThomas Petazzoni 		return -ENOTSUPP;
29406763c74SThomas Petazzoni 	case 0x0a: /* all gpio */
29506763c74SThomas Petazzoni 		return 0;
29606763c74SThomas Petazzoni 	/* 0x00 : i2s1/spdifo : no gpio */
29706763c74SThomas Petazzoni 	/* 0x0c : ssp/spdifo  : no gpio */
29806763c74SThomas Petazzoni 	/* 0x0f : ssp/twsi    : no gpio */
29906763c74SThomas Petazzoni 	}
30006763c74SThomas Petazzoni 	return -ENOTSUPP;
30106763c74SThomas Petazzoni }
30206763c74SThomas Petazzoni 
30306763c74SThomas Petazzoni /* mpp[52:57] has gpio pins capable of in and out */
3042035d39dSSebastian Hesselbarth static int dove_audio1_ctrl_gpio_dir(unsigned pid, bool input)
30506763c74SThomas Petazzoni {
30606763c74SThomas Petazzoni 	if (pid < 52 || pid > 57)
30706763c74SThomas Petazzoni 		return -ENOTSUPP;
30806763c74SThomas Petazzoni 	return 0;
30906763c74SThomas Petazzoni }
31006763c74SThomas Petazzoni 
3112035d39dSSebastian Hesselbarth static int dove_twsi_ctrl_get(unsigned pid, unsigned long *config)
31206763c74SThomas Petazzoni {
313*6da67cabSSebastian Hesselbarth 	unsigned int gcfg1;
314*6da67cabSSebastian Hesselbarth 	unsigned int gcfg2;
315*6da67cabSSebastian Hesselbarth 
316*6da67cabSSebastian Hesselbarth 	regmap_read(gconfmap, GLOBAL_CONFIG_1, &gcfg1);
317*6da67cabSSebastian Hesselbarth 	regmap_read(gconfmap, GLOBAL_CONFIG_2, &gcfg2);
31806763c74SThomas Petazzoni 
31906763c74SThomas Petazzoni 	*config = 0;
320*6da67cabSSebastian Hesselbarth 	if (gcfg1 & TWSI_ENABLE_OPTION1)
32106763c74SThomas Petazzoni 		*config = 1;
322*6da67cabSSebastian Hesselbarth 	else if (gcfg2 & TWSI_ENABLE_OPTION2)
32306763c74SThomas Petazzoni 		*config = 2;
324*6da67cabSSebastian Hesselbarth 	else if (gcfg2 & TWSI_ENABLE_OPTION3)
32506763c74SThomas Petazzoni 		*config = 3;
32606763c74SThomas Petazzoni 
32706763c74SThomas Petazzoni 	return 0;
32806763c74SThomas Petazzoni }
32906763c74SThomas Petazzoni 
3302035d39dSSebastian Hesselbarth static int dove_twsi_ctrl_set(unsigned pid, unsigned long config)
33106763c74SThomas Petazzoni {
332*6da67cabSSebastian Hesselbarth 	unsigned int gcfg1 = 0;
333*6da67cabSSebastian Hesselbarth 	unsigned int gcfg2 = 0;
33406763c74SThomas Petazzoni 
33506763c74SThomas Petazzoni 	switch (config) {
33606763c74SThomas Petazzoni 	case 1:
337*6da67cabSSebastian Hesselbarth 		gcfg1 = TWSI_ENABLE_OPTION1;
33806763c74SThomas Petazzoni 		break;
33906763c74SThomas Petazzoni 	case 2:
340*6da67cabSSebastian Hesselbarth 		gcfg2 = TWSI_ENABLE_OPTION2;
34106763c74SThomas Petazzoni 		break;
34206763c74SThomas Petazzoni 	case 3:
343*6da67cabSSebastian Hesselbarth 		gcfg2 = TWSI_ENABLE_OPTION3;
34406763c74SThomas Petazzoni 		break;
34506763c74SThomas Petazzoni 	}
34606763c74SThomas Petazzoni 
347*6da67cabSSebastian Hesselbarth 	regmap_update_bits(gconfmap, GLOBAL_CONFIG_1,
348*6da67cabSSebastian Hesselbarth 			   TWSI_ENABLE_OPTION1,
349*6da67cabSSebastian Hesselbarth 			   gcfg1);
350*6da67cabSSebastian Hesselbarth 	regmap_update_bits(gconfmap, GLOBAL_CONFIG_2,
351*6da67cabSSebastian Hesselbarth 			   TWSI_ENABLE_OPTION2 | TWSI_ENABLE_OPTION3,
352*6da67cabSSebastian Hesselbarth 			   gcfg2);
35306763c74SThomas Petazzoni 
35406763c74SThomas Petazzoni 	return 0;
35506763c74SThomas Petazzoni }
35606763c74SThomas Petazzoni 
35706763c74SThomas Petazzoni static struct mvebu_mpp_ctrl dove_mpp_controls[] = {
358c2f082feSSebastian Hesselbarth 	MPP_FUNC_CTRL(0, 15, NULL, dove_pmu_mpp_ctrl),
3591217b790SSebastian Hesselbarth 	MPP_FUNC_CTRL(16, 23, NULL, dove_mpp_ctrl),
36006763c74SThomas Petazzoni 	MPP_FUNC_CTRL(24, 39, "mpp_camera", dove_mpp4_ctrl),
36106763c74SThomas Petazzoni 	MPP_FUNC_CTRL(40, 45, "mpp_sdio0", dove_mpp4_ctrl),
36206763c74SThomas Petazzoni 	MPP_FUNC_CTRL(46, 51, "mpp_sdio1", dove_mpp4_ctrl),
36306763c74SThomas Petazzoni 	MPP_FUNC_GPIO_CTRL(52, 57, "mpp_audio1", dove_audio1_ctrl),
36406763c74SThomas Petazzoni 	MPP_FUNC_CTRL(58, 61, "mpp_spi0", dove_mpp4_ctrl),
36506763c74SThomas Petazzoni 	MPP_FUNC_CTRL(62, 63, "mpp_uart1", dove_mpp4_ctrl),
36606763c74SThomas Petazzoni 	MPP_FUNC_CTRL(64, 71, "mpp_nand", dove_nand_ctrl),
36706763c74SThomas Petazzoni 	MPP_FUNC_CTRL(72, 72, "audio0", dove_audio0_ctrl),
36806763c74SThomas Petazzoni 	MPP_FUNC_CTRL(73, 73, "twsi", dove_twsi_ctrl),
36906763c74SThomas Petazzoni };
37006763c74SThomas Petazzoni 
37106763c74SThomas Petazzoni static struct mvebu_mpp_mode dove_mpp_modes[] = {
37206763c74SThomas Petazzoni 	MPP_MODE(0,
37306763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
37406763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart2", "rts"),
37506763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio0", "cd"),
37606763c74SThomas Petazzoni 		MPP_FUNCTION(0x0f, "lcd0", "pwm"),
377bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
378bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
379bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
380bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
381bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
382bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
383bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
384bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
385bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
386bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
387bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
388bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
38906763c74SThomas Petazzoni 	MPP_MODE(1,
39006763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
39106763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart2", "cts"),
39206763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio0", "wp"),
39306763c74SThomas Petazzoni 		MPP_FUNCTION(0x0f, "lcd1", "pwm"),
394bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
395bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
396bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
397bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
398bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
399bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
400bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
401bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
402bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
403bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
404bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
405bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
40606763c74SThomas Petazzoni 	MPP_MODE(2,
40706763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
40806763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "sata", "prsnt"),
40906763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart2", "txd"),
41006763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio0", "buspwr"),
41106763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "uart1", "rts"),
412bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
413bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
414bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
415bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
416bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
417bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
418bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
419bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
420bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
421bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
422bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
423bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
42406763c74SThomas Petazzoni 	MPP_MODE(3,
42506763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
42606763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "sata", "act"),
42706763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart2", "rxd"),
42806763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio0", "ledctrl"),
42906763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "uart1", "cts"),
43006763c74SThomas Petazzoni 		MPP_FUNCTION(0x0f, "lcd-spi", "cs1"),
431bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
432bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
433bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
434bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
435bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
436bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
437bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
438bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
439bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
440bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
441bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
442bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
44306763c74SThomas Petazzoni 	MPP_MODE(4,
44406763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
44506763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart3", "rts"),
44606763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio1", "cd"),
44706763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "spi1", "miso"),
448bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
449bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
450bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
451bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
452bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
453bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
454bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
455bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
456bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
457bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
458bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
459bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
46006763c74SThomas Petazzoni 	MPP_MODE(5,
46106763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
46206763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart3", "cts"),
46306763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio1", "wp"),
46406763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "spi1", "cs"),
465bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
466bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
467bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
468bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
469bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
470bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
471bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
472bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
473bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
474bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
475bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
476bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
47706763c74SThomas Petazzoni 	MPP_MODE(6,
47806763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
47906763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart3", "txd"),
48006763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio1", "buspwr"),
48106763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "spi1", "mosi"),
482bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
483bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
484bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
485bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
486bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
487bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
488bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
489bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
490bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
491bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
492bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
493bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
49406763c74SThomas Petazzoni 	MPP_MODE(7,
49506763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
49606763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart3", "rxd"),
49706763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio1", "ledctrl"),
49806763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "spi1", "sck"),
499bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
500bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
501bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
502bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
503bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
504bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
505bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
506bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
507bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
508bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
509bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
510bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
51106763c74SThomas Petazzoni 	MPP_MODE(8,
51206763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
51306763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "watchdog", "rstout"),
514bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
515bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
516bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
517bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
518bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
519bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
520bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
521bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
522bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
523bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
524bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
525bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
52606763c74SThomas Petazzoni 	MPP_MODE(9,
52706763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
52806763c74SThomas Petazzoni 		MPP_FUNCTION(0x05, "pex1", "clkreq"),
529bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
530bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
531bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
532bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
533bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
534bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
535bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
536bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
537bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
538bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
539bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
540bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
54106763c74SThomas Petazzoni 	MPP_MODE(10,
54206763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
54306763c74SThomas Petazzoni 		MPP_FUNCTION(0x05, "ssp", "sclk"),
544bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
545bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
546bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
547bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
548bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
549bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
550bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
551bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
552bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
553bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
554bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
555bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
55606763c74SThomas Petazzoni 	MPP_MODE(11,
55706763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
55806763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "sata", "prsnt"),
55906763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "sata-1", "act"),
56006763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio0", "ledctrl"),
56106763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "sdio1", "ledctrl"),
56206763c74SThomas Petazzoni 		MPP_FUNCTION(0x05, "pex0", "clkreq"),
563bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
564bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
565bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
566bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
567bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
568bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
569bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
570bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
571bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
572bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
573bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
574bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
57506763c74SThomas Petazzoni 	MPP_MODE(12,
57606763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
57706763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "sata", "act"),
57806763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart2", "rts"),
57906763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "audio0", "extclk"),
58006763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "sdio1", "cd"),
581bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
582bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
583bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
584bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
585bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
586bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
587bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
588bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
589bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
590bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
591bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
592bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
59306763c74SThomas Petazzoni 	MPP_MODE(13,
59406763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
59506763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart2", "cts"),
59606763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "audio1", "extclk"),
59706763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "sdio1", "wp"),
59806763c74SThomas Petazzoni 		MPP_FUNCTION(0x05, "ssp", "extclk"),
599bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
600bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
601bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
602bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
603bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
604bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
605bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
606bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
607bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
608bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
609bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
610bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
61106763c74SThomas Petazzoni 	MPP_MODE(14,
61206763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
61306763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart2", "txd"),
61406763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "sdio1", "buspwr"),
61506763c74SThomas Petazzoni 		MPP_FUNCTION(0x05, "ssp", "rxd"),
616bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
617bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
618bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
619bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
620bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
621bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
622bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
623bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
624bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
625bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
626bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
627bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
62806763c74SThomas Petazzoni 	MPP_MODE(15,
62906763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
63006763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart2", "rxd"),
63106763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "sdio1", "ledctrl"),
63206763c74SThomas Petazzoni 		MPP_FUNCTION(0x05, "ssp", "sfrm"),
633bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
634bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
635bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
636bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
637bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
638bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
639bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
640bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
641bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
642bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
643bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
644bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
64506763c74SThomas Petazzoni 	MPP_MODE(16,
64606763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
64706763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart3", "rts"),
64806763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio0", "cd"),
64906763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "lcd-spi", "cs1"),
65006763c74SThomas Petazzoni 		MPP_FUNCTION(0x05, "ac97", "sdi1")),
65106763c74SThomas Petazzoni 	MPP_MODE(17,
65206763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
65306763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "ac97-1", "sysclko"),
65406763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart3", "cts"),
65506763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio0", "wp"),
65606763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "twsi", "sda"),
65706763c74SThomas Petazzoni 		MPP_FUNCTION(0x05, "ac97", "sdi2")),
65806763c74SThomas Petazzoni 	MPP_MODE(18,
65906763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
66006763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart3", "txd"),
66106763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio0", "buspwr"),
66206763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "lcd0", "pwm"),
66306763c74SThomas Petazzoni 		MPP_FUNCTION(0x05, "ac97", "sdi3")),
66406763c74SThomas Petazzoni 	MPP_MODE(19,
66506763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
66606763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart3", "rxd"),
66706763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio0", "ledctrl"),
66806763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "twsi", "sck")),
66906763c74SThomas Petazzoni 	MPP_MODE(20,
67006763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
67106763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "ac97", "sysclko"),
67206763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "lcd-spi", "miso"),
67306763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio1", "cd"),
67406763c74SThomas Petazzoni 		MPP_FUNCTION(0x05, "sdio0", "cd"),
67506763c74SThomas Petazzoni 		MPP_FUNCTION(0x06, "spi1", "miso")),
67606763c74SThomas Petazzoni 	MPP_MODE(21,
67706763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
67806763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "uart1", "rts"),
67906763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "lcd-spi", "cs0"),
68006763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio1", "wp"),
68106763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "ssp", "sfrm"),
68206763c74SThomas Petazzoni 		MPP_FUNCTION(0x05, "sdio0", "wp"),
68306763c74SThomas Petazzoni 		MPP_FUNCTION(0x06, "spi1", "cs")),
68406763c74SThomas Petazzoni 	MPP_MODE(22,
68506763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
68606763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "uart1", "cts"),
68706763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "lcd-spi", "mosi"),
68806763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio1", "buspwr"),
68906763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "ssp", "txd"),
69006763c74SThomas Petazzoni 		MPP_FUNCTION(0x05, "sdio0", "buspwr"),
69106763c74SThomas Petazzoni 		MPP_FUNCTION(0x06, "spi1", "mosi")),
69206763c74SThomas Petazzoni 	MPP_MODE(23,
69306763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
69406763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "lcd-spi", "sck"),
69506763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio1", "ledctrl"),
69606763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "ssp", "sclk"),
69706763c74SThomas Petazzoni 		MPP_FUNCTION(0x05, "sdio0", "ledctrl"),
69806763c74SThomas Petazzoni 		MPP_FUNCTION(0x06, "spi1", "sck")),
69906763c74SThomas Petazzoni 	MPP_MODE(24,
70006763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "camera", NULL),
70106763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "gpio", NULL)),
70206763c74SThomas Petazzoni 	MPP_MODE(40,
70306763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "sdio0", NULL),
70406763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "gpio", NULL)),
70506763c74SThomas Petazzoni 	MPP_MODE(46,
70606763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "sdio1", NULL),
70706763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "gpio", NULL)),
70806763c74SThomas Petazzoni 	MPP_MODE(52,
70906763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "i2s1/spdifo", NULL),
71006763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "i2s1", NULL),
71106763c74SThomas Petazzoni 		MPP_FUNCTION(0x08, "spdifo", NULL),
71206763c74SThomas Petazzoni 		MPP_FUNCTION(0x0a, "gpio", NULL),
71306763c74SThomas Petazzoni 		MPP_FUNCTION(0x0b, "twsi", NULL),
71406763c74SThomas Petazzoni 		MPP_FUNCTION(0x0c, "ssp/spdifo", NULL),
71506763c74SThomas Petazzoni 		MPP_FUNCTION(0x0e, "ssp", NULL),
71606763c74SThomas Petazzoni 		MPP_FUNCTION(0x0f, "ssp/twsi", NULL)),
71706763c74SThomas Petazzoni 	MPP_MODE(58,
71806763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "spi0", NULL),
71906763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "gpio", NULL)),
72006763c74SThomas Petazzoni 	MPP_MODE(62,
72106763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "uart1", NULL),
72206763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "gpio", NULL)),
72306763c74SThomas Petazzoni 	MPP_MODE(64,
72406763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "nand", NULL),
72506763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "gpo", NULL)),
72606763c74SThomas Petazzoni 	MPP_MODE(72,
72706763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "i2s", NULL),
72806763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "ac97", NULL)),
72906763c74SThomas Petazzoni 	MPP_MODE(73,
73006763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "twsi-none", NULL),
73106763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "twsi-opt1", NULL),
73206763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "twsi-opt2", NULL),
73306763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "twsi-opt3", NULL)),
73406763c74SThomas Petazzoni };
73506763c74SThomas Petazzoni 
73606763c74SThomas Petazzoni static struct pinctrl_gpio_range dove_mpp_gpio_ranges[] = {
73706763c74SThomas Petazzoni 	MPP_GPIO_RANGE(0,  0,  0, 32),
73806763c74SThomas Petazzoni 	MPP_GPIO_RANGE(1, 32, 32, 32),
73906763c74SThomas Petazzoni 	MPP_GPIO_RANGE(2, 64, 64,  8),
74006763c74SThomas Petazzoni };
74106763c74SThomas Petazzoni 
74206763c74SThomas Petazzoni static struct mvebu_pinctrl_soc_info dove_pinctrl_info = {
74306763c74SThomas Petazzoni 	.controls = dove_mpp_controls,
74406763c74SThomas Petazzoni 	.ncontrols = ARRAY_SIZE(dove_mpp_controls),
74506763c74SThomas Petazzoni 	.modes = dove_mpp_modes,
74606763c74SThomas Petazzoni 	.nmodes = ARRAY_SIZE(dove_mpp_modes),
74706763c74SThomas Petazzoni 	.gpioranges = dove_mpp_gpio_ranges,
74806763c74SThomas Petazzoni 	.ngpioranges = ARRAY_SIZE(dove_mpp_gpio_ranges),
74906763c74SThomas Petazzoni 	.variant = 0,
75006763c74SThomas Petazzoni };
75106763c74SThomas Petazzoni 
75206763c74SThomas Petazzoni static struct clk *clk;
75306763c74SThomas Petazzoni 
754150632b0SGreg Kroah-Hartman static struct of_device_id dove_pinctrl_of_match[] = {
75506763c74SThomas Petazzoni 	{ .compatible = "marvell,dove-pinctrl", .data = &dove_pinctrl_info },
75606763c74SThomas Petazzoni 	{ }
75706763c74SThomas Petazzoni };
75806763c74SThomas Petazzoni 
759e91f7916SSebastian Hesselbarth static struct regmap_config gc_regmap_config = {
760e91f7916SSebastian Hesselbarth 	.reg_bits = 32,
761e91f7916SSebastian Hesselbarth 	.val_bits = 32,
762e91f7916SSebastian Hesselbarth 	.reg_stride = 4,
763e91f7916SSebastian Hesselbarth 	.max_register = 5,
764e91f7916SSebastian Hesselbarth };
765e91f7916SSebastian Hesselbarth 
766150632b0SGreg Kroah-Hartman static int dove_pinctrl_probe(struct platform_device *pdev)
76706763c74SThomas Petazzoni {
7684d73fc77SSebastian Hesselbarth 	struct resource *res, *mpp_res;
7694d73fc77SSebastian Hesselbarth 	struct resource fb_res;
77006763c74SThomas Petazzoni 	const struct of_device_id *match =
77106763c74SThomas Petazzoni 		of_match_device(dove_pinctrl_of_match, &pdev->dev);
77216fa36beSAndrew Lunn 	pdev->dev.platform_data = (void *)match->data;
77306763c74SThomas Petazzoni 
77406763c74SThomas Petazzoni 	/*
77506763c74SThomas Petazzoni 	 * General MPP Configuration Register is part of pdma registers.
77606763c74SThomas Petazzoni 	 * grab clk to make sure it is ticking.
77706763c74SThomas Petazzoni 	 */
77806763c74SThomas Petazzoni 	clk = devm_clk_get(&pdev->dev, NULL);
779ba607b62SSebastian Hesselbarth 	if (IS_ERR(clk)) {
780ba607b62SSebastian Hesselbarth 		dev_err(&pdev->dev, "Unable to get pdma clock");
7815795c6acSRusty Russell 		return PTR_ERR(clk);
782ba607b62SSebastian Hesselbarth 	}
78306763c74SThomas Petazzoni 	clk_prepare_enable(clk);
78406763c74SThomas Petazzoni 
7854d73fc77SSebastian Hesselbarth 	mpp_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
7864d73fc77SSebastian Hesselbarth 	mpp_base = devm_ioremap_resource(&pdev->dev, mpp_res);
7871217b790SSebastian Hesselbarth 	if (IS_ERR(mpp_base))
7881217b790SSebastian Hesselbarth 		return PTR_ERR(mpp_base);
7891217b790SSebastian Hesselbarth 
7904d73fc77SSebastian Hesselbarth 	/* prepare fallback resource */
7914d73fc77SSebastian Hesselbarth 	memcpy(&fb_res, mpp_res, sizeof(struct resource));
7924d73fc77SSebastian Hesselbarth 	fb_res.start = 0;
7934d73fc77SSebastian Hesselbarth 
7944d73fc77SSebastian Hesselbarth 	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
7954d73fc77SSebastian Hesselbarth 	if (!res) {
7964d73fc77SSebastian Hesselbarth 		dev_warn(&pdev->dev, "falling back to hardcoded MPP4 resource\n");
7974d73fc77SSebastian Hesselbarth 		adjust_resource(&fb_res,
7984d73fc77SSebastian Hesselbarth 			(mpp_res->start & INT_REGS_MASK) + MPP4_REGS_OFFS, 0x4);
7994d73fc77SSebastian Hesselbarth 		res = &fb_res;
8004d73fc77SSebastian Hesselbarth 	}
8014d73fc77SSebastian Hesselbarth 
8024d73fc77SSebastian Hesselbarth 	mpp4_base = devm_ioremap_resource(&pdev->dev, res);
8034d73fc77SSebastian Hesselbarth 	if (IS_ERR(mpp4_base))
8044d73fc77SSebastian Hesselbarth 		return PTR_ERR(mpp4_base);
8054d73fc77SSebastian Hesselbarth 
8064d73fc77SSebastian Hesselbarth 	res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
8074d73fc77SSebastian Hesselbarth 	if (!res) {
8084d73fc77SSebastian Hesselbarth 		dev_warn(&pdev->dev, "falling back to hardcoded PMU resource\n");
8094d73fc77SSebastian Hesselbarth 		adjust_resource(&fb_res,
8104d73fc77SSebastian Hesselbarth 			(mpp_res->start & INT_REGS_MASK) + PMU_REGS_OFFS, 0x8);
8114d73fc77SSebastian Hesselbarth 		res = &fb_res;
8124d73fc77SSebastian Hesselbarth 	}
8134d73fc77SSebastian Hesselbarth 
8144d73fc77SSebastian Hesselbarth 	pmu_base = devm_ioremap_resource(&pdev->dev, res);
8154d73fc77SSebastian Hesselbarth 	if (IS_ERR(pmu_base))
8164d73fc77SSebastian Hesselbarth 		return PTR_ERR(pmu_base);
8174d73fc77SSebastian Hesselbarth 
818e91f7916SSebastian Hesselbarth 	gconfmap = syscon_regmap_lookup_by_compatible("marvell,dove-global-config");
819e91f7916SSebastian Hesselbarth 	if (IS_ERR(gconfmap)) {
820e91f7916SSebastian Hesselbarth 		void __iomem *gc_base;
821e91f7916SSebastian Hesselbarth 
822e91f7916SSebastian Hesselbarth 		dev_warn(&pdev->dev, "falling back to hardcoded global registers\n");
823e91f7916SSebastian Hesselbarth 		adjust_resource(&fb_res,
824e91f7916SSebastian Hesselbarth 			(mpp_res->start & INT_REGS_MASK) + GC_REGS_OFFS, 0x14);
825e91f7916SSebastian Hesselbarth 		gc_base = devm_ioremap_resource(&pdev->dev, &fb_res);
826e91f7916SSebastian Hesselbarth 		if (IS_ERR(gc_base))
827e91f7916SSebastian Hesselbarth 			return PTR_ERR(gc_base);
828e91f7916SSebastian Hesselbarth 		gconfmap = devm_regmap_init_mmio(&pdev->dev,
829e91f7916SSebastian Hesselbarth 						 gc_base, &gc_regmap_config);
830e91f7916SSebastian Hesselbarth 		if (IS_ERR(gconfmap))
831e91f7916SSebastian Hesselbarth 			return PTR_ERR(gconfmap);
832e91f7916SSebastian Hesselbarth 	}
833e91f7916SSebastian Hesselbarth 
8344d73fc77SSebastian Hesselbarth 	/* Warn on any missing DT resource */
8354d73fc77SSebastian Hesselbarth 	WARN(fb_res.start, FW_BUG "Missing pinctrl regs in DTB. Please update your firmware.\n");
8364d73fc77SSebastian Hesselbarth 
83706763c74SThomas Petazzoni 	return mvebu_pinctrl_probe(pdev);
83806763c74SThomas Petazzoni }
83906763c74SThomas Petazzoni 
840150632b0SGreg Kroah-Hartman static int dove_pinctrl_remove(struct platform_device *pdev)
84106763c74SThomas Petazzoni {
84206763c74SThomas Petazzoni 	int ret;
84306763c74SThomas Petazzoni 
84406763c74SThomas Petazzoni 	ret = mvebu_pinctrl_remove(pdev);
84506763c74SThomas Petazzoni 	if (!IS_ERR(clk))
84606763c74SThomas Petazzoni 		clk_disable_unprepare(clk);
84706763c74SThomas Petazzoni 	return ret;
84806763c74SThomas Petazzoni }
84906763c74SThomas Petazzoni 
85006763c74SThomas Petazzoni static struct platform_driver dove_pinctrl_driver = {
85106763c74SThomas Petazzoni 	.driver = {
85206763c74SThomas Petazzoni 		.name = "dove-pinctrl",
85306763c74SThomas Petazzoni 		.owner = THIS_MODULE,
854f2e9394dSSachin Kamat 		.of_match_table = dove_pinctrl_of_match,
85506763c74SThomas Petazzoni 	},
85606763c74SThomas Petazzoni 	.probe = dove_pinctrl_probe,
857150632b0SGreg Kroah-Hartman 	.remove = dove_pinctrl_remove,
85806763c74SThomas Petazzoni };
85906763c74SThomas Petazzoni 
86006763c74SThomas Petazzoni module_platform_driver(dove_pinctrl_driver);
86106763c74SThomas Petazzoni 
86206763c74SThomas Petazzoni MODULE_AUTHOR("Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>");
86306763c74SThomas Petazzoni MODULE_DESCRIPTION("Marvell Dove pinctrl driver");
86406763c74SThomas Petazzoni MODULE_LICENSE("GPL v2");
865