#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>
#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 …
#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 …
#define SPMI_REGULATOR_USE_HW_DEFAULT …
enum spmi_vs_soft_start_str { … };
struct spmi_regulator_init_data { … };
enum spmi_regulator_logical_type { … };
enum spmi_regulator_type { … };
enum spmi_regulator_subtype { … };
enum spmi_common_regulator_registers { … };
enum spmi_ftsmps426_regulator_registers { … };
enum spmi_hfsmps_regulator_registers { … };
enum spmi_vs_registers { … };
enum spmi_boost_registers { … };
enum spmi_boost_byp_registers { … };
enum spmi_saw3_registers { … };
enum spmi_common_control_register_index { … };
#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 …
#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 …
#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 …
#define SPMI_COMMON_PULL_DOWN_ENABLE_MASK …
#define SPMI_LDO_CURRENT_LIMIT_ENABLE_MASK …
#define SPMI_LDO_SOFT_START_ENABLE_MASK …
#define SPMI_VS_OCP_OVERRIDE …
#define SPMI_VS_OCP_NO_OVERRIDE …
#define SPMI_VS_SOFT_START_ENABLE_MASK …
#define SPMI_VS_SOFT_START_SEL_MASK …
#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 …
#define SPMI_FTSMPS_CLOCK_RATE …
#define SPMI_FTSMPS_STEP_DELAY …
#define SPMI_DEFAULT_STEP_DELAY …
#define SPMI_FTSMPS_STEP_MARGIN_NUM …
#define SPMI_FTSMPS_STEP_MARGIN_DEN …
#define SPMI_HFSMPS_SLEW_RATE_38p4 …
#define SPMI_FTSMPS426_STEP_CTRL_DELAY_MASK …
#define SPMI_FTSMPS426_STEP_CTRL_DELAY_SHIFT …
#define SPMI_FTSMPS426_CLOCK_RATE …
#define SPMI_HFS430_CLOCK_RATE …
#define SPMI_FTSMPS426_STEP_DELAY …
#define SPMI_FTSMPS426_STEP_MARGIN_NUM …
#define SPMI_FTSMPS426_STEP_MARGIN_DEN …
#define ULT_SMPS_RANGE_SPLIT …
struct spmi_voltage_range { … };
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) …
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 = …;
#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(…) …;