Quoting Satya Priya (2022-05-11 06:18:31) > diff --git a/drivers/regulator/qcom-pm8008-regulator.c b/drivers/regulator/qcom-pm8008-regulator.c > new file mode 100644 > index 0000000..0361f02 > --- /dev/null > +++ b/drivers/regulator/qcom-pm8008-regulator.c > @@ -0,0 +1,221 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* Copyright (c) 2022, The Linux Foundation. All rights reserved. */ > + > +#include <linux/device.h> > +#include <linux/kernel.h> > +#include <linux/mfd/qcom_pm8008.h> > +#include <linux/module.h> > +#include <linux/of.h> Is this include used? > +#include <linux/of_device.h> > +#include <linux/platform_device.h> > +#include <linux/regmap.h> > +#include <linux/regulator/driver.h> > +#include <linux/regulator/of_regulator.h> Is this include used? > + > +#define VSET_STEP_MV 8 > +#define VSET_STEP_UV (VSET_STEP_MV * 1000) > + > +#define LDO_ENABLE_REG(base) ((base) + 0x46) > +#define ENABLE_BIT BIT(7) > + > +#define LDO_VSET_LB_REG(base) ((base) + 0x40) > + > +#define LDO_STEPPER_CTL_REG(base) ((base) + 0x3b) > +#define DEFAULT_VOLTAGE_STEPPER_RATE 38400 > +#define STEP_RATE_MASK GENMASK(1, 0) > + > +struct pm8008_regulator_data { > + const char *name; > + const char *supply_name; > + int min_uv; > + int max_uv; > + int min_dropout_uv; > + const struct linear_range *voltage_range; > +}; > + > +struct pm8008_regulator { > + struct device *dev; > + struct regmap *regmap; > + struct regulator_desc rdesc; > + u16 base; > + int step_rate; > + int voltage_selector; > +}; > + > +static const struct linear_range nldo_ranges[] = { > + REGULATOR_LINEAR_RANGE(528000, 0, 122, 8000), > +}; > + > +static const struct linear_range pldo_ranges[] = { > + REGULATOR_LINEAR_RANGE(1504000, 0, 237, 8000), > +}; > + > +static const struct pm8008_regulator_data reg_data[] = { > + /* name parent min_uv max_uv headroom_uv voltage_range */ > + { "ldo1", "vdd_l1_l2", 528000, 1504000, 225000, nldo_ranges, }, > + { "ldo2", "vdd_l1_l2", 528000, 1504000, 225000, nldo_ranges, }, > + { "ldo3", "vdd_l3_l4", 1504000, 3400000, 300000, pldo_ranges, }, > + { "ldo4", "vdd_l3_l4", 1504000, 3400000, 300000, pldo_ranges, }, > + { "ldo5", "vdd_l5", 1504000, 3400000, 200000, pldo_ranges, }, > + { "ldo6", "vdd_l6", 1504000, 3400000, 200000, pldo_ranges, }, > + { "ldo7", "vdd_l7", 1504000, 3400000, 200000, pldo_ranges, }, > +}; > + > +static int pm8008_regulator_get_voltage(struct regulator_dev *rdev) > +{ > + struct pm8008_regulator *pm8008_reg = rdev_get_drvdata(rdev); > + > + return pm8008_reg->voltage_selector; > +} > + > +static inline int pm8008_write_voltage(struct pm8008_regulator *pm8008_reg, > + int mV) > +{ > + __le16 vset_raw; > + > + vset_raw = cpu_to_le16(mV); > + > + return regmap_bulk_write(pm8008_reg->regmap, > + LDO_VSET_LB_REG(pm8008_reg->base), > + (const void *)&vset_raw, sizeof(vset_raw)); Does sparse complain about casting away __le16? > +} > + > +static int pm8008_regulator_set_voltage_time(struct regulator_dev *rdev, > + int old_uV, int new_uv) > +{ > + struct pm8008_regulator *pm8008_reg = rdev_get_drvdata(rdev); > + > + return DIV_ROUND_UP(abs(new_uv - old_uV), pm8008_reg->step_rate); > +} > +