linux/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c

// SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2016-2018 Nuvoton Technology corporation.
// Copyright (c) 2016, Dell Inc
// Copyright (c) 2021-2022 Jonathan Neuschäfer
//
// This driver uses the following registers:
// - Pin mux registers, in the GCR (general control registers) block
// - GPIO registers, specific to each GPIO bank
// - GPIO event (interrupt) registers, located centrally in the GPIO register
//   block, shared between all GPIO banks

#include <linux/device.h>
#include <linux/fwnode.h>
#include <linux/gpio/driver.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/mfd/syscon.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>

#include <linux/pinctrl/pinconf.h>
#include <linux/pinctrl/pinconf-generic.h>
#include <linux/pinctrl/pinctrl.h>
#include <linux/pinctrl/pinmux.h>

#include "../core.h"

/* GCR registers */
#define WPCM450_GCR_MFSEL1
#define WPCM450_GCR_MFSEL2
#define WPCM450_GCR_NONE

/* GPIO event (interrupt) registers */
#define WPCM450_GPEVTYPE
#define WPCM450_GPEVPOL
#define WPCM450_GPEVDBNC
#define WPCM450_GPEVEN
#define WPCM450_GPEVST

#define WPCM450_NUM_BANKS
#define WPCM450_NUM_GPIOS
#define WPCM450_NUM_GPIO_IRQS

struct wpcm450_pinctrl;
struct wpcm450_bank;

struct wpcm450_gpio {};

struct wpcm450_pinctrl {};

struct wpcm450_bank {};

static const struct wpcm450_bank wpcm450_banks[WPCM450_NUM_BANKS] =;

static int wpcm450_gpio_irq_bitnum(struct wpcm450_gpio *gpio, struct irq_data *d)
{}

static int wpcm450_irq_bitnum_to_gpio(struct wpcm450_gpio *gpio, int bitnum)
{}

static void wpcm450_gpio_irq_ack(struct irq_data *d)
{}

static void wpcm450_gpio_irq_mask(struct irq_data *d)
{}

static void wpcm450_gpio_irq_unmask(struct irq_data *d)
{}

/*
 * This is an implementation of the gpio_chip->get() function, for use in
 * wpcm450_gpio_fix_evpol. Unfortunately, we can't use the bgpio-provided
 * implementation there, because it would require taking gpio_chip->bgpio_lock,
 * which is a spin lock, but wpcm450_gpio_fix_evpol must work in contexts where
 * a raw spin lock is held.
 */
static int wpcm450_gpio_get(struct wpcm450_gpio *gpio, int offset)
{}

/*
 * Since the GPIO controller does not support dual-edge triggered interrupts
 * (IRQ_TYPE_EDGE_BOTH), they are emulated using rising/falling edge triggered
 * interrupts. wpcm450_gpio_fix_evpol sets the interrupt polarity for the
 * specified emulated dual-edge triggered interrupts, so that the next edge can
 * be detected.
 */
static void wpcm450_gpio_fix_evpol(struct wpcm450_gpio *gpio, unsigned long all)
{}

static int wpcm450_gpio_set_irq_type(struct irq_data *d, unsigned int flow_type)
{}

static const struct irq_chip wpcm450_gpio_irqchip =;

static void wpcm450_gpio_irqhandler(struct irq_desc *desc)
{}

static int smb0_pins[]  =;
static int smb1_pins[]  =;
static int smb2_pins[]  =;
static int smb3_pins[]  =;
static int smb4_pins[]  =;
static int smb5_pins[]  =;

static int scs1_pins[] =;
static int scs2_pins[] =;
static int scs3_pins[] =;

static int bsp_pins[] =;
static int hsp1_pins[] =;
static int hsp2_pins[] =;

static int r1err_pins[] =;
static int r1md_pins[] =;
static int rmii2_pins[] =;
static int r2err_pins[] =;
static int r2md_pins[] =;

static int kbcc_pins[] =;
static int clko_pins[] =;
static int smi_pins[] =;
static int uinc_pins[] =;
static int mben_pins[] =;

static int gspi_pins[] =;
static int sspi_pins[] =;

static int xcs1_pins[] =;
static int xcs2_pins[] =;

static int sdio_pins[] =;

static int fi0_pins[] =;
static int fi1_pins[] =;
static int fi2_pins[] =;
static int fi3_pins[] =;
static int fi4_pins[] =;
static int fi5_pins[] =;
static int fi6_pins[] =;
static int fi7_pins[] =;
static int fi8_pins[] =;
static int fi9_pins[] =;
static int fi10_pins[] =;
static int fi11_pins[] =;
static int fi12_pins[] =;
static int fi13_pins[] =;
static int fi14_pins[] =;
static int fi15_pins[] =;

static int pwm0_pins[] =;
static int pwm1_pins[] =;
static int pwm2_pins[] =;
static int pwm3_pins[] =;
static int pwm4_pins[] =;
static int pwm5_pins[] =;
static int pwm6_pins[] =;
static int pwm7_pins[] =;

static int hg0_pins[] =;
static int hg1_pins[] =;
static int hg2_pins[] =;
static int hg3_pins[] =;
static int hg4_pins[] =;
static int hg5_pins[] =;
static int hg6_pins[] =;
static int hg7_pins[] =;

#define WPCM450_GRPS \

enum {};

static const struct pingroup wpcm450_groups[] =;

#define WPCM450_SFUNC(a)
#define WPCM450_FUNC(a, b...)
#define WPCM450_MKFUNC(nm)
struct wpcm450_func {};

WPCM450_SFUNC(smb3);
WPCM450_SFUNC(smb4);
WPCM450_SFUNC(smb5);
WPCM450_SFUNC(scs1);
WPCM450_SFUNC(scs2);
WPCM450_SFUNC(scs3);
WPCM450_SFUNC(smb0);
WPCM450_SFUNC(smb1);
WPCM450_SFUNC(smb2);
WPCM450_SFUNC(bsp);
WPCM450_SFUNC(hsp1);
WPCM450_SFUNC(hsp2);
WPCM450_SFUNC(r1err);
WPCM450_SFUNC(r1md);
WPCM450_SFUNC(rmii2);
WPCM450_SFUNC(r2err);
WPCM450_SFUNC(r2md);
WPCM450_SFUNC(kbcc);
WPCM450_SFUNC(clko);
WPCM450_SFUNC(smi);
WPCM450_SFUNC(uinc);
WPCM450_SFUNC(gspi);
WPCM450_SFUNC(mben);
WPCM450_SFUNC(xcs2);
WPCM450_SFUNC(xcs1);
WPCM450_SFUNC(sdio);
WPCM450_SFUNC(sspi);
WPCM450_SFUNC(fi0);
WPCM450_SFUNC(fi1);
WPCM450_SFUNC(fi2);
WPCM450_SFUNC(fi3);
WPCM450_SFUNC(fi4);
WPCM450_SFUNC(fi5);
WPCM450_SFUNC(fi6);
WPCM450_SFUNC(fi7);
WPCM450_SFUNC(fi8);
WPCM450_SFUNC(fi9);
WPCM450_SFUNC(fi10);
WPCM450_SFUNC(fi11);
WPCM450_SFUNC(fi12);
WPCM450_SFUNC(fi13);
WPCM450_SFUNC(fi14);
WPCM450_SFUNC(fi15);
WPCM450_SFUNC(pwm0);
WPCM450_SFUNC(pwm1);
WPCM450_SFUNC(pwm2);
WPCM450_SFUNC(pwm3);
WPCM450_SFUNC(pwm4);
WPCM450_SFUNC(pwm5);
WPCM450_SFUNC(pwm6);
WPCM450_SFUNC(pwm7);
WPCM450_SFUNC(hg0);
WPCM450_SFUNC(hg1);
WPCM450_SFUNC(hg2);
WPCM450_SFUNC(hg3);
WPCM450_SFUNC(hg4);
WPCM450_SFUNC(hg5);
WPCM450_SFUNC(hg6);
WPCM450_SFUNC(hg7);

#define WPCM450_GRP
WPCM450_FUNC(gpio, WPCM450_GRPS);
#undef WPCM450_GRP

/* Function names */
static struct wpcm450_func wpcm450_funcs[] =;

#define WPCM450_PINCFG(a, b, c, d, e, f, g)

struct wpcm450_pincfg {};

/* Add this value to bit0 or bit1 to indicate that the MFSEL bit is inverted */
#define INV

static const struct wpcm450_pincfg pincfg[] =;

#define WPCM450_PIN(n)

static const struct pinctrl_pin_desc wpcm450_pins[] =;

/* Helper function to update MFSEL field according to the selected function */
static void wpcm450_update_mfsel(struct regmap *gcr_regmap, int reg, int bit, int fn, int fn_selected)
{}

/* Enable mode in pin group */
static void wpcm450_setfunc(struct regmap *gcr_regmap, const unsigned int *pin,
			    int npins, int func)
{}

static int wpcm450_get_groups_count(struct pinctrl_dev *pctldev)
{}

static const char *wpcm450_get_group_name(struct pinctrl_dev *pctldev,
					  unsigned int selector)
{}

static int wpcm450_get_group_pins(struct pinctrl_dev *pctldev,
				  unsigned int selector,
				  const unsigned int **pins,
				  unsigned int *npins)
{}

static void wpcm450_dt_free_map(struct pinctrl_dev *pctldev,
				struct pinctrl_map *map, u32 num_maps)
{}

static const struct pinctrl_ops wpcm450_pinctrl_ops =;

static int wpcm450_get_functions_count(struct pinctrl_dev *pctldev)
{}

static const char *wpcm450_get_function_name(struct pinctrl_dev *pctldev,
					     unsigned int function)
{}

static int wpcm450_get_function_groups(struct pinctrl_dev *pctldev,
				       unsigned int function,
				       const char * const **groups,
				       unsigned int * const ngroups)
{}

static int wpcm450_pinmux_set_mux(struct pinctrl_dev *pctldev,
				  unsigned int function,
				  unsigned int group)
{}

static const struct pinmux_ops wpcm450_pinmux_ops =;

static int debounce_bitnum(int gpio)
{}

static int wpcm450_config_get(struct pinctrl_dev *pctldev, unsigned int pin,
			      unsigned long *config)
{}

static int wpcm450_config_set_one(struct wpcm450_pinctrl *pctrl,
				  unsigned int pin, unsigned long config)
{}

static int wpcm450_config_set(struct pinctrl_dev *pctldev, unsigned int pin,
			      unsigned long *configs, unsigned int num_configs)
{}

static const struct pinconf_ops wpcm450_pinconf_ops =;

static struct pinctrl_desc wpcm450_pinctrl_desc =;

static int wpcm450_gpio_set_config(struct gpio_chip *chip,
				   unsigned int offset, unsigned long config)
{}

static int wpcm450_gpio_add_pin_ranges(struct gpio_chip *chip)
{}

static int wpcm450_gpio_register(struct platform_device *pdev,
				 struct wpcm450_pinctrl *pctrl)
{}

static int wpcm450_pinctrl_probe(struct platform_device *pdev)
{}

static const struct of_device_id wpcm450_pinctrl_match[] =;
MODULE_DEVICE_TABLE(of, wpcm450_pinctrl_match);

static struct platform_driver wpcm450_pinctrl_driver =;
module_platform_driver();

MODULE_LICENSE();
MODULE_AUTHOR();
MODULE_DESCRIPTION();