Re: [PATCH RESEND v6 5/5] regulator: axp20x: add support for the AXP318W
Chen-Yu Tsai <[email protected]>
| Newsgroups | gmane.linux.kernel,gmane.linux.drivers.devicetree |
|---|---|
| Message-ID | <CAGb2v64HtVFWmYV5uYBN+h2S+xGM=0XrkHuRj13cG3W=nOVN1Q@mail.gmail.com> |
On Thu, Aug 13, 2026 at 5:31 AM Jerome Brunet <[email protected]> wrote: > > From: Andre Przywara <[email protected]> > > The X-Powers AXP318W is a typical PMIC from X-Powers, featuring nine > DC/DC converters and 28 LDOs, on the regulator side. > > Describe the chip's voltage settings and switch registers, how the > voltages are encoded, and connect this to the MFD device via its > regulator ID. > We use just "318" for the internal identifiers, for easier typing and > less churn. If something else other than the "AXP318W" shows up, that's > an easy change, externally visible strings carry the additional letter > already. > > Reviewed-by: Mark Brown <[email protected]> > Signed-off-by: Andre Przywara <[email protected]> > Co-developed-by: Jerome Brunet <[email protected]> > Signed-off-by: Jerome Brunet <[email protected]> > --- > drivers/regulator/axp20x-regulator.c | 324 ++++++++++++++++++++++++++++++++++- > include/linux/mfd/axp20x.h | 45 +++++ > 2 files changed, 360 insertions(+), 9 deletions(-) > > diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c > index da891415efc0..9e81e2cb7542 100644 > --- a/drivers/regulator/axp20x-regulator.c > +++ b/drivers/regulator/axp20x-regulator.c > @@ -138,6 +138,29 @@ > #define AXP313A_DCDC_V_OUT_MASK GENMASK(6, 0) > #define AXP313A_LDO_V_OUT_MASK GENMASK(4, 0) > > +#define AXP318_DCDC1_PFM_PWM_CTRL BIT(7) > +#define AXP318_DCDC23_POLYPHASE_CTRL BIT(6) > +#define AXP318_DCDC45_POLYPHASE_CTRL BIT(7) > +#define AXP318_DCDC1_V_OUT_MASK GENMASK(4, 0) > +#define AXP318_DCDC2_V_OUT_MASK GENMASK(6, 0) > +#define AXP318_LDO_V_OUT_MASK GENMASK(4, 0) > +#define AXP318_ELDO_V_OUT_MASK GENMASK(5, 0) > +#define AXP318_THRESHOLD_VOLTAGE 1540000 > +/* > + * FIXME: > + * Some LDOs of the AXP318 may be fed by different supplies and > + * the documentation repeatedly warns that output voltage must > + * be less than the supply, which is the case for any LDO really. > + * > + * The best way to let the framework handle this is to set the > + * min_dropout_uV field. However the AXP318 documentation > + * does not provide any information about this. > + * > + * Realistically, it can't be less than 1uV so use this > + * for all LDOs until we know more. > + */ > +#define AXP318_LDO_MIN_DROPOUT 1 /* uV */ > + > #define AXP717_DCDC1_NUM_VOLTAGES 88 > #define AXP717_DCDC2_NUM_VOLTAGES 107 > #define AXP717_DCDC3_NUM_VOLTAGES 103 [...] > @@ -1430,6 +1704,20 @@ static int axp20x_set_dcdc_workmode(struct regulator_dev *rdev, int id, u32 work > workmode <<= ffs(mask) - 1; > break; > > + case AXP318_ID: > + /* > + * Only DCDC1 has PWM control on the AXP318 > + * The other DCDCs control DVM through bit 7 of the related > + * registers. Work mode could possibly extended to deal with > + * this but it is not how it is documented at the moment > + */ DVM bit is for turning on / off voltage ramp rate control. It is unrelated to work mode. Please drop the comment. > + if (id != AXP318_DCDC1) > + return -EINVAL; > + reg = AXP318_DCDC1_CONTROL; > + mask = AXP318_DCDC1_PFM_PWM_CTRL; > + workmode <<= ffs(mask) - 1; > + break; > + > case AXP806_ID: > /* > * AXP806 DCDC regulator IDs have the same range as AXP22X. [...] > diff --git a/include/linux/mfd/axp20x.h b/include/linux/mfd/axp20x.h > index 0191467de4ec..251f057ea76d 100644 > --- a/include/linux/mfd/axp20x.h > +++ b/include/linux/mfd/axp20x.h > @@ -128,6 +128,7 @@ enum axp20x_variants { > #define AXP318_DCDC7_CONTROL 0x18 > #define AXP318_DCDC8_CONTROL 0x19 > #define AXP318_DCDC9_CONTROL 0x1a > +#define AXP318_DCDC_CONTROL1 0x1b This could be moved to the previous patch for completeness. [...] Once fixed, Reviewed-by: Chen-Yu Tsai <[email protected]>