linux/drivers/regulator/qcom_spmi-regulator.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2012-2015, The Linux Foundation. All rights reserved.
 */

#include <linux/module.h>
#include <linux/delay.h>
#include <linux/devm-helpers.h>
#include <linux/err.h>
#include <linux/kernel.h>
#include <linux/interrupt.h>
#include <linux/bitops.h>
#include <linux/slab.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/ktime.h>
#include <linux/regulator/driver.h>
#include <linux/regmap.h>
#include <linux/list.h>
#include <linux/mfd/syscon.h>
#include <linux/io.h>

/* Pin control enable input pins. */
#define SPMI_REGULATOR_PIN_CTRL_ENABLE_NONE
#define SPMI_REGULATOR_PIN_CTRL_ENABLE_EN0
#define SPMI_REGULATOR_PIN_CTRL_ENABLE_EN1
#define SPMI_REGULATOR_PIN_CTRL_ENABLE_EN2
#define SPMI_REGULATOR_PIN_CTRL_ENABLE_EN3
#define SPMI_REGULATOR_PIN_CTRL_ENABLE_HW_DEFAULT

/* Pin control high power mode input pins. */
#define SPMI_REGULATOR_PIN_CTRL_HPM_NONE
#define SPMI_REGULATOR_PIN_CTRL_HPM_EN0
#define SPMI_REGULATOR_PIN_CTRL_HPM_EN1
#define SPMI_REGULATOR_PIN_CTRL_HPM_EN2
#define SPMI_REGULATOR_PIN_CTRL_HPM_EN3
#define SPMI_REGULATOR_PIN_CTRL_HPM_SLEEP_B
#define SPMI_REGULATOR_PIN_CTRL_HPM_HW_DEFAULT

/*
 * Used with enable parameters to specify that hardware default register values
 * should be left unaltered.
 */
#define SPMI_REGULATOR_USE_HW_DEFAULT

/* Soft start strength of a voltage switch type regulator */
enum spmi_vs_soft_start_str {};

/**
 * struct spmi_regulator_init_data - spmi-regulator initialization data
 * @pin_ctrl_enable:        Bit mask specifying which hardware pins should be
 *				used to enable the regulator, if any
 *			    Value should be an ORing of
 *				SPMI_REGULATOR_PIN_CTRL_ENABLE_* constants.  If
 *				the bit specified by
 *				SPMI_REGULATOR_PIN_CTRL_ENABLE_HW_DEFAULT is
 *				set, then pin control enable hardware registers
 *				will not be modified.
 * @pin_ctrl_hpm:           Bit mask specifying which hardware pins should be
 *				used to force the regulator into high power
 *				mode, if any
 *			    Value should be an ORing of
 *				SPMI_REGULATOR_PIN_CTRL_HPM_* constants.  If
 *				the bit specified by
 *				SPMI_REGULATOR_PIN_CTRL_HPM_HW_DEFAULT is
 *				set, then pin control mode hardware registers
 *				will not be modified.
 * @vs_soft_start_strength: This parameter sets the soft start strength for
 *				voltage switch type regulators.  Its value
 *				should be one of SPMI_VS_SOFT_START_STR_*.  If
 *				its value is SPMI_VS_SOFT_START_STR_HW_DEFAULT,
 *				then the soft start strength will be left at its
 *				default hardware value.
 */
struct spmi_regulator_init_data {};

/* These types correspond to unique register layouts. */
enum spmi_regulator_logical_type {};

enum spmi_regulator_type {};

enum spmi_regulator_subtype {};

enum spmi_common_regulator_registers {};

/*
 * Second common register layout used by newer devices starting with ftsmps426
 * Note that some of the registers from the first common layout remain
 * unchanged and their definition is not duplicated.
 */
enum spmi_ftsmps426_regulator_registers {};

/*
 * Third common register layout
 */
enum spmi_hfsmps_regulator_registers {};

enum spmi_vs_registers {};

enum spmi_boost_registers {};

enum spmi_boost_byp_registers {};

enum spmi_saw3_registers {};

/* Used for indexing into ctrl_reg.  These are offets from 0x40 */
enum spmi_common_control_register_index {};

/* Common regulator control register layout */
#define SPMI_COMMON_ENABLE_MASK
#define SPMI_COMMON_ENABLE
#define SPMI_COMMON_DISABLE
#define SPMI_COMMON_ENABLE_FOLLOW_HW_EN3_MASK
#define SPMI_COMMON_ENABLE_FOLLOW_HW_EN2_MASK
#define SPMI_COMMON_ENABLE_FOLLOW_HW_EN1_MASK
#define SPMI_COMMON_ENABLE_FOLLOW_HW_EN0_MASK
#define SPMI_COMMON_ENABLE_FOLLOW_ALL_MASK

/* Common regulator mode register layout */
#define SPMI_COMMON_MODE_HPM_MASK
#define SPMI_COMMON_MODE_AUTO_MASK
#define SPMI_COMMON_MODE_BYPASS_MASK
#define SPMI_COMMON_MODE_FOLLOW_AWAKE_MASK
#define SPMI_COMMON_MODE_FOLLOW_HW_EN3_MASK
#define SPMI_COMMON_MODE_FOLLOW_HW_EN2_MASK
#define SPMI_COMMON_MODE_FOLLOW_HW_EN1_MASK
#define SPMI_COMMON_MODE_FOLLOW_HW_EN0_MASK
#define SPMI_COMMON_MODE_FOLLOW_ALL_MASK

#define SPMI_FTSMPS426_MODE_BYPASS_MASK
#define SPMI_FTSMPS426_MODE_RETENTION_MASK
#define SPMI_FTSMPS426_MODE_LPM_MASK
#define SPMI_FTSMPS426_MODE_AUTO_MASK
#define SPMI_FTSMPS426_MODE_HPM_MASK

#define SPMI_FTSMPS426_MODE_MASK

/* Third common regulator mode register values */
#define SPMI_HFSMPS_MODE_BYPASS_MASK
#define SPMI_HFSMPS_MODE_RETENTION_MASK
#define SPMI_HFSMPS_MODE_LPM_MASK
#define SPMI_HFSMPS_MODE_AUTO_MASK
#define SPMI_HFSMPS_MODE_HPM_MASK

#define SPMI_HFSMPS_MODE_MASK

/* Common regulator pull down control register layout */
#define SPMI_COMMON_PULL_DOWN_ENABLE_MASK

/* LDO regulator current limit control register layout */
#define SPMI_LDO_CURRENT_LIMIT_ENABLE_MASK

/* LDO regulator soft start control register layout */
#define SPMI_LDO_SOFT_START_ENABLE_MASK

/* VS regulator over current protection control register layout */
#define SPMI_VS_OCP_OVERRIDE
#define SPMI_VS_OCP_NO_OVERRIDE

/* VS regulator soft start control register layout */
#define SPMI_VS_SOFT_START_ENABLE_MASK
#define SPMI_VS_SOFT_START_SEL_MASK

/* Boost regulator current limit control register layout */
#define SPMI_BOOST_CURRENT_LIMIT_ENABLE_MASK
#define SPMI_BOOST_CURRENT_LIMIT_MASK

#define SPMI_VS_OCP_DEFAULT_MAX_RETRIES
#define SPMI_VS_OCP_DEFAULT_RETRY_DELAY_MS
#define SPMI_VS_OCP_FALL_DELAY_US
#define SPMI_VS_OCP_FAULT_DELAY_US

#define SPMI_FTSMPS_STEP_CTRL_STEP_MASK
#define SPMI_FTSMPS_STEP_CTRL_STEP_SHIFT
#define SPMI_FTSMPS_STEP_CTRL_DELAY_MASK
#define SPMI_FTSMPS_STEP_CTRL_DELAY_SHIFT

/* Clock rate in kHz of the FTSMPS regulator reference clock. */
#define SPMI_FTSMPS_CLOCK_RATE

/* Minimum voltage stepper delay for each step. */
#define SPMI_FTSMPS_STEP_DELAY
#define SPMI_DEFAULT_STEP_DELAY

/*
 * The ratio SPMI_FTSMPS_STEP_MARGIN_NUM/SPMI_FTSMPS_STEP_MARGIN_DEN is used to
 * adjust the step rate in order to account for oscillator variance.
 */
#define SPMI_FTSMPS_STEP_MARGIN_NUM
#define SPMI_FTSMPS_STEP_MARGIN_DEN

/* slew_rate has units of uV/us. */
#define SPMI_HFSMPS_SLEW_RATE_38p4

#define SPMI_FTSMPS426_STEP_CTRL_DELAY_MASK
#define SPMI_FTSMPS426_STEP_CTRL_DELAY_SHIFT

/* Clock rate in kHz of the FTSMPS426 regulator reference clock. */
#define SPMI_FTSMPS426_CLOCK_RATE

#define SPMI_HFS430_CLOCK_RATE

/* Minimum voltage stepper delay for each step. */
#define SPMI_FTSMPS426_STEP_DELAY

/*
 * The ratio SPMI_FTSMPS426_STEP_MARGIN_NUM/SPMI_FTSMPS426_STEP_MARGIN_DEN is
 * used to adjust the step rate in order to account for oscillator variance.
 */
#define SPMI_FTSMPS426_STEP_MARGIN_NUM
#define SPMI_FTSMPS426_STEP_MARGIN_DEN


/* VSET value to decide the range of ULT SMPS */
#define ULT_SMPS_RANGE_SPLIT

/**
 * struct spmi_voltage_range - regulator set point voltage mapping description
 * @min_uV:		Minimum programmable output voltage resulting from
 *			set point register value 0x00
 * @max_uV:		Maximum programmable output voltage
 * @step_uV:		Output voltage increase resulting from the set point
 *			register value increasing by 1
 * @set_point_min_uV:	Minimum allowed voltage
 * @set_point_max_uV:	Maximum allowed voltage.  This may be tweaked in order
 *			to pick which range should be used in the case of
 *			overlapping set points.
 * @n_voltages:		Number of preferred voltage set points present in this
 *			range
 * @range_sel:		Voltage range register value corresponding to this range
 *
 * The following relationships must be true for the values used in this struct:
 * (max_uV - min_uV) % step_uV == 0
 * (set_point_min_uV - min_uV) % step_uV == 0*
 * (set_point_max_uV - min_uV) % step_uV == 0*
 * n_voltages = (set_point_max_uV - set_point_min_uV) / step_uV + 1
 *
 * *Note, set_point_min_uV == set_point_max_uV == 0 is allowed in order to
 * specify that the voltage range has meaning, but is not preferred.
 */
struct spmi_voltage_range {};

/*
 * The ranges specified in the spmi_voltage_set_points struct must be listed
 * so that range[i].set_point_max_uV < range[i+1].set_point_min_uV.
 */
struct spmi_voltage_set_points {};

struct spmi_regulator {};

struct spmi_regulator_mapping {};

struct spmi_regulator_data {};

#define SPMI_VREG(_type, _subtype, _dig_major_min, _dig_major_max, \
		      _logical_type, _ops_val, _set_points_val, _hpm_min_load)

#define SPMI_VREG_VS(_subtype, _dig_major_min, _dig_major_max)

#define SPMI_VOLTAGE_RANGE(_range_sel, _min_uV, _set_point_min_uV, \
			_set_point_max_uV, _max_uV, _step_uV)

#define DEFINE_SPMI_SET_POINTS(name)

/*
 * These tables contain the physically available PMIC regulator voltage setpoint
 * ranges.  Where two ranges overlap in hardware, one of the ranges is trimmed
 * to ensure that the setpoints available to software are monotonically
 * increasing and unique.  The set_voltage callback functions expect these
 * properties to hold.
 */
static struct spmi_voltage_range pldo_ranges[] =;

static struct spmi_voltage_range nldo1_ranges[] =;

static struct spmi_voltage_range nldo2_ranges[] =;

static struct spmi_voltage_range nldo3_ranges[] =;

static struct spmi_voltage_range ln_ldo_ranges[] =;

static struct spmi_voltage_range smps_ranges[] =;

static struct spmi_voltage_range ftsmps_ranges[] =;

static struct spmi_voltage_range ftsmps2p5_ranges[] =;

static struct spmi_voltage_range ftsmps426_ranges[] =;

static struct spmi_voltage_range boost_ranges[] =;

static struct spmi_voltage_range boost_byp_ranges[] =;

static struct spmi_voltage_range ult_lo_smps_ranges[] =;

static struct spmi_voltage_range ult_ho_smps_ranges[] =;

static struct spmi_voltage_range ult_nldo_ranges[] =;

static struct spmi_voltage_range ult_pldo_ranges[] =;

static struct spmi_voltage_range pldo660_ranges[] =;

static struct spmi_voltage_range nldo660_ranges[] =;

static struct spmi_voltage_range ht_lvpldo_ranges[] =;

static struct spmi_voltage_range ht_nldo_ranges[] =;

static struct spmi_voltage_range hfs430_ranges[] =;

static struct spmi_voltage_range ht_p150_ranges[] =;

static struct spmi_voltage_range ht_p600_ranges[] =;

static struct spmi_voltage_range nldo_510_ranges[] =;

static struct spmi_voltage_range ftsmps510_ranges[] =;

static DEFINE_SPMI_SET_POINTS(pldo);
static DEFINE_SPMI_SET_POINTS(nldo1);
static DEFINE_SPMI_SET_POINTS(nldo2);
static DEFINE_SPMI_SET_POINTS(nldo3);
static DEFINE_SPMI_SET_POINTS(ln_ldo);
static DEFINE_SPMI_SET_POINTS(smps);
static DEFINE_SPMI_SET_POINTS(ftsmps);
static DEFINE_SPMI_SET_POINTS(ftsmps2p5);
static DEFINE_SPMI_SET_POINTS(ftsmps426);
static DEFINE_SPMI_SET_POINTS(boost);
static DEFINE_SPMI_SET_POINTS(boost_byp);
static DEFINE_SPMI_SET_POINTS(ult_lo_smps);
static DEFINE_SPMI_SET_POINTS(ult_ho_smps);
static DEFINE_SPMI_SET_POINTS(ult_nldo);
static DEFINE_SPMI_SET_POINTS(ult_pldo);
static DEFINE_SPMI_SET_POINTS(pldo660);
static DEFINE_SPMI_SET_POINTS(nldo660);
static DEFINE_SPMI_SET_POINTS(ht_lvpldo);
static DEFINE_SPMI_SET_POINTS(ht_nldo);
static DEFINE_SPMI_SET_POINTS(hfs430);
static DEFINE_SPMI_SET_POINTS(ht_p150);
static DEFINE_SPMI_SET_POINTS(ht_p600);
static DEFINE_SPMI_SET_POINTS(nldo_510);
static DEFINE_SPMI_SET_POINTS(ftsmps510);

static inline int spmi_vreg_read(struct spmi_regulator *vreg, u16 addr, u8 *buf,
				 int len)
{}

static inline int spmi_vreg_write(struct spmi_regulator *vreg, u16 addr,
				u8 *buf, int len)
{}

static int spmi_vreg_update_bits(struct spmi_regulator *vreg, u16 addr, u8 val,
		u8 mask)
{}

static int spmi_regulator_vs_enable(struct regulator_dev *rdev)
{}

static int spmi_regulator_vs_ocp(struct regulator_dev *rdev, int lim_uA,
				 int severity, bool enable)
{}

static int spmi_regulator_select_voltage(struct spmi_regulator *vreg,
					 int min_uV, int max_uV)
{}

static int spmi_sw_selector_to_hw(struct spmi_regulator *vreg,
				  unsigned selector, u8 *range_sel,
				  u8 *voltage_sel)
{}

static int spmi_hw_selector_to_sw(struct spmi_regulator *vreg, u8 hw_sel,
				  const struct spmi_voltage_range *range)
{}

static const struct spmi_voltage_range *
spmi_regulator_find_range(struct spmi_regulator *vreg)
{}

static int spmi_regulator_select_voltage_same_range(struct spmi_regulator *vreg,
		int min_uV, int max_uV)
{}

static int spmi_regulator_common_map_voltage(struct regulator_dev *rdev,
					     int min_uV, int max_uV)
{}

static int
spmi_regulator_common_set_voltage(struct regulator_dev *rdev, unsigned selector)
{}

static int spmi_regulator_common_list_voltage(struct regulator_dev *rdev,
					      unsigned selector);

static int spmi_regulator_ftsmps426_set_voltage(struct regulator_dev *rdev,
					      unsigned selector)
{}

static int spmi_regulator_set_voltage_time_sel(struct regulator_dev *rdev,
		unsigned int old_selector, unsigned int new_selector)
{}

static int spmi_regulator_common_get_voltage(struct regulator_dev *rdev)
{}

static int spmi_regulator_ftsmps426_get_voltage(struct regulator_dev *rdev)
{}

static int spmi_regulator_single_map_voltage(struct regulator_dev *rdev,
		int min_uV, int max_uV)
{}

static int spmi_regulator_single_range_set_voltage(struct regulator_dev *rdev,
						   unsigned selector)
{}

static int spmi_regulator_single_range_get_voltage(struct regulator_dev *rdev)
{}

static int spmi_regulator_ult_lo_smps_set_voltage(struct regulator_dev *rdev,
						  unsigned selector)
{}

static int spmi_regulator_ult_lo_smps_get_voltage(struct regulator_dev *rdev)
{}

static int spmi_regulator_common_list_voltage(struct regulator_dev *rdev,
			unsigned selector)
{}

static int
spmi_regulator_common_set_bypass(struct regulator_dev *rdev, bool enable)
{}

static int
spmi_regulator_common_get_bypass(struct regulator_dev *rdev, bool *enable)
{}

static unsigned int spmi_regulator_common_get_mode(struct regulator_dev *rdev)
{}

static unsigned int spmi_regulator_ftsmps426_get_mode(struct regulator_dev *rdev)
{}

static unsigned int spmi_regulator_hfsmps_get_mode(struct regulator_dev *rdev)
{}

static int
spmi_regulator_common_set_mode(struct regulator_dev *rdev, unsigned int mode)
{}

static int
spmi_regulator_ftsmps426_set_mode(struct regulator_dev *rdev, unsigned int mode)
{}

static int
spmi_regulator_hfsmps_set_mode(struct regulator_dev *rdev, unsigned int mode)
{}

static int
spmi_regulator_common_set_load(struct regulator_dev *rdev, int load_uA)
{}

static int spmi_regulator_common_set_pull_down(struct regulator_dev *rdev)
{}

static int spmi_regulator_hfsmps_set_pull_down(struct regulator_dev *rdev)
{}

static int spmi_regulator_common_set_soft_start(struct regulator_dev *rdev)
{}

static int spmi_regulator_set_ilim(struct regulator_dev *rdev, int ilim_uA)
{}

static int spmi_regulator_vs_clear_ocp(struct spmi_regulator *vreg)
{}

static void spmi_regulator_vs_ocp_work(struct work_struct *work)
{}

static irqreturn_t spmi_regulator_vs_ocp_isr(int irq, void *data)
{}

#define SAW3_VCTL_DATA_MASK
#define SAW3_VCTL_CLEAR_MASK
#define SAW3_AVS_CTL_EN_MASK
#define SAW3_AVS_CTL_TGGL_MASK
#define SAW3_AVS_CTL_CLEAR_MASK

static struct regmap *saw_regmap;

static void spmi_saw_set_vdd(void *data)
{}

static int
spmi_regulator_saw_set_voltage(struct regulator_dev *rdev, unsigned selector)
{}

static struct regulator_ops spmi_saw_ops =;

static const struct regulator_ops spmi_smps_ops =;

static const struct regulator_ops spmi_ldo_ops =;

static const struct regulator_ops spmi_ln_ldo_ops =;

static const struct regulator_ops spmi_vs_ops =;

static const struct regulator_ops spmi_boost_ops =;

static const struct regulator_ops spmi_ftsmps_ops =;

static const struct regulator_ops spmi_ult_lo_smps_ops =;

static const struct regulator_ops spmi_ult_ho_smps_ops =;

static const struct regulator_ops spmi_ult_ldo_ops =;

static const struct regulator_ops spmi_ftsmps426_ops =;

static const struct regulator_ops spmi_hfs430_ops =;

static const struct regulator_ops spmi_hfsmps_ops =;

/* Maximum possible digital major revision value */
#define INF

static const struct spmi_regulator_mapping supported_regulators[] =;

static void spmi_calculate_num_voltages(struct spmi_voltage_set_points *points)
{}

static int spmi_regulator_match(struct spmi_regulator *vreg, u16 force_type)
{}

static int spmi_regulator_init_slew_rate(struct spmi_regulator *vreg)
{}

static int spmi_regulator_init_slew_rate_ftsmps426(struct spmi_regulator *vreg,
						   int clock_rate)
{}

static int spmi_regulator_init_slew_rate_hfsmps(struct spmi_regulator *vreg)
{}

static int spmi_regulator_init_registers(struct spmi_regulator *vreg,
				const struct spmi_regulator_init_data *data)
{}

static void spmi_regulator_get_dt_config(struct spmi_regulator *vreg,
		struct device_node *node, struct spmi_regulator_init_data *data)
{}

static unsigned int spmi_regulator_of_map_mode(unsigned int mode)
{}

static int spmi_regulator_of_parse(struct device_node *node,
			    const struct regulator_desc *desc,
			    struct regulator_config *config)
{}

static const struct spmi_regulator_data pm6125_regulators[] =;

static const struct spmi_regulator_data pm660_regulators[] =;

static const struct spmi_regulator_data pm660l_regulators[] =;

static const struct spmi_regulator_data pm8004_regulators[] =;

static const struct spmi_regulator_data pm8005_regulators[] =;

static const struct spmi_regulator_data pm8019_regulators[] =;

static const struct spmi_regulator_data pm8226_regulators[] =;

static const struct spmi_regulator_data pm8841_regulators[] =;

static const struct spmi_regulator_data pm8909_regulators[] =;

static const struct spmi_regulator_data pm8916_regulators[] =;

static const struct spmi_regulator_data pm8937_regulators[] =;

static const struct spmi_regulator_data pm8941_regulators[] =;

static const struct spmi_regulator_data pm8950_regulators[] =;

static const struct spmi_regulator_data pm8994_regulators[] =;

static const struct spmi_regulator_data pma8084_regulators[] =;

static const struct spmi_regulator_data pmi8994_regulators[] =;

static const struct spmi_regulator_data pmp8074_regulators[] =;

static const struct spmi_regulator_data pms405_regulators[] =;

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

static int qcom_spmi_regulator_probe(struct platform_device *pdev)
{}

static struct platform_driver qcom_spmi_regulator_driver =;
module_platform_driver();

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