* [PATCH 0/3] axp20x backup battery charging @ 2017-12-30 15:23 Paul Kocialkowski 2017-12-30 15:23 ` [PATCH 1/3] dt-bindings: mfd: axp20x: Document backup battery charging property Paul Kocialkowski ` (2 more replies) 0 siblings, 3 replies; 7+ messages in thread From: Paul Kocialkowski @ 2017-12-30 15:23 UTC (permalink / raw) To: linux-arm-kernel This series introduces support for axp20x backup battery charging, with a dedicated device-tree property. I wondered whether to include this in a power-supply driver or not. Since it does not, in fact, supply power to the whole system and because no status changes over time, I thought it would be inappropriate to craft a power supply driver only for this. I also wondered whether to stick this into an existing power-supply driver, as is done by e.g. twl4030, but we have two distinct supply drivers for the axp20x (ac and usb), that may be used together or not. Also, the backup battery isn't tied to the power supply anyway. This is why I thought it would make more sense to put this in the mfd driver directly. What do you think? ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/3] dt-bindings: mfd: axp20x: Document backup battery charging property 2017-12-30 15:23 [PATCH 0/3] axp20x backup battery charging Paul Kocialkowski @ 2017-12-30 15:23 ` Paul Kocialkowski 2018-01-02 15:48 ` Lee Jones 2018-02-12 20:10 ` Pavel Machek 2017-12-30 15:23 ` [PATCH 2/3] mfd: axp20x: Add support for backup battery charging Paul Kocialkowski 2017-12-30 15:23 ` [PATCH 3/3] ARM: dts: sun7i: lamobo-r1: Add backup battery charging property Paul Kocialkowski 2 siblings, 2 replies; 7+ messages in thread From: Paul Kocialkowski @ 2017-12-30 15:23 UTC (permalink / raw) To: linux-arm-kernel This adds documentation for the "backup" property of the axp20x driver, that controls the charging mechanism for the backup battery on axp20x. Signed-off-by: Paul Kocialkowski <contact@paulk.fr> diff --git a/Documentation/devicetree/bindings/mfd/axp20x.txt b/Documentation/devicetree/bindings/mfd/axp20x.txt index 9455503b0299..382776b29932 100644 --- a/Documentation/devicetree/bindings/mfd/axp20x.txt +++ b/Documentation/devicetree/bindings/mfd/axp20x.txt @@ -58,6 +58,11 @@ Optional properties: See Documentation/devicetree/bindings/regulator/regulator.txt for more information on standard regulator bindings. +- backup: An array of two integers for backup battery charging (axp20x-only), + describing the charging voltage in mV first and the charging current + in uA second. Backup battery charging is only enabled when these two + fields are filled. + Optional properties for DCDC regulators: - x-powers,dcdc-workmode: 1 for PWM mode, 0 for AUTO (PWM/PFM) mode Default: Current hardware setting @@ -256,4 +261,6 @@ axp209: pmic at 34 { /* unused but preferred to be managed by OS */ }; }; + + backup = <3000 200>; }; -- 2.15.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 1/3] dt-bindings: mfd: axp20x: Document backup battery charging property 2017-12-30 15:23 ` [PATCH 1/3] dt-bindings: mfd: axp20x: Document backup battery charging property Paul Kocialkowski @ 2018-01-02 15:48 ` Lee Jones 2018-02-12 20:10 ` Pavel Machek 1 sibling, 0 replies; 7+ messages in thread From: Lee Jones @ 2018-01-02 15:48 UTC (permalink / raw) To: linux-arm-kernel On Sat, 30 Dec 2017, Paul Kocialkowski wrote: > This adds documentation for the "backup" property of the axp20x driver, > that controls the charging mechanism for the backup battery on axp20x. > > Signed-off-by: Paul Kocialkowski <contact@paulk.fr> > > diff --git a/Documentation/devicetree/bindings/mfd/axp20x.txt b/Documentation/devicetree/bindings/mfd/axp20x.txt > index 9455503b0299..382776b29932 100644 > --- a/Documentation/devicetree/bindings/mfd/axp20x.txt > +++ b/Documentation/devicetree/bindings/mfd/axp20x.txt > @@ -58,6 +58,11 @@ Optional properties: > See Documentation/devicetree/bindings/regulator/regulator.txt > for more information on standard regulator bindings. > > +- backup: An array of two integers for backup battery charging (axp20x-only), > + describing the charging voltage in mV first and the charging current > + in uA second. Backup battery charging is only enabled when these two > + fields are filled. > + > Optional properties for DCDC regulators: > - x-powers,dcdc-workmode: 1 for PWM mode, 0 for AUTO (PWM/PFM) mode > Default: Current hardware setting > @@ -256,4 +261,6 @@ axp209: pmic at 34 { > /* unused but preferred to be managed by OS */ > }; > }; > + > + backup = <3000 200>; It's unlikely that this will become a generic property, so you should prefix it with your vendor ID. > }; -- Lee Jones Linaro Services Technical Lead Linaro.org ? Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/3] dt-bindings: mfd: axp20x: Document backup battery charging property 2017-12-30 15:23 ` [PATCH 1/3] dt-bindings: mfd: axp20x: Document backup battery charging property Paul Kocialkowski 2018-01-02 15:48 ` Lee Jones @ 2018-02-12 20:10 ` Pavel Machek 1 sibling, 0 replies; 7+ messages in thread From: Pavel Machek @ 2018-02-12 20:10 UTC (permalink / raw) To: linux-arm-kernel Hi! > This adds documentation for the "backup" property of the axp20x driver, > that controls the charging mechanism for the backup battery on axp20x. > > Signed-off-by: Paul Kocialkowski <contact@paulk.fr> > > diff --git a/Documentation/devicetree/bindings/mfd/axp20x.txt b/Documentation/devicetree/bindings/mfd/axp20x.txt > index 9455503b0299..382776b29932 100644 > --- a/Documentation/devicetree/bindings/mfd/axp20x.txt > +++ b/Documentation/devicetree/bindings/mfd/axp20x.txt > @@ -58,6 +58,11 @@ Optional properties: > See Documentation/devicetree/bindings/regulator/regulator.txt > for more information on standard regulator bindings. > > +- backup: An array of two integers for backup battery charging (axp20x-only), > + describing the charging voltage in mV first and the charging current > + in uA second. Backup battery charging is only enabled when these two > + fields are filled. Well... We do want to charge batteries other than your backup battery. Probably this should get separate "backup battery" node with properties explaining how it is charged? Pavel -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180212/bf991805/attachment-0001.sig> ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/3] mfd: axp20x: Add support for backup battery charging 2017-12-30 15:23 [PATCH 0/3] axp20x backup battery charging Paul Kocialkowski 2017-12-30 15:23 ` [PATCH 1/3] dt-bindings: mfd: axp20x: Document backup battery charging property Paul Kocialkowski @ 2017-12-30 15:23 ` Paul Kocialkowski 2018-01-02 15:46 ` Lee Jones 2017-12-30 15:23 ` [PATCH 3/3] ARM: dts: sun7i: lamobo-r1: Add backup battery charging property Paul Kocialkowski 2 siblings, 1 reply; 7+ messages in thread From: Paul Kocialkowski @ 2017-12-30 15:23 UTC (permalink / raw) To: linux-arm-kernel This adds support for backup battery charging for axp20x PMICs, that is configured through a dedicated device-tree property. It supports 4 different charging voltages and as many charging currents. This is especially useful to allow the on-chip RTC (on the SoC side) to be powered when the rest of the system is off. Signed-off-by: Paul Kocialkowski <contact@paulk.fr> diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c index 2468b431bb22..7847f5d0b979 100644 --- a/drivers/mfd/axp20x.c +++ b/drivers/mfd/axp20x.c @@ -34,6 +34,16 @@ #define AXP806_REG_ADDR_EXT_ADDR_MASTER_MODE 0 #define AXP806_REG_ADDR_EXT_ADDR_SLAVE_MODE BIT(4) +#define AXP20X_CHRG_BAK_CTRL_ENABLE BIT(7) +#define AXP20X_CHRG_BAK_VOLTAGE_3100_MV (0 << 5) +#define AXP20X_CHRG_BAK_VOLTAGE_3000_MV (1 << 5) +#define AXP20X_CHRG_BAK_VOLTAGE_3600_MV (2 << 5) +#define AXP20X_CHRG_BAK_VOLTAGE_2500_MV (3 << 5) +#define AXP20X_CHRG_BAK_CURRENT_50_UA (0 << 0) +#define AXP20X_CHRG_BAK_CURRENT_100_UA (1 << 0) +#define AXP20X_CHRG_BAK_CURRENT_200_UA (2 << 0) +#define AXP20X_CHRG_BAK_CURRENT_400_UA (3 << 0) + static const char * const axp20x_model_names[] = { "AXP152", "AXP202", @@ -894,6 +904,63 @@ static void axp20x_power_off(void) msleep(500); } +static void axp20x_backup_setup(struct axp20x_dev *axp20x) +{ + u32 backup[2]; + int reg; + int ret; + + ret = of_property_read_u32_array(axp20x->dev->of_node, "backup", backup, + 2); + if (ret != 0) + return; + + switch (axp20x->variant) { + case AXP202_ID: + case AXP209_ID: + reg = AXP20X_CHRG_BAK_CTRL_ENABLE; + + /* Charging voltage. */ + switch (backup[0]) { + case 2500: + reg |= AXP20X_CHRG_BAK_VOLTAGE_2500_MV; + break; + case 3000: + reg |= AXP20X_CHRG_BAK_VOLTAGE_3000_MV; + break; + case 3100: + reg |= AXP20X_CHRG_BAK_VOLTAGE_3100_MV; + break; + case 3600: + reg |= AXP20X_CHRG_BAK_VOLTAGE_3600_MV; + break; + default: + return; + } + + /* Charging current. */ + switch (backup[1]) { + case 50: + reg |= AXP20X_CHRG_BAK_CURRENT_50_UA; + break; + case 100: + reg |= AXP20X_CHRG_BAK_CURRENT_100_UA; + break; + case 200: + reg |= AXP20X_CHRG_BAK_CURRENT_200_UA; + break; + case 400: + reg |= AXP20X_CHRG_BAK_CURRENT_400_UA; + break; + default: + return; + } + + regmap_write(axp20x->regmap, AXP20X_CHRG_BAK_CTRL, reg); + break; + } +} + int axp20x_match_device(struct axp20x_dev *axp20x) { struct device *dev = axp20x->dev; @@ -1023,6 +1090,9 @@ int axp20x_device_probe(struct axp20x_dev *axp20x) AXP806_REG_ADDR_EXT_ADDR_SLAVE_MODE); } + /* Backup RTC battery. */ + axp20x_backup_setup(axp20x); + ret = regmap_add_irq_chip(axp20x->regmap, axp20x->irq, IRQF_ONESHOT | IRQF_SHARED | axp20x->irq_flags, -1, axp20x->regmap_irq_chip, &axp20x->regmap_irqc); -- 2.15.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/3] mfd: axp20x: Add support for backup battery charging 2017-12-30 15:23 ` [PATCH 2/3] mfd: axp20x: Add support for backup battery charging Paul Kocialkowski @ 2018-01-02 15:46 ` Lee Jones 0 siblings, 0 replies; 7+ messages in thread From: Lee Jones @ 2018-01-02 15:46 UTC (permalink / raw) To: linux-arm-kernel On Sat, 30 Dec 2017, Paul Kocialkowski wrote: > This adds support for backup battery charging for axp20x PMICs, that is > configured through a dedicated device-tree property. > > It supports 4 different charging voltages and as many charging currents. > This is especially useful to allow the on-chip RTC (on the SoC side) to > be powered when the rest of the system is off. > > Signed-off-by: Paul Kocialkowski <contact@paulk.fr> > > diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c > index 2468b431bb22..7847f5d0b979 100644 > --- a/drivers/mfd/axp20x.c > +++ b/drivers/mfd/axp20x.c > @@ -34,6 +34,16 @@ > #define AXP806_REG_ADDR_EXT_ADDR_MASTER_MODE 0 > #define AXP806_REG_ADDR_EXT_ADDR_SLAVE_MODE BIT(4) > > +#define AXP20X_CHRG_BAK_CTRL_ENABLE BIT(7) > +#define AXP20X_CHRG_BAK_VOLTAGE_3100_MV (0 << 5) > +#define AXP20X_CHRG_BAK_VOLTAGE_3000_MV (1 << 5) > +#define AXP20X_CHRG_BAK_VOLTAGE_3600_MV (2 << 5) > +#define AXP20X_CHRG_BAK_VOLTAGE_2500_MV (3 << 5) > +#define AXP20X_CHRG_BAK_CURRENT_50_UA (0 << 0) > +#define AXP20X_CHRG_BAK_CURRENT_100_UA (1 << 0) > +#define AXP20X_CHRG_BAK_CURRENT_200_UA (2 << 0) > +#define AXP20X_CHRG_BAK_CURRENT_400_UA (3 << 0) > + > static const char * const axp20x_model_names[] = { > "AXP152", > "AXP202", > @@ -894,6 +904,63 @@ static void axp20x_power_off(void) > msleep(500); > } > > +static void axp20x_backup_setup(struct axp20x_dev *axp20x) > +{ > + u32 backup[2]; > + int reg; > + int ret; > + > + ret = of_property_read_u32_array(axp20x->dev->of_node, "backup", backup, > + 2); > + if (ret != 0) Nit: if (ret) > + return; > + > + switch (axp20x->variant) { > + case AXP202_ID: > + case AXP209_ID: Nested switch statements, hmm ... Instead, what if you either only invoked this function for supported devices, or at least returned early for non-supported ones? if (axp20x->variant != AXP202_ID && axp20x->variant != AXP209_ID) return; > + reg = AXP20X_CHRG_BAK_CTRL_ENABLE; > + > + /* Charging voltage. */ > + switch (backup[0]) { > + case 2500: > + reg |= AXP20X_CHRG_BAK_VOLTAGE_2500_MV; > + break; > + case 3000: > + reg |= AXP20X_CHRG_BAK_VOLTAGE_3000_MV; > + break; > + case 3100: > + reg |= AXP20X_CHRG_BAK_VOLTAGE_3100_MV; > + break; > + case 3600: > + reg |= AXP20X_CHRG_BAK_VOLTAGE_3600_MV; > + break; > + default: > + return; > + } > + > + /* Charging current. */ > + switch (backup[1]) { > + case 50: > + reg |= AXP20X_CHRG_BAK_CURRENT_50_UA; > + break; > + case 100: > + reg |= AXP20X_CHRG_BAK_CURRENT_100_UA; > + break; > + case 200: > + reg |= AXP20X_CHRG_BAK_CURRENT_200_UA; > + break; > + case 400: > + reg |= AXP20X_CHRG_BAK_CURRENT_400_UA; > + break; > + default: > + return; > + } > + > + regmap_write(axp20x->regmap, AXP20X_CHRG_BAK_CTRL, reg); > + break; > + } > +} > + > int axp20x_match_device(struct axp20x_dev *axp20x) > { > struct device *dev = axp20x->dev; > @@ -1023,6 +1090,9 @@ int axp20x_device_probe(struct axp20x_dev *axp20x) > AXP806_REG_ADDR_EXT_ADDR_SLAVE_MODE); > } > > + /* Backup RTC battery. */ > + axp20x_backup_setup(axp20x); > + > ret = regmap_add_irq_chip(axp20x->regmap, axp20x->irq, > IRQF_ONESHOT | IRQF_SHARED | axp20x->irq_flags, > -1, axp20x->regmap_irq_chip, &axp20x->regmap_irqc); -- Lee Jones Linaro Services Technical Lead Linaro.org ? Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 3/3] ARM: dts: sun7i: lamobo-r1: Add backup battery charging property 2017-12-30 15:23 [PATCH 0/3] axp20x backup battery charging Paul Kocialkowski 2017-12-30 15:23 ` [PATCH 1/3] dt-bindings: mfd: axp20x: Document backup battery charging property Paul Kocialkowski 2017-12-30 15:23 ` [PATCH 2/3] mfd: axp20x: Add support for backup battery charging Paul Kocialkowski @ 2017-12-30 15:23 ` Paul Kocialkowski 2 siblings, 0 replies; 7+ messages in thread From: Paul Kocialkowski @ 2017-12-30 15:23 UTC (permalink / raw) To: linux-arm-kernel This adds the axp20x backup property to the lamobo-r1 device-tree, that allows charging the backup battery attached to its AXP209. It is especially useful since the battery is used for the RTC module. Signed-off-by: Paul Kocialkowski <contact@paulk.fr> diff --git a/arch/arm/boot/dts/sun7i-a20-lamobo-r1.dts b/arch/arm/boot/dts/sun7i-a20-lamobo-r1.dts index 442f3c755f36..e218fd8ea94f 100644 --- a/arch/arm/boot/dts/sun7i-a20-lamobo-r1.dts +++ b/arch/arm/boot/dts/sun7i-a20-lamobo-r1.dts @@ -207,6 +207,8 @@ reg = <0x34>; interrupt-parent = <&nmi_intc>; interrupts = <0 IRQ_TYPE_LEVEL_LOW>; + + backup = <3000 200>; }; }; -- 2.15.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2018-02-12 20:10 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-12-30 15:23 [PATCH 0/3] axp20x backup battery charging Paul Kocialkowski 2017-12-30 15:23 ` [PATCH 1/3] dt-bindings: mfd: axp20x: Document backup battery charging property Paul Kocialkowski 2018-01-02 15:48 ` Lee Jones 2018-02-12 20:10 ` Pavel Machek 2017-12-30 15:23 ` [PATCH 2/3] mfd: axp20x: Add support for backup battery charging Paul Kocialkowski 2018-01-02 15:46 ` Lee Jones 2017-12-30 15:23 ` [PATCH 3/3] ARM: dts: sun7i: lamobo-r1: Add backup battery charging property Paul Kocialkowski
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).