#include <linux/module.h>
#include <linux/slab.h>
#include <linux/i2c.h>
#include <linux/regmap.h>
#include <linux/err.h>
#include <linux/gpio/consumer.h>
#include <linux/delay.h>
#include <linux/regulator/lp872x.h>
#include <linux/regulator/driver.h>
#include <linux/platform_device.h>
#include <linux/of.h>
#include <linux/regulator/of_regulator.h>
#define LP872X_GENERAL_CFG …
#define LP872X_LDO1_VOUT …
#define LP872X_LDO2_VOUT …
#define LP872X_LDO3_VOUT …
#define LP872X_LDO4_VOUT …
#define LP872X_LDO5_VOUT …
#define LP8720_BUCK_VOUT1 …
#define LP8720_BUCK_VOUT2 …
#define LP8720_ENABLE …
#define LP8725_LILO1_VOUT …
#define LP8725_LILO2_VOUT …
#define LP8725_BUCK1_VOUT1 …
#define LP8725_BUCK1_VOUT2 …
#define LP8725_BUCK2_VOUT1 …
#define LP8725_BUCK2_VOUT2 …
#define LP8725_BUCK_CTRL …
#define LP8725_LDO_CTRL …
#define LP872X_VOUT_M …
#define LP872X_START_DELAY_M …
#define LP872X_START_DELAY_S …
#define LP872X_EN_LDO1_M …
#define LP872X_EN_LDO2_M …
#define LP872X_EN_LDO3_M …
#define LP872X_EN_LDO4_M …
#define LP872X_EN_LDO5_M …
#define LP8720_TIMESTEP_S …
#define LP8720_TIMESTEP_M …
#define LP8720_EXT_DVS_M …
#define LP8720_BUCK_FPWM_S …
#define LP8720_BUCK_FPWM_M …
#define LP8720_EN_BUCK_M …
#define LP8720_DVS_SEL_M …
#define LP8725_TIMESTEP_M …
#define LP8725_TIMESTEP_S …
#define LP8725_BUCK1_EN_M …
#define LP8725_DVS1_M …
#define LP8725_DVS2_M …
#define LP8725_BUCK2_EN_M …
#define LP8725_BUCK_CL_M …
#define LP8725_BUCK_CL_S …
#define LP8725_BUCK1_FPWM_S …
#define LP8725_BUCK1_FPWM_M …
#define LP8725_BUCK2_FPWM_S …
#define LP8725_BUCK2_FPWM_M …
#define LP8725_EN_LILO1_M …
#define LP8725_EN_LILO2_M …
#define LP872X_FORCE_PWM …
#define LP872X_AUTO_PWM …
#define LP8720_NUM_REGULATORS …
#define LP8725_NUM_REGULATORS …
#define EXTERN_DVS_USED …
#define MAX_DELAY …
#define LP8720_DEFAULT_DVS …
#define LP8725_DEFAULT_DVS …
#define MAX_REGISTERS …
enum lp872x_id { … };
struct lp872x { … };
static const unsigned int lp872x_ldo_vtbl[] = …;
static const unsigned int lp8720_ldo4_vtbl[] = …;
static const unsigned int lp8725_lilo_vtbl[] = …;
#define EXT_R …
static const unsigned int lp8720_buck_vtbl[] = …;
static const unsigned int lp8725_buck_vtbl[] = …;
static const unsigned int lp8725_buck_uA[] = …;
static int lp872x_read_byte(struct lp872x *lp, u8 addr, u8 *data)
{ … }
static inline int lp872x_write_byte(struct lp872x *lp, u8 addr, u8 data)
{ … }
static inline int lp872x_update_bits(struct lp872x *lp, u8 addr,
unsigned int mask, u8 data)
{ … }
static int lp872x_get_timestep_usec(struct lp872x *lp)
{ … }
static int lp872x_regulator_enable_time(struct regulator_dev *rdev)
{ … }
static void lp872x_set_dvs(struct lp872x *lp, enum lp872x_dvs_sel dvs_sel,
struct gpio_desc *gpio)
{ … }
static u8 lp872x_select_buck_vout_addr(struct lp872x *lp,
enum lp872x_regulator_id buck)
{ … }
static bool lp872x_is_valid_buck_addr(u8 addr)
{ … }
static int lp872x_buck_set_voltage_sel(struct regulator_dev *rdev,
unsigned selector)
{ … }
static int lp872x_buck_get_voltage_sel(struct regulator_dev *rdev)
{ … }
static int lp872x_buck_set_mode(struct regulator_dev *rdev, unsigned int mode)
{ … }
static unsigned int lp872x_buck_get_mode(struct regulator_dev *rdev)
{ … }
static const struct regulator_ops lp872x_ldo_ops = …;
static const struct regulator_ops lp8720_buck_ops = …;
static const struct regulator_ops lp8725_buck_ops = …;
static const struct regulator_desc lp8720_regulator_desc[] = …;
static const struct regulator_desc lp8725_regulator_desc[] = …;
static int lp872x_init_dvs(struct lp872x *lp)
{ … }
static int lp872x_hw_enable(struct lp872x *lp)
{ … }
static int lp872x_config(struct lp872x *lp)
{ … }
static struct regulator_init_data
*lp872x_find_regulator_init_data(int id, struct lp872x *lp)
{ … }
static int lp872x_regulator_register(struct lp872x *lp)
{ … }
static const struct regmap_config lp872x_regmap_config = …;
#ifdef CONFIG_OF
#define LP872X_VALID_OPMODE …
static struct of_regulator_match lp8720_matches[] = …;
static struct of_regulator_match lp8725_matches[] = …;
static struct lp872x_platform_data
*lp872x_populate_pdata_from_dt(struct device *dev, enum lp872x_id which)
{ … }
#else
static struct lp872x_platform_data
*lp872x_populate_pdata_from_dt(struct device *dev, enum lp872x_id which)
{
return NULL;
}
#endif
static int lp872x_probe(struct i2c_client *cl)
{ … }
static const struct of_device_id lp872x_dt_ids[] __maybe_unused = …;
MODULE_DEVICE_TABLE(of, lp872x_dt_ids);
static const struct i2c_device_id lp872x_ids[] = …;
MODULE_DEVICE_TABLE(i2c, lp872x_ids);
static struct i2c_driver lp872x_driver = …;
module_i2c_driver(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_AUTHOR(…) …;
MODULE_LICENSE(…) …;