162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 262306a36Sopenharmony_ci// Copyright (c) 2016-2018 Nuvoton Technology corporation. 362306a36Sopenharmony_ci// Copyright (c) 2016, Dell Inc 462306a36Sopenharmony_ci 562306a36Sopenharmony_ci#include <linux/device.h> 662306a36Sopenharmony_ci#include <linux/gpio/driver.h> 762306a36Sopenharmony_ci#include <linux/interrupt.h> 862306a36Sopenharmony_ci#include <linux/irq.h> 962306a36Sopenharmony_ci#include <linux/mfd/syscon.h> 1062306a36Sopenharmony_ci#include <linux/module.h> 1162306a36Sopenharmony_ci#include <linux/of.h> 1262306a36Sopenharmony_ci#include <linux/of_address.h> 1362306a36Sopenharmony_ci#include <linux/of_irq.h> 1462306a36Sopenharmony_ci#include <linux/platform_device.h> 1562306a36Sopenharmony_ci#include <linux/property.h> 1662306a36Sopenharmony_ci#include <linux/regmap.h> 1762306a36Sopenharmony_ci#include <linux/seq_file.h> 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ci#include <linux/pinctrl/consumer.h> 2062306a36Sopenharmony_ci#include <linux/pinctrl/machine.h> 2162306a36Sopenharmony_ci#include <linux/pinctrl/pinconf-generic.h> 2262306a36Sopenharmony_ci#include <linux/pinctrl/pinconf.h> 2362306a36Sopenharmony_ci#include <linux/pinctrl/pinctrl.h> 2462306a36Sopenharmony_ci#include <linux/pinctrl/pinmux.h> 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ci/* GCR registers */ 2762306a36Sopenharmony_ci#define NPCM7XX_GCR_PDID 0x00 2862306a36Sopenharmony_ci#define NPCM7XX_GCR_MFSEL1 0x0C 2962306a36Sopenharmony_ci#define NPCM7XX_GCR_MFSEL2 0x10 3062306a36Sopenharmony_ci#define NPCM7XX_GCR_MFSEL3 0x64 3162306a36Sopenharmony_ci#define NPCM7XX_GCR_MFSEL4 0xb0 3262306a36Sopenharmony_ci#define NPCM7XX_GCR_CPCTL 0xD0 3362306a36Sopenharmony_ci#define NPCM7XX_GCR_CP2BST 0xD4 3462306a36Sopenharmony_ci#define NPCM7XX_GCR_B2CPNT 0xD8 3562306a36Sopenharmony_ci#define NPCM7XX_GCR_I2CSEGSEL 0xE0 3662306a36Sopenharmony_ci#define NPCM7XX_GCR_I2CSEGCTL 0xE4 3762306a36Sopenharmony_ci#define NPCM7XX_GCR_SRCNT 0x68 3862306a36Sopenharmony_ci#define NPCM7XX_GCR_FLOCKR1 0x74 3962306a36Sopenharmony_ci#define NPCM7XX_GCR_DSCNT 0x78 4062306a36Sopenharmony_ci 4162306a36Sopenharmony_ci#define SRCNT_ESPI BIT(3) 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ci/* GPIO registers */ 4462306a36Sopenharmony_ci#define NPCM7XX_GP_N_TLOCK1 0x00 4562306a36Sopenharmony_ci#define NPCM7XX_GP_N_DIN 0x04 /* Data IN */ 4662306a36Sopenharmony_ci#define NPCM7XX_GP_N_POL 0x08 /* Polarity */ 4762306a36Sopenharmony_ci#define NPCM7XX_GP_N_DOUT 0x0c /* Data OUT */ 4862306a36Sopenharmony_ci#define NPCM7XX_GP_N_OE 0x10 /* Output Enable */ 4962306a36Sopenharmony_ci#define NPCM7XX_GP_N_OTYP 0x14 5062306a36Sopenharmony_ci#define NPCM7XX_GP_N_MP 0x18 5162306a36Sopenharmony_ci#define NPCM7XX_GP_N_PU 0x1c /* Pull-up */ 5262306a36Sopenharmony_ci#define NPCM7XX_GP_N_PD 0x20 /* Pull-down */ 5362306a36Sopenharmony_ci#define NPCM7XX_GP_N_DBNC 0x24 /* Debounce */ 5462306a36Sopenharmony_ci#define NPCM7XX_GP_N_EVTYP 0x28 /* Event Type */ 5562306a36Sopenharmony_ci#define NPCM7XX_GP_N_EVBE 0x2c /* Event Both Edge */ 5662306a36Sopenharmony_ci#define NPCM7XX_GP_N_OBL0 0x30 5762306a36Sopenharmony_ci#define NPCM7XX_GP_N_OBL1 0x34 5862306a36Sopenharmony_ci#define NPCM7XX_GP_N_OBL2 0x38 5962306a36Sopenharmony_ci#define NPCM7XX_GP_N_OBL3 0x3c 6062306a36Sopenharmony_ci#define NPCM7XX_GP_N_EVEN 0x40 /* Event Enable */ 6162306a36Sopenharmony_ci#define NPCM7XX_GP_N_EVENS 0x44 /* Event Set (enable) */ 6262306a36Sopenharmony_ci#define NPCM7XX_GP_N_EVENC 0x48 /* Event Clear (disable) */ 6362306a36Sopenharmony_ci#define NPCM7XX_GP_N_EVST 0x4c /* Event Status */ 6462306a36Sopenharmony_ci#define NPCM7XX_GP_N_SPLCK 0x50 6562306a36Sopenharmony_ci#define NPCM7XX_GP_N_MPLCK 0x54 6662306a36Sopenharmony_ci#define NPCM7XX_GP_N_IEM 0x58 /* Input Enable */ 6762306a36Sopenharmony_ci#define NPCM7XX_GP_N_OSRC 0x5c 6862306a36Sopenharmony_ci#define NPCM7XX_GP_N_ODSC 0x60 6962306a36Sopenharmony_ci#define NPCM7XX_GP_N_DOS 0x68 /* Data OUT Set */ 7062306a36Sopenharmony_ci#define NPCM7XX_GP_N_DOC 0x6c /* Data OUT Clear */ 7162306a36Sopenharmony_ci#define NPCM7XX_GP_N_OES 0x70 /* Output Enable Set */ 7262306a36Sopenharmony_ci#define NPCM7XX_GP_N_OEC 0x74 /* Output Enable Clear */ 7362306a36Sopenharmony_ci#define NPCM7XX_GP_N_TLOCK2 0x7c 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ci#define NPCM7XX_GPIO_PER_BANK 32 7662306a36Sopenharmony_ci#define NPCM7XX_GPIO_BANK_NUM 8 7762306a36Sopenharmony_ci#define NPCM7XX_GCR_NONE 0 7862306a36Sopenharmony_ci 7962306a36Sopenharmony_ci/* Structure for register banks */ 8062306a36Sopenharmony_cistruct npcm7xx_gpio { 8162306a36Sopenharmony_ci void __iomem *base; 8262306a36Sopenharmony_ci struct gpio_chip gc; 8362306a36Sopenharmony_ci int irqbase; 8462306a36Sopenharmony_ci int irq; 8562306a36Sopenharmony_ci u32 pinctrl_id; 8662306a36Sopenharmony_ci int (*direction_input)(struct gpio_chip *chip, unsigned int offset); 8762306a36Sopenharmony_ci int (*direction_output)(struct gpio_chip *chip, unsigned int offset, 8862306a36Sopenharmony_ci int value); 8962306a36Sopenharmony_ci int (*request)(struct gpio_chip *chip, unsigned int offset); 9062306a36Sopenharmony_ci void (*free)(struct gpio_chip *chip, unsigned int offset); 9162306a36Sopenharmony_ci}; 9262306a36Sopenharmony_ci 9362306a36Sopenharmony_cistruct npcm7xx_pinctrl { 9462306a36Sopenharmony_ci struct pinctrl_dev *pctldev; 9562306a36Sopenharmony_ci struct device *dev; 9662306a36Sopenharmony_ci struct npcm7xx_gpio gpio_bank[NPCM7XX_GPIO_BANK_NUM]; 9762306a36Sopenharmony_ci struct irq_domain *domain; 9862306a36Sopenharmony_ci struct regmap *gcr_regmap; 9962306a36Sopenharmony_ci void __iomem *regs; 10062306a36Sopenharmony_ci u32 bank_num; 10162306a36Sopenharmony_ci}; 10262306a36Sopenharmony_ci 10362306a36Sopenharmony_ci/* GPIO handling in the pinctrl driver */ 10462306a36Sopenharmony_cistatic void npcm_gpio_set(struct gpio_chip *gc, void __iomem *reg, 10562306a36Sopenharmony_ci unsigned int pinmask) 10662306a36Sopenharmony_ci{ 10762306a36Sopenharmony_ci unsigned long flags; 10862306a36Sopenharmony_ci unsigned long val; 10962306a36Sopenharmony_ci 11062306a36Sopenharmony_ci raw_spin_lock_irqsave(&gc->bgpio_lock, flags); 11162306a36Sopenharmony_ci 11262306a36Sopenharmony_ci val = ioread32(reg) | pinmask; 11362306a36Sopenharmony_ci iowrite32(val, reg); 11462306a36Sopenharmony_ci 11562306a36Sopenharmony_ci raw_spin_unlock_irqrestore(&gc->bgpio_lock, flags); 11662306a36Sopenharmony_ci} 11762306a36Sopenharmony_ci 11862306a36Sopenharmony_cistatic void npcm_gpio_clr(struct gpio_chip *gc, void __iomem *reg, 11962306a36Sopenharmony_ci unsigned int pinmask) 12062306a36Sopenharmony_ci{ 12162306a36Sopenharmony_ci unsigned long flags; 12262306a36Sopenharmony_ci unsigned long val; 12362306a36Sopenharmony_ci 12462306a36Sopenharmony_ci raw_spin_lock_irqsave(&gc->bgpio_lock, flags); 12562306a36Sopenharmony_ci 12662306a36Sopenharmony_ci val = ioread32(reg) & ~pinmask; 12762306a36Sopenharmony_ci iowrite32(val, reg); 12862306a36Sopenharmony_ci 12962306a36Sopenharmony_ci raw_spin_unlock_irqrestore(&gc->bgpio_lock, flags); 13062306a36Sopenharmony_ci} 13162306a36Sopenharmony_ci 13262306a36Sopenharmony_cistatic void npcmgpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) 13362306a36Sopenharmony_ci{ 13462306a36Sopenharmony_ci struct npcm7xx_gpio *bank = gpiochip_get_data(chip); 13562306a36Sopenharmony_ci 13662306a36Sopenharmony_ci seq_printf(s, "-- module %d [gpio%d - %d]\n", 13762306a36Sopenharmony_ci bank->gc.base / bank->gc.ngpio, 13862306a36Sopenharmony_ci bank->gc.base, 13962306a36Sopenharmony_ci bank->gc.base + bank->gc.ngpio); 14062306a36Sopenharmony_ci seq_printf(s, "DIN :%.8x DOUT:%.8x IE :%.8x OE :%.8x\n", 14162306a36Sopenharmony_ci ioread32(bank->base + NPCM7XX_GP_N_DIN), 14262306a36Sopenharmony_ci ioread32(bank->base + NPCM7XX_GP_N_DOUT), 14362306a36Sopenharmony_ci ioread32(bank->base + NPCM7XX_GP_N_IEM), 14462306a36Sopenharmony_ci ioread32(bank->base + NPCM7XX_GP_N_OE)); 14562306a36Sopenharmony_ci seq_printf(s, "PU :%.8x PD :%.8x DB :%.8x POL :%.8x\n", 14662306a36Sopenharmony_ci ioread32(bank->base + NPCM7XX_GP_N_PU), 14762306a36Sopenharmony_ci ioread32(bank->base + NPCM7XX_GP_N_PD), 14862306a36Sopenharmony_ci ioread32(bank->base + NPCM7XX_GP_N_DBNC), 14962306a36Sopenharmony_ci ioread32(bank->base + NPCM7XX_GP_N_POL)); 15062306a36Sopenharmony_ci seq_printf(s, "ETYP:%.8x EVBE:%.8x EVEN:%.8x EVST:%.8x\n", 15162306a36Sopenharmony_ci ioread32(bank->base + NPCM7XX_GP_N_EVTYP), 15262306a36Sopenharmony_ci ioread32(bank->base + NPCM7XX_GP_N_EVBE), 15362306a36Sopenharmony_ci ioread32(bank->base + NPCM7XX_GP_N_EVEN), 15462306a36Sopenharmony_ci ioread32(bank->base + NPCM7XX_GP_N_EVST)); 15562306a36Sopenharmony_ci seq_printf(s, "OTYP:%.8x OSRC:%.8x ODSC:%.8x\n", 15662306a36Sopenharmony_ci ioread32(bank->base + NPCM7XX_GP_N_OTYP), 15762306a36Sopenharmony_ci ioread32(bank->base + NPCM7XX_GP_N_OSRC), 15862306a36Sopenharmony_ci ioread32(bank->base + NPCM7XX_GP_N_ODSC)); 15962306a36Sopenharmony_ci seq_printf(s, "OBL0:%.8x OBL1:%.8x OBL2:%.8x OBL3:%.8x\n", 16062306a36Sopenharmony_ci ioread32(bank->base + NPCM7XX_GP_N_OBL0), 16162306a36Sopenharmony_ci ioread32(bank->base + NPCM7XX_GP_N_OBL1), 16262306a36Sopenharmony_ci ioread32(bank->base + NPCM7XX_GP_N_OBL2), 16362306a36Sopenharmony_ci ioread32(bank->base + NPCM7XX_GP_N_OBL3)); 16462306a36Sopenharmony_ci seq_printf(s, "SLCK:%.8x MLCK:%.8x\n", 16562306a36Sopenharmony_ci ioread32(bank->base + NPCM7XX_GP_N_SPLCK), 16662306a36Sopenharmony_ci ioread32(bank->base + NPCM7XX_GP_N_MPLCK)); 16762306a36Sopenharmony_ci} 16862306a36Sopenharmony_ci 16962306a36Sopenharmony_cistatic int npcmgpio_direction_input(struct gpio_chip *chip, unsigned int offset) 17062306a36Sopenharmony_ci{ 17162306a36Sopenharmony_ci struct npcm7xx_gpio *bank = gpiochip_get_data(chip); 17262306a36Sopenharmony_ci int ret; 17362306a36Sopenharmony_ci 17462306a36Sopenharmony_ci ret = pinctrl_gpio_direction_input(offset + chip->base); 17562306a36Sopenharmony_ci if (ret) 17662306a36Sopenharmony_ci return ret; 17762306a36Sopenharmony_ci 17862306a36Sopenharmony_ci return bank->direction_input(chip, offset); 17962306a36Sopenharmony_ci} 18062306a36Sopenharmony_ci 18162306a36Sopenharmony_ci/* Set GPIO to Output with initial value */ 18262306a36Sopenharmony_cistatic int npcmgpio_direction_output(struct gpio_chip *chip, 18362306a36Sopenharmony_ci unsigned int offset, int value) 18462306a36Sopenharmony_ci{ 18562306a36Sopenharmony_ci struct npcm7xx_gpio *bank = gpiochip_get_data(chip); 18662306a36Sopenharmony_ci int ret; 18762306a36Sopenharmony_ci 18862306a36Sopenharmony_ci dev_dbg(chip->parent, "gpio_direction_output: offset%d = %x\n", offset, 18962306a36Sopenharmony_ci value); 19062306a36Sopenharmony_ci 19162306a36Sopenharmony_ci ret = pinctrl_gpio_direction_output(offset + chip->base); 19262306a36Sopenharmony_ci if (ret) 19362306a36Sopenharmony_ci return ret; 19462306a36Sopenharmony_ci 19562306a36Sopenharmony_ci return bank->direction_output(chip, offset, value); 19662306a36Sopenharmony_ci} 19762306a36Sopenharmony_ci 19862306a36Sopenharmony_cistatic int npcmgpio_gpio_request(struct gpio_chip *chip, unsigned int offset) 19962306a36Sopenharmony_ci{ 20062306a36Sopenharmony_ci struct npcm7xx_gpio *bank = gpiochip_get_data(chip); 20162306a36Sopenharmony_ci int ret; 20262306a36Sopenharmony_ci 20362306a36Sopenharmony_ci dev_dbg(chip->parent, "gpio_request: offset%d\n", offset); 20462306a36Sopenharmony_ci ret = pinctrl_gpio_request(offset + chip->base); 20562306a36Sopenharmony_ci if (ret) 20662306a36Sopenharmony_ci return ret; 20762306a36Sopenharmony_ci 20862306a36Sopenharmony_ci return bank->request(chip, offset); 20962306a36Sopenharmony_ci} 21062306a36Sopenharmony_ci 21162306a36Sopenharmony_cistatic void npcmgpio_gpio_free(struct gpio_chip *chip, unsigned int offset) 21262306a36Sopenharmony_ci{ 21362306a36Sopenharmony_ci dev_dbg(chip->parent, "gpio_free: offset%d\n", offset); 21462306a36Sopenharmony_ci pinctrl_gpio_free(offset + chip->base); 21562306a36Sopenharmony_ci} 21662306a36Sopenharmony_ci 21762306a36Sopenharmony_cistatic void npcmgpio_irq_handler(struct irq_desc *desc) 21862306a36Sopenharmony_ci{ 21962306a36Sopenharmony_ci struct gpio_chip *gc; 22062306a36Sopenharmony_ci struct irq_chip *chip; 22162306a36Sopenharmony_ci struct npcm7xx_gpio *bank; 22262306a36Sopenharmony_ci unsigned long sts, en, bit; 22362306a36Sopenharmony_ci 22462306a36Sopenharmony_ci gc = irq_desc_get_handler_data(desc); 22562306a36Sopenharmony_ci bank = gpiochip_get_data(gc); 22662306a36Sopenharmony_ci chip = irq_desc_get_chip(desc); 22762306a36Sopenharmony_ci 22862306a36Sopenharmony_ci chained_irq_enter(chip, desc); 22962306a36Sopenharmony_ci sts = ioread32(bank->base + NPCM7XX_GP_N_EVST); 23062306a36Sopenharmony_ci en = ioread32(bank->base + NPCM7XX_GP_N_EVEN); 23162306a36Sopenharmony_ci dev_dbg(bank->gc.parent, "==> got irq sts %.8lx %.8lx\n", sts, 23262306a36Sopenharmony_ci en); 23362306a36Sopenharmony_ci 23462306a36Sopenharmony_ci sts &= en; 23562306a36Sopenharmony_ci for_each_set_bit(bit, &sts, NPCM7XX_GPIO_PER_BANK) 23662306a36Sopenharmony_ci generic_handle_domain_irq(gc->irq.domain, bit); 23762306a36Sopenharmony_ci chained_irq_exit(chip, desc); 23862306a36Sopenharmony_ci} 23962306a36Sopenharmony_ci 24062306a36Sopenharmony_cistatic int npcmgpio_set_irq_type(struct irq_data *d, unsigned int type) 24162306a36Sopenharmony_ci{ 24262306a36Sopenharmony_ci struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 24362306a36Sopenharmony_ci struct npcm7xx_gpio *bank = gpiochip_get_data(gc); 24462306a36Sopenharmony_ci unsigned int gpio = BIT(irqd_to_hwirq(d)); 24562306a36Sopenharmony_ci 24662306a36Sopenharmony_ci dev_dbg(bank->gc.parent, "setirqtype: %u.%u = %u\n", gpio, 24762306a36Sopenharmony_ci d->irq, type); 24862306a36Sopenharmony_ci switch (type) { 24962306a36Sopenharmony_ci case IRQ_TYPE_EDGE_RISING: 25062306a36Sopenharmony_ci dev_dbg(bank->gc.parent, "edge.rising\n"); 25162306a36Sopenharmony_ci npcm_gpio_clr(&bank->gc, bank->base + NPCM7XX_GP_N_EVBE, gpio); 25262306a36Sopenharmony_ci npcm_gpio_clr(&bank->gc, bank->base + NPCM7XX_GP_N_POL, gpio); 25362306a36Sopenharmony_ci break; 25462306a36Sopenharmony_ci case IRQ_TYPE_EDGE_FALLING: 25562306a36Sopenharmony_ci dev_dbg(bank->gc.parent, "edge.falling\n"); 25662306a36Sopenharmony_ci npcm_gpio_clr(&bank->gc, bank->base + NPCM7XX_GP_N_EVBE, gpio); 25762306a36Sopenharmony_ci npcm_gpio_set(&bank->gc, bank->base + NPCM7XX_GP_N_POL, gpio); 25862306a36Sopenharmony_ci break; 25962306a36Sopenharmony_ci case IRQ_TYPE_EDGE_BOTH: 26062306a36Sopenharmony_ci dev_dbg(bank->gc.parent, "edge.both\n"); 26162306a36Sopenharmony_ci npcm_gpio_set(&bank->gc, bank->base + NPCM7XX_GP_N_EVBE, gpio); 26262306a36Sopenharmony_ci break; 26362306a36Sopenharmony_ci case IRQ_TYPE_LEVEL_LOW: 26462306a36Sopenharmony_ci dev_dbg(bank->gc.parent, "level.low\n"); 26562306a36Sopenharmony_ci npcm_gpio_set(&bank->gc, bank->base + NPCM7XX_GP_N_POL, gpio); 26662306a36Sopenharmony_ci break; 26762306a36Sopenharmony_ci case IRQ_TYPE_LEVEL_HIGH: 26862306a36Sopenharmony_ci dev_dbg(bank->gc.parent, "level.high\n"); 26962306a36Sopenharmony_ci npcm_gpio_clr(&bank->gc, bank->base + NPCM7XX_GP_N_POL, gpio); 27062306a36Sopenharmony_ci break; 27162306a36Sopenharmony_ci default: 27262306a36Sopenharmony_ci dev_dbg(bank->gc.parent, "invalid irq type\n"); 27362306a36Sopenharmony_ci return -EINVAL; 27462306a36Sopenharmony_ci } 27562306a36Sopenharmony_ci 27662306a36Sopenharmony_ci if (type & (IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW)) { 27762306a36Sopenharmony_ci npcm_gpio_clr(&bank->gc, bank->base + NPCM7XX_GP_N_EVTYP, gpio); 27862306a36Sopenharmony_ci irq_set_handler_locked(d, handle_level_irq); 27962306a36Sopenharmony_ci } else if (type & (IRQ_TYPE_EDGE_BOTH | IRQ_TYPE_EDGE_RISING 28062306a36Sopenharmony_ci | IRQ_TYPE_EDGE_FALLING)) { 28162306a36Sopenharmony_ci npcm_gpio_set(&bank->gc, bank->base + NPCM7XX_GP_N_EVTYP, gpio); 28262306a36Sopenharmony_ci irq_set_handler_locked(d, handle_edge_irq); 28362306a36Sopenharmony_ci } 28462306a36Sopenharmony_ci 28562306a36Sopenharmony_ci return 0; 28662306a36Sopenharmony_ci} 28762306a36Sopenharmony_ci 28862306a36Sopenharmony_cistatic void npcmgpio_irq_ack(struct irq_data *d) 28962306a36Sopenharmony_ci{ 29062306a36Sopenharmony_ci struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 29162306a36Sopenharmony_ci struct npcm7xx_gpio *bank = gpiochip_get_data(gc); 29262306a36Sopenharmony_ci unsigned int gpio = irqd_to_hwirq(d); 29362306a36Sopenharmony_ci 29462306a36Sopenharmony_ci dev_dbg(bank->gc.parent, "irq_ack: %u.%u\n", gpio, d->irq); 29562306a36Sopenharmony_ci iowrite32(BIT(gpio), bank->base + NPCM7XX_GP_N_EVST); 29662306a36Sopenharmony_ci} 29762306a36Sopenharmony_ci 29862306a36Sopenharmony_ci/* Disable GPIO interrupt */ 29962306a36Sopenharmony_cistatic void npcmgpio_irq_mask(struct irq_data *d) 30062306a36Sopenharmony_ci{ 30162306a36Sopenharmony_ci struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 30262306a36Sopenharmony_ci struct npcm7xx_gpio *bank = gpiochip_get_data(gc); 30362306a36Sopenharmony_ci unsigned int gpio = irqd_to_hwirq(d); 30462306a36Sopenharmony_ci 30562306a36Sopenharmony_ci /* Clear events */ 30662306a36Sopenharmony_ci dev_dbg(bank->gc.parent, "irq_mask: %u.%u\n", gpio, d->irq); 30762306a36Sopenharmony_ci iowrite32(BIT(gpio), bank->base + NPCM7XX_GP_N_EVENC); 30862306a36Sopenharmony_ci gpiochip_disable_irq(gc, gpio); 30962306a36Sopenharmony_ci} 31062306a36Sopenharmony_ci 31162306a36Sopenharmony_ci/* Enable GPIO interrupt */ 31262306a36Sopenharmony_cistatic void npcmgpio_irq_unmask(struct irq_data *d) 31362306a36Sopenharmony_ci{ 31462306a36Sopenharmony_ci struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 31562306a36Sopenharmony_ci struct npcm7xx_gpio *bank = gpiochip_get_data(gc); 31662306a36Sopenharmony_ci unsigned int gpio = irqd_to_hwirq(d); 31762306a36Sopenharmony_ci 31862306a36Sopenharmony_ci /* Enable events */ 31962306a36Sopenharmony_ci gpiochip_enable_irq(gc, gpio); 32062306a36Sopenharmony_ci dev_dbg(bank->gc.parent, "irq_unmask: %u.%u\n", gpio, d->irq); 32162306a36Sopenharmony_ci iowrite32(BIT(gpio), bank->base + NPCM7XX_GP_N_EVENS); 32262306a36Sopenharmony_ci} 32362306a36Sopenharmony_ci 32462306a36Sopenharmony_cistatic unsigned int npcmgpio_irq_startup(struct irq_data *d) 32562306a36Sopenharmony_ci{ 32662306a36Sopenharmony_ci struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 32762306a36Sopenharmony_ci unsigned int gpio = irqd_to_hwirq(d); 32862306a36Sopenharmony_ci 32962306a36Sopenharmony_ci /* active-high, input, clear interrupt, enable interrupt */ 33062306a36Sopenharmony_ci dev_dbg(gc->parent, "startup: %u.%u\n", gpio, d->irq); 33162306a36Sopenharmony_ci npcmgpio_direction_input(gc, gpio); 33262306a36Sopenharmony_ci npcmgpio_irq_ack(d); 33362306a36Sopenharmony_ci npcmgpio_irq_unmask(d); 33462306a36Sopenharmony_ci 33562306a36Sopenharmony_ci return 0; 33662306a36Sopenharmony_ci} 33762306a36Sopenharmony_ci 33862306a36Sopenharmony_cistatic const struct irq_chip npcmgpio_irqchip = { 33962306a36Sopenharmony_ci .name = "NPCM7XX-GPIO-IRQ", 34062306a36Sopenharmony_ci .irq_ack = npcmgpio_irq_ack, 34162306a36Sopenharmony_ci .irq_unmask = npcmgpio_irq_unmask, 34262306a36Sopenharmony_ci .irq_mask = npcmgpio_irq_mask, 34362306a36Sopenharmony_ci .irq_set_type = npcmgpio_set_irq_type, 34462306a36Sopenharmony_ci .irq_startup = npcmgpio_irq_startup, 34562306a36Sopenharmony_ci .flags = IRQCHIP_IMMUTABLE, 34662306a36Sopenharmony_ci GPIOCHIP_IRQ_RESOURCE_HELPERS, 34762306a36Sopenharmony_ci}; 34862306a36Sopenharmony_ci 34962306a36Sopenharmony_ci/* pinmux handing in the pinctrl driver*/ 35062306a36Sopenharmony_cistatic const int smb0_pins[] = { 115, 114 }; 35162306a36Sopenharmony_cistatic const int smb0b_pins[] = { 195, 194 }; 35262306a36Sopenharmony_cistatic const int smb0c_pins[] = { 202, 196 }; 35362306a36Sopenharmony_cistatic const int smb0d_pins[] = { 198, 199 }; 35462306a36Sopenharmony_cistatic const int smb0den_pins[] = { 197 }; 35562306a36Sopenharmony_ci 35662306a36Sopenharmony_cistatic const int smb1_pins[] = { 117, 116 }; 35762306a36Sopenharmony_cistatic const int smb1b_pins[] = { 126, 127 }; 35862306a36Sopenharmony_cistatic const int smb1c_pins[] = { 124, 125 }; 35962306a36Sopenharmony_cistatic const int smb1d_pins[] = { 4, 5 }; 36062306a36Sopenharmony_ci 36162306a36Sopenharmony_cistatic const int smb2_pins[] = { 119, 118 }; 36262306a36Sopenharmony_cistatic const int smb2b_pins[] = { 122, 123 }; 36362306a36Sopenharmony_cistatic const int smb2c_pins[] = { 120, 121 }; 36462306a36Sopenharmony_cistatic const int smb2d_pins[] = { 6, 7 }; 36562306a36Sopenharmony_ci 36662306a36Sopenharmony_cistatic const int smb3_pins[] = { 30, 31 }; 36762306a36Sopenharmony_cistatic const int smb3b_pins[] = { 39, 40 }; 36862306a36Sopenharmony_cistatic const int smb3c_pins[] = { 37, 38 }; 36962306a36Sopenharmony_cistatic const int smb3d_pins[] = { 59, 60 }; 37062306a36Sopenharmony_ci 37162306a36Sopenharmony_cistatic const int smb4_pins[] = { 28, 29 }; 37262306a36Sopenharmony_cistatic const int smb4b_pins[] = { 18, 19 }; 37362306a36Sopenharmony_cistatic const int smb4c_pins[] = { 20, 21 }; 37462306a36Sopenharmony_cistatic const int smb4d_pins[] = { 22, 23 }; 37562306a36Sopenharmony_cistatic const int smb4den_pins[] = { 17 }; 37662306a36Sopenharmony_ci 37762306a36Sopenharmony_cistatic const int smb5_pins[] = { 26, 27 }; 37862306a36Sopenharmony_cistatic const int smb5b_pins[] = { 13, 12 }; 37962306a36Sopenharmony_cistatic const int smb5c_pins[] = { 15, 14 }; 38062306a36Sopenharmony_cistatic const int smb5d_pins[] = { 94, 93 }; 38162306a36Sopenharmony_cistatic const int ga20kbc_pins[] = { 94, 93 }; 38262306a36Sopenharmony_ci 38362306a36Sopenharmony_cistatic const int smb6_pins[] = { 172, 171 }; 38462306a36Sopenharmony_cistatic const int smb7_pins[] = { 174, 173 }; 38562306a36Sopenharmony_cistatic const int smb8_pins[] = { 129, 128 }; 38662306a36Sopenharmony_cistatic const int smb9_pins[] = { 131, 130 }; 38762306a36Sopenharmony_cistatic const int smb10_pins[] = { 133, 132 }; 38862306a36Sopenharmony_cistatic const int smb11_pins[] = { 135, 134 }; 38962306a36Sopenharmony_cistatic const int smb12_pins[] = { 221, 220 }; 39062306a36Sopenharmony_cistatic const int smb13_pins[] = { 223, 222 }; 39162306a36Sopenharmony_cistatic const int smb14_pins[] = { 22, 23 }; 39262306a36Sopenharmony_cistatic const int smb15_pins[] = { 20, 21 }; 39362306a36Sopenharmony_ci 39462306a36Sopenharmony_cistatic const int fanin0_pins[] = { 64 }; 39562306a36Sopenharmony_cistatic const int fanin1_pins[] = { 65 }; 39662306a36Sopenharmony_cistatic const int fanin2_pins[] = { 66 }; 39762306a36Sopenharmony_cistatic const int fanin3_pins[] = { 67 }; 39862306a36Sopenharmony_cistatic const int fanin4_pins[] = { 68 }; 39962306a36Sopenharmony_cistatic const int fanin5_pins[] = { 69 }; 40062306a36Sopenharmony_cistatic const int fanin6_pins[] = { 70 }; 40162306a36Sopenharmony_cistatic const int fanin7_pins[] = { 71 }; 40262306a36Sopenharmony_cistatic const int fanin8_pins[] = { 72 }; 40362306a36Sopenharmony_cistatic const int fanin9_pins[] = { 73 }; 40462306a36Sopenharmony_cistatic const int fanin10_pins[] = { 74 }; 40562306a36Sopenharmony_cistatic const int fanin11_pins[] = { 75 }; 40662306a36Sopenharmony_cistatic const int fanin12_pins[] = { 76 }; 40762306a36Sopenharmony_cistatic const int fanin13_pins[] = { 77 }; 40862306a36Sopenharmony_cistatic const int fanin14_pins[] = { 78 }; 40962306a36Sopenharmony_cistatic const int fanin15_pins[] = { 79 }; 41062306a36Sopenharmony_cistatic const int faninx_pins[] = { 175, 176, 177, 203 }; 41162306a36Sopenharmony_ci 41262306a36Sopenharmony_cistatic const int pwm0_pins[] = { 80 }; 41362306a36Sopenharmony_cistatic const int pwm1_pins[] = { 81 }; 41462306a36Sopenharmony_cistatic const int pwm2_pins[] = { 82 }; 41562306a36Sopenharmony_cistatic const int pwm3_pins[] = { 83 }; 41662306a36Sopenharmony_cistatic const int pwm4_pins[] = { 144 }; 41762306a36Sopenharmony_cistatic const int pwm5_pins[] = { 145 }; 41862306a36Sopenharmony_cistatic const int pwm6_pins[] = { 146 }; 41962306a36Sopenharmony_cistatic const int pwm7_pins[] = { 147 }; 42062306a36Sopenharmony_ci 42162306a36Sopenharmony_cistatic const int uart1_pins[] = { 43, 44, 45, 46, 47, 61, 62, 63 }; 42262306a36Sopenharmony_cistatic const int uart2_pins[] = { 48, 49, 50, 51, 52, 53, 54, 55 }; 42362306a36Sopenharmony_ci 42462306a36Sopenharmony_ci/* RGMII 1 pin group */ 42562306a36Sopenharmony_cistatic const int rg1_pins[] = { 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 42662306a36Sopenharmony_ci 106, 107 }; 42762306a36Sopenharmony_ci/* RGMII 1 MD interface pin group */ 42862306a36Sopenharmony_cistatic const int rg1mdio_pins[] = { 108, 109 }; 42962306a36Sopenharmony_ci 43062306a36Sopenharmony_ci/* RGMII 2 pin group */ 43162306a36Sopenharmony_cistatic const int rg2_pins[] = { 110, 111, 112, 113, 208, 209, 210, 211, 212, 43262306a36Sopenharmony_ci 213, 214, 215 }; 43362306a36Sopenharmony_ci/* RGMII 2 MD interface pin group */ 43462306a36Sopenharmony_cistatic const int rg2mdio_pins[] = { 216, 217 }; 43562306a36Sopenharmony_ci 43662306a36Sopenharmony_cistatic const int ddr_pins[] = { 110, 111, 112, 113, 208, 209, 210, 211, 212, 43762306a36Sopenharmony_ci 213, 214, 215, 216, 217 }; 43862306a36Sopenharmony_ci/* Serial I/O Expander 1 */ 43962306a36Sopenharmony_cistatic const int iox1_pins[] = { 0, 1, 2, 3 }; 44062306a36Sopenharmony_ci/* Serial I/O Expander 2 */ 44162306a36Sopenharmony_cistatic const int iox2_pins[] = { 4, 5, 6, 7 }; 44262306a36Sopenharmony_ci/* Host Serial I/O Expander 2 */ 44362306a36Sopenharmony_cistatic const int ioxh_pins[] = { 10, 11, 24, 25 }; 44462306a36Sopenharmony_ci 44562306a36Sopenharmony_cistatic const int mmc_pins[] = { 152, 154, 156, 157, 158, 159 }; 44662306a36Sopenharmony_cistatic const int mmcwp_pins[] = { 153 }; 44762306a36Sopenharmony_cistatic const int mmccd_pins[] = { 155 }; 44862306a36Sopenharmony_cistatic const int mmcrst_pins[] = { 155 }; 44962306a36Sopenharmony_cistatic const int mmc8_pins[] = { 148, 149, 150, 151 }; 45062306a36Sopenharmony_ci 45162306a36Sopenharmony_ci/* RMII 1 pin groups */ 45262306a36Sopenharmony_cistatic const int r1_pins[] = { 178, 179, 180, 181, 182, 193, 201 }; 45362306a36Sopenharmony_cistatic const int r1err_pins[] = { 56 }; 45462306a36Sopenharmony_cistatic const int r1md_pins[] = { 57, 58 }; 45562306a36Sopenharmony_ci 45662306a36Sopenharmony_ci/* RMII 2 pin groups */ 45762306a36Sopenharmony_cistatic const int r2_pins[] = { 84, 85, 86, 87, 88, 89, 200 }; 45862306a36Sopenharmony_cistatic const int r2err_pins[] = { 90 }; 45962306a36Sopenharmony_cistatic const int r2md_pins[] = { 91, 92 }; 46062306a36Sopenharmony_ci 46162306a36Sopenharmony_cistatic const int sd1_pins[] = { 136, 137, 138, 139, 140, 141, 142, 143 }; 46262306a36Sopenharmony_cistatic const int sd1pwr_pins[] = { 143 }; 46362306a36Sopenharmony_ci 46462306a36Sopenharmony_cistatic const int wdog1_pins[] = { 218 }; 46562306a36Sopenharmony_cistatic const int wdog2_pins[] = { 219 }; 46662306a36Sopenharmony_ci 46762306a36Sopenharmony_ci/* BMC serial port 0 */ 46862306a36Sopenharmony_cistatic const int bmcuart0a_pins[] = { 41, 42 }; 46962306a36Sopenharmony_cistatic const int bmcuart0b_pins[] = { 48, 49 }; 47062306a36Sopenharmony_ci 47162306a36Sopenharmony_cistatic const int bmcuart1_pins[] = { 43, 44, 62, 63 }; 47262306a36Sopenharmony_ci 47362306a36Sopenharmony_ci/* System Control Interrupt and Power Management Event pin group */ 47462306a36Sopenharmony_cistatic const int scipme_pins[] = { 169 }; 47562306a36Sopenharmony_ci/* System Management Interrupt pin group */ 47662306a36Sopenharmony_cistatic const int sci_pins[] = { 170 }; 47762306a36Sopenharmony_ci/* Serial Interrupt Line pin group */ 47862306a36Sopenharmony_cistatic const int serirq_pins[] = { 162 }; 47962306a36Sopenharmony_ci 48062306a36Sopenharmony_cistatic const int clkout_pins[] = { 160 }; 48162306a36Sopenharmony_cistatic const int clkreq_pins[] = { 231 }; 48262306a36Sopenharmony_ci 48362306a36Sopenharmony_cistatic const int jtag2_pins[] = { 43, 44, 45, 46, 47 }; 48462306a36Sopenharmony_ci/* Graphics SPI Clock pin group */ 48562306a36Sopenharmony_cistatic const int gspi_pins[] = { 12, 13, 14, 15 }; 48662306a36Sopenharmony_ci 48762306a36Sopenharmony_cistatic const int spix_pins[] = { 224, 225, 226, 227, 229, 230 }; 48862306a36Sopenharmony_cistatic const int spixcs1_pins[] = { 228 }; 48962306a36Sopenharmony_ci 49062306a36Sopenharmony_cistatic const int pspi1_pins[] = { 175, 176, 177 }; 49162306a36Sopenharmony_cistatic const int pspi2_pins[] = { 17, 18, 19 }; 49262306a36Sopenharmony_ci 49362306a36Sopenharmony_cistatic const int spi0cs1_pins[] = { 32 }; 49462306a36Sopenharmony_ci 49562306a36Sopenharmony_cistatic const int spi3_pins[] = { 183, 184, 185, 186 }; 49662306a36Sopenharmony_cistatic const int spi3cs1_pins[] = { 187 }; 49762306a36Sopenharmony_cistatic const int spi3quad_pins[] = { 188, 189 }; 49862306a36Sopenharmony_cistatic const int spi3cs2_pins[] = { 188 }; 49962306a36Sopenharmony_cistatic const int spi3cs3_pins[] = { 189 }; 50062306a36Sopenharmony_ci 50162306a36Sopenharmony_cistatic const int ddc_pins[] = { 204, 205, 206, 207 }; 50262306a36Sopenharmony_ci 50362306a36Sopenharmony_cistatic const int lpc_pins[] = { 95, 161, 163, 164, 165, 166, 167 }; 50462306a36Sopenharmony_cistatic const int lpcclk_pins[] = { 168 }; 50562306a36Sopenharmony_cistatic const int espi_pins[] = { 95, 161, 163, 164, 165, 166, 167, 168 }; 50662306a36Sopenharmony_ci 50762306a36Sopenharmony_cistatic const int lkgpo0_pins[] = { 16 }; 50862306a36Sopenharmony_cistatic const int lkgpo1_pins[] = { 8 }; 50962306a36Sopenharmony_cistatic const int lkgpo2_pins[] = { 9 }; 51062306a36Sopenharmony_ci 51162306a36Sopenharmony_cistatic const int nprd_smi_pins[] = { 190 }; 51262306a36Sopenharmony_ci 51362306a36Sopenharmony_ci/* 51462306a36Sopenharmony_ci * pin: name, number 51562306a36Sopenharmony_ci * group: name, npins, pins 51662306a36Sopenharmony_ci * function: name, ngroups, groups 51762306a36Sopenharmony_ci */ 51862306a36Sopenharmony_cistruct npcm7xx_group { 51962306a36Sopenharmony_ci const char *name; 52062306a36Sopenharmony_ci const unsigned int *pins; 52162306a36Sopenharmony_ci int npins; 52262306a36Sopenharmony_ci}; 52362306a36Sopenharmony_ci 52462306a36Sopenharmony_ci#define NPCM7XX_GRPS \ 52562306a36Sopenharmony_ci NPCM7XX_GRP(smb0), \ 52662306a36Sopenharmony_ci NPCM7XX_GRP(smb0b), \ 52762306a36Sopenharmony_ci NPCM7XX_GRP(smb0c), \ 52862306a36Sopenharmony_ci NPCM7XX_GRP(smb0d), \ 52962306a36Sopenharmony_ci NPCM7XX_GRP(smb0den), \ 53062306a36Sopenharmony_ci NPCM7XX_GRP(smb1), \ 53162306a36Sopenharmony_ci NPCM7XX_GRP(smb1b), \ 53262306a36Sopenharmony_ci NPCM7XX_GRP(smb1c), \ 53362306a36Sopenharmony_ci NPCM7XX_GRP(smb1d), \ 53462306a36Sopenharmony_ci NPCM7XX_GRP(smb2), \ 53562306a36Sopenharmony_ci NPCM7XX_GRP(smb2b), \ 53662306a36Sopenharmony_ci NPCM7XX_GRP(smb2c), \ 53762306a36Sopenharmony_ci NPCM7XX_GRP(smb2d), \ 53862306a36Sopenharmony_ci NPCM7XX_GRP(smb3), \ 53962306a36Sopenharmony_ci NPCM7XX_GRP(smb3b), \ 54062306a36Sopenharmony_ci NPCM7XX_GRP(smb3c), \ 54162306a36Sopenharmony_ci NPCM7XX_GRP(smb3d), \ 54262306a36Sopenharmony_ci NPCM7XX_GRP(smb4), \ 54362306a36Sopenharmony_ci NPCM7XX_GRP(smb4b), \ 54462306a36Sopenharmony_ci NPCM7XX_GRP(smb4c), \ 54562306a36Sopenharmony_ci NPCM7XX_GRP(smb4d), \ 54662306a36Sopenharmony_ci NPCM7XX_GRP(smb4den), \ 54762306a36Sopenharmony_ci NPCM7XX_GRP(smb5), \ 54862306a36Sopenharmony_ci NPCM7XX_GRP(smb5b), \ 54962306a36Sopenharmony_ci NPCM7XX_GRP(smb5c), \ 55062306a36Sopenharmony_ci NPCM7XX_GRP(smb5d), \ 55162306a36Sopenharmony_ci NPCM7XX_GRP(ga20kbc), \ 55262306a36Sopenharmony_ci NPCM7XX_GRP(smb6), \ 55362306a36Sopenharmony_ci NPCM7XX_GRP(smb7), \ 55462306a36Sopenharmony_ci NPCM7XX_GRP(smb8), \ 55562306a36Sopenharmony_ci NPCM7XX_GRP(smb9), \ 55662306a36Sopenharmony_ci NPCM7XX_GRP(smb10), \ 55762306a36Sopenharmony_ci NPCM7XX_GRP(smb11), \ 55862306a36Sopenharmony_ci NPCM7XX_GRP(smb12), \ 55962306a36Sopenharmony_ci NPCM7XX_GRP(smb13), \ 56062306a36Sopenharmony_ci NPCM7XX_GRP(smb14), \ 56162306a36Sopenharmony_ci NPCM7XX_GRP(smb15), \ 56262306a36Sopenharmony_ci NPCM7XX_GRP(fanin0), \ 56362306a36Sopenharmony_ci NPCM7XX_GRP(fanin1), \ 56462306a36Sopenharmony_ci NPCM7XX_GRP(fanin2), \ 56562306a36Sopenharmony_ci NPCM7XX_GRP(fanin3), \ 56662306a36Sopenharmony_ci NPCM7XX_GRP(fanin4), \ 56762306a36Sopenharmony_ci NPCM7XX_GRP(fanin5), \ 56862306a36Sopenharmony_ci NPCM7XX_GRP(fanin6), \ 56962306a36Sopenharmony_ci NPCM7XX_GRP(fanin7), \ 57062306a36Sopenharmony_ci NPCM7XX_GRP(fanin8), \ 57162306a36Sopenharmony_ci NPCM7XX_GRP(fanin9), \ 57262306a36Sopenharmony_ci NPCM7XX_GRP(fanin10), \ 57362306a36Sopenharmony_ci NPCM7XX_GRP(fanin11), \ 57462306a36Sopenharmony_ci NPCM7XX_GRP(fanin12), \ 57562306a36Sopenharmony_ci NPCM7XX_GRP(fanin13), \ 57662306a36Sopenharmony_ci NPCM7XX_GRP(fanin14), \ 57762306a36Sopenharmony_ci NPCM7XX_GRP(fanin15), \ 57862306a36Sopenharmony_ci NPCM7XX_GRP(faninx), \ 57962306a36Sopenharmony_ci NPCM7XX_GRP(pwm0), \ 58062306a36Sopenharmony_ci NPCM7XX_GRP(pwm1), \ 58162306a36Sopenharmony_ci NPCM7XX_GRP(pwm2), \ 58262306a36Sopenharmony_ci NPCM7XX_GRP(pwm3), \ 58362306a36Sopenharmony_ci NPCM7XX_GRP(pwm4), \ 58462306a36Sopenharmony_ci NPCM7XX_GRP(pwm5), \ 58562306a36Sopenharmony_ci NPCM7XX_GRP(pwm6), \ 58662306a36Sopenharmony_ci NPCM7XX_GRP(pwm7), \ 58762306a36Sopenharmony_ci NPCM7XX_GRP(rg1), \ 58862306a36Sopenharmony_ci NPCM7XX_GRP(rg1mdio), \ 58962306a36Sopenharmony_ci NPCM7XX_GRP(rg2), \ 59062306a36Sopenharmony_ci NPCM7XX_GRP(rg2mdio), \ 59162306a36Sopenharmony_ci NPCM7XX_GRP(ddr), \ 59262306a36Sopenharmony_ci NPCM7XX_GRP(uart1), \ 59362306a36Sopenharmony_ci NPCM7XX_GRP(uart2), \ 59462306a36Sopenharmony_ci NPCM7XX_GRP(bmcuart0a), \ 59562306a36Sopenharmony_ci NPCM7XX_GRP(bmcuart0b), \ 59662306a36Sopenharmony_ci NPCM7XX_GRP(bmcuart1), \ 59762306a36Sopenharmony_ci NPCM7XX_GRP(iox1), \ 59862306a36Sopenharmony_ci NPCM7XX_GRP(iox2), \ 59962306a36Sopenharmony_ci NPCM7XX_GRP(ioxh), \ 60062306a36Sopenharmony_ci NPCM7XX_GRP(gspi), \ 60162306a36Sopenharmony_ci NPCM7XX_GRP(mmc), \ 60262306a36Sopenharmony_ci NPCM7XX_GRP(mmcwp), \ 60362306a36Sopenharmony_ci NPCM7XX_GRP(mmccd), \ 60462306a36Sopenharmony_ci NPCM7XX_GRP(mmcrst), \ 60562306a36Sopenharmony_ci NPCM7XX_GRP(mmc8), \ 60662306a36Sopenharmony_ci NPCM7XX_GRP(r1), \ 60762306a36Sopenharmony_ci NPCM7XX_GRP(r1err), \ 60862306a36Sopenharmony_ci NPCM7XX_GRP(r1md), \ 60962306a36Sopenharmony_ci NPCM7XX_GRP(r2), \ 61062306a36Sopenharmony_ci NPCM7XX_GRP(r2err), \ 61162306a36Sopenharmony_ci NPCM7XX_GRP(r2md), \ 61262306a36Sopenharmony_ci NPCM7XX_GRP(sd1), \ 61362306a36Sopenharmony_ci NPCM7XX_GRP(sd1pwr), \ 61462306a36Sopenharmony_ci NPCM7XX_GRP(wdog1), \ 61562306a36Sopenharmony_ci NPCM7XX_GRP(wdog2), \ 61662306a36Sopenharmony_ci NPCM7XX_GRP(scipme), \ 61762306a36Sopenharmony_ci NPCM7XX_GRP(sci), \ 61862306a36Sopenharmony_ci NPCM7XX_GRP(serirq), \ 61962306a36Sopenharmony_ci NPCM7XX_GRP(jtag2), \ 62062306a36Sopenharmony_ci NPCM7XX_GRP(spix), \ 62162306a36Sopenharmony_ci NPCM7XX_GRP(spixcs1), \ 62262306a36Sopenharmony_ci NPCM7XX_GRP(pspi1), \ 62362306a36Sopenharmony_ci NPCM7XX_GRP(pspi2), \ 62462306a36Sopenharmony_ci NPCM7XX_GRP(ddc), \ 62562306a36Sopenharmony_ci NPCM7XX_GRP(clkreq), \ 62662306a36Sopenharmony_ci NPCM7XX_GRP(clkout), \ 62762306a36Sopenharmony_ci NPCM7XX_GRP(spi3), \ 62862306a36Sopenharmony_ci NPCM7XX_GRP(spi3cs1), \ 62962306a36Sopenharmony_ci NPCM7XX_GRP(spi3quad), \ 63062306a36Sopenharmony_ci NPCM7XX_GRP(spi3cs2), \ 63162306a36Sopenharmony_ci NPCM7XX_GRP(spi3cs3), \ 63262306a36Sopenharmony_ci NPCM7XX_GRP(spi0cs1), \ 63362306a36Sopenharmony_ci NPCM7XX_GRP(lpc), \ 63462306a36Sopenharmony_ci NPCM7XX_GRP(lpcclk), \ 63562306a36Sopenharmony_ci NPCM7XX_GRP(espi), \ 63662306a36Sopenharmony_ci NPCM7XX_GRP(lkgpo0), \ 63762306a36Sopenharmony_ci NPCM7XX_GRP(lkgpo1), \ 63862306a36Sopenharmony_ci NPCM7XX_GRP(lkgpo2), \ 63962306a36Sopenharmony_ci NPCM7XX_GRP(nprd_smi), \ 64062306a36Sopenharmony_ci \ 64162306a36Sopenharmony_ci 64262306a36Sopenharmony_cienum { 64362306a36Sopenharmony_ci#define NPCM7XX_GRP(x) fn_ ## x 64462306a36Sopenharmony_ci NPCM7XX_GRPS 64562306a36Sopenharmony_ci /* add placeholder for none/gpio */ 64662306a36Sopenharmony_ci NPCM7XX_GRP(none), 64762306a36Sopenharmony_ci NPCM7XX_GRP(gpio), 64862306a36Sopenharmony_ci#undef NPCM7XX_GRP 64962306a36Sopenharmony_ci}; 65062306a36Sopenharmony_ci 65162306a36Sopenharmony_cistatic struct npcm7xx_group npcm7xx_groups[] = { 65262306a36Sopenharmony_ci#define NPCM7XX_GRP(x) { .name = #x, .pins = x ## _pins, \ 65362306a36Sopenharmony_ci .npins = ARRAY_SIZE(x ## _pins) } 65462306a36Sopenharmony_ci NPCM7XX_GRPS 65562306a36Sopenharmony_ci#undef NPCM7XX_GRP 65662306a36Sopenharmony_ci}; 65762306a36Sopenharmony_ci 65862306a36Sopenharmony_ci#define NPCM7XX_SFUNC(a) NPCM7XX_FUNC(a, #a) 65962306a36Sopenharmony_ci#define NPCM7XX_FUNC(a, b...) static const char *a ## _grp[] = { b } 66062306a36Sopenharmony_ci#define NPCM7XX_MKFUNC(nm) { .name = #nm, .ngroups = ARRAY_SIZE(nm ## _grp), \ 66162306a36Sopenharmony_ci .groups = nm ## _grp } 66262306a36Sopenharmony_cistruct npcm7xx_func { 66362306a36Sopenharmony_ci const char *name; 66462306a36Sopenharmony_ci const unsigned int ngroups; 66562306a36Sopenharmony_ci const char *const *groups; 66662306a36Sopenharmony_ci}; 66762306a36Sopenharmony_ci 66862306a36Sopenharmony_ciNPCM7XX_SFUNC(smb0); 66962306a36Sopenharmony_ciNPCM7XX_SFUNC(smb0b); 67062306a36Sopenharmony_ciNPCM7XX_SFUNC(smb0c); 67162306a36Sopenharmony_ciNPCM7XX_SFUNC(smb0d); 67262306a36Sopenharmony_ciNPCM7XX_SFUNC(smb0den); 67362306a36Sopenharmony_ciNPCM7XX_SFUNC(smb1); 67462306a36Sopenharmony_ciNPCM7XX_SFUNC(smb1b); 67562306a36Sopenharmony_ciNPCM7XX_SFUNC(smb1c); 67662306a36Sopenharmony_ciNPCM7XX_SFUNC(smb1d); 67762306a36Sopenharmony_ciNPCM7XX_SFUNC(smb2); 67862306a36Sopenharmony_ciNPCM7XX_SFUNC(smb2b); 67962306a36Sopenharmony_ciNPCM7XX_SFUNC(smb2c); 68062306a36Sopenharmony_ciNPCM7XX_SFUNC(smb2d); 68162306a36Sopenharmony_ciNPCM7XX_SFUNC(smb3); 68262306a36Sopenharmony_ciNPCM7XX_SFUNC(smb3b); 68362306a36Sopenharmony_ciNPCM7XX_SFUNC(smb3c); 68462306a36Sopenharmony_ciNPCM7XX_SFUNC(smb3d); 68562306a36Sopenharmony_ciNPCM7XX_SFUNC(smb4); 68662306a36Sopenharmony_ciNPCM7XX_SFUNC(smb4b); 68762306a36Sopenharmony_ciNPCM7XX_SFUNC(smb4c); 68862306a36Sopenharmony_ciNPCM7XX_SFUNC(smb4d); 68962306a36Sopenharmony_ciNPCM7XX_SFUNC(smb4den); 69062306a36Sopenharmony_ciNPCM7XX_SFUNC(smb5); 69162306a36Sopenharmony_ciNPCM7XX_SFUNC(smb5b); 69262306a36Sopenharmony_ciNPCM7XX_SFUNC(smb5c); 69362306a36Sopenharmony_ciNPCM7XX_SFUNC(smb5d); 69462306a36Sopenharmony_ciNPCM7XX_SFUNC(ga20kbc); 69562306a36Sopenharmony_ciNPCM7XX_SFUNC(smb6); 69662306a36Sopenharmony_ciNPCM7XX_SFUNC(smb7); 69762306a36Sopenharmony_ciNPCM7XX_SFUNC(smb8); 69862306a36Sopenharmony_ciNPCM7XX_SFUNC(smb9); 69962306a36Sopenharmony_ciNPCM7XX_SFUNC(smb10); 70062306a36Sopenharmony_ciNPCM7XX_SFUNC(smb11); 70162306a36Sopenharmony_ciNPCM7XX_SFUNC(smb12); 70262306a36Sopenharmony_ciNPCM7XX_SFUNC(smb13); 70362306a36Sopenharmony_ciNPCM7XX_SFUNC(smb14); 70462306a36Sopenharmony_ciNPCM7XX_SFUNC(smb15); 70562306a36Sopenharmony_ciNPCM7XX_SFUNC(fanin0); 70662306a36Sopenharmony_ciNPCM7XX_SFUNC(fanin1); 70762306a36Sopenharmony_ciNPCM7XX_SFUNC(fanin2); 70862306a36Sopenharmony_ciNPCM7XX_SFUNC(fanin3); 70962306a36Sopenharmony_ciNPCM7XX_SFUNC(fanin4); 71062306a36Sopenharmony_ciNPCM7XX_SFUNC(fanin5); 71162306a36Sopenharmony_ciNPCM7XX_SFUNC(fanin6); 71262306a36Sopenharmony_ciNPCM7XX_SFUNC(fanin7); 71362306a36Sopenharmony_ciNPCM7XX_SFUNC(fanin8); 71462306a36Sopenharmony_ciNPCM7XX_SFUNC(fanin9); 71562306a36Sopenharmony_ciNPCM7XX_SFUNC(fanin10); 71662306a36Sopenharmony_ciNPCM7XX_SFUNC(fanin11); 71762306a36Sopenharmony_ciNPCM7XX_SFUNC(fanin12); 71862306a36Sopenharmony_ciNPCM7XX_SFUNC(fanin13); 71962306a36Sopenharmony_ciNPCM7XX_SFUNC(fanin14); 72062306a36Sopenharmony_ciNPCM7XX_SFUNC(fanin15); 72162306a36Sopenharmony_ciNPCM7XX_SFUNC(faninx); 72262306a36Sopenharmony_ciNPCM7XX_SFUNC(pwm0); 72362306a36Sopenharmony_ciNPCM7XX_SFUNC(pwm1); 72462306a36Sopenharmony_ciNPCM7XX_SFUNC(pwm2); 72562306a36Sopenharmony_ciNPCM7XX_SFUNC(pwm3); 72662306a36Sopenharmony_ciNPCM7XX_SFUNC(pwm4); 72762306a36Sopenharmony_ciNPCM7XX_SFUNC(pwm5); 72862306a36Sopenharmony_ciNPCM7XX_SFUNC(pwm6); 72962306a36Sopenharmony_ciNPCM7XX_SFUNC(pwm7); 73062306a36Sopenharmony_ciNPCM7XX_SFUNC(rg1); 73162306a36Sopenharmony_ciNPCM7XX_SFUNC(rg1mdio); 73262306a36Sopenharmony_ciNPCM7XX_SFUNC(rg2); 73362306a36Sopenharmony_ciNPCM7XX_SFUNC(rg2mdio); 73462306a36Sopenharmony_ciNPCM7XX_SFUNC(ddr); 73562306a36Sopenharmony_ciNPCM7XX_SFUNC(uart1); 73662306a36Sopenharmony_ciNPCM7XX_SFUNC(uart2); 73762306a36Sopenharmony_ciNPCM7XX_SFUNC(bmcuart0a); 73862306a36Sopenharmony_ciNPCM7XX_SFUNC(bmcuart0b); 73962306a36Sopenharmony_ciNPCM7XX_SFUNC(bmcuart1); 74062306a36Sopenharmony_ciNPCM7XX_SFUNC(iox1); 74162306a36Sopenharmony_ciNPCM7XX_SFUNC(iox2); 74262306a36Sopenharmony_ciNPCM7XX_SFUNC(ioxh); 74362306a36Sopenharmony_ciNPCM7XX_SFUNC(gspi); 74462306a36Sopenharmony_ciNPCM7XX_SFUNC(mmc); 74562306a36Sopenharmony_ciNPCM7XX_SFUNC(mmcwp); 74662306a36Sopenharmony_ciNPCM7XX_SFUNC(mmccd); 74762306a36Sopenharmony_ciNPCM7XX_SFUNC(mmcrst); 74862306a36Sopenharmony_ciNPCM7XX_SFUNC(mmc8); 74962306a36Sopenharmony_ciNPCM7XX_SFUNC(r1); 75062306a36Sopenharmony_ciNPCM7XX_SFUNC(r1err); 75162306a36Sopenharmony_ciNPCM7XX_SFUNC(r1md); 75262306a36Sopenharmony_ciNPCM7XX_SFUNC(r2); 75362306a36Sopenharmony_ciNPCM7XX_SFUNC(r2err); 75462306a36Sopenharmony_ciNPCM7XX_SFUNC(r2md); 75562306a36Sopenharmony_ciNPCM7XX_SFUNC(sd1); 75662306a36Sopenharmony_ciNPCM7XX_SFUNC(sd1pwr); 75762306a36Sopenharmony_ciNPCM7XX_SFUNC(wdog1); 75862306a36Sopenharmony_ciNPCM7XX_SFUNC(wdog2); 75962306a36Sopenharmony_ciNPCM7XX_SFUNC(scipme); 76062306a36Sopenharmony_ciNPCM7XX_SFUNC(sci); 76162306a36Sopenharmony_ciNPCM7XX_SFUNC(serirq); 76262306a36Sopenharmony_ciNPCM7XX_SFUNC(jtag2); 76362306a36Sopenharmony_ciNPCM7XX_SFUNC(spix); 76462306a36Sopenharmony_ciNPCM7XX_SFUNC(spixcs1); 76562306a36Sopenharmony_ciNPCM7XX_SFUNC(pspi1); 76662306a36Sopenharmony_ciNPCM7XX_SFUNC(pspi2); 76762306a36Sopenharmony_ciNPCM7XX_SFUNC(ddc); 76862306a36Sopenharmony_ciNPCM7XX_SFUNC(clkreq); 76962306a36Sopenharmony_ciNPCM7XX_SFUNC(clkout); 77062306a36Sopenharmony_ciNPCM7XX_SFUNC(spi3); 77162306a36Sopenharmony_ciNPCM7XX_SFUNC(spi3cs1); 77262306a36Sopenharmony_ciNPCM7XX_SFUNC(spi3quad); 77362306a36Sopenharmony_ciNPCM7XX_SFUNC(spi3cs2); 77462306a36Sopenharmony_ciNPCM7XX_SFUNC(spi3cs3); 77562306a36Sopenharmony_ciNPCM7XX_SFUNC(spi0cs1); 77662306a36Sopenharmony_ciNPCM7XX_SFUNC(lpc); 77762306a36Sopenharmony_ciNPCM7XX_SFUNC(lpcclk); 77862306a36Sopenharmony_ciNPCM7XX_SFUNC(espi); 77962306a36Sopenharmony_ciNPCM7XX_SFUNC(lkgpo0); 78062306a36Sopenharmony_ciNPCM7XX_SFUNC(lkgpo1); 78162306a36Sopenharmony_ciNPCM7XX_SFUNC(lkgpo2); 78262306a36Sopenharmony_ciNPCM7XX_SFUNC(nprd_smi); 78362306a36Sopenharmony_ci 78462306a36Sopenharmony_ci/* Function names */ 78562306a36Sopenharmony_cistatic struct npcm7xx_func npcm7xx_funcs[] = { 78662306a36Sopenharmony_ci NPCM7XX_MKFUNC(smb0), 78762306a36Sopenharmony_ci NPCM7XX_MKFUNC(smb0b), 78862306a36Sopenharmony_ci NPCM7XX_MKFUNC(smb0c), 78962306a36Sopenharmony_ci NPCM7XX_MKFUNC(smb0d), 79062306a36Sopenharmony_ci NPCM7XX_MKFUNC(smb0den), 79162306a36Sopenharmony_ci NPCM7XX_MKFUNC(smb1), 79262306a36Sopenharmony_ci NPCM7XX_MKFUNC(smb1b), 79362306a36Sopenharmony_ci NPCM7XX_MKFUNC(smb1c), 79462306a36Sopenharmony_ci NPCM7XX_MKFUNC(smb1d), 79562306a36Sopenharmony_ci NPCM7XX_MKFUNC(smb2), 79662306a36Sopenharmony_ci NPCM7XX_MKFUNC(smb2b), 79762306a36Sopenharmony_ci NPCM7XX_MKFUNC(smb2c), 79862306a36Sopenharmony_ci NPCM7XX_MKFUNC(smb2d), 79962306a36Sopenharmony_ci NPCM7XX_MKFUNC(smb3), 80062306a36Sopenharmony_ci NPCM7XX_MKFUNC(smb3b), 80162306a36Sopenharmony_ci NPCM7XX_MKFUNC(smb3c), 80262306a36Sopenharmony_ci NPCM7XX_MKFUNC(smb3d), 80362306a36Sopenharmony_ci NPCM7XX_MKFUNC(smb4), 80462306a36Sopenharmony_ci NPCM7XX_MKFUNC(smb4b), 80562306a36Sopenharmony_ci NPCM7XX_MKFUNC(smb4c), 80662306a36Sopenharmony_ci NPCM7XX_MKFUNC(smb4d), 80762306a36Sopenharmony_ci NPCM7XX_MKFUNC(smb4den), 80862306a36Sopenharmony_ci NPCM7XX_MKFUNC(smb5), 80962306a36Sopenharmony_ci NPCM7XX_MKFUNC(smb5b), 81062306a36Sopenharmony_ci NPCM7XX_MKFUNC(smb5c), 81162306a36Sopenharmony_ci NPCM7XX_MKFUNC(smb5d), 81262306a36Sopenharmony_ci NPCM7XX_MKFUNC(ga20kbc), 81362306a36Sopenharmony_ci NPCM7XX_MKFUNC(smb6), 81462306a36Sopenharmony_ci NPCM7XX_MKFUNC(smb7), 81562306a36Sopenharmony_ci NPCM7XX_MKFUNC(smb8), 81662306a36Sopenharmony_ci NPCM7XX_MKFUNC(smb9), 81762306a36Sopenharmony_ci NPCM7XX_MKFUNC(smb10), 81862306a36Sopenharmony_ci NPCM7XX_MKFUNC(smb11), 81962306a36Sopenharmony_ci NPCM7XX_MKFUNC(smb12), 82062306a36Sopenharmony_ci NPCM7XX_MKFUNC(smb13), 82162306a36Sopenharmony_ci NPCM7XX_MKFUNC(smb14), 82262306a36Sopenharmony_ci NPCM7XX_MKFUNC(smb15), 82362306a36Sopenharmony_ci NPCM7XX_MKFUNC(fanin0), 82462306a36Sopenharmony_ci NPCM7XX_MKFUNC(fanin1), 82562306a36Sopenharmony_ci NPCM7XX_MKFUNC(fanin2), 82662306a36Sopenharmony_ci NPCM7XX_MKFUNC(fanin3), 82762306a36Sopenharmony_ci NPCM7XX_MKFUNC(fanin4), 82862306a36Sopenharmony_ci NPCM7XX_MKFUNC(fanin5), 82962306a36Sopenharmony_ci NPCM7XX_MKFUNC(fanin6), 83062306a36Sopenharmony_ci NPCM7XX_MKFUNC(fanin7), 83162306a36Sopenharmony_ci NPCM7XX_MKFUNC(fanin8), 83262306a36Sopenharmony_ci NPCM7XX_MKFUNC(fanin9), 83362306a36Sopenharmony_ci NPCM7XX_MKFUNC(fanin10), 83462306a36Sopenharmony_ci NPCM7XX_MKFUNC(fanin11), 83562306a36Sopenharmony_ci NPCM7XX_MKFUNC(fanin12), 83662306a36Sopenharmony_ci NPCM7XX_MKFUNC(fanin13), 83762306a36Sopenharmony_ci NPCM7XX_MKFUNC(fanin14), 83862306a36Sopenharmony_ci NPCM7XX_MKFUNC(fanin15), 83962306a36Sopenharmony_ci NPCM7XX_MKFUNC(faninx), 84062306a36Sopenharmony_ci NPCM7XX_MKFUNC(pwm0), 84162306a36Sopenharmony_ci NPCM7XX_MKFUNC(pwm1), 84262306a36Sopenharmony_ci NPCM7XX_MKFUNC(pwm2), 84362306a36Sopenharmony_ci NPCM7XX_MKFUNC(pwm3), 84462306a36Sopenharmony_ci NPCM7XX_MKFUNC(pwm4), 84562306a36Sopenharmony_ci NPCM7XX_MKFUNC(pwm5), 84662306a36Sopenharmony_ci NPCM7XX_MKFUNC(pwm6), 84762306a36Sopenharmony_ci NPCM7XX_MKFUNC(pwm7), 84862306a36Sopenharmony_ci NPCM7XX_MKFUNC(rg1), 84962306a36Sopenharmony_ci NPCM7XX_MKFUNC(rg1mdio), 85062306a36Sopenharmony_ci NPCM7XX_MKFUNC(rg2), 85162306a36Sopenharmony_ci NPCM7XX_MKFUNC(rg2mdio), 85262306a36Sopenharmony_ci NPCM7XX_MKFUNC(ddr), 85362306a36Sopenharmony_ci NPCM7XX_MKFUNC(uart1), 85462306a36Sopenharmony_ci NPCM7XX_MKFUNC(uart2), 85562306a36Sopenharmony_ci NPCM7XX_MKFUNC(bmcuart0a), 85662306a36Sopenharmony_ci NPCM7XX_MKFUNC(bmcuart0b), 85762306a36Sopenharmony_ci NPCM7XX_MKFUNC(bmcuart1), 85862306a36Sopenharmony_ci NPCM7XX_MKFUNC(iox1), 85962306a36Sopenharmony_ci NPCM7XX_MKFUNC(iox2), 86062306a36Sopenharmony_ci NPCM7XX_MKFUNC(ioxh), 86162306a36Sopenharmony_ci NPCM7XX_MKFUNC(gspi), 86262306a36Sopenharmony_ci NPCM7XX_MKFUNC(mmc), 86362306a36Sopenharmony_ci NPCM7XX_MKFUNC(mmcwp), 86462306a36Sopenharmony_ci NPCM7XX_MKFUNC(mmccd), 86562306a36Sopenharmony_ci NPCM7XX_MKFUNC(mmcrst), 86662306a36Sopenharmony_ci NPCM7XX_MKFUNC(mmc8), 86762306a36Sopenharmony_ci NPCM7XX_MKFUNC(r1), 86862306a36Sopenharmony_ci NPCM7XX_MKFUNC(r1err), 86962306a36Sopenharmony_ci NPCM7XX_MKFUNC(r1md), 87062306a36Sopenharmony_ci NPCM7XX_MKFUNC(r2), 87162306a36Sopenharmony_ci NPCM7XX_MKFUNC(r2err), 87262306a36Sopenharmony_ci NPCM7XX_MKFUNC(r2md), 87362306a36Sopenharmony_ci NPCM7XX_MKFUNC(sd1), 87462306a36Sopenharmony_ci NPCM7XX_MKFUNC(sd1pwr), 87562306a36Sopenharmony_ci NPCM7XX_MKFUNC(wdog1), 87662306a36Sopenharmony_ci NPCM7XX_MKFUNC(wdog2), 87762306a36Sopenharmony_ci NPCM7XX_MKFUNC(scipme), 87862306a36Sopenharmony_ci NPCM7XX_MKFUNC(sci), 87962306a36Sopenharmony_ci NPCM7XX_MKFUNC(serirq), 88062306a36Sopenharmony_ci NPCM7XX_MKFUNC(jtag2), 88162306a36Sopenharmony_ci NPCM7XX_MKFUNC(spix), 88262306a36Sopenharmony_ci NPCM7XX_MKFUNC(spixcs1), 88362306a36Sopenharmony_ci NPCM7XX_MKFUNC(pspi1), 88462306a36Sopenharmony_ci NPCM7XX_MKFUNC(pspi2), 88562306a36Sopenharmony_ci NPCM7XX_MKFUNC(ddc), 88662306a36Sopenharmony_ci NPCM7XX_MKFUNC(clkreq), 88762306a36Sopenharmony_ci NPCM7XX_MKFUNC(clkout), 88862306a36Sopenharmony_ci NPCM7XX_MKFUNC(spi3), 88962306a36Sopenharmony_ci NPCM7XX_MKFUNC(spi3cs1), 89062306a36Sopenharmony_ci NPCM7XX_MKFUNC(spi3quad), 89162306a36Sopenharmony_ci NPCM7XX_MKFUNC(spi3cs2), 89262306a36Sopenharmony_ci NPCM7XX_MKFUNC(spi3cs3), 89362306a36Sopenharmony_ci NPCM7XX_MKFUNC(spi0cs1), 89462306a36Sopenharmony_ci NPCM7XX_MKFUNC(lpc), 89562306a36Sopenharmony_ci NPCM7XX_MKFUNC(lpcclk), 89662306a36Sopenharmony_ci NPCM7XX_MKFUNC(espi), 89762306a36Sopenharmony_ci NPCM7XX_MKFUNC(lkgpo0), 89862306a36Sopenharmony_ci NPCM7XX_MKFUNC(lkgpo1), 89962306a36Sopenharmony_ci NPCM7XX_MKFUNC(lkgpo2), 90062306a36Sopenharmony_ci NPCM7XX_MKFUNC(nprd_smi), 90162306a36Sopenharmony_ci}; 90262306a36Sopenharmony_ci 90362306a36Sopenharmony_ci#define NPCM7XX_PINCFG(a, b, c, d, e, f, g, h, i, j, k) \ 90462306a36Sopenharmony_ci [a] = { .fn0 = fn_ ## b, .reg0 = NPCM7XX_GCR_ ## c, .bit0 = d, \ 90562306a36Sopenharmony_ci .fn1 = fn_ ## e, .reg1 = NPCM7XX_GCR_ ## f, .bit1 = g, \ 90662306a36Sopenharmony_ci .fn2 = fn_ ## h, .reg2 = NPCM7XX_GCR_ ## i, .bit2 = j, \ 90762306a36Sopenharmony_ci .flag = k } 90862306a36Sopenharmony_ci 90962306a36Sopenharmony_ci/* Drive strength controlled by NPCM7XX_GP_N_ODSC */ 91062306a36Sopenharmony_ci#define DRIVE_STRENGTH_LO_SHIFT 8 91162306a36Sopenharmony_ci#define DRIVE_STRENGTH_HI_SHIFT 12 91262306a36Sopenharmony_ci#define DRIVE_STRENGTH_MASK 0x0000FF00 91362306a36Sopenharmony_ci 91462306a36Sopenharmony_ci#define DSTR(lo, hi) (((lo) << DRIVE_STRENGTH_LO_SHIFT) | \ 91562306a36Sopenharmony_ci ((hi) << DRIVE_STRENGTH_HI_SHIFT)) 91662306a36Sopenharmony_ci#define DSLO(x) (((x) >> DRIVE_STRENGTH_LO_SHIFT) & 0xF) 91762306a36Sopenharmony_ci#define DSHI(x) (((x) >> DRIVE_STRENGTH_HI_SHIFT) & 0xF) 91862306a36Sopenharmony_ci 91962306a36Sopenharmony_ci#define GPI 0x1 /* Not GPO */ 92062306a36Sopenharmony_ci#define GPO 0x2 /* Not GPI */ 92162306a36Sopenharmony_ci#define SLEW 0x4 /* Has Slew Control, NPCM7XX_GP_N_OSRC */ 92262306a36Sopenharmony_ci#define SLEWLPC 0x8 /* Has Slew Control, SRCNT.3 */ 92362306a36Sopenharmony_ci 92462306a36Sopenharmony_cistruct npcm7xx_pincfg { 92562306a36Sopenharmony_ci int flag; 92662306a36Sopenharmony_ci int fn0, reg0, bit0; 92762306a36Sopenharmony_ci int fn1, reg1, bit1; 92862306a36Sopenharmony_ci int fn2, reg2, bit2; 92962306a36Sopenharmony_ci}; 93062306a36Sopenharmony_ci 93162306a36Sopenharmony_cistatic const struct npcm7xx_pincfg pincfg[] = { 93262306a36Sopenharmony_ci /* PIN FUNCTION 1 FUNCTION 2 FUNCTION 3 FLAGS */ 93362306a36Sopenharmony_ci NPCM7XX_PINCFG(0, iox1, MFSEL1, 30, none, NONE, 0, none, NONE, 0, 0), 93462306a36Sopenharmony_ci NPCM7XX_PINCFG(1, iox1, MFSEL1, 30, none, NONE, 0, none, NONE, 0, DSTR(8, 12)), 93562306a36Sopenharmony_ci NPCM7XX_PINCFG(2, iox1, MFSEL1, 30, none, NONE, 0, none, NONE, 0, DSTR(8, 12)), 93662306a36Sopenharmony_ci NPCM7XX_PINCFG(3, iox1, MFSEL1, 30, none, NONE, 0, none, NONE, 0, 0), 93762306a36Sopenharmony_ci NPCM7XX_PINCFG(4, iox2, MFSEL3, 14, smb1d, I2CSEGSEL, 7, none, NONE, 0, SLEW), 93862306a36Sopenharmony_ci NPCM7XX_PINCFG(5, iox2, MFSEL3, 14, smb1d, I2CSEGSEL, 7, none, NONE, 0, SLEW), 93962306a36Sopenharmony_ci NPCM7XX_PINCFG(6, iox2, MFSEL3, 14, smb2d, I2CSEGSEL, 10, none, NONE, 0, SLEW), 94062306a36Sopenharmony_ci NPCM7XX_PINCFG(7, iox2, MFSEL3, 14, smb2d, I2CSEGSEL, 10, none, NONE, 0, SLEW), 94162306a36Sopenharmony_ci NPCM7XX_PINCFG(8, lkgpo1, FLOCKR1, 4, none, NONE, 0, none, NONE, 0, DSTR(8, 12)), 94262306a36Sopenharmony_ci NPCM7XX_PINCFG(9, lkgpo2, FLOCKR1, 8, none, NONE, 0, none, NONE, 0, DSTR(8, 12)), 94362306a36Sopenharmony_ci NPCM7XX_PINCFG(10, ioxh, MFSEL3, 18, none, NONE, 0, none, NONE, 0, DSTR(8, 12)), 94462306a36Sopenharmony_ci NPCM7XX_PINCFG(11, ioxh, MFSEL3, 18, none, NONE, 0, none, NONE, 0, DSTR(8, 12)), 94562306a36Sopenharmony_ci NPCM7XX_PINCFG(12, gspi, MFSEL1, 24, smb5b, I2CSEGSEL, 19, none, NONE, 0, SLEW), 94662306a36Sopenharmony_ci NPCM7XX_PINCFG(13, gspi, MFSEL1, 24, smb5b, I2CSEGSEL, 19, none, NONE, 0, SLEW), 94762306a36Sopenharmony_ci NPCM7XX_PINCFG(14, gspi, MFSEL1, 24, smb5c, I2CSEGSEL, 20, none, NONE, 0, SLEW), 94862306a36Sopenharmony_ci NPCM7XX_PINCFG(15, gspi, MFSEL1, 24, smb5c, I2CSEGSEL, 20, none, NONE, 0, SLEW), 94962306a36Sopenharmony_ci NPCM7XX_PINCFG(16, lkgpo0, FLOCKR1, 0, none, NONE, 0, none, NONE, 0, DSTR(8, 12)), 95062306a36Sopenharmony_ci NPCM7XX_PINCFG(17, pspi2, MFSEL3, 13, smb4den, I2CSEGSEL, 23, none, NONE, 0, DSTR(8, 12)), 95162306a36Sopenharmony_ci NPCM7XX_PINCFG(18, pspi2, MFSEL3, 13, smb4b, I2CSEGSEL, 14, none, NONE, 0, DSTR(8, 12)), 95262306a36Sopenharmony_ci NPCM7XX_PINCFG(19, pspi2, MFSEL3, 13, smb4b, I2CSEGSEL, 14, none, NONE, 0, DSTR(8, 12)), 95362306a36Sopenharmony_ci NPCM7XX_PINCFG(20, smb4c, I2CSEGSEL, 15, smb15, MFSEL3, 8, none, NONE, 0, 0), 95462306a36Sopenharmony_ci NPCM7XX_PINCFG(21, smb4c, I2CSEGSEL, 15, smb15, MFSEL3, 8, none, NONE, 0, 0), 95562306a36Sopenharmony_ci NPCM7XX_PINCFG(22, smb4d, I2CSEGSEL, 16, smb14, MFSEL3, 7, none, NONE, 0, 0), 95662306a36Sopenharmony_ci NPCM7XX_PINCFG(23, smb4d, I2CSEGSEL, 16, smb14, MFSEL3, 7, none, NONE, 0, 0), 95762306a36Sopenharmony_ci NPCM7XX_PINCFG(24, ioxh, MFSEL3, 18, none, NONE, 0, none, NONE, 0, DSTR(8, 12)), 95862306a36Sopenharmony_ci NPCM7XX_PINCFG(25, ioxh, MFSEL3, 18, none, NONE, 0, none, NONE, 0, DSTR(8, 12)), 95962306a36Sopenharmony_ci NPCM7XX_PINCFG(26, smb5, MFSEL1, 2, none, NONE, 0, none, NONE, 0, 0), 96062306a36Sopenharmony_ci NPCM7XX_PINCFG(27, smb5, MFSEL1, 2, none, NONE, 0, none, NONE, 0, 0), 96162306a36Sopenharmony_ci NPCM7XX_PINCFG(28, smb4, MFSEL1, 1, none, NONE, 0, none, NONE, 0, 0), 96262306a36Sopenharmony_ci NPCM7XX_PINCFG(29, smb4, MFSEL1, 1, none, NONE, 0, none, NONE, 0, 0), 96362306a36Sopenharmony_ci NPCM7XX_PINCFG(30, smb3, MFSEL1, 0, none, NONE, 0, none, NONE, 0, 0), 96462306a36Sopenharmony_ci NPCM7XX_PINCFG(31, smb3, MFSEL1, 0, none, NONE, 0, none, NONE, 0, 0), 96562306a36Sopenharmony_ci 96662306a36Sopenharmony_ci NPCM7XX_PINCFG(32, spi0cs1, MFSEL1, 3, none, NONE, 0, none, NONE, 0, 0), 96762306a36Sopenharmony_ci NPCM7XX_PINCFG(33, none, NONE, 0, none, NONE, 0, none, NONE, 0, SLEW), 96862306a36Sopenharmony_ci NPCM7XX_PINCFG(34, none, NONE, 0, none, NONE, 0, none, NONE, 0, SLEW), 96962306a36Sopenharmony_ci NPCM7XX_PINCFG(37, smb3c, I2CSEGSEL, 12, none, NONE, 0, none, NONE, 0, SLEW), 97062306a36Sopenharmony_ci NPCM7XX_PINCFG(38, smb3c, I2CSEGSEL, 12, none, NONE, 0, none, NONE, 0, SLEW), 97162306a36Sopenharmony_ci NPCM7XX_PINCFG(39, smb3b, I2CSEGSEL, 11, none, NONE, 0, none, NONE, 0, SLEW), 97262306a36Sopenharmony_ci NPCM7XX_PINCFG(40, smb3b, I2CSEGSEL, 11, none, NONE, 0, none, NONE, 0, SLEW), 97362306a36Sopenharmony_ci NPCM7XX_PINCFG(41, bmcuart0a, MFSEL1, 9, none, NONE, 0, none, NONE, 0, 0), 97462306a36Sopenharmony_ci NPCM7XX_PINCFG(42, bmcuart0a, MFSEL1, 9, none, NONE, 0, none, NONE, 0, DSTR(2, 4) | GPO), 97562306a36Sopenharmony_ci NPCM7XX_PINCFG(43, uart1, MFSEL1, 10, jtag2, MFSEL4, 0, bmcuart1, MFSEL3, 24, 0), 97662306a36Sopenharmony_ci NPCM7XX_PINCFG(44, uart1, MFSEL1, 10, jtag2, MFSEL4, 0, bmcuart1, MFSEL3, 24, 0), 97762306a36Sopenharmony_ci NPCM7XX_PINCFG(45, uart1, MFSEL1, 10, jtag2, MFSEL4, 0, none, NONE, 0, 0), 97862306a36Sopenharmony_ci NPCM7XX_PINCFG(46, uart1, MFSEL1, 10, jtag2, MFSEL4, 0, none, NONE, 0, DSTR(2, 8)), 97962306a36Sopenharmony_ci NPCM7XX_PINCFG(47, uart1, MFSEL1, 10, jtag2, MFSEL4, 0, none, NONE, 0, DSTR(2, 8)), 98062306a36Sopenharmony_ci NPCM7XX_PINCFG(48, uart2, MFSEL1, 11, bmcuart0b, MFSEL4, 1, none, NONE, 0, GPO), 98162306a36Sopenharmony_ci NPCM7XX_PINCFG(49, uart2, MFSEL1, 11, bmcuart0b, MFSEL4, 1, none, NONE, 0, 0), 98262306a36Sopenharmony_ci NPCM7XX_PINCFG(50, uart2, MFSEL1, 11, none, NONE, 0, none, NONE, 0, 0), 98362306a36Sopenharmony_ci NPCM7XX_PINCFG(51, uart2, MFSEL1, 11, none, NONE, 0, none, NONE, 0, GPO), 98462306a36Sopenharmony_ci NPCM7XX_PINCFG(52, uart2, MFSEL1, 11, none, NONE, 0, none, NONE, 0, 0), 98562306a36Sopenharmony_ci NPCM7XX_PINCFG(53, uart2, MFSEL1, 11, none, NONE, 0, none, NONE, 0, GPO), 98662306a36Sopenharmony_ci NPCM7XX_PINCFG(54, uart2, MFSEL1, 11, none, NONE, 0, none, NONE, 0, 0), 98762306a36Sopenharmony_ci NPCM7XX_PINCFG(55, uart2, MFSEL1, 11, none, NONE, 0, none, NONE, 0, 0), 98862306a36Sopenharmony_ci NPCM7XX_PINCFG(56, r1err, MFSEL1, 12, none, NONE, 0, none, NONE, 0, 0), 98962306a36Sopenharmony_ci NPCM7XX_PINCFG(57, r1md, MFSEL1, 13, none, NONE, 0, none, NONE, 0, DSTR(2, 4)), 99062306a36Sopenharmony_ci NPCM7XX_PINCFG(58, r1md, MFSEL1, 13, none, NONE, 0, none, NONE, 0, DSTR(2, 4)), 99162306a36Sopenharmony_ci NPCM7XX_PINCFG(59, smb3d, I2CSEGSEL, 13, none, NONE, 0, none, NONE, 0, 0), 99262306a36Sopenharmony_ci NPCM7XX_PINCFG(60, smb3d, I2CSEGSEL, 13, none, NONE, 0, none, NONE, 0, 0), 99362306a36Sopenharmony_ci NPCM7XX_PINCFG(61, uart1, MFSEL1, 10, none, NONE, 0, none, NONE, 0, GPO), 99462306a36Sopenharmony_ci NPCM7XX_PINCFG(62, uart1, MFSEL1, 10, bmcuart1, MFSEL3, 24, none, NONE, 0, GPO), 99562306a36Sopenharmony_ci NPCM7XX_PINCFG(63, uart1, MFSEL1, 10, bmcuart1, MFSEL3, 24, none, NONE, 0, GPO), 99662306a36Sopenharmony_ci 99762306a36Sopenharmony_ci NPCM7XX_PINCFG(64, fanin0, MFSEL2, 0, none, NONE, 0, none, NONE, 0, 0), 99862306a36Sopenharmony_ci NPCM7XX_PINCFG(65, fanin1, MFSEL2, 1, none, NONE, 0, none, NONE, 0, 0), 99962306a36Sopenharmony_ci NPCM7XX_PINCFG(66, fanin2, MFSEL2, 2, none, NONE, 0, none, NONE, 0, 0), 100062306a36Sopenharmony_ci NPCM7XX_PINCFG(67, fanin3, MFSEL2, 3, none, NONE, 0, none, NONE, 0, 0), 100162306a36Sopenharmony_ci NPCM7XX_PINCFG(68, fanin4, MFSEL2, 4, none, NONE, 0, none, NONE, 0, 0), 100262306a36Sopenharmony_ci NPCM7XX_PINCFG(69, fanin5, MFSEL2, 5, none, NONE, 0, none, NONE, 0, 0), 100362306a36Sopenharmony_ci NPCM7XX_PINCFG(70, fanin6, MFSEL2, 6, none, NONE, 0, none, NONE, 0, 0), 100462306a36Sopenharmony_ci NPCM7XX_PINCFG(71, fanin7, MFSEL2, 7, none, NONE, 0, none, NONE, 0, 0), 100562306a36Sopenharmony_ci NPCM7XX_PINCFG(72, fanin8, MFSEL2, 8, none, NONE, 0, none, NONE, 0, 0), 100662306a36Sopenharmony_ci NPCM7XX_PINCFG(73, fanin9, MFSEL2, 9, none, NONE, 0, none, NONE, 0, 0), 100762306a36Sopenharmony_ci NPCM7XX_PINCFG(74, fanin10, MFSEL2, 10, none, NONE, 0, none, NONE, 0, 0), 100862306a36Sopenharmony_ci NPCM7XX_PINCFG(75, fanin11, MFSEL2, 11, none, NONE, 0, none, NONE, 0, 0), 100962306a36Sopenharmony_ci NPCM7XX_PINCFG(76, fanin12, MFSEL2, 12, none, NONE, 0, none, NONE, 0, 0), 101062306a36Sopenharmony_ci NPCM7XX_PINCFG(77, fanin13, MFSEL2, 13, none, NONE, 0, none, NONE, 0, 0), 101162306a36Sopenharmony_ci NPCM7XX_PINCFG(78, fanin14, MFSEL2, 14, none, NONE, 0, none, NONE, 0, 0), 101262306a36Sopenharmony_ci NPCM7XX_PINCFG(79, fanin15, MFSEL2, 15, none, NONE, 0, none, NONE, 0, 0), 101362306a36Sopenharmony_ci NPCM7XX_PINCFG(80, pwm0, MFSEL2, 16, none, NONE, 0, none, NONE, 0, DSTR(4, 8)), 101462306a36Sopenharmony_ci NPCM7XX_PINCFG(81, pwm1, MFSEL2, 17, none, NONE, 0, none, NONE, 0, DSTR(4, 8)), 101562306a36Sopenharmony_ci NPCM7XX_PINCFG(82, pwm2, MFSEL2, 18, none, NONE, 0, none, NONE, 0, DSTR(4, 8)), 101662306a36Sopenharmony_ci NPCM7XX_PINCFG(83, pwm3, MFSEL2, 19, none, NONE, 0, none, NONE, 0, DSTR(4, 8)), 101762306a36Sopenharmony_ci NPCM7XX_PINCFG(84, r2, MFSEL1, 14, none, NONE, 0, none, NONE, 0, DSTR(8, 12) | SLEW), 101862306a36Sopenharmony_ci NPCM7XX_PINCFG(85, r2, MFSEL1, 14, none, NONE, 0, none, NONE, 0, DSTR(8, 12) | SLEW), 101962306a36Sopenharmony_ci NPCM7XX_PINCFG(86, r2, MFSEL1, 14, none, NONE, 0, none, NONE, 0, DSTR(8, 12) | SLEW), 102062306a36Sopenharmony_ci NPCM7XX_PINCFG(87, r2, MFSEL1, 14, none, NONE, 0, none, NONE, 0, 0), 102162306a36Sopenharmony_ci NPCM7XX_PINCFG(88, r2, MFSEL1, 14, none, NONE, 0, none, NONE, 0, 0), 102262306a36Sopenharmony_ci NPCM7XX_PINCFG(89, r2, MFSEL1, 14, none, NONE, 0, none, NONE, 0, 0), 102362306a36Sopenharmony_ci NPCM7XX_PINCFG(90, r2err, MFSEL1, 15, none, NONE, 0, none, NONE, 0, 0), 102462306a36Sopenharmony_ci NPCM7XX_PINCFG(91, r2md, MFSEL1, 16, none, NONE, 0, none, NONE, 0, DSTR(2, 4)), 102562306a36Sopenharmony_ci NPCM7XX_PINCFG(92, r2md, MFSEL1, 16, none, NONE, 0, none, NONE, 0, DSTR(2, 4)), 102662306a36Sopenharmony_ci NPCM7XX_PINCFG(93, ga20kbc, MFSEL1, 17, smb5d, I2CSEGSEL, 21, none, NONE, 0, 0), 102762306a36Sopenharmony_ci NPCM7XX_PINCFG(94, ga20kbc, MFSEL1, 17, smb5d, I2CSEGSEL, 21, none, NONE, 0, 0), 102862306a36Sopenharmony_ci NPCM7XX_PINCFG(95, lpc, NONE, 0, espi, MFSEL4, 8, gpio, MFSEL1, 26, 0), 102962306a36Sopenharmony_ci 103062306a36Sopenharmony_ci NPCM7XX_PINCFG(96, rg1, MFSEL4, 22, none, NONE, 0, none, NONE, 0, 0), 103162306a36Sopenharmony_ci NPCM7XX_PINCFG(97, rg1, MFSEL4, 22, none, NONE, 0, none, NONE, 0, 0), 103262306a36Sopenharmony_ci NPCM7XX_PINCFG(98, rg1, MFSEL4, 22, none, NONE, 0, none, NONE, 0, 0), 103362306a36Sopenharmony_ci NPCM7XX_PINCFG(99, rg1, MFSEL4, 22, none, NONE, 0, none, NONE, 0, 0), 103462306a36Sopenharmony_ci NPCM7XX_PINCFG(100, rg1, MFSEL4, 22, none, NONE, 0, none, NONE, 0, 0), 103562306a36Sopenharmony_ci NPCM7XX_PINCFG(101, rg1, MFSEL4, 22, none, NONE, 0, none, NONE, 0, 0), 103662306a36Sopenharmony_ci NPCM7XX_PINCFG(102, rg1, MFSEL4, 22, none, NONE, 0, none, NONE, 0, 0), 103762306a36Sopenharmony_ci NPCM7XX_PINCFG(103, rg1, MFSEL4, 22, none, NONE, 0, none, NONE, 0, 0), 103862306a36Sopenharmony_ci NPCM7XX_PINCFG(104, rg1, MFSEL4, 22, none, NONE, 0, none, NONE, 0, 0), 103962306a36Sopenharmony_ci NPCM7XX_PINCFG(105, rg1, MFSEL4, 22, none, NONE, 0, none, NONE, 0, 0), 104062306a36Sopenharmony_ci NPCM7XX_PINCFG(106, rg1, MFSEL4, 22, none, NONE, 0, none, NONE, 0, 0), 104162306a36Sopenharmony_ci NPCM7XX_PINCFG(107, rg1, MFSEL4, 22, none, NONE, 0, none, NONE, 0, 0), 104262306a36Sopenharmony_ci NPCM7XX_PINCFG(108, rg1mdio, MFSEL4, 21, none, NONE, 0, none, NONE, 0, 0), 104362306a36Sopenharmony_ci NPCM7XX_PINCFG(109, rg1mdio, MFSEL4, 21, none, NONE, 0, none, NONE, 0, 0), 104462306a36Sopenharmony_ci NPCM7XX_PINCFG(110, rg2, MFSEL4, 24, ddr, MFSEL3, 26, none, NONE, 0, 0), 104562306a36Sopenharmony_ci NPCM7XX_PINCFG(111, rg2, MFSEL4, 24, ddr, MFSEL3, 26, none, NONE, 0, 0), 104662306a36Sopenharmony_ci NPCM7XX_PINCFG(112, rg2, MFSEL4, 24, ddr, MFSEL3, 26, none, NONE, 0, 0), 104762306a36Sopenharmony_ci NPCM7XX_PINCFG(113, rg2, MFSEL4, 24, ddr, MFSEL3, 26, none, NONE, 0, 0), 104862306a36Sopenharmony_ci NPCM7XX_PINCFG(114, smb0, MFSEL1, 6, none, NONE, 0, none, NONE, 0, 0), 104962306a36Sopenharmony_ci NPCM7XX_PINCFG(115, smb0, MFSEL1, 6, none, NONE, 0, none, NONE, 0, 0), 105062306a36Sopenharmony_ci NPCM7XX_PINCFG(116, smb1, MFSEL1, 7, none, NONE, 0, none, NONE, 0, 0), 105162306a36Sopenharmony_ci NPCM7XX_PINCFG(117, smb1, MFSEL1, 7, none, NONE, 0, none, NONE, 0, 0), 105262306a36Sopenharmony_ci NPCM7XX_PINCFG(118, smb2, MFSEL1, 8, none, NONE, 0, none, NONE, 0, 0), 105362306a36Sopenharmony_ci NPCM7XX_PINCFG(119, smb2, MFSEL1, 8, none, NONE, 0, none, NONE, 0, 0), 105462306a36Sopenharmony_ci NPCM7XX_PINCFG(120, smb2c, I2CSEGSEL, 9, none, NONE, 0, none, NONE, 0, SLEW), 105562306a36Sopenharmony_ci NPCM7XX_PINCFG(121, smb2c, I2CSEGSEL, 9, none, NONE, 0, none, NONE, 0, SLEW), 105662306a36Sopenharmony_ci NPCM7XX_PINCFG(122, smb2b, I2CSEGSEL, 8, none, NONE, 0, none, NONE, 0, SLEW), 105762306a36Sopenharmony_ci NPCM7XX_PINCFG(123, smb2b, I2CSEGSEL, 8, none, NONE, 0, none, NONE, 0, SLEW), 105862306a36Sopenharmony_ci NPCM7XX_PINCFG(124, smb1c, I2CSEGSEL, 6, none, NONE, 0, none, NONE, 0, SLEW), 105962306a36Sopenharmony_ci NPCM7XX_PINCFG(125, smb1c, I2CSEGSEL, 6, none, NONE, 0, none, NONE, 0, SLEW), 106062306a36Sopenharmony_ci NPCM7XX_PINCFG(126, smb1b, I2CSEGSEL, 5, none, NONE, 0, none, NONE, 0, SLEW), 106162306a36Sopenharmony_ci NPCM7XX_PINCFG(127, smb1b, I2CSEGSEL, 5, none, NONE, 0, none, NONE, 0, SLEW), 106262306a36Sopenharmony_ci 106362306a36Sopenharmony_ci NPCM7XX_PINCFG(128, smb8, MFSEL4, 11, none, NONE, 0, none, NONE, 0, 0), 106462306a36Sopenharmony_ci NPCM7XX_PINCFG(129, smb8, MFSEL4, 11, none, NONE, 0, none, NONE, 0, 0), 106562306a36Sopenharmony_ci NPCM7XX_PINCFG(130, smb9, MFSEL4, 12, none, NONE, 0, none, NONE, 0, 0), 106662306a36Sopenharmony_ci NPCM7XX_PINCFG(131, smb9, MFSEL4, 12, none, NONE, 0, none, NONE, 0, 0), 106762306a36Sopenharmony_ci NPCM7XX_PINCFG(132, smb10, MFSEL4, 13, none, NONE, 0, none, NONE, 0, 0), 106862306a36Sopenharmony_ci NPCM7XX_PINCFG(133, smb10, MFSEL4, 13, none, NONE, 0, none, NONE, 0, 0), 106962306a36Sopenharmony_ci NPCM7XX_PINCFG(134, smb11, MFSEL4, 14, none, NONE, 0, none, NONE, 0, 0), 107062306a36Sopenharmony_ci NPCM7XX_PINCFG(135, smb11, MFSEL4, 14, none, NONE, 0, none, NONE, 0, 0), 107162306a36Sopenharmony_ci NPCM7XX_PINCFG(136, sd1, MFSEL3, 12, none, NONE, 0, none, NONE, 0, DSTR(8, 12) | SLEW), 107262306a36Sopenharmony_ci NPCM7XX_PINCFG(137, sd1, MFSEL3, 12, none, NONE, 0, none, NONE, 0, DSTR(8, 12) | SLEW), 107362306a36Sopenharmony_ci NPCM7XX_PINCFG(138, sd1, MFSEL3, 12, none, NONE, 0, none, NONE, 0, DSTR(8, 12) | SLEW), 107462306a36Sopenharmony_ci NPCM7XX_PINCFG(139, sd1, MFSEL3, 12, none, NONE, 0, none, NONE, 0, DSTR(8, 12) | SLEW), 107562306a36Sopenharmony_ci NPCM7XX_PINCFG(140, sd1, MFSEL3, 12, none, NONE, 0, none, NONE, 0, DSTR(8, 12) | SLEW), 107662306a36Sopenharmony_ci NPCM7XX_PINCFG(141, sd1, MFSEL3, 12, none, NONE, 0, none, NONE, 0, 0), 107762306a36Sopenharmony_ci NPCM7XX_PINCFG(142, sd1, MFSEL3, 12, none, NONE, 0, none, NONE, 0, DSTR(8, 12) | SLEW), 107862306a36Sopenharmony_ci NPCM7XX_PINCFG(143, sd1, MFSEL3, 12, sd1pwr, MFSEL4, 5, none, NONE, 0, 0), 107962306a36Sopenharmony_ci NPCM7XX_PINCFG(144, pwm4, MFSEL2, 20, none, NONE, 0, none, NONE, 0, DSTR(4, 8)), 108062306a36Sopenharmony_ci NPCM7XX_PINCFG(145, pwm5, MFSEL2, 21, none, NONE, 0, none, NONE, 0, DSTR(4, 8)), 108162306a36Sopenharmony_ci NPCM7XX_PINCFG(146, pwm6, MFSEL2, 22, none, NONE, 0, none, NONE, 0, DSTR(4, 8)), 108262306a36Sopenharmony_ci NPCM7XX_PINCFG(147, pwm7, MFSEL2, 23, none, NONE, 0, none, NONE, 0, DSTR(4, 8)), 108362306a36Sopenharmony_ci NPCM7XX_PINCFG(148, mmc8, MFSEL3, 11, none, NONE, 0, none, NONE, 0, DSTR(8, 12) | SLEW), 108462306a36Sopenharmony_ci NPCM7XX_PINCFG(149, mmc8, MFSEL3, 11, none, NONE, 0, none, NONE, 0, DSTR(8, 12) | SLEW), 108562306a36Sopenharmony_ci NPCM7XX_PINCFG(150, mmc8, MFSEL3, 11, none, NONE, 0, none, NONE, 0, DSTR(8, 12) | SLEW), 108662306a36Sopenharmony_ci NPCM7XX_PINCFG(151, mmc8, MFSEL3, 11, none, NONE, 0, none, NONE, 0, DSTR(8, 12) | SLEW), 108762306a36Sopenharmony_ci NPCM7XX_PINCFG(152, mmc, MFSEL3, 10, none, NONE, 0, none, NONE, 0, DSTR(8, 12) | SLEW), 108862306a36Sopenharmony_ci NPCM7XX_PINCFG(153, mmcwp, FLOCKR1, 24, none, NONE, 0, none, NONE, 0, 0), /* Z1/A1 */ 108962306a36Sopenharmony_ci NPCM7XX_PINCFG(154, mmc, MFSEL3, 10, none, NONE, 0, none, NONE, 0, DSTR(8, 12) | SLEW), 109062306a36Sopenharmony_ci NPCM7XX_PINCFG(155, mmccd, MFSEL3, 25, mmcrst, MFSEL4, 6, none, NONE, 0, 0), /* Z1/A1 */ 109162306a36Sopenharmony_ci NPCM7XX_PINCFG(156, mmc, MFSEL3, 10, none, NONE, 0, none, NONE, 0, DSTR(8, 12) | SLEW), 109262306a36Sopenharmony_ci NPCM7XX_PINCFG(157, mmc, MFSEL3, 10, none, NONE, 0, none, NONE, 0, DSTR(8, 12) | SLEW), 109362306a36Sopenharmony_ci NPCM7XX_PINCFG(158, mmc, MFSEL3, 10, none, NONE, 0, none, NONE, 0, DSTR(8, 12) | SLEW), 109462306a36Sopenharmony_ci NPCM7XX_PINCFG(159, mmc, MFSEL3, 10, none, NONE, 0, none, NONE, 0, DSTR(8, 12) | SLEW), 109562306a36Sopenharmony_ci 109662306a36Sopenharmony_ci NPCM7XX_PINCFG(160, clkout, MFSEL1, 21, none, NONE, 0, none, NONE, 0, DSTR(8, 12) | SLEW), 109762306a36Sopenharmony_ci NPCM7XX_PINCFG(161, lpc, NONE, 0, espi, MFSEL4, 8, gpio, MFSEL1, 26, DSTR(8, 12)), 109862306a36Sopenharmony_ci NPCM7XX_PINCFG(162, serirq, NONE, 0, gpio, MFSEL1, 31, none, NONE, 0, DSTR(8, 12)), 109962306a36Sopenharmony_ci NPCM7XX_PINCFG(163, lpc, NONE, 0, espi, MFSEL4, 8, gpio, MFSEL1, 26, 0), 110062306a36Sopenharmony_ci NPCM7XX_PINCFG(164, lpc, NONE, 0, espi, MFSEL4, 8, gpio, MFSEL1, 26, SLEWLPC), 110162306a36Sopenharmony_ci NPCM7XX_PINCFG(165, lpc, NONE, 0, espi, MFSEL4, 8, gpio, MFSEL1, 26, SLEWLPC), 110262306a36Sopenharmony_ci NPCM7XX_PINCFG(166, lpc, NONE, 0, espi, MFSEL4, 8, gpio, MFSEL1, 26, SLEWLPC), 110362306a36Sopenharmony_ci NPCM7XX_PINCFG(167, lpc, NONE, 0, espi, MFSEL4, 8, gpio, MFSEL1, 26, SLEWLPC), 110462306a36Sopenharmony_ci NPCM7XX_PINCFG(168, lpcclk, NONE, 0, espi, MFSEL4, 8, gpio, MFSEL3, 16, 0), 110562306a36Sopenharmony_ci NPCM7XX_PINCFG(169, scipme, MFSEL3, 0, none, NONE, 0, none, NONE, 0, 0), 110662306a36Sopenharmony_ci NPCM7XX_PINCFG(170, sci, MFSEL1, 22, none, NONE, 0, none, NONE, 0, 0), 110762306a36Sopenharmony_ci NPCM7XX_PINCFG(171, smb6, MFSEL3, 1, none, NONE, 0, none, NONE, 0, 0), 110862306a36Sopenharmony_ci NPCM7XX_PINCFG(172, smb6, MFSEL3, 1, none, NONE, 0, none, NONE, 0, 0), 110962306a36Sopenharmony_ci NPCM7XX_PINCFG(173, smb7, MFSEL3, 2, none, NONE, 0, none, NONE, 0, 0), 111062306a36Sopenharmony_ci NPCM7XX_PINCFG(174, smb7, MFSEL3, 2, none, NONE, 0, none, NONE, 0, 0), 111162306a36Sopenharmony_ci NPCM7XX_PINCFG(175, pspi1, MFSEL3, 4, faninx, MFSEL3, 3, none, NONE, 0, DSTR(8, 12)), 111262306a36Sopenharmony_ci NPCM7XX_PINCFG(176, pspi1, MFSEL3, 4, faninx, MFSEL3, 3, none, NONE, 0, DSTR(8, 12)), 111362306a36Sopenharmony_ci NPCM7XX_PINCFG(177, pspi1, MFSEL3, 4, faninx, MFSEL3, 3, none, NONE, 0, DSTR(8, 12)), 111462306a36Sopenharmony_ci NPCM7XX_PINCFG(178, r1, MFSEL3, 9, none, NONE, 0, none, NONE, 0, DSTR(8, 12) | SLEW), 111562306a36Sopenharmony_ci NPCM7XX_PINCFG(179, r1, MFSEL3, 9, none, NONE, 0, none, NONE, 0, DSTR(8, 12) | SLEW), 111662306a36Sopenharmony_ci NPCM7XX_PINCFG(180, r1, MFSEL3, 9, none, NONE, 0, none, NONE, 0, DSTR(8, 12) | SLEW), 111762306a36Sopenharmony_ci NPCM7XX_PINCFG(181, r1, MFSEL3, 9, none, NONE, 0, none, NONE, 0, 0), 111862306a36Sopenharmony_ci NPCM7XX_PINCFG(182, r1, MFSEL3, 9, none, NONE, 0, none, NONE, 0, 0), 111962306a36Sopenharmony_ci NPCM7XX_PINCFG(183, spi3, MFSEL4, 16, none, NONE, 0, none, NONE, 0, DSTR(8, 12) | SLEW), 112062306a36Sopenharmony_ci NPCM7XX_PINCFG(184, spi3, MFSEL4, 16, none, NONE, 0, none, NONE, 0, DSTR(8, 12) | SLEW | GPO), 112162306a36Sopenharmony_ci NPCM7XX_PINCFG(185, spi3, MFSEL4, 16, none, NONE, 0, none, NONE, 0, DSTR(8, 12) | SLEW | GPO), 112262306a36Sopenharmony_ci NPCM7XX_PINCFG(186, spi3, MFSEL4, 16, none, NONE, 0, none, NONE, 0, DSTR(8, 12)), 112362306a36Sopenharmony_ci NPCM7XX_PINCFG(187, spi3cs1, MFSEL4, 17, none, NONE, 0, none, NONE, 0, DSTR(8, 12)), 112462306a36Sopenharmony_ci NPCM7XX_PINCFG(188, spi3quad, MFSEL4, 20, spi3cs2, MFSEL4, 18, none, NONE, 0, DSTR(8, 12) | SLEW), 112562306a36Sopenharmony_ci NPCM7XX_PINCFG(189, spi3quad, MFSEL4, 20, spi3cs3, MFSEL4, 19, none, NONE, 0, DSTR(8, 12) | SLEW), 112662306a36Sopenharmony_ci NPCM7XX_PINCFG(190, gpio, FLOCKR1, 20, nprd_smi, NONE, 0, none, NONE, 0, DSTR(2, 4)), 112762306a36Sopenharmony_ci NPCM7XX_PINCFG(191, none, NONE, 0, none, NONE, 0, none, NONE, 0, DSTR(8, 12)), /* XX */ 112862306a36Sopenharmony_ci 112962306a36Sopenharmony_ci NPCM7XX_PINCFG(192, none, NONE, 0, none, NONE, 0, none, NONE, 0, DSTR(8, 12)), /* XX */ 113062306a36Sopenharmony_ci NPCM7XX_PINCFG(193, r1, MFSEL3, 9, none, NONE, 0, none, NONE, 0, 0), 113162306a36Sopenharmony_ci NPCM7XX_PINCFG(194, smb0b, I2CSEGSEL, 0, none, NONE, 0, none, NONE, 0, 0), 113262306a36Sopenharmony_ci NPCM7XX_PINCFG(195, smb0b, I2CSEGSEL, 0, none, NONE, 0, none, NONE, 0, 0), 113362306a36Sopenharmony_ci NPCM7XX_PINCFG(196, smb0c, I2CSEGSEL, 1, none, NONE, 0, none, NONE, 0, 0), 113462306a36Sopenharmony_ci NPCM7XX_PINCFG(197, smb0den, I2CSEGSEL, 22, none, NONE, 0, none, NONE, 0, SLEW), 113562306a36Sopenharmony_ci NPCM7XX_PINCFG(198, smb0d, I2CSEGSEL, 2, none, NONE, 0, none, NONE, 0, 0), 113662306a36Sopenharmony_ci NPCM7XX_PINCFG(199, smb0d, I2CSEGSEL, 2, none, NONE, 0, none, NONE, 0, 0), 113762306a36Sopenharmony_ci NPCM7XX_PINCFG(200, r2, MFSEL1, 14, none, NONE, 0, none, NONE, 0, 0), 113862306a36Sopenharmony_ci NPCM7XX_PINCFG(201, r1, MFSEL3, 9, none, NONE, 0, none, NONE, 0, 0), 113962306a36Sopenharmony_ci NPCM7XX_PINCFG(202, smb0c, I2CSEGSEL, 1, none, NONE, 0, none, NONE, 0, 0), 114062306a36Sopenharmony_ci NPCM7XX_PINCFG(203, faninx, MFSEL3, 3, none, NONE, 0, none, NONE, 0, DSTR(8, 12)), 114162306a36Sopenharmony_ci NPCM7XX_PINCFG(204, ddc, NONE, 0, gpio, MFSEL3, 22, none, NONE, 0, SLEW), 114262306a36Sopenharmony_ci NPCM7XX_PINCFG(205, ddc, NONE, 0, gpio, MFSEL3, 22, none, NONE, 0, SLEW), 114362306a36Sopenharmony_ci NPCM7XX_PINCFG(206, ddc, NONE, 0, gpio, MFSEL3, 22, none, NONE, 0, DSTR(4, 8)), 114462306a36Sopenharmony_ci NPCM7XX_PINCFG(207, ddc, NONE, 0, gpio, MFSEL3, 22, none, NONE, 0, DSTR(4, 8)), 114562306a36Sopenharmony_ci NPCM7XX_PINCFG(208, rg2, MFSEL4, 24, ddr, MFSEL3, 26, none, NONE, 0, 0), 114662306a36Sopenharmony_ci NPCM7XX_PINCFG(209, rg2, MFSEL4, 24, ddr, MFSEL3, 26, none, NONE, 0, 0), 114762306a36Sopenharmony_ci NPCM7XX_PINCFG(210, rg2, MFSEL4, 24, ddr, MFSEL3, 26, none, NONE, 0, 0), 114862306a36Sopenharmony_ci NPCM7XX_PINCFG(211, rg2, MFSEL4, 24, ddr, MFSEL3, 26, none, NONE, 0, 0), 114962306a36Sopenharmony_ci NPCM7XX_PINCFG(212, rg2, MFSEL4, 24, ddr, MFSEL3, 26, none, NONE, 0, 0), 115062306a36Sopenharmony_ci NPCM7XX_PINCFG(213, rg2, MFSEL4, 24, ddr, MFSEL3, 26, none, NONE, 0, 0), 115162306a36Sopenharmony_ci NPCM7XX_PINCFG(214, rg2, MFSEL4, 24, ddr, MFSEL3, 26, none, NONE, 0, 0), 115262306a36Sopenharmony_ci NPCM7XX_PINCFG(215, rg2, MFSEL4, 24, ddr, MFSEL3, 26, none, NONE, 0, 0), 115362306a36Sopenharmony_ci NPCM7XX_PINCFG(216, rg2mdio, MFSEL4, 23, ddr, MFSEL3, 26, none, NONE, 0, 0), 115462306a36Sopenharmony_ci NPCM7XX_PINCFG(217, rg2mdio, MFSEL4, 23, ddr, MFSEL3, 26, none, NONE, 0, 0), 115562306a36Sopenharmony_ci NPCM7XX_PINCFG(218, wdog1, MFSEL3, 19, none, NONE, 0, none, NONE, 0, 0), 115662306a36Sopenharmony_ci NPCM7XX_PINCFG(219, wdog2, MFSEL3, 20, none, NONE, 0, none, NONE, 0, DSTR(4, 8)), 115762306a36Sopenharmony_ci NPCM7XX_PINCFG(220, smb12, MFSEL3, 5, none, NONE, 0, none, NONE, 0, 0), 115862306a36Sopenharmony_ci NPCM7XX_PINCFG(221, smb12, MFSEL3, 5, none, NONE, 0, none, NONE, 0, 0), 115962306a36Sopenharmony_ci NPCM7XX_PINCFG(222, smb13, MFSEL3, 6, none, NONE, 0, none, NONE, 0, 0), 116062306a36Sopenharmony_ci NPCM7XX_PINCFG(223, smb13, MFSEL3, 6, none, NONE, 0, none, NONE, 0, 0), 116162306a36Sopenharmony_ci 116262306a36Sopenharmony_ci NPCM7XX_PINCFG(224, spix, MFSEL4, 27, none, NONE, 0, none, NONE, 0, SLEW), 116362306a36Sopenharmony_ci NPCM7XX_PINCFG(225, spix, MFSEL4, 27, none, NONE, 0, none, NONE, 0, DSTR(8, 12) | SLEW | GPO), 116462306a36Sopenharmony_ci NPCM7XX_PINCFG(226, spix, MFSEL4, 27, none, NONE, 0, none, NONE, 0, DSTR(8, 12) | SLEW | GPO), 116562306a36Sopenharmony_ci NPCM7XX_PINCFG(227, spix, MFSEL4, 27, none, NONE, 0, none, NONE, 0, DSTR(8, 12) | SLEW), 116662306a36Sopenharmony_ci NPCM7XX_PINCFG(228, spixcs1, MFSEL4, 28, none, NONE, 0, none, NONE, 0, DSTR(8, 12) | SLEW), 116762306a36Sopenharmony_ci NPCM7XX_PINCFG(229, spix, MFSEL4, 27, none, NONE, 0, none, NONE, 0, DSTR(8, 12) | SLEW), 116862306a36Sopenharmony_ci NPCM7XX_PINCFG(230, spix, MFSEL4, 27, none, NONE, 0, none, NONE, 0, DSTR(8, 12) | SLEW), 116962306a36Sopenharmony_ci NPCM7XX_PINCFG(231, clkreq, MFSEL4, 9, none, NONE, 0, none, NONE, 0, DSTR(8, 12)), 117062306a36Sopenharmony_ci NPCM7XX_PINCFG(253, none, NONE, 0, none, NONE, 0, none, NONE, 0, GPI), /* SDHC1 power */ 117162306a36Sopenharmony_ci NPCM7XX_PINCFG(254, none, NONE, 0, none, NONE, 0, none, NONE, 0, GPI), /* SDHC2 power */ 117262306a36Sopenharmony_ci NPCM7XX_PINCFG(255, none, NONE, 0, none, NONE, 0, none, NONE, 0, GPI), /* DACOSEL */ 117362306a36Sopenharmony_ci}; 117462306a36Sopenharmony_ci 117562306a36Sopenharmony_ci/* number, name, drv_data */ 117662306a36Sopenharmony_cistatic const struct pinctrl_pin_desc npcm7xx_pins[] = { 117762306a36Sopenharmony_ci PINCTRL_PIN(0, "GPIO0/IOX1DI"), 117862306a36Sopenharmony_ci PINCTRL_PIN(1, "GPIO1/IOX1LD"), 117962306a36Sopenharmony_ci PINCTRL_PIN(2, "GPIO2/IOX1CK"), 118062306a36Sopenharmony_ci PINCTRL_PIN(3, "GPIO3/IOX1D0"), 118162306a36Sopenharmony_ci PINCTRL_PIN(4, "GPIO4/IOX2DI/SMB1DSDA"), 118262306a36Sopenharmony_ci PINCTRL_PIN(5, "GPIO5/IOX2LD/SMB1DSCL"), 118362306a36Sopenharmony_ci PINCTRL_PIN(6, "GPIO6/IOX2CK/SMB2DSDA"), 118462306a36Sopenharmony_ci PINCTRL_PIN(7, "GPIO7/IOX2D0/SMB2DSCL"), 118562306a36Sopenharmony_ci PINCTRL_PIN(8, "GPIO8/LKGPO1"), 118662306a36Sopenharmony_ci PINCTRL_PIN(9, "GPIO9/LKGPO2"), 118762306a36Sopenharmony_ci PINCTRL_PIN(10, "GPIO10/IOXHLD"), 118862306a36Sopenharmony_ci PINCTRL_PIN(11, "GPIO11/IOXHCK"), 118962306a36Sopenharmony_ci PINCTRL_PIN(12, "GPIO12/GSPICK/SMB5BSCL"), 119062306a36Sopenharmony_ci PINCTRL_PIN(13, "GPIO13/GSPIDO/SMB5BSDA"), 119162306a36Sopenharmony_ci PINCTRL_PIN(14, "GPIO14/GSPIDI/SMB5CSCL"), 119262306a36Sopenharmony_ci PINCTRL_PIN(15, "GPIO15/GSPICS/SMB5CSDA"), 119362306a36Sopenharmony_ci PINCTRL_PIN(16, "GPIO16/LKGPO0"), 119462306a36Sopenharmony_ci PINCTRL_PIN(17, "GPIO17/PSPI2DI/SMB4DEN"), 119562306a36Sopenharmony_ci PINCTRL_PIN(18, "GPIO18/PSPI2D0/SMB4BSDA"), 119662306a36Sopenharmony_ci PINCTRL_PIN(19, "GPIO19/PSPI2CK/SMB4BSCL"), 119762306a36Sopenharmony_ci PINCTRL_PIN(20, "GPIO20/SMB4CSDA/SMB15SDA"), 119862306a36Sopenharmony_ci PINCTRL_PIN(21, "GPIO21/SMB4CSCL/SMB15SCL"), 119962306a36Sopenharmony_ci PINCTRL_PIN(22, "GPIO22/SMB4DSDA/SMB14SDA"), 120062306a36Sopenharmony_ci PINCTRL_PIN(23, "GPIO23/SMB4DSCL/SMB14SCL"), 120162306a36Sopenharmony_ci PINCTRL_PIN(24, "GPIO24/IOXHDO"), 120262306a36Sopenharmony_ci PINCTRL_PIN(25, "GPIO25/IOXHDI"), 120362306a36Sopenharmony_ci PINCTRL_PIN(26, "GPIO26/SMB5SDA"), 120462306a36Sopenharmony_ci PINCTRL_PIN(27, "GPIO27/SMB5SCL"), 120562306a36Sopenharmony_ci PINCTRL_PIN(28, "GPIO28/SMB4SDA"), 120662306a36Sopenharmony_ci PINCTRL_PIN(29, "GPIO29/SMB4SCL"), 120762306a36Sopenharmony_ci PINCTRL_PIN(30, "GPIO30/SMB3SDA"), 120862306a36Sopenharmony_ci PINCTRL_PIN(31, "GPIO31/SMB3SCL"), 120962306a36Sopenharmony_ci 121062306a36Sopenharmony_ci PINCTRL_PIN(32, "GPIO32/nSPI0CS1"), 121162306a36Sopenharmony_ci PINCTRL_PIN(33, "SPI0D2"), 121262306a36Sopenharmony_ci PINCTRL_PIN(34, "SPI0D3"), 121362306a36Sopenharmony_ci PINCTRL_PIN(37, "GPIO37/SMB3CSDA"), 121462306a36Sopenharmony_ci PINCTRL_PIN(38, "GPIO38/SMB3CSCL"), 121562306a36Sopenharmony_ci PINCTRL_PIN(39, "GPIO39/SMB3BSDA"), 121662306a36Sopenharmony_ci PINCTRL_PIN(40, "GPIO40/SMB3BSCL"), 121762306a36Sopenharmony_ci PINCTRL_PIN(41, "GPIO41/BSPRXD"), 121862306a36Sopenharmony_ci PINCTRL_PIN(42, "GPO42/BSPTXD/STRAP11"), 121962306a36Sopenharmony_ci PINCTRL_PIN(43, "GPIO43/RXD1/JTMS2/BU1RXD"), 122062306a36Sopenharmony_ci PINCTRL_PIN(44, "GPIO44/nCTS1/JTDI2/BU1CTS"), 122162306a36Sopenharmony_ci PINCTRL_PIN(45, "GPIO45/nDCD1/JTDO2"), 122262306a36Sopenharmony_ci PINCTRL_PIN(46, "GPIO46/nDSR1/JTCK2"), 122362306a36Sopenharmony_ci PINCTRL_PIN(47, "GPIO47/nRI1/JCP_RDY2"), 122462306a36Sopenharmony_ci PINCTRL_PIN(48, "GPIO48/TXD2/BSPTXD"), 122562306a36Sopenharmony_ci PINCTRL_PIN(49, "GPIO49/RXD2/BSPRXD"), 122662306a36Sopenharmony_ci PINCTRL_PIN(50, "GPIO50/nCTS2"), 122762306a36Sopenharmony_ci PINCTRL_PIN(51, "GPO51/nRTS2/STRAP2"), 122862306a36Sopenharmony_ci PINCTRL_PIN(52, "GPIO52/nDCD2"), 122962306a36Sopenharmony_ci PINCTRL_PIN(53, "GPO53/nDTR2_BOUT2/STRAP1"), 123062306a36Sopenharmony_ci PINCTRL_PIN(54, "GPIO54/nDSR2"), 123162306a36Sopenharmony_ci PINCTRL_PIN(55, "GPIO55/nRI2"), 123262306a36Sopenharmony_ci PINCTRL_PIN(56, "GPIO56/R1RXERR"), 123362306a36Sopenharmony_ci PINCTRL_PIN(57, "GPIO57/R1MDC"), 123462306a36Sopenharmony_ci PINCTRL_PIN(58, "GPIO58/R1MDIO"), 123562306a36Sopenharmony_ci PINCTRL_PIN(59, "GPIO59/SMB3DSDA"), 123662306a36Sopenharmony_ci PINCTRL_PIN(60, "GPIO60/SMB3DSCL"), 123762306a36Sopenharmony_ci PINCTRL_PIN(61, "GPO61/nDTR1_BOUT1/STRAP6"), 123862306a36Sopenharmony_ci PINCTRL_PIN(62, "GPO62/nRTST1/STRAP5"), 123962306a36Sopenharmony_ci PINCTRL_PIN(63, "GPO63/TXD1/STRAP4"), 124062306a36Sopenharmony_ci 124162306a36Sopenharmony_ci PINCTRL_PIN(64, "GPIO64/FANIN0"), 124262306a36Sopenharmony_ci PINCTRL_PIN(65, "GPIO65/FANIN1"), 124362306a36Sopenharmony_ci PINCTRL_PIN(66, "GPIO66/FANIN2"), 124462306a36Sopenharmony_ci PINCTRL_PIN(67, "GPIO67/FANIN3"), 124562306a36Sopenharmony_ci PINCTRL_PIN(68, "GPIO68/FANIN4"), 124662306a36Sopenharmony_ci PINCTRL_PIN(69, "GPIO69/FANIN5"), 124762306a36Sopenharmony_ci PINCTRL_PIN(70, "GPIO70/FANIN6"), 124862306a36Sopenharmony_ci PINCTRL_PIN(71, "GPIO71/FANIN7"), 124962306a36Sopenharmony_ci PINCTRL_PIN(72, "GPIO72/FANIN8"), 125062306a36Sopenharmony_ci PINCTRL_PIN(73, "GPIO73/FANIN9"), 125162306a36Sopenharmony_ci PINCTRL_PIN(74, "GPIO74/FANIN10"), 125262306a36Sopenharmony_ci PINCTRL_PIN(75, "GPIO75/FANIN11"), 125362306a36Sopenharmony_ci PINCTRL_PIN(76, "GPIO76/FANIN12"), 125462306a36Sopenharmony_ci PINCTRL_PIN(77, "GPIO77/FANIN13"), 125562306a36Sopenharmony_ci PINCTRL_PIN(78, "GPIO78/FANIN14"), 125662306a36Sopenharmony_ci PINCTRL_PIN(79, "GPIO79/FANIN15"), 125762306a36Sopenharmony_ci PINCTRL_PIN(80, "GPIO80/PWM0"), 125862306a36Sopenharmony_ci PINCTRL_PIN(81, "GPIO81/PWM1"), 125962306a36Sopenharmony_ci PINCTRL_PIN(82, "GPIO82/PWM2"), 126062306a36Sopenharmony_ci PINCTRL_PIN(83, "GPIO83/PWM3"), 126162306a36Sopenharmony_ci PINCTRL_PIN(84, "GPIO84/R2TXD0"), 126262306a36Sopenharmony_ci PINCTRL_PIN(85, "GPIO85/R2TXD1"), 126362306a36Sopenharmony_ci PINCTRL_PIN(86, "GPIO86/R2TXEN"), 126462306a36Sopenharmony_ci PINCTRL_PIN(87, "GPIO87/R2RXD0"), 126562306a36Sopenharmony_ci PINCTRL_PIN(88, "GPIO88/R2RXD1"), 126662306a36Sopenharmony_ci PINCTRL_PIN(89, "GPIO89/R2CRSDV"), 126762306a36Sopenharmony_ci PINCTRL_PIN(90, "GPIO90/R2RXERR"), 126862306a36Sopenharmony_ci PINCTRL_PIN(91, "GPIO91/R2MDC"), 126962306a36Sopenharmony_ci PINCTRL_PIN(92, "GPIO92/R2MDIO"), 127062306a36Sopenharmony_ci PINCTRL_PIN(93, "GPIO93/GA20/SMB5DSCL"), 127162306a36Sopenharmony_ci PINCTRL_PIN(94, "GPIO94/nKBRST/SMB5DSDA"), 127262306a36Sopenharmony_ci PINCTRL_PIN(95, "GPIO95/nLRESET/nESPIRST"), 127362306a36Sopenharmony_ci 127462306a36Sopenharmony_ci PINCTRL_PIN(96, "GPIO96/RG1TXD0"), 127562306a36Sopenharmony_ci PINCTRL_PIN(97, "GPIO97/RG1TXD1"), 127662306a36Sopenharmony_ci PINCTRL_PIN(98, "GPIO98/RG1TXD2"), 127762306a36Sopenharmony_ci PINCTRL_PIN(99, "GPIO99/RG1TXD3"), 127862306a36Sopenharmony_ci PINCTRL_PIN(100, "GPIO100/RG1TXC"), 127962306a36Sopenharmony_ci PINCTRL_PIN(101, "GPIO101/RG1TXCTL"), 128062306a36Sopenharmony_ci PINCTRL_PIN(102, "GPIO102/RG1RXD0"), 128162306a36Sopenharmony_ci PINCTRL_PIN(103, "GPIO103/RG1RXD1"), 128262306a36Sopenharmony_ci PINCTRL_PIN(104, "GPIO104/RG1RXD2"), 128362306a36Sopenharmony_ci PINCTRL_PIN(105, "GPIO105/RG1RXD3"), 128462306a36Sopenharmony_ci PINCTRL_PIN(106, "GPIO106/RG1RXC"), 128562306a36Sopenharmony_ci PINCTRL_PIN(107, "GPIO107/RG1RXCTL"), 128662306a36Sopenharmony_ci PINCTRL_PIN(108, "GPIO108/RG1MDC"), 128762306a36Sopenharmony_ci PINCTRL_PIN(109, "GPIO109/RG1MDIO"), 128862306a36Sopenharmony_ci PINCTRL_PIN(110, "GPIO110/RG2TXD0/DDRV0"), 128962306a36Sopenharmony_ci PINCTRL_PIN(111, "GPIO111/RG2TXD1/DDRV1"), 129062306a36Sopenharmony_ci PINCTRL_PIN(112, "GPIO112/RG2TXD2/DDRV2"), 129162306a36Sopenharmony_ci PINCTRL_PIN(113, "GPIO113/RG2TXD3/DDRV3"), 129262306a36Sopenharmony_ci PINCTRL_PIN(114, "GPIO114/SMB0SCL"), 129362306a36Sopenharmony_ci PINCTRL_PIN(115, "GPIO115/SMB0SDA"), 129462306a36Sopenharmony_ci PINCTRL_PIN(116, "GPIO116/SMB1SCL"), 129562306a36Sopenharmony_ci PINCTRL_PIN(117, "GPIO117/SMB1SDA"), 129662306a36Sopenharmony_ci PINCTRL_PIN(118, "GPIO118/SMB2SCL"), 129762306a36Sopenharmony_ci PINCTRL_PIN(119, "GPIO119/SMB2SDA"), 129862306a36Sopenharmony_ci PINCTRL_PIN(120, "GPIO120/SMB2CSDA"), 129962306a36Sopenharmony_ci PINCTRL_PIN(121, "GPIO121/SMB2CSCL"), 130062306a36Sopenharmony_ci PINCTRL_PIN(122, "GPIO122/SMB2BSDA"), 130162306a36Sopenharmony_ci PINCTRL_PIN(123, "GPIO123/SMB2BSCL"), 130262306a36Sopenharmony_ci PINCTRL_PIN(124, "GPIO124/SMB1CSDA"), 130362306a36Sopenharmony_ci PINCTRL_PIN(125, "GPIO125/SMB1CSCL"), 130462306a36Sopenharmony_ci PINCTRL_PIN(126, "GPIO126/SMB1BSDA"), 130562306a36Sopenharmony_ci PINCTRL_PIN(127, "GPIO127/SMB1BSCL"), 130662306a36Sopenharmony_ci 130762306a36Sopenharmony_ci PINCTRL_PIN(128, "GPIO128/SMB8SCL"), 130862306a36Sopenharmony_ci PINCTRL_PIN(129, "GPIO129/SMB8SDA"), 130962306a36Sopenharmony_ci PINCTRL_PIN(130, "GPIO130/SMB9SCL"), 131062306a36Sopenharmony_ci PINCTRL_PIN(131, "GPIO131/SMB9SDA"), 131162306a36Sopenharmony_ci PINCTRL_PIN(132, "GPIO132/SMB10SCL"), 131262306a36Sopenharmony_ci PINCTRL_PIN(133, "GPIO133/SMB10SDA"), 131362306a36Sopenharmony_ci PINCTRL_PIN(134, "GPIO134/SMB11SCL"), 131462306a36Sopenharmony_ci PINCTRL_PIN(135, "GPIO135/SMB11SDA"), 131562306a36Sopenharmony_ci PINCTRL_PIN(136, "GPIO136/SD1DT0"), 131662306a36Sopenharmony_ci PINCTRL_PIN(137, "GPIO137/SD1DT1"), 131762306a36Sopenharmony_ci PINCTRL_PIN(138, "GPIO138/SD1DT2"), 131862306a36Sopenharmony_ci PINCTRL_PIN(139, "GPIO139/SD1DT3"), 131962306a36Sopenharmony_ci PINCTRL_PIN(140, "GPIO140/SD1CLK"), 132062306a36Sopenharmony_ci PINCTRL_PIN(141, "GPIO141/SD1WP"), 132162306a36Sopenharmony_ci PINCTRL_PIN(142, "GPIO142/SD1CMD"), 132262306a36Sopenharmony_ci PINCTRL_PIN(143, "GPIO143/SD1CD/SD1PWR"), 132362306a36Sopenharmony_ci PINCTRL_PIN(144, "GPIO144/PWM4"), 132462306a36Sopenharmony_ci PINCTRL_PIN(145, "GPIO145/PWM5"), 132562306a36Sopenharmony_ci PINCTRL_PIN(146, "GPIO146/PWM6"), 132662306a36Sopenharmony_ci PINCTRL_PIN(147, "GPIO147/PWM7"), 132762306a36Sopenharmony_ci PINCTRL_PIN(148, "GPIO148/MMCDT4"), 132862306a36Sopenharmony_ci PINCTRL_PIN(149, "GPIO149/MMCDT5"), 132962306a36Sopenharmony_ci PINCTRL_PIN(150, "GPIO150/MMCDT6"), 133062306a36Sopenharmony_ci PINCTRL_PIN(151, "GPIO151/MMCDT7"), 133162306a36Sopenharmony_ci PINCTRL_PIN(152, "GPIO152/MMCCLK"), 133262306a36Sopenharmony_ci PINCTRL_PIN(153, "GPIO153/MMCWP"), 133362306a36Sopenharmony_ci PINCTRL_PIN(154, "GPIO154/MMCCMD"), 133462306a36Sopenharmony_ci PINCTRL_PIN(155, "GPIO155/nMMCCD/nMMCRST"), 133562306a36Sopenharmony_ci PINCTRL_PIN(156, "GPIO156/MMCDT0"), 133662306a36Sopenharmony_ci PINCTRL_PIN(157, "GPIO157/MMCDT1"), 133762306a36Sopenharmony_ci PINCTRL_PIN(158, "GPIO158/MMCDT2"), 133862306a36Sopenharmony_ci PINCTRL_PIN(159, "GPIO159/MMCDT3"), 133962306a36Sopenharmony_ci 134062306a36Sopenharmony_ci PINCTRL_PIN(160, "GPIO160/CLKOUT/RNGOSCOUT"), 134162306a36Sopenharmony_ci PINCTRL_PIN(161, "GPIO161/nLFRAME/nESPICS"), 134262306a36Sopenharmony_ci PINCTRL_PIN(162, "GPIO162/SERIRQ"), 134362306a36Sopenharmony_ci PINCTRL_PIN(163, "GPIO163/LCLK/ESPICLK"), 134462306a36Sopenharmony_ci PINCTRL_PIN(164, "GPIO164/LAD0/ESPI_IO0"/*dscnt6*/), 134562306a36Sopenharmony_ci PINCTRL_PIN(165, "GPIO165/LAD1/ESPI_IO1"/*dscnt6*/), 134662306a36Sopenharmony_ci PINCTRL_PIN(166, "GPIO166/LAD2/ESPI_IO2"/*dscnt6*/), 134762306a36Sopenharmony_ci PINCTRL_PIN(167, "GPIO167/LAD3/ESPI_IO3"/*dscnt6*/), 134862306a36Sopenharmony_ci PINCTRL_PIN(168, "GPIO168/nCLKRUN/nESPIALERT"), 134962306a36Sopenharmony_ci PINCTRL_PIN(169, "GPIO169/nSCIPME"), 135062306a36Sopenharmony_ci PINCTRL_PIN(170, "GPIO170/nSMI"), 135162306a36Sopenharmony_ci PINCTRL_PIN(171, "GPIO171/SMB6SCL"), 135262306a36Sopenharmony_ci PINCTRL_PIN(172, "GPIO172/SMB6SDA"), 135362306a36Sopenharmony_ci PINCTRL_PIN(173, "GPIO173/SMB7SCL"), 135462306a36Sopenharmony_ci PINCTRL_PIN(174, "GPIO174/SMB7SDA"), 135562306a36Sopenharmony_ci PINCTRL_PIN(175, "GPIO175/PSPI1CK/FANIN19"), 135662306a36Sopenharmony_ci PINCTRL_PIN(176, "GPIO176/PSPI1DO/FANIN18"), 135762306a36Sopenharmony_ci PINCTRL_PIN(177, "GPIO177/PSPI1DI/FANIN17"), 135862306a36Sopenharmony_ci PINCTRL_PIN(178, "GPIO178/R1TXD0"), 135962306a36Sopenharmony_ci PINCTRL_PIN(179, "GPIO179/R1TXD1"), 136062306a36Sopenharmony_ci PINCTRL_PIN(180, "GPIO180/R1TXEN"), 136162306a36Sopenharmony_ci PINCTRL_PIN(181, "GPIO181/R1RXD0"), 136262306a36Sopenharmony_ci PINCTRL_PIN(182, "GPIO182/R1RXD1"), 136362306a36Sopenharmony_ci PINCTRL_PIN(183, "GPIO183/SPI3CK"), 136462306a36Sopenharmony_ci PINCTRL_PIN(184, "GPO184/SPI3D0/STRAP9"), 136562306a36Sopenharmony_ci PINCTRL_PIN(185, "GPO185/SPI3D1/STRAP10"), 136662306a36Sopenharmony_ci PINCTRL_PIN(186, "GPIO186/nSPI3CS0"), 136762306a36Sopenharmony_ci PINCTRL_PIN(187, "GPIO187/nSPI3CS1"), 136862306a36Sopenharmony_ci PINCTRL_PIN(188, "GPIO188/SPI3D2/nSPI3CS2"), 136962306a36Sopenharmony_ci PINCTRL_PIN(189, "GPIO189/SPI3D3/nSPI3CS3"), 137062306a36Sopenharmony_ci PINCTRL_PIN(190, "GPIO190/nPRD_SMI"), 137162306a36Sopenharmony_ci PINCTRL_PIN(191, "GPIO191"), 137262306a36Sopenharmony_ci 137362306a36Sopenharmony_ci PINCTRL_PIN(192, "GPIO192"), 137462306a36Sopenharmony_ci PINCTRL_PIN(193, "GPIO193/R1CRSDV"), 137562306a36Sopenharmony_ci PINCTRL_PIN(194, "GPIO194/SMB0BSCL"), 137662306a36Sopenharmony_ci PINCTRL_PIN(195, "GPIO195/SMB0BSDA"), 137762306a36Sopenharmony_ci PINCTRL_PIN(196, "GPIO196/SMB0CSCL"), 137862306a36Sopenharmony_ci PINCTRL_PIN(197, "GPIO197/SMB0DEN"), 137962306a36Sopenharmony_ci PINCTRL_PIN(198, "GPIO198/SMB0DSDA"), 138062306a36Sopenharmony_ci PINCTRL_PIN(199, "GPIO199/SMB0DSCL"), 138162306a36Sopenharmony_ci PINCTRL_PIN(200, "GPIO200/R2CK"), 138262306a36Sopenharmony_ci PINCTRL_PIN(201, "GPIO201/R1CK"), 138362306a36Sopenharmony_ci PINCTRL_PIN(202, "GPIO202/SMB0CSDA"), 138462306a36Sopenharmony_ci PINCTRL_PIN(203, "GPIO203/FANIN16"), 138562306a36Sopenharmony_ci PINCTRL_PIN(204, "GPIO204/DDC2SCL"), 138662306a36Sopenharmony_ci PINCTRL_PIN(205, "GPIO205/DDC2SDA"), 138762306a36Sopenharmony_ci PINCTRL_PIN(206, "GPIO206/HSYNC2"), 138862306a36Sopenharmony_ci PINCTRL_PIN(207, "GPIO207/VSYNC2"), 138962306a36Sopenharmony_ci PINCTRL_PIN(208, "GPIO208/RG2TXC/DVCK"), 139062306a36Sopenharmony_ci PINCTRL_PIN(209, "GPIO209/RG2TXCTL/DDRV4"), 139162306a36Sopenharmony_ci PINCTRL_PIN(210, "GPIO210/RG2RXD0/DDRV5"), 139262306a36Sopenharmony_ci PINCTRL_PIN(211, "GPIO211/RG2RXD1/DDRV6"), 139362306a36Sopenharmony_ci PINCTRL_PIN(212, "GPIO212/RG2RXD2/DDRV7"), 139462306a36Sopenharmony_ci PINCTRL_PIN(213, "GPIO213/RG2RXD3/DDRV8"), 139562306a36Sopenharmony_ci PINCTRL_PIN(214, "GPIO214/RG2RXC/DDRV9"), 139662306a36Sopenharmony_ci PINCTRL_PIN(215, "GPIO215/RG2RXCTL/DDRV10"), 139762306a36Sopenharmony_ci PINCTRL_PIN(216, "GPIO216/RG2MDC/DDRV11"), 139862306a36Sopenharmony_ci PINCTRL_PIN(217, "GPIO217/RG2MDIO/DVHSYNC"), 139962306a36Sopenharmony_ci PINCTRL_PIN(218, "GPIO218/nWDO1"), 140062306a36Sopenharmony_ci PINCTRL_PIN(219, "GPIO219/nWDO2"), 140162306a36Sopenharmony_ci PINCTRL_PIN(220, "GPIO220/SMB12SCL"), 140262306a36Sopenharmony_ci PINCTRL_PIN(221, "GPIO221/SMB12SDA"), 140362306a36Sopenharmony_ci PINCTRL_PIN(222, "GPIO222/SMB13SCL"), 140462306a36Sopenharmony_ci PINCTRL_PIN(223, "GPIO223/SMB13SDA"), 140562306a36Sopenharmony_ci 140662306a36Sopenharmony_ci PINCTRL_PIN(224, "GPIO224/SPIXCK"), 140762306a36Sopenharmony_ci PINCTRL_PIN(225, "GPO225/SPIXD0/STRAP12"), 140862306a36Sopenharmony_ci PINCTRL_PIN(226, "GPO226/SPIXD1/STRAP13"), 140962306a36Sopenharmony_ci PINCTRL_PIN(227, "GPIO227/nSPIXCS0"), 141062306a36Sopenharmony_ci PINCTRL_PIN(228, "GPIO228/nSPIXCS1"), 141162306a36Sopenharmony_ci PINCTRL_PIN(229, "GPO229/SPIXD2/STRAP3"), 141262306a36Sopenharmony_ci PINCTRL_PIN(230, "GPIO230/SPIXD3"), 141362306a36Sopenharmony_ci PINCTRL_PIN(231, "GPIO231/nCLKREQ"), 141462306a36Sopenharmony_ci PINCTRL_PIN(255, "GPI255/DACOSEL"), 141562306a36Sopenharmony_ci}; 141662306a36Sopenharmony_ci 141762306a36Sopenharmony_ci/* Enable mode in pin group */ 141862306a36Sopenharmony_cistatic void npcm7xx_setfunc(struct regmap *gcr_regmap, const unsigned int *pin, 141962306a36Sopenharmony_ci int pin_number, int mode) 142062306a36Sopenharmony_ci{ 142162306a36Sopenharmony_ci const struct npcm7xx_pincfg *cfg; 142262306a36Sopenharmony_ci int i; 142362306a36Sopenharmony_ci 142462306a36Sopenharmony_ci for (i = 0 ; i < pin_number ; i++) { 142562306a36Sopenharmony_ci cfg = &pincfg[pin[i]]; 142662306a36Sopenharmony_ci if (mode == fn_gpio || cfg->fn0 == mode || cfg->fn1 == mode || cfg->fn2 == mode) { 142762306a36Sopenharmony_ci if (cfg->reg0) 142862306a36Sopenharmony_ci regmap_update_bits(gcr_regmap, cfg->reg0, 142962306a36Sopenharmony_ci BIT(cfg->bit0), 143062306a36Sopenharmony_ci !!(cfg->fn0 == mode) ? 143162306a36Sopenharmony_ci BIT(cfg->bit0) : 0); 143262306a36Sopenharmony_ci if (cfg->reg1) 143362306a36Sopenharmony_ci regmap_update_bits(gcr_regmap, cfg->reg1, 143462306a36Sopenharmony_ci BIT(cfg->bit1), 143562306a36Sopenharmony_ci !!(cfg->fn1 == mode) ? 143662306a36Sopenharmony_ci BIT(cfg->bit1) : 0); 143762306a36Sopenharmony_ci if (cfg->reg2) 143862306a36Sopenharmony_ci regmap_update_bits(gcr_regmap, cfg->reg2, 143962306a36Sopenharmony_ci BIT(cfg->bit2), 144062306a36Sopenharmony_ci !!(cfg->fn2 == mode) ? 144162306a36Sopenharmony_ci BIT(cfg->bit2) : 0); 144262306a36Sopenharmony_ci } 144362306a36Sopenharmony_ci } 144462306a36Sopenharmony_ci} 144562306a36Sopenharmony_ci 144662306a36Sopenharmony_ci/* Get slew rate of pin (high/low) */ 144762306a36Sopenharmony_cistatic int npcm7xx_get_slew_rate(struct npcm7xx_gpio *bank, 144862306a36Sopenharmony_ci struct regmap *gcr_regmap, unsigned int pin) 144962306a36Sopenharmony_ci{ 145062306a36Sopenharmony_ci u32 val; 145162306a36Sopenharmony_ci int gpio = (pin % bank->gc.ngpio); 145262306a36Sopenharmony_ci unsigned long pinmask = BIT(gpio); 145362306a36Sopenharmony_ci 145462306a36Sopenharmony_ci if (pincfg[pin].flag & SLEW) 145562306a36Sopenharmony_ci return ioread32(bank->base + NPCM7XX_GP_N_OSRC) 145662306a36Sopenharmony_ci & pinmask; 145762306a36Sopenharmony_ci /* LPC Slew rate in SRCNT register */ 145862306a36Sopenharmony_ci if (pincfg[pin].flag & SLEWLPC) { 145962306a36Sopenharmony_ci regmap_read(gcr_regmap, NPCM7XX_GCR_SRCNT, &val); 146062306a36Sopenharmony_ci return !!(val & SRCNT_ESPI); 146162306a36Sopenharmony_ci } 146262306a36Sopenharmony_ci 146362306a36Sopenharmony_ci return -EINVAL; 146462306a36Sopenharmony_ci} 146562306a36Sopenharmony_ci 146662306a36Sopenharmony_ci/* Set slew rate of pin (high/low) */ 146762306a36Sopenharmony_cistatic int npcm7xx_set_slew_rate(struct npcm7xx_gpio *bank, 146862306a36Sopenharmony_ci struct regmap *gcr_regmap, unsigned int pin, 146962306a36Sopenharmony_ci int arg) 147062306a36Sopenharmony_ci{ 147162306a36Sopenharmony_ci int gpio = BIT(pin % bank->gc.ngpio); 147262306a36Sopenharmony_ci 147362306a36Sopenharmony_ci if (pincfg[pin].flag & SLEW) { 147462306a36Sopenharmony_ci switch (arg) { 147562306a36Sopenharmony_ci case 0: 147662306a36Sopenharmony_ci npcm_gpio_clr(&bank->gc, bank->base + NPCM7XX_GP_N_OSRC, 147762306a36Sopenharmony_ci gpio); 147862306a36Sopenharmony_ci return 0; 147962306a36Sopenharmony_ci case 1: 148062306a36Sopenharmony_ci npcm_gpio_set(&bank->gc, bank->base + NPCM7XX_GP_N_OSRC, 148162306a36Sopenharmony_ci gpio); 148262306a36Sopenharmony_ci return 0; 148362306a36Sopenharmony_ci default: 148462306a36Sopenharmony_ci return -EINVAL; 148562306a36Sopenharmony_ci } 148662306a36Sopenharmony_ci } 148762306a36Sopenharmony_ci /* LPC Slew rate in SRCNT register */ 148862306a36Sopenharmony_ci if (pincfg[pin].flag & SLEWLPC) { 148962306a36Sopenharmony_ci switch (arg) { 149062306a36Sopenharmony_ci case 0: 149162306a36Sopenharmony_ci regmap_update_bits(gcr_regmap, NPCM7XX_GCR_SRCNT, 149262306a36Sopenharmony_ci SRCNT_ESPI, 0); 149362306a36Sopenharmony_ci return 0; 149462306a36Sopenharmony_ci case 1: 149562306a36Sopenharmony_ci regmap_update_bits(gcr_regmap, NPCM7XX_GCR_SRCNT, 149662306a36Sopenharmony_ci SRCNT_ESPI, SRCNT_ESPI); 149762306a36Sopenharmony_ci return 0; 149862306a36Sopenharmony_ci default: 149962306a36Sopenharmony_ci return -EINVAL; 150062306a36Sopenharmony_ci } 150162306a36Sopenharmony_ci } 150262306a36Sopenharmony_ci 150362306a36Sopenharmony_ci return -EINVAL; 150462306a36Sopenharmony_ci} 150562306a36Sopenharmony_ci 150662306a36Sopenharmony_ci/* Get drive strength for a pin, if supported */ 150762306a36Sopenharmony_cistatic int npcm7xx_get_drive_strength(struct pinctrl_dev *pctldev, 150862306a36Sopenharmony_ci unsigned int pin) 150962306a36Sopenharmony_ci{ 151062306a36Sopenharmony_ci struct npcm7xx_pinctrl *npcm = pinctrl_dev_get_drvdata(pctldev); 151162306a36Sopenharmony_ci struct npcm7xx_gpio *bank = 151262306a36Sopenharmony_ci &npcm->gpio_bank[pin / NPCM7XX_GPIO_PER_BANK]; 151362306a36Sopenharmony_ci int gpio = (pin % bank->gc.ngpio); 151462306a36Sopenharmony_ci unsigned long pinmask = BIT(gpio); 151562306a36Sopenharmony_ci u32 ds = 0; 151662306a36Sopenharmony_ci int flg, val; 151762306a36Sopenharmony_ci 151862306a36Sopenharmony_ci flg = pincfg[pin].flag; 151962306a36Sopenharmony_ci if (flg & DRIVE_STRENGTH_MASK) { 152062306a36Sopenharmony_ci /* Get standard reading */ 152162306a36Sopenharmony_ci val = ioread32(bank->base + NPCM7XX_GP_N_ODSC) 152262306a36Sopenharmony_ci & pinmask; 152362306a36Sopenharmony_ci ds = val ? DSHI(flg) : DSLO(flg); 152462306a36Sopenharmony_ci dev_dbg(bank->gc.parent, 152562306a36Sopenharmony_ci "pin %d strength %d = %d\n", pin, val, ds); 152662306a36Sopenharmony_ci return ds; 152762306a36Sopenharmony_ci } 152862306a36Sopenharmony_ci 152962306a36Sopenharmony_ci return -EINVAL; 153062306a36Sopenharmony_ci} 153162306a36Sopenharmony_ci 153262306a36Sopenharmony_ci/* Set drive strength for a pin, if supported */ 153362306a36Sopenharmony_cistatic int npcm7xx_set_drive_strength(struct npcm7xx_pinctrl *npcm, 153462306a36Sopenharmony_ci unsigned int pin, int nval) 153562306a36Sopenharmony_ci{ 153662306a36Sopenharmony_ci int v; 153762306a36Sopenharmony_ci struct npcm7xx_gpio *bank = 153862306a36Sopenharmony_ci &npcm->gpio_bank[pin / NPCM7XX_GPIO_PER_BANK]; 153962306a36Sopenharmony_ci int gpio = BIT(pin % bank->gc.ngpio); 154062306a36Sopenharmony_ci 154162306a36Sopenharmony_ci v = (pincfg[pin].flag & DRIVE_STRENGTH_MASK); 154262306a36Sopenharmony_ci if (!nval || !v) 154362306a36Sopenharmony_ci return -ENOTSUPP; 154462306a36Sopenharmony_ci if (DSLO(v) == nval) { 154562306a36Sopenharmony_ci dev_dbg(bank->gc.parent, 154662306a36Sopenharmony_ci "setting pin %d to low strength [%d]\n", pin, nval); 154762306a36Sopenharmony_ci npcm_gpio_clr(&bank->gc, bank->base + NPCM7XX_GP_N_ODSC, gpio); 154862306a36Sopenharmony_ci return 0; 154962306a36Sopenharmony_ci } else if (DSHI(v) == nval) { 155062306a36Sopenharmony_ci dev_dbg(bank->gc.parent, 155162306a36Sopenharmony_ci "setting pin %d to high strength [%d]\n", pin, nval); 155262306a36Sopenharmony_ci npcm_gpio_set(&bank->gc, bank->base + NPCM7XX_GP_N_ODSC, gpio); 155362306a36Sopenharmony_ci return 0; 155462306a36Sopenharmony_ci } 155562306a36Sopenharmony_ci 155662306a36Sopenharmony_ci return -ENOTSUPP; 155762306a36Sopenharmony_ci} 155862306a36Sopenharmony_ci 155962306a36Sopenharmony_ci/* pinctrl_ops */ 156062306a36Sopenharmony_cistatic void npcm7xx_pin_dbg_show(struct pinctrl_dev *pctldev, 156162306a36Sopenharmony_ci struct seq_file *s, unsigned int offset) 156262306a36Sopenharmony_ci{ 156362306a36Sopenharmony_ci seq_printf(s, "pinctrl_ops.dbg: %d", offset); 156462306a36Sopenharmony_ci} 156562306a36Sopenharmony_ci 156662306a36Sopenharmony_cistatic int npcm7xx_get_groups_count(struct pinctrl_dev *pctldev) 156762306a36Sopenharmony_ci{ 156862306a36Sopenharmony_ci struct npcm7xx_pinctrl *npcm = pinctrl_dev_get_drvdata(pctldev); 156962306a36Sopenharmony_ci 157062306a36Sopenharmony_ci dev_dbg(npcm->dev, "group size: %zu\n", ARRAY_SIZE(npcm7xx_groups)); 157162306a36Sopenharmony_ci return ARRAY_SIZE(npcm7xx_groups); 157262306a36Sopenharmony_ci} 157362306a36Sopenharmony_ci 157462306a36Sopenharmony_cistatic const char *npcm7xx_get_group_name(struct pinctrl_dev *pctldev, 157562306a36Sopenharmony_ci unsigned int selector) 157662306a36Sopenharmony_ci{ 157762306a36Sopenharmony_ci return npcm7xx_groups[selector].name; 157862306a36Sopenharmony_ci} 157962306a36Sopenharmony_ci 158062306a36Sopenharmony_cistatic int npcm7xx_get_group_pins(struct pinctrl_dev *pctldev, 158162306a36Sopenharmony_ci unsigned int selector, 158262306a36Sopenharmony_ci const unsigned int **pins, 158362306a36Sopenharmony_ci unsigned int *npins) 158462306a36Sopenharmony_ci{ 158562306a36Sopenharmony_ci *npins = npcm7xx_groups[selector].npins; 158662306a36Sopenharmony_ci *pins = npcm7xx_groups[selector].pins; 158762306a36Sopenharmony_ci 158862306a36Sopenharmony_ci return 0; 158962306a36Sopenharmony_ci} 159062306a36Sopenharmony_ci 159162306a36Sopenharmony_cistatic int npcm7xx_dt_node_to_map(struct pinctrl_dev *pctldev, 159262306a36Sopenharmony_ci struct device_node *np_config, 159362306a36Sopenharmony_ci struct pinctrl_map **map, 159462306a36Sopenharmony_ci u32 *num_maps) 159562306a36Sopenharmony_ci{ 159662306a36Sopenharmony_ci struct npcm7xx_pinctrl *npcm = pinctrl_dev_get_drvdata(pctldev); 159762306a36Sopenharmony_ci 159862306a36Sopenharmony_ci dev_dbg(npcm->dev, "dt_node_to_map: %s\n", np_config->name); 159962306a36Sopenharmony_ci return pinconf_generic_dt_node_to_map(pctldev, np_config, 160062306a36Sopenharmony_ci map, num_maps, 160162306a36Sopenharmony_ci PIN_MAP_TYPE_INVALID); 160262306a36Sopenharmony_ci} 160362306a36Sopenharmony_ci 160462306a36Sopenharmony_cistatic void npcm7xx_dt_free_map(struct pinctrl_dev *pctldev, 160562306a36Sopenharmony_ci struct pinctrl_map *map, u32 num_maps) 160662306a36Sopenharmony_ci{ 160762306a36Sopenharmony_ci kfree(map); 160862306a36Sopenharmony_ci} 160962306a36Sopenharmony_ci 161062306a36Sopenharmony_cistatic const struct pinctrl_ops npcm7xx_pinctrl_ops = { 161162306a36Sopenharmony_ci .get_groups_count = npcm7xx_get_groups_count, 161262306a36Sopenharmony_ci .get_group_name = npcm7xx_get_group_name, 161362306a36Sopenharmony_ci .get_group_pins = npcm7xx_get_group_pins, 161462306a36Sopenharmony_ci .pin_dbg_show = npcm7xx_pin_dbg_show, 161562306a36Sopenharmony_ci .dt_node_to_map = npcm7xx_dt_node_to_map, 161662306a36Sopenharmony_ci .dt_free_map = npcm7xx_dt_free_map, 161762306a36Sopenharmony_ci}; 161862306a36Sopenharmony_ci 161962306a36Sopenharmony_ci/* pinmux_ops */ 162062306a36Sopenharmony_cistatic int npcm7xx_get_functions_count(struct pinctrl_dev *pctldev) 162162306a36Sopenharmony_ci{ 162262306a36Sopenharmony_ci return ARRAY_SIZE(npcm7xx_funcs); 162362306a36Sopenharmony_ci} 162462306a36Sopenharmony_ci 162562306a36Sopenharmony_cistatic const char *npcm7xx_get_function_name(struct pinctrl_dev *pctldev, 162662306a36Sopenharmony_ci unsigned int function) 162762306a36Sopenharmony_ci{ 162862306a36Sopenharmony_ci return npcm7xx_funcs[function].name; 162962306a36Sopenharmony_ci} 163062306a36Sopenharmony_ci 163162306a36Sopenharmony_cistatic int npcm7xx_get_function_groups(struct pinctrl_dev *pctldev, 163262306a36Sopenharmony_ci unsigned int function, 163362306a36Sopenharmony_ci const char * const **groups, 163462306a36Sopenharmony_ci unsigned int * const ngroups) 163562306a36Sopenharmony_ci{ 163662306a36Sopenharmony_ci *ngroups = npcm7xx_funcs[function].ngroups; 163762306a36Sopenharmony_ci *groups = npcm7xx_funcs[function].groups; 163862306a36Sopenharmony_ci 163962306a36Sopenharmony_ci return 0; 164062306a36Sopenharmony_ci} 164162306a36Sopenharmony_ci 164262306a36Sopenharmony_cistatic int npcm7xx_pinmux_set_mux(struct pinctrl_dev *pctldev, 164362306a36Sopenharmony_ci unsigned int function, 164462306a36Sopenharmony_ci unsigned int group) 164562306a36Sopenharmony_ci{ 164662306a36Sopenharmony_ci struct npcm7xx_pinctrl *npcm = pinctrl_dev_get_drvdata(pctldev); 164762306a36Sopenharmony_ci 164862306a36Sopenharmony_ci dev_dbg(npcm->dev, "set_mux: %d, %d[%s]\n", function, group, 164962306a36Sopenharmony_ci npcm7xx_groups[group].name); 165062306a36Sopenharmony_ci 165162306a36Sopenharmony_ci npcm7xx_setfunc(npcm->gcr_regmap, npcm7xx_groups[group].pins, 165262306a36Sopenharmony_ci npcm7xx_groups[group].npins, group); 165362306a36Sopenharmony_ci 165462306a36Sopenharmony_ci return 0; 165562306a36Sopenharmony_ci} 165662306a36Sopenharmony_ci 165762306a36Sopenharmony_cistatic int npcm7xx_gpio_request_enable(struct pinctrl_dev *pctldev, 165862306a36Sopenharmony_ci struct pinctrl_gpio_range *range, 165962306a36Sopenharmony_ci unsigned int offset) 166062306a36Sopenharmony_ci{ 166162306a36Sopenharmony_ci struct npcm7xx_pinctrl *npcm = pinctrl_dev_get_drvdata(pctldev); 166262306a36Sopenharmony_ci 166362306a36Sopenharmony_ci if (!range) { 166462306a36Sopenharmony_ci dev_err(npcm->dev, "invalid range\n"); 166562306a36Sopenharmony_ci return -EINVAL; 166662306a36Sopenharmony_ci } 166762306a36Sopenharmony_ci if (!range->gc) { 166862306a36Sopenharmony_ci dev_err(npcm->dev, "invalid gpiochip\n"); 166962306a36Sopenharmony_ci return -EINVAL; 167062306a36Sopenharmony_ci } 167162306a36Sopenharmony_ci 167262306a36Sopenharmony_ci npcm7xx_setfunc(npcm->gcr_regmap, &offset, 1, fn_gpio); 167362306a36Sopenharmony_ci 167462306a36Sopenharmony_ci return 0; 167562306a36Sopenharmony_ci} 167662306a36Sopenharmony_ci 167762306a36Sopenharmony_ci/* Release GPIO back to pinctrl mode */ 167862306a36Sopenharmony_cistatic void npcm7xx_gpio_request_free(struct pinctrl_dev *pctldev, 167962306a36Sopenharmony_ci struct pinctrl_gpio_range *range, 168062306a36Sopenharmony_ci unsigned int offset) 168162306a36Sopenharmony_ci{ 168262306a36Sopenharmony_ci struct npcm7xx_pinctrl *npcm = pinctrl_dev_get_drvdata(pctldev); 168362306a36Sopenharmony_ci int virq; 168462306a36Sopenharmony_ci 168562306a36Sopenharmony_ci virq = irq_find_mapping(npcm->domain, offset); 168662306a36Sopenharmony_ci if (virq) 168762306a36Sopenharmony_ci irq_dispose_mapping(virq); 168862306a36Sopenharmony_ci} 168962306a36Sopenharmony_ci 169062306a36Sopenharmony_ci/* Set GPIO direction */ 169162306a36Sopenharmony_cistatic int npcm_gpio_set_direction(struct pinctrl_dev *pctldev, 169262306a36Sopenharmony_ci struct pinctrl_gpio_range *range, 169362306a36Sopenharmony_ci unsigned int offset, bool input) 169462306a36Sopenharmony_ci{ 169562306a36Sopenharmony_ci struct npcm7xx_pinctrl *npcm = pinctrl_dev_get_drvdata(pctldev); 169662306a36Sopenharmony_ci struct npcm7xx_gpio *bank = 169762306a36Sopenharmony_ci &npcm->gpio_bank[offset / NPCM7XX_GPIO_PER_BANK]; 169862306a36Sopenharmony_ci int gpio = BIT(offset % bank->gc.ngpio); 169962306a36Sopenharmony_ci 170062306a36Sopenharmony_ci dev_dbg(bank->gc.parent, "GPIO Set Direction: %d = %d\n", offset, 170162306a36Sopenharmony_ci input); 170262306a36Sopenharmony_ci if (input) 170362306a36Sopenharmony_ci iowrite32(gpio, bank->base + NPCM7XX_GP_N_OEC); 170462306a36Sopenharmony_ci else 170562306a36Sopenharmony_ci iowrite32(gpio, bank->base + NPCM7XX_GP_N_OES); 170662306a36Sopenharmony_ci 170762306a36Sopenharmony_ci return 0; 170862306a36Sopenharmony_ci} 170962306a36Sopenharmony_ci 171062306a36Sopenharmony_cistatic const struct pinmux_ops npcm7xx_pinmux_ops = { 171162306a36Sopenharmony_ci .get_functions_count = npcm7xx_get_functions_count, 171262306a36Sopenharmony_ci .get_function_name = npcm7xx_get_function_name, 171362306a36Sopenharmony_ci .get_function_groups = npcm7xx_get_function_groups, 171462306a36Sopenharmony_ci .set_mux = npcm7xx_pinmux_set_mux, 171562306a36Sopenharmony_ci .gpio_request_enable = npcm7xx_gpio_request_enable, 171662306a36Sopenharmony_ci .gpio_disable_free = npcm7xx_gpio_request_free, 171762306a36Sopenharmony_ci .gpio_set_direction = npcm_gpio_set_direction, 171862306a36Sopenharmony_ci}; 171962306a36Sopenharmony_ci 172062306a36Sopenharmony_ci/* pinconf_ops */ 172162306a36Sopenharmony_cistatic int npcm7xx_config_get(struct pinctrl_dev *pctldev, unsigned int pin, 172262306a36Sopenharmony_ci unsigned long *config) 172362306a36Sopenharmony_ci{ 172462306a36Sopenharmony_ci enum pin_config_param param = pinconf_to_config_param(*config); 172562306a36Sopenharmony_ci struct npcm7xx_pinctrl *npcm = pinctrl_dev_get_drvdata(pctldev); 172662306a36Sopenharmony_ci struct npcm7xx_gpio *bank = 172762306a36Sopenharmony_ci &npcm->gpio_bank[pin / NPCM7XX_GPIO_PER_BANK]; 172862306a36Sopenharmony_ci int gpio = (pin % bank->gc.ngpio); 172962306a36Sopenharmony_ci unsigned long pinmask = BIT(gpio); 173062306a36Sopenharmony_ci u32 ie, oe, pu, pd; 173162306a36Sopenharmony_ci int rc = 0; 173262306a36Sopenharmony_ci 173362306a36Sopenharmony_ci switch (param) { 173462306a36Sopenharmony_ci case PIN_CONFIG_BIAS_DISABLE: 173562306a36Sopenharmony_ci case PIN_CONFIG_BIAS_PULL_UP: 173662306a36Sopenharmony_ci case PIN_CONFIG_BIAS_PULL_DOWN: 173762306a36Sopenharmony_ci pu = ioread32(bank->base + NPCM7XX_GP_N_PU) & pinmask; 173862306a36Sopenharmony_ci pd = ioread32(bank->base + NPCM7XX_GP_N_PD) & pinmask; 173962306a36Sopenharmony_ci if (param == PIN_CONFIG_BIAS_DISABLE) 174062306a36Sopenharmony_ci rc = (!pu && !pd); 174162306a36Sopenharmony_ci else if (param == PIN_CONFIG_BIAS_PULL_UP) 174262306a36Sopenharmony_ci rc = (pu && !pd); 174362306a36Sopenharmony_ci else if (param == PIN_CONFIG_BIAS_PULL_DOWN) 174462306a36Sopenharmony_ci rc = (!pu && pd); 174562306a36Sopenharmony_ci break; 174662306a36Sopenharmony_ci case PIN_CONFIG_OUTPUT: 174762306a36Sopenharmony_ci case PIN_CONFIG_INPUT_ENABLE: 174862306a36Sopenharmony_ci ie = ioread32(bank->base + NPCM7XX_GP_N_IEM) & pinmask; 174962306a36Sopenharmony_ci oe = ioread32(bank->base + NPCM7XX_GP_N_OE) & pinmask; 175062306a36Sopenharmony_ci if (param == PIN_CONFIG_INPUT_ENABLE) 175162306a36Sopenharmony_ci rc = (ie && !oe); 175262306a36Sopenharmony_ci else if (param == PIN_CONFIG_OUTPUT) 175362306a36Sopenharmony_ci rc = (!ie && oe); 175462306a36Sopenharmony_ci break; 175562306a36Sopenharmony_ci case PIN_CONFIG_DRIVE_PUSH_PULL: 175662306a36Sopenharmony_ci rc = !(ioread32(bank->base + NPCM7XX_GP_N_OTYP) & pinmask); 175762306a36Sopenharmony_ci break; 175862306a36Sopenharmony_ci case PIN_CONFIG_DRIVE_OPEN_DRAIN: 175962306a36Sopenharmony_ci rc = ioread32(bank->base + NPCM7XX_GP_N_OTYP) & pinmask; 176062306a36Sopenharmony_ci break; 176162306a36Sopenharmony_ci case PIN_CONFIG_INPUT_DEBOUNCE: 176262306a36Sopenharmony_ci rc = ioread32(bank->base + NPCM7XX_GP_N_DBNC) & pinmask; 176362306a36Sopenharmony_ci break; 176462306a36Sopenharmony_ci case PIN_CONFIG_DRIVE_STRENGTH: 176562306a36Sopenharmony_ci rc = npcm7xx_get_drive_strength(pctldev, pin); 176662306a36Sopenharmony_ci if (rc) 176762306a36Sopenharmony_ci *config = pinconf_to_config_packed(param, rc); 176862306a36Sopenharmony_ci break; 176962306a36Sopenharmony_ci case PIN_CONFIG_SLEW_RATE: 177062306a36Sopenharmony_ci rc = npcm7xx_get_slew_rate(bank, npcm->gcr_regmap, pin); 177162306a36Sopenharmony_ci if (rc >= 0) 177262306a36Sopenharmony_ci *config = pinconf_to_config_packed(param, rc); 177362306a36Sopenharmony_ci break; 177462306a36Sopenharmony_ci default: 177562306a36Sopenharmony_ci return -ENOTSUPP; 177662306a36Sopenharmony_ci } 177762306a36Sopenharmony_ci 177862306a36Sopenharmony_ci if (!rc) 177962306a36Sopenharmony_ci return -EINVAL; 178062306a36Sopenharmony_ci 178162306a36Sopenharmony_ci return 0; 178262306a36Sopenharmony_ci} 178362306a36Sopenharmony_ci 178462306a36Sopenharmony_cistatic int npcm7xx_config_set_one(struct npcm7xx_pinctrl *npcm, 178562306a36Sopenharmony_ci unsigned int pin, unsigned long config) 178662306a36Sopenharmony_ci{ 178762306a36Sopenharmony_ci enum pin_config_param param = pinconf_to_config_param(config); 178862306a36Sopenharmony_ci u16 arg = pinconf_to_config_argument(config); 178962306a36Sopenharmony_ci struct npcm7xx_gpio *bank = 179062306a36Sopenharmony_ci &npcm->gpio_bank[pin / NPCM7XX_GPIO_PER_BANK]; 179162306a36Sopenharmony_ci int gpio = BIT(pin % bank->gc.ngpio); 179262306a36Sopenharmony_ci 179362306a36Sopenharmony_ci dev_dbg(bank->gc.parent, "param=%d %d[GPIO]\n", param, pin); 179462306a36Sopenharmony_ci switch (param) { 179562306a36Sopenharmony_ci case PIN_CONFIG_BIAS_DISABLE: 179662306a36Sopenharmony_ci npcm_gpio_clr(&bank->gc, bank->base + NPCM7XX_GP_N_PU, gpio); 179762306a36Sopenharmony_ci npcm_gpio_clr(&bank->gc, bank->base + NPCM7XX_GP_N_PD, gpio); 179862306a36Sopenharmony_ci break; 179962306a36Sopenharmony_ci case PIN_CONFIG_BIAS_PULL_DOWN: 180062306a36Sopenharmony_ci npcm_gpio_clr(&bank->gc, bank->base + NPCM7XX_GP_N_PU, gpio); 180162306a36Sopenharmony_ci npcm_gpio_set(&bank->gc, bank->base + NPCM7XX_GP_N_PD, gpio); 180262306a36Sopenharmony_ci break; 180362306a36Sopenharmony_ci case PIN_CONFIG_BIAS_PULL_UP: 180462306a36Sopenharmony_ci npcm_gpio_clr(&bank->gc, bank->base + NPCM7XX_GP_N_PD, gpio); 180562306a36Sopenharmony_ci npcm_gpio_set(&bank->gc, bank->base + NPCM7XX_GP_N_PU, gpio); 180662306a36Sopenharmony_ci break; 180762306a36Sopenharmony_ci case PIN_CONFIG_INPUT_ENABLE: 180862306a36Sopenharmony_ci iowrite32(gpio, bank->base + NPCM7XX_GP_N_OEC); 180962306a36Sopenharmony_ci bank->direction_input(&bank->gc, pin % bank->gc.ngpio); 181062306a36Sopenharmony_ci break; 181162306a36Sopenharmony_ci case PIN_CONFIG_OUTPUT: 181262306a36Sopenharmony_ci iowrite32(gpio, bank->base + NPCM7XX_GP_N_OES); 181362306a36Sopenharmony_ci bank->direction_output(&bank->gc, pin % bank->gc.ngpio, arg); 181462306a36Sopenharmony_ci break; 181562306a36Sopenharmony_ci case PIN_CONFIG_DRIVE_PUSH_PULL: 181662306a36Sopenharmony_ci npcm_gpio_clr(&bank->gc, bank->base + NPCM7XX_GP_N_OTYP, gpio); 181762306a36Sopenharmony_ci break; 181862306a36Sopenharmony_ci case PIN_CONFIG_DRIVE_OPEN_DRAIN: 181962306a36Sopenharmony_ci npcm_gpio_set(&bank->gc, bank->base + NPCM7XX_GP_N_OTYP, gpio); 182062306a36Sopenharmony_ci break; 182162306a36Sopenharmony_ci case PIN_CONFIG_INPUT_DEBOUNCE: 182262306a36Sopenharmony_ci npcm_gpio_set(&bank->gc, bank->base + NPCM7XX_GP_N_DBNC, gpio); 182362306a36Sopenharmony_ci break; 182462306a36Sopenharmony_ci case PIN_CONFIG_SLEW_RATE: 182562306a36Sopenharmony_ci return npcm7xx_set_slew_rate(bank, npcm->gcr_regmap, pin, arg); 182662306a36Sopenharmony_ci case PIN_CONFIG_DRIVE_STRENGTH: 182762306a36Sopenharmony_ci return npcm7xx_set_drive_strength(npcm, pin, arg); 182862306a36Sopenharmony_ci default: 182962306a36Sopenharmony_ci return -ENOTSUPP; 183062306a36Sopenharmony_ci } 183162306a36Sopenharmony_ci 183262306a36Sopenharmony_ci return 0; 183362306a36Sopenharmony_ci} 183462306a36Sopenharmony_ci 183562306a36Sopenharmony_ci/* Set multiple configuration settings for a pin */ 183662306a36Sopenharmony_cistatic int npcm7xx_config_set(struct pinctrl_dev *pctldev, unsigned int pin, 183762306a36Sopenharmony_ci unsigned long *configs, unsigned int num_configs) 183862306a36Sopenharmony_ci{ 183962306a36Sopenharmony_ci struct npcm7xx_pinctrl *npcm = pinctrl_dev_get_drvdata(pctldev); 184062306a36Sopenharmony_ci int rc; 184162306a36Sopenharmony_ci 184262306a36Sopenharmony_ci while (num_configs--) { 184362306a36Sopenharmony_ci rc = npcm7xx_config_set_one(npcm, pin, *configs++); 184462306a36Sopenharmony_ci if (rc) 184562306a36Sopenharmony_ci return rc; 184662306a36Sopenharmony_ci } 184762306a36Sopenharmony_ci 184862306a36Sopenharmony_ci return 0; 184962306a36Sopenharmony_ci} 185062306a36Sopenharmony_ci 185162306a36Sopenharmony_cistatic const struct pinconf_ops npcm7xx_pinconf_ops = { 185262306a36Sopenharmony_ci .is_generic = true, 185362306a36Sopenharmony_ci .pin_config_get = npcm7xx_config_get, 185462306a36Sopenharmony_ci .pin_config_set = npcm7xx_config_set, 185562306a36Sopenharmony_ci}; 185662306a36Sopenharmony_ci 185762306a36Sopenharmony_ci/* pinctrl_desc */ 185862306a36Sopenharmony_cistatic struct pinctrl_desc npcm7xx_pinctrl_desc = { 185962306a36Sopenharmony_ci .name = "npcm7xx-pinctrl", 186062306a36Sopenharmony_ci .pins = npcm7xx_pins, 186162306a36Sopenharmony_ci .npins = ARRAY_SIZE(npcm7xx_pins), 186262306a36Sopenharmony_ci .pctlops = &npcm7xx_pinctrl_ops, 186362306a36Sopenharmony_ci .pmxops = &npcm7xx_pinmux_ops, 186462306a36Sopenharmony_ci .confops = &npcm7xx_pinconf_ops, 186562306a36Sopenharmony_ci .owner = THIS_MODULE, 186662306a36Sopenharmony_ci}; 186762306a36Sopenharmony_ci 186862306a36Sopenharmony_cistatic int npcm7xx_gpio_of(struct npcm7xx_pinctrl *pctrl) 186962306a36Sopenharmony_ci{ 187062306a36Sopenharmony_ci int ret = -ENXIO; 187162306a36Sopenharmony_ci struct resource res; 187262306a36Sopenharmony_ci struct device *dev = pctrl->dev; 187362306a36Sopenharmony_ci struct fwnode_reference_args args; 187462306a36Sopenharmony_ci struct fwnode_handle *child; 187562306a36Sopenharmony_ci int id = 0; 187662306a36Sopenharmony_ci 187762306a36Sopenharmony_ci for_each_gpiochip_node(dev, child) { 187862306a36Sopenharmony_ci struct device_node *np = to_of_node(child); 187962306a36Sopenharmony_ci 188062306a36Sopenharmony_ci ret = of_address_to_resource(np, 0, &res); 188162306a36Sopenharmony_ci if (ret < 0) { 188262306a36Sopenharmony_ci dev_err(dev, "Resource fail for GPIO bank %u\n", id); 188362306a36Sopenharmony_ci return ret; 188462306a36Sopenharmony_ci } 188562306a36Sopenharmony_ci 188662306a36Sopenharmony_ci pctrl->gpio_bank[id].base = ioremap(res.start, resource_size(&res)); 188762306a36Sopenharmony_ci if (!pctrl->gpio_bank[id].base) 188862306a36Sopenharmony_ci return -EINVAL; 188962306a36Sopenharmony_ci 189062306a36Sopenharmony_ci ret = bgpio_init(&pctrl->gpio_bank[id].gc, dev, 4, 189162306a36Sopenharmony_ci pctrl->gpio_bank[id].base + NPCM7XX_GP_N_DIN, 189262306a36Sopenharmony_ci pctrl->gpio_bank[id].base + NPCM7XX_GP_N_DOUT, 189362306a36Sopenharmony_ci NULL, 189462306a36Sopenharmony_ci NULL, 189562306a36Sopenharmony_ci pctrl->gpio_bank[id].base + NPCM7XX_GP_N_IEM, 189662306a36Sopenharmony_ci BGPIOF_READ_OUTPUT_REG_SET); 189762306a36Sopenharmony_ci if (ret) { 189862306a36Sopenharmony_ci dev_err(dev, "bgpio_init() failed\n"); 189962306a36Sopenharmony_ci return ret; 190062306a36Sopenharmony_ci } 190162306a36Sopenharmony_ci 190262306a36Sopenharmony_ci ret = fwnode_property_get_reference_args(child, "gpio-ranges", NULL, 3, 0, &args); 190362306a36Sopenharmony_ci if (ret < 0) { 190462306a36Sopenharmony_ci dev_err(dev, "gpio-ranges fail for GPIO bank %u\n", id); 190562306a36Sopenharmony_ci return ret; 190662306a36Sopenharmony_ci } 190762306a36Sopenharmony_ci 190862306a36Sopenharmony_ci ret = irq_of_parse_and_map(np, 0); 190962306a36Sopenharmony_ci if (!ret) { 191062306a36Sopenharmony_ci dev_err(dev, "No IRQ for GPIO bank %u\n", id); 191162306a36Sopenharmony_ci return -EINVAL; 191262306a36Sopenharmony_ci } 191362306a36Sopenharmony_ci pctrl->gpio_bank[id].irq = ret; 191462306a36Sopenharmony_ci pctrl->gpio_bank[id].irqbase = id * NPCM7XX_GPIO_PER_BANK; 191562306a36Sopenharmony_ci pctrl->gpio_bank[id].pinctrl_id = args.args[0]; 191662306a36Sopenharmony_ci pctrl->gpio_bank[id].gc.base = args.args[1]; 191762306a36Sopenharmony_ci pctrl->gpio_bank[id].gc.ngpio = args.args[2]; 191862306a36Sopenharmony_ci pctrl->gpio_bank[id].gc.owner = THIS_MODULE; 191962306a36Sopenharmony_ci pctrl->gpio_bank[id].gc.parent = dev; 192062306a36Sopenharmony_ci pctrl->gpio_bank[id].gc.fwnode = child; 192162306a36Sopenharmony_ci pctrl->gpio_bank[id].gc.label = devm_kasprintf(dev, GFP_KERNEL, "%pfw", child); 192262306a36Sopenharmony_ci if (pctrl->gpio_bank[id].gc.label == NULL) 192362306a36Sopenharmony_ci return -ENOMEM; 192462306a36Sopenharmony_ci 192562306a36Sopenharmony_ci pctrl->gpio_bank[id].gc.dbg_show = npcmgpio_dbg_show; 192662306a36Sopenharmony_ci pctrl->gpio_bank[id].direction_input = pctrl->gpio_bank[id].gc.direction_input; 192762306a36Sopenharmony_ci pctrl->gpio_bank[id].gc.direction_input = npcmgpio_direction_input; 192862306a36Sopenharmony_ci pctrl->gpio_bank[id].direction_output = pctrl->gpio_bank[id].gc.direction_output; 192962306a36Sopenharmony_ci pctrl->gpio_bank[id].gc.direction_output = npcmgpio_direction_output; 193062306a36Sopenharmony_ci pctrl->gpio_bank[id].request = pctrl->gpio_bank[id].gc.request; 193162306a36Sopenharmony_ci pctrl->gpio_bank[id].gc.request = npcmgpio_gpio_request; 193262306a36Sopenharmony_ci pctrl->gpio_bank[id].gc.free = npcmgpio_gpio_free; 193362306a36Sopenharmony_ci id++; 193462306a36Sopenharmony_ci } 193562306a36Sopenharmony_ci 193662306a36Sopenharmony_ci pctrl->bank_num = id; 193762306a36Sopenharmony_ci return ret; 193862306a36Sopenharmony_ci} 193962306a36Sopenharmony_ci 194062306a36Sopenharmony_cistatic int npcm7xx_gpio_register(struct npcm7xx_pinctrl *pctrl) 194162306a36Sopenharmony_ci{ 194262306a36Sopenharmony_ci int ret, id; 194362306a36Sopenharmony_ci 194462306a36Sopenharmony_ci for (id = 0 ; id < pctrl->bank_num ; id++) { 194562306a36Sopenharmony_ci struct gpio_irq_chip *girq; 194662306a36Sopenharmony_ci 194762306a36Sopenharmony_ci girq = &pctrl->gpio_bank[id].gc.irq; 194862306a36Sopenharmony_ci gpio_irq_chip_set_chip(girq, &npcmgpio_irqchip); 194962306a36Sopenharmony_ci girq->parent_handler = npcmgpio_irq_handler; 195062306a36Sopenharmony_ci girq->num_parents = 1; 195162306a36Sopenharmony_ci girq->parents = devm_kcalloc(pctrl->dev, 1, 195262306a36Sopenharmony_ci sizeof(*girq->parents), 195362306a36Sopenharmony_ci GFP_KERNEL); 195462306a36Sopenharmony_ci if (!girq->parents) { 195562306a36Sopenharmony_ci ret = -ENOMEM; 195662306a36Sopenharmony_ci goto err_register; 195762306a36Sopenharmony_ci } 195862306a36Sopenharmony_ci girq->parents[0] = pctrl->gpio_bank[id].irq; 195962306a36Sopenharmony_ci girq->default_type = IRQ_TYPE_NONE; 196062306a36Sopenharmony_ci girq->handler = handle_level_irq; 196162306a36Sopenharmony_ci ret = devm_gpiochip_add_data(pctrl->dev, 196262306a36Sopenharmony_ci &pctrl->gpio_bank[id].gc, 196362306a36Sopenharmony_ci &pctrl->gpio_bank[id]); 196462306a36Sopenharmony_ci if (ret) { 196562306a36Sopenharmony_ci dev_err(pctrl->dev, "Failed to add GPIO chip %u\n", id); 196662306a36Sopenharmony_ci goto err_register; 196762306a36Sopenharmony_ci } 196862306a36Sopenharmony_ci 196962306a36Sopenharmony_ci ret = gpiochip_add_pin_range(&pctrl->gpio_bank[id].gc, 197062306a36Sopenharmony_ci dev_name(pctrl->dev), 197162306a36Sopenharmony_ci pctrl->gpio_bank[id].pinctrl_id, 197262306a36Sopenharmony_ci pctrl->gpio_bank[id].gc.base, 197362306a36Sopenharmony_ci pctrl->gpio_bank[id].gc.ngpio); 197462306a36Sopenharmony_ci if (ret < 0) { 197562306a36Sopenharmony_ci dev_err(pctrl->dev, "Failed to add GPIO bank %u\n", id); 197662306a36Sopenharmony_ci gpiochip_remove(&pctrl->gpio_bank[id].gc); 197762306a36Sopenharmony_ci goto err_register; 197862306a36Sopenharmony_ci } 197962306a36Sopenharmony_ci } 198062306a36Sopenharmony_ci 198162306a36Sopenharmony_ci return 0; 198262306a36Sopenharmony_ci 198362306a36Sopenharmony_cierr_register: 198462306a36Sopenharmony_ci for (; id > 0; id--) 198562306a36Sopenharmony_ci gpiochip_remove(&pctrl->gpio_bank[id - 1].gc); 198662306a36Sopenharmony_ci 198762306a36Sopenharmony_ci return ret; 198862306a36Sopenharmony_ci} 198962306a36Sopenharmony_ci 199062306a36Sopenharmony_cistatic int npcm7xx_pinctrl_probe(struct platform_device *pdev) 199162306a36Sopenharmony_ci{ 199262306a36Sopenharmony_ci struct npcm7xx_pinctrl *pctrl; 199362306a36Sopenharmony_ci int ret; 199462306a36Sopenharmony_ci 199562306a36Sopenharmony_ci pctrl = devm_kzalloc(&pdev->dev, sizeof(*pctrl), GFP_KERNEL); 199662306a36Sopenharmony_ci if (!pctrl) 199762306a36Sopenharmony_ci return -ENOMEM; 199862306a36Sopenharmony_ci 199962306a36Sopenharmony_ci pctrl->dev = &pdev->dev; 200062306a36Sopenharmony_ci dev_set_drvdata(&pdev->dev, pctrl); 200162306a36Sopenharmony_ci 200262306a36Sopenharmony_ci pctrl->gcr_regmap = 200362306a36Sopenharmony_ci syscon_regmap_lookup_by_compatible("nuvoton,npcm750-gcr"); 200462306a36Sopenharmony_ci if (IS_ERR(pctrl->gcr_regmap)) { 200562306a36Sopenharmony_ci dev_err(pctrl->dev, "didn't find nuvoton,npcm750-gcr\n"); 200662306a36Sopenharmony_ci return PTR_ERR(pctrl->gcr_regmap); 200762306a36Sopenharmony_ci } 200862306a36Sopenharmony_ci 200962306a36Sopenharmony_ci ret = npcm7xx_gpio_of(pctrl); 201062306a36Sopenharmony_ci if (ret < 0) { 201162306a36Sopenharmony_ci dev_err(pctrl->dev, "Failed to gpio dt-binding %u\n", ret); 201262306a36Sopenharmony_ci return ret; 201362306a36Sopenharmony_ci } 201462306a36Sopenharmony_ci 201562306a36Sopenharmony_ci pctrl->pctldev = devm_pinctrl_register(&pdev->dev, 201662306a36Sopenharmony_ci &npcm7xx_pinctrl_desc, pctrl); 201762306a36Sopenharmony_ci if (IS_ERR(pctrl->pctldev)) { 201862306a36Sopenharmony_ci dev_err(&pdev->dev, "Failed to register pinctrl device\n"); 201962306a36Sopenharmony_ci return PTR_ERR(pctrl->pctldev); 202062306a36Sopenharmony_ci } 202162306a36Sopenharmony_ci 202262306a36Sopenharmony_ci ret = npcm7xx_gpio_register(pctrl); 202362306a36Sopenharmony_ci if (ret < 0) { 202462306a36Sopenharmony_ci dev_err(pctrl->dev, "Failed to register gpio %u\n", ret); 202562306a36Sopenharmony_ci return ret; 202662306a36Sopenharmony_ci } 202762306a36Sopenharmony_ci 202862306a36Sopenharmony_ci pr_info("NPCM7xx Pinctrl driver probed\n"); 202962306a36Sopenharmony_ci return 0; 203062306a36Sopenharmony_ci} 203162306a36Sopenharmony_ci 203262306a36Sopenharmony_cistatic const struct of_device_id npcm7xx_pinctrl_match[] = { 203362306a36Sopenharmony_ci { .compatible = "nuvoton,npcm750-pinctrl" }, 203462306a36Sopenharmony_ci { }, 203562306a36Sopenharmony_ci}; 203662306a36Sopenharmony_ciMODULE_DEVICE_TABLE(of, npcm7xx_pinctrl_match); 203762306a36Sopenharmony_ci 203862306a36Sopenharmony_cistatic struct platform_driver npcm7xx_pinctrl_driver = { 203962306a36Sopenharmony_ci .probe = npcm7xx_pinctrl_probe, 204062306a36Sopenharmony_ci .driver = { 204162306a36Sopenharmony_ci .name = "npcm7xx-pinctrl", 204262306a36Sopenharmony_ci .of_match_table = npcm7xx_pinctrl_match, 204362306a36Sopenharmony_ci .suppress_bind_attrs = true, 204462306a36Sopenharmony_ci }, 204562306a36Sopenharmony_ci}; 204662306a36Sopenharmony_ci 204762306a36Sopenharmony_cistatic int __init npcm7xx_pinctrl_register(void) 204862306a36Sopenharmony_ci{ 204962306a36Sopenharmony_ci return platform_driver_register(&npcm7xx_pinctrl_driver); 205062306a36Sopenharmony_ci} 205162306a36Sopenharmony_ciarch_initcall(npcm7xx_pinctrl_register); 205262306a36Sopenharmony_ci 205362306a36Sopenharmony_ciMODULE_AUTHOR("jordan_hargrave@dell.com"); 205462306a36Sopenharmony_ciMODULE_AUTHOR("tomer.maimon@nuvoton.com"); 205562306a36Sopenharmony_ciMODULE_DESCRIPTION("Nuvoton NPCM7XX Pinctrl and GPIO driver"); 2056