18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Marvell Dove pinctrl driver based on mvebu pinctrl core
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Author: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#include <linux/err.h>
98c2ecf20Sopenharmony_ci#include <linux/init.h>
108c2ecf20Sopenharmony_ci#include <linux/io.h>
118c2ecf20Sopenharmony_ci#include <linux/bitops.h>
128c2ecf20Sopenharmony_ci#include <linux/platform_device.h>
138c2ecf20Sopenharmony_ci#include <linux/clk.h>
148c2ecf20Sopenharmony_ci#include <linux/of.h>
158c2ecf20Sopenharmony_ci#include <linux/of_device.h>
168c2ecf20Sopenharmony_ci#include <linux/mfd/syscon.h>
178c2ecf20Sopenharmony_ci#include <linux/pinctrl/pinctrl.h>
188c2ecf20Sopenharmony_ci#include <linux/regmap.h>
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci#include "pinctrl-mvebu.h"
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci/* Internal registers can be configured at any 1 MiB aligned address */
238c2ecf20Sopenharmony_ci#define INT_REGS_MASK		~(SZ_1M - 1)
248c2ecf20Sopenharmony_ci#define MPP4_REGS_OFFS		0xd0440
258c2ecf20Sopenharmony_ci#define PMU_REGS_OFFS		0xd802c
268c2ecf20Sopenharmony_ci#define GC_REGS_OFFS		0xe802c
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci/* MPP Base registers */
298c2ecf20Sopenharmony_ci#define PMU_MPP_GENERAL_CTRL	0x10
308c2ecf20Sopenharmony_ci#define  AU0_AC97_SEL		BIT(16)
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci/* MPP Control 4 register */
338c2ecf20Sopenharmony_ci#define SPI_GPIO_SEL		BIT(5)
348c2ecf20Sopenharmony_ci#define UART1_GPIO_SEL		BIT(4)
358c2ecf20Sopenharmony_ci#define AU1_GPIO_SEL		BIT(3)
368c2ecf20Sopenharmony_ci#define CAM_GPIO_SEL		BIT(2)
378c2ecf20Sopenharmony_ci#define SD1_GPIO_SEL		BIT(1)
388c2ecf20Sopenharmony_ci#define SD0_GPIO_SEL		BIT(0)
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci/* PMU Signal Select registers */
418c2ecf20Sopenharmony_ci#define PMU_SIGNAL_SELECT_0	0x00
428c2ecf20Sopenharmony_ci#define PMU_SIGNAL_SELECT_1	0x04
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci/* Global Config regmap registers */
458c2ecf20Sopenharmony_ci#define GLOBAL_CONFIG_1		0x00
468c2ecf20Sopenharmony_ci#define  TWSI_ENABLE_OPTION1	BIT(7)
478c2ecf20Sopenharmony_ci#define GLOBAL_CONFIG_2		0x04
488c2ecf20Sopenharmony_ci#define  TWSI_ENABLE_OPTION2	BIT(20)
498c2ecf20Sopenharmony_ci#define  TWSI_ENABLE_OPTION3	BIT(21)
508c2ecf20Sopenharmony_ci#define  TWSI_OPTION3_GPIO	BIT(22)
518c2ecf20Sopenharmony_ci#define SSP_CTRL_STATUS_1	0x08
528c2ecf20Sopenharmony_ci#define  SSP_ON_AU1		BIT(0)
538c2ecf20Sopenharmony_ci#define MPP_GENERAL_CONFIG	0x10
548c2ecf20Sopenharmony_ci#define  AU1_SPDIFO_GPIO_EN	BIT(1)
558c2ecf20Sopenharmony_ci#define  NAND_GPIO_EN		BIT(0)
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci#define CONFIG_PMU	BIT(4)
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_cistatic void __iomem *mpp4_base;
608c2ecf20Sopenharmony_cistatic void __iomem *pmu_base;
618c2ecf20Sopenharmony_cistatic struct regmap *gconfmap;
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_cistatic int dove_pmu_mpp_ctrl_get(struct mvebu_mpp_ctrl_data *data,
648c2ecf20Sopenharmony_ci				 unsigned pid, unsigned long *config)
658c2ecf20Sopenharmony_ci{
668c2ecf20Sopenharmony_ci	unsigned off = (pid / MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS;
678c2ecf20Sopenharmony_ci	unsigned shift = (pid % MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS;
688c2ecf20Sopenharmony_ci	unsigned long pmu = readl(data->base + PMU_MPP_GENERAL_CTRL);
698c2ecf20Sopenharmony_ci	unsigned long func;
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci	if ((pmu & BIT(pid)) == 0)
728c2ecf20Sopenharmony_ci		return mvebu_mmio_mpp_ctrl_get(data, pid, config);
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci	func = readl(pmu_base + PMU_SIGNAL_SELECT_0 + off);
758c2ecf20Sopenharmony_ci	*config = (func >> shift) & MVEBU_MPP_MASK;
768c2ecf20Sopenharmony_ci	*config |= CONFIG_PMU;
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ci	return 0;
798c2ecf20Sopenharmony_ci}
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_cistatic int dove_pmu_mpp_ctrl_set(struct mvebu_mpp_ctrl_data *data,
828c2ecf20Sopenharmony_ci				 unsigned pid, unsigned long config)
838c2ecf20Sopenharmony_ci{
848c2ecf20Sopenharmony_ci	unsigned off = (pid / MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS;
858c2ecf20Sopenharmony_ci	unsigned shift = (pid % MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS;
868c2ecf20Sopenharmony_ci	unsigned long pmu = readl(data->base + PMU_MPP_GENERAL_CTRL);
878c2ecf20Sopenharmony_ci	unsigned long func;
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci	if ((config & CONFIG_PMU) == 0) {
908c2ecf20Sopenharmony_ci		writel(pmu & ~BIT(pid), data->base + PMU_MPP_GENERAL_CTRL);
918c2ecf20Sopenharmony_ci		return mvebu_mmio_mpp_ctrl_set(data, pid, config);
928c2ecf20Sopenharmony_ci	}
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci	writel(pmu | BIT(pid), data->base + PMU_MPP_GENERAL_CTRL);
958c2ecf20Sopenharmony_ci	func = readl(pmu_base + PMU_SIGNAL_SELECT_0 + off);
968c2ecf20Sopenharmony_ci	func &= ~(MVEBU_MPP_MASK << shift);
978c2ecf20Sopenharmony_ci	func |= (config & MVEBU_MPP_MASK) << shift;
988c2ecf20Sopenharmony_ci	writel(func, pmu_base + PMU_SIGNAL_SELECT_0 + off);
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ci	return 0;
1018c2ecf20Sopenharmony_ci}
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_cistatic int dove_mpp4_ctrl_get(struct mvebu_mpp_ctrl_data *data, unsigned pid,
1048c2ecf20Sopenharmony_ci			      unsigned long *config)
1058c2ecf20Sopenharmony_ci{
1068c2ecf20Sopenharmony_ci	unsigned long mpp4 = readl(mpp4_base);
1078c2ecf20Sopenharmony_ci	unsigned long mask;
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ci	switch (pid) {
1108c2ecf20Sopenharmony_ci	case 24: /* mpp_camera */
1118c2ecf20Sopenharmony_ci		mask = CAM_GPIO_SEL;
1128c2ecf20Sopenharmony_ci		break;
1138c2ecf20Sopenharmony_ci	case 40: /* mpp_sdio0 */
1148c2ecf20Sopenharmony_ci		mask = SD0_GPIO_SEL;
1158c2ecf20Sopenharmony_ci		break;
1168c2ecf20Sopenharmony_ci	case 46: /* mpp_sdio1 */
1178c2ecf20Sopenharmony_ci		mask = SD1_GPIO_SEL;
1188c2ecf20Sopenharmony_ci		break;
1198c2ecf20Sopenharmony_ci	case 58: /* mpp_spi0 */
1208c2ecf20Sopenharmony_ci		mask = SPI_GPIO_SEL;
1218c2ecf20Sopenharmony_ci		break;
1228c2ecf20Sopenharmony_ci	case 62: /* mpp_uart1 */
1238c2ecf20Sopenharmony_ci		mask = UART1_GPIO_SEL;
1248c2ecf20Sopenharmony_ci		break;
1258c2ecf20Sopenharmony_ci	default:
1268c2ecf20Sopenharmony_ci		return -EINVAL;
1278c2ecf20Sopenharmony_ci	}
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_ci	*config = ((mpp4 & mask) != 0);
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ci	return 0;
1328c2ecf20Sopenharmony_ci}
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_cistatic int dove_mpp4_ctrl_set(struct mvebu_mpp_ctrl_data *data, unsigned pid,
1358c2ecf20Sopenharmony_ci			      unsigned long config)
1368c2ecf20Sopenharmony_ci{
1378c2ecf20Sopenharmony_ci	unsigned long mpp4 = readl(mpp4_base);
1388c2ecf20Sopenharmony_ci	unsigned long mask;
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_ci	switch (pid) {
1418c2ecf20Sopenharmony_ci	case 24: /* mpp_camera */
1428c2ecf20Sopenharmony_ci		mask = CAM_GPIO_SEL;
1438c2ecf20Sopenharmony_ci		break;
1448c2ecf20Sopenharmony_ci	case 40: /* mpp_sdio0 */
1458c2ecf20Sopenharmony_ci		mask = SD0_GPIO_SEL;
1468c2ecf20Sopenharmony_ci		break;
1478c2ecf20Sopenharmony_ci	case 46: /* mpp_sdio1 */
1488c2ecf20Sopenharmony_ci		mask = SD1_GPIO_SEL;
1498c2ecf20Sopenharmony_ci		break;
1508c2ecf20Sopenharmony_ci	case 58: /* mpp_spi0 */
1518c2ecf20Sopenharmony_ci		mask = SPI_GPIO_SEL;
1528c2ecf20Sopenharmony_ci		break;
1538c2ecf20Sopenharmony_ci	case 62: /* mpp_uart1 */
1548c2ecf20Sopenharmony_ci		mask = UART1_GPIO_SEL;
1558c2ecf20Sopenharmony_ci		break;
1568c2ecf20Sopenharmony_ci	default:
1578c2ecf20Sopenharmony_ci		return -EINVAL;
1588c2ecf20Sopenharmony_ci	}
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_ci	mpp4 &= ~mask;
1618c2ecf20Sopenharmony_ci	if (config)
1628c2ecf20Sopenharmony_ci		mpp4 |= mask;
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_ci	writel(mpp4, mpp4_base);
1658c2ecf20Sopenharmony_ci
1668c2ecf20Sopenharmony_ci	return 0;
1678c2ecf20Sopenharmony_ci}
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_cistatic int dove_nand_ctrl_get(struct mvebu_mpp_ctrl_data *data, unsigned pid,
1708c2ecf20Sopenharmony_ci			      unsigned long *config)
1718c2ecf20Sopenharmony_ci{
1728c2ecf20Sopenharmony_ci	unsigned int gmpp;
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_ci	regmap_read(gconfmap, MPP_GENERAL_CONFIG, &gmpp);
1758c2ecf20Sopenharmony_ci	*config = ((gmpp & NAND_GPIO_EN) != 0);
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_ci	return 0;
1788c2ecf20Sopenharmony_ci}
1798c2ecf20Sopenharmony_ci
1808c2ecf20Sopenharmony_cistatic int dove_nand_ctrl_set(struct mvebu_mpp_ctrl_data *data, unsigned pid,
1818c2ecf20Sopenharmony_ci			      unsigned long config)
1828c2ecf20Sopenharmony_ci{
1838c2ecf20Sopenharmony_ci	regmap_update_bits(gconfmap, MPP_GENERAL_CONFIG,
1848c2ecf20Sopenharmony_ci			   NAND_GPIO_EN,
1858c2ecf20Sopenharmony_ci			   (config) ? NAND_GPIO_EN : 0);
1868c2ecf20Sopenharmony_ci	return 0;
1878c2ecf20Sopenharmony_ci}
1888c2ecf20Sopenharmony_ci
1898c2ecf20Sopenharmony_cistatic int dove_audio0_ctrl_get(struct mvebu_mpp_ctrl_data *data, unsigned pid,
1908c2ecf20Sopenharmony_ci				unsigned long *config)
1918c2ecf20Sopenharmony_ci{
1928c2ecf20Sopenharmony_ci	unsigned long pmu = readl(data->base + PMU_MPP_GENERAL_CTRL);
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_ci	*config = ((pmu & AU0_AC97_SEL) != 0);
1958c2ecf20Sopenharmony_ci
1968c2ecf20Sopenharmony_ci	return 0;
1978c2ecf20Sopenharmony_ci}
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_cistatic int dove_audio0_ctrl_set(struct mvebu_mpp_ctrl_data *data, unsigned pid,
2008c2ecf20Sopenharmony_ci				unsigned long config)
2018c2ecf20Sopenharmony_ci{
2028c2ecf20Sopenharmony_ci	unsigned long pmu = readl(data->base + PMU_MPP_GENERAL_CTRL);
2038c2ecf20Sopenharmony_ci
2048c2ecf20Sopenharmony_ci	pmu &= ~AU0_AC97_SEL;
2058c2ecf20Sopenharmony_ci	if (config)
2068c2ecf20Sopenharmony_ci		pmu |= AU0_AC97_SEL;
2078c2ecf20Sopenharmony_ci	writel(pmu, data->base + PMU_MPP_GENERAL_CTRL);
2088c2ecf20Sopenharmony_ci
2098c2ecf20Sopenharmony_ci	return 0;
2108c2ecf20Sopenharmony_ci}
2118c2ecf20Sopenharmony_ci
2128c2ecf20Sopenharmony_cistatic int dove_audio1_ctrl_get(struct mvebu_mpp_ctrl_data *data, unsigned pid,
2138c2ecf20Sopenharmony_ci				unsigned long *config)
2148c2ecf20Sopenharmony_ci{
2158c2ecf20Sopenharmony_ci	unsigned int mpp4 = readl(mpp4_base);
2168c2ecf20Sopenharmony_ci	unsigned int sspc1;
2178c2ecf20Sopenharmony_ci	unsigned int gmpp;
2188c2ecf20Sopenharmony_ci	unsigned int gcfg2;
2198c2ecf20Sopenharmony_ci
2208c2ecf20Sopenharmony_ci	regmap_read(gconfmap, SSP_CTRL_STATUS_1, &sspc1);
2218c2ecf20Sopenharmony_ci	regmap_read(gconfmap, MPP_GENERAL_CONFIG, &gmpp);
2228c2ecf20Sopenharmony_ci	regmap_read(gconfmap, GLOBAL_CONFIG_2, &gcfg2);
2238c2ecf20Sopenharmony_ci
2248c2ecf20Sopenharmony_ci	*config = 0;
2258c2ecf20Sopenharmony_ci	if (mpp4 & AU1_GPIO_SEL)
2268c2ecf20Sopenharmony_ci		*config |= BIT(3);
2278c2ecf20Sopenharmony_ci	if (sspc1 & SSP_ON_AU1)
2288c2ecf20Sopenharmony_ci		*config |= BIT(2);
2298c2ecf20Sopenharmony_ci	if (gmpp & AU1_SPDIFO_GPIO_EN)
2308c2ecf20Sopenharmony_ci		*config |= BIT(1);
2318c2ecf20Sopenharmony_ci	if (gcfg2 & TWSI_OPTION3_GPIO)
2328c2ecf20Sopenharmony_ci		*config |= BIT(0);
2338c2ecf20Sopenharmony_ci
2348c2ecf20Sopenharmony_ci	/* SSP/TWSI only if I2S1 not set*/
2358c2ecf20Sopenharmony_ci	if ((*config & BIT(3)) == 0)
2368c2ecf20Sopenharmony_ci		*config &= ~(BIT(2) | BIT(0));
2378c2ecf20Sopenharmony_ci	/* TWSI only if SPDIFO not set*/
2388c2ecf20Sopenharmony_ci	if ((*config & BIT(1)) == 0)
2398c2ecf20Sopenharmony_ci		*config &= ~BIT(0);
2408c2ecf20Sopenharmony_ci	return 0;
2418c2ecf20Sopenharmony_ci}
2428c2ecf20Sopenharmony_ci
2438c2ecf20Sopenharmony_cistatic int dove_audio1_ctrl_set(struct mvebu_mpp_ctrl_data *data, unsigned pid,
2448c2ecf20Sopenharmony_ci				unsigned long config)
2458c2ecf20Sopenharmony_ci{
2468c2ecf20Sopenharmony_ci	unsigned int mpp4 = readl(mpp4_base);
2478c2ecf20Sopenharmony_ci
2488c2ecf20Sopenharmony_ci	mpp4 &= ~AU1_GPIO_SEL;
2498c2ecf20Sopenharmony_ci	if (config & BIT(3))
2508c2ecf20Sopenharmony_ci		mpp4 |= AU1_GPIO_SEL;
2518c2ecf20Sopenharmony_ci	writel(mpp4, mpp4_base);
2528c2ecf20Sopenharmony_ci
2538c2ecf20Sopenharmony_ci	regmap_update_bits(gconfmap, SSP_CTRL_STATUS_1,
2548c2ecf20Sopenharmony_ci			   SSP_ON_AU1,
2558c2ecf20Sopenharmony_ci			   (config & BIT(2)) ? SSP_ON_AU1 : 0);
2568c2ecf20Sopenharmony_ci	regmap_update_bits(gconfmap, MPP_GENERAL_CONFIG,
2578c2ecf20Sopenharmony_ci			   AU1_SPDIFO_GPIO_EN,
2588c2ecf20Sopenharmony_ci			   (config & BIT(1)) ? AU1_SPDIFO_GPIO_EN : 0);
2598c2ecf20Sopenharmony_ci	regmap_update_bits(gconfmap, GLOBAL_CONFIG_2,
2608c2ecf20Sopenharmony_ci			   TWSI_OPTION3_GPIO,
2618c2ecf20Sopenharmony_ci			   (config & BIT(0)) ? TWSI_OPTION3_GPIO : 0);
2628c2ecf20Sopenharmony_ci
2638c2ecf20Sopenharmony_ci	return 0;
2648c2ecf20Sopenharmony_ci}
2658c2ecf20Sopenharmony_ci
2668c2ecf20Sopenharmony_ci/* mpp[52:57] gpio pins depend heavily on current config;
2678c2ecf20Sopenharmony_ci * gpio_req does not try to mux in gpio capabilities to not
2688c2ecf20Sopenharmony_ci * break other functions. If you require all mpps as gpio
2698c2ecf20Sopenharmony_ci * enforce gpio setting by pinctrl mapping.
2708c2ecf20Sopenharmony_ci */
2718c2ecf20Sopenharmony_cistatic int dove_audio1_ctrl_gpio_req(struct mvebu_mpp_ctrl_data *data,
2728c2ecf20Sopenharmony_ci				     unsigned pid)
2738c2ecf20Sopenharmony_ci{
2748c2ecf20Sopenharmony_ci	unsigned long config;
2758c2ecf20Sopenharmony_ci
2768c2ecf20Sopenharmony_ci	dove_audio1_ctrl_get(data, pid, &config);
2778c2ecf20Sopenharmony_ci
2788c2ecf20Sopenharmony_ci	switch (config) {
2798c2ecf20Sopenharmony_ci	case 0x02: /* i2s1 : gpio[56:57] */
2808c2ecf20Sopenharmony_ci	case 0x0e: /* ssp  : gpio[56:57] */
2818c2ecf20Sopenharmony_ci		if (pid >= 56)
2828c2ecf20Sopenharmony_ci			return 0;
2838c2ecf20Sopenharmony_ci		return -ENOTSUPP;
2848c2ecf20Sopenharmony_ci	case 0x08: /* spdifo : gpio[52:55] */
2858c2ecf20Sopenharmony_ci	case 0x0b: /* twsi   : gpio[52:55] */
2868c2ecf20Sopenharmony_ci		if (pid <= 55)
2878c2ecf20Sopenharmony_ci			return 0;
2888c2ecf20Sopenharmony_ci		return -ENOTSUPP;
2898c2ecf20Sopenharmony_ci	case 0x0a: /* all gpio */
2908c2ecf20Sopenharmony_ci		return 0;
2918c2ecf20Sopenharmony_ci	/* 0x00 : i2s1/spdifo : no gpio */
2928c2ecf20Sopenharmony_ci	/* 0x0c : ssp/spdifo  : no gpio */
2938c2ecf20Sopenharmony_ci	/* 0x0f : ssp/twsi    : no gpio */
2948c2ecf20Sopenharmony_ci	}
2958c2ecf20Sopenharmony_ci	return -ENOTSUPP;
2968c2ecf20Sopenharmony_ci}
2978c2ecf20Sopenharmony_ci
2988c2ecf20Sopenharmony_ci/* mpp[52:57] has gpio pins capable of in and out */
2998c2ecf20Sopenharmony_cistatic int dove_audio1_ctrl_gpio_dir(struct mvebu_mpp_ctrl_data *data,
3008c2ecf20Sopenharmony_ci				     unsigned pid, bool input)
3018c2ecf20Sopenharmony_ci{
3028c2ecf20Sopenharmony_ci	if (pid < 52 || pid > 57)
3038c2ecf20Sopenharmony_ci		return -ENOTSUPP;
3048c2ecf20Sopenharmony_ci	return 0;
3058c2ecf20Sopenharmony_ci}
3068c2ecf20Sopenharmony_ci
3078c2ecf20Sopenharmony_cistatic int dove_twsi_ctrl_get(struct mvebu_mpp_ctrl_data *data, unsigned pid,
3088c2ecf20Sopenharmony_ci			      unsigned long *config)
3098c2ecf20Sopenharmony_ci{
3108c2ecf20Sopenharmony_ci	unsigned int gcfg1;
3118c2ecf20Sopenharmony_ci	unsigned int gcfg2;
3128c2ecf20Sopenharmony_ci
3138c2ecf20Sopenharmony_ci	regmap_read(gconfmap, GLOBAL_CONFIG_1, &gcfg1);
3148c2ecf20Sopenharmony_ci	regmap_read(gconfmap, GLOBAL_CONFIG_2, &gcfg2);
3158c2ecf20Sopenharmony_ci
3168c2ecf20Sopenharmony_ci	*config = 0;
3178c2ecf20Sopenharmony_ci	if (gcfg1 & TWSI_ENABLE_OPTION1)
3188c2ecf20Sopenharmony_ci		*config = 1;
3198c2ecf20Sopenharmony_ci	else if (gcfg2 & TWSI_ENABLE_OPTION2)
3208c2ecf20Sopenharmony_ci		*config = 2;
3218c2ecf20Sopenharmony_ci	else if (gcfg2 & TWSI_ENABLE_OPTION3)
3228c2ecf20Sopenharmony_ci		*config = 3;
3238c2ecf20Sopenharmony_ci
3248c2ecf20Sopenharmony_ci	return 0;
3258c2ecf20Sopenharmony_ci}
3268c2ecf20Sopenharmony_ci
3278c2ecf20Sopenharmony_cistatic int dove_twsi_ctrl_set(struct mvebu_mpp_ctrl_data *data, unsigned pid,
3288c2ecf20Sopenharmony_ci			      unsigned long config)
3298c2ecf20Sopenharmony_ci{
3308c2ecf20Sopenharmony_ci	unsigned int gcfg1 = 0;
3318c2ecf20Sopenharmony_ci	unsigned int gcfg2 = 0;
3328c2ecf20Sopenharmony_ci
3338c2ecf20Sopenharmony_ci	switch (config) {
3348c2ecf20Sopenharmony_ci	case 1:
3358c2ecf20Sopenharmony_ci		gcfg1 = TWSI_ENABLE_OPTION1;
3368c2ecf20Sopenharmony_ci		break;
3378c2ecf20Sopenharmony_ci	case 2:
3388c2ecf20Sopenharmony_ci		gcfg2 = TWSI_ENABLE_OPTION2;
3398c2ecf20Sopenharmony_ci		break;
3408c2ecf20Sopenharmony_ci	case 3:
3418c2ecf20Sopenharmony_ci		gcfg2 = TWSI_ENABLE_OPTION3;
3428c2ecf20Sopenharmony_ci		break;
3438c2ecf20Sopenharmony_ci	}
3448c2ecf20Sopenharmony_ci
3458c2ecf20Sopenharmony_ci	regmap_update_bits(gconfmap, GLOBAL_CONFIG_1,
3468c2ecf20Sopenharmony_ci			   TWSI_ENABLE_OPTION1,
3478c2ecf20Sopenharmony_ci			   gcfg1);
3488c2ecf20Sopenharmony_ci	regmap_update_bits(gconfmap, GLOBAL_CONFIG_2,
3498c2ecf20Sopenharmony_ci			   TWSI_ENABLE_OPTION2 | TWSI_ENABLE_OPTION3,
3508c2ecf20Sopenharmony_ci			   gcfg2);
3518c2ecf20Sopenharmony_ci
3528c2ecf20Sopenharmony_ci	return 0;
3538c2ecf20Sopenharmony_ci}
3548c2ecf20Sopenharmony_ci
3558c2ecf20Sopenharmony_cistatic const struct mvebu_mpp_ctrl dove_mpp_controls[] = {
3568c2ecf20Sopenharmony_ci	MPP_FUNC_CTRL(0, 15, NULL, dove_pmu_mpp_ctrl),
3578c2ecf20Sopenharmony_ci	MPP_FUNC_CTRL(16, 23, NULL, mvebu_mmio_mpp_ctrl),
3588c2ecf20Sopenharmony_ci	MPP_FUNC_CTRL(24, 39, "mpp_camera", dove_mpp4_ctrl),
3598c2ecf20Sopenharmony_ci	MPP_FUNC_CTRL(40, 45, "mpp_sdio0", dove_mpp4_ctrl),
3608c2ecf20Sopenharmony_ci	MPP_FUNC_CTRL(46, 51, "mpp_sdio1", dove_mpp4_ctrl),
3618c2ecf20Sopenharmony_ci	MPP_FUNC_GPIO_CTRL(52, 57, "mpp_audio1", dove_audio1_ctrl),
3628c2ecf20Sopenharmony_ci	MPP_FUNC_CTRL(58, 61, "mpp_spi0", dove_mpp4_ctrl),
3638c2ecf20Sopenharmony_ci	MPP_FUNC_CTRL(62, 63, "mpp_uart1", dove_mpp4_ctrl),
3648c2ecf20Sopenharmony_ci	MPP_FUNC_CTRL(64, 71, "mpp_nand", dove_nand_ctrl),
3658c2ecf20Sopenharmony_ci	MPP_FUNC_CTRL(72, 72, "audio0", dove_audio0_ctrl),
3668c2ecf20Sopenharmony_ci	MPP_FUNC_CTRL(73, 73, "twsi", dove_twsi_ctrl),
3678c2ecf20Sopenharmony_ci};
3688c2ecf20Sopenharmony_ci
3698c2ecf20Sopenharmony_cistatic struct mvebu_mpp_mode dove_mpp_modes[] = {
3708c2ecf20Sopenharmony_ci	MPP_MODE(0,
3718c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x00, "gpio", NULL),
3728c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x02, "uart2", "rts"),
3738c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x03, "sdio0", "cd"),
3748c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x0f, "lcd0", "pwm"),
3758c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
3768c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
3778c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
3788c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
3798c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
3808c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
3818c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
3828c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
3838c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
3848c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
3858c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
3868c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
3878c2ecf20Sopenharmony_ci	MPP_MODE(1,
3888c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x00, "gpio", NULL),
3898c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x02, "uart2", "cts"),
3908c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x03, "sdio0", "wp"),
3918c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x0f, "lcd1", "pwm"),
3928c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
3938c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
3948c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
3958c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
3968c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
3978c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
3988c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
3998c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
4008c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
4018c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
4028c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
4038c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
4048c2ecf20Sopenharmony_ci	MPP_MODE(2,
4058c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x00, "gpio", NULL),
4068c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x01, "sata", "prsnt"),
4078c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x02, "uart2", "txd"),
4088c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x03, "sdio0", "buspwr"),
4098c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x04, "uart1", "rts"),
4108c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
4118c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
4128c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
4138c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
4148c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
4158c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
4168c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
4178c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
4188c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
4198c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
4208c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
4218c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
4228c2ecf20Sopenharmony_ci	MPP_MODE(3,
4238c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x00, "gpio", NULL),
4248c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x01, "sata", "act"),
4258c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x02, "uart2", "rxd"),
4268c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x03, "sdio0", "ledctrl"),
4278c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x04, "uart1", "cts"),
4288c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x0f, "lcd-spi", "cs1"),
4298c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
4308c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
4318c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
4328c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
4338c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
4348c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
4358c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
4368c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
4378c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
4388c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
4398c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
4408c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
4418c2ecf20Sopenharmony_ci	MPP_MODE(4,
4428c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x00, "gpio", NULL),
4438c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x02, "uart3", "rts"),
4448c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x03, "sdio1", "cd"),
4458c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x04, "spi1", "miso"),
4468c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
4478c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
4488c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
4498c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
4508c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
4518c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
4528c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
4538c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
4548c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
4558c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
4568c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
4578c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
4588c2ecf20Sopenharmony_ci	MPP_MODE(5,
4598c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x00, "gpio", NULL),
4608c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x02, "uart3", "cts"),
4618c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x03, "sdio1", "wp"),
4628c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x04, "spi1", "cs"),
4638c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
4648c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
4658c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
4668c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
4678c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
4688c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
4698c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
4708c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
4718c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
4728c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
4738c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
4748c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
4758c2ecf20Sopenharmony_ci	MPP_MODE(6,
4768c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x00, "gpio", NULL),
4778c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x02, "uart3", "txd"),
4788c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x03, "sdio1", "buspwr"),
4798c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x04, "spi1", "mosi"),
4808c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
4818c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
4828c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
4838c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
4848c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
4858c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
4868c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
4878c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
4888c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
4898c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
4908c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
4918c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
4928c2ecf20Sopenharmony_ci	MPP_MODE(7,
4938c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x00, "gpio", NULL),
4948c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x02, "uart3", "rxd"),
4958c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x03, "sdio1", "ledctrl"),
4968c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x04, "spi1", "sck"),
4978c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
4988c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
4998c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
5008c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
5018c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
5028c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
5038c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL),
5048c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
5058c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
5068c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
5078c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
5088c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
5098c2ecf20Sopenharmony_ci	MPP_MODE(8,
5108c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x00, "gpio", NULL),
5118c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x01, "watchdog", "rstout"),
5128c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
5138c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
5148c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
5158c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
5168c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
5178c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
5188c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
5198c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
5208c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
5218c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
5228c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
5238c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
5248c2ecf20Sopenharmony_ci	MPP_MODE(9,
5258c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x00, "gpio", NULL),
5268c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x05, "pex1", "clkreq"),
5278c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
5288c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
5298c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
5308c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
5318c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
5328c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
5338c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
5348c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
5358c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
5368c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
5378c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
5388c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
5398c2ecf20Sopenharmony_ci	MPP_MODE(10,
5408c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x00, "gpio", NULL),
5418c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x05, "ssp", "sclk"),
5428c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
5438c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
5448c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
5458c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
5468c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
5478c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
5488c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
5498c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
5508c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
5518c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
5528c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
5538c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
5548c2ecf20Sopenharmony_ci	MPP_MODE(11,
5558c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x00, "gpio", NULL),
5568c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x01, "sata", "prsnt"),
5578c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x02, "sata-1", "act"),
5588c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x03, "sdio0", "ledctrl"),
5598c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x04, "sdio1", "ledctrl"),
5608c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x05, "pex0", "clkreq"),
5618c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
5628c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
5638c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
5648c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
5658c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
5668c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
5678c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
5688c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
5698c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
5708c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
5718c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
5728c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
5738c2ecf20Sopenharmony_ci	MPP_MODE(12,
5748c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x00, "gpio", NULL),
5758c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x01, "sata", "act"),
5768c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x02, "uart2", "rts"),
5778c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x03, "audio0", "extclk"),
5788c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x04, "sdio1", "cd"),
5798c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
5808c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
5818c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
5828c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
5838c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
5848c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
5858c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
5868c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
5878c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
5888c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
5898c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
5908c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
5918c2ecf20Sopenharmony_ci	MPP_MODE(13,
5928c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x00, "gpio", NULL),
5938c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x02, "uart2", "cts"),
5948c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x03, "audio1", "extclk"),
5958c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x04, "sdio1", "wp"),
5968c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x05, "ssp", "extclk"),
5978c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
5988c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
5998c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
6008c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
6018c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
6028c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
6038c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
6048c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
6058c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
6068c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
6078c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
6088c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
6098c2ecf20Sopenharmony_ci	MPP_MODE(14,
6108c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x00, "gpio", NULL),
6118c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x02, "uart2", "txd"),
6128c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x04, "sdio1", "buspwr"),
6138c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x05, "ssp", "rxd"),
6148c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
6158c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
6168c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
6178c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
6188c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
6198c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
6208c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
6218c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
6228c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
6238c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
6248c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
6258c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
6268c2ecf20Sopenharmony_ci	MPP_MODE(15,
6278c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x00, "gpio", NULL),
6288c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x02, "uart2", "rxd"),
6298c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x04, "sdio1", "ledctrl"),
6308c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x05, "ssp", "sfrm"),
6318c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL),
6328c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL),
6338c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL),
6348c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"),
6358c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL),
6368c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL),
6378c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL),
6388c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL),
6398c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL),
6408c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL),
6418c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL),
6428c2ecf20Sopenharmony_ci		MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)),
6438c2ecf20Sopenharmony_ci	MPP_MODE(16,
6448c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x00, "gpio", NULL),
6458c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x02, "uart3", "rts"),
6468c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x03, "sdio0", "cd"),
6478c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x04, "lcd-spi", "cs1"),
6488c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x05, "ac97", "sdi1")),
6498c2ecf20Sopenharmony_ci	MPP_MODE(17,
6508c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x00, "gpio", NULL),
6518c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x01, "ac97-1", "sysclko"),
6528c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x02, "uart3", "cts"),
6538c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x03, "sdio0", "wp"),
6548c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x04, "twsi", "sda"),
6558c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x05, "ac97", "sdi2")),
6568c2ecf20Sopenharmony_ci	MPP_MODE(18,
6578c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x00, "gpio", NULL),
6588c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x02, "uart3", "txd"),
6598c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x03, "sdio0", "buspwr"),
6608c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x04, "lcd0", "pwm"),
6618c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x05, "ac97", "sdi3")),
6628c2ecf20Sopenharmony_ci	MPP_MODE(19,
6638c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x00, "gpio", NULL),
6648c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x02, "uart3", "rxd"),
6658c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x03, "sdio0", "ledctrl"),
6668c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x04, "twsi", "sck")),
6678c2ecf20Sopenharmony_ci	MPP_MODE(20,
6688c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x00, "gpio", NULL),
6698c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x01, "ac97", "sysclko"),
6708c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x02, "lcd-spi", "miso"),
6718c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x03, "sdio1", "cd"),
6728c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x05, "sdio0", "cd"),
6738c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x06, "spi1", "miso")),
6748c2ecf20Sopenharmony_ci	MPP_MODE(21,
6758c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x00, "gpio", NULL),
6768c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x01, "uart1", "rts"),
6778c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x02, "lcd-spi", "cs0"),
6788c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x03, "sdio1", "wp"),
6798c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x04, "ssp", "sfrm"),
6808c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x05, "sdio0", "wp"),
6818c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x06, "spi1", "cs")),
6828c2ecf20Sopenharmony_ci	MPP_MODE(22,
6838c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x00, "gpio", NULL),
6848c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x01, "uart1", "cts"),
6858c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x02, "lcd-spi", "mosi"),
6868c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x03, "sdio1", "buspwr"),
6878c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x04, "ssp", "txd"),
6888c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x05, "sdio0", "buspwr"),
6898c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x06, "spi1", "mosi")),
6908c2ecf20Sopenharmony_ci	MPP_MODE(23,
6918c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x00, "gpio", NULL),
6928c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x02, "lcd-spi", "sck"),
6938c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x03, "sdio1", "ledctrl"),
6948c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x04, "ssp", "sclk"),
6958c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x05, "sdio0", "ledctrl"),
6968c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x06, "spi1", "sck")),
6978c2ecf20Sopenharmony_ci	MPP_MODE(24,
6988c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x00, "camera", NULL),
6998c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x01, "gpio", NULL)),
7008c2ecf20Sopenharmony_ci	MPP_MODE(40,
7018c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x00, "sdio0", NULL),
7028c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x01, "gpio", NULL)),
7038c2ecf20Sopenharmony_ci	MPP_MODE(46,
7048c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x00, "sdio1", NULL),
7058c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x01, "gpio", NULL)),
7068c2ecf20Sopenharmony_ci	MPP_MODE(52,
7078c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x00, "i2s1/spdifo", NULL),
7088c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x02, "i2s1", NULL),
7098c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x08, "spdifo", NULL),
7108c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x0a, "gpio", NULL),
7118c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x0b, "twsi", NULL),
7128c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x0c, "ssp/spdifo", NULL),
7138c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x0e, "ssp", NULL),
7148c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x0f, "ssp/twsi", NULL)),
7158c2ecf20Sopenharmony_ci	MPP_MODE(58,
7168c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x00, "spi0", NULL),
7178c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x01, "gpio", NULL)),
7188c2ecf20Sopenharmony_ci	MPP_MODE(62,
7198c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x00, "uart1", NULL),
7208c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x01, "gpio", NULL)),
7218c2ecf20Sopenharmony_ci	MPP_MODE(64,
7228c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x00, "nand", NULL),
7238c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x01, "gpo", NULL)),
7248c2ecf20Sopenharmony_ci	MPP_MODE(72,
7258c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x00, "i2s", NULL),
7268c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x01, "ac97", NULL)),
7278c2ecf20Sopenharmony_ci	MPP_MODE(73,
7288c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x00, "twsi-none", NULL),
7298c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x01, "twsi-opt1", NULL),
7308c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x02, "twsi-opt2", NULL),
7318c2ecf20Sopenharmony_ci		MPP_FUNCTION(0x03, "twsi-opt3", NULL)),
7328c2ecf20Sopenharmony_ci};
7338c2ecf20Sopenharmony_ci
7348c2ecf20Sopenharmony_cistatic struct pinctrl_gpio_range dove_mpp_gpio_ranges[] = {
7358c2ecf20Sopenharmony_ci	MPP_GPIO_RANGE(0,  0,  0, 32),
7368c2ecf20Sopenharmony_ci	MPP_GPIO_RANGE(1, 32, 32, 32),
7378c2ecf20Sopenharmony_ci	MPP_GPIO_RANGE(2, 64, 64,  8),
7388c2ecf20Sopenharmony_ci};
7398c2ecf20Sopenharmony_ci
7408c2ecf20Sopenharmony_cistatic struct mvebu_pinctrl_soc_info dove_pinctrl_info = {
7418c2ecf20Sopenharmony_ci	.controls = dove_mpp_controls,
7428c2ecf20Sopenharmony_ci	.ncontrols = ARRAY_SIZE(dove_mpp_controls),
7438c2ecf20Sopenharmony_ci	.modes = dove_mpp_modes,
7448c2ecf20Sopenharmony_ci	.nmodes = ARRAY_SIZE(dove_mpp_modes),
7458c2ecf20Sopenharmony_ci	.gpioranges = dove_mpp_gpio_ranges,
7468c2ecf20Sopenharmony_ci	.ngpioranges = ARRAY_SIZE(dove_mpp_gpio_ranges),
7478c2ecf20Sopenharmony_ci	.variant = 0,
7488c2ecf20Sopenharmony_ci};
7498c2ecf20Sopenharmony_ci
7508c2ecf20Sopenharmony_cistatic struct clk *clk;
7518c2ecf20Sopenharmony_ci
7528c2ecf20Sopenharmony_cistatic const struct of_device_id dove_pinctrl_of_match[] = {
7538c2ecf20Sopenharmony_ci	{ .compatible = "marvell,dove-pinctrl", .data = &dove_pinctrl_info },
7548c2ecf20Sopenharmony_ci	{ }
7558c2ecf20Sopenharmony_ci};
7568c2ecf20Sopenharmony_ci
7578c2ecf20Sopenharmony_cistatic const struct regmap_config gc_regmap_config = {
7588c2ecf20Sopenharmony_ci	.reg_bits = 32,
7598c2ecf20Sopenharmony_ci	.val_bits = 32,
7608c2ecf20Sopenharmony_ci	.reg_stride = 4,
7618c2ecf20Sopenharmony_ci	.max_register = 5,
7628c2ecf20Sopenharmony_ci};
7638c2ecf20Sopenharmony_ci
7648c2ecf20Sopenharmony_cistatic int dove_pinctrl_probe(struct platform_device *pdev)
7658c2ecf20Sopenharmony_ci{
7668c2ecf20Sopenharmony_ci	struct resource *res, *mpp_res;
7678c2ecf20Sopenharmony_ci	struct resource fb_res;
7688c2ecf20Sopenharmony_ci	const struct of_device_id *match =
7698c2ecf20Sopenharmony_ci		of_match_device(dove_pinctrl_of_match, &pdev->dev);
7708c2ecf20Sopenharmony_ci	struct mvebu_mpp_ctrl_data *mpp_data;
7718c2ecf20Sopenharmony_ci	void __iomem *base;
7728c2ecf20Sopenharmony_ci	int i;
7738c2ecf20Sopenharmony_ci
7748c2ecf20Sopenharmony_ci	pdev->dev.platform_data = (void *)match->data;
7758c2ecf20Sopenharmony_ci
7768c2ecf20Sopenharmony_ci	/*
7778c2ecf20Sopenharmony_ci	 * General MPP Configuration Register is part of pdma registers.
7788c2ecf20Sopenharmony_ci	 * grab clk to make sure it is ticking.
7798c2ecf20Sopenharmony_ci	 */
7808c2ecf20Sopenharmony_ci	clk = devm_clk_get(&pdev->dev, NULL);
7818c2ecf20Sopenharmony_ci	if (IS_ERR(clk)) {
7828c2ecf20Sopenharmony_ci		dev_err(&pdev->dev, "Unable to get pdma clock");
7838c2ecf20Sopenharmony_ci		return PTR_ERR(clk);
7848c2ecf20Sopenharmony_ci	}
7858c2ecf20Sopenharmony_ci	clk_prepare_enable(clk);
7868c2ecf20Sopenharmony_ci
7878c2ecf20Sopenharmony_ci	mpp_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
7888c2ecf20Sopenharmony_ci	base = devm_ioremap_resource(&pdev->dev, mpp_res);
7898c2ecf20Sopenharmony_ci	if (IS_ERR(base))
7908c2ecf20Sopenharmony_ci		return PTR_ERR(base);
7918c2ecf20Sopenharmony_ci
7928c2ecf20Sopenharmony_ci	mpp_data = devm_kcalloc(&pdev->dev, dove_pinctrl_info.ncontrols,
7938c2ecf20Sopenharmony_ci				sizeof(*mpp_data), GFP_KERNEL);
7948c2ecf20Sopenharmony_ci	if (!mpp_data)
7958c2ecf20Sopenharmony_ci		return -ENOMEM;
7968c2ecf20Sopenharmony_ci
7978c2ecf20Sopenharmony_ci	dove_pinctrl_info.control_data = mpp_data;
7988c2ecf20Sopenharmony_ci	for (i = 0; i < ARRAY_SIZE(dove_mpp_controls); i++)
7998c2ecf20Sopenharmony_ci		mpp_data[i].base = base;
8008c2ecf20Sopenharmony_ci
8018c2ecf20Sopenharmony_ci	/* prepare fallback resource */
8028c2ecf20Sopenharmony_ci	memcpy(&fb_res, mpp_res, sizeof(struct resource));
8038c2ecf20Sopenharmony_ci	fb_res.start = 0;
8048c2ecf20Sopenharmony_ci
8058c2ecf20Sopenharmony_ci	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
8068c2ecf20Sopenharmony_ci	if (!res) {
8078c2ecf20Sopenharmony_ci		dev_warn(&pdev->dev, "falling back to hardcoded MPP4 resource\n");
8088c2ecf20Sopenharmony_ci		adjust_resource(&fb_res,
8098c2ecf20Sopenharmony_ci			(mpp_res->start & INT_REGS_MASK) + MPP4_REGS_OFFS, 0x4);
8108c2ecf20Sopenharmony_ci		res = &fb_res;
8118c2ecf20Sopenharmony_ci	}
8128c2ecf20Sopenharmony_ci
8138c2ecf20Sopenharmony_ci	mpp4_base = devm_ioremap_resource(&pdev->dev, res);
8148c2ecf20Sopenharmony_ci	if (IS_ERR(mpp4_base))
8158c2ecf20Sopenharmony_ci		return PTR_ERR(mpp4_base);
8168c2ecf20Sopenharmony_ci
8178c2ecf20Sopenharmony_ci	res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
8188c2ecf20Sopenharmony_ci	if (!res) {
8198c2ecf20Sopenharmony_ci		dev_warn(&pdev->dev, "falling back to hardcoded PMU resource\n");
8208c2ecf20Sopenharmony_ci		adjust_resource(&fb_res,
8218c2ecf20Sopenharmony_ci			(mpp_res->start & INT_REGS_MASK) + PMU_REGS_OFFS, 0x8);
8228c2ecf20Sopenharmony_ci		res = &fb_res;
8238c2ecf20Sopenharmony_ci	}
8248c2ecf20Sopenharmony_ci
8258c2ecf20Sopenharmony_ci	pmu_base = devm_ioremap_resource(&pdev->dev, res);
8268c2ecf20Sopenharmony_ci	if (IS_ERR(pmu_base))
8278c2ecf20Sopenharmony_ci		return PTR_ERR(pmu_base);
8288c2ecf20Sopenharmony_ci
8298c2ecf20Sopenharmony_ci	gconfmap = syscon_regmap_lookup_by_compatible("marvell,dove-global-config");
8308c2ecf20Sopenharmony_ci	if (IS_ERR(gconfmap)) {
8318c2ecf20Sopenharmony_ci		void __iomem *gc_base;
8328c2ecf20Sopenharmony_ci
8338c2ecf20Sopenharmony_ci		dev_warn(&pdev->dev, "falling back to hardcoded global registers\n");
8348c2ecf20Sopenharmony_ci		adjust_resource(&fb_res,
8358c2ecf20Sopenharmony_ci			(mpp_res->start & INT_REGS_MASK) + GC_REGS_OFFS, 0x14);
8368c2ecf20Sopenharmony_ci		gc_base = devm_ioremap_resource(&pdev->dev, &fb_res);
8378c2ecf20Sopenharmony_ci		if (IS_ERR(gc_base))
8388c2ecf20Sopenharmony_ci			return PTR_ERR(gc_base);
8398c2ecf20Sopenharmony_ci		gconfmap = devm_regmap_init_mmio(&pdev->dev,
8408c2ecf20Sopenharmony_ci						 gc_base, &gc_regmap_config);
8418c2ecf20Sopenharmony_ci		if (IS_ERR(gconfmap))
8428c2ecf20Sopenharmony_ci			return PTR_ERR(gconfmap);
8438c2ecf20Sopenharmony_ci	}
8448c2ecf20Sopenharmony_ci
8458c2ecf20Sopenharmony_ci	/* Warn on any missing DT resource */
8468c2ecf20Sopenharmony_ci	if (fb_res.start)
8478c2ecf20Sopenharmony_ci		dev_warn(&pdev->dev, FW_BUG "Missing pinctrl regs in DTB. Please update your firmware.\n");
8488c2ecf20Sopenharmony_ci
8498c2ecf20Sopenharmony_ci	return mvebu_pinctrl_probe(pdev);
8508c2ecf20Sopenharmony_ci}
8518c2ecf20Sopenharmony_ci
8528c2ecf20Sopenharmony_cistatic struct platform_driver dove_pinctrl_driver = {
8538c2ecf20Sopenharmony_ci	.driver = {
8548c2ecf20Sopenharmony_ci		.name = "dove-pinctrl",
8558c2ecf20Sopenharmony_ci		.suppress_bind_attrs = true,
8568c2ecf20Sopenharmony_ci		.of_match_table = dove_pinctrl_of_match,
8578c2ecf20Sopenharmony_ci	},
8588c2ecf20Sopenharmony_ci	.probe = dove_pinctrl_probe,
8598c2ecf20Sopenharmony_ci};
8608c2ecf20Sopenharmony_cibuiltin_platform_driver(dove_pinctrl_driver);
861