linux/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2012-2014, 2016-2021 The Linux Foundation. All rights reserved.
 * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
 */

#include <linux/gpio/driver.h>
#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_irq.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/seq_file.h>
#include <linux/slab.h>
#include <linux/spmi.h>
#include <linux/types.h>

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

#include <dt-bindings/pinctrl/qcom,pmic-gpio.h>

#include "../core.h"
#include "../pinctrl-utils.h"

#define PMIC_GPIO_ADDRESS_RANGE

/* type and subtype registers base address offsets */
#define PMIC_GPIO_REG_TYPE
#define PMIC_GPIO_REG_SUBTYPE

/* GPIO peripheral type and subtype out_values */
#define PMIC_GPIO_TYPE
#define PMIC_GPIO_SUBTYPE_GPIO_4CH
#define PMIC_GPIO_SUBTYPE_GPIOC_4CH
#define PMIC_GPIO_SUBTYPE_GPIO_8CH
#define PMIC_GPIO_SUBTYPE_GPIOC_8CH
#define PMIC_GPIO_SUBTYPE_GPIO_LV
#define PMIC_GPIO_SUBTYPE_GPIO_MV
#define PMIC_GPIO_SUBTYPE_GPIO_LV_VIN2
#define PMIC_GPIO_SUBTYPE_GPIO_MV_VIN3

#define PMIC_MPP_REG_RT_STS
#define PMIC_MPP_REG_RT_STS_VAL_MASK

/* control register base address offsets */
#define PMIC_GPIO_REG_MODE_CTL
#define PMIC_GPIO_REG_DIG_VIN_CTL
#define PMIC_GPIO_REG_DIG_PULL_CTL
#define PMIC_GPIO_REG_LV_MV_DIG_OUT_SOURCE_CTL
#define PMIC_GPIO_REG_DIG_IN_CTL
#define PMIC_GPIO_REG_DIG_OUT_CTL
#define PMIC_GPIO_REG_EN_CTL
#define PMIC_GPIO_REG_LV_MV_ANA_PASS_THRU_SEL

/* PMIC_GPIO_REG_MODE_CTL */
#define PMIC_GPIO_REG_MODE_VALUE_SHIFT
#define PMIC_GPIO_REG_MODE_FUNCTION_SHIFT
#define PMIC_GPIO_REG_MODE_FUNCTION_MASK
#define PMIC_GPIO_REG_MODE_DIR_SHIFT
#define PMIC_GPIO_REG_MODE_DIR_MASK

#define PMIC_GPIO_MODE_DIGITAL_INPUT
#define PMIC_GPIO_MODE_DIGITAL_OUTPUT
#define PMIC_GPIO_MODE_DIGITAL_INPUT_OUTPUT
#define PMIC_GPIO_MODE_ANALOG_PASS_THRU
#define PMIC_GPIO_REG_LV_MV_MODE_DIR_MASK

/* PMIC_GPIO_REG_DIG_VIN_CTL */
#define PMIC_GPIO_REG_VIN_SHIFT
#define PMIC_GPIO_REG_VIN_MASK

/* PMIC_GPIO_REG_DIG_PULL_CTL */
#define PMIC_GPIO_REG_PULL_SHIFT
#define PMIC_GPIO_REG_PULL_MASK

#define PMIC_GPIO_PULL_DOWN
#define PMIC_GPIO_PULL_DISABLE

/* PMIC_GPIO_REG_LV_MV_DIG_OUT_SOURCE_CTL for LV/MV */
#define PMIC_GPIO_LV_MV_OUTPUT_INVERT
#define PMIC_GPIO_LV_MV_OUTPUT_INVERT_SHIFT
#define PMIC_GPIO_LV_MV_OUTPUT_SOURCE_SEL_MASK

/* PMIC_GPIO_REG_DIG_IN_CTL */
#define PMIC_GPIO_LV_MV_DIG_IN_DTEST_EN
#define PMIC_GPIO_LV_MV_DIG_IN_DTEST_SEL_MASK
#define PMIC_GPIO_DIG_IN_DTEST_SEL_MASK

/* PMIC_GPIO_REG_DIG_OUT_CTL */
#define PMIC_GPIO_REG_OUT_STRENGTH_SHIFT
#define PMIC_GPIO_REG_OUT_STRENGTH_MASK
#define PMIC_GPIO_REG_OUT_TYPE_SHIFT
#define PMIC_GPIO_REG_OUT_TYPE_MASK

/*
 * Output type - indicates pin should be configured as push-pull,
 * open drain or open source.
 */
#define PMIC_GPIO_OUT_BUF_CMOS
#define PMIC_GPIO_OUT_BUF_OPEN_DRAIN_NMOS
#define PMIC_GPIO_OUT_BUF_OPEN_DRAIN_PMOS

#define PMIC_GPIO_OUT_STRENGTH_LOW
#define PMIC_GPIO_OUT_STRENGTH_HIGH

/* PMIC_GPIO_REG_EN_CTL */
#define PMIC_GPIO_REG_MASTER_EN_SHIFT

#define PMIC_GPIO_PHYSICAL_OFFSET

/* PMIC_GPIO_REG_LV_MV_ANA_PASS_THRU_SEL */
#define PMIC_GPIO_LV_MV_ANA_MUX_SEL_MASK

/* Qualcomm specific pin configurations */
#define PMIC_GPIO_CONF_PULL_UP
#define PMIC_GPIO_CONF_STRENGTH
#define PMIC_GPIO_CONF_ATEST
#define PMIC_GPIO_CONF_ANALOG_PASS
#define PMIC_GPIO_CONF_DTEST_BUFFER

/* The index of each function in pmic_gpio_functions[] array */
enum pmic_gpio_func_index {};

/**
 * struct pmic_gpio_pad - keep current GPIO settings
 * @base: Address base in SPMI device.
 * @is_enabled: Set to false when GPIO should be put in high Z state.
 * @out_value: Cached pin output value
 * @have_buffer: Set to true if GPIO output could be configured in push-pull,
 *	open-drain or open-source mode.
 * @output_enabled: Set to true if GPIO output logic is enabled.
 * @input_enabled: Set to true if GPIO input buffer logic is enabled.
 * @analog_pass: Set to true if GPIO is in analog-pass-through mode.
 * @lv_mv_type: Set to true if GPIO subtype is GPIO_LV(0x10) or GPIO_MV(0x11).
 * @num_sources: Number of power-sources supported by this GPIO.
 * @power_source: Current power-source used.
 * @buffer_type: Push-pull, open-drain or open-source.
 * @pullup: Constant current which flow trough GPIO output buffer.
 * @strength: No, Low, Medium, High
 * @function: See pmic_gpio_functions[]
 * @atest: the ATEST selection for GPIO analog-pass-through mode
 * @dtest_buffer: the DTEST buffer selection for digital input mode.
 */
struct pmic_gpio_pad {};

struct pmic_gpio_state {};

static const struct pinconf_generic_params pmic_gpio_bindings[] =;

#ifdef CONFIG_DEBUG_FS
static const struct pin_config_item pmic_conf_items[ARRAY_SIZE(pmic_gpio_bindings)] =;
#endif

static const char *const pmic_gpio_groups[] =;

static const char *const pmic_gpio_functions[] =;

static int pmic_gpio_read(struct pmic_gpio_state *state,
			  struct pmic_gpio_pad *pad, unsigned int addr)
{}

static int pmic_gpio_write(struct pmic_gpio_state *state,
			   struct pmic_gpio_pad *pad, unsigned int addr,
			   unsigned int val)
{}

static int pmic_gpio_get_groups_count(struct pinctrl_dev *pctldev)
{}

static const char *pmic_gpio_get_group_name(struct pinctrl_dev *pctldev,
					    unsigned pin)
{}

static int pmic_gpio_get_group_pins(struct pinctrl_dev *pctldev, unsigned pin,
				    const unsigned **pins, unsigned *num_pins)
{}

static const struct pinctrl_ops pmic_gpio_pinctrl_ops =;

static int pmic_gpio_get_functions_count(struct pinctrl_dev *pctldev)
{}

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

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

static int pmic_gpio_set_mux(struct pinctrl_dev *pctldev, unsigned function,
				unsigned pin)
{}

static const struct pinmux_ops pmic_gpio_pinmux_ops =;

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

static int pmic_gpio_config_set(struct pinctrl_dev *pctldev, unsigned int pin,
				unsigned long *configs, unsigned nconfs)
{}

static void pmic_gpio_config_dbg_show(struct pinctrl_dev *pctldev,
				      struct seq_file *s, unsigned pin)
{}

static const struct pinconf_ops pmic_gpio_pinconf_ops =;

static int pmic_gpio_direction_input(struct gpio_chip *chip, unsigned pin)
{}

static int pmic_gpio_direction_output(struct gpio_chip *chip,
				      unsigned pin, int val)
{}

static int pmic_gpio_get(struct gpio_chip *chip, unsigned pin)
{}

static void pmic_gpio_set(struct gpio_chip *chip, unsigned pin, int value)
{}

static int pmic_gpio_of_xlate(struct gpio_chip *chip,
			      const struct of_phandle_args *gpio_desc,
			      u32 *flags)
{}

static void pmic_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
{}

static const struct gpio_chip pmic_gpio_gpio_template =;

static int pmic_gpio_populate(struct pmic_gpio_state *state,
			      struct pmic_gpio_pad *pad)
{}

static int pmic_gpio_domain_translate(struct irq_domain *domain,
				      struct irq_fwspec *fwspec,
				      unsigned long *hwirq,
				      unsigned int *type)
{}

static unsigned int pmic_gpio_child_offset_to_irq(struct gpio_chip *chip,
						  unsigned int offset)
{}

static int pmic_gpio_child_to_parent_hwirq(struct gpio_chip *chip,
					   unsigned int child_hwirq,
					   unsigned int child_type,
					   unsigned int *parent_hwirq,
					   unsigned int *parent_type)
{}

static int pmic_gpio_populate_parent_fwspec(struct gpio_chip *chip,
					    union gpio_irq_fwspec *gfwspec,
					    unsigned int parent_hwirq,
					    unsigned int parent_type)
{}

static void pmic_gpio_irq_mask(struct irq_data *data)
{}

static void pmic_gpio_irq_unmask(struct irq_data *data)
{}

static const struct irq_chip spmi_gpio_irq_chip =;

static int pmic_gpio_probe(struct platform_device *pdev)
{}

static void pmic_gpio_remove(struct platform_device *pdev)
{}

static const struct of_device_id pmic_gpio_of_match[] =;

MODULE_DEVICE_TABLE(of, pmic_gpio_of_match);

static struct platform_driver pmic_gpio_driver =;

module_platform_driver();

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