Skip to contentSkip to conversation

power: Add an axp20x-usb-power driver

PATCH RESEND Superseded Hans de Goede 3 participants 6 messages Sep 20, 2015 – Sep 22, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v4 cover power: Add an axp20x-usb-power driver

Hi,

This is a resend of v4 of the axp20x-usb-power power-supply driver, after v4 there have been no further comments, so I assume that this version is ready for merging, yet for some reason it has not been merged yet.

Can we please get this driver merged (preferably into 4.3, but if not at least lets get it into next / 4.4 asap).

Regards,

Hans

#1 lore raw

PATCH RESEND v4 1/2 ARM: dts: Add binding documentation for AXP20x pmic usb power supply

Add binding documentation for the usb power supply part of the AXP20x pmic.

---
Changes in v2:
-Split out into a separate patch from the actual driver commit Changes in v4:
-s/usb_power_supply/usb-power-supply/ in the dts example code

---
 .../bindings/power_supply/axp20x_usb_power.txt     | 34 ++++++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power_supply/axp20x_usb_power.txt
Documentation/devicetree/bindings/power_supply/axp20x_usb_power.txt new file +34 -0
new file mode 100644
index 0000000..862f4a4
@@ -0,0 +1,34 @@
+AXP20x USB power supply
+
+Required Properties:
+-compatible: "x-powers,axp202-usb-power-supply"
+
+This node is a subnode of the axp20x PMIC.
+
+Example:
+
+axp209: pmic at 34 {
+	compatible = "x-powers,axp209";
+	reg = <0x34>;
+	interrupt-parent = <&nmi_intc>;
+	interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
+	interrupt-controller;
+	#interrupt-cells = <1>;
+
+	regulators {
+		x-powers,dcdc-freq = <1500>;
+
+		vdd_cpu: dcdc2 {
+			regulator-always-on;
+			regulator-min-microvolt = <1000000>;
+			regulator-max-microvolt = <1450000>;
+			regulator-name = "vdd-cpu";
+		};
+
+		...
+	};
+
+	usb-power-supply: usb-power-supply {
+		compatible = "x-powers,axp202-usb-power-supply";
+	};
+};
Signature · 1 line
2.4.3
maintainer
#2 lore raw

PATCH RESEND v4 1/2 ARM: dts: Add binding documentation for AXP20x pmic usb power supply

Quoted 3 lines · Hans de Goede

Add binding documentation for the usb power supply part of the AXP20x pmic.

Quoted 51 lines

---
Changes in v2:
-Split out into a separate patch from the actual driver commit Changes in v4:

(quoted diff) +0 -2
-s/usb_power_supply/usb-power-supply/ in the dts example code
---
 .../bindings/power_supply/axp20x_usb_power.txt     | 34 ++++++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power_supply/axp20x_usb_power.txt
Documentation/devicetree/bindings/power_supply/axp20x_usb_power.txt new file +34 -0
new file mode 100644
index 0000000..862f4a4
@@ -0,0 +1,34 @@
+AXP20x USB power supply
+
+Required Properties:
+-compatible: "x-powers,axp202-usb-power-supply"
+
+This node is a subnode of the axp20x PMIC.
+
+Example:
+
+axp209: pmic at 34 {
+	compatible = "x-powers,axp209";
+	reg = <0x34>;
+	interrupt-parent = <&nmi_intc>;
+	interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
+	interrupt-controller;
+	#interrupt-cells = <1>;
+
+	regulators {
+		x-powers,dcdc-freq = <1500>;
+
+		vdd_cpu: dcdc2 {
+			regulator-always-on;
+			regulator-min-microvolt = <1000000>;
+			regulator-max-microvolt = <1450000>;
+			regulator-name = "vdd-cpu";
+		};
+
+		...
+	};
+
+	usb-power-supply: usb-power-supply {
+		compatible = "x-powers,axp202-usb-power-supply";
+	};
+};
#3 lore raw

PATCH RESEND v4 2/2 power: Add an axp20x-usb-power driver

In reply to Hans de Goede

This adds a driver for the usb power_supply bits of the axp20x PMICs.

I initially started writing my own driver, before coming aware of Bruno Pr?mont's excellent earlier RFC with a driver for this.

My driver was lacking CURRENT_MAX and VOLTAGE_MIN support Bruno's drvier has, so I've copied the code for those from his driver.

Note that the AC-power-supply and battery charger bits will need separate drivers. Each one needs its own devictree child-node so that other devicetree nodes can reference the right power-supply, and thus each one will get its own mfd-cell / platform_device and platform-driver.

---
Changes in v2:
-Split out the dt-bindings documentation into a separate patch -Renamed axp20x_read_16bit to axp20x_read_variable_width -Use better local variable names inside axp20x_read_variable_width Changes in v3:
-Add Bruno's S-o-b
Changes in v4:
-Check that parent drv data is not NULL
-Replace "r" local variable with a "ret" variable

---
 drivers/power/Kconfig            |   7 ++
 drivers/power/Makefile           |   1 +
 drivers/power/axp20x_usb_power.c | 248 +++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/axp20x.h       |  24 ++++
 4 files changed, 280 insertions(+)
 create mode 100644 drivers/power/axp20x_usb_power.c
drivers/power/Kconfig +7 -0
index f8758d6..914167e 100644
@@ -472,6 +472,13 @@ config CHARGER_RT9455
 	help
 	  Say Y to enable support for Richtek RT9455 battery charger.
 
+config AXP20X_POWER
+	tristate "AXP20x power supply driver"
+	depends on MFD_AXP20X
+	help
+	  This driver provides support for the power supply features of
+	  AXP20x PMIC.
+
 source "drivers/power/reset/Kconfig"
 
 endif # POWER_SUPPLY
drivers/power/Makefile +1 -0
index 5752ce8..fb4413e 100644
@@ -9,6 +9,7 @@ obj-$(CONFIG_GENERIC_ADC_BATTERY)	+= generic-adc-battery.o
 
 obj-$(CONFIG_PDA_POWER)		+= pda_power.o
 obj-$(CONFIG_APM_POWER)		+= apm_power.o
+obj-$(CONFIG_AXP20X_POWER)	+= axp20x_usb_power.o
 obj-$(CONFIG_MAX8925_POWER)	+= max8925_power.o
 obj-$(CONFIG_WM831X_BACKUP)	+= wm831x_backup.o
 obj-$(CONFIG_WM831X_POWER)	+= wm831x_power.o
drivers/power/axp20x_usb_power.c new file +248 -0

248 lines not on this page · raw message

include/linux/mfd/axp20x.h +24 -0
index cc8ad1e..b24c771 100644
@@ -11,6 +11,8 @@
 #ifndef __LINUX_MFD_AXP20X_H
 #define __LINUX_MFD_AXP20X_H
 
+#include <linux/regmap.h>
+
 enum {
 	AXP152_ID = 0,
 	AXP202_ID,
@@ -438,4 +440,26 @@ struct axp288_extcon_pdata {
 	struct gpio_desc *gpio_mux_cntl;
 };
 
+/* generic helper function for reading 9-16 bit wide regs */
+static inline int axp20x_read_variable_width(struct regmap *regmap,
+	unsigned int reg, unsigned int width)
+{
+	unsigned int reg_val, result;
+	int err;
+
+	err = regmap_read(regmap, reg, &reg_val);
+	if (err)
+		return err;
+
+	result = reg_val << (width - 8);
+
+	err = regmap_read(regmap, reg + 1, &reg_val);
+	if (err)
+		return err;
+
+	result |= reg_val;
+
+	return result;
+}
+
 #endif /* __LINUX_MFD_AXP20X_H */
Signature · 1 line
2.4.3
#4 lore raw

v4 cover power: Add an axp20x-usb-power driver

In reply to Hans de Goede

Hi,

Quoted 4 lines · Hans de Goede

This is a resend of v4 of the axp20x-usb-power power-supply driver, after v4 there have been no further comments, so I assume that this version is ready for merging, yet for some reason it has not been merged yet.

My fault. I did not have enough time before my vacation.

Quoted 1 line

Can we please get this driver merged (preferably into 4.3,

It's obviously too late now.

Quoted 1 line

but if not at least lets get it into next / 4.4 asap).

I already merged this into my (local) dev branch last week. I just pushed it out, so it should appear in next tomorrow.

-- Sebastian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150922/bdb81ddb/attachment-0001.sig>

#5 lore raw

v4 cover power: Add an axp20x-usb-power driver

Hi,

Quoted 9 lines · Sebastian Reichel

Hi,

Quoted 4 lines · Hans de Goede

This is a resend of v4 of the axp20x-usb-power power-supply driver, after v4 there have been no further comments, so I assume that this version is ready for merging, yet for some reason it has not been merged yet.

My fault. I did not have enough time before my vacation.

No problem, I was just making sure this did not fall through the cracks.

Quoted 3 lines
Quoted 1 line

Can we please get this driver merged (preferably into 4.3,

It's obviously too late now.

Ok.

Quoted 4 lines
Quoted 1 line

but if not at least lets get it into next / 4.4 asap).

I already merged this into my (local) dev branch last week. I just pushed it out, so it should appear in next tomorrow.

Great, thanks!

Regards,

Hans