xref: /linux/drivers/pinctrl/mvebu/pinctrl-dove.c (revision f2e9394d1a3bc7a4f646345d93468c8aa1f7d2ee)
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>
2106763c74SThomas Petazzoni #include <linux/pinctrl/pinctrl.h>
2206763c74SThomas Petazzoni 
2306763c74SThomas Petazzoni #include "pinctrl-mvebu.h"
2406763c74SThomas Petazzoni 
2578f9f3b1SSebastian Hesselbarth #define DOVE_SB_REGS_VIRT_BASE		IOMEM(0xfde00000)
2678f9f3b1SSebastian Hesselbarth #define DOVE_MPP_VIRT_BASE		(DOVE_SB_REGS_VIRT_BASE + 0xd0200)
2706763c74SThomas Petazzoni #define DOVE_PMU_MPP_GENERAL_CTRL	(DOVE_MPP_VIRT_BASE + 0x10)
2806763c74SThomas Petazzoni #define  DOVE_AU0_AC97_SEL		BIT(16)
29bbd7b275SSebastian Hesselbarth #define DOVE_PMU_SIGNAL_SELECT_0	(DOVE_SB_REGS_VIRT_BASE + 0xd802C)
30bbd7b275SSebastian Hesselbarth #define DOVE_PMU_SIGNAL_SELECT_1	(DOVE_SB_REGS_VIRT_BASE + 0xd8030)
31bbd7b275SSebastian Hesselbarth #define DOVE_GLOBAL_CONFIG_1		(DOVE_SB_REGS_VIRT_BASE + 0xe802C)
3278f9f3b1SSebastian Hesselbarth #define DOVE_GLOBAL_CONFIG_1		(DOVE_SB_REGS_VIRT_BASE + 0xe802C)
3306763c74SThomas Petazzoni #define  DOVE_TWSI_ENABLE_OPTION1	BIT(7)
3478f9f3b1SSebastian Hesselbarth #define DOVE_GLOBAL_CONFIG_2		(DOVE_SB_REGS_VIRT_BASE + 0xe8030)
3506763c74SThomas Petazzoni #define  DOVE_TWSI_ENABLE_OPTION2	BIT(20)
3606763c74SThomas Petazzoni #define  DOVE_TWSI_ENABLE_OPTION3	BIT(21)
3706763c74SThomas Petazzoni #define  DOVE_TWSI_OPTION3_GPIO		BIT(22)
3878f9f3b1SSebastian Hesselbarth #define DOVE_SSP_CTRL_STATUS_1		(DOVE_SB_REGS_VIRT_BASE + 0xe8034)
3906763c74SThomas Petazzoni #define  DOVE_SSP_ON_AU1		BIT(0)
4078f9f3b1SSebastian Hesselbarth #define DOVE_MPP_GENERAL_VIRT_BASE	(DOVE_SB_REGS_VIRT_BASE + 0xe803c)
4106763c74SThomas Petazzoni #define  DOVE_AU1_SPDIFO_GPIO_EN	BIT(1)
4206763c74SThomas Petazzoni #define  DOVE_NAND_GPIO_EN		BIT(0)
4378f9f3b1SSebastian Hesselbarth #define DOVE_GPIO_LO_VIRT_BASE		(DOVE_SB_REGS_VIRT_BASE + 0xd0400)
4406763c74SThomas Petazzoni #define DOVE_MPP_CTRL4_VIRT_BASE	(DOVE_GPIO_LO_VIRT_BASE + 0x40)
4506763c74SThomas Petazzoni #define  DOVE_SPI_GPIO_SEL		BIT(5)
4606763c74SThomas Petazzoni #define  DOVE_UART1_GPIO_SEL		BIT(4)
4706763c74SThomas Petazzoni #define  DOVE_AU1_GPIO_SEL		BIT(3)
4806763c74SThomas Petazzoni #define  DOVE_CAM_GPIO_SEL		BIT(2)
4906763c74SThomas Petazzoni #define  DOVE_SD1_GPIO_SEL		BIT(1)
5006763c74SThomas Petazzoni #define  DOVE_SD0_GPIO_SEL		BIT(0)
5106763c74SThomas Petazzoni 
5206763c74SThomas Petazzoni #define MPPS_PER_REG	8
5306763c74SThomas Petazzoni #define MPP_BITS	4
5406763c74SThomas Petazzoni #define MPP_MASK	0xf
5506763c74SThomas Petazzoni 
5606763c74SThomas Petazzoni #define CONFIG_PMU	BIT(4)
5706763c74SThomas Petazzoni 
5806763c74SThomas Petazzoni static int dove_pmu_mpp_ctrl_get(struct mvebu_mpp_ctrl *ctrl,
5906763c74SThomas Petazzoni 				 unsigned long *config)
6006763c74SThomas Petazzoni {
6106763c74SThomas Petazzoni 	unsigned off = (ctrl->pid / MPPS_PER_REG) * MPP_BITS;
6206763c74SThomas Petazzoni 	unsigned shift = (ctrl->pid % MPPS_PER_REG) * MPP_BITS;
6306763c74SThomas Petazzoni 	unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL);
64bbd7b275SSebastian Hesselbarth 	unsigned long func;
6506763c74SThomas Petazzoni 
66bbd7b275SSebastian Hesselbarth 	if (pmu & (1 << ctrl->pid)) {
67bbd7b275SSebastian Hesselbarth 		func = readl(DOVE_PMU_SIGNAL_SELECT_0 + off);
68bbd7b275SSebastian Hesselbarth 		*config = (func >> shift) & MPP_MASK;
69bbd7b275SSebastian Hesselbarth 		*config |= CONFIG_PMU;
70bbd7b275SSebastian Hesselbarth 	} else {
71bbd7b275SSebastian Hesselbarth 		func = readl(DOVE_MPP_VIRT_BASE + off);
72bbd7b275SSebastian Hesselbarth 		*config = (func >> shift) & MPP_MASK;
73bbd7b275SSebastian Hesselbarth 	}
7406763c74SThomas Petazzoni 	return 0;
7506763c74SThomas Petazzoni }
7606763c74SThomas Petazzoni 
7706763c74SThomas Petazzoni static int dove_pmu_mpp_ctrl_set(struct mvebu_mpp_ctrl *ctrl,
7806763c74SThomas Petazzoni 				 unsigned long config)
7906763c74SThomas Petazzoni {
8006763c74SThomas Petazzoni 	unsigned off = (ctrl->pid / MPPS_PER_REG) * MPP_BITS;
8106763c74SThomas Petazzoni 	unsigned shift = (ctrl->pid % MPPS_PER_REG) * MPP_BITS;
8206763c74SThomas Petazzoni 	unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL);
83bbd7b275SSebastian Hesselbarth 	unsigned long func;
8406763c74SThomas Petazzoni 
85bbd7b275SSebastian Hesselbarth 	if (config & CONFIG_PMU) {
8606763c74SThomas Petazzoni 		writel(pmu | (1 << ctrl->pid), DOVE_PMU_MPP_GENERAL_CTRL);
87bbd7b275SSebastian Hesselbarth 		func = readl(DOVE_PMU_SIGNAL_SELECT_0 + off);
88bbd7b275SSebastian Hesselbarth 		func &= ~(MPP_MASK << shift);
89bbd7b275SSebastian Hesselbarth 		func |= (config & MPP_MASK) << shift;
90bbd7b275SSebastian Hesselbarth 		writel(func, DOVE_PMU_SIGNAL_SELECT_0 + off);
91bbd7b275SSebastian Hesselbarth 	} else {
9206763c74SThomas Petazzoni 		writel(pmu & ~(1 << ctrl->pid), DOVE_PMU_MPP_GENERAL_CTRL);
93bbd7b275SSebastian Hesselbarth 		func = readl(DOVE_MPP_VIRT_BASE + off);
94bbd7b275SSebastian Hesselbarth 		func &= ~(MPP_MASK << shift);
95bbd7b275SSebastian Hesselbarth 		func |= (config & MPP_MASK) << shift;
96bbd7b275SSebastian Hesselbarth 		writel(func, DOVE_MPP_VIRT_BASE + off);
9706763c74SThomas Petazzoni 	}
9806763c74SThomas Petazzoni 	return 0;
9906763c74SThomas Petazzoni }
10006763c74SThomas Petazzoni 
10106763c74SThomas Petazzoni static int dove_mpp4_ctrl_get(struct mvebu_mpp_ctrl *ctrl,
10206763c74SThomas Petazzoni 			      unsigned long *config)
10306763c74SThomas Petazzoni {
10406763c74SThomas Petazzoni 	unsigned long mpp4 = readl(DOVE_MPP_CTRL4_VIRT_BASE);
10506763c74SThomas Petazzoni 	unsigned long mask;
10606763c74SThomas Petazzoni 
10706763c74SThomas Petazzoni 	switch (ctrl->pid) {
10806763c74SThomas Petazzoni 	case 24: /* mpp_camera */
10906763c74SThomas Petazzoni 		mask = DOVE_CAM_GPIO_SEL;
11006763c74SThomas Petazzoni 		break;
11106763c74SThomas Petazzoni 	case 40: /* mpp_sdio0 */
11206763c74SThomas Petazzoni 		mask = DOVE_SD0_GPIO_SEL;
11306763c74SThomas Petazzoni 		break;
11406763c74SThomas Petazzoni 	case 46: /* mpp_sdio1 */
11506763c74SThomas Petazzoni 		mask = DOVE_SD1_GPIO_SEL;
11606763c74SThomas Petazzoni 		break;
11706763c74SThomas Petazzoni 	case 58: /* mpp_spi0 */
11806763c74SThomas Petazzoni 		mask = DOVE_SPI_GPIO_SEL;
11906763c74SThomas Petazzoni 		break;
12006763c74SThomas Petazzoni 	case 62: /* mpp_uart1 */
12106763c74SThomas Petazzoni 		mask = DOVE_UART1_GPIO_SEL;
12206763c74SThomas Petazzoni 		break;
12306763c74SThomas Petazzoni 	default:
12406763c74SThomas Petazzoni 		return -EINVAL;
12506763c74SThomas Petazzoni 	}
12606763c74SThomas Petazzoni 
12706763c74SThomas Petazzoni 	*config = ((mpp4 & mask) != 0);
12806763c74SThomas Petazzoni 
12906763c74SThomas Petazzoni 	return 0;
13006763c74SThomas Petazzoni }
13106763c74SThomas Petazzoni 
13206763c74SThomas Petazzoni static int dove_mpp4_ctrl_set(struct mvebu_mpp_ctrl *ctrl,
13306763c74SThomas Petazzoni 			      unsigned long config)
13406763c74SThomas Petazzoni {
13506763c74SThomas Petazzoni 	unsigned long mpp4 = readl(DOVE_MPP_CTRL4_VIRT_BASE);
13606763c74SThomas Petazzoni 	unsigned long mask;
13706763c74SThomas Petazzoni 
13806763c74SThomas Petazzoni 	switch (ctrl->pid) {
13906763c74SThomas Petazzoni 	case 24: /* mpp_camera */
14006763c74SThomas Petazzoni 		mask = DOVE_CAM_GPIO_SEL;
14106763c74SThomas Petazzoni 		break;
14206763c74SThomas Petazzoni 	case 40: /* mpp_sdio0 */
14306763c74SThomas Petazzoni 		mask = DOVE_SD0_GPIO_SEL;
14406763c74SThomas Petazzoni 		break;
14506763c74SThomas Petazzoni 	case 46: /* mpp_sdio1 */
14606763c74SThomas Petazzoni 		mask = DOVE_SD1_GPIO_SEL;
14706763c74SThomas Petazzoni 		break;
14806763c74SThomas Petazzoni 	case 58: /* mpp_spi0 */
14906763c74SThomas Petazzoni 		mask = DOVE_SPI_GPIO_SEL;
15006763c74SThomas Petazzoni 		break;
15106763c74SThomas Petazzoni 	case 62: /* mpp_uart1 */
15206763c74SThomas Petazzoni 		mask = DOVE_UART1_GPIO_SEL;
15306763c74SThomas Petazzoni 		break;
15406763c74SThomas Petazzoni 	default:
15506763c74SThomas Petazzoni 		return -EINVAL;
15606763c74SThomas Petazzoni 	}
15706763c74SThomas Petazzoni 
15806763c74SThomas Petazzoni 	mpp4 &= ~mask;
15906763c74SThomas Petazzoni 	if (config)
16006763c74SThomas Petazzoni 		mpp4 |= mask;
16106763c74SThomas Petazzoni 
16206763c74SThomas Petazzoni 	writel(mpp4, DOVE_MPP_CTRL4_VIRT_BASE);
16306763c74SThomas Petazzoni 
16406763c74SThomas Petazzoni 	return 0;
16506763c74SThomas Petazzoni }
16606763c74SThomas Petazzoni 
16706763c74SThomas Petazzoni static int dove_nand_ctrl_get(struct mvebu_mpp_ctrl *ctrl,
16806763c74SThomas Petazzoni 			      unsigned long *config)
16906763c74SThomas Petazzoni {
17006763c74SThomas Petazzoni 	unsigned long gmpp = readl(DOVE_MPP_GENERAL_VIRT_BASE);
17106763c74SThomas Petazzoni 
17206763c74SThomas Petazzoni 	*config = ((gmpp & DOVE_NAND_GPIO_EN) != 0);
17306763c74SThomas Petazzoni 
17406763c74SThomas Petazzoni 	return 0;
17506763c74SThomas Petazzoni }
17606763c74SThomas Petazzoni 
17706763c74SThomas Petazzoni static int dove_nand_ctrl_set(struct mvebu_mpp_ctrl *ctrl,
17806763c74SThomas Petazzoni 			      unsigned long config)
17906763c74SThomas Petazzoni {
18006763c74SThomas Petazzoni 	unsigned long gmpp = readl(DOVE_MPP_GENERAL_VIRT_BASE);
18106763c74SThomas Petazzoni 
18206763c74SThomas Petazzoni 	gmpp &= ~DOVE_NAND_GPIO_EN;
18306763c74SThomas Petazzoni 	if (config)
18406763c74SThomas Petazzoni 		gmpp |= DOVE_NAND_GPIO_EN;
18506763c74SThomas Petazzoni 
18606763c74SThomas Petazzoni 	writel(gmpp, DOVE_MPP_GENERAL_VIRT_BASE);
18706763c74SThomas Petazzoni 
18806763c74SThomas Petazzoni 	return 0;
18906763c74SThomas Petazzoni }
19006763c74SThomas Petazzoni 
19106763c74SThomas Petazzoni static int dove_audio0_ctrl_get(struct mvebu_mpp_ctrl *ctrl,
19206763c74SThomas Petazzoni 				unsigned long *config)
19306763c74SThomas Petazzoni {
19406763c74SThomas Petazzoni 	unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL);
19506763c74SThomas Petazzoni 
19606763c74SThomas Petazzoni 	*config = ((pmu & DOVE_AU0_AC97_SEL) != 0);
19706763c74SThomas Petazzoni 
19806763c74SThomas Petazzoni 	return 0;
19906763c74SThomas Petazzoni }
20006763c74SThomas Petazzoni 
20106763c74SThomas Petazzoni static int dove_audio0_ctrl_set(struct mvebu_mpp_ctrl *ctrl,
20206763c74SThomas Petazzoni 				unsigned long config)
20306763c74SThomas Petazzoni {
20406763c74SThomas Petazzoni 	unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL);
20506763c74SThomas Petazzoni 
20606763c74SThomas Petazzoni 	pmu &= ~DOVE_AU0_AC97_SEL;
20706763c74SThomas Petazzoni 	if (config)
20806763c74SThomas Petazzoni 		pmu |= DOVE_AU0_AC97_SEL;
20906763c74SThomas Petazzoni 	writel(pmu, DOVE_PMU_MPP_GENERAL_CTRL);
21006763c74SThomas Petazzoni 
21106763c74SThomas Petazzoni 	return 0;
21206763c74SThomas Petazzoni }
21306763c74SThomas Petazzoni 
21406763c74SThomas Petazzoni static int dove_audio1_ctrl_get(struct mvebu_mpp_ctrl *ctrl,
21506763c74SThomas Petazzoni 				unsigned long *config)
21606763c74SThomas Petazzoni {
21706763c74SThomas Petazzoni 	unsigned long mpp4 = readl(DOVE_MPP_CTRL4_VIRT_BASE);
21806763c74SThomas Petazzoni 	unsigned long sspc1 = readl(DOVE_SSP_CTRL_STATUS_1);
21906763c74SThomas Petazzoni 	unsigned long gmpp = readl(DOVE_MPP_GENERAL_VIRT_BASE);
22006763c74SThomas Petazzoni 	unsigned long gcfg2 = readl(DOVE_GLOBAL_CONFIG_2);
22106763c74SThomas Petazzoni 
22206763c74SThomas Petazzoni 	*config = 0;
22306763c74SThomas Petazzoni 	if (mpp4 & DOVE_AU1_GPIO_SEL)
22406763c74SThomas Petazzoni 		*config |= BIT(3);
22506763c74SThomas Petazzoni 	if (sspc1 & DOVE_SSP_ON_AU1)
22606763c74SThomas Petazzoni 		*config |= BIT(2);
22706763c74SThomas Petazzoni 	if (gmpp & DOVE_AU1_SPDIFO_GPIO_EN)
22806763c74SThomas Petazzoni 		*config |= BIT(1);
22906763c74SThomas Petazzoni 	if (gcfg2 & DOVE_TWSI_OPTION3_GPIO)
23006763c74SThomas Petazzoni 		*config |= BIT(0);
23106763c74SThomas Petazzoni 
23206763c74SThomas Petazzoni 	/* SSP/TWSI only if I2S1 not set*/
23306763c74SThomas Petazzoni 	if ((*config & BIT(3)) == 0)
23406763c74SThomas Petazzoni 		*config &= ~(BIT(2) | BIT(0));
23506763c74SThomas Petazzoni 	/* TWSI only if SPDIFO not set*/
23606763c74SThomas Petazzoni 	if ((*config & BIT(1)) == 0)
23706763c74SThomas Petazzoni 		*config &= ~BIT(0);
23806763c74SThomas Petazzoni 	return 0;
23906763c74SThomas Petazzoni }
24006763c74SThomas Petazzoni 
24106763c74SThomas Petazzoni static int dove_audio1_ctrl_set(struct mvebu_mpp_ctrl *ctrl,
24206763c74SThomas Petazzoni 				unsigned long config)
24306763c74SThomas Petazzoni {
24406763c74SThomas Petazzoni 	unsigned long mpp4 = readl(DOVE_MPP_CTRL4_VIRT_BASE);
24506763c74SThomas Petazzoni 	unsigned long sspc1 = readl(DOVE_SSP_CTRL_STATUS_1);
24606763c74SThomas Petazzoni 	unsigned long gmpp = readl(DOVE_MPP_GENERAL_VIRT_BASE);
24706763c74SThomas Petazzoni 	unsigned long gcfg2 = readl(DOVE_GLOBAL_CONFIG_2);
24806763c74SThomas Petazzoni 
24963ace077SAxel Lin 	/*
25063ace077SAxel Lin 	 * clear all audio1 related bits before configure
25163ace077SAxel Lin 	 */
25263ace077SAxel Lin 	gcfg2 &= ~DOVE_TWSI_OPTION3_GPIO;
25363ace077SAxel Lin 	gmpp &= ~DOVE_AU1_SPDIFO_GPIO_EN;
25463ace077SAxel Lin 	sspc1 &= ~DOVE_SSP_ON_AU1;
25563ace077SAxel Lin 	mpp4 &= ~DOVE_AU1_GPIO_SEL;
25663ace077SAxel Lin 
25706763c74SThomas Petazzoni 	if (config & BIT(0))
25806763c74SThomas Petazzoni 		gcfg2 |= DOVE_TWSI_OPTION3_GPIO;
25906763c74SThomas Petazzoni 	if (config & BIT(1))
26006763c74SThomas Petazzoni 		gmpp |= DOVE_AU1_SPDIFO_GPIO_EN;
26106763c74SThomas Petazzoni 	if (config & BIT(2))
26206763c74SThomas Petazzoni 		sspc1 |= DOVE_SSP_ON_AU1;
26306763c74SThomas Petazzoni 	if (config & BIT(3))
26406763c74SThomas Petazzoni 		mpp4 |= DOVE_AU1_GPIO_SEL;
26506763c74SThomas Petazzoni 
26606763c74SThomas Petazzoni 	writel(mpp4, DOVE_MPP_CTRL4_VIRT_BASE);
26706763c74SThomas Petazzoni 	writel(sspc1, DOVE_SSP_CTRL_STATUS_1);
26806763c74SThomas Petazzoni 	writel(gmpp, DOVE_MPP_GENERAL_VIRT_BASE);
26906763c74SThomas Petazzoni 	writel(gcfg2, DOVE_GLOBAL_CONFIG_2);
27006763c74SThomas Petazzoni 
27106763c74SThomas Petazzoni 	return 0;
27206763c74SThomas Petazzoni }
27306763c74SThomas Petazzoni 
27406763c74SThomas Petazzoni /* mpp[52:57] gpio pins depend heavily on current config;
27506763c74SThomas Petazzoni  * gpio_req does not try to mux in gpio capabilities to not
27606763c74SThomas Petazzoni  * break other functions. If you require all mpps as gpio
27706763c74SThomas Petazzoni  * enforce gpio setting by pinctrl mapping.
27806763c74SThomas Petazzoni  */
27906763c74SThomas Petazzoni static int dove_audio1_ctrl_gpio_req(struct mvebu_mpp_ctrl *ctrl, u8 pid)
28006763c74SThomas Petazzoni {
28106763c74SThomas Petazzoni 	unsigned long config;
28206763c74SThomas Petazzoni 
28306763c74SThomas Petazzoni 	dove_audio1_ctrl_get(ctrl, &config);
28406763c74SThomas Petazzoni 
28506763c74SThomas Petazzoni 	switch (config) {
28606763c74SThomas Petazzoni 	case 0x02: /* i2s1 : gpio[56:57] */
28706763c74SThomas Petazzoni 	case 0x0e: /* ssp  : gpio[56:57] */
28806763c74SThomas Petazzoni 		if (pid >= 56)
28906763c74SThomas Petazzoni 			return 0;
29006763c74SThomas Petazzoni 		return -ENOTSUPP;
29106763c74SThomas Petazzoni 	case 0x08: /* spdifo : gpio[52:55] */
29206763c74SThomas Petazzoni 	case 0x0b: /* twsi   : gpio[52:55] */
29306763c74SThomas Petazzoni 		if (pid <= 55)
29406763c74SThomas Petazzoni 			return 0;
29506763c74SThomas Petazzoni 		return -ENOTSUPP;
29606763c74SThomas Petazzoni 	case 0x0a: /* all gpio */
29706763c74SThomas Petazzoni 		return 0;
29806763c74SThomas Petazzoni 	/* 0x00 : i2s1/spdifo : no gpio */
29906763c74SThomas Petazzoni 	/* 0x0c : ssp/spdifo  : no gpio */
30006763c74SThomas Petazzoni 	/* 0x0f : ssp/twsi    : no gpio */
30106763c74SThomas Petazzoni 	}
30206763c74SThomas Petazzoni 	return -ENOTSUPP;
30306763c74SThomas Petazzoni }
30406763c74SThomas Petazzoni 
30506763c74SThomas Petazzoni /* mpp[52:57] has gpio pins capable of in and out */
30606763c74SThomas Petazzoni static int dove_audio1_ctrl_gpio_dir(struct mvebu_mpp_ctrl *ctrl, u8 pid,
30706763c74SThomas Petazzoni 				bool input)
30806763c74SThomas Petazzoni {
30906763c74SThomas Petazzoni 	if (pid < 52 || pid > 57)
31006763c74SThomas Petazzoni 		return -ENOTSUPP;
31106763c74SThomas Petazzoni 	return 0;
31206763c74SThomas Petazzoni }
31306763c74SThomas Petazzoni 
31406763c74SThomas Petazzoni static int dove_twsi_ctrl_get(struct mvebu_mpp_ctrl *ctrl,
31506763c74SThomas Petazzoni 			      unsigned long *config)
31606763c74SThomas Petazzoni {
31706763c74SThomas Petazzoni 	unsigned long gcfg1 = readl(DOVE_GLOBAL_CONFIG_1);
31806763c74SThomas Petazzoni 	unsigned long gcfg2 = readl(DOVE_GLOBAL_CONFIG_2);
31906763c74SThomas Petazzoni 
32006763c74SThomas Petazzoni 	*config = 0;
32106763c74SThomas Petazzoni 	if (gcfg1 & DOVE_TWSI_ENABLE_OPTION1)
32206763c74SThomas Petazzoni 		*config = 1;
32306763c74SThomas Petazzoni 	else if (gcfg2 & DOVE_TWSI_ENABLE_OPTION2)
32406763c74SThomas Petazzoni 		*config = 2;
32506763c74SThomas Petazzoni 	else if (gcfg2 & DOVE_TWSI_ENABLE_OPTION3)
32606763c74SThomas Petazzoni 		*config = 3;
32706763c74SThomas Petazzoni 
32806763c74SThomas Petazzoni 	return 0;
32906763c74SThomas Petazzoni }
33006763c74SThomas Petazzoni 
33106763c74SThomas Petazzoni static int dove_twsi_ctrl_set(struct mvebu_mpp_ctrl *ctrl,
33206763c74SThomas Petazzoni 				unsigned long config)
33306763c74SThomas Petazzoni {
33406763c74SThomas Petazzoni 	unsigned long gcfg1 = readl(DOVE_GLOBAL_CONFIG_1);
33506763c74SThomas Petazzoni 	unsigned long gcfg2 = readl(DOVE_GLOBAL_CONFIG_2);
33606763c74SThomas Petazzoni 
33706763c74SThomas Petazzoni 	gcfg1 &= ~DOVE_TWSI_ENABLE_OPTION1;
3386d0a4ed2SRoel Kluin 	gcfg2 &= ~(DOVE_TWSI_ENABLE_OPTION2 | DOVE_TWSI_ENABLE_OPTION3);
33906763c74SThomas Petazzoni 
34006763c74SThomas Petazzoni 	switch (config) {
34106763c74SThomas Petazzoni 	case 1:
34206763c74SThomas Petazzoni 		gcfg1 |= DOVE_TWSI_ENABLE_OPTION1;
34306763c74SThomas Petazzoni 		break;
34406763c74SThomas Petazzoni 	case 2:
34506763c74SThomas Petazzoni 		gcfg2 |= DOVE_TWSI_ENABLE_OPTION2;
34606763c74SThomas Petazzoni 		break;
34706763c74SThomas Petazzoni 	case 3:
34806763c74SThomas Petazzoni 		gcfg2 |= DOVE_TWSI_ENABLE_OPTION3;
34906763c74SThomas Petazzoni 		break;
35006763c74SThomas Petazzoni 	}
35106763c74SThomas Petazzoni 
35206763c74SThomas Petazzoni 	writel(gcfg1, DOVE_GLOBAL_CONFIG_1);
35306763c74SThomas Petazzoni 	writel(gcfg2, DOVE_GLOBAL_CONFIG_2);
35406763c74SThomas Petazzoni 
35506763c74SThomas Petazzoni 	return 0;
35606763c74SThomas Petazzoni }
35706763c74SThomas Petazzoni 
35806763c74SThomas Petazzoni static struct mvebu_mpp_ctrl dove_mpp_controls[] = {
35906763c74SThomas Petazzoni 	MPP_FUNC_CTRL(0, 0, "mpp0", dove_pmu_mpp_ctrl),
36006763c74SThomas Petazzoni 	MPP_FUNC_CTRL(1, 1, "mpp1", dove_pmu_mpp_ctrl),
36106763c74SThomas Petazzoni 	MPP_FUNC_CTRL(2, 2, "mpp2", dove_pmu_mpp_ctrl),
36206763c74SThomas Petazzoni 	MPP_FUNC_CTRL(3, 3, "mpp3", dove_pmu_mpp_ctrl),
36306763c74SThomas Petazzoni 	MPP_FUNC_CTRL(4, 4, "mpp4", dove_pmu_mpp_ctrl),
36406763c74SThomas Petazzoni 	MPP_FUNC_CTRL(5, 5, "mpp5", dove_pmu_mpp_ctrl),
36506763c74SThomas Petazzoni 	MPP_FUNC_CTRL(6, 6, "mpp6", dove_pmu_mpp_ctrl),
36606763c74SThomas Petazzoni 	MPP_FUNC_CTRL(7, 7, "mpp7", dove_pmu_mpp_ctrl),
36706763c74SThomas Petazzoni 	MPP_FUNC_CTRL(8, 8, "mpp8", dove_pmu_mpp_ctrl),
36806763c74SThomas Petazzoni 	MPP_FUNC_CTRL(9, 9, "mpp9", dove_pmu_mpp_ctrl),
36906763c74SThomas Petazzoni 	MPP_FUNC_CTRL(10, 10, "mpp10", dove_pmu_mpp_ctrl),
37006763c74SThomas Petazzoni 	MPP_FUNC_CTRL(11, 11, "mpp11", dove_pmu_mpp_ctrl),
37106763c74SThomas Petazzoni 	MPP_FUNC_CTRL(12, 12, "mpp12", dove_pmu_mpp_ctrl),
37206763c74SThomas Petazzoni 	MPP_FUNC_CTRL(13, 13, "mpp13", dove_pmu_mpp_ctrl),
37306763c74SThomas Petazzoni 	MPP_FUNC_CTRL(14, 14, "mpp14", dove_pmu_mpp_ctrl),
37406763c74SThomas Petazzoni 	MPP_FUNC_CTRL(15, 15, "mpp15", dove_pmu_mpp_ctrl),
37506763c74SThomas Petazzoni 	MPP_REG_CTRL(16, 23),
37606763c74SThomas Petazzoni 	MPP_FUNC_CTRL(24, 39, "mpp_camera", dove_mpp4_ctrl),
37706763c74SThomas Petazzoni 	MPP_FUNC_CTRL(40, 45, "mpp_sdio0", dove_mpp4_ctrl),
37806763c74SThomas Petazzoni 	MPP_FUNC_CTRL(46, 51, "mpp_sdio1", dove_mpp4_ctrl),
37906763c74SThomas Petazzoni 	MPP_FUNC_GPIO_CTRL(52, 57, "mpp_audio1", dove_audio1_ctrl),
38006763c74SThomas Petazzoni 	MPP_FUNC_CTRL(58, 61, "mpp_spi0", dove_mpp4_ctrl),
38106763c74SThomas Petazzoni 	MPP_FUNC_CTRL(62, 63, "mpp_uart1", dove_mpp4_ctrl),
38206763c74SThomas Petazzoni 	MPP_FUNC_CTRL(64, 71, "mpp_nand", dove_nand_ctrl),
38306763c74SThomas Petazzoni 	MPP_FUNC_CTRL(72, 72, "audio0", dove_audio0_ctrl),
38406763c74SThomas Petazzoni 	MPP_FUNC_CTRL(73, 73, "twsi", dove_twsi_ctrl),
38506763c74SThomas Petazzoni };
38606763c74SThomas Petazzoni 
38706763c74SThomas Petazzoni static struct mvebu_mpp_mode dove_mpp_modes[] = {
38806763c74SThomas Petazzoni 	MPP_MODE(0,
38906763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
39006763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart2", "rts"),
39106763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio0", "cd"),
39206763c74SThomas Petazzoni 		MPP_FUNCTION(0x0f, "lcd0", "pwm"),
393bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
394bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
395bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
396bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
397bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
398bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
399bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
400bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
401bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
402bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
403bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
404bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
40506763c74SThomas Petazzoni 	MPP_MODE(1,
40606763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
40706763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart2", "cts"),
40806763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio0", "wp"),
40906763c74SThomas Petazzoni 		MPP_FUNCTION(0x0f, "lcd1", "pwm"),
410bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
411bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
412bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
413bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
414bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
415bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
416bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
417bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
418bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
419bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
420bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
421bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
42206763c74SThomas Petazzoni 	MPP_MODE(2,
42306763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
42406763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "sata", "prsnt"),
42506763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart2", "txd"),
42606763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio0", "buspwr"),
42706763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "uart1", "rts"),
428bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
429bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
430bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
431bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
432bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
433bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
434bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
435bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
436bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
437bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
438bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
439bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
44006763c74SThomas Petazzoni 	MPP_MODE(3,
44106763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
44206763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "sata", "act"),
44306763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart2", "rxd"),
44406763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio0", "ledctrl"),
44506763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "uart1", "cts"),
44606763c74SThomas Petazzoni 		MPP_FUNCTION(0x0f, "lcd-spi", "cs1"),
447bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
448bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
449bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
450bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
451bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
452bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
453bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
454bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
455bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
456bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
457bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
458bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
45906763c74SThomas Petazzoni 	MPP_MODE(4,
46006763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
46106763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart3", "rts"),
46206763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio1", "cd"),
46306763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "spi1", "miso"),
464bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
465bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
466bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
467bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
468bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
469bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
470bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
471bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
472bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
473bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
474bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
475bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
47606763c74SThomas Petazzoni 	MPP_MODE(5,
47706763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
47806763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart3", "cts"),
47906763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio1", "wp"),
48006763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "spi1", "cs"),
481bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
482bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
483bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
484bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
485bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
486bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
487bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
488bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
489bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
490bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
491bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
492bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
49306763c74SThomas Petazzoni 	MPP_MODE(6,
49406763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
49506763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart3", "txd"),
49606763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio1", "buspwr"),
49706763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "spi1", "mosi"),
498bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
499bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
500bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
501bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
502bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
503bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
504bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
505bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
506bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
507bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
508bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
509bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
51006763c74SThomas Petazzoni 	MPP_MODE(7,
51106763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
51206763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart3", "rxd"),
51306763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio1", "ledctrl"),
51406763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "spi1", "sck"),
515bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
516bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
517bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
518bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
519bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
520bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
521bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
522bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
523bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
524bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
525bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
526bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
52706763c74SThomas Petazzoni 	MPP_MODE(8,
52806763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
52906763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "watchdog", "rstout"),
530bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
531bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
532bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
533bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
534bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
535bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
536bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
537bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
538bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
539bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
540bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
541bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
54206763c74SThomas Petazzoni 	MPP_MODE(9,
54306763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
54406763c74SThomas Petazzoni 		MPP_FUNCTION(0x05, "pex1", "clkreq"),
545bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
546bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
547bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
548bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
549bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
550bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
551bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
552bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
553bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
554bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
555bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
556bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
55706763c74SThomas Petazzoni 	MPP_MODE(10,
55806763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
55906763c74SThomas Petazzoni 		MPP_FUNCTION(0x05, "ssp", "sclk"),
560bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
561bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
562bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
563bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
564bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
565bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
566bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
567bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
568bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
569bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
570bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
571bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
57206763c74SThomas Petazzoni 	MPP_MODE(11,
57306763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
57406763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "sata", "prsnt"),
57506763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "sata-1", "act"),
57606763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio0", "ledctrl"),
57706763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "sdio1", "ledctrl"),
57806763c74SThomas Petazzoni 		MPP_FUNCTION(0x05, "pex0", "clkreq"),
579bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
580bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
581bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
582bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
583bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
584bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
585bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
586bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
587bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
588bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
589bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
590bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
59106763c74SThomas Petazzoni 	MPP_MODE(12,
59206763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
59306763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "sata", "act"),
59406763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart2", "rts"),
59506763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "audio0", "extclk"),
59606763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "sdio1", "cd"),
597bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
598bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
599bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
600bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
601bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
602bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
603bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
604bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
605bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
606bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
607bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
608bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
60906763c74SThomas Petazzoni 	MPP_MODE(13,
61006763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
61106763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart2", "cts"),
61206763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "audio1", "extclk"),
61306763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "sdio1", "wp"),
61406763c74SThomas Petazzoni 		MPP_FUNCTION(0x05, "ssp", "extclk"),
615bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
616bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
617bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
618bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
619bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
620bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
621bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
622bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
623bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
624bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
625bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
626bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
62706763c74SThomas Petazzoni 	MPP_MODE(14,
62806763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
62906763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart2", "txd"),
63006763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "sdio1", "buspwr"),
63106763c74SThomas Petazzoni 		MPP_FUNCTION(0x05, "ssp", "rxd"),
632bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
633bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
634bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
635bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
636bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
637bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
638bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
639bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
640bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
641bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
642bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
643bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
64406763c74SThomas Petazzoni 	MPP_MODE(15,
64506763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
64606763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart2", "rxd"),
64706763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "sdio1", "ledctrl"),
64806763c74SThomas Petazzoni 		MPP_FUNCTION(0x05, "ssp", "sfrm"),
649bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
650bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
651bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
652bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
653bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
654bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
655bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
656bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
657bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
658bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
659bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
660bbd7b275SSebastian Hesselbarth 		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
66106763c74SThomas Petazzoni 	MPP_MODE(16,
66206763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
66306763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart3", "rts"),
66406763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio0", "cd"),
66506763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "lcd-spi", "cs1"),
66606763c74SThomas Petazzoni 		MPP_FUNCTION(0x05, "ac97", "sdi1")),
66706763c74SThomas Petazzoni 	MPP_MODE(17,
66806763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
66906763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "ac97-1", "sysclko"),
67006763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart3", "cts"),
67106763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio0", "wp"),
67206763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "twsi", "sda"),
67306763c74SThomas Petazzoni 		MPP_FUNCTION(0x05, "ac97", "sdi2")),
67406763c74SThomas Petazzoni 	MPP_MODE(18,
67506763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
67606763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart3", "txd"),
67706763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio0", "buspwr"),
67806763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "lcd0", "pwm"),
67906763c74SThomas Petazzoni 		MPP_FUNCTION(0x05, "ac97", "sdi3")),
68006763c74SThomas Petazzoni 	MPP_MODE(19,
68106763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
68206763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "uart3", "rxd"),
68306763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio0", "ledctrl"),
68406763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "twsi", "sck")),
68506763c74SThomas Petazzoni 	MPP_MODE(20,
68606763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
68706763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "ac97", "sysclko"),
68806763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "lcd-spi", "miso"),
68906763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio1", "cd"),
69006763c74SThomas Petazzoni 		MPP_FUNCTION(0x05, "sdio0", "cd"),
69106763c74SThomas Petazzoni 		MPP_FUNCTION(0x06, "spi1", "miso")),
69206763c74SThomas Petazzoni 	MPP_MODE(21,
69306763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
69406763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "uart1", "rts"),
69506763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "lcd-spi", "cs0"),
69606763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio1", "wp"),
69706763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "ssp", "sfrm"),
69806763c74SThomas Petazzoni 		MPP_FUNCTION(0x05, "sdio0", "wp"),
69906763c74SThomas Petazzoni 		MPP_FUNCTION(0x06, "spi1", "cs")),
70006763c74SThomas Petazzoni 	MPP_MODE(22,
70106763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
70206763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "uart1", "cts"),
70306763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "lcd-spi", "mosi"),
70406763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio1", "buspwr"),
70506763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "ssp", "txd"),
70606763c74SThomas Petazzoni 		MPP_FUNCTION(0x05, "sdio0", "buspwr"),
70706763c74SThomas Petazzoni 		MPP_FUNCTION(0x06, "spi1", "mosi")),
70806763c74SThomas Petazzoni 	MPP_MODE(23,
70906763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "gpio", NULL),
71006763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "lcd-spi", "sck"),
71106763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "sdio1", "ledctrl"),
71206763c74SThomas Petazzoni 		MPP_FUNCTION(0x04, "ssp", "sclk"),
71306763c74SThomas Petazzoni 		MPP_FUNCTION(0x05, "sdio0", "ledctrl"),
71406763c74SThomas Petazzoni 		MPP_FUNCTION(0x06, "spi1", "sck")),
71506763c74SThomas Petazzoni 	MPP_MODE(24,
71606763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "camera", NULL),
71706763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "gpio", NULL)),
71806763c74SThomas Petazzoni 	MPP_MODE(40,
71906763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "sdio0", NULL),
72006763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "gpio", NULL)),
72106763c74SThomas Petazzoni 	MPP_MODE(46,
72206763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "sdio1", NULL),
72306763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "gpio", NULL)),
72406763c74SThomas Petazzoni 	MPP_MODE(52,
72506763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "i2s1/spdifo", NULL),
72606763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "i2s1", NULL),
72706763c74SThomas Petazzoni 		MPP_FUNCTION(0x08, "spdifo", NULL),
72806763c74SThomas Petazzoni 		MPP_FUNCTION(0x0a, "gpio", NULL),
72906763c74SThomas Petazzoni 		MPP_FUNCTION(0x0b, "twsi", NULL),
73006763c74SThomas Petazzoni 		MPP_FUNCTION(0x0c, "ssp/spdifo", NULL),
73106763c74SThomas Petazzoni 		MPP_FUNCTION(0x0e, "ssp", NULL),
73206763c74SThomas Petazzoni 		MPP_FUNCTION(0x0f, "ssp/twsi", NULL)),
73306763c74SThomas Petazzoni 	MPP_MODE(58,
73406763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "spi0", NULL),
73506763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "gpio", NULL)),
73606763c74SThomas Petazzoni 	MPP_MODE(62,
73706763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "uart1", NULL),
73806763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "gpio", NULL)),
73906763c74SThomas Petazzoni 	MPP_MODE(64,
74006763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "nand", NULL),
74106763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "gpo", NULL)),
74206763c74SThomas Petazzoni 	MPP_MODE(72,
74306763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "i2s", NULL),
74406763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "ac97", NULL)),
74506763c74SThomas Petazzoni 	MPP_MODE(73,
74606763c74SThomas Petazzoni 		MPP_FUNCTION(0x00, "twsi-none", NULL),
74706763c74SThomas Petazzoni 		MPP_FUNCTION(0x01, "twsi-opt1", NULL),
74806763c74SThomas Petazzoni 		MPP_FUNCTION(0x02, "twsi-opt2", NULL),
74906763c74SThomas Petazzoni 		MPP_FUNCTION(0x03, "twsi-opt3", NULL)),
75006763c74SThomas Petazzoni };
75106763c74SThomas Petazzoni 
75206763c74SThomas Petazzoni static struct pinctrl_gpio_range dove_mpp_gpio_ranges[] = {
75306763c74SThomas Petazzoni 	MPP_GPIO_RANGE(0,  0,  0, 32),
75406763c74SThomas Petazzoni 	MPP_GPIO_RANGE(1, 32, 32, 32),
75506763c74SThomas Petazzoni 	MPP_GPIO_RANGE(2, 64, 64,  8),
75606763c74SThomas Petazzoni };
75706763c74SThomas Petazzoni 
75806763c74SThomas Petazzoni static struct mvebu_pinctrl_soc_info dove_pinctrl_info = {
75906763c74SThomas Petazzoni 	.controls = dove_mpp_controls,
76006763c74SThomas Petazzoni 	.ncontrols = ARRAY_SIZE(dove_mpp_controls),
76106763c74SThomas Petazzoni 	.modes = dove_mpp_modes,
76206763c74SThomas Petazzoni 	.nmodes = ARRAY_SIZE(dove_mpp_modes),
76306763c74SThomas Petazzoni 	.gpioranges = dove_mpp_gpio_ranges,
76406763c74SThomas Petazzoni 	.ngpioranges = ARRAY_SIZE(dove_mpp_gpio_ranges),
76506763c74SThomas Petazzoni 	.variant = 0,
76606763c74SThomas Petazzoni };
76706763c74SThomas Petazzoni 
76806763c74SThomas Petazzoni static struct clk *clk;
76906763c74SThomas Petazzoni 
770150632b0SGreg Kroah-Hartman static struct of_device_id dove_pinctrl_of_match[] = {
77106763c74SThomas Petazzoni 	{ .compatible = "marvell,dove-pinctrl", .data = &dove_pinctrl_info },
77206763c74SThomas Petazzoni 	{ }
77306763c74SThomas Petazzoni };
77406763c74SThomas Petazzoni 
775150632b0SGreg Kroah-Hartman static int dove_pinctrl_probe(struct platform_device *pdev)
77606763c74SThomas Petazzoni {
77706763c74SThomas Petazzoni 	const struct of_device_id *match =
77806763c74SThomas Petazzoni 		of_match_device(dove_pinctrl_of_match, &pdev->dev);
77916fa36beSAndrew Lunn 	pdev->dev.platform_data = (void *)match->data;
78006763c74SThomas Petazzoni 
78106763c74SThomas Petazzoni 	/*
78206763c74SThomas Petazzoni 	 * General MPP Configuration Register is part of pdma registers.
78306763c74SThomas Petazzoni 	 * grab clk to make sure it is ticking.
78406763c74SThomas Petazzoni 	 */
78506763c74SThomas Petazzoni 	clk = devm_clk_get(&pdev->dev, NULL);
786ba607b62SSebastian Hesselbarth 	if (IS_ERR(clk)) {
787ba607b62SSebastian Hesselbarth 		dev_err(&pdev->dev, "Unable to get pdma clock");
7885795c6acSRusty Russell 		return PTR_ERR(clk);
789ba607b62SSebastian Hesselbarth 	}
79006763c74SThomas Petazzoni 	clk_prepare_enable(clk);
79106763c74SThomas Petazzoni 
79206763c74SThomas Petazzoni 	return mvebu_pinctrl_probe(pdev);
79306763c74SThomas Petazzoni }
79406763c74SThomas Petazzoni 
795150632b0SGreg Kroah-Hartman static int dove_pinctrl_remove(struct platform_device *pdev)
79606763c74SThomas Petazzoni {
79706763c74SThomas Petazzoni 	int ret;
79806763c74SThomas Petazzoni 
79906763c74SThomas Petazzoni 	ret = mvebu_pinctrl_remove(pdev);
80006763c74SThomas Petazzoni 	if (!IS_ERR(clk))
80106763c74SThomas Petazzoni 		clk_disable_unprepare(clk);
80206763c74SThomas Petazzoni 	return ret;
80306763c74SThomas Petazzoni }
80406763c74SThomas Petazzoni 
80506763c74SThomas Petazzoni static struct platform_driver dove_pinctrl_driver = {
80606763c74SThomas Petazzoni 	.driver = {
80706763c74SThomas Petazzoni 		.name = "dove-pinctrl",
80806763c74SThomas Petazzoni 		.owner = THIS_MODULE,
809*f2e9394dSSachin Kamat 		.of_match_table = dove_pinctrl_of_match,
81006763c74SThomas Petazzoni 	},
81106763c74SThomas Petazzoni 	.probe = dove_pinctrl_probe,
812150632b0SGreg Kroah-Hartman 	.remove = dove_pinctrl_remove,
81306763c74SThomas Petazzoni };
81406763c74SThomas Petazzoni 
81506763c74SThomas Petazzoni module_platform_driver(dove_pinctrl_driver);
81606763c74SThomas Petazzoni 
81706763c74SThomas Petazzoni MODULE_AUTHOR("Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>");
81806763c74SThomas Petazzoni MODULE_DESCRIPTION("Marvell Dove pinctrl driver");
81906763c74SThomas Petazzoni MODULE_LICENSE("GPL v2");
820