18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci// Copyright (c) 2016-2018 Nuvoton Technology corporation.
38c2ecf20Sopenharmony_ci// Copyright (c) 2016, Dell Inc
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#include <linux/device.h>
68c2ecf20Sopenharmony_ci#include <linux/gpio/driver.h>
78c2ecf20Sopenharmony_ci#include <linux/interrupt.h>
88c2ecf20Sopenharmony_ci#include <linux/irq.h>
98c2ecf20Sopenharmony_ci#include <linux/mfd/syscon.h>
108c2ecf20Sopenharmony_ci#include <linux/module.h>
118c2ecf20Sopenharmony_ci#include <linux/of.h>
128c2ecf20Sopenharmony_ci#include <linux/of_address.h>
138c2ecf20Sopenharmony_ci#include <linux/of_irq.h>
148c2ecf20Sopenharmony_ci#include <linux/pinctrl/machine.h>
158c2ecf20Sopenharmony_ci#include <linux/pinctrl/pinconf.h>
168c2ecf20Sopenharmony_ci#include <linux/pinctrl/pinconf-generic.h>
178c2ecf20Sopenharmony_ci#include <linux/pinctrl/pinctrl.h>
188c2ecf20Sopenharmony_ci#include <linux/pinctrl/pinmux.h>
198c2ecf20Sopenharmony_ci#include <linux/platform_device.h>
208c2ecf20Sopenharmony_ci#include <linux/regmap.h>
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci/* GCR registers */
238c2ecf20Sopenharmony_ci#define NPCM7XX_GCR_PDID	0x00
248c2ecf20Sopenharmony_ci#define NPCM7XX_GCR_MFSEL1	0x0C
258c2ecf20Sopenharmony_ci#define NPCM7XX_GCR_MFSEL2	0x10
268c2ecf20Sopenharmony_ci#define NPCM7XX_GCR_MFSEL3	0x64
278c2ecf20Sopenharmony_ci#define NPCM7XX_GCR_MFSEL4	0xb0
288c2ecf20Sopenharmony_ci#define NPCM7XX_GCR_CPCTL	0xD0
298c2ecf20Sopenharmony_ci#define NPCM7XX_GCR_CP2BST	0xD4
308c2ecf20Sopenharmony_ci#define NPCM7XX_GCR_B2CPNT	0xD8
318c2ecf20Sopenharmony_ci#define NPCM7XX_GCR_I2CSEGSEL	0xE0
328c2ecf20Sopenharmony_ci#define NPCM7XX_GCR_I2CSEGCTL	0xE4
338c2ecf20Sopenharmony_ci#define NPCM7XX_GCR_SRCNT	0x68
348c2ecf20Sopenharmony_ci#define NPCM7XX_GCR_FLOCKR1	0x74
358c2ecf20Sopenharmony_ci#define NPCM7XX_GCR_DSCNT	0x78
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci#define SRCNT_ESPI		BIT(3)
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci/* GPIO registers */
408c2ecf20Sopenharmony_ci#define NPCM7XX_GP_N_TLOCK1	0x00
418c2ecf20Sopenharmony_ci#define NPCM7XX_GP_N_DIN	0x04 /* Data IN */
428c2ecf20Sopenharmony_ci#define NPCM7XX_GP_N_POL	0x08 /* Polarity */
438c2ecf20Sopenharmony_ci#define NPCM7XX_GP_N_DOUT	0x0c /* Data OUT */
448c2ecf20Sopenharmony_ci#define NPCM7XX_GP_N_OE		0x10 /* Output Enable */
458c2ecf20Sopenharmony_ci#define NPCM7XX_GP_N_OTYP	0x14
468c2ecf20Sopenharmony_ci#define NPCM7XX_GP_N_MP		0x18
478c2ecf20Sopenharmony_ci#define NPCM7XX_GP_N_PU		0x1c /* Pull-up */
488c2ecf20Sopenharmony_ci#define NPCM7XX_GP_N_PD		0x20 /* Pull-down */
498c2ecf20Sopenharmony_ci#define NPCM7XX_GP_N_DBNC	0x24 /* Debounce */
508c2ecf20Sopenharmony_ci#define NPCM7XX_GP_N_EVTYP	0x28 /* Event Type */
518c2ecf20Sopenharmony_ci#define NPCM7XX_GP_N_EVBE	0x2c /* Event Both Edge */
528c2ecf20Sopenharmony_ci#define NPCM7XX_GP_N_OBL0	0x30
538c2ecf20Sopenharmony_ci#define NPCM7XX_GP_N_OBL1	0x34
548c2ecf20Sopenharmony_ci#define NPCM7XX_GP_N_OBL2	0x38
558c2ecf20Sopenharmony_ci#define NPCM7XX_GP_N_OBL3	0x3c
568c2ecf20Sopenharmony_ci#define NPCM7XX_GP_N_EVEN	0x40 /* Event Enable */
578c2ecf20Sopenharmony_ci#define NPCM7XX_GP_N_EVENS	0x44 /* Event Set (enable) */
588c2ecf20Sopenharmony_ci#define NPCM7XX_GP_N_EVENC	0x48 /* Event Clear (disable) */
598c2ecf20Sopenharmony_ci#define NPCM7XX_GP_N_EVST	0x4c /* Event Status */
608c2ecf20Sopenharmony_ci#define NPCM7XX_GP_N_SPLCK	0x50
618c2ecf20Sopenharmony_ci#define NPCM7XX_GP_N_MPLCK	0x54
628c2ecf20Sopenharmony_ci#define NPCM7XX_GP_N_IEM	0x58 /* Input Enable */
638c2ecf20Sopenharmony_ci#define NPCM7XX_GP_N_OSRC	0x5c
648c2ecf20Sopenharmony_ci#define NPCM7XX_GP_N_ODSC	0x60
658c2ecf20Sopenharmony_ci#define NPCM7XX_GP_N_DOS	0x68 /* Data OUT Set */
668c2ecf20Sopenharmony_ci#define NPCM7XX_GP_N_DOC	0x6c /* Data OUT Clear */
678c2ecf20Sopenharmony_ci#define NPCM7XX_GP_N_OES	0x70 /* Output Enable Set */
688c2ecf20Sopenharmony_ci#define NPCM7XX_GP_N_OEC	0x74 /* Output Enable Clear */
698c2ecf20Sopenharmony_ci#define NPCM7XX_GP_N_TLOCK2	0x7c
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci#define NPCM7XX_GPIO_PER_BANK	32
728c2ecf20Sopenharmony_ci#define NPCM7XX_GPIO_BANK_NUM	8
738c2ecf20Sopenharmony_ci#define NPCM7XX_GCR_NONE	0
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ci/* Structure for register banks */
768c2ecf20Sopenharmony_cistruct npcm7xx_gpio {
778c2ecf20Sopenharmony_ci	void __iomem		*base;
788c2ecf20Sopenharmony_ci	struct gpio_chip	gc;
798c2ecf20Sopenharmony_ci	int			irqbase;
808c2ecf20Sopenharmony_ci	int			irq;
818c2ecf20Sopenharmony_ci	struct irq_chip		irq_chip;
828c2ecf20Sopenharmony_ci	u32			pinctrl_id;
838c2ecf20Sopenharmony_ci	int (*direction_input)(struct gpio_chip *chip, unsigned offset);
848c2ecf20Sopenharmony_ci	int (*direction_output)(struct gpio_chip *chip, unsigned offset,
858c2ecf20Sopenharmony_ci				int value);
868c2ecf20Sopenharmony_ci	int (*request)(struct gpio_chip *chip, unsigned offset);
878c2ecf20Sopenharmony_ci	void (*free)(struct gpio_chip *chip, unsigned offset);
888c2ecf20Sopenharmony_ci};
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_cistruct npcm7xx_pinctrl {
918c2ecf20Sopenharmony_ci	struct pinctrl_dev	*pctldev;
928c2ecf20Sopenharmony_ci	struct device		*dev;
938c2ecf20Sopenharmony_ci	struct npcm7xx_gpio	gpio_bank[NPCM7XX_GPIO_BANK_NUM];
948c2ecf20Sopenharmony_ci	struct irq_domain	*domain;
958c2ecf20Sopenharmony_ci	struct regmap		*gcr_regmap;
968c2ecf20Sopenharmony_ci	void __iomem		*regs;
978c2ecf20Sopenharmony_ci	u32			bank_num;
988c2ecf20Sopenharmony_ci};
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ci/* GPIO handling in the pinctrl driver */
1018c2ecf20Sopenharmony_cistatic void npcm_gpio_set(struct gpio_chip *gc, void __iomem *reg,
1028c2ecf20Sopenharmony_ci			  unsigned int pinmask)
1038c2ecf20Sopenharmony_ci{
1048c2ecf20Sopenharmony_ci	unsigned long flags;
1058c2ecf20Sopenharmony_ci	unsigned long val;
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_ci	spin_lock_irqsave(&gc->bgpio_lock, flags);
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ci	val = ioread32(reg) | pinmask;
1108c2ecf20Sopenharmony_ci	iowrite32(val, reg);
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ci	spin_unlock_irqrestore(&gc->bgpio_lock, flags);
1138c2ecf20Sopenharmony_ci}
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_cistatic void npcm_gpio_clr(struct gpio_chip *gc, void __iomem *reg,
1168c2ecf20Sopenharmony_ci			  unsigned int pinmask)
1178c2ecf20Sopenharmony_ci{
1188c2ecf20Sopenharmony_ci	unsigned long flags;
1198c2ecf20Sopenharmony_ci	unsigned long val;
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci	spin_lock_irqsave(&gc->bgpio_lock, flags);
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_ci	val = ioread32(reg) & ~pinmask;
1248c2ecf20Sopenharmony_ci	iowrite32(val, reg);
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_ci	spin_unlock_irqrestore(&gc->bgpio_lock, flags);
1278c2ecf20Sopenharmony_ci}
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_cistatic void npcmgpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
1308c2ecf20Sopenharmony_ci{
1318c2ecf20Sopenharmony_ci	struct npcm7xx_gpio *bank = gpiochip_get_data(chip);
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_ci	seq_printf(s, "-- module %d [gpio%d - %d]\n",
1348c2ecf20Sopenharmony_ci		   bank->gc.base / bank->gc.ngpio,
1358c2ecf20Sopenharmony_ci		   bank->gc.base,
1368c2ecf20Sopenharmony_ci		   bank->gc.base + bank->gc.ngpio);
1378c2ecf20Sopenharmony_ci	seq_printf(s, "DIN :%.8x DOUT:%.8x IE  :%.8x OE	 :%.8x\n",
1388c2ecf20Sopenharmony_ci		   ioread32(bank->base + NPCM7XX_GP_N_DIN),
1398c2ecf20Sopenharmony_ci		   ioread32(bank->base + NPCM7XX_GP_N_DOUT),
1408c2ecf20Sopenharmony_ci		   ioread32(bank->base + NPCM7XX_GP_N_IEM),
1418c2ecf20Sopenharmony_ci		   ioread32(bank->base + NPCM7XX_GP_N_OE));
1428c2ecf20Sopenharmony_ci	seq_printf(s, "PU  :%.8x PD  :%.8x DB  :%.8x POL :%.8x\n",
1438c2ecf20Sopenharmony_ci		   ioread32(bank->base + NPCM7XX_GP_N_PU),
1448c2ecf20Sopenharmony_ci		   ioread32(bank->base + NPCM7XX_GP_N_PD),
1458c2ecf20Sopenharmony_ci		   ioread32(bank->base + NPCM7XX_GP_N_DBNC),
1468c2ecf20Sopenharmony_ci		   ioread32(bank->base + NPCM7XX_GP_N_POL));
1478c2ecf20Sopenharmony_ci	seq_printf(s, "ETYP:%.8x EVBE:%.8x EVEN:%.8x EVST:%.8x\n",
1488c2ecf20Sopenharmony_ci		   ioread32(bank->base + NPCM7XX_GP_N_EVTYP),
1498c2ecf20Sopenharmony_ci		   ioread32(bank->base + NPCM7XX_GP_N_EVBE),
1508c2ecf20Sopenharmony_ci		   ioread32(bank->base + NPCM7XX_GP_N_EVEN),
1518c2ecf20Sopenharmony_ci		   ioread32(bank->base + NPCM7XX_GP_N_EVST));
1528c2ecf20Sopenharmony_ci	seq_printf(s, "OTYP:%.8x OSRC:%.8x ODSC:%.8x\n",
1538c2ecf20Sopenharmony_ci		   ioread32(bank->base + NPCM7XX_GP_N_OTYP),
1548c2ecf20Sopenharmony_ci		   ioread32(bank->base + NPCM7XX_GP_N_OSRC),
1558c2ecf20Sopenharmony_ci		   ioread32(bank->base + NPCM7XX_GP_N_ODSC));
1568c2ecf20Sopenharmony_ci	seq_printf(s, "OBL0:%.8x OBL1:%.8x OBL2:%.8x OBL3:%.8x\n",
1578c2ecf20Sopenharmony_ci		   ioread32(bank->base + NPCM7XX_GP_N_OBL0),
1588c2ecf20Sopenharmony_ci		   ioread32(bank->base + NPCM7XX_GP_N_OBL1),
1598c2ecf20Sopenharmony_ci		   ioread32(bank->base + NPCM7XX_GP_N_OBL2),
1608c2ecf20Sopenharmony_ci		   ioread32(bank->base + NPCM7XX_GP_N_OBL3));
1618c2ecf20Sopenharmony_ci	seq_printf(s, "SLCK:%.8x MLCK:%.8x\n",
1628c2ecf20Sopenharmony_ci		   ioread32(bank->base + NPCM7XX_GP_N_SPLCK),
1638c2ecf20Sopenharmony_ci		   ioread32(bank->base + NPCM7XX_GP_N_MPLCK));
1648c2ecf20Sopenharmony_ci}
1658c2ecf20Sopenharmony_ci
1668c2ecf20Sopenharmony_cistatic int npcmgpio_direction_input(struct gpio_chip *chip, unsigned int offset)
1678c2ecf20Sopenharmony_ci{
1688c2ecf20Sopenharmony_ci	struct npcm7xx_gpio *bank = gpiochip_get_data(chip);
1698c2ecf20Sopenharmony_ci	int ret;
1708c2ecf20Sopenharmony_ci
1718c2ecf20Sopenharmony_ci	ret = pinctrl_gpio_direction_input(offset + chip->base);
1728c2ecf20Sopenharmony_ci	if (ret)
1738c2ecf20Sopenharmony_ci		return ret;
1748c2ecf20Sopenharmony_ci
1758c2ecf20Sopenharmony_ci	return bank->direction_input(chip, offset);
1768c2ecf20Sopenharmony_ci}
1778c2ecf20Sopenharmony_ci
1788c2ecf20Sopenharmony_ci/* Set GPIO to Output with initial value */
1798c2ecf20Sopenharmony_cistatic int npcmgpio_direction_output(struct gpio_chip *chip,
1808c2ecf20Sopenharmony_ci				     unsigned int offset, int value)
1818c2ecf20Sopenharmony_ci{
1828c2ecf20Sopenharmony_ci	struct npcm7xx_gpio *bank = gpiochip_get_data(chip);
1838c2ecf20Sopenharmony_ci	int ret;
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_ci	dev_dbg(chip->parent, "gpio_direction_output: offset%d = %x\n", offset,
1868c2ecf20Sopenharmony_ci		value);
1878c2ecf20Sopenharmony_ci
1888c2ecf20Sopenharmony_ci	ret = pinctrl_gpio_direction_output(offset + chip->base);
1898c2ecf20Sopenharmony_ci	if (ret)
1908c2ecf20Sopenharmony_ci		return ret;
1918c2ecf20Sopenharmony_ci
1928c2ecf20Sopenharmony_ci	return bank->direction_output(chip, offset, value);
1938c2ecf20Sopenharmony_ci}
1948c2ecf20Sopenharmony_ci
1958c2ecf20Sopenharmony_cistatic int npcmgpio_gpio_request(struct gpio_chip *chip, unsigned int offset)
1968c2ecf20Sopenharmony_ci{
1978c2ecf20Sopenharmony_ci	struct npcm7xx_gpio *bank = gpiochip_get_data(chip);
1988c2ecf20Sopenharmony_ci	int ret;
1998c2ecf20Sopenharmony_ci
2008c2ecf20Sopenharmony_ci	dev_dbg(chip->parent, "gpio_request: offset%d\n", offset);
2018c2ecf20Sopenharmony_ci	ret = pinctrl_gpio_request(offset + chip->base);
2028c2ecf20Sopenharmony_ci	if (ret)
2038c2ecf20Sopenharmony_ci		return ret;
2048c2ecf20Sopenharmony_ci
2058c2ecf20Sopenharmony_ci	return bank->request(chip, offset);
2068c2ecf20Sopenharmony_ci}
2078c2ecf20Sopenharmony_ci
2088c2ecf20Sopenharmony_cistatic void npcmgpio_gpio_free(struct gpio_chip *chip, unsigned int offset)
2098c2ecf20Sopenharmony_ci{
2108c2ecf20Sopenharmony_ci	dev_dbg(chip->parent, "gpio_free: offset%d\n", offset);
2118c2ecf20Sopenharmony_ci	pinctrl_gpio_free(offset + chip->base);
2128c2ecf20Sopenharmony_ci}
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_cistatic void npcmgpio_irq_handler(struct irq_desc *desc)
2158c2ecf20Sopenharmony_ci{
2168c2ecf20Sopenharmony_ci	struct gpio_chip *gc;
2178c2ecf20Sopenharmony_ci	struct irq_chip *chip;
2188c2ecf20Sopenharmony_ci	struct npcm7xx_gpio *bank;
2198c2ecf20Sopenharmony_ci	u32 sts, en, bit;
2208c2ecf20Sopenharmony_ci
2218c2ecf20Sopenharmony_ci	gc = irq_desc_get_handler_data(desc);
2228c2ecf20Sopenharmony_ci	bank = gpiochip_get_data(gc);
2238c2ecf20Sopenharmony_ci	chip = irq_desc_get_chip(desc);
2248c2ecf20Sopenharmony_ci
2258c2ecf20Sopenharmony_ci	chained_irq_enter(chip, desc);
2268c2ecf20Sopenharmony_ci	sts = ioread32(bank->base + NPCM7XX_GP_N_EVST);
2278c2ecf20Sopenharmony_ci	en  = ioread32(bank->base + NPCM7XX_GP_N_EVEN);
2288c2ecf20Sopenharmony_ci	dev_dbg(bank->gc.parent, "==> got irq sts %.8x %.8x\n", sts,
2298c2ecf20Sopenharmony_ci		en);
2308c2ecf20Sopenharmony_ci
2318c2ecf20Sopenharmony_ci	sts &= en;
2328c2ecf20Sopenharmony_ci	for_each_set_bit(bit, (const void *)&sts, NPCM7XX_GPIO_PER_BANK)
2338c2ecf20Sopenharmony_ci		generic_handle_irq(irq_linear_revmap(gc->irq.domain, bit));
2348c2ecf20Sopenharmony_ci	chained_irq_exit(chip, desc);
2358c2ecf20Sopenharmony_ci}
2368c2ecf20Sopenharmony_ci
2378c2ecf20Sopenharmony_cistatic int npcmgpio_set_irq_type(struct irq_data *d, unsigned int type)
2388c2ecf20Sopenharmony_ci{
2398c2ecf20Sopenharmony_ci	struct npcm7xx_gpio *bank =
2408c2ecf20Sopenharmony_ci		gpiochip_get_data(irq_data_get_irq_chip_data(d));
2418c2ecf20Sopenharmony_ci	unsigned int gpio = BIT(d->hwirq);
2428c2ecf20Sopenharmony_ci
2438c2ecf20Sopenharmony_ci	dev_dbg(bank->gc.parent, "setirqtype: %u.%u = %u\n", gpio,
2448c2ecf20Sopenharmony_ci		d->irq, type);
2458c2ecf20Sopenharmony_ci	switch (type) {
2468c2ecf20Sopenharmony_ci	case IRQ_TYPE_EDGE_RISING:
2478c2ecf20Sopenharmony_ci		dev_dbg(bank->gc.parent, "edge.rising\n");
2488c2ecf20Sopenharmony_ci		npcm_gpio_clr(&bank->gc, bank->base + NPCM7XX_GP_N_EVBE, gpio);
2498c2ecf20Sopenharmony_ci		npcm_gpio_clr(&bank->gc, bank->base + NPCM7XX_GP_N_POL, gpio);
2508c2ecf20Sopenharmony_ci		break;
2518c2ecf20Sopenharmony_ci	case IRQ_TYPE_EDGE_FALLING:
2528c2ecf20Sopenharmony_ci		dev_dbg(bank->gc.parent, "edge.falling\n");
2538c2ecf20Sopenharmony_ci		npcm_gpio_clr(&bank->gc, bank->base + NPCM7XX_GP_N_EVBE, gpio);
2548c2ecf20Sopenharmony_ci		npcm_gpio_set(&bank->gc, bank->base + NPCM7XX_GP_N_POL, gpio);
2558c2ecf20Sopenharmony_ci		break;
2568c2ecf20Sopenharmony_ci	case IRQ_TYPE_EDGE_BOTH:
2578c2ecf20Sopenharmony_ci		dev_dbg(bank->gc.parent, "edge.both\n");
2588c2ecf20Sopenharmony_ci		npcm_gpio_set(&bank->gc, bank->base + NPCM7XX_GP_N_EVBE, gpio);
2598c2ecf20Sopenharmony_ci		break;
2608c2ecf20Sopenharmony_ci	case IRQ_TYPE_LEVEL_LOW:
2618c2ecf20Sopenharmony_ci		dev_dbg(bank->gc.parent, "level.low\n");
2628c2ecf20Sopenharmony_ci		npcm_gpio_set(&bank->gc, bank->base + NPCM7XX_GP_N_POL, gpio);
2638c2ecf20Sopenharmony_ci		break;
2648c2ecf20Sopenharmony_ci	case IRQ_TYPE_LEVEL_HIGH:
2658c2ecf20Sopenharmony_ci		dev_dbg(bank->gc.parent, "level.high\n");
2668c2ecf20Sopenharmony_ci		npcm_gpio_clr(&bank->gc, bank->base + NPCM7XX_GP_N_POL, gpio);
2678c2ecf20Sopenharmony_ci		break;
2688c2ecf20Sopenharmony_ci	default:
2698c2ecf20Sopenharmony_ci		dev_dbg(bank->gc.parent, "invalid irq type\n");
2708c2ecf20Sopenharmony_ci		return -EINVAL;
2718c2ecf20Sopenharmony_ci	}
2728c2ecf20Sopenharmony_ci
2738c2ecf20Sopenharmony_ci	if (type & (IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW)) {
2748c2ecf20Sopenharmony_ci		npcm_gpio_clr(&bank->gc, bank->base + NPCM7XX_GP_N_EVTYP, gpio);
2758c2ecf20Sopenharmony_ci		irq_set_handler_locked(d, handle_level_irq);
2768c2ecf20Sopenharmony_ci	} else if (type & (IRQ_TYPE_EDGE_BOTH | IRQ_TYPE_EDGE_RISING
2778c2ecf20Sopenharmony_ci			   | IRQ_TYPE_EDGE_FALLING)) {
2788c2ecf20Sopenharmony_ci		npcm_gpio_set(&bank->gc, bank->base + NPCM7XX_GP_N_EVTYP, gpio);
2798c2ecf20Sopenharmony_ci		irq_set_handler_locked(d, handle_edge_irq);
2808c2ecf20Sopenharmony_ci	}
2818c2ecf20Sopenharmony_ci
2828c2ecf20Sopenharmony_ci	return 0;
2838c2ecf20Sopenharmony_ci}
2848c2ecf20Sopenharmony_ci
2858c2ecf20Sopenharmony_cistatic void npcmgpio_irq_ack(struct irq_data *d)
2868c2ecf20Sopenharmony_ci{
2878c2ecf20Sopenharmony_ci	struct npcm7xx_gpio *bank =
2888c2ecf20Sopenharmony_ci		gpiochip_get_data(irq_data_get_irq_chip_data(d));
2898c2ecf20Sopenharmony_ci	unsigned int gpio = d->hwirq;
2908c2ecf20Sopenharmony_ci
2918c2ecf20Sopenharmony_ci	dev_dbg(bank->gc.parent, "irq_ack: %u.%u\n", gpio, d->irq);
2928c2ecf20Sopenharmony_ci	iowrite32(BIT(gpio), bank->base + NPCM7XX_GP_N_EVST);
2938c2ecf20Sopenharmony_ci}
2948c2ecf20Sopenharmony_ci
2958c2ecf20Sopenharmony_ci/* Disable GPIO interrupt */
2968c2ecf20Sopenharmony_cistatic void npcmgpio_irq_mask(struct irq_data *d)
2978c2ecf20Sopenharmony_ci{
2988c2ecf20Sopenharmony_ci	struct npcm7xx_gpio *bank =
2998c2ecf20Sopenharmony_ci		gpiochip_get_data(irq_data_get_irq_chip_data(d));
3008c2ecf20Sopenharmony_ci	unsigned int gpio = d->hwirq;
3018c2ecf20Sopenharmony_ci
3028c2ecf20Sopenharmony_ci	/* Clear events */
3038c2ecf20Sopenharmony_ci	dev_dbg(bank->gc.parent, "irq_mask: %u.%u\n", gpio, d->irq);
3048c2ecf20Sopenharmony_ci	iowrite32(BIT(gpio), bank->base + NPCM7XX_GP_N_EVENC);
3058c2ecf20Sopenharmony_ci}
3068c2ecf20Sopenharmony_ci
3078c2ecf20Sopenharmony_ci/* Enable GPIO interrupt */
3088c2ecf20Sopenharmony_cistatic void npcmgpio_irq_unmask(struct irq_data *d)
3098c2ecf20Sopenharmony_ci{
3108c2ecf20Sopenharmony_ci	struct npcm7xx_gpio *bank =
3118c2ecf20Sopenharmony_ci		gpiochip_get_data(irq_data_get_irq_chip_data(d));
3128c2ecf20Sopenharmony_ci	unsigned int gpio = d->hwirq;
3138c2ecf20Sopenharmony_ci
3148c2ecf20Sopenharmony_ci	/* Enable events */
3158c2ecf20Sopenharmony_ci	dev_dbg(bank->gc.parent, "irq_unmask: %u.%u\n", gpio, d->irq);
3168c2ecf20Sopenharmony_ci	iowrite32(BIT(gpio), bank->base + NPCM7XX_GP_N_EVENS);
3178c2ecf20Sopenharmony_ci}
3188c2ecf20Sopenharmony_ci
3198c2ecf20Sopenharmony_cistatic unsigned int npcmgpio_irq_startup(struct irq_data *d)
3208c2ecf20Sopenharmony_ci{
3218c2ecf20Sopenharmony_ci	struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
3228c2ecf20Sopenharmony_ci	unsigned int gpio = d->hwirq;
3238c2ecf20Sopenharmony_ci
3248c2ecf20Sopenharmony_ci	/* active-high, input, clear interrupt, enable interrupt */
3258c2ecf20Sopenharmony_ci	dev_dbg(gc->parent, "startup: %u.%u\n", gpio, d->irq);
3268c2ecf20Sopenharmony_ci	npcmgpio_direction_input(gc, gpio);
3278c2ecf20Sopenharmony_ci	npcmgpio_irq_ack(d);
3288c2ecf20Sopenharmony_ci	npcmgpio_irq_unmask(d);
3298c2ecf20Sopenharmony_ci
3308c2ecf20Sopenharmony_ci	return 0;
3318c2ecf20Sopenharmony_ci}
3328c2ecf20Sopenharmony_ci
3338c2ecf20Sopenharmony_cistatic const struct irq_chip npcmgpio_irqchip = {
3348c2ecf20Sopenharmony_ci	.name = "NPCM7XX-GPIO-IRQ",
3358c2ecf20Sopenharmony_ci	.irq_ack = npcmgpio_irq_ack,
3368c2ecf20Sopenharmony_ci	.irq_unmask = npcmgpio_irq_unmask,
3378c2ecf20Sopenharmony_ci	.irq_mask = npcmgpio_irq_mask,
3388c2ecf20Sopenharmony_ci	.irq_set_type = npcmgpio_set_irq_type,
3398c2ecf20Sopenharmony_ci	.irq_startup = npcmgpio_irq_startup,
3408c2ecf20Sopenharmony_ci};
3418c2ecf20Sopenharmony_ci
3428c2ecf20Sopenharmony_ci/* pinmux handing in the pinctrl driver*/
3438c2ecf20Sopenharmony_cistatic const int smb0_pins[]  = { 115, 114 };
3448c2ecf20Sopenharmony_cistatic const int smb0b_pins[] = { 195, 194 };
3458c2ecf20Sopenharmony_cistatic const int smb0c_pins[] = { 202, 196 };
3468c2ecf20Sopenharmony_cistatic const int smb0d_pins[] = { 198, 199 };
3478c2ecf20Sopenharmony_cistatic const int smb0den_pins[] = { 197 };
3488c2ecf20Sopenharmony_ci
3498c2ecf20Sopenharmony_cistatic const int smb1_pins[]  = { 117, 116 };
3508c2ecf20Sopenharmony_cistatic const int smb1b_pins[] = { 126, 127 };
3518c2ecf20Sopenharmony_cistatic const int smb1c_pins[] = { 124, 125 };
3528c2ecf20Sopenharmony_cistatic const int smb1d_pins[] = { 4, 5 };
3538c2ecf20Sopenharmony_ci
3548c2ecf20Sopenharmony_cistatic const int smb2_pins[]  = { 119, 118 };
3558c2ecf20Sopenharmony_cistatic const int smb2b_pins[] = { 122, 123 };
3568c2ecf20Sopenharmony_cistatic const int smb2c_pins[] = { 120, 121 };
3578c2ecf20Sopenharmony_cistatic const int smb2d_pins[] = { 6, 7 };
3588c2ecf20Sopenharmony_ci
3598c2ecf20Sopenharmony_cistatic const int smb3_pins[]  = { 30, 31 };
3608c2ecf20Sopenharmony_cistatic const int smb3b_pins[] = { 39, 40 };
3618c2ecf20Sopenharmony_cistatic const int smb3c_pins[] = { 37, 38 };
3628c2ecf20Sopenharmony_cistatic const int smb3d_pins[] = { 59, 60 };
3638c2ecf20Sopenharmony_ci
3648c2ecf20Sopenharmony_cistatic const int smb4_pins[]  = { 28, 29 };
3658c2ecf20Sopenharmony_cistatic const int smb4b_pins[] = { 18, 19 };
3668c2ecf20Sopenharmony_cistatic const int smb4c_pins[] = { 20, 21 };
3678c2ecf20Sopenharmony_cistatic const int smb4d_pins[] = { 22, 23 };
3688c2ecf20Sopenharmony_cistatic const int smb4den_pins[] = { 17 };
3698c2ecf20Sopenharmony_ci
3708c2ecf20Sopenharmony_cistatic const int smb5_pins[]  = { 26, 27 };
3718c2ecf20Sopenharmony_cistatic const int smb5b_pins[] = { 13, 12 };
3728c2ecf20Sopenharmony_cistatic const int smb5c_pins[] = { 15, 14 };
3738c2ecf20Sopenharmony_cistatic const int smb5d_pins[] = { 94, 93 };
3748c2ecf20Sopenharmony_cistatic const int ga20kbc_pins[] = { 94, 93 };
3758c2ecf20Sopenharmony_ci
3768c2ecf20Sopenharmony_cistatic const int smb6_pins[]  = { 172, 171 };
3778c2ecf20Sopenharmony_cistatic const int smb7_pins[]  = { 174, 173 };
3788c2ecf20Sopenharmony_cistatic const int smb8_pins[]  = { 129, 128 };
3798c2ecf20Sopenharmony_cistatic const int smb9_pins[]  = { 131, 130 };
3808c2ecf20Sopenharmony_cistatic const int smb10_pins[] = { 133, 132 };
3818c2ecf20Sopenharmony_cistatic const int smb11_pins[] = { 135, 134 };
3828c2ecf20Sopenharmony_cistatic const int smb12_pins[] = { 221, 220 };
3838c2ecf20Sopenharmony_cistatic const int smb13_pins[] = { 223, 222 };
3848c2ecf20Sopenharmony_cistatic const int smb14_pins[] = { 22, 23 };
3858c2ecf20Sopenharmony_cistatic const int smb15_pins[] = { 20, 21 };
3868c2ecf20Sopenharmony_ci
3878c2ecf20Sopenharmony_cistatic const int fanin0_pins[] = { 64 };
3888c2ecf20Sopenharmony_cistatic const int fanin1_pins[] = { 65 };
3898c2ecf20Sopenharmony_cistatic const int fanin2_pins[] = { 66 };
3908c2ecf20Sopenharmony_cistatic const int fanin3_pins[] = { 67 };
3918c2ecf20Sopenharmony_cistatic const int fanin4_pins[] = { 68 };
3928c2ecf20Sopenharmony_cistatic const int fanin5_pins[] = { 69 };
3938c2ecf20Sopenharmony_cistatic const int fanin6_pins[] = { 70 };
3948c2ecf20Sopenharmony_cistatic const int fanin7_pins[] = { 71 };
3958c2ecf20Sopenharmony_cistatic const int fanin8_pins[] = { 72 };
3968c2ecf20Sopenharmony_cistatic const int fanin9_pins[] = { 73 };
3978c2ecf20Sopenharmony_cistatic const int fanin10_pins[] = { 74 };
3988c2ecf20Sopenharmony_cistatic const int fanin11_pins[] = { 75 };
3998c2ecf20Sopenharmony_cistatic const int fanin12_pins[] = { 76 };
4008c2ecf20Sopenharmony_cistatic const int fanin13_pins[] = { 77 };
4018c2ecf20Sopenharmony_cistatic const int fanin14_pins[] = { 78 };
4028c2ecf20Sopenharmony_cistatic const int fanin15_pins[] = { 79 };
4038c2ecf20Sopenharmony_cistatic const int faninx_pins[] = { 175, 176, 177, 203 };
4048c2ecf20Sopenharmony_ci
4058c2ecf20Sopenharmony_cistatic const int pwm0_pins[] = { 80 };
4068c2ecf20Sopenharmony_cistatic const int pwm1_pins[] = { 81 };
4078c2ecf20Sopenharmony_cistatic const int pwm2_pins[] = { 82 };
4088c2ecf20Sopenharmony_cistatic const int pwm3_pins[] = { 83 };
4098c2ecf20Sopenharmony_cistatic const int pwm4_pins[] = { 144 };
4108c2ecf20Sopenharmony_cistatic const int pwm5_pins[] = { 145 };
4118c2ecf20Sopenharmony_cistatic const int pwm6_pins[] = { 146 };
4128c2ecf20Sopenharmony_cistatic const int pwm7_pins[] = { 147 };
4138c2ecf20Sopenharmony_ci
4148c2ecf20Sopenharmony_cistatic const int uart1_pins[] = { 43, 44, 45, 46, 47, 61, 62, 63 };
4158c2ecf20Sopenharmony_cistatic const int uart2_pins[] = { 48, 49, 50, 51, 52, 53, 54, 55 };
4168c2ecf20Sopenharmony_ci
4178c2ecf20Sopenharmony_ci/* RGMII 1 pin group */
4188c2ecf20Sopenharmony_cistatic const int rg1_pins[] = { 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
4198c2ecf20Sopenharmony_ci	106, 107 };
4208c2ecf20Sopenharmony_ci/* RGMII 1 MD interface pin group */
4218c2ecf20Sopenharmony_cistatic const int rg1mdio_pins[] = { 108, 109 };
4228c2ecf20Sopenharmony_ci
4238c2ecf20Sopenharmony_ci/* RGMII 2 pin group */
4248c2ecf20Sopenharmony_cistatic const int rg2_pins[] = { 110, 111, 112, 113, 208, 209, 210, 211, 212,
4258c2ecf20Sopenharmony_ci	213, 214, 215 };
4268c2ecf20Sopenharmony_ci/* RGMII 2 MD interface pin group */
4278c2ecf20Sopenharmony_cistatic const int rg2mdio_pins[] = { 216, 217 };
4288c2ecf20Sopenharmony_ci
4298c2ecf20Sopenharmony_cistatic const int ddr_pins[] = { 110, 111, 112, 113, 208, 209, 210, 211, 212,
4308c2ecf20Sopenharmony_ci	213, 214, 215, 216, 217 };
4318c2ecf20Sopenharmony_ci/* Serial I/O Expander 1 */
4328c2ecf20Sopenharmony_cistatic const int iox1_pins[] = { 0, 1, 2, 3 };
4338c2ecf20Sopenharmony_ci/* Serial I/O Expander 2 */
4348c2ecf20Sopenharmony_cistatic const int iox2_pins[] = { 4, 5, 6, 7 };
4358c2ecf20Sopenharmony_ci/* Host Serial I/O Expander 2 */
4368c2ecf20Sopenharmony_cistatic const int ioxh_pins[] = { 10, 11, 24, 25 };
4378c2ecf20Sopenharmony_ci
4388c2ecf20Sopenharmony_cistatic const int mmc_pins[] = { 152, 154, 156, 157, 158, 159 };
4398c2ecf20Sopenharmony_cistatic const int mmcwp_pins[] = { 153 };
4408c2ecf20Sopenharmony_cistatic const int mmccd_pins[] = { 155 };
4418c2ecf20Sopenharmony_cistatic const int mmcrst_pins[] = { 155 };
4428c2ecf20Sopenharmony_cistatic const int mmc8_pins[] = { 148, 149, 150, 151 };
4438c2ecf20Sopenharmony_ci
4448c2ecf20Sopenharmony_ci/* RMII 1 pin groups */
4458c2ecf20Sopenharmony_cistatic const int r1_pins[] = { 178, 179, 180, 181, 182, 193, 201 };
4468c2ecf20Sopenharmony_cistatic const int r1err_pins[] = { 56 };
4478c2ecf20Sopenharmony_cistatic const int r1md_pins[] = { 57, 58 };
4488c2ecf20Sopenharmony_ci
4498c2ecf20Sopenharmony_ci/* RMII 2 pin groups */
4508c2ecf20Sopenharmony_cistatic const int r2_pins[] = { 84, 85, 86, 87, 88, 89, 200 };
4518c2ecf20Sopenharmony_cistatic const int r2err_pins[] = { 90 };
4528c2ecf20Sopenharmony_cistatic const int r2md_pins[] = { 91, 92 };
4538c2ecf20Sopenharmony_ci
4548c2ecf20Sopenharmony_cistatic const int sd1_pins[] = { 136, 137, 138, 139, 140, 141, 142, 143 };
4558c2ecf20Sopenharmony_cistatic const int sd1pwr_pins[] = { 143 };
4568c2ecf20Sopenharmony_ci
4578c2ecf20Sopenharmony_cistatic const int wdog1_pins[] = { 218 };
4588c2ecf20Sopenharmony_cistatic const int wdog2_pins[] = { 219 };
4598c2ecf20Sopenharmony_ci
4608c2ecf20Sopenharmony_ci/* BMC serial port 0 */
4618c2ecf20Sopenharmony_cistatic const int bmcuart0a_pins[] = { 41, 42 };
4628c2ecf20Sopenharmony_cistatic const int bmcuart0b_pins[] = { 48, 49 };
4638c2ecf20Sopenharmony_ci
4648c2ecf20Sopenharmony_cistatic const int bmcuart1_pins[] = { 43, 44, 62, 63 };
4658c2ecf20Sopenharmony_ci
4668c2ecf20Sopenharmony_ci/* System Control Interrupt and Power Management Event pin group */
4678c2ecf20Sopenharmony_cistatic const int scipme_pins[] = { 169 };
4688c2ecf20Sopenharmony_ci/* System Management Interrupt pin group */
4698c2ecf20Sopenharmony_cistatic const int sci_pins[] = { 170 };
4708c2ecf20Sopenharmony_ci/* Serial Interrupt Line pin group */
4718c2ecf20Sopenharmony_cistatic const int serirq_pins[] = { 162 };
4728c2ecf20Sopenharmony_ci
4738c2ecf20Sopenharmony_cistatic const int clkout_pins[] = { 160 };
4748c2ecf20Sopenharmony_cistatic const int clkreq_pins[] = { 231 };
4758c2ecf20Sopenharmony_ci
4768c2ecf20Sopenharmony_cistatic const int jtag2_pins[] = { 43, 44, 45, 46, 47 };
4778c2ecf20Sopenharmony_ci/* Graphics SPI Clock pin group */
4788c2ecf20Sopenharmony_cistatic const int gspi_pins[] = { 12, 13, 14, 15 };
4798c2ecf20Sopenharmony_ci
4808c2ecf20Sopenharmony_cistatic const int spix_pins[] = { 224, 225, 226, 227, 229, 230 };
4818c2ecf20Sopenharmony_cistatic const int spixcs1_pins[] = { 228 };
4828c2ecf20Sopenharmony_ci
4838c2ecf20Sopenharmony_cistatic const int pspi1_pins[] = { 175, 176, 177 };
4848c2ecf20Sopenharmony_cistatic const int pspi2_pins[] = { 17, 18, 19 };
4858c2ecf20Sopenharmony_ci
4868c2ecf20Sopenharmony_cistatic const int spi0cs1_pins[] = { 32 };
4878c2ecf20Sopenharmony_ci
4888c2ecf20Sopenharmony_cistatic const int spi3_pins[] = { 183, 184, 185, 186 };
4898c2ecf20Sopenharmony_cistatic const int spi3cs1_pins[] = { 187 };
4908c2ecf20Sopenharmony_cistatic const int spi3quad_pins[] = { 188, 189 };
4918c2ecf20Sopenharmony_cistatic const int spi3cs2_pins[] = { 188 };
4928c2ecf20Sopenharmony_cistatic const int spi3cs3_pins[] = { 189 };
4938c2ecf20Sopenharmony_ci
4948c2ecf20Sopenharmony_cistatic const int ddc_pins[] = { 204, 205, 206, 207 };
4958c2ecf20Sopenharmony_ci
4968c2ecf20Sopenharmony_cistatic const int lpc_pins[] = { 95, 161, 163, 164, 165, 166, 167 };
4978c2ecf20Sopenharmony_cistatic const int lpcclk_pins[] = { 168 };
4988c2ecf20Sopenharmony_cistatic const int espi_pins[] = { 95, 161, 163, 164, 165, 166, 167, 168 };
4998c2ecf20Sopenharmony_ci
5008c2ecf20Sopenharmony_cistatic const int lkgpo0_pins[] = { 16 };
5018c2ecf20Sopenharmony_cistatic const int lkgpo1_pins[] = { 8 };
5028c2ecf20Sopenharmony_cistatic const int lkgpo2_pins[] = { 9 };
5038c2ecf20Sopenharmony_ci
5048c2ecf20Sopenharmony_cistatic const int nprd_smi_pins[] = { 190 };
5058c2ecf20Sopenharmony_ci
5068c2ecf20Sopenharmony_ci/*
5078c2ecf20Sopenharmony_ci * pin:	     name, number
5088c2ecf20Sopenharmony_ci * group:    name, npins,   pins
5098c2ecf20Sopenharmony_ci * function: name, ngroups, groups
5108c2ecf20Sopenharmony_ci */
5118c2ecf20Sopenharmony_cistruct npcm7xx_group {
5128c2ecf20Sopenharmony_ci	const char *name;
5138c2ecf20Sopenharmony_ci	const unsigned int *pins;
5148c2ecf20Sopenharmony_ci	int npins;
5158c2ecf20Sopenharmony_ci};
5168c2ecf20Sopenharmony_ci
5178c2ecf20Sopenharmony_ci#define NPCM7XX_GRPS \
5188c2ecf20Sopenharmony_ci	NPCM7XX_GRP(smb0), \
5198c2ecf20Sopenharmony_ci	NPCM7XX_GRP(smb0b), \
5208c2ecf20Sopenharmony_ci	NPCM7XX_GRP(smb0c), \
5218c2ecf20Sopenharmony_ci	NPCM7XX_GRP(smb0d), \
5228c2ecf20Sopenharmony_ci	NPCM7XX_GRP(smb0den), \
5238c2ecf20Sopenharmony_ci	NPCM7XX_GRP(smb1), \
5248c2ecf20Sopenharmony_ci	NPCM7XX_GRP(smb1b), \
5258c2ecf20Sopenharmony_ci	NPCM7XX_GRP(smb1c), \
5268c2ecf20Sopenharmony_ci	NPCM7XX_GRP(smb1d), \
5278c2ecf20Sopenharmony_ci	NPCM7XX_GRP(smb2), \
5288c2ecf20Sopenharmony_ci	NPCM7XX_GRP(smb2b), \
5298c2ecf20Sopenharmony_ci	NPCM7XX_GRP(smb2c), \
5308c2ecf20Sopenharmony_ci	NPCM7XX_GRP(smb2d), \
5318c2ecf20Sopenharmony_ci	NPCM7XX_GRP(smb3), \
5328c2ecf20Sopenharmony_ci	NPCM7XX_GRP(smb3b), \
5338c2ecf20Sopenharmony_ci	NPCM7XX_GRP(smb3c), \
5348c2ecf20Sopenharmony_ci	NPCM7XX_GRP(smb3d), \
5358c2ecf20Sopenharmony_ci	NPCM7XX_GRP(smb4), \
5368c2ecf20Sopenharmony_ci	NPCM7XX_GRP(smb4b), \
5378c2ecf20Sopenharmony_ci	NPCM7XX_GRP(smb4c), \
5388c2ecf20Sopenharmony_ci	NPCM7XX_GRP(smb4d), \
5398c2ecf20Sopenharmony_ci	NPCM7XX_GRP(smb4den), \
5408c2ecf20Sopenharmony_ci	NPCM7XX_GRP(smb5), \
5418c2ecf20Sopenharmony_ci	NPCM7XX_GRP(smb5b), \
5428c2ecf20Sopenharmony_ci	NPCM7XX_GRP(smb5c), \
5438c2ecf20Sopenharmony_ci	NPCM7XX_GRP(smb5d), \
5448c2ecf20Sopenharmony_ci	NPCM7XX_GRP(ga20kbc), \
5458c2ecf20Sopenharmony_ci	NPCM7XX_GRP(smb6), \
5468c2ecf20Sopenharmony_ci	NPCM7XX_GRP(smb7), \
5478c2ecf20Sopenharmony_ci	NPCM7XX_GRP(smb8), \
5488c2ecf20Sopenharmony_ci	NPCM7XX_GRP(smb9), \
5498c2ecf20Sopenharmony_ci	NPCM7XX_GRP(smb10), \
5508c2ecf20Sopenharmony_ci	NPCM7XX_GRP(smb11), \
5518c2ecf20Sopenharmony_ci	NPCM7XX_GRP(smb12), \
5528c2ecf20Sopenharmony_ci	NPCM7XX_GRP(smb13), \
5538c2ecf20Sopenharmony_ci	NPCM7XX_GRP(smb14), \
5548c2ecf20Sopenharmony_ci	NPCM7XX_GRP(smb15), \
5558c2ecf20Sopenharmony_ci	NPCM7XX_GRP(fanin0), \
5568c2ecf20Sopenharmony_ci	NPCM7XX_GRP(fanin1), \
5578c2ecf20Sopenharmony_ci	NPCM7XX_GRP(fanin2), \
5588c2ecf20Sopenharmony_ci	NPCM7XX_GRP(fanin3), \
5598c2ecf20Sopenharmony_ci	NPCM7XX_GRP(fanin4), \
5608c2ecf20Sopenharmony_ci	NPCM7XX_GRP(fanin5), \
5618c2ecf20Sopenharmony_ci	NPCM7XX_GRP(fanin6), \
5628c2ecf20Sopenharmony_ci	NPCM7XX_GRP(fanin7), \
5638c2ecf20Sopenharmony_ci	NPCM7XX_GRP(fanin8), \
5648c2ecf20Sopenharmony_ci	NPCM7XX_GRP(fanin9), \
5658c2ecf20Sopenharmony_ci	NPCM7XX_GRP(fanin10), \
5668c2ecf20Sopenharmony_ci	NPCM7XX_GRP(fanin11), \
5678c2ecf20Sopenharmony_ci	NPCM7XX_GRP(fanin12), \
5688c2ecf20Sopenharmony_ci	NPCM7XX_GRP(fanin13), \
5698c2ecf20Sopenharmony_ci	NPCM7XX_GRP(fanin14), \
5708c2ecf20Sopenharmony_ci	NPCM7XX_GRP(fanin15), \
5718c2ecf20Sopenharmony_ci	NPCM7XX_GRP(faninx), \
5728c2ecf20Sopenharmony_ci	NPCM7XX_GRP(pwm0), \
5738c2ecf20Sopenharmony_ci	NPCM7XX_GRP(pwm1), \
5748c2ecf20Sopenharmony_ci	NPCM7XX_GRP(pwm2), \
5758c2ecf20Sopenharmony_ci	NPCM7XX_GRP(pwm3), \
5768c2ecf20Sopenharmony_ci	NPCM7XX_GRP(pwm4), \
5778c2ecf20Sopenharmony_ci	NPCM7XX_GRP(pwm5), \
5788c2ecf20Sopenharmony_ci	NPCM7XX_GRP(pwm6), \
5798c2ecf20Sopenharmony_ci	NPCM7XX_GRP(pwm7), \
5808c2ecf20Sopenharmony_ci	NPCM7XX_GRP(rg1), \
5818c2ecf20Sopenharmony_ci	NPCM7XX_GRP(rg1mdio), \
5828c2ecf20Sopenharmony_ci	NPCM7XX_GRP(rg2), \
5838c2ecf20Sopenharmony_ci	NPCM7XX_GRP(rg2mdio), \
5848c2ecf20Sopenharmony_ci	NPCM7XX_GRP(ddr), \
5858c2ecf20Sopenharmony_ci	NPCM7XX_GRP(uart1), \
5868c2ecf20Sopenharmony_ci	NPCM7XX_GRP(uart2), \
5878c2ecf20Sopenharmony_ci	NPCM7XX_GRP(bmcuart0a), \
5888c2ecf20Sopenharmony_ci	NPCM7XX_GRP(bmcuart0b), \
5898c2ecf20Sopenharmony_ci	NPCM7XX_GRP(bmcuart1), \
5908c2ecf20Sopenharmony_ci	NPCM7XX_GRP(iox1), \
5918c2ecf20Sopenharmony_ci	NPCM7XX_GRP(iox2), \
5928c2ecf20Sopenharmony_ci	NPCM7XX_GRP(ioxh), \
5938c2ecf20Sopenharmony_ci	NPCM7XX_GRP(gspi), \
5948c2ecf20Sopenharmony_ci	NPCM7XX_GRP(mmc), \
5958c2ecf20Sopenharmony_ci	NPCM7XX_GRP(mmcwp), \
5968c2ecf20Sopenharmony_ci	NPCM7XX_GRP(mmccd), \
5978c2ecf20Sopenharmony_ci	NPCM7XX_GRP(mmcrst), \
5988c2ecf20Sopenharmony_ci	NPCM7XX_GRP(mmc8), \
5998c2ecf20Sopenharmony_ci	NPCM7XX_GRP(r1), \
6008c2ecf20Sopenharmony_ci	NPCM7XX_GRP(r1err), \
6018c2ecf20Sopenharmony_ci	NPCM7XX_GRP(r1md), \
6028c2ecf20Sopenharmony_ci	NPCM7XX_GRP(r2), \
6038c2ecf20Sopenharmony_ci	NPCM7XX_GRP(r2err), \
6048c2ecf20Sopenharmony_ci	NPCM7XX_GRP(r2md), \
6058c2ecf20Sopenharmony_ci	NPCM7XX_GRP(sd1), \
6068c2ecf20Sopenharmony_ci	NPCM7XX_GRP(sd1pwr), \
6078c2ecf20Sopenharmony_ci	NPCM7XX_GRP(wdog1), \
6088c2ecf20Sopenharmony_ci	NPCM7XX_GRP(wdog2), \
6098c2ecf20Sopenharmony_ci	NPCM7XX_GRP(scipme), \
6108c2ecf20Sopenharmony_ci	NPCM7XX_GRP(sci), \
6118c2ecf20Sopenharmony_ci	NPCM7XX_GRP(serirq), \
6128c2ecf20Sopenharmony_ci	NPCM7XX_GRP(jtag2), \
6138c2ecf20Sopenharmony_ci	NPCM7XX_GRP(spix), \
6148c2ecf20Sopenharmony_ci	NPCM7XX_GRP(spixcs1), \
6158c2ecf20Sopenharmony_ci	NPCM7XX_GRP(pspi1), \
6168c2ecf20Sopenharmony_ci	NPCM7XX_GRP(pspi2), \
6178c2ecf20Sopenharmony_ci	NPCM7XX_GRP(ddc), \
6188c2ecf20Sopenharmony_ci	NPCM7XX_GRP(clkreq), \
6198c2ecf20Sopenharmony_ci	NPCM7XX_GRP(clkout), \
6208c2ecf20Sopenharmony_ci	NPCM7XX_GRP(spi3), \
6218c2ecf20Sopenharmony_ci	NPCM7XX_GRP(spi3cs1), \
6228c2ecf20Sopenharmony_ci	NPCM7XX_GRP(spi3quad), \
6238c2ecf20Sopenharmony_ci	NPCM7XX_GRP(spi3cs2), \
6248c2ecf20Sopenharmony_ci	NPCM7XX_GRP(spi3cs3), \
6258c2ecf20Sopenharmony_ci	NPCM7XX_GRP(spi0cs1), \
6268c2ecf20Sopenharmony_ci	NPCM7XX_GRP(lpc), \
6278c2ecf20Sopenharmony_ci	NPCM7XX_GRP(lpcclk), \
6288c2ecf20Sopenharmony_ci	NPCM7XX_GRP(espi), \
6298c2ecf20Sopenharmony_ci	NPCM7XX_GRP(lkgpo0), \
6308c2ecf20Sopenharmony_ci	NPCM7XX_GRP(lkgpo1), \
6318c2ecf20Sopenharmony_ci	NPCM7XX_GRP(lkgpo2), \
6328c2ecf20Sopenharmony_ci	NPCM7XX_GRP(nprd_smi), \
6338c2ecf20Sopenharmony_ci	\
6348c2ecf20Sopenharmony_ci
6358c2ecf20Sopenharmony_cienum {
6368c2ecf20Sopenharmony_ci#define NPCM7XX_GRP(x) fn_ ## x
6378c2ecf20Sopenharmony_ci	NPCM7XX_GRPS
6388c2ecf20Sopenharmony_ci	/* add placeholder for none/gpio */
6398c2ecf20Sopenharmony_ci	NPCM7XX_GRP(none),
6408c2ecf20Sopenharmony_ci	NPCM7XX_GRP(gpio),
6418c2ecf20Sopenharmony_ci#undef NPCM7XX_GRP
6428c2ecf20Sopenharmony_ci};
6438c2ecf20Sopenharmony_ci
6448c2ecf20Sopenharmony_cistatic struct npcm7xx_group npcm7xx_groups[] = {
6458c2ecf20Sopenharmony_ci#define NPCM7XX_GRP(x) { .name = #x, .pins = x ## _pins, \
6468c2ecf20Sopenharmony_ci			.npins = ARRAY_SIZE(x ## _pins) }
6478c2ecf20Sopenharmony_ci	NPCM7XX_GRPS
6488c2ecf20Sopenharmony_ci#undef NPCM7XX_GRP
6498c2ecf20Sopenharmony_ci};
6508c2ecf20Sopenharmony_ci
6518c2ecf20Sopenharmony_ci#define NPCM7XX_SFUNC(a) NPCM7XX_FUNC(a, #a)
6528c2ecf20Sopenharmony_ci#define NPCM7XX_FUNC(a, b...) static const char *a ## _grp[] = { b }
6538c2ecf20Sopenharmony_ci#define NPCM7XX_MKFUNC(nm) { .name = #nm, .ngroups = ARRAY_SIZE(nm ## _grp), \
6548c2ecf20Sopenharmony_ci			.groups = nm ## _grp }
6558c2ecf20Sopenharmony_cistruct npcm7xx_func {
6568c2ecf20Sopenharmony_ci	const char *name;
6578c2ecf20Sopenharmony_ci	const unsigned int ngroups;
6588c2ecf20Sopenharmony_ci	const char *const *groups;
6598c2ecf20Sopenharmony_ci};
6608c2ecf20Sopenharmony_ci
6618c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(smb0);
6628c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(smb0b);
6638c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(smb0c);
6648c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(smb0d);
6658c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(smb0den);
6668c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(smb1);
6678c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(smb1b);
6688c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(smb1c);
6698c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(smb1d);
6708c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(smb2);
6718c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(smb2b);
6728c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(smb2c);
6738c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(smb2d);
6748c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(smb3);
6758c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(smb3b);
6768c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(smb3c);
6778c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(smb3d);
6788c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(smb4);
6798c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(smb4b);
6808c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(smb4c);
6818c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(smb4d);
6828c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(smb4den);
6838c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(smb5);
6848c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(smb5b);
6858c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(smb5c);
6868c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(smb5d);
6878c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(ga20kbc);
6888c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(smb6);
6898c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(smb7);
6908c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(smb8);
6918c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(smb9);
6928c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(smb10);
6938c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(smb11);
6948c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(smb12);
6958c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(smb13);
6968c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(smb14);
6978c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(smb15);
6988c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(fanin0);
6998c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(fanin1);
7008c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(fanin2);
7018c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(fanin3);
7028c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(fanin4);
7038c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(fanin5);
7048c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(fanin6);
7058c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(fanin7);
7068c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(fanin8);
7078c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(fanin9);
7088c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(fanin10);
7098c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(fanin11);
7108c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(fanin12);
7118c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(fanin13);
7128c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(fanin14);
7138c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(fanin15);
7148c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(faninx);
7158c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(pwm0);
7168c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(pwm1);
7178c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(pwm2);
7188c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(pwm3);
7198c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(pwm4);
7208c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(pwm5);
7218c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(pwm6);
7228c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(pwm7);
7238c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(rg1);
7248c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(rg1mdio);
7258c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(rg2);
7268c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(rg2mdio);
7278c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(ddr);
7288c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(uart1);
7298c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(uart2);
7308c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(bmcuart0a);
7318c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(bmcuart0b);
7328c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(bmcuart1);
7338c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(iox1);
7348c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(iox2);
7358c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(ioxh);
7368c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(gspi);
7378c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(mmc);
7388c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(mmcwp);
7398c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(mmccd);
7408c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(mmcrst);
7418c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(mmc8);
7428c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(r1);
7438c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(r1err);
7448c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(r1md);
7458c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(r2);
7468c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(r2err);
7478c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(r2md);
7488c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(sd1);
7498c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(sd1pwr);
7508c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(wdog1);
7518c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(wdog2);
7528c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(scipme);
7538c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(sci);
7548c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(serirq);
7558c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(jtag2);
7568c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(spix);
7578c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(spixcs1);
7588c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(pspi1);
7598c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(pspi2);
7608c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(ddc);
7618c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(clkreq);
7628c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(clkout);
7638c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(spi3);
7648c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(spi3cs1);
7658c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(spi3quad);
7668c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(spi3cs2);
7678c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(spi3cs3);
7688c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(spi0cs1);
7698c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(lpc);
7708c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(lpcclk);
7718c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(espi);
7728c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(lkgpo0);
7738c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(lkgpo1);
7748c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(lkgpo2);
7758c2ecf20Sopenharmony_ciNPCM7XX_SFUNC(nprd_smi);
7768c2ecf20Sopenharmony_ci
7778c2ecf20Sopenharmony_ci/* Function names */
7788c2ecf20Sopenharmony_cistatic struct npcm7xx_func npcm7xx_funcs[] = {
7798c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(smb0),
7808c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(smb0b),
7818c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(smb0c),
7828c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(smb0d),
7838c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(smb0den),
7848c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(smb1),
7858c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(smb1b),
7868c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(smb1c),
7878c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(smb1d),
7888c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(smb2),
7898c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(smb2b),
7908c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(smb2c),
7918c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(smb2d),
7928c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(smb3),
7938c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(smb3b),
7948c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(smb3c),
7958c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(smb3d),
7968c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(smb4),
7978c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(smb4b),
7988c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(smb4c),
7998c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(smb4d),
8008c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(smb4den),
8018c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(smb5),
8028c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(smb5b),
8038c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(smb5c),
8048c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(smb5d),
8058c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(ga20kbc),
8068c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(smb6),
8078c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(smb7),
8088c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(smb8),
8098c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(smb9),
8108c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(smb10),
8118c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(smb11),
8128c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(smb12),
8138c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(smb13),
8148c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(smb14),
8158c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(smb15),
8168c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(fanin0),
8178c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(fanin1),
8188c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(fanin2),
8198c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(fanin3),
8208c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(fanin4),
8218c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(fanin5),
8228c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(fanin6),
8238c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(fanin7),
8248c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(fanin8),
8258c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(fanin9),
8268c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(fanin10),
8278c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(fanin11),
8288c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(fanin12),
8298c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(fanin13),
8308c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(fanin14),
8318c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(fanin15),
8328c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(faninx),
8338c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(pwm0),
8348c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(pwm1),
8358c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(pwm2),
8368c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(pwm3),
8378c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(pwm4),
8388c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(pwm5),
8398c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(pwm6),
8408c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(pwm7),
8418c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(rg1),
8428c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(rg1mdio),
8438c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(rg2),
8448c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(rg2mdio),
8458c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(ddr),
8468c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(uart1),
8478c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(uart2),
8488c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(bmcuart0a),
8498c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(bmcuart0b),
8508c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(bmcuart1),
8518c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(iox1),
8528c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(iox2),
8538c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(ioxh),
8548c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(gspi),
8558c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(mmc),
8568c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(mmcwp),
8578c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(mmccd),
8588c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(mmcrst),
8598c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(mmc8),
8608c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(r1),
8618c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(r1err),
8628c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(r1md),
8638c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(r2),
8648c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(r2err),
8658c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(r2md),
8668c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(sd1),
8678c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(sd1pwr),
8688c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(wdog1),
8698c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(wdog2),
8708c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(scipme),
8718c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(sci),
8728c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(serirq),
8738c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(jtag2),
8748c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(spix),
8758c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(spixcs1),
8768c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(pspi1),
8778c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(pspi2),
8788c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(ddc),
8798c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(clkreq),
8808c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(clkout),
8818c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(spi3),
8828c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(spi3cs1),
8838c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(spi3quad),
8848c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(spi3cs2),
8858c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(spi3cs3),
8868c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(spi0cs1),
8878c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(lpc),
8888c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(lpcclk),
8898c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(espi),
8908c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(lkgpo0),
8918c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(lkgpo1),
8928c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(lkgpo2),
8938c2ecf20Sopenharmony_ci	NPCM7XX_MKFUNC(nprd_smi),
8948c2ecf20Sopenharmony_ci};
8958c2ecf20Sopenharmony_ci
8968c2ecf20Sopenharmony_ci#define NPCM7XX_PINCFG(a, b, c, d, e, f, g, h, i, j, k) \
8978c2ecf20Sopenharmony_ci	[a] { .fn0 = fn_ ## b, .reg0 = NPCM7XX_GCR_ ## c, .bit0 = d, \
8988c2ecf20Sopenharmony_ci			.fn1 = fn_ ## e, .reg1 = NPCM7XX_GCR_ ## f, .bit1 = g, \
8998c2ecf20Sopenharmony_ci			.fn2 = fn_ ## h, .reg2 = NPCM7XX_GCR_ ## i, .bit2 = j, \
9008c2ecf20Sopenharmony_ci			.flag = k }
9018c2ecf20Sopenharmony_ci
9028c2ecf20Sopenharmony_ci/* Drive strength controlled by NPCM7XX_GP_N_ODSC */
9038c2ecf20Sopenharmony_ci#define DRIVE_STRENGTH_LO_SHIFT		8
9048c2ecf20Sopenharmony_ci#define DRIVE_STRENGTH_HI_SHIFT		12
9058c2ecf20Sopenharmony_ci#define DRIVE_STRENGTH_MASK		0x0000FF00
9068c2ecf20Sopenharmony_ci
9078c2ecf20Sopenharmony_ci#define DSTR(lo, hi)	(((lo) << DRIVE_STRENGTH_LO_SHIFT) | \
9088c2ecf20Sopenharmony_ci			 ((hi) << DRIVE_STRENGTH_HI_SHIFT))
9098c2ecf20Sopenharmony_ci#define DSLO(x)		(((x) >> DRIVE_STRENGTH_LO_SHIFT) & 0xF)
9108c2ecf20Sopenharmony_ci#define DSHI(x)		(((x) >> DRIVE_STRENGTH_HI_SHIFT) & 0xF)
9118c2ecf20Sopenharmony_ci
9128c2ecf20Sopenharmony_ci#define GPI		0x1 /* Not GPO */
9138c2ecf20Sopenharmony_ci#define GPO		0x2 /* Not GPI */
9148c2ecf20Sopenharmony_ci#define SLEW		0x4 /* Has Slew Control, NPCM7XX_GP_N_OSRC */
9158c2ecf20Sopenharmony_ci#define SLEWLPC		0x8 /* Has Slew Control, SRCNT.3 */
9168c2ecf20Sopenharmony_ci
9178c2ecf20Sopenharmony_cistruct npcm7xx_pincfg {
9188c2ecf20Sopenharmony_ci	int flag;
9198c2ecf20Sopenharmony_ci	int fn0, reg0, bit0;
9208c2ecf20Sopenharmony_ci	int fn1, reg1, bit1;
9218c2ecf20Sopenharmony_ci	int fn2, reg2, bit2;
9228c2ecf20Sopenharmony_ci};
9238c2ecf20Sopenharmony_ci
9248c2ecf20Sopenharmony_cistatic const struct npcm7xx_pincfg pincfg[] = {
9258c2ecf20Sopenharmony_ci	/*	PIN	  FUNCTION 1		   FUNCTION 2		  FUNCTION 3	    FLAGS */
9268c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(0,	 iox1, MFSEL1, 30,	  none, NONE, 0,	none, NONE, 0,	     0),
9278c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(1,	 iox1, MFSEL1, 30,	  none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12)),
9288c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(2,	 iox1, MFSEL1, 30,	  none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12)),
9298c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(3,	 iox1, MFSEL1, 30,	  none, NONE, 0,	none, NONE, 0,	     0),
9308c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(4,	 iox2, MFSEL3, 14,	 smb1d, I2CSEGSEL, 7,	none, NONE, 0,	     SLEW),
9318c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(5,	 iox2, MFSEL3, 14,	 smb1d, I2CSEGSEL, 7,	none, NONE, 0,	     SLEW),
9328c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(6,	 iox2, MFSEL3, 14,	 smb2d, I2CSEGSEL, 10,  none, NONE, 0,       SLEW),
9338c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(7,	 iox2, MFSEL3, 14,	 smb2d, I2CSEGSEL, 10,  none, NONE, 0,       SLEW),
9348c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(8,      lkgpo1, FLOCKR1, 4,        none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12)),
9358c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(9,      lkgpo2, FLOCKR1, 8,        none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12)),
9368c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(10,	 ioxh, MFSEL3, 18,	  none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12)),
9378c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(11,	 ioxh, MFSEL3, 18,	  none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12)),
9388c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(12,	 gspi, MFSEL1, 24,	 smb5b, I2CSEGSEL, 19,  none, NONE, 0,	     SLEW),
9398c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(13,	 gspi, MFSEL1, 24,	 smb5b, I2CSEGSEL, 19,  none, NONE, 0,	     SLEW),
9408c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(14,	 gspi, MFSEL1, 24,	 smb5c, I2CSEGSEL, 20,	none, NONE, 0,	     SLEW),
9418c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(15,	 gspi, MFSEL1, 24,	 smb5c, I2CSEGSEL, 20,	none, NONE, 0,	     SLEW),
9428c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(16,     lkgpo0, FLOCKR1, 0,        none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12)),
9438c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(17,      pspi2, MFSEL3, 13,     smb4den, I2CSEGSEL, 23,  none, NONE, 0,       DSTR(8, 12)),
9448c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(18,      pspi2, MFSEL3, 13,	 smb4b, I2CSEGSEL, 14,  none, NONE, 0,	     DSTR(8, 12)),
9458c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(19,      pspi2, MFSEL3, 13,	 smb4b, I2CSEGSEL, 14,  none, NONE, 0,	     DSTR(8, 12)),
9468c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(20,	smb4c, I2CSEGSEL, 15,    smb15, MFSEL3, 8,      none, NONE, 0,	     0),
9478c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(21,	smb4c, I2CSEGSEL, 15,    smb15, MFSEL3, 8,      none, NONE, 0,	     0),
9488c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(22,      smb4d, I2CSEGSEL, 16,	 smb14, MFSEL3, 7,      none, NONE, 0,	     0),
9498c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(23,      smb4d, I2CSEGSEL, 16,	 smb14, MFSEL3, 7,      none, NONE, 0,	     0),
9508c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(24,	 ioxh, MFSEL3, 18,	  none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12)),
9518c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(25,	 ioxh, MFSEL3, 18,	  none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12)),
9528c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(26,	 smb5, MFSEL1, 2,	  none, NONE, 0,	none, NONE, 0,	     0),
9538c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(27,	 smb5, MFSEL1, 2,	  none, NONE, 0,	none, NONE, 0,	     0),
9548c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(28,	 smb4, MFSEL1, 1,	  none, NONE, 0,	none, NONE, 0,	     0),
9558c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(29,	 smb4, MFSEL1, 1,	  none, NONE, 0,	none, NONE, 0,	     0),
9568c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(30,	 smb3, MFSEL1, 0,	  none, NONE, 0,	none, NONE, 0,	     0),
9578c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(31,	 smb3, MFSEL1, 0,	  none, NONE, 0,	none, NONE, 0,	     0),
9588c2ecf20Sopenharmony_ci
9598c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(32,    spi0cs1, MFSEL1, 3,	  none, NONE, 0,	none, NONE, 0,	     0),
9608c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(33,   none, NONE, 0,     none, NONE, 0,	none, NONE, 0,	     SLEW),
9618c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(34,   none, NONE, 0,     none, NONE, 0,	none, NONE, 0,	     SLEW),
9628c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(37,	smb3c, I2CSEGSEL, 12,	  none, NONE, 0,	none, NONE, 0,	     SLEW),
9638c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(38,	smb3c, I2CSEGSEL, 12,	  none, NONE, 0,	none, NONE, 0,	     SLEW),
9648c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(39,	smb3b, I2CSEGSEL, 11,	  none, NONE, 0,	none, NONE, 0,	     SLEW),
9658c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(40,	smb3b, I2CSEGSEL, 11,	  none, NONE, 0,	none, NONE, 0,	     SLEW),
9668c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(41,  bmcuart0a, MFSEL1, 9,         none, NONE, 0,	none, NONE, 0,	     0),
9678c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(42,  bmcuart0a, MFSEL1, 9,         none, NONE, 0,	none, NONE, 0,	     DSTR(2, 4) | GPO),
9688c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(43,      uart1, MFSEL1, 10,	 jtag2, MFSEL4, 0,  bmcuart1, MFSEL3, 24,    0),
9698c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(44,      uart1, MFSEL1, 10,	 jtag2, MFSEL4, 0,  bmcuart1, MFSEL3, 24,    0),
9708c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(45,      uart1, MFSEL1, 10,	 jtag2, MFSEL4, 0,	none, NONE, 0,	     0),
9718c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(46,      uart1, MFSEL1, 10,	 jtag2, MFSEL4, 0,	none, NONE, 0,	     DSTR(2, 8)),
9728c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(47,      uart1, MFSEL1, 10,	 jtag2, MFSEL4, 0,	none, NONE, 0,	     DSTR(2, 8)),
9738c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(48,	uart2, MFSEL1, 11,   bmcuart0b, MFSEL4, 1,      none, NONE, 0,	     GPO),
9748c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(49,	uart2, MFSEL1, 11,   bmcuart0b, MFSEL4, 1,      none, NONE, 0,	     0),
9758c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(50,	uart2, MFSEL1, 11,	  none, NONE, 0,        none, NONE, 0,	     0),
9768c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(51,	uart2, MFSEL1, 11,	  none, NONE, 0,        none, NONE, 0,	     GPO),
9778c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(52,	uart2, MFSEL1, 11,	  none, NONE, 0,        none, NONE, 0,	     0),
9788c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(53,	uart2, MFSEL1, 11,	  none, NONE, 0,        none, NONE, 0,	     GPO),
9798c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(54,	uart2, MFSEL1, 11,	  none, NONE, 0,        none, NONE, 0,	     0),
9808c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(55,	uart2, MFSEL1, 11,	  none, NONE, 0,        none, NONE, 0,	     0),
9818c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(56,	r1err, MFSEL1, 12,	  none, NONE, 0,	none, NONE, 0,	     0),
9828c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(57,       r1md, MFSEL1, 13,        none, NONE, 0,        none, NONE, 0,       DSTR(2, 4)),
9838c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(58,       r1md, MFSEL1, 13,        none, NONE, 0,	none, NONE, 0,	     DSTR(2, 4)),
9848c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(59,	smb3d, I2CSEGSEL, 13,	  none, NONE, 0,	none, NONE, 0,	     0),
9858c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(60,	smb3d, I2CSEGSEL, 13,	  none, NONE, 0,	none, NONE, 0,	     0),
9868c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(61,      uart1, MFSEL1, 10,	  none, NONE, 0,	none, NONE, 0,     GPO),
9878c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(62,      uart1, MFSEL1, 10,    bmcuart1, MFSEL3, 24,	none, NONE, 0,     GPO),
9888c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(63,      uart1, MFSEL1, 10,    bmcuart1, MFSEL3, 24,	none, NONE, 0,     GPO),
9898c2ecf20Sopenharmony_ci
9908c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(64,    fanin0, MFSEL2, 0,          none, NONE, 0,	none, NONE, 0,	     0),
9918c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(65,    fanin1, MFSEL2, 1,          none, NONE, 0,	none, NONE, 0,	     0),
9928c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(66,    fanin2, MFSEL2, 2,          none, NONE, 0,	none, NONE, 0,	     0),
9938c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(67,    fanin3, MFSEL2, 3,          none, NONE, 0,	none, NONE, 0,	     0),
9948c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(68,    fanin4, MFSEL2, 4,          none, NONE, 0,	none, NONE, 0,	     0),
9958c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(69,    fanin5, MFSEL2, 5,          none, NONE, 0,	none, NONE, 0,	     0),
9968c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(70,    fanin6, MFSEL2, 6,          none, NONE, 0,	none, NONE, 0,	     0),
9978c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(71,    fanin7, MFSEL2, 7,          none, NONE, 0,	none, NONE, 0,	     0),
9988c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(72,    fanin8, MFSEL2, 8,          none, NONE, 0,	none, NONE, 0,	     0),
9998c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(73,    fanin9, MFSEL2, 9,          none, NONE, 0,	none, NONE, 0,	     0),
10008c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(74,    fanin10, MFSEL2, 10,        none, NONE, 0,	none, NONE, 0,	     0),
10018c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(75,    fanin11, MFSEL2, 11,        none, NONE, 0,	none, NONE, 0,	     0),
10028c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(76,    fanin12, MFSEL2, 12,        none, NONE, 0,	none, NONE, 0,	     0),
10038c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(77,    fanin13, MFSEL2, 13,        none, NONE, 0,	none, NONE, 0,	     0),
10048c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(78,    fanin14, MFSEL2, 14,        none, NONE, 0,	none, NONE, 0,	     0),
10058c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(79,    fanin15, MFSEL2, 15,        none, NONE, 0,	none, NONE, 0,	     0),
10068c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(80,	 pwm0, MFSEL2, 16,        none, NONE, 0,	none, NONE, 0,	     DSTR(4, 8)),
10078c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(81,	 pwm1, MFSEL2, 17,        none, NONE, 0,	none, NONE, 0,	     DSTR(4, 8)),
10088c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(82,	 pwm2, MFSEL2, 18,        none, NONE, 0,	none, NONE, 0,	     DSTR(4, 8)),
10098c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(83,	 pwm3, MFSEL2, 19,        none, NONE, 0,	none, NONE, 0,	     DSTR(4, 8)),
10108c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(84,         r2, MFSEL1, 14,        none, NONE, 0,        none, NONE, 0,	     DSTR(8, 12) | SLEW),
10118c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(85,         r2, MFSEL1, 14,        none, NONE, 0,        none, NONE, 0,	     DSTR(8, 12) | SLEW),
10128c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(86,         r2, MFSEL1, 14,        none, NONE, 0,        none, NONE, 0,	     DSTR(8, 12) | SLEW),
10138c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(87,         r2, MFSEL1, 14,        none, NONE, 0,        none, NONE, 0,	     0),
10148c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(88,         r2, MFSEL1, 14,        none, NONE, 0,        none, NONE, 0,	     0),
10158c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(89,         r2, MFSEL1, 14,        none, NONE, 0,        none, NONE, 0,	     0),
10168c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(90,      r2err, MFSEL1, 15,        none, NONE, 0,        none, NONE, 0,       0),
10178c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(91,       r2md, MFSEL1, 16,	  none, NONE, 0,        none, NONE, 0,	     DSTR(2, 4)),
10188c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(92,       r2md, MFSEL1, 16,	  none, NONE, 0,        none, NONE, 0,	     DSTR(2, 4)),
10198c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(93,    ga20kbc, MFSEL1, 17,	 smb5d, I2CSEGSEL, 21,  none, NONE, 0,	     0),
10208c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(94,    ga20kbc, MFSEL1, 17,	 smb5d, I2CSEGSEL, 21,  none, NONE, 0,	     0),
10218c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(95,	  lpc, NONE, 0,		  espi, MFSEL4, 8,      gpio, MFSEL1, 26,    0),
10228c2ecf20Sopenharmony_ci
10238c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(96,	  rg1, MFSEL4, 22,	  none, NONE, 0,	none, NONE, 0,	     0),
10248c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(97,	  rg1, MFSEL4, 22,	  none, NONE, 0,	none, NONE, 0,	     0),
10258c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(98,	  rg1, MFSEL4, 22,	  none, NONE, 0,	none, NONE, 0,	     0),
10268c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(99,	  rg1, MFSEL4, 22,	  none, NONE, 0,	none, NONE, 0,	     0),
10278c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(100,	  rg1, MFSEL4, 22,	  none, NONE, 0,	none, NONE, 0,	     0),
10288c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(101,	  rg1, MFSEL4, 22,	  none, NONE, 0,	none, NONE, 0,	     0),
10298c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(102,	  rg1, MFSEL4, 22,	  none, NONE, 0,	none, NONE, 0,	     0),
10308c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(103,	  rg1, MFSEL4, 22,	  none, NONE, 0,	none, NONE, 0,	     0),
10318c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(104,	  rg1, MFSEL4, 22,	  none, NONE, 0,	none, NONE, 0,	     0),
10328c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(105,	  rg1, MFSEL4, 22,	  none, NONE, 0,	none, NONE, 0,	     0),
10338c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(106,	  rg1, MFSEL4, 22,	  none, NONE, 0,	none, NONE, 0,	     0),
10348c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(107,	  rg1, MFSEL4, 22,	  none, NONE, 0,	none, NONE, 0,	     0),
10358c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(108,   rg1mdio, MFSEL4, 21,        none, NONE, 0,	none, NONE, 0,	     0),
10368c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(109,   rg1mdio, MFSEL4, 21,        none, NONE, 0,	none, NONE, 0,	     0),
10378c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(110,       rg2, MFSEL4, 24,         ddr, MFSEL3, 26,     none, NONE, 0,       0),
10388c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(111,       rg2, MFSEL4, 24,         ddr, MFSEL3, 26,     none, NONE, 0,       0),
10398c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(112,       rg2, MFSEL4, 24,         ddr, MFSEL3, 26,     none, NONE, 0,       0),
10408c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(113,       rg2, MFSEL4, 24,         ddr, MFSEL3, 26,     none, NONE, 0,       0),
10418c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(114,	 smb0, MFSEL1, 6,	  none, NONE, 0,	none, NONE, 0,	     0),
10428c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(115,	 smb0, MFSEL1, 6,	  none, NONE, 0,	none, NONE, 0,	     0),
10438c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(116,	 smb1, MFSEL1, 7,	  none, NONE, 0,	none, NONE, 0,	     0),
10448c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(117,	 smb1, MFSEL1, 7,	  none, NONE, 0,	none, NONE, 0,	     0),
10458c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(118,	 smb2, MFSEL1, 8,	  none, NONE, 0,	none, NONE, 0,	     0),
10468c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(119,	 smb2, MFSEL1, 8,	  none, NONE, 0,	none, NONE, 0,	     0),
10478c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(120,	smb2c, I2CSEGSEL, 9,	  none, NONE, 0,	none, NONE, 0,	     SLEW),
10488c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(121,	smb2c, I2CSEGSEL, 9,      none, NONE, 0,	none, NONE, 0,	     SLEW),
10498c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(122,	smb2b, I2CSEGSEL, 8,	  none, NONE, 0,	none, NONE, 0,	     SLEW),
10508c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(123,	smb2b, I2CSEGSEL, 8,	  none, NONE, 0,	none, NONE, 0,	     SLEW),
10518c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(124,	smb1c, I2CSEGSEL, 6,	  none, NONE, 0,	none, NONE, 0,	     SLEW),
10528c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(125,	smb1c, I2CSEGSEL, 6,	  none, NONE, 0,	none, NONE, 0,	     SLEW),
10538c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(126,	smb1b, I2CSEGSEL, 5,	  none, NONE, 0,	none, NONE, 0,	     SLEW),
10548c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(127,	smb1b, I2CSEGSEL, 5,	  none, NONE, 0,	none, NONE, 0,	     SLEW),
10558c2ecf20Sopenharmony_ci
10568c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(128,	 smb8, MFSEL4, 11,	  none, NONE, 0,	none, NONE, 0,	     0),
10578c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(129,	 smb8, MFSEL4, 11,	  none, NONE, 0,	none, NONE, 0,	     0),
10588c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(130,	 smb9, MFSEL4, 12,        none, NONE, 0,	none, NONE, 0,	     0),
10598c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(131,	 smb9, MFSEL4, 12,        none, NONE, 0,	none, NONE, 0,	     0),
10608c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(132,	smb10, MFSEL4, 13,	  none, NONE, 0,	none, NONE, 0,	     0),
10618c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(133,	smb10, MFSEL4, 13,	  none, NONE, 0,	none, NONE, 0,	     0),
10628c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(134,	smb11, MFSEL4, 14,	  none, NONE, 0,	none, NONE, 0,	     0),
10638c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(135,	smb11, MFSEL4, 14,	  none, NONE, 0,	none, NONE, 0,	     0),
10648c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(136,	  sd1, MFSEL3, 12,	  none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12) | SLEW),
10658c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(137,	  sd1, MFSEL3, 12,	  none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12) | SLEW),
10668c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(138,	  sd1, MFSEL3, 12,	  none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12) | SLEW),
10678c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(139,	  sd1, MFSEL3, 12,	  none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12) | SLEW),
10688c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(140,	  sd1, MFSEL3, 12,	  none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12) | SLEW),
10698c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(141,	  sd1, MFSEL3, 12,	  none, NONE, 0,	none, NONE, 0,	     0),
10708c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(142,	  sd1, MFSEL3, 12,	  none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12) | SLEW),
10718c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(143,       sd1, MFSEL3, 12,      sd1pwr, MFSEL4, 5,      none, NONE, 0,       0),
10728c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(144,	 pwm4, MFSEL2, 20,	  none, NONE, 0,	none, NONE, 0,	     DSTR(4, 8)),
10738c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(145,	 pwm5, MFSEL2, 21,	  none, NONE, 0,	none, NONE, 0,	     DSTR(4, 8)),
10748c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(146,	 pwm6, MFSEL2, 22,	  none, NONE, 0,	none, NONE, 0,	     DSTR(4, 8)),
10758c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(147,	 pwm7, MFSEL2, 23,	  none, NONE, 0,	none, NONE, 0,	     DSTR(4, 8)),
10768c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(148,	 mmc8, MFSEL3, 11,	  none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12) | SLEW),
10778c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(149,	 mmc8, MFSEL3, 11,	  none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12) | SLEW),
10788c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(150,	 mmc8, MFSEL3, 11,	  none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12) | SLEW),
10798c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(151,	 mmc8, MFSEL3, 11,	  none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12) | SLEW),
10808c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(152,	  mmc, MFSEL3, 10,	  none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12) | SLEW),
10818c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(153,     mmcwp, FLOCKR1, 24,       none, NONE, 0,	none, NONE, 0,	     0),  /* Z1/A1 */
10828c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(154,	  mmc, MFSEL3, 10,	  none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12) | SLEW),
10838c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(155,     mmccd, MFSEL3, 25,      mmcrst, MFSEL4, 6,      none, NONE, 0,       0),  /* Z1/A1 */
10848c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(156,	  mmc, MFSEL3, 10,	  none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12) | SLEW),
10858c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(157,	  mmc, MFSEL3, 10,	  none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12) | SLEW),
10868c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(158,	  mmc, MFSEL3, 10,	  none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12) | SLEW),
10878c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(159,	  mmc, MFSEL3, 10,	  none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12) | SLEW),
10888c2ecf20Sopenharmony_ci
10898c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(160,    clkout, MFSEL1, 21,        none, NONE, 0,        none, NONE, 0,	     DSTR(8, 12) | SLEW),
10908c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(161,	  lpc, NONE, 0,		  espi, MFSEL4, 8,      gpio, MFSEL1, 26,    DSTR(8, 12)),
10918c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(162,    serirq, NONE, 0,           gpio, MFSEL1, 31,	none, NONE, 0,	     DSTR(8, 12)),
10928c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(163,	  lpc, NONE, 0,		  espi, MFSEL4, 8,      gpio, MFSEL1, 26,    0),
10938c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(164,	  lpc, NONE, 0,		  espi, MFSEL4, 8,      gpio, MFSEL1, 26,    SLEWLPC),
10948c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(165,	  lpc, NONE, 0,		  espi, MFSEL4, 8,      gpio, MFSEL1, 26,    SLEWLPC),
10958c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(166,	  lpc, NONE, 0,		  espi, MFSEL4, 8,      gpio, MFSEL1, 26,    SLEWLPC),
10968c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(167,	  lpc, NONE, 0,		  espi, MFSEL4, 8,      gpio, MFSEL1, 26,    SLEWLPC),
10978c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(168,    lpcclk, NONE, 0,           espi, MFSEL4, 8,      gpio, MFSEL3, 16,    0),
10988c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(169,    scipme, MFSEL3, 0,         none, NONE, 0,	none, NONE, 0,	     0),
10998c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(170,	  sci, MFSEL1, 22,        none, NONE, 0,        none, NONE, 0,	     0),
11008c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(171,	 smb6, MFSEL3, 1,	  none, NONE, 0,	none, NONE, 0,	     0),
11018c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(172,	 smb6, MFSEL3, 1,	  none, NONE, 0,	none, NONE, 0,	     0),
11028c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(173,	 smb7, MFSEL3, 2,	  none, NONE, 0,	none, NONE, 0,	     0),
11038c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(174,	 smb7, MFSEL3, 2,	  none, NONE, 0,	none, NONE, 0,	     0),
11048c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(175,	pspi1, MFSEL3, 4,       faninx, MFSEL3, 3,      none, NONE, 0,	     DSTR(8, 12)),
11058c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(176,     pspi1, MFSEL3, 4,       faninx, MFSEL3, 3,      none, NONE, 0,	     DSTR(8, 12)),
11068c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(177,     pspi1, MFSEL3, 4,       faninx, MFSEL3, 3,      none, NONE, 0,	     DSTR(8, 12)),
11078c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(178,	   r1, MFSEL3, 9,	  none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12) | SLEW),
11088c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(179,	   r1, MFSEL3, 9,	  none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12) | SLEW),
11098c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(180,	   r1, MFSEL3, 9,	  none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12) | SLEW),
11108c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(181,	   r1, MFSEL3, 9,	  none, NONE, 0,	none, NONE, 0,	     0),
11118c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(182,	   r1, MFSEL3, 9,	  none, NONE, 0,	none, NONE, 0,	     0),
11128c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(183,     spi3, MFSEL4, 16,	  none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12) | SLEW),
11138c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(184,     spi3, MFSEL4, 16,	  none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12) | SLEW | GPO),
11148c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(185,     spi3, MFSEL4, 16,	  none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12) | SLEW | GPO),
11158c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(186,     spi3, MFSEL4, 16,	  none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12)),
11168c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(187,   spi3cs1, MFSEL4, 17,        none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12)),
11178c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(188,  spi3quad, MFSEL4, 20,     spi3cs2, MFSEL4, 18,     none, NONE, 0,    DSTR(8, 12) | SLEW),
11188c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(189,  spi3quad, MFSEL4, 20,     spi3cs3, MFSEL4, 19,     none, NONE, 0,    DSTR(8, 12) | SLEW),
11198c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(190,      gpio, FLOCKR1, 20,   nprd_smi, NONE, 0,	none, NONE, 0,	     DSTR(2, 4)),
11208c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(191,	 none, NONE, 0,		  none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12)),  /* XX */
11218c2ecf20Sopenharmony_ci
11228c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(192,	 none, NONE, 0,		  none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12)),  /* XX */
11238c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(193,	   r1, MFSEL3, 9,	  none, NONE, 0,	none, NONE, 0,	     0),
11248c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(194,	smb0b, I2CSEGSEL, 0,	  none, NONE, 0,	none, NONE, 0,	     0),
11258c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(195,	smb0b, I2CSEGSEL, 0,	  none, NONE, 0,	none, NONE, 0,	     0),
11268c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(196,	smb0c, I2CSEGSEL, 1,	  none, NONE, 0,	none, NONE, 0,	     0),
11278c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(197,   smb0den, I2CSEGSEL, 22,     none, NONE, 0,	none, NONE, 0,	     SLEW),
11288c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(198,	smb0d, I2CSEGSEL, 2,	  none, NONE, 0,	none, NONE, 0,	     0),
11298c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(199,	smb0d, I2CSEGSEL, 2,	  none, NONE, 0,	none, NONE, 0,	     0),
11308c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(200,        r2, MFSEL1, 14,        none, NONE, 0,        none, NONE, 0,       0),
11318c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(201,	   r1, MFSEL3, 9,	  none, NONE, 0,	none, NONE, 0,	     0),
11328c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(202,	smb0c, I2CSEGSEL, 1,	  none, NONE, 0,	none, NONE, 0,	     0),
11338c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(203,    faninx, MFSEL3, 3,         none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12)),
11348c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(204,	  ddc, NONE, 0,           gpio, MFSEL3, 22,	none, NONE, 0,	     SLEW),
11358c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(205,	  ddc, NONE, 0,           gpio, MFSEL3, 22,	none, NONE, 0,	     SLEW),
11368c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(206,	  ddc, NONE, 0,           gpio, MFSEL3, 22,	none, NONE, 0,	     DSTR(4, 8)),
11378c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(207,	  ddc, NONE, 0,           gpio, MFSEL3, 22,	none, NONE, 0,	     DSTR(4, 8)),
11388c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(208,       rg2, MFSEL4, 24,         ddr, MFSEL3, 26,     none, NONE, 0,       0),
11398c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(209,       rg2, MFSEL4, 24,         ddr, MFSEL3, 26,     none, NONE, 0,       0),
11408c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(210,       rg2, MFSEL4, 24,         ddr, MFSEL3, 26,     none, NONE, 0,       0),
11418c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(211,       rg2, MFSEL4, 24,         ddr, MFSEL3, 26,     none, NONE, 0,       0),
11428c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(212,       rg2, MFSEL4, 24,         ddr, MFSEL3, 26,     none, NONE, 0,       0),
11438c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(213,       rg2, MFSEL4, 24,         ddr, MFSEL3, 26,     none, NONE, 0,       0),
11448c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(214,       rg2, MFSEL4, 24,         ddr, MFSEL3, 26,     none, NONE, 0,       0),
11458c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(215,       rg2, MFSEL4, 24,         ddr, MFSEL3, 26,     none, NONE, 0,       0),
11468c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(216,   rg2mdio, MFSEL4, 23,         ddr, MFSEL3, 26,     none, NONE, 0,       0),
11478c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(217,   rg2mdio, MFSEL4, 23,         ddr, MFSEL3, 26,     none, NONE, 0,       0),
11488c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(218,     wdog1, MFSEL3, 19,        none, NONE, 0,	none, NONE, 0,	     0),
11498c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(219,     wdog2, MFSEL3, 20,        none, NONE, 0,	none, NONE, 0,	     DSTR(4, 8)),
11508c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(220,	smb12, MFSEL3, 5,	  none, NONE, 0,	none, NONE, 0,	     0),
11518c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(221,	smb12, MFSEL3, 5,	  none, NONE, 0,	none, NONE, 0,	     0),
11528c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(222,     smb13, MFSEL3, 6,         none, NONE, 0,	none, NONE, 0,	     0),
11538c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(223,     smb13, MFSEL3, 6,         none, NONE, 0,	none, NONE, 0,	     0),
11548c2ecf20Sopenharmony_ci
11558c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(224,	 spix, MFSEL4, 27,        none, NONE, 0,	none, NONE, 0,	     SLEW),
11568c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(225,	 spix, MFSEL4, 27,        none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12) | SLEW | GPO),
11578c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(226,	 spix, MFSEL4, 27,        none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12) | SLEW | GPO),
11588c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(227,	 spix, MFSEL4, 27,        none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12) | SLEW),
11598c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(228,   spixcs1, MFSEL4, 28,        none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12) | SLEW),
11608c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(229,	 spix, MFSEL4, 27,        none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12) | SLEW),
11618c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(230,	 spix, MFSEL4, 27,        none, NONE, 0,	none, NONE, 0,	     DSTR(8, 12) | SLEW),
11628c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(231,    clkreq, MFSEL4, 9,         none, NONE, 0,        none, NONE, 0,	     DSTR(8, 12)),
11638c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(253,	 none, NONE, 0,		  none, NONE, 0,	none, NONE, 0,	     GPI), /* SDHC1 power */
11648c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(254,	 none, NONE, 0,		  none, NONE, 0,	none, NONE, 0,	     GPI), /* SDHC2 power */
11658c2ecf20Sopenharmony_ci	NPCM7XX_PINCFG(255,	 none, NONE, 0,		  none, NONE, 0,	none, NONE, 0,	     GPI), /* DACOSEL */
11668c2ecf20Sopenharmony_ci};
11678c2ecf20Sopenharmony_ci
11688c2ecf20Sopenharmony_ci/* number, name, drv_data */
11698c2ecf20Sopenharmony_cistatic const struct pinctrl_pin_desc npcm7xx_pins[] = {
11708c2ecf20Sopenharmony_ci	PINCTRL_PIN(0,	"GPIO0/IOX1DI"),
11718c2ecf20Sopenharmony_ci	PINCTRL_PIN(1,	"GPIO1/IOX1LD"),
11728c2ecf20Sopenharmony_ci	PINCTRL_PIN(2,	"GPIO2/IOX1CK"),
11738c2ecf20Sopenharmony_ci	PINCTRL_PIN(3,	"GPIO3/IOX1D0"),
11748c2ecf20Sopenharmony_ci	PINCTRL_PIN(4,	"GPIO4/IOX2DI/SMB1DSDA"),
11758c2ecf20Sopenharmony_ci	PINCTRL_PIN(5,	"GPIO5/IOX2LD/SMB1DSCL"),
11768c2ecf20Sopenharmony_ci	PINCTRL_PIN(6,	"GPIO6/IOX2CK/SMB2DSDA"),
11778c2ecf20Sopenharmony_ci	PINCTRL_PIN(7,	"GPIO7/IOX2D0/SMB2DSCL"),
11788c2ecf20Sopenharmony_ci	PINCTRL_PIN(8,	"GPIO8/LKGPO1"),
11798c2ecf20Sopenharmony_ci	PINCTRL_PIN(9,	"GPIO9/LKGPO2"),
11808c2ecf20Sopenharmony_ci	PINCTRL_PIN(10, "GPIO10/IOXHLD"),
11818c2ecf20Sopenharmony_ci	PINCTRL_PIN(11, "GPIO11/IOXHCK"),
11828c2ecf20Sopenharmony_ci	PINCTRL_PIN(12, "GPIO12/GSPICK/SMB5BSCL"),
11838c2ecf20Sopenharmony_ci	PINCTRL_PIN(13, "GPIO13/GSPIDO/SMB5BSDA"),
11848c2ecf20Sopenharmony_ci	PINCTRL_PIN(14, "GPIO14/GSPIDI/SMB5CSCL"),
11858c2ecf20Sopenharmony_ci	PINCTRL_PIN(15, "GPIO15/GSPICS/SMB5CSDA"),
11868c2ecf20Sopenharmony_ci	PINCTRL_PIN(16, "GPIO16/LKGPO0"),
11878c2ecf20Sopenharmony_ci	PINCTRL_PIN(17, "GPIO17/PSPI2DI/SMB4DEN"),
11888c2ecf20Sopenharmony_ci	PINCTRL_PIN(18, "GPIO18/PSPI2D0/SMB4BSDA"),
11898c2ecf20Sopenharmony_ci	PINCTRL_PIN(19, "GPIO19/PSPI2CK/SMB4BSCL"),
11908c2ecf20Sopenharmony_ci	PINCTRL_PIN(20, "GPIO20/SMB4CSDA/SMB15SDA"),
11918c2ecf20Sopenharmony_ci	PINCTRL_PIN(21, "GPIO21/SMB4CSCL/SMB15SCL"),
11928c2ecf20Sopenharmony_ci	PINCTRL_PIN(22, "GPIO22/SMB4DSDA/SMB14SDA"),
11938c2ecf20Sopenharmony_ci	PINCTRL_PIN(23, "GPIO23/SMB4DSCL/SMB14SCL"),
11948c2ecf20Sopenharmony_ci	PINCTRL_PIN(24, "GPIO24/IOXHDO"),
11958c2ecf20Sopenharmony_ci	PINCTRL_PIN(25, "GPIO25/IOXHDI"),
11968c2ecf20Sopenharmony_ci	PINCTRL_PIN(26, "GPIO26/SMB5SDA"),
11978c2ecf20Sopenharmony_ci	PINCTRL_PIN(27, "GPIO27/SMB5SCL"),
11988c2ecf20Sopenharmony_ci	PINCTRL_PIN(28, "GPIO28/SMB4SDA"),
11998c2ecf20Sopenharmony_ci	PINCTRL_PIN(29, "GPIO29/SMB4SCL"),
12008c2ecf20Sopenharmony_ci	PINCTRL_PIN(30, "GPIO30/SMB3SDA"),
12018c2ecf20Sopenharmony_ci	PINCTRL_PIN(31, "GPIO31/SMB3SCL"),
12028c2ecf20Sopenharmony_ci
12038c2ecf20Sopenharmony_ci	PINCTRL_PIN(32, "GPIO32/nSPI0CS1"),
12048c2ecf20Sopenharmony_ci	PINCTRL_PIN(33, "SPI0D2"),
12058c2ecf20Sopenharmony_ci	PINCTRL_PIN(34, "SPI0D3"),
12068c2ecf20Sopenharmony_ci	PINCTRL_PIN(37, "GPIO37/SMB3CSDA"),
12078c2ecf20Sopenharmony_ci	PINCTRL_PIN(38, "GPIO38/SMB3CSCL"),
12088c2ecf20Sopenharmony_ci	PINCTRL_PIN(39, "GPIO39/SMB3BSDA"),
12098c2ecf20Sopenharmony_ci	PINCTRL_PIN(40, "GPIO40/SMB3BSCL"),
12108c2ecf20Sopenharmony_ci	PINCTRL_PIN(41, "GPIO41/BSPRXD"),
12118c2ecf20Sopenharmony_ci	PINCTRL_PIN(42, "GPO42/BSPTXD/STRAP11"),
12128c2ecf20Sopenharmony_ci	PINCTRL_PIN(43, "GPIO43/RXD1/JTMS2/BU1RXD"),
12138c2ecf20Sopenharmony_ci	PINCTRL_PIN(44, "GPIO44/nCTS1/JTDI2/BU1CTS"),
12148c2ecf20Sopenharmony_ci	PINCTRL_PIN(45, "GPIO45/nDCD1/JTDO2"),
12158c2ecf20Sopenharmony_ci	PINCTRL_PIN(46, "GPIO46/nDSR1/JTCK2"),
12168c2ecf20Sopenharmony_ci	PINCTRL_PIN(47, "GPIO47/nRI1/JCP_RDY2"),
12178c2ecf20Sopenharmony_ci	PINCTRL_PIN(48, "GPIO48/TXD2/BSPTXD"),
12188c2ecf20Sopenharmony_ci	PINCTRL_PIN(49, "GPIO49/RXD2/BSPRXD"),
12198c2ecf20Sopenharmony_ci	PINCTRL_PIN(50, "GPIO50/nCTS2"),
12208c2ecf20Sopenharmony_ci	PINCTRL_PIN(51, "GPO51/nRTS2/STRAP2"),
12218c2ecf20Sopenharmony_ci	PINCTRL_PIN(52, "GPIO52/nDCD2"),
12228c2ecf20Sopenharmony_ci	PINCTRL_PIN(53, "GPO53/nDTR2_BOUT2/STRAP1"),
12238c2ecf20Sopenharmony_ci	PINCTRL_PIN(54, "GPIO54/nDSR2"),
12248c2ecf20Sopenharmony_ci	PINCTRL_PIN(55, "GPIO55/nRI2"),
12258c2ecf20Sopenharmony_ci	PINCTRL_PIN(56, "GPIO56/R1RXERR"),
12268c2ecf20Sopenharmony_ci	PINCTRL_PIN(57, "GPIO57/R1MDC"),
12278c2ecf20Sopenharmony_ci	PINCTRL_PIN(58, "GPIO58/R1MDIO"),
12288c2ecf20Sopenharmony_ci	PINCTRL_PIN(59, "GPIO59/SMB3DSDA"),
12298c2ecf20Sopenharmony_ci	PINCTRL_PIN(60, "GPIO60/SMB3DSCL"),
12308c2ecf20Sopenharmony_ci	PINCTRL_PIN(61, "GPO61/nDTR1_BOUT1/STRAP6"),
12318c2ecf20Sopenharmony_ci	PINCTRL_PIN(62, "GPO62/nRTST1/STRAP5"),
12328c2ecf20Sopenharmony_ci	PINCTRL_PIN(63, "GPO63/TXD1/STRAP4"),
12338c2ecf20Sopenharmony_ci
12348c2ecf20Sopenharmony_ci	PINCTRL_PIN(64, "GPIO64/FANIN0"),
12358c2ecf20Sopenharmony_ci	PINCTRL_PIN(65, "GPIO65/FANIN1"),
12368c2ecf20Sopenharmony_ci	PINCTRL_PIN(66, "GPIO66/FANIN2"),
12378c2ecf20Sopenharmony_ci	PINCTRL_PIN(67, "GPIO67/FANIN3"),
12388c2ecf20Sopenharmony_ci	PINCTRL_PIN(68, "GPIO68/FANIN4"),
12398c2ecf20Sopenharmony_ci	PINCTRL_PIN(69, "GPIO69/FANIN5"),
12408c2ecf20Sopenharmony_ci	PINCTRL_PIN(70, "GPIO70/FANIN6"),
12418c2ecf20Sopenharmony_ci	PINCTRL_PIN(71, "GPIO71/FANIN7"),
12428c2ecf20Sopenharmony_ci	PINCTRL_PIN(72, "GPIO72/FANIN8"),
12438c2ecf20Sopenharmony_ci	PINCTRL_PIN(73, "GPIO73/FANIN9"),
12448c2ecf20Sopenharmony_ci	PINCTRL_PIN(74, "GPIO74/FANIN10"),
12458c2ecf20Sopenharmony_ci	PINCTRL_PIN(75, "GPIO75/FANIN11"),
12468c2ecf20Sopenharmony_ci	PINCTRL_PIN(76, "GPIO76/FANIN12"),
12478c2ecf20Sopenharmony_ci	PINCTRL_PIN(77, "GPIO77/FANIN13"),
12488c2ecf20Sopenharmony_ci	PINCTRL_PIN(78, "GPIO78/FANIN14"),
12498c2ecf20Sopenharmony_ci	PINCTRL_PIN(79, "GPIO79/FANIN15"),
12508c2ecf20Sopenharmony_ci	PINCTRL_PIN(80, "GPIO80/PWM0"),
12518c2ecf20Sopenharmony_ci	PINCTRL_PIN(81, "GPIO81/PWM1"),
12528c2ecf20Sopenharmony_ci	PINCTRL_PIN(82, "GPIO82/PWM2"),
12538c2ecf20Sopenharmony_ci	PINCTRL_PIN(83, "GPIO83/PWM3"),
12548c2ecf20Sopenharmony_ci	PINCTRL_PIN(84, "GPIO84/R2TXD0"),
12558c2ecf20Sopenharmony_ci	PINCTRL_PIN(85, "GPIO85/R2TXD1"),
12568c2ecf20Sopenharmony_ci	PINCTRL_PIN(86, "GPIO86/R2TXEN"),
12578c2ecf20Sopenharmony_ci	PINCTRL_PIN(87, "GPIO87/R2RXD0"),
12588c2ecf20Sopenharmony_ci	PINCTRL_PIN(88, "GPIO88/R2RXD1"),
12598c2ecf20Sopenharmony_ci	PINCTRL_PIN(89, "GPIO89/R2CRSDV"),
12608c2ecf20Sopenharmony_ci	PINCTRL_PIN(90, "GPIO90/R2RXERR"),
12618c2ecf20Sopenharmony_ci	PINCTRL_PIN(91, "GPIO91/R2MDC"),
12628c2ecf20Sopenharmony_ci	PINCTRL_PIN(92, "GPIO92/R2MDIO"),
12638c2ecf20Sopenharmony_ci	PINCTRL_PIN(93, "GPIO93/GA20/SMB5DSCL"),
12648c2ecf20Sopenharmony_ci	PINCTRL_PIN(94, "GPIO94/nKBRST/SMB5DSDA"),
12658c2ecf20Sopenharmony_ci	PINCTRL_PIN(95, "GPIO95/nLRESET/nESPIRST"),
12668c2ecf20Sopenharmony_ci
12678c2ecf20Sopenharmony_ci	PINCTRL_PIN(96, "GPIO96/RG1TXD0"),
12688c2ecf20Sopenharmony_ci	PINCTRL_PIN(97, "GPIO97/RG1TXD1"),
12698c2ecf20Sopenharmony_ci	PINCTRL_PIN(98, "GPIO98/RG1TXD2"),
12708c2ecf20Sopenharmony_ci	PINCTRL_PIN(99, "GPIO99/RG1TXD3"),
12718c2ecf20Sopenharmony_ci	PINCTRL_PIN(100, "GPIO100/RG1TXC"),
12728c2ecf20Sopenharmony_ci	PINCTRL_PIN(101, "GPIO101/RG1TXCTL"),
12738c2ecf20Sopenharmony_ci	PINCTRL_PIN(102, "GPIO102/RG1RXD0"),
12748c2ecf20Sopenharmony_ci	PINCTRL_PIN(103, "GPIO103/RG1RXD1"),
12758c2ecf20Sopenharmony_ci	PINCTRL_PIN(104, "GPIO104/RG1RXD2"),
12768c2ecf20Sopenharmony_ci	PINCTRL_PIN(105, "GPIO105/RG1RXD3"),
12778c2ecf20Sopenharmony_ci	PINCTRL_PIN(106, "GPIO106/RG1RXC"),
12788c2ecf20Sopenharmony_ci	PINCTRL_PIN(107, "GPIO107/RG1RXCTL"),
12798c2ecf20Sopenharmony_ci	PINCTRL_PIN(108, "GPIO108/RG1MDC"),
12808c2ecf20Sopenharmony_ci	PINCTRL_PIN(109, "GPIO109/RG1MDIO"),
12818c2ecf20Sopenharmony_ci	PINCTRL_PIN(110, "GPIO110/RG2TXD0/DDRV0"),
12828c2ecf20Sopenharmony_ci	PINCTRL_PIN(111, "GPIO111/RG2TXD1/DDRV1"),
12838c2ecf20Sopenharmony_ci	PINCTRL_PIN(112, "GPIO112/RG2TXD2/DDRV2"),
12848c2ecf20Sopenharmony_ci	PINCTRL_PIN(113, "GPIO113/RG2TXD3/DDRV3"),
12858c2ecf20Sopenharmony_ci	PINCTRL_PIN(114, "GPIO114/SMB0SCL"),
12868c2ecf20Sopenharmony_ci	PINCTRL_PIN(115, "GPIO115/SMB0SDA"),
12878c2ecf20Sopenharmony_ci	PINCTRL_PIN(116, "GPIO116/SMB1SCL"),
12888c2ecf20Sopenharmony_ci	PINCTRL_PIN(117, "GPIO117/SMB1SDA"),
12898c2ecf20Sopenharmony_ci	PINCTRL_PIN(118, "GPIO118/SMB2SCL"),
12908c2ecf20Sopenharmony_ci	PINCTRL_PIN(119, "GPIO119/SMB2SDA"),
12918c2ecf20Sopenharmony_ci	PINCTRL_PIN(120, "GPIO120/SMB2CSDA"),
12928c2ecf20Sopenharmony_ci	PINCTRL_PIN(121, "GPIO121/SMB2CSCL"),
12938c2ecf20Sopenharmony_ci	PINCTRL_PIN(122, "GPIO122/SMB2BSDA"),
12948c2ecf20Sopenharmony_ci	PINCTRL_PIN(123, "GPIO123/SMB2BSCL"),
12958c2ecf20Sopenharmony_ci	PINCTRL_PIN(124, "GPIO124/SMB1CSDA"),
12968c2ecf20Sopenharmony_ci	PINCTRL_PIN(125, "GPIO125/SMB1CSCL"),
12978c2ecf20Sopenharmony_ci	PINCTRL_PIN(126, "GPIO126/SMB1BSDA"),
12988c2ecf20Sopenharmony_ci	PINCTRL_PIN(127, "GPIO127/SMB1BSCL"),
12998c2ecf20Sopenharmony_ci
13008c2ecf20Sopenharmony_ci	PINCTRL_PIN(128, "GPIO128/SMB8SCL"),
13018c2ecf20Sopenharmony_ci	PINCTRL_PIN(129, "GPIO129/SMB8SDA"),
13028c2ecf20Sopenharmony_ci	PINCTRL_PIN(130, "GPIO130/SMB9SCL"),
13038c2ecf20Sopenharmony_ci	PINCTRL_PIN(131, "GPIO131/SMB9SDA"),
13048c2ecf20Sopenharmony_ci	PINCTRL_PIN(132, "GPIO132/SMB10SCL"),
13058c2ecf20Sopenharmony_ci	PINCTRL_PIN(133, "GPIO133/SMB10SDA"),
13068c2ecf20Sopenharmony_ci	PINCTRL_PIN(134, "GPIO134/SMB11SCL"),
13078c2ecf20Sopenharmony_ci	PINCTRL_PIN(135, "GPIO135/SMB11SDA"),
13088c2ecf20Sopenharmony_ci	PINCTRL_PIN(136, "GPIO136/SD1DT0"),
13098c2ecf20Sopenharmony_ci	PINCTRL_PIN(137, "GPIO137/SD1DT1"),
13108c2ecf20Sopenharmony_ci	PINCTRL_PIN(138, "GPIO138/SD1DT2"),
13118c2ecf20Sopenharmony_ci	PINCTRL_PIN(139, "GPIO139/SD1DT3"),
13128c2ecf20Sopenharmony_ci	PINCTRL_PIN(140, "GPIO140/SD1CLK"),
13138c2ecf20Sopenharmony_ci	PINCTRL_PIN(141, "GPIO141/SD1WP"),
13148c2ecf20Sopenharmony_ci	PINCTRL_PIN(142, "GPIO142/SD1CMD"),
13158c2ecf20Sopenharmony_ci	PINCTRL_PIN(143, "GPIO143/SD1CD/SD1PWR"),
13168c2ecf20Sopenharmony_ci	PINCTRL_PIN(144, "GPIO144/PWM4"),
13178c2ecf20Sopenharmony_ci	PINCTRL_PIN(145, "GPIO145/PWM5"),
13188c2ecf20Sopenharmony_ci	PINCTRL_PIN(146, "GPIO146/PWM6"),
13198c2ecf20Sopenharmony_ci	PINCTRL_PIN(147, "GPIO147/PWM7"),
13208c2ecf20Sopenharmony_ci	PINCTRL_PIN(148, "GPIO148/MMCDT4"),
13218c2ecf20Sopenharmony_ci	PINCTRL_PIN(149, "GPIO149/MMCDT5"),
13228c2ecf20Sopenharmony_ci	PINCTRL_PIN(150, "GPIO150/MMCDT6"),
13238c2ecf20Sopenharmony_ci	PINCTRL_PIN(151, "GPIO151/MMCDT7"),
13248c2ecf20Sopenharmony_ci	PINCTRL_PIN(152, "GPIO152/MMCCLK"),
13258c2ecf20Sopenharmony_ci	PINCTRL_PIN(153, "GPIO153/MMCWP"),
13268c2ecf20Sopenharmony_ci	PINCTRL_PIN(154, "GPIO154/MMCCMD"),
13278c2ecf20Sopenharmony_ci	PINCTRL_PIN(155, "GPIO155/nMMCCD/nMMCRST"),
13288c2ecf20Sopenharmony_ci	PINCTRL_PIN(156, "GPIO156/MMCDT0"),
13298c2ecf20Sopenharmony_ci	PINCTRL_PIN(157, "GPIO157/MMCDT1"),
13308c2ecf20Sopenharmony_ci	PINCTRL_PIN(158, "GPIO158/MMCDT2"),
13318c2ecf20Sopenharmony_ci	PINCTRL_PIN(159, "GPIO159/MMCDT3"),
13328c2ecf20Sopenharmony_ci
13338c2ecf20Sopenharmony_ci	PINCTRL_PIN(160, "GPIO160/CLKOUT/RNGOSCOUT"),
13348c2ecf20Sopenharmony_ci	PINCTRL_PIN(161, "GPIO161/nLFRAME/nESPICS"),
13358c2ecf20Sopenharmony_ci	PINCTRL_PIN(162, "GPIO162/SERIRQ"),
13368c2ecf20Sopenharmony_ci	PINCTRL_PIN(163, "GPIO163/LCLK/ESPICLK"),
13378c2ecf20Sopenharmony_ci	PINCTRL_PIN(164, "GPIO164/LAD0/ESPI_IO0"/*dscnt6*/),
13388c2ecf20Sopenharmony_ci	PINCTRL_PIN(165, "GPIO165/LAD1/ESPI_IO1"/*dscnt6*/),
13398c2ecf20Sopenharmony_ci	PINCTRL_PIN(166, "GPIO166/LAD2/ESPI_IO2"/*dscnt6*/),
13408c2ecf20Sopenharmony_ci	PINCTRL_PIN(167, "GPIO167/LAD3/ESPI_IO3"/*dscnt6*/),
13418c2ecf20Sopenharmony_ci	PINCTRL_PIN(168, "GPIO168/nCLKRUN/nESPIALERT"),
13428c2ecf20Sopenharmony_ci	PINCTRL_PIN(169, "GPIO169/nSCIPME"),
13438c2ecf20Sopenharmony_ci	PINCTRL_PIN(170, "GPIO170/nSMI"),
13448c2ecf20Sopenharmony_ci	PINCTRL_PIN(171, "GPIO171/SMB6SCL"),
13458c2ecf20Sopenharmony_ci	PINCTRL_PIN(172, "GPIO172/SMB6SDA"),
13468c2ecf20Sopenharmony_ci	PINCTRL_PIN(173, "GPIO173/SMB7SCL"),
13478c2ecf20Sopenharmony_ci	PINCTRL_PIN(174, "GPIO174/SMB7SDA"),
13488c2ecf20Sopenharmony_ci	PINCTRL_PIN(175, "GPIO175/PSPI1CK/FANIN19"),
13498c2ecf20Sopenharmony_ci	PINCTRL_PIN(176, "GPIO176/PSPI1DO/FANIN18"),
13508c2ecf20Sopenharmony_ci	PINCTRL_PIN(177, "GPIO177/PSPI1DI/FANIN17"),
13518c2ecf20Sopenharmony_ci	PINCTRL_PIN(178, "GPIO178/R1TXD0"),
13528c2ecf20Sopenharmony_ci	PINCTRL_PIN(179, "GPIO179/R1TXD1"),
13538c2ecf20Sopenharmony_ci	PINCTRL_PIN(180, "GPIO180/R1TXEN"),
13548c2ecf20Sopenharmony_ci	PINCTRL_PIN(181, "GPIO181/R1RXD0"),
13558c2ecf20Sopenharmony_ci	PINCTRL_PIN(182, "GPIO182/R1RXD1"),
13568c2ecf20Sopenharmony_ci	PINCTRL_PIN(183, "GPIO183/SPI3CK"),
13578c2ecf20Sopenharmony_ci	PINCTRL_PIN(184, "GPO184/SPI3D0/STRAP9"),
13588c2ecf20Sopenharmony_ci	PINCTRL_PIN(185, "GPO185/SPI3D1/STRAP10"),
13598c2ecf20Sopenharmony_ci	PINCTRL_PIN(186, "GPIO186/nSPI3CS0"),
13608c2ecf20Sopenharmony_ci	PINCTRL_PIN(187, "GPIO187/nSPI3CS1"),
13618c2ecf20Sopenharmony_ci	PINCTRL_PIN(188, "GPIO188/SPI3D2/nSPI3CS2"),
13628c2ecf20Sopenharmony_ci	PINCTRL_PIN(189, "GPIO189/SPI3D3/nSPI3CS3"),
13638c2ecf20Sopenharmony_ci	PINCTRL_PIN(190, "GPIO190/nPRD_SMI"),
13648c2ecf20Sopenharmony_ci	PINCTRL_PIN(191, "GPIO191"),
13658c2ecf20Sopenharmony_ci
13668c2ecf20Sopenharmony_ci	PINCTRL_PIN(192, "GPIO192"),
13678c2ecf20Sopenharmony_ci	PINCTRL_PIN(193, "GPIO193/R1CRSDV"),
13688c2ecf20Sopenharmony_ci	PINCTRL_PIN(194, "GPIO194/SMB0BSCL"),
13698c2ecf20Sopenharmony_ci	PINCTRL_PIN(195, "GPIO195/SMB0BSDA"),
13708c2ecf20Sopenharmony_ci	PINCTRL_PIN(196, "GPIO196/SMB0CSCL"),
13718c2ecf20Sopenharmony_ci	PINCTRL_PIN(197, "GPIO197/SMB0DEN"),
13728c2ecf20Sopenharmony_ci	PINCTRL_PIN(198, "GPIO198/SMB0DSDA"),
13738c2ecf20Sopenharmony_ci	PINCTRL_PIN(199, "GPIO199/SMB0DSCL"),
13748c2ecf20Sopenharmony_ci	PINCTRL_PIN(200, "GPIO200/R2CK"),
13758c2ecf20Sopenharmony_ci	PINCTRL_PIN(201, "GPIO201/R1CK"),
13768c2ecf20Sopenharmony_ci	PINCTRL_PIN(202, "GPIO202/SMB0CSDA"),
13778c2ecf20Sopenharmony_ci	PINCTRL_PIN(203, "GPIO203/FANIN16"),
13788c2ecf20Sopenharmony_ci	PINCTRL_PIN(204, "GPIO204/DDC2SCL"),
13798c2ecf20Sopenharmony_ci	PINCTRL_PIN(205, "GPIO205/DDC2SDA"),
13808c2ecf20Sopenharmony_ci	PINCTRL_PIN(206, "GPIO206/HSYNC2"),
13818c2ecf20Sopenharmony_ci	PINCTRL_PIN(207, "GPIO207/VSYNC2"),
13828c2ecf20Sopenharmony_ci	PINCTRL_PIN(208, "GPIO208/RG2TXC/DVCK"),
13838c2ecf20Sopenharmony_ci	PINCTRL_PIN(209, "GPIO209/RG2TXCTL/DDRV4"),
13848c2ecf20Sopenharmony_ci	PINCTRL_PIN(210, "GPIO210/RG2RXD0/DDRV5"),
13858c2ecf20Sopenharmony_ci	PINCTRL_PIN(211, "GPIO211/RG2RXD1/DDRV6"),
13868c2ecf20Sopenharmony_ci	PINCTRL_PIN(212, "GPIO212/RG2RXD2/DDRV7"),
13878c2ecf20Sopenharmony_ci	PINCTRL_PIN(213, "GPIO213/RG2RXD3/DDRV8"),
13888c2ecf20Sopenharmony_ci	PINCTRL_PIN(214, "GPIO214/RG2RXC/DDRV9"),
13898c2ecf20Sopenharmony_ci	PINCTRL_PIN(215, "GPIO215/RG2RXCTL/DDRV10"),
13908c2ecf20Sopenharmony_ci	PINCTRL_PIN(216, "GPIO216/RG2MDC/DDRV11"),
13918c2ecf20Sopenharmony_ci	PINCTRL_PIN(217, "GPIO217/RG2MDIO/DVHSYNC"),
13928c2ecf20Sopenharmony_ci	PINCTRL_PIN(218, "GPIO218/nWDO1"),
13938c2ecf20Sopenharmony_ci	PINCTRL_PIN(219, "GPIO219/nWDO2"),
13948c2ecf20Sopenharmony_ci	PINCTRL_PIN(220, "GPIO220/SMB12SCL"),
13958c2ecf20Sopenharmony_ci	PINCTRL_PIN(221, "GPIO221/SMB12SDA"),
13968c2ecf20Sopenharmony_ci	PINCTRL_PIN(222, "GPIO222/SMB13SCL"),
13978c2ecf20Sopenharmony_ci	PINCTRL_PIN(223, "GPIO223/SMB13SDA"),
13988c2ecf20Sopenharmony_ci
13998c2ecf20Sopenharmony_ci	PINCTRL_PIN(224, "GPIO224/SPIXCK"),
14008c2ecf20Sopenharmony_ci	PINCTRL_PIN(225, "GPO225/SPIXD0/STRAP12"),
14018c2ecf20Sopenharmony_ci	PINCTRL_PIN(226, "GPO226/SPIXD1/STRAP13"),
14028c2ecf20Sopenharmony_ci	PINCTRL_PIN(227, "GPIO227/nSPIXCS0"),
14038c2ecf20Sopenharmony_ci	PINCTRL_PIN(228, "GPIO228/nSPIXCS1"),
14048c2ecf20Sopenharmony_ci	PINCTRL_PIN(229, "GPO229/SPIXD2/STRAP3"),
14058c2ecf20Sopenharmony_ci	PINCTRL_PIN(230, "GPIO230/SPIXD3"),
14068c2ecf20Sopenharmony_ci	PINCTRL_PIN(231, "GPIO231/nCLKREQ"),
14078c2ecf20Sopenharmony_ci	PINCTRL_PIN(255, "GPI255/DACOSEL"),
14088c2ecf20Sopenharmony_ci};
14098c2ecf20Sopenharmony_ci
14108c2ecf20Sopenharmony_ci/* Enable mode in pin group */
14118c2ecf20Sopenharmony_cistatic void npcm7xx_setfunc(struct regmap *gcr_regmap, const unsigned int *pin,
14128c2ecf20Sopenharmony_ci			    int pin_number, int mode)
14138c2ecf20Sopenharmony_ci{
14148c2ecf20Sopenharmony_ci	const struct npcm7xx_pincfg *cfg;
14158c2ecf20Sopenharmony_ci	int i;
14168c2ecf20Sopenharmony_ci
14178c2ecf20Sopenharmony_ci	for (i = 0 ; i < pin_number ; i++) {
14188c2ecf20Sopenharmony_ci		cfg = &pincfg[pin[i]];
14198c2ecf20Sopenharmony_ci		if (mode == fn_gpio || cfg->fn0 == mode || cfg->fn1 == mode || cfg->fn2 == mode) {
14208c2ecf20Sopenharmony_ci			if (cfg->reg0)
14218c2ecf20Sopenharmony_ci				regmap_update_bits(gcr_regmap, cfg->reg0,
14228c2ecf20Sopenharmony_ci						   BIT(cfg->bit0),
14238c2ecf20Sopenharmony_ci						   !!(cfg->fn0 == mode) ?
14248c2ecf20Sopenharmony_ci						   BIT(cfg->bit0) : 0);
14258c2ecf20Sopenharmony_ci			if (cfg->reg1)
14268c2ecf20Sopenharmony_ci				regmap_update_bits(gcr_regmap, cfg->reg1,
14278c2ecf20Sopenharmony_ci						   BIT(cfg->bit1),
14288c2ecf20Sopenharmony_ci						   !!(cfg->fn1 == mode) ?
14298c2ecf20Sopenharmony_ci						   BIT(cfg->bit1) : 0);
14308c2ecf20Sopenharmony_ci			if (cfg->reg2)
14318c2ecf20Sopenharmony_ci				regmap_update_bits(gcr_regmap, cfg->reg2,
14328c2ecf20Sopenharmony_ci						   BIT(cfg->bit2),
14338c2ecf20Sopenharmony_ci						   !!(cfg->fn2 == mode) ?
14348c2ecf20Sopenharmony_ci						   BIT(cfg->bit2) : 0);
14358c2ecf20Sopenharmony_ci		}
14368c2ecf20Sopenharmony_ci	}
14378c2ecf20Sopenharmony_ci}
14388c2ecf20Sopenharmony_ci
14398c2ecf20Sopenharmony_ci/* Get slew rate of pin (high/low) */
14408c2ecf20Sopenharmony_cistatic int npcm7xx_get_slew_rate(struct npcm7xx_gpio *bank,
14418c2ecf20Sopenharmony_ci				 struct regmap *gcr_regmap, unsigned int pin)
14428c2ecf20Sopenharmony_ci{
14438c2ecf20Sopenharmony_ci	u32 val;
14448c2ecf20Sopenharmony_ci	int gpio = (pin % bank->gc.ngpio);
14458c2ecf20Sopenharmony_ci	unsigned long pinmask = BIT(gpio);
14468c2ecf20Sopenharmony_ci
14478c2ecf20Sopenharmony_ci	if (pincfg[pin].flag & SLEW)
14488c2ecf20Sopenharmony_ci		return ioread32(bank->base + NPCM7XX_GP_N_OSRC)
14498c2ecf20Sopenharmony_ci		& pinmask;
14508c2ecf20Sopenharmony_ci	/* LPC Slew rate in SRCNT register */
14518c2ecf20Sopenharmony_ci	if (pincfg[pin].flag & SLEWLPC) {
14528c2ecf20Sopenharmony_ci		regmap_read(gcr_regmap, NPCM7XX_GCR_SRCNT, &val);
14538c2ecf20Sopenharmony_ci		return !!(val & SRCNT_ESPI);
14548c2ecf20Sopenharmony_ci	}
14558c2ecf20Sopenharmony_ci
14568c2ecf20Sopenharmony_ci	return -EINVAL;
14578c2ecf20Sopenharmony_ci}
14588c2ecf20Sopenharmony_ci
14598c2ecf20Sopenharmony_ci/* Set slew rate of pin (high/low) */
14608c2ecf20Sopenharmony_cistatic int npcm7xx_set_slew_rate(struct npcm7xx_gpio *bank,
14618c2ecf20Sopenharmony_ci				 struct regmap *gcr_regmap, unsigned int pin,
14628c2ecf20Sopenharmony_ci				 int arg)
14638c2ecf20Sopenharmony_ci{
14648c2ecf20Sopenharmony_ci	int gpio = BIT(pin % bank->gc.ngpio);
14658c2ecf20Sopenharmony_ci
14668c2ecf20Sopenharmony_ci	if (pincfg[pin].flag & SLEW) {
14678c2ecf20Sopenharmony_ci		switch (arg) {
14688c2ecf20Sopenharmony_ci		case 0:
14698c2ecf20Sopenharmony_ci			npcm_gpio_clr(&bank->gc, bank->base + NPCM7XX_GP_N_OSRC,
14708c2ecf20Sopenharmony_ci				      gpio);
14718c2ecf20Sopenharmony_ci			return 0;
14728c2ecf20Sopenharmony_ci		case 1:
14738c2ecf20Sopenharmony_ci			npcm_gpio_set(&bank->gc, bank->base + NPCM7XX_GP_N_OSRC,
14748c2ecf20Sopenharmony_ci				      gpio);
14758c2ecf20Sopenharmony_ci			return 0;
14768c2ecf20Sopenharmony_ci		default:
14778c2ecf20Sopenharmony_ci			return -EINVAL;
14788c2ecf20Sopenharmony_ci		}
14798c2ecf20Sopenharmony_ci	}
14808c2ecf20Sopenharmony_ci	/* LPC Slew rate in SRCNT register */
14818c2ecf20Sopenharmony_ci	if (pincfg[pin].flag & SLEWLPC) {
14828c2ecf20Sopenharmony_ci		switch (arg) {
14838c2ecf20Sopenharmony_ci		case 0:
14848c2ecf20Sopenharmony_ci			regmap_update_bits(gcr_regmap, NPCM7XX_GCR_SRCNT,
14858c2ecf20Sopenharmony_ci					   SRCNT_ESPI, 0);
14868c2ecf20Sopenharmony_ci			return 0;
14878c2ecf20Sopenharmony_ci		case 1:
14888c2ecf20Sopenharmony_ci			regmap_update_bits(gcr_regmap, NPCM7XX_GCR_SRCNT,
14898c2ecf20Sopenharmony_ci					   SRCNT_ESPI, SRCNT_ESPI);
14908c2ecf20Sopenharmony_ci			return 0;
14918c2ecf20Sopenharmony_ci		default:
14928c2ecf20Sopenharmony_ci			return -EINVAL;
14938c2ecf20Sopenharmony_ci		}
14948c2ecf20Sopenharmony_ci	}
14958c2ecf20Sopenharmony_ci
14968c2ecf20Sopenharmony_ci	return -EINVAL;
14978c2ecf20Sopenharmony_ci}
14988c2ecf20Sopenharmony_ci
14998c2ecf20Sopenharmony_ci/* Get drive strength for a pin, if supported */
15008c2ecf20Sopenharmony_cistatic int npcm7xx_get_drive_strength(struct pinctrl_dev *pctldev,
15018c2ecf20Sopenharmony_ci				      unsigned int pin)
15028c2ecf20Sopenharmony_ci{
15038c2ecf20Sopenharmony_ci	struct npcm7xx_pinctrl *npcm = pinctrl_dev_get_drvdata(pctldev);
15048c2ecf20Sopenharmony_ci	struct npcm7xx_gpio *bank =
15058c2ecf20Sopenharmony_ci		&npcm->gpio_bank[pin / NPCM7XX_GPIO_PER_BANK];
15068c2ecf20Sopenharmony_ci	int gpio = (pin % bank->gc.ngpio);
15078c2ecf20Sopenharmony_ci	unsigned long pinmask = BIT(gpio);
15088c2ecf20Sopenharmony_ci	u32 ds = 0;
15098c2ecf20Sopenharmony_ci	int flg, val;
15108c2ecf20Sopenharmony_ci
15118c2ecf20Sopenharmony_ci	flg = pincfg[pin].flag;
15128c2ecf20Sopenharmony_ci	if (flg & DRIVE_STRENGTH_MASK) {
15138c2ecf20Sopenharmony_ci		/* Get standard reading */
15148c2ecf20Sopenharmony_ci		val = ioread32(bank->base + NPCM7XX_GP_N_ODSC)
15158c2ecf20Sopenharmony_ci		& pinmask;
15168c2ecf20Sopenharmony_ci		ds = val ? DSHI(flg) : DSLO(flg);
15178c2ecf20Sopenharmony_ci		dev_dbg(bank->gc.parent,
15188c2ecf20Sopenharmony_ci			"pin %d strength %d = %d\n", pin, val, ds);
15198c2ecf20Sopenharmony_ci		return ds;
15208c2ecf20Sopenharmony_ci	}
15218c2ecf20Sopenharmony_ci
15228c2ecf20Sopenharmony_ci	return -EINVAL;
15238c2ecf20Sopenharmony_ci}
15248c2ecf20Sopenharmony_ci
15258c2ecf20Sopenharmony_ci/* Set drive strength for a pin, if supported */
15268c2ecf20Sopenharmony_cistatic int npcm7xx_set_drive_strength(struct npcm7xx_pinctrl *npcm,
15278c2ecf20Sopenharmony_ci				      unsigned int pin, int nval)
15288c2ecf20Sopenharmony_ci{
15298c2ecf20Sopenharmony_ci	int v;
15308c2ecf20Sopenharmony_ci	struct npcm7xx_gpio *bank =
15318c2ecf20Sopenharmony_ci		&npcm->gpio_bank[pin / NPCM7XX_GPIO_PER_BANK];
15328c2ecf20Sopenharmony_ci	int gpio = BIT(pin % bank->gc.ngpio);
15338c2ecf20Sopenharmony_ci
15348c2ecf20Sopenharmony_ci	v = (pincfg[pin].flag & DRIVE_STRENGTH_MASK);
15358c2ecf20Sopenharmony_ci	if (!nval || !v)
15368c2ecf20Sopenharmony_ci		return -ENOTSUPP;
15378c2ecf20Sopenharmony_ci	if (DSLO(v) == nval) {
15388c2ecf20Sopenharmony_ci		dev_dbg(bank->gc.parent,
15398c2ecf20Sopenharmony_ci			"setting pin %d to low strength [%d]\n", pin, nval);
15408c2ecf20Sopenharmony_ci		npcm_gpio_clr(&bank->gc, bank->base + NPCM7XX_GP_N_ODSC, gpio);
15418c2ecf20Sopenharmony_ci		return 0;
15428c2ecf20Sopenharmony_ci	} else if (DSHI(v) == nval) {
15438c2ecf20Sopenharmony_ci		dev_dbg(bank->gc.parent,
15448c2ecf20Sopenharmony_ci			"setting pin %d to high strength [%d]\n", pin, nval);
15458c2ecf20Sopenharmony_ci		npcm_gpio_set(&bank->gc, bank->base + NPCM7XX_GP_N_ODSC, gpio);
15468c2ecf20Sopenharmony_ci		return 0;
15478c2ecf20Sopenharmony_ci	}
15488c2ecf20Sopenharmony_ci
15498c2ecf20Sopenharmony_ci	return -ENOTSUPP;
15508c2ecf20Sopenharmony_ci}
15518c2ecf20Sopenharmony_ci
15528c2ecf20Sopenharmony_ci/* pinctrl_ops */
15538c2ecf20Sopenharmony_cistatic void npcm7xx_pin_dbg_show(struct pinctrl_dev *pctldev,
15548c2ecf20Sopenharmony_ci				 struct seq_file *s, unsigned int offset)
15558c2ecf20Sopenharmony_ci{
15568c2ecf20Sopenharmony_ci	seq_printf(s, "pinctrl_ops.dbg: %d", offset);
15578c2ecf20Sopenharmony_ci}
15588c2ecf20Sopenharmony_ci
15598c2ecf20Sopenharmony_cistatic int npcm7xx_get_groups_count(struct pinctrl_dev *pctldev)
15608c2ecf20Sopenharmony_ci{
15618c2ecf20Sopenharmony_ci	struct npcm7xx_pinctrl *npcm = pinctrl_dev_get_drvdata(pctldev);
15628c2ecf20Sopenharmony_ci
15638c2ecf20Sopenharmony_ci	dev_dbg(npcm->dev, "group size: %zu\n", ARRAY_SIZE(npcm7xx_groups));
15648c2ecf20Sopenharmony_ci	return ARRAY_SIZE(npcm7xx_groups);
15658c2ecf20Sopenharmony_ci}
15668c2ecf20Sopenharmony_ci
15678c2ecf20Sopenharmony_cistatic const char *npcm7xx_get_group_name(struct pinctrl_dev *pctldev,
15688c2ecf20Sopenharmony_ci					  unsigned int selector)
15698c2ecf20Sopenharmony_ci{
15708c2ecf20Sopenharmony_ci	return npcm7xx_groups[selector].name;
15718c2ecf20Sopenharmony_ci}
15728c2ecf20Sopenharmony_ci
15738c2ecf20Sopenharmony_cistatic int npcm7xx_get_group_pins(struct pinctrl_dev *pctldev,
15748c2ecf20Sopenharmony_ci				  unsigned int selector,
15758c2ecf20Sopenharmony_ci				  const unsigned int **pins,
15768c2ecf20Sopenharmony_ci				  unsigned int *npins)
15778c2ecf20Sopenharmony_ci{
15788c2ecf20Sopenharmony_ci	*npins = npcm7xx_groups[selector].npins;
15798c2ecf20Sopenharmony_ci	*pins  = npcm7xx_groups[selector].pins;
15808c2ecf20Sopenharmony_ci
15818c2ecf20Sopenharmony_ci	return 0;
15828c2ecf20Sopenharmony_ci}
15838c2ecf20Sopenharmony_ci
15848c2ecf20Sopenharmony_cistatic int npcm7xx_dt_node_to_map(struct pinctrl_dev *pctldev,
15858c2ecf20Sopenharmony_ci				  struct device_node *np_config,
15868c2ecf20Sopenharmony_ci				  struct pinctrl_map **map,
15878c2ecf20Sopenharmony_ci				  u32 *num_maps)
15888c2ecf20Sopenharmony_ci{
15898c2ecf20Sopenharmony_ci	struct npcm7xx_pinctrl *npcm = pinctrl_dev_get_drvdata(pctldev);
15908c2ecf20Sopenharmony_ci
15918c2ecf20Sopenharmony_ci	dev_dbg(npcm->dev, "dt_node_to_map: %s\n", np_config->name);
15928c2ecf20Sopenharmony_ci	return pinconf_generic_dt_node_to_map(pctldev, np_config,
15938c2ecf20Sopenharmony_ci					      map, num_maps,
15948c2ecf20Sopenharmony_ci					      PIN_MAP_TYPE_INVALID);
15958c2ecf20Sopenharmony_ci}
15968c2ecf20Sopenharmony_ci
15978c2ecf20Sopenharmony_cistatic void npcm7xx_dt_free_map(struct pinctrl_dev *pctldev,
15988c2ecf20Sopenharmony_ci				struct pinctrl_map *map, u32 num_maps)
15998c2ecf20Sopenharmony_ci{
16008c2ecf20Sopenharmony_ci	kfree(map);
16018c2ecf20Sopenharmony_ci}
16028c2ecf20Sopenharmony_ci
16038c2ecf20Sopenharmony_cistatic const struct pinctrl_ops npcm7xx_pinctrl_ops = {
16048c2ecf20Sopenharmony_ci	.get_groups_count = npcm7xx_get_groups_count,
16058c2ecf20Sopenharmony_ci	.get_group_name = npcm7xx_get_group_name,
16068c2ecf20Sopenharmony_ci	.get_group_pins = npcm7xx_get_group_pins,
16078c2ecf20Sopenharmony_ci	.pin_dbg_show = npcm7xx_pin_dbg_show,
16088c2ecf20Sopenharmony_ci	.dt_node_to_map = npcm7xx_dt_node_to_map,
16098c2ecf20Sopenharmony_ci	.dt_free_map = npcm7xx_dt_free_map,
16108c2ecf20Sopenharmony_ci};
16118c2ecf20Sopenharmony_ci
16128c2ecf20Sopenharmony_ci/* pinmux_ops  */
16138c2ecf20Sopenharmony_cistatic int npcm7xx_get_functions_count(struct pinctrl_dev *pctldev)
16148c2ecf20Sopenharmony_ci{
16158c2ecf20Sopenharmony_ci	return ARRAY_SIZE(npcm7xx_funcs);
16168c2ecf20Sopenharmony_ci}
16178c2ecf20Sopenharmony_ci
16188c2ecf20Sopenharmony_cistatic const char *npcm7xx_get_function_name(struct pinctrl_dev *pctldev,
16198c2ecf20Sopenharmony_ci					     unsigned int function)
16208c2ecf20Sopenharmony_ci{
16218c2ecf20Sopenharmony_ci	return npcm7xx_funcs[function].name;
16228c2ecf20Sopenharmony_ci}
16238c2ecf20Sopenharmony_ci
16248c2ecf20Sopenharmony_cistatic int npcm7xx_get_function_groups(struct pinctrl_dev *pctldev,
16258c2ecf20Sopenharmony_ci				       unsigned int function,
16268c2ecf20Sopenharmony_ci				       const char * const **groups,
16278c2ecf20Sopenharmony_ci				       unsigned int * const ngroups)
16288c2ecf20Sopenharmony_ci{
16298c2ecf20Sopenharmony_ci	*ngroups = npcm7xx_funcs[function].ngroups;
16308c2ecf20Sopenharmony_ci	*groups	 = npcm7xx_funcs[function].groups;
16318c2ecf20Sopenharmony_ci
16328c2ecf20Sopenharmony_ci	return 0;
16338c2ecf20Sopenharmony_ci}
16348c2ecf20Sopenharmony_ci
16358c2ecf20Sopenharmony_cistatic int npcm7xx_pinmux_set_mux(struct pinctrl_dev *pctldev,
16368c2ecf20Sopenharmony_ci				  unsigned int function,
16378c2ecf20Sopenharmony_ci				  unsigned int group)
16388c2ecf20Sopenharmony_ci{
16398c2ecf20Sopenharmony_ci	struct npcm7xx_pinctrl *npcm = pinctrl_dev_get_drvdata(pctldev);
16408c2ecf20Sopenharmony_ci
16418c2ecf20Sopenharmony_ci	dev_dbg(npcm->dev, "set_mux: %d, %d[%s]\n", function, group,
16428c2ecf20Sopenharmony_ci		npcm7xx_groups[group].name);
16438c2ecf20Sopenharmony_ci
16448c2ecf20Sopenharmony_ci	npcm7xx_setfunc(npcm->gcr_regmap, npcm7xx_groups[group].pins,
16458c2ecf20Sopenharmony_ci			npcm7xx_groups[group].npins, group);
16468c2ecf20Sopenharmony_ci
16478c2ecf20Sopenharmony_ci	return 0;
16488c2ecf20Sopenharmony_ci}
16498c2ecf20Sopenharmony_ci
16508c2ecf20Sopenharmony_cistatic int npcm7xx_gpio_request_enable(struct pinctrl_dev *pctldev,
16518c2ecf20Sopenharmony_ci				       struct pinctrl_gpio_range *range,
16528c2ecf20Sopenharmony_ci				       unsigned int offset)
16538c2ecf20Sopenharmony_ci{
16548c2ecf20Sopenharmony_ci	struct npcm7xx_pinctrl *npcm = pinctrl_dev_get_drvdata(pctldev);
16558c2ecf20Sopenharmony_ci
16568c2ecf20Sopenharmony_ci	if (!range) {
16578c2ecf20Sopenharmony_ci		dev_err(npcm->dev, "invalid range\n");
16588c2ecf20Sopenharmony_ci		return -EINVAL;
16598c2ecf20Sopenharmony_ci	}
16608c2ecf20Sopenharmony_ci	if (!range->gc) {
16618c2ecf20Sopenharmony_ci		dev_err(npcm->dev, "invalid gpiochip\n");
16628c2ecf20Sopenharmony_ci		return -EINVAL;
16638c2ecf20Sopenharmony_ci	}
16648c2ecf20Sopenharmony_ci
16658c2ecf20Sopenharmony_ci	npcm7xx_setfunc(npcm->gcr_regmap, &offset, 1, fn_gpio);
16668c2ecf20Sopenharmony_ci
16678c2ecf20Sopenharmony_ci	return 0;
16688c2ecf20Sopenharmony_ci}
16698c2ecf20Sopenharmony_ci
16708c2ecf20Sopenharmony_ci/* Release GPIO back to pinctrl mode */
16718c2ecf20Sopenharmony_cistatic void npcm7xx_gpio_request_free(struct pinctrl_dev *pctldev,
16728c2ecf20Sopenharmony_ci				      struct pinctrl_gpio_range *range,
16738c2ecf20Sopenharmony_ci				      unsigned int offset)
16748c2ecf20Sopenharmony_ci{
16758c2ecf20Sopenharmony_ci	struct npcm7xx_pinctrl *npcm = pinctrl_dev_get_drvdata(pctldev);
16768c2ecf20Sopenharmony_ci	int virq;
16778c2ecf20Sopenharmony_ci
16788c2ecf20Sopenharmony_ci	virq = irq_find_mapping(npcm->domain, offset);
16798c2ecf20Sopenharmony_ci	if (virq)
16808c2ecf20Sopenharmony_ci		irq_dispose_mapping(virq);
16818c2ecf20Sopenharmony_ci}
16828c2ecf20Sopenharmony_ci
16838c2ecf20Sopenharmony_ci/* Set GPIO direction */
16848c2ecf20Sopenharmony_cistatic int npcm_gpio_set_direction(struct pinctrl_dev *pctldev,
16858c2ecf20Sopenharmony_ci				   struct pinctrl_gpio_range *range,
16868c2ecf20Sopenharmony_ci				   unsigned int offset, bool input)
16878c2ecf20Sopenharmony_ci{
16888c2ecf20Sopenharmony_ci	struct npcm7xx_pinctrl *npcm = pinctrl_dev_get_drvdata(pctldev);
16898c2ecf20Sopenharmony_ci	struct npcm7xx_gpio *bank =
16908c2ecf20Sopenharmony_ci		&npcm->gpio_bank[offset / NPCM7XX_GPIO_PER_BANK];
16918c2ecf20Sopenharmony_ci	int gpio = BIT(offset % bank->gc.ngpio);
16928c2ecf20Sopenharmony_ci
16938c2ecf20Sopenharmony_ci	dev_dbg(bank->gc.parent, "GPIO Set Direction: %d = %d\n", offset,
16948c2ecf20Sopenharmony_ci		input);
16958c2ecf20Sopenharmony_ci	if (input)
16968c2ecf20Sopenharmony_ci		iowrite32(gpio, bank->base + NPCM7XX_GP_N_OEC);
16978c2ecf20Sopenharmony_ci	else
16988c2ecf20Sopenharmony_ci		iowrite32(gpio, bank->base + NPCM7XX_GP_N_OES);
16998c2ecf20Sopenharmony_ci
17008c2ecf20Sopenharmony_ci	return 0;
17018c2ecf20Sopenharmony_ci}
17028c2ecf20Sopenharmony_ci
17038c2ecf20Sopenharmony_cistatic const struct pinmux_ops npcm7xx_pinmux_ops = {
17048c2ecf20Sopenharmony_ci	.get_functions_count = npcm7xx_get_functions_count,
17058c2ecf20Sopenharmony_ci	.get_function_name = npcm7xx_get_function_name,
17068c2ecf20Sopenharmony_ci	.get_function_groups = npcm7xx_get_function_groups,
17078c2ecf20Sopenharmony_ci	.set_mux = npcm7xx_pinmux_set_mux,
17088c2ecf20Sopenharmony_ci	.gpio_request_enable = npcm7xx_gpio_request_enable,
17098c2ecf20Sopenharmony_ci	.gpio_disable_free = npcm7xx_gpio_request_free,
17108c2ecf20Sopenharmony_ci	.gpio_set_direction = npcm_gpio_set_direction,
17118c2ecf20Sopenharmony_ci};
17128c2ecf20Sopenharmony_ci
17138c2ecf20Sopenharmony_ci/* pinconf_ops */
17148c2ecf20Sopenharmony_cistatic int npcm7xx_config_get(struct pinctrl_dev *pctldev, unsigned int pin,
17158c2ecf20Sopenharmony_ci			      unsigned long *config)
17168c2ecf20Sopenharmony_ci{
17178c2ecf20Sopenharmony_ci	enum pin_config_param param = pinconf_to_config_param(*config);
17188c2ecf20Sopenharmony_ci	struct npcm7xx_pinctrl *npcm = pinctrl_dev_get_drvdata(pctldev);
17198c2ecf20Sopenharmony_ci	struct npcm7xx_gpio *bank =
17208c2ecf20Sopenharmony_ci		&npcm->gpio_bank[pin / NPCM7XX_GPIO_PER_BANK];
17218c2ecf20Sopenharmony_ci	int gpio = (pin % bank->gc.ngpio);
17228c2ecf20Sopenharmony_ci	unsigned long pinmask = BIT(gpio);
17238c2ecf20Sopenharmony_ci	u32 ie, oe, pu, pd;
17248c2ecf20Sopenharmony_ci	int rc = 0;
17258c2ecf20Sopenharmony_ci
17268c2ecf20Sopenharmony_ci	switch (param) {
17278c2ecf20Sopenharmony_ci	case PIN_CONFIG_BIAS_DISABLE:
17288c2ecf20Sopenharmony_ci	case PIN_CONFIG_BIAS_PULL_UP:
17298c2ecf20Sopenharmony_ci	case PIN_CONFIG_BIAS_PULL_DOWN:
17308c2ecf20Sopenharmony_ci		pu = ioread32(bank->base + NPCM7XX_GP_N_PU) & pinmask;
17318c2ecf20Sopenharmony_ci		pd = ioread32(bank->base + NPCM7XX_GP_N_PD) & pinmask;
17328c2ecf20Sopenharmony_ci		if (param == PIN_CONFIG_BIAS_DISABLE)
17338c2ecf20Sopenharmony_ci			rc = (!pu && !pd);
17348c2ecf20Sopenharmony_ci		else if (param == PIN_CONFIG_BIAS_PULL_UP)
17358c2ecf20Sopenharmony_ci			rc = (pu && !pd);
17368c2ecf20Sopenharmony_ci		else if (param == PIN_CONFIG_BIAS_PULL_DOWN)
17378c2ecf20Sopenharmony_ci			rc = (!pu && pd);
17388c2ecf20Sopenharmony_ci		break;
17398c2ecf20Sopenharmony_ci	case PIN_CONFIG_OUTPUT:
17408c2ecf20Sopenharmony_ci	case PIN_CONFIG_INPUT_ENABLE:
17418c2ecf20Sopenharmony_ci		ie = ioread32(bank->base + NPCM7XX_GP_N_IEM) & pinmask;
17428c2ecf20Sopenharmony_ci		oe = ioread32(bank->base + NPCM7XX_GP_N_OE) & pinmask;
17438c2ecf20Sopenharmony_ci		if (param == PIN_CONFIG_INPUT_ENABLE)
17448c2ecf20Sopenharmony_ci			rc = (ie && !oe);
17458c2ecf20Sopenharmony_ci		else if (param == PIN_CONFIG_OUTPUT)
17468c2ecf20Sopenharmony_ci			rc = (!ie && oe);
17478c2ecf20Sopenharmony_ci		break;
17488c2ecf20Sopenharmony_ci	case PIN_CONFIG_DRIVE_PUSH_PULL:
17498c2ecf20Sopenharmony_ci		rc = !(ioread32(bank->base + NPCM7XX_GP_N_OTYP) & pinmask);
17508c2ecf20Sopenharmony_ci		break;
17518c2ecf20Sopenharmony_ci	case PIN_CONFIG_DRIVE_OPEN_DRAIN:
17528c2ecf20Sopenharmony_ci		rc = ioread32(bank->base + NPCM7XX_GP_N_OTYP) & pinmask;
17538c2ecf20Sopenharmony_ci		break;
17548c2ecf20Sopenharmony_ci	case PIN_CONFIG_INPUT_DEBOUNCE:
17558c2ecf20Sopenharmony_ci		rc = ioread32(bank->base + NPCM7XX_GP_N_DBNC) & pinmask;
17568c2ecf20Sopenharmony_ci		break;
17578c2ecf20Sopenharmony_ci	case PIN_CONFIG_DRIVE_STRENGTH:
17588c2ecf20Sopenharmony_ci		rc = npcm7xx_get_drive_strength(pctldev, pin);
17598c2ecf20Sopenharmony_ci		if (rc)
17608c2ecf20Sopenharmony_ci			*config = pinconf_to_config_packed(param, rc);
17618c2ecf20Sopenharmony_ci		break;
17628c2ecf20Sopenharmony_ci	case PIN_CONFIG_SLEW_RATE:
17638c2ecf20Sopenharmony_ci		rc = npcm7xx_get_slew_rate(bank, npcm->gcr_regmap, pin);
17648c2ecf20Sopenharmony_ci		if (rc >= 0)
17658c2ecf20Sopenharmony_ci			*config = pinconf_to_config_packed(param, rc);
17668c2ecf20Sopenharmony_ci		break;
17678c2ecf20Sopenharmony_ci	default:
17688c2ecf20Sopenharmony_ci		return -ENOTSUPP;
17698c2ecf20Sopenharmony_ci	}
17708c2ecf20Sopenharmony_ci
17718c2ecf20Sopenharmony_ci	if (!rc)
17728c2ecf20Sopenharmony_ci		return -EINVAL;
17738c2ecf20Sopenharmony_ci
17748c2ecf20Sopenharmony_ci	return 0;
17758c2ecf20Sopenharmony_ci}
17768c2ecf20Sopenharmony_ci
17778c2ecf20Sopenharmony_cistatic int npcm7xx_config_set_one(struct npcm7xx_pinctrl *npcm,
17788c2ecf20Sopenharmony_ci				  unsigned int pin, unsigned long config)
17798c2ecf20Sopenharmony_ci{
17808c2ecf20Sopenharmony_ci	enum pin_config_param param = pinconf_to_config_param(config);
17818c2ecf20Sopenharmony_ci	u16 arg = pinconf_to_config_argument(config);
17828c2ecf20Sopenharmony_ci	struct npcm7xx_gpio *bank =
17838c2ecf20Sopenharmony_ci		&npcm->gpio_bank[pin / NPCM7XX_GPIO_PER_BANK];
17848c2ecf20Sopenharmony_ci	int gpio = BIT(pin % bank->gc.ngpio);
17858c2ecf20Sopenharmony_ci
17868c2ecf20Sopenharmony_ci	dev_dbg(bank->gc.parent, "param=%d %d[GPIO]\n", param, pin);
17878c2ecf20Sopenharmony_ci	switch (param) {
17888c2ecf20Sopenharmony_ci	case PIN_CONFIG_BIAS_DISABLE:
17898c2ecf20Sopenharmony_ci		npcm_gpio_clr(&bank->gc, bank->base + NPCM7XX_GP_N_PU, gpio);
17908c2ecf20Sopenharmony_ci		npcm_gpio_clr(&bank->gc, bank->base + NPCM7XX_GP_N_PD, gpio);
17918c2ecf20Sopenharmony_ci		break;
17928c2ecf20Sopenharmony_ci	case PIN_CONFIG_BIAS_PULL_DOWN:
17938c2ecf20Sopenharmony_ci		npcm_gpio_clr(&bank->gc, bank->base + NPCM7XX_GP_N_PU, gpio);
17948c2ecf20Sopenharmony_ci		npcm_gpio_set(&bank->gc, bank->base + NPCM7XX_GP_N_PD, gpio);
17958c2ecf20Sopenharmony_ci		break;
17968c2ecf20Sopenharmony_ci	case PIN_CONFIG_BIAS_PULL_UP:
17978c2ecf20Sopenharmony_ci		npcm_gpio_clr(&bank->gc, bank->base + NPCM7XX_GP_N_PD, gpio);
17988c2ecf20Sopenharmony_ci		npcm_gpio_set(&bank->gc, bank->base + NPCM7XX_GP_N_PU, gpio);
17998c2ecf20Sopenharmony_ci		break;
18008c2ecf20Sopenharmony_ci	case PIN_CONFIG_INPUT_ENABLE:
18018c2ecf20Sopenharmony_ci		iowrite32(gpio, bank->base + NPCM7XX_GP_N_OEC);
18028c2ecf20Sopenharmony_ci		bank->direction_input(&bank->gc, pin % bank->gc.ngpio);
18038c2ecf20Sopenharmony_ci		break;
18048c2ecf20Sopenharmony_ci	case PIN_CONFIG_OUTPUT:
18058c2ecf20Sopenharmony_ci		iowrite32(gpio, bank->base + NPCM7XX_GP_N_OES);
18068c2ecf20Sopenharmony_ci		bank->direction_output(&bank->gc, pin % bank->gc.ngpio, arg);
18078c2ecf20Sopenharmony_ci		break;
18088c2ecf20Sopenharmony_ci	case PIN_CONFIG_DRIVE_PUSH_PULL:
18098c2ecf20Sopenharmony_ci		npcm_gpio_clr(&bank->gc, bank->base + NPCM7XX_GP_N_OTYP, gpio);
18108c2ecf20Sopenharmony_ci		break;
18118c2ecf20Sopenharmony_ci	case PIN_CONFIG_DRIVE_OPEN_DRAIN:
18128c2ecf20Sopenharmony_ci		npcm_gpio_set(&bank->gc, bank->base + NPCM7XX_GP_N_OTYP, gpio);
18138c2ecf20Sopenharmony_ci		break;
18148c2ecf20Sopenharmony_ci	case PIN_CONFIG_INPUT_DEBOUNCE:
18158c2ecf20Sopenharmony_ci		npcm_gpio_set(&bank->gc, bank->base + NPCM7XX_GP_N_DBNC, gpio);
18168c2ecf20Sopenharmony_ci		break;
18178c2ecf20Sopenharmony_ci	case PIN_CONFIG_SLEW_RATE:
18188c2ecf20Sopenharmony_ci		return npcm7xx_set_slew_rate(bank, npcm->gcr_regmap, pin, arg);
18198c2ecf20Sopenharmony_ci	case PIN_CONFIG_DRIVE_STRENGTH:
18208c2ecf20Sopenharmony_ci		return npcm7xx_set_drive_strength(npcm, pin, arg);
18218c2ecf20Sopenharmony_ci	default:
18228c2ecf20Sopenharmony_ci		return -ENOTSUPP;
18238c2ecf20Sopenharmony_ci	}
18248c2ecf20Sopenharmony_ci
18258c2ecf20Sopenharmony_ci	return 0;
18268c2ecf20Sopenharmony_ci}
18278c2ecf20Sopenharmony_ci
18288c2ecf20Sopenharmony_ci/* Set multiple configuration settings for a pin */
18298c2ecf20Sopenharmony_cistatic int npcm7xx_config_set(struct pinctrl_dev *pctldev, unsigned int pin,
18308c2ecf20Sopenharmony_ci			      unsigned long *configs, unsigned int num_configs)
18318c2ecf20Sopenharmony_ci{
18328c2ecf20Sopenharmony_ci	struct npcm7xx_pinctrl *npcm = pinctrl_dev_get_drvdata(pctldev);
18338c2ecf20Sopenharmony_ci	int rc;
18348c2ecf20Sopenharmony_ci
18358c2ecf20Sopenharmony_ci	while (num_configs--) {
18368c2ecf20Sopenharmony_ci		rc = npcm7xx_config_set_one(npcm, pin, *configs++);
18378c2ecf20Sopenharmony_ci		if (rc)
18388c2ecf20Sopenharmony_ci			return rc;
18398c2ecf20Sopenharmony_ci	}
18408c2ecf20Sopenharmony_ci
18418c2ecf20Sopenharmony_ci	return 0;
18428c2ecf20Sopenharmony_ci}
18438c2ecf20Sopenharmony_ci
18448c2ecf20Sopenharmony_cistatic const struct pinconf_ops npcm7xx_pinconf_ops = {
18458c2ecf20Sopenharmony_ci	.is_generic = true,
18468c2ecf20Sopenharmony_ci	.pin_config_get = npcm7xx_config_get,
18478c2ecf20Sopenharmony_ci	.pin_config_set = npcm7xx_config_set,
18488c2ecf20Sopenharmony_ci};
18498c2ecf20Sopenharmony_ci
18508c2ecf20Sopenharmony_ci/* pinctrl_desc */
18518c2ecf20Sopenharmony_cistatic struct pinctrl_desc npcm7xx_pinctrl_desc = {
18528c2ecf20Sopenharmony_ci	.name = "npcm7xx-pinctrl",
18538c2ecf20Sopenharmony_ci	.pins = npcm7xx_pins,
18548c2ecf20Sopenharmony_ci	.npins = ARRAY_SIZE(npcm7xx_pins),
18558c2ecf20Sopenharmony_ci	.pctlops = &npcm7xx_pinctrl_ops,
18568c2ecf20Sopenharmony_ci	.pmxops = &npcm7xx_pinmux_ops,
18578c2ecf20Sopenharmony_ci	.confops = &npcm7xx_pinconf_ops,
18588c2ecf20Sopenharmony_ci	.owner = THIS_MODULE,
18598c2ecf20Sopenharmony_ci};
18608c2ecf20Sopenharmony_ci
18618c2ecf20Sopenharmony_cistatic int npcm7xx_gpio_of(struct npcm7xx_pinctrl *pctrl)
18628c2ecf20Sopenharmony_ci{
18638c2ecf20Sopenharmony_ci	int ret = -ENXIO;
18648c2ecf20Sopenharmony_ci	struct resource res;
18658c2ecf20Sopenharmony_ci	int id = 0, irq;
18668c2ecf20Sopenharmony_ci	struct device_node *np;
18678c2ecf20Sopenharmony_ci	struct of_phandle_args pinspec;
18688c2ecf20Sopenharmony_ci
18698c2ecf20Sopenharmony_ci	for_each_available_child_of_node(pctrl->dev->of_node, np)
18708c2ecf20Sopenharmony_ci		if (of_find_property(np, "gpio-controller", NULL)) {
18718c2ecf20Sopenharmony_ci			ret = of_address_to_resource(np, 0, &res);
18728c2ecf20Sopenharmony_ci			if (ret < 0) {
18738c2ecf20Sopenharmony_ci				dev_err(pctrl->dev,
18748c2ecf20Sopenharmony_ci					"Resource fail for GPIO bank %u\n", id);
18758c2ecf20Sopenharmony_ci				return ret;
18768c2ecf20Sopenharmony_ci			}
18778c2ecf20Sopenharmony_ci
18788c2ecf20Sopenharmony_ci			pctrl->gpio_bank[id].base =
18798c2ecf20Sopenharmony_ci				ioremap(res.start, resource_size(&res));
18808c2ecf20Sopenharmony_ci
18818c2ecf20Sopenharmony_ci			irq = irq_of_parse_and_map(np, 0);
18828c2ecf20Sopenharmony_ci			if (irq < 0) {
18838c2ecf20Sopenharmony_ci				dev_err(pctrl->dev,
18848c2ecf20Sopenharmony_ci					"No IRQ for GPIO bank %u\n", id);
18858c2ecf20Sopenharmony_ci				ret = irq;
18868c2ecf20Sopenharmony_ci				return ret;
18878c2ecf20Sopenharmony_ci			}
18888c2ecf20Sopenharmony_ci
18898c2ecf20Sopenharmony_ci			ret = bgpio_init(&pctrl->gpio_bank[id].gc,
18908c2ecf20Sopenharmony_ci					 pctrl->dev, 4,
18918c2ecf20Sopenharmony_ci					 pctrl->gpio_bank[id].base +
18928c2ecf20Sopenharmony_ci					 NPCM7XX_GP_N_DIN,
18938c2ecf20Sopenharmony_ci					 pctrl->gpio_bank[id].base +
18948c2ecf20Sopenharmony_ci					 NPCM7XX_GP_N_DOUT,
18958c2ecf20Sopenharmony_ci					 NULL,
18968c2ecf20Sopenharmony_ci					 NULL,
18978c2ecf20Sopenharmony_ci					 pctrl->gpio_bank[id].base +
18988c2ecf20Sopenharmony_ci					 NPCM7XX_GP_N_IEM,
18998c2ecf20Sopenharmony_ci					 BGPIOF_READ_OUTPUT_REG_SET);
19008c2ecf20Sopenharmony_ci			if (ret) {
19018c2ecf20Sopenharmony_ci				dev_err(pctrl->dev, "bgpio_init() failed\n");
19028c2ecf20Sopenharmony_ci				return ret;
19038c2ecf20Sopenharmony_ci			}
19048c2ecf20Sopenharmony_ci
19058c2ecf20Sopenharmony_ci			ret = of_parse_phandle_with_fixed_args(np,
19068c2ecf20Sopenharmony_ci							       "gpio-ranges", 3,
19078c2ecf20Sopenharmony_ci							       0, &pinspec);
19088c2ecf20Sopenharmony_ci			if (ret < 0) {
19098c2ecf20Sopenharmony_ci				dev_err(pctrl->dev,
19108c2ecf20Sopenharmony_ci					"gpio-ranges fail for GPIO bank %u\n",
19118c2ecf20Sopenharmony_ci					id);
19128c2ecf20Sopenharmony_ci				return ret;
19138c2ecf20Sopenharmony_ci			}
19148c2ecf20Sopenharmony_ci
19158c2ecf20Sopenharmony_ci			pctrl->gpio_bank[id].irq = irq;
19168c2ecf20Sopenharmony_ci			pctrl->gpio_bank[id].irq_chip = npcmgpio_irqchip;
19178c2ecf20Sopenharmony_ci			pctrl->gpio_bank[id].gc.parent = pctrl->dev;
19188c2ecf20Sopenharmony_ci			pctrl->gpio_bank[id].irqbase =
19198c2ecf20Sopenharmony_ci				id * NPCM7XX_GPIO_PER_BANK;
19208c2ecf20Sopenharmony_ci			pctrl->gpio_bank[id].pinctrl_id = pinspec.args[0];
19218c2ecf20Sopenharmony_ci			pctrl->gpio_bank[id].gc.base = pinspec.args[1];
19228c2ecf20Sopenharmony_ci			pctrl->gpio_bank[id].gc.ngpio = pinspec.args[2];
19238c2ecf20Sopenharmony_ci			pctrl->gpio_bank[id].gc.owner = THIS_MODULE;
19248c2ecf20Sopenharmony_ci			pctrl->gpio_bank[id].gc.label =
19258c2ecf20Sopenharmony_ci				devm_kasprintf(pctrl->dev, GFP_KERNEL, "%pOF",
19268c2ecf20Sopenharmony_ci					       np);
19278c2ecf20Sopenharmony_ci			if (pctrl->gpio_bank[id].gc.label == NULL)
19288c2ecf20Sopenharmony_ci				return -ENOMEM;
19298c2ecf20Sopenharmony_ci
19308c2ecf20Sopenharmony_ci			pctrl->gpio_bank[id].gc.dbg_show = npcmgpio_dbg_show;
19318c2ecf20Sopenharmony_ci			pctrl->gpio_bank[id].direction_input =
19328c2ecf20Sopenharmony_ci				pctrl->gpio_bank[id].gc.direction_input;
19338c2ecf20Sopenharmony_ci			pctrl->gpio_bank[id].gc.direction_input =
19348c2ecf20Sopenharmony_ci				npcmgpio_direction_input;
19358c2ecf20Sopenharmony_ci			pctrl->gpio_bank[id].direction_output =
19368c2ecf20Sopenharmony_ci				pctrl->gpio_bank[id].gc.direction_output;
19378c2ecf20Sopenharmony_ci			pctrl->gpio_bank[id].gc.direction_output =
19388c2ecf20Sopenharmony_ci				npcmgpio_direction_output;
19398c2ecf20Sopenharmony_ci			pctrl->gpio_bank[id].request =
19408c2ecf20Sopenharmony_ci				pctrl->gpio_bank[id].gc.request;
19418c2ecf20Sopenharmony_ci			pctrl->gpio_bank[id].gc.request = npcmgpio_gpio_request;
19428c2ecf20Sopenharmony_ci			pctrl->gpio_bank[id].gc.free = npcmgpio_gpio_free;
19438c2ecf20Sopenharmony_ci			pctrl->gpio_bank[id].gc.of_node = np;
19448c2ecf20Sopenharmony_ci			id++;
19458c2ecf20Sopenharmony_ci		}
19468c2ecf20Sopenharmony_ci
19478c2ecf20Sopenharmony_ci	pctrl->bank_num = id;
19488c2ecf20Sopenharmony_ci	return ret;
19498c2ecf20Sopenharmony_ci}
19508c2ecf20Sopenharmony_ci
19518c2ecf20Sopenharmony_cistatic int npcm7xx_gpio_register(struct npcm7xx_pinctrl *pctrl)
19528c2ecf20Sopenharmony_ci{
19538c2ecf20Sopenharmony_ci	int ret, id;
19548c2ecf20Sopenharmony_ci
19558c2ecf20Sopenharmony_ci	for (id = 0 ; id < pctrl->bank_num ; id++) {
19568c2ecf20Sopenharmony_ci		struct gpio_irq_chip *girq;
19578c2ecf20Sopenharmony_ci
19588c2ecf20Sopenharmony_ci		girq = &pctrl->gpio_bank[id].gc.irq;
19598c2ecf20Sopenharmony_ci		girq->chip = &pctrl->gpio_bank[id].irq_chip;
19608c2ecf20Sopenharmony_ci		girq->parent_handler = npcmgpio_irq_handler;
19618c2ecf20Sopenharmony_ci		girq->num_parents = 1;
19628c2ecf20Sopenharmony_ci		girq->parents = devm_kcalloc(pctrl->dev, 1,
19638c2ecf20Sopenharmony_ci					     sizeof(*girq->parents),
19648c2ecf20Sopenharmony_ci					     GFP_KERNEL);
19658c2ecf20Sopenharmony_ci		if (!girq->parents) {
19668c2ecf20Sopenharmony_ci			ret = -ENOMEM;
19678c2ecf20Sopenharmony_ci			goto err_register;
19688c2ecf20Sopenharmony_ci		}
19698c2ecf20Sopenharmony_ci		girq->parents[0] = pctrl->gpio_bank[id].irq;
19708c2ecf20Sopenharmony_ci		girq->default_type = IRQ_TYPE_NONE;
19718c2ecf20Sopenharmony_ci		girq->handler = handle_level_irq;
19728c2ecf20Sopenharmony_ci		ret = devm_gpiochip_add_data(pctrl->dev,
19738c2ecf20Sopenharmony_ci					     &pctrl->gpio_bank[id].gc,
19748c2ecf20Sopenharmony_ci					     &pctrl->gpio_bank[id]);
19758c2ecf20Sopenharmony_ci		if (ret) {
19768c2ecf20Sopenharmony_ci			dev_err(pctrl->dev, "Failed to add GPIO chip %u\n", id);
19778c2ecf20Sopenharmony_ci			goto err_register;
19788c2ecf20Sopenharmony_ci		}
19798c2ecf20Sopenharmony_ci
19808c2ecf20Sopenharmony_ci		ret = gpiochip_add_pin_range(&pctrl->gpio_bank[id].gc,
19818c2ecf20Sopenharmony_ci					     dev_name(pctrl->dev),
19828c2ecf20Sopenharmony_ci					     pctrl->gpio_bank[id].pinctrl_id,
19838c2ecf20Sopenharmony_ci					     pctrl->gpio_bank[id].gc.base,
19848c2ecf20Sopenharmony_ci					     pctrl->gpio_bank[id].gc.ngpio);
19858c2ecf20Sopenharmony_ci		if (ret < 0) {
19868c2ecf20Sopenharmony_ci			dev_err(pctrl->dev, "Failed to add GPIO bank %u\n", id);
19878c2ecf20Sopenharmony_ci			gpiochip_remove(&pctrl->gpio_bank[id].gc);
19888c2ecf20Sopenharmony_ci			goto err_register;
19898c2ecf20Sopenharmony_ci		}
19908c2ecf20Sopenharmony_ci	}
19918c2ecf20Sopenharmony_ci
19928c2ecf20Sopenharmony_ci	return 0;
19938c2ecf20Sopenharmony_ci
19948c2ecf20Sopenharmony_cierr_register:
19958c2ecf20Sopenharmony_ci	for (; id > 0; id--)
19968c2ecf20Sopenharmony_ci		gpiochip_remove(&pctrl->gpio_bank[id - 1].gc);
19978c2ecf20Sopenharmony_ci
19988c2ecf20Sopenharmony_ci	return ret;
19998c2ecf20Sopenharmony_ci}
20008c2ecf20Sopenharmony_ci
20018c2ecf20Sopenharmony_cistatic int npcm7xx_pinctrl_probe(struct platform_device *pdev)
20028c2ecf20Sopenharmony_ci{
20038c2ecf20Sopenharmony_ci	struct npcm7xx_pinctrl *pctrl;
20048c2ecf20Sopenharmony_ci	int ret;
20058c2ecf20Sopenharmony_ci
20068c2ecf20Sopenharmony_ci	pctrl = devm_kzalloc(&pdev->dev, sizeof(*pctrl), GFP_KERNEL);
20078c2ecf20Sopenharmony_ci	if (!pctrl)
20088c2ecf20Sopenharmony_ci		return -ENOMEM;
20098c2ecf20Sopenharmony_ci
20108c2ecf20Sopenharmony_ci	pctrl->dev = &pdev->dev;
20118c2ecf20Sopenharmony_ci	dev_set_drvdata(&pdev->dev, pctrl);
20128c2ecf20Sopenharmony_ci
20138c2ecf20Sopenharmony_ci	pctrl->gcr_regmap =
20148c2ecf20Sopenharmony_ci		syscon_regmap_lookup_by_compatible("nuvoton,npcm750-gcr");
20158c2ecf20Sopenharmony_ci	if (IS_ERR(pctrl->gcr_regmap)) {
20168c2ecf20Sopenharmony_ci		dev_err(pctrl->dev, "didn't find nuvoton,npcm750-gcr\n");
20178c2ecf20Sopenharmony_ci		return PTR_ERR(pctrl->gcr_regmap);
20188c2ecf20Sopenharmony_ci	}
20198c2ecf20Sopenharmony_ci
20208c2ecf20Sopenharmony_ci	ret = npcm7xx_gpio_of(pctrl);
20218c2ecf20Sopenharmony_ci	if (ret < 0) {
20228c2ecf20Sopenharmony_ci		dev_err(pctrl->dev, "Failed to gpio dt-binding %u\n", ret);
20238c2ecf20Sopenharmony_ci		return ret;
20248c2ecf20Sopenharmony_ci	}
20258c2ecf20Sopenharmony_ci
20268c2ecf20Sopenharmony_ci	pctrl->pctldev = devm_pinctrl_register(&pdev->dev,
20278c2ecf20Sopenharmony_ci					       &npcm7xx_pinctrl_desc, pctrl);
20288c2ecf20Sopenharmony_ci	if (IS_ERR(pctrl->pctldev)) {
20298c2ecf20Sopenharmony_ci		dev_err(&pdev->dev, "Failed to register pinctrl device\n");
20308c2ecf20Sopenharmony_ci		return PTR_ERR(pctrl->pctldev);
20318c2ecf20Sopenharmony_ci	}
20328c2ecf20Sopenharmony_ci
20338c2ecf20Sopenharmony_ci	ret = npcm7xx_gpio_register(pctrl);
20348c2ecf20Sopenharmony_ci	if (ret < 0) {
20358c2ecf20Sopenharmony_ci		dev_err(pctrl->dev, "Failed to register gpio %u\n", ret);
20368c2ecf20Sopenharmony_ci		return ret;
20378c2ecf20Sopenharmony_ci	}
20388c2ecf20Sopenharmony_ci
20398c2ecf20Sopenharmony_ci	pr_info("NPCM7xx Pinctrl driver probed\n");
20408c2ecf20Sopenharmony_ci	return 0;
20418c2ecf20Sopenharmony_ci}
20428c2ecf20Sopenharmony_ci
20438c2ecf20Sopenharmony_cistatic const struct of_device_id npcm7xx_pinctrl_match[] = {
20448c2ecf20Sopenharmony_ci	{ .compatible = "nuvoton,npcm750-pinctrl" },
20458c2ecf20Sopenharmony_ci	{ },
20468c2ecf20Sopenharmony_ci};
20478c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(of, npcm7xx_pinctrl_match);
20488c2ecf20Sopenharmony_ci
20498c2ecf20Sopenharmony_cistatic struct platform_driver npcm7xx_pinctrl_driver = {
20508c2ecf20Sopenharmony_ci	.probe = npcm7xx_pinctrl_probe,
20518c2ecf20Sopenharmony_ci	.driver = {
20528c2ecf20Sopenharmony_ci		.name = "npcm7xx-pinctrl",
20538c2ecf20Sopenharmony_ci		.of_match_table = npcm7xx_pinctrl_match,
20548c2ecf20Sopenharmony_ci		.suppress_bind_attrs = true,
20558c2ecf20Sopenharmony_ci	},
20568c2ecf20Sopenharmony_ci};
20578c2ecf20Sopenharmony_ci
20588c2ecf20Sopenharmony_cistatic int __init npcm7xx_pinctrl_register(void)
20598c2ecf20Sopenharmony_ci{
20608c2ecf20Sopenharmony_ci	return platform_driver_register(&npcm7xx_pinctrl_driver);
20618c2ecf20Sopenharmony_ci}
20628c2ecf20Sopenharmony_ciarch_initcall(npcm7xx_pinctrl_register);
20638c2ecf20Sopenharmony_ci
20648c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL v2");
20658c2ecf20Sopenharmony_ciMODULE_AUTHOR("jordan_hargrave@dell.com");
20668c2ecf20Sopenharmony_ciMODULE_AUTHOR("tomer.maimon@nuvoton.com");
20678c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("Nuvoton NPCM7XX Pinctrl and GPIO driver");
2068