Skip to contentSkip to conversation

mfd: AXP20x: Add support for AXP202 and AXP209

PATCH Superseded Carlo Caione 7 participants 34 messages Mar 15, 2014 – Mar 25, 2014

Subsystems (8)

v2 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v2 cover mfd: AXP20x: Add support for AXP202 and AXP209

AXP209 and AXP202 are the PMUs (Power Management Unit) used by A10, A13 and A20 SoCs and developed by X-Powers, a sister company of Allwinner. AXP20x comprises an adaptive USB-Compatible PWM charger, 2 BUCK DC-DC converters, 5 LDOs, multiple 12-bit ADCs of voltage, current and temperature as well as 4 configurable GPIOs.

This set of patches introduces the core driver and support for two different subsystems:
- Regulators
- PEK (Power Enable Key)

This patchset depends on patchsets:
irq: sun4i IRQ 0 / ENMI fixes (Hans de Goede)
ARM: sun7i/sun6i: irqchip: Irqchip driver for NMI controller (Carlo Caione)

Changes since v1:
- Added a new standalone patch for defconfig

- MFD core:
* Removed axp,system-power-controller property

- Bindings documentation:
* Corrected description for dcdc-workmode property
* Removed unused axp20x-pek compatible

- Input misc PEK driver:
* Fixed seconds in lower case

- Regulators subsystem:
* Fixed axp20x_set_suspend_voltage()
* Switched to using multi-bit control for regulators
* When "regulators" node is not found driver doesn't quit
* Driver is now using devm_regulator_register()
* Added module_platform_driver() instead of subsys_initcall()

- DT:
* Added new DTSI for AXP209
* Added support for cubietruck and olinuxino-micro

Carlo Caione (8):
mfd: AXP20x: Add mfd driver for AXP20x PMIC
mfd: AXP20x: Add bindings documentation
input: misc: Add driver for AXP20x Power Enable Key
input: misc: Add ABI docs for AXP20x PEK
regulator: AXP20x: Add support for regulators subsystem
ARM: sunxi: dt: Add x-powers-axp209.dtsi file
ARM: sun7i: dt: Add AXP209 support to various boards
ARM: sunxi: Add AXP20x support in defconfig

 .../ABI/testing/sysfs-driver-input-axp-pek         |  11 +
 Documentation/devicetree/bindings/mfd/axp20x.txt   |  83 ++++++
 .../devicetree/bindings/vendor-prefixes.txt        |   1 +
 arch/arm/boot/dts/sun7i-a20-cubieboard2.dts        |  12 +
 arch/arm/boot/dts/sun7i-a20-cubietruck.dts         |  13 +
 arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts    |  12 +
 arch/arm/boot/dts/x-powers-axp209.dtsi             |  60 +++++
 arch/arm/configs/sunxi_defconfig                   |   4 +
 drivers/input/misc/Kconfig                         |  11 +
 drivers/input/misc/Makefile                        |   1 +
 drivers/input/misc/axp20x-pek.c                    | 267 +++++++++++++++++++
 drivers/mfd/Kconfig                                |  12 +
 drivers/mfd/Makefile                               |   1 +
 drivers/mfd/axp20x.c                               | 247 +++++++++++++++++
 drivers/regulator/Kconfig                          |   7 +
 drivers/regulator/Makefile                         |   1 +
 drivers/regulator/axp20x-regulator.c               | 293 +++++++++++++++++++++
 include/linux/mfd/axp20x.h                         | 179 +++++++++++++
 18 files changed, 1215 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-driver-input-axp-pek
 create mode 100644 Documentation/devicetree/bindings/mfd/axp20x.txt
 create mode 100644 arch/arm/boot/dts/x-powers-axp209.dtsi
 create mode 100644 drivers/input/misc/axp20x-pek.c
 create mode 100644 drivers/mfd/axp20x.c
 create mode 100644 drivers/regulator/axp20x-regulator.c
 create mode 100644 include/linux/mfd/axp20x.h
Signature · 1 line
1.8.3.2
#1 lore raw

PATCH v2 1/8 mfd: AXP20x: Add mfd driver for AXP20x PMIC

This patch introduces the preliminary support for PMICs X-Powers AXP202 and AXP209. The AXP209 and AXP202 are the PMUs (Power Management Unit) used by A10, A13 and A20 SoCs and developed by X-Powers, a sister company of Allwinner.

The core enables support for two subsystems:
- PEK (Power Enable Key)
- Regulators

---
 drivers/mfd/Kconfig        |  12 +++
 drivers/mfd/Makefile       |   1 +
 drivers/mfd/axp20x.c       | 247 +++++++++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/axp20x.h | 179 ++++++++++++++++++++++++++++++++
 4 files changed, 439 insertions(+)
 create mode 100644 drivers/mfd/axp20x.c
 create mode 100644 include/linux/mfd/axp20x.h
drivers/mfd/Kconfig +12 -0
index 49bb445..24ba61a 100644
@@ -59,6 +59,18 @@ config MFD_AAT2870_CORE
 	  additional drivers must be enabled in order to use the
 	  functionality of the device.
 
+config MFD_AXP20X
+	bool "X-Powers AXP20X"
+	select MFD_CORE
+	select REGMAP_I2C
+	select REGMAP_IRQ
+	depends on I2C=y
+	help
+	  If you say Y here you get support for the AXP20X.
+	  This driver provides common support for accessing the device,
+	  additional drivers must be enabled in order to use the
+	  functionality of the device.
+
 config MFD_CROS_EC
 	tristate "ChromeOS Embedded Controller"
 	select MFD_CORE
drivers/mfd/Makefile +1 -0
index 5aea5ef..fb773b5 100644
@@ -101,6 +101,7 @@ obj-$(CONFIG_PMIC_DA9052)	+= da9052-irq.o
 obj-$(CONFIG_PMIC_DA9052)	+= da9052-core.o
 obj-$(CONFIG_MFD_DA9052_SPI)	+= da9052-spi.o
 obj-$(CONFIG_MFD_DA9052_I2C)	+= da9052-i2c.o
+obj-$(CONFIG_MFD_AXP20X)	+= axp20x.o
 
 obj-$(CONFIG_MFD_LP3943)	+= lp3943.o
 obj-$(CONFIG_MFD_LP8788)	+= lp8788.o lp8788-irq.o
drivers/mfd/axp20x.c new file +247 -0

247 lines not on this page · raw message

include/linux/mfd/axp20x.h new file +179 -0

179 lines not on this page · raw message

Signature · 1 line
1.8.3.2
#2 lore raw

PATCH v2 1/8 mfd: AXP20x: Add mfd driver for AXP20x PMIC

Quoted 18 lines

This patch introduces the preliminary support for PMICs X-Powers AXP202 and AXP209. The AXP209 and AXP202 are the PMUs (Power Management Unit) used by A10, A13 and A20 SoCs and developed by X-Powers, a sister company of Allwinner.

The core enables support for two subsystems:
- PEK (Power Enable Key)
- Regulators

---
 drivers/mfd/Kconfig        |  12 +++
 drivers/mfd/Makefile       |   1 +
 drivers/mfd/axp20x.c       | 247 +++++++++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/axp20x.h | 179 ++++++++++++++++++++++++++++++++
 4 files changed, 439 insertions(+)
 create mode 100644 drivers/mfd/axp20x.c
 create mode 100644 include/linux/mfd/axp20x.h

[...]

Quoted 2 lines

+/*
+ * axp20x.c - mfd core driver for the X-Powers AXP202 and AXP209

MFD

[...]

Quoted 14 lines
drivers/mfd/axp20x.c new file +14 -0
+static struct resource axp20x_pek_resources[] = {
+	{
+		.name	= "PEK_DBR",
+		.start	= AXP20X_IRQ_PEK_RIS_EDGE,
+		.end	= AXP20X_IRQ_PEK_RIS_EDGE,
+		.flags	= IORESOURCE_IRQ,
+	},
+	{
+		.name	= "PEK_DBF",
+		.start	= AXP20X_IRQ_PEK_FAL_EDGE,
+		.end	= AXP20X_IRQ_PEK_FAL_EDGE,
+		.flags	= IORESOURCE_IRQ,
+	},
+};

[...]

drivers/mfd/axp20x.c line 133

Quoted 9 lines
drivers/mfd/axp20x.c new file +9 -0
+static struct mfd_cell axp20x_cells[] = {
+	{
+		.name		= "axp20x-pek",
+		.num_resources	= ARRAY_SIZE(axp20x_pek_resources),
+		.resources	= axp20x_pek_resources,
+	}, {
+		.name		= "axp20x-regulator",
+	},
+};

nit: The format of these two structs are inconsistent.

[...]

Quoted 7 lines
drivers/mfd/axp20x.c new file +7 -0
+static int axp20x_i2c_probe(struct i2c_client *i2c,
+			 const struct i2c_device_id *id)
+{
+	struct axp20x_dev *axp20x;
+	const struct of_device_id *of_id;
+	int ret;
+

drivers/mfd/axp20x.c line 164

Quoted 10 lines
drivers/mfd/axp20x.c new file +10 -0
+	axp20x = devm_kzalloc(&i2c->dev, sizeof(*axp20x), GFP_KERNEL);
+	if (!axp20x)
+		return -ENOMEM;
+
+	of_id = of_match_device(axp20x_of_match, &i2c->dev);
+	if (!of_id) {
+		dev_err(&i2c->dev, "Unable to setup AXP20X data\n");
+		return -ENODEV;
+	}
+	axp20x->variant = (int) of_id->data;

No need to cast from void *.

drivers/mfd/axp20x.c line 177

Quoted 12 lines
drivers/mfd/axp20x.c new file +12 -0
+	axp20x->i2c_client = i2c;
+	axp20x->dev = &i2c->dev;
+	dev_set_drvdata(axp20x->dev, axp20x);
+
+	axp20x->regmap = devm_regmap_init_i2c(i2c, &axp20x_regmap_config);
+	if (IS_ERR(axp20x->regmap)) {
+		ret = PTR_ERR(axp20x->regmap);
+		dev_err(&i2c->dev, "regmap init failed: %d\n", ret);
+		return ret;
+	}
+
+	axp20x->irq = i2c->irq;

Do you _really_ need this if you have 'axp20x->i2c_client->irq'?

Quoted 20 lines
drivers/mfd/axp20x.c new file +20 -0
+	ret = regmap_add_irq_chip(axp20x->regmap, axp20x->irq,
+				  IRQF_ONESHOT | IRQF_SHARED, -1,
+				  &axp20x_regmap_irq_chip,
+				  &axp20x->regmap_irqc);
+	if (ret) {
+		dev_err(&i2c->dev, "failed to add irq chip: %d\n", ret);
+		return ret;
+	}
+
+	ret = mfd_add_devices(axp20x->dev, -1, axp20x_cells,
+			      ARRAY_SIZE(axp20x_cells), NULL, 0, NULL);
+
+	if (ret) {
+		dev_err(&i2c->dev, "failed to add MFD devices: %d\n", ret);
+		goto mfd_err;
+	}
+
+	if (!pm_power_off) {
+		axp20x_pm_power_off = axp20x;
+		pm_power_off = axp20x_power_off;

drivers/mfd/axp20x.c line 207

Quoted 10 lines
drivers/mfd/axp20x.c new file +10 -0
+	}
+
+	dev_info(&i2c->dev, "AXP20X driver loaded\n");
+
+	return 0;
+
+mfd_err:
+	regmap_del_irq_chip(axp20x->irq, axp20x->regmap_irqc);
+
+	return ret;

I'd say the goto is pointless if you're only using it once.

Instead move regmap_del_irq_chip() into mfd_add_devices()'s error handler and return straight from there.

[...]

drivers/mfd/axp20x.c line 230

Quoted 6 lines
drivers/mfd/axp20x.c new file +6 -0
+static const struct i2c_device_id axp20x_i2c_id[] = {
+	{ "axp202", AXP202_ID },
+	{ "axp209", AXP209_ID },
+	{ }
+};
+MODULE_DEVICE_TABLE(i2c, axp20x_i2c_id);

Isn't this redundant now that you're using of_id?

[...]

include/linux/mfd/axp20x.h line 15

Quoted 5 lines
include/linux/mfd/axp20x.h new file +5 -0
+#ifndef __LINUX_MFD_AXP20X_H
+#define __LINUX_MFD_AXP20X_H
+
+#define AXP202_ID			0
+#define AXP209_ID			1

enum?

[...]

include/linux/mfd/axp20x.h line 176

Quoted 7 lines
include/linux/mfd/axp20x.h new file +7 -0
+struct axp20x_dev {
+	struct device			*dev;
+	struct i2c_client		*i2c_client;
+	struct regmap			*regmap;
+	struct regmap_irq_chip_data	*regmap_irqc;
+	int				variant;
+	int				irq;

i2c_client->irq?

Quoted 3 lines
include/linux/mfd/axp20x.h new file +3 -0
+};
+
+#endif /* __LINUX_MFD_AXP20X_H */
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#3 lore raw

[linux-sunxi] Re: [PATCH v2 1/8] mfd: AXP20x: Add mfd driver for AXP20x PMIC

Quoted 11 lines · Lee Jones

drivers/mfd/axp20x.c line 133

Quoted 9 lines
drivers/mfd/axp20x.c new file +9 -0
+static struct mfd_cell axp20x_cells[] = {
+	{
+		.name		= "axp20x-pek",
+		.num_resources	= ARRAY_SIZE(axp20x_pek_resources),
+		.resources	= axp20x_pek_resources,
+	}, {
+		.name		= "axp20x-regulator",
+	},
+};

nit: The format of these two structs are inconsistent.

Uhm, what do you mean?

Quoted 11 lines
Quoted 11 lines
drivers/mfd/axp20x.c new file +11 -0
+static int axp20x_i2c_probe(struct i2c_client *i2c,
+			 const struct i2c_device_id *id)
+{
+	struct axp20x_dev *axp20x;
+	const struct of_device_id *of_id;
+	int ret;
+
+	axp20x = devm_kzalloc(&i2c->dev, sizeof(*axp20x), GFP_KERNEL);
+	if (!axp20x)
+		return -ENOMEM;
+
Quoted 8 lines

drivers/mfd/axp20x.c line 164

Quoted 6 lines
drivers/mfd/axp20x.c new file +6 -0
+	of_id = of_match_device(axp20x_of_match, &i2c->dev);
+	if (!of_id) {
+		dev_err(&i2c->dev, "Unable to setup AXP20X data\n");
+		return -ENODEV;
+	}
+	axp20x->variant = (int) of_id->data;

No need to cast from void *.

My compiler says otherwise :)

Quoted 10 lines

[...]

drivers/mfd/axp20x.c line 230

Quoted 6 lines
drivers/mfd/axp20x.c new file +6 -0
+static const struct i2c_device_id axp20x_i2c_id[] = {
+	{ "axp202", AXP202_ID },
+	{ "axp209", AXP209_ID },
+	{ }
+};
+MODULE_DEVICE_TABLE(i2c, axp20x_i2c_id);

Isn't this redundant now that you're using of_id?

It is not. Even it is unused it has to be in the driver otherwise the driver is not loaded. Probably it is something wrong in the I2C core.

Best,

Signature · 1 line
Carlo Caione
maintainer
#4 lore raw

[linux-sunxi] Re: [PATCH v2 1/8] mfd: AXP20x: Add mfd driver for AXP20x PMIC

Quoted 11 lines · Carlo Caione
Quoted 8 lines · Lee Jones

drivers/mfd/axp20x.c line 164

Quoted 6 lines
drivers/mfd/axp20x.c new file +6 -0
+	of_id = of_match_device(axp20x_of_match, &i2c->dev);
+	if (!of_id) {
+		dev_err(&i2c->dev, "Unable to setup AXP20X data\n");
+		return -ENODEV;
+	}
+	axp20x->variant = (int) of_id->data;

No need to cast from void *.

Quoted 1 line

My compiler says otherwise :)

Are you sure your compiler isn't correctly telling you not to cast away
const? If the compiler is complaining about a cast on void then it's
spotted a definite bug.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140322/634fefa6/attachment.sig>

#5 lore raw

[linux-sunxi] Re: [PATCH v2 1/8] mfd: AXP20x: Add mfd driver for AXP20x PMIC

Quoted 10 lines · Mark Brown
Quoted 8 lines · Carlo Caione
Quoted 6 lines · Lee Jones
Quoted 6 lines

+ of_id = of_match_device(axp20x_of_match, &i2c->dev);
+ if (!of_id) {

drivers/mfd/axp20x.c new file +4 -0
+         dev_err(&i2c->dev, "Unable to setup AXP20X data\n");
+         return -ENODEV;
+ }
+ axp20x->variant = (int) of_id->data;
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

No need to cast from void *.

My compiler says otherwise :)

Are you sure your compiler isn't correctly telling you not to cast away const? If the compiler is complaining about a cast on void then it's spotted a definite bug.

drivers/mfd/axp20x.c:172:18: warning: assignment makes integer from pointer without a cast [enabled by default]

Signature · 1 line
Carlo Caione
#6 lore raw

[linux-sunxi] Re: [PATCH v2 1/8] mfd: AXP20x: Add mfd driver for AXP20x PMIC

In reply to Mark Brown
Quoted 10 lines · Mark Brown
Quoted 8 lines · Carlo Caione
Quoted 6 lines · Lee Jones
Quoted 6 lines

+ of_id = of_match_device(axp20x_of_match, &i2c->dev);
+ if (!of_id) {

drivers/mfd/axp20x.c new file +4 -0
+         dev_err(&i2c->dev, "Unable to setup AXP20X data\n");
+         return -ENODEV;
+ }
+ axp20x->variant = (int) of_id->data;
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

No need to cast from void *.

My compiler says otherwise :)

Are you sure your compiler isn't correctly telling you not to cast away const? If the compiler is complaining about a cast on void then it's spotted a definite bug.

[resend since gmail decided to not put broonie in CC]

drivers/mfd/axp20x.c:172:18: warning: assignment makes integer frompointer without a cast [enabled by default]

Signature · 1 line
Carlo Caione
maintainer
#7 lore raw

[linux-sunxi] Re: [PATCH v2 1/8] mfd: AXP20x: Add mfd driver for AXP20x PMIC

Quoted 15 lines · Carlo Caione
Quoted 14 lines · Mark Brown
Quoted 12 lines · Carlo Caione
Quoted 8 lines · Lee Jones

drivers/mfd/axp20x.c line 164

Quoted 6 lines

+ of_id = of_match_device(axp20x_of_match, &i2c->dev);
+ if (!of_id) {

drivers/mfd/axp20x.c new file +4 -0
+         dev_err(&i2c->dev, "Unable to setup AXP20X data\n");
+         return -ENODEV;
+ }
+ axp20x->variant = (int) of_id->data;

No need to cast from void *.

My compiler says otherwise :)

Quoted 8 lines
Quoted 3 lines

Are you sure your compiler isn't correctly telling you not to cast away const? If the compiler is complaining about a cast on void then it's spotted a definite bug.

[resend since gmail decided to not put broonie in CC]

drivers/mfd/axp20x.c:172:18: warning: assignment makes integer frompointer without a cast [enabled by default]

You need to cast to long, otherwise you will get warnings when compiling on 64 bit arches.

Thanks.

Signature · 1 line
Dmitry
#8 lore raw

[linux-sunxi] Re: [PATCH v2 1/8] mfd: AXP20x: Add mfd driver for AXP20x PMIC

Quoted 20 lines · Dmitry Torokhov
Quoted 19 lines · Carlo Caione
Quoted 17 lines · Mark Brown
Quoted 9 lines · Carlo Caione
Quoted 6 lines · Lee Jones
Quoted 6 lines

+ of_id = of_match_device(axp20x_of_match, &i2c->dev);
+ if (!of_id) {

drivers/mfd/axp20x.c new file +4 -0
+         dev_err(&i2c->dev, "Unable to setup AXP20X data\n");
+         return -ENODEV;
+ }
+ axp20x->variant = (int) of_id->data;
Quoted 3 lines
Quoted 1 line

No need to cast from void *.

My compiler says otherwise :)

Are you sure your compiler isn't correctly telling you not to cast away const? If the compiler is complaining about a cast on void then it's spotted a definite bug.

Quoted 7 lines
Quoted 4 lines

[resend since gmail decided to not put broonie in CC]

drivers/mfd/axp20x.c:172:18: warning: assignment makes integer frompointer without a cast [enabled by default]

You need to cast to long, otherwise you will get warnings when compiling on 64 bit arches.

Actually no warning also with (int) cast.

Signature · 1 line
Carlo Caione
maintainer
#9 lore raw

[linux-sunxi] Re: [PATCH v2 1/8] mfd: AXP20x: Add mfd driver for AXP20x PMIC

Quoted 9 lines · Carlo Caione
Quoted 5 lines · Dmitry Torokhov
Quoted 2 lines

drivers/mfd/axp20x.c:172:18: warning: assignment makes integer frompointer without a cast [enabled by default]

You need to cast to long, otherwise you will get warnings when compiling on 64 bit arches.

Actually no warning also with (int) cast.

That's because you squashed it to something smaller than a long using
the cast. The other option is to make the variable you're assigning to
suitable to hold the value - intptr_t or a long.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140322/736dbead/attachment.sig>

#10 lore raw

[linux-sunxi] Re: [PATCH v2 1/8] mfd: AXP20x: Add mfd driver for AXP20x PMIC

In reply to Carlo Caione
Quoted 12 lines
Quoted 11 lines

drivers/mfd/axp20x.c line 133

Quoted 9 lines
drivers/mfd/axp20x.c new file +9 -0
+static struct mfd_cell axp20x_cells[] = {
+	{
+		.name		= "axp20x-pek",
+		.num_resources	= ARRAY_SIZE(axp20x_pek_resources),
+		.resources	= axp20x_pek_resources,
+	}, {
+		.name		= "axp20x-regulator",
+	},
+};

nit: The format of these two structs are inconsistent.

Quoted 1 line

Uhm, what do you mean?

Well you've removed the struct above this one in your reply. Take a look at my reply to you and see the differences between this _two_ structs, this being only one of them.

[...]

Quoted 11 lines
Quoted 8 lines

drivers/mfd/axp20x.c line 230

Quoted 6 lines
drivers/mfd/axp20x.c new file +6 -0
+static const struct i2c_device_id axp20x_i2c_id[] = {
+	{ "axp202", AXP202_ID },
+	{ "axp209", AXP209_ID },
+	{ }
+};
+MODULE_DEVICE_TABLE(i2c, axp20x_i2c_id);

Isn't this redundant now that you're using of_id?

It is not. Even it is unused it has to be in the driver otherwise the driver is not loaded. Probably it is something wrong in the I2C core.

Sorry, I should have been more specific. The I2C core requires this struct, but the IDs are unused and redundant. Best remove them in order to mitigate any confusion.

Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#11 lore raw

PATCH v2 2/8 mfd: AXP20x: Add bindings documentation

In reply to Carlo Caione

Bindings documentation for the AXP20x driver. In this file also two sub-nodes (PEK and regulators) are documented.

---
 Documentation/devicetree/bindings/mfd/axp20x.txt   | 83 ++++++++++++++++++++++
 .../devicetree/bindings/vendor-prefixes.txt        |  1 +
 2 files changed, 84 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/axp20x.txt
Documentation/devicetree/bindings/mfd/axp20x.txt new file +83 -0
new file mode 100644
index 0000000..982aefe
@@ -0,0 +1,83 @@
+* axp20x device tree bindings
+
+The axp20x family current members :-
+axp202 (X-Powers)
+axp209 (X-Powers)
+
+Required properties:
+- compatible 			: Should be "x-powers,axp202" or "x-powers,axp209"
+- interrupt-controller 		: axp20x has its own internal IRQs
+- #interrupt-cells 		: Should be set to 1
+- interrupt-parent 		: The parent interrupt controller
+- interrupts 			: Interrupt specifiers for interrupt sources
+- reg 				: The I2C slave address for the AXP chip
+
+Sub-nodes:
+* regulators : Contain the regulator nodes. The regulators are bound using
+	       their name as listed here: dcdc2, dcdc3, ldo1, ldo2, ldo3,
+	       ldo4, ldo5.
+	       The bindings details of individual regulator device can be found in:
+	       Documentation/devicetree/bindings/regulator/regulator.txt with the
+	       exception of:
+
+	- dcdc-freq		: defines the work frequency of DC-DC in KHz
+				  (range: 750-1875). Default: 1.5MHz
+	- dcdc-workmode		: Optional. 1 for PWM mode, 0 for AUTO mode
+				  Default: AUTO mode
+
+Example:
+
+axp: axp20x at 34 {
+	reg = <0x34>;
+	interrupt-parent = <&nmi_intc>;
+	interrupts = <0 8>;
+
+	compatible = "x-powers,axp209";
+	interrupt-controller;
+	#interrupt-cells = <1>;
+
+	regulators {
+		dcdc-freq = "1500";
+
+		axp_dcdc2: dcdc2 {
+			regulator-min-microvolt = <700000>;
+			regulator-max-microvolt = <2275000>;
+			dcdc-workmode = <0>;
+			regulator-always-on;
+		};
+
+		axp_dcdc3: dcdc3 {
+			regulator-min-microvolt = <700000>;
+			regulator-max-microvolt = <3500000>;
+			dcdc-workmode = <0>;
+			regulator-always-on;
+		};
+
+		axp_ldo1: ldo1 {
+			regulator-min-microvolt = <1300000>;
+			regulator-max-microvolt = <1300000>;
+		};
+
+		axp_ldo2: ldo2 {
+			regulator-min-microvolt = <1800000>;
+			regulator-max-microvolt = <3300000>;
+			regulator-always-on;
+		};
+
+		axp_ldo3: ldo3 {
+			regulator-min-microvolt = <700000>;
+			regulator-max-microvolt = <3500000>;
+		};
+
+		axp_ldo4: ldo4 {
+			regulator-min-microvolt = <1250000>;
+			regulator-max-microvolt = <3300000>;
+		};
+
+		axp_ldo5: ldo5 {
+			regulator-min-microvolt = <1800000>;
+			regulator-max-microvolt = <3300000>;
+		};
+	};
+};
+
Documentation/devicetree/bindings/vendor-prefixes.txt +1 -0
index 40ce2df..d06ba8c 100644
@@ -95,3 +95,4 @@ winbond Winbond Electronics corp.
 wlf	Wolfson Microelectronics
 wm	Wondermedia Technologies, Inc.
 xlnx	Xilinx
+x-powers	X-Powers
Signature · 1 line
1.8.3.2
#12 lore raw

PATCH v2 2/8 mfd: AXP20x: Add bindings documentation

Quoted 2 lines · Carlo Caione

Bindings documentation for the AXP20x driver. In this file also two sub-nodes (PEK and regulators) are documented.

PEK doesn't look to be documented, either in this patch, or any other.

Quoted 4 lines
---
 Documentation/devicetree/bindings/mfd/axp20x.txt   | 83 ++++++++++++++++++++++
 .../devicetree/bindings/vendor-prefixes.txt        |  1 +

I don't really know what the DT maintainers are expecting here, but I would have done two patches.

Quoted 25 lines
 2 files changed, 84 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/axp20x.txt
Documentation/devicetree/bindings/mfd/axp20x.txt new file +16 -0
new file mode 100644
index 0000000..982aefe
@@ -0,0 +1,83 @@
+* axp20x device tree bindings
+
+The axp20x family current members :-
+axp202 (X-Powers)
+axp209 (X-Powers)
+
+Required properties:
+- compatible 			: Should be "x-powers,axp202" or "x-powers,axp209"
+- interrupt-controller 		: axp20x has its own internal IRQs
+- #interrupt-cells 		: Should be set to 1
+- interrupt-parent 		: The parent interrupt controller
+- interrupts 			: Interrupt specifiers for interrupt sources
+- reg 				: The I2C slave address for the AXP chip
+
+Sub-nodes:
+* regulators : Contain the regulator nodes. The regulators are bound using

Documentation/devicetree/bindings/mfd/axp20x.txt line 26

Quoted 10 lines
Documentation/devicetree/bindings/mfd/axp20x.txt new file +10 -0
+	       their name as listed here: dcdc2, dcdc3, ldo1, ldo2, ldo3,
+	       ldo4, ldo5.
+	       The bindings details of individual regulator device can be found in:
+	       Documentation/devicetree/bindings/regulator/regulator.txt with the
+	       exception of:
+
+	- dcdc-freq		: defines the work frequency of DC-DC in KHz
+				  (range: 750-1875). Default: 1.5MHz
+	- dcdc-workmode		: Optional. 1 for PWM mode, 0 for AUTO mode
+				  Default: AUTO mode

Those two are x-powers specific, or would it make sense to have them in other drivers too?

If the former, please add the x-powers prefix.

Documentation/devicetree/bindings/mfd/axp20x.txt line 39

Quoted 13 lines
Documentation/devicetree/bindings/mfd/axp20x.txt new file +13 -0
+
+Example:
+
+axp: axp20x at 34 {
+	reg = <0x34>;
+	interrupt-parent = <&nmi_intc>;
+	interrupts = <0 8>;
+
+	compatible = "x-powers,axp209";
+	interrupt-controller;
+	#interrupt-cells = <1>;
+
+	regulators {

Do we really need that subnode ? it looks useless, and we already know that we are defining regulators here.

Documentation/devicetree/bindings/mfd/axp20x.txt line 40

Quoted 1 line
Documentation/devicetree/bindings/mfd/axp20x.txt new file +1 -0
+		dcdc-freq = "1500";

That frequency is defined at the same level than the dcdc-workmode property, yet they both seem to be placed at different levels.

Documentation/devicetree/bindings/mfd/axp20x.txt line 52

Quoted 12 lines
Documentation/devicetree/bindings/mfd/axp20x.txt new file +12 -0
+
+		axp_dcdc2: dcdc2 {
+			regulator-min-microvolt = <700000>;
+			regulator-max-microvolt = <2275000>;
+			dcdc-workmode = <0>;
+			regulator-always-on;
+		};
+
+		axp_dcdc3: dcdc3 {
+			regulator-min-microvolt = <700000>;
+			regulator-max-microvolt = <3500000>;
+			dcdc-workmode = <0>;

It looks like those are at their default values?

Thanks!
Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140318/8f9575d9/attachment.sig>
#13 lore raw

[linux-sunxi] Re: [PATCH v2 2/8] mfd: AXP20x: Add bindings documentation

Quoted 5 lines · Maxime Ripard
Quoted 2 lines · Carlo Caione

Bindings documentation for the AXP20x driver. In this file also two sub-nodes (PEK and regulators) are documented.

PEK doesn't look to be documented, either in this patch, or any other.

Residue from v1. To be deleted.

Quoted 7 lines
Quoted 4 lines
---
 Documentation/devicetree/bindings/mfd/axp20x.txt   | 83 ++++++++++++++++++++++
 .../devicetree/bindings/vendor-prefixes.txt        |  1 +

I don't really know what the DT maintainers are expecting here, but I would have done two patches.

Uhm, no idea (and no feedback). I'll split it.

Quoted 39 lines
Quoted 25 lines
 2 files changed, 84 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/axp20x.txt
Documentation/devicetree/bindings/mfd/axp20x.txt new file +16 -0
new file mode 100644
index 0000000..982aefe
@@ -0,0 +1,83 @@
+* axp20x device tree bindings
+
+The axp20x family current members :-
+axp202 (X-Powers)
+axp209 (X-Powers)
+
+Required properties:
+- compatible 			: Should be "x-powers,axp202" or "x-powers,axp209"
+- interrupt-controller 		: axp20x has its own internal IRQs
+- #interrupt-cells 		: Should be set to 1
+- interrupt-parent 		: The parent interrupt controller
+- interrupts 			: Interrupt specifiers for interrupt sources
+- reg 				: The I2C slave address for the AXP chip
+
+Sub-nodes:
+* regulators : Contain the regulator nodes. The regulators are bound using

Documentation/devicetree/bindings/mfd/axp20x.txt line 26

Quoted 10 lines
Documentation/devicetree/bindings/mfd/axp20x.txt new file +10 -0
+	       their name as listed here: dcdc2, dcdc3, ldo1, ldo2, ldo3,
+	       ldo4, ldo5.
+	       The bindings details of individual regulator device can be found in:
+	       Documentation/devicetree/bindings/regulator/regulator.txt with the
+	       exception of:
+
+	- dcdc-freq		: defines the work frequency of DC-DC in KHz
+				  (range: 750-1875). Default: 1.5MHz
+	- dcdc-workmode		: Optional. 1 for PWM mode, 0 for AUTO mode
+				  Default: AUTO mode

Those two are x-powers specific, or would it make sense to have them in other drivers too?

Quoted 1 line

If the former, please add the x-powers prefix.

AFAIK this is AXP specific. I'll add the prefix.

Quoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/mfd/axp20x.txt new file +8 -0
+
+Example:
+
+axp: axp20x at 34 {
+	reg = <0x34>;
+	interrupt-parent = <&nmi_intc>;
+	interrupts = <0 8>;
+
Quoted 8 lines

Documentation/devicetree/bindings/mfd/axp20x.txt line 39

Quoted 5 lines
Documentation/devicetree/bindings/mfd/axp20x.txt new file +5 -0
+	compatible = "x-powers,axp209";
+	interrupt-controller;
+	#interrupt-cells = <1>;
+
+	regulators {

Do we really need that subnode ? it looks useless, and we already know that we are defining regulators here.

What do you mean? We are defining the MFD and regulators are just one of the subsystem here. Moveover I'm using the "regulators" node in the regulators driver (using of_find_node_by_name()) to get the regulators configuration.

Quoted 4 lines

Documentation/devicetree/bindings/mfd/axp20x.txt line 40

Quoted 1 line
Documentation/devicetree/bindings/mfd/axp20x.txt new file +1 -0
+		dcdc-freq = "1500";

That frequency is defined at the same level than the dcdc-workmode property, yet they both seem to be placed at different levels.

They are at different level. dcdc-freq is valid for all the dcdc, whereas dcdc-workmode is dcdc-specific.
I'll clarify the point.

Quoted 6 lines
Quoted 6 lines
Documentation/devicetree/bindings/mfd/axp20x.txt new file +6 -0
+
+		axp_dcdc2: dcdc2 {
+			regulator-min-microvolt = <700000>;
+			regulator-max-microvolt = <2275000>;
+			dcdc-workmode = <0>;
+			regulator-always-on;
Quoted 8 lines

Documentation/devicetree/bindings/mfd/axp20x.txt line 52

Quoted 6 lines
Documentation/devicetree/bindings/mfd/axp20x.txt new file +6 -0
+		};
+
+		axp_dcdc3: dcdc3 {
+			regulator-min-microvolt = <700000>;
+			regulator-max-microvolt = <3500000>;
+			dcdc-workmode = <0>;

It looks like those are at their default values?

Yes. To be fixed.

Thanks,

Signature · 1 line
Carlo Caione
#14 lore raw

[linux-sunxi] Re: [PATCH v2 2/8] mfd: AXP20x: Add bindings documentation

Quoted 17 lines · Carlo Caione
Quoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/mfd/axp20x.txt new file +8 -0
+
+Example:
+
+axp: axp20x at 34 {
+	reg = <0x34>;
+	interrupt-parent = <&nmi_intc>;
+	interrupts = <0 8>;
+
Quoted 8 lines

Documentation/devicetree/bindings/mfd/axp20x.txt line 39

Quoted 5 lines
Documentation/devicetree/bindings/mfd/axp20x.txt new file +5 -0
+	compatible = "x-powers,axp209";
+	interrupt-controller;
+	#interrupt-cells = <1>;
+
+	regulators {

Do we really need that subnode ? it looks useless, and we already know that we are defining regulators here.

Quoted 2 lines

What do you mean? We are defining the MFD and regulators are just one of the subsystem here.

I mean that it's useless.

Quoted 3 lines

Moveover I'm using the "regulators" node in the
regulators driver (using of_find_node_by_name()) to get the regulators configuration.

Can't you just use the of_node field of whatever struct device you get?

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140325/f773fca7/attachment.sig>
#15 lore raw

PATCH v2 3/8 input: misc: Add driver for AXP20x Power Enable Key

In reply to Carlo Caione

This patch add support for the Power Enable Key found on MFD AXP202 and AXP209. Besides the basic support for the button, the driver adds two entries in sysfs to configure the time delay for power on/off.

---
 drivers/input/misc/Kconfig      |  11 ++
 drivers/input/misc/Makefile     |   1 +
 drivers/input/misc/axp20x-pek.c | 267 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 279 insertions(+)
 create mode 100644 drivers/input/misc/axp20x-pek.c
drivers/input/misc/Kconfig +11 -0
index 7904ab0..87244fb 100644
@@ -393,6 +393,17 @@ config INPUT_RETU_PWRBUTTON
 	  To compile this driver as a module, choose M here. The module will
 	  be called retu-pwrbutton.
 
+config INPUT_AXP20X_PEK
+	tristate "X-Powers AXP20X power button driver"
+	depends on MFD_AXP20X
+	help
+	  Say Y here if you want to enable power key reporting via the
+	  AXP20X PMIC.
+
+	  To compile this driver as a module, choose M here. The module will
+	  be called axp20x-pek.
+
+
 config INPUT_TWL4030_PWRBUTTON
 	tristate "TWL4030 Power button Driver"
 	depends on TWL4030_CORE
drivers/input/misc/Makefile +1 -0
index cda71fc..624abf5 100644
@@ -50,6 +50,7 @@ obj-$(CONFIG_INPUT_POWERMATE)		+= powermate.o
 obj-$(CONFIG_INPUT_PWM_BEEPER)		+= pwm-beeper.o
 obj-$(CONFIG_INPUT_RB532_BUTTON)	+= rb532_button.o
 obj-$(CONFIG_INPUT_RETU_PWRBUTTON)	+= retu-pwrbutton.o
+obj-$(CONFIG_INPUT_AXP20X_PEK)		+= axp20x-pek.o
 obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER)	+= rotary_encoder.o
 obj-$(CONFIG_INPUT_SGI_BTNS)		+= sgi_btns.o
 obj-$(CONFIG_INPUT_SIRFSOC_ONKEY)	+= sirfsoc-onkey.o
drivers/input/misc/axp20x-pek.c new file +267 -0

267 lines not on this page · raw message

Signature · 1 line
1.8.3.2
#16 lore raw

PATCH v2 3/8 input: misc: Add driver for AXP20x Power Enable Key

Quoted 5 lines · Carlo Caione

This patch add support for the Power Enable Key found on MFD AXP202 and AXP209. Besides the basic support for the button, the driver adds two entries in sysfs to configure the time delay for power on/off.

Quoted 8 lines
---
 drivers/input/misc/Kconfig      |  11 ++
 drivers/input/misc/Makefile     |   1 +
 drivers/input/misc/axp20x-pek.c | 267 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 279 insertions(+)
 create mode 100644 drivers/input/misc/axp20x-pek.c

From what I understood of the MFD framework, you usually have a MFD

core driver that gets loaded from the DT and instantiate its various functions through sub-devices, that are registered through mfd_add_devices, and the drivers for these sub-devices are supported in sub-drivers that are located in the driver/mfd, alongside the core driver.

I believe that such a pattern allows for two interesting things:
- You don't have to search around the whole kernel tree to find where a given sub-feature is supported.
- You don't have to cripple your DT with instantiation of all the subcomponents, while you only really have one device.

Do you have a reason for not following this pattern?

Quoted 280 lines
drivers/input/misc/Kconfig +11 -0
index 7904ab0..87244fb 100644
@@ -393,6 +393,17 @@ config INPUT_RETU_PWRBUTTON
 	  To compile this driver as a module, choose M here. The module will
 	  be called retu-pwrbutton.
 
+config INPUT_AXP20X_PEK
+	tristate "X-Powers AXP20X power button driver"
+	depends on MFD_AXP20X
+	help
+	  Say Y here if you want to enable power key reporting via the
+	  AXP20X PMIC.
+
+	  To compile this driver as a module, choose M here. The module will
+	  be called axp20x-pek.
+
+
 config INPUT_TWL4030_PWRBUTTON
 	tristate "TWL4030 Power button Driver"
 	depends on TWL4030_CORE
drivers/input/misc/Makefile +1 -0
index cda71fc..624abf5 100644
@@ -50,6 +50,7 @@ obj-$(CONFIG_INPUT_POWERMATE)		+= powermate.o
 obj-$(CONFIG_INPUT_PWM_BEEPER)		+= pwm-beeper.o
 obj-$(CONFIG_INPUT_RB532_BUTTON)	+= rb532_button.o
 obj-$(CONFIG_INPUT_RETU_PWRBUTTON)	+= retu-pwrbutton.o
+obj-$(CONFIG_INPUT_AXP20X_PEK)		+= axp20x-pek.o
 obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER)	+= rotary_encoder.o
 obj-$(CONFIG_INPUT_SGI_BTNS)		+= sgi_btns.o
 obj-$(CONFIG_INPUT_SIRFSOC_ONKEY)	+= sirfsoc-onkey.o
drivers/input/misc/axp20x-pek.c new file +239 -0
new file mode 100644
index 0000000..060212f
@@ -0,0 +1,267 @@
+/*
+ * axp20x power button driver.
+ *
+ * Copyright (C) 2013 Carlo Caione <[email protected]>
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file "COPYING" in the main directory of this
+ * archive for more details.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/errno.h>
+#include <linux/irq.h>
+#include <linux/init.h>
+#include <linux/input.h>
+#include <linux/interrupt.h>
+#include <linux/kernel.h>
+#include <linux/mfd/axp20x.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
+
+#define AXP20X_PEK_STARTUP_MASK		(0xc0)
+#define AXP20X_PEK_SHUTDOWN_MASK	(0x03)
+
+static const char const *startup_time[] = { "128ms", "3s" , "1s", "2s" };
+static const char const *shutdown_time[] = { "4s", "6s" , "8s", "10s" };
+
+struct axp20x_pek {
+	struct axp20x_dev *axp20x;
+	struct input_dev *input;
+	int irq_dbr;
+	int irq_dbf;
+};
+
+struct axp20x_pek_ext_attr {
+	const char const **str;
+	unsigned int mask;
+};
+
+static struct axp20x_pek_ext_attr axp20x_pek_startup_ext_attr = {
+	.str	= startup_time,
+	.mask	= AXP20X_PEK_STARTUP_MASK,
+};
+
+static struct axp20x_pek_ext_attr axp20x_pek_shutdown_ext_attr = {
+	.str	= shutdown_time,
+	.mask	= AXP20X_PEK_SHUTDOWN_MASK,
+};
+
+static struct axp20x_pek_ext_attr *get_axp_ext_attr(struct device_attribute *attr)
+{
+	return container_of(attr, struct dev_ext_attribute, attr)->var;
+}
+
+static ssize_t axp20x_show_ext_attr(struct device *dev, struct device_attribute *attr,
+			     char *buf)
+{
+	struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev);
+	struct axp20x_pek_ext_attr *axp20x_ea = get_axp_ext_attr(attr);
+	unsigned int val;
+	int ret, i;
+	int cnt = 0;
+
+	ret = regmap_read(axp20x_pek->axp20x->regmap, AXP20X_PEK_KEY, &val);
+	if (ret != 0)
+		return ret;
+
+	val &= axp20x_ea->mask;
+	val >>= ffs(axp20x_ea->mask) - 1;
+
+	for (i = 0; i < 4; i++) {
+		if (val == i)
+			cnt += sprintf(buf + cnt, "[%s] ", axp20x_ea->str[i]);
+		else
+			cnt += sprintf(buf + cnt, "%s ", axp20x_ea->str[i]);
+	}
+
+	cnt += sprintf(buf + cnt, "\n");
+
+	return cnt;
+}
+
+static ssize_t axp20x_store_ext_attr(struct device *dev, struct device_attribute *attr,
+			      const char *buf, size_t count)
+{
+	struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev);
+	struct axp20x_pek_ext_attr *axp20x_ea = get_axp_ext_attr(attr);
+	char val_str[20];
+	int ret, i;
+	size_t len;
+
+	val_str[sizeof(val_str) - 1] = '\0';
+	strncpy(val_str, buf, sizeof(val_str) - 1);
+	len = strlen(val_str);
+
+	if (len && val_str[len - 1] == '\n')
+		val_str[len - 1] = '\0';
+
+	for (i = 0; i < 4; i++) {
+		if (!strcmp(val_str, axp20x_ea->str[i])) {
+
+			i <<= ffs(axp20x_ea->mask) - 1;
+			ret = regmap_update_bits(axp20x_pek->axp20x->regmap,
+						 AXP20X_PEK_KEY,
+						 axp20x_ea->mask, i);
+			if (ret != 0)
+				return -EINVAL;
+			return count;
+		}
+	}
+
+	return -EINVAL;
+}
+
+static struct dev_ext_attribute axp20x_dev_attr_startup = {
+	.attr	= __ATTR(startup, 0644, axp20x_show_ext_attr, axp20x_store_ext_attr),
+	.var	= &axp20x_pek_startup_ext_attr
+};
+
+static struct dev_ext_attribute axp20x_dev_attr_shutdown = {
+	__ATTR(shutdown, 0644, axp20x_show_ext_attr, axp20x_store_ext_attr),
+	&axp20x_pek_shutdown_ext_attr
+};
+
+static struct attribute *dev_attrs[] = {
+	&axp20x_dev_attr_startup.attr.attr,
+	&axp20x_dev_attr_shutdown.attr.attr,
+	NULL,
+};
+
+static struct attribute_group dev_attr_group = {
+	.attrs	= dev_attrs,
+};
+
+static const struct attribute_group *dev_attr_groups[] = {
+	&dev_attr_group,
+	NULL,
+};
+
+static irqreturn_t axp20x_pek_irq(int irq, void *pwr)
+{
+	struct input_dev *idev = pwr;
+	struct axp20x_pek *axp20x_pek = input_get_drvdata(idev);
+
+	if (irq == axp20x_pek->irq_dbr)
+		input_report_key(idev, KEY_POWER, true);
+	else if (irq == axp20x_pek->irq_dbf)
+		input_report_key(idev, KEY_POWER, false);
+
+	input_sync(idev);
+
+	return IRQ_HANDLED;
+}
+
+static int axp20x_pek_probe(struct platform_device *pdev)
+{
+	struct axp20x_pek *axp20x_pek;
+	struct axp20x_dev *axp20x;
+	struct input_dev *idev;
+	int error;
+
+	axp20x_pek = devm_kzalloc(&pdev->dev, sizeof(struct axp20x_pek),
+				  GFP_KERNEL);
+	if (!axp20x_pek)
+		return -ENOMEM;
+
+	axp20x_pek->axp20x = dev_get_drvdata(pdev->dev.parent);
+	axp20x = axp20x_pek->axp20x;
+
+	axp20x_pek->irq_dbr = platform_get_irq_byname(pdev, "PEK_DBR");
+	if (axp20x_pek->irq_dbr < 0) {
+		dev_err(&pdev->dev, "No IRQ for PEK_DBR, error=%d\n",
+				axp20x_pek->irq_dbr);
+		return axp20x_pek->irq_dbr;
+	}
+	axp20x_pek->irq_dbr = regmap_irq_get_virq(axp20x->regmap_irqc,
+						  axp20x_pek->irq_dbr);
+
+	axp20x_pek->irq_dbf = platform_get_irq_byname(pdev, "PEK_DBF");
+	if (axp20x_pek->irq_dbf < 0) {
+		dev_err(&pdev->dev, "No IRQ for PEK_DBF, error=%d\n",
+				axp20x_pek->irq_dbf);
+		return axp20x_pek->irq_dbf;
+	}
+	axp20x_pek->irq_dbf = regmap_irq_get_virq(axp20x->regmap_irqc,
+						  axp20x_pek->irq_dbf);
+
+	axp20x_pek->input = devm_input_allocate_device(&pdev->dev);
+	if (!axp20x_pek->input)
+		return -ENOMEM;
+
+	idev = axp20x_pek->input;
+
+	idev->name = "axp20x-pek";
+	idev->phys = "m1kbd/input2";
+	idev->dev.parent = &pdev->dev;
+
+	input_set_capability(idev, EV_KEY, KEY_POWER);
+
+	input_set_drvdata(idev, axp20x_pek);
+
+	error = devm_request_threaded_irq(&pdev->dev, axp20x_pek->irq_dbr,
+					  NULL, axp20x_pek_irq, 0,
+					  "axp20x-pek-dbr", idev);
+	if (error) {
+		dev_err(axp20x->dev, "Failed to request dbr IRQ#%d: %d\n",
+			axp20x_pek->irq_dbr, error);
+
+		return error;
+	}
+
+	error = devm_request_threaded_irq(&pdev->dev, axp20x_pek->irq_dbf,
+					  NULL, axp20x_pek_irq, 0,
+					  "axp20x-pek-dbf", idev);
+	if (error) {
+		dev_err(axp20x->dev, "Failed to request dbf IRQ#%d: %d\n",
+			axp20x_pek->irq_dbf, error);
+		return error;
+	}
+
+	idev->dev.groups = dev_attr_groups;
+	error = input_register_device(idev);
+	if (error) {
+		dev_err(axp20x->dev, "Can't register input device: %d\n", error);
+		return error;
+	}
+
+	platform_set_drvdata(pdev, axp20x_pek);
+
+	return 0;
+}
+
+static int axp20x_pek_remove(struct platform_device *pdev)

drivers/input/misc/axp20x-pek.c line 249

Quoted 10 lines
drivers/input/misc/axp20x-pek.c new file +10 -0
+{
+	struct axp20x_pek *axp20x_pek = platform_get_drvdata(pdev);
+
+	input_unregister_device(axp20x_pek->input);
+
+	return 0;
+}
+
+static const struct of_device_id axp20x_pek_match[] = {
+	{ .compatible = "x-powers,axp20x-pek", },

No pattern-matching compatible strings please.

Thanks!
Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140318/b442f012/attachment.sig>
#17 lore raw

PATCH v2 3/8 input: misc: Add driver for AXP20x Power Enable Key

Quoted 19 lines
Quoted 11 lines

This patch add support for the Power Enable Key found on MFD AXP202 and AXP209. Besides the basic support for the button, the driver adds two entries in sysfs to configure the time delay for power on/off.

---
 drivers/input/misc/Kconfig      |  11 ++
 drivers/input/misc/Makefile     |   1 +
 drivers/input/misc/axp20x-pek.c | 267 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 279 insertions(+)
 create mode 100644 drivers/input/misc/axp20x-pek.c

From what I understood of the MFD framework, you usually have a MFD core driver that gets loaded from the DT and instantiate its various functions through sub-devices, that are registered through mfd_add_devices, and the drivers for these sub-devices are supported in sub-drivers that are located in the driver/mfd, alongside the core driver.

Quoted 7 lines

I believe that such a pattern allows for two interesting things:
- You don't have to search around the whole kernel tree to find where a given sub-feature is supported.
- You don't have to cripple your DT with instantiation of all the subcomponents, while you only really have one device.

Do you have a reason for not following this pattern?

Sorry Maxime, this is not the case.

If an MFD contains Regulators and USB & GPIO Controllers, I'd expect to see the device represented in the following way:

drivers/mfd/<id>.c
drivers/{gpio,pinctrl}/{gpio,pinctrl}-<id>.c
drivers/regulator/<id>-regulator.c
drivers/usb/host/<id>.c

Quoted 295 lines
Quoted 279 lines
drivers/input/misc/Kconfig +11 -0
index 7904ab0..87244fb 100644
@@ -393,6 +393,17 @@ config INPUT_RETU_PWRBUTTON
 	  To compile this driver as a module, choose M here. The module will
 	  be called retu-pwrbutton.
 
+config INPUT_AXP20X_PEK
+	tristate "X-Powers AXP20X power button driver"
+	depends on MFD_AXP20X
+	help
+	  Say Y here if you want to enable power key reporting via the
+	  AXP20X PMIC.
+
+	  To compile this driver as a module, choose M here. The module will
+	  be called axp20x-pek.
+
+
 config INPUT_TWL4030_PWRBUTTON
 	tristate "TWL4030 Power button Driver"
 	depends on TWL4030_CORE
drivers/input/misc/Makefile +1 -0
index cda71fc..624abf5 100644
@@ -50,6 +50,7 @@ obj-$(CONFIG_INPUT_POWERMATE)		+= powermate.o
 obj-$(CONFIG_INPUT_PWM_BEEPER)		+= pwm-beeper.o
 obj-$(CONFIG_INPUT_RB532_BUTTON)	+= rb532_button.o
 obj-$(CONFIG_INPUT_RETU_PWRBUTTON)	+= retu-pwrbutton.o
+obj-$(CONFIG_INPUT_AXP20X_PEK)		+= axp20x-pek.o
 obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER)	+= rotary_encoder.o
 obj-$(CONFIG_INPUT_SGI_BTNS)		+= sgi_btns.o
 obj-$(CONFIG_INPUT_SIRFSOC_ONKEY)	+= sirfsoc-onkey.o
drivers/input/misc/axp20x-pek.c new file +239 -0
new file mode 100644
index 0000000..060212f
@@ -0,0 +1,267 @@
+/*
+ * axp20x power button driver.
+ *
+ * Copyright (C) 2013 Carlo Caione <[email protected]>
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file "COPYING" in the main directory of this
+ * archive for more details.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/errno.h>
+#include <linux/irq.h>
+#include <linux/init.h>
+#include <linux/input.h>
+#include <linux/interrupt.h>
+#include <linux/kernel.h>
+#include <linux/mfd/axp20x.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
+
+#define AXP20X_PEK_STARTUP_MASK		(0xc0)
+#define AXP20X_PEK_SHUTDOWN_MASK	(0x03)
+
+static const char const *startup_time[] = { "128ms", "3s" , "1s", "2s" };
+static const char const *shutdown_time[] = { "4s", "6s" , "8s", "10s" };
+
+struct axp20x_pek {
+	struct axp20x_dev *axp20x;
+	struct input_dev *input;
+	int irq_dbr;
+	int irq_dbf;
+};
+
+struct axp20x_pek_ext_attr {
+	const char const **str;
+	unsigned int mask;
+};
+
+static struct axp20x_pek_ext_attr axp20x_pek_startup_ext_attr = {
+	.str	= startup_time,
+	.mask	= AXP20X_PEK_STARTUP_MASK,
+};
+
+static struct axp20x_pek_ext_attr axp20x_pek_shutdown_ext_attr = {
+	.str	= shutdown_time,
+	.mask	= AXP20X_PEK_SHUTDOWN_MASK,
+};
+
+static struct axp20x_pek_ext_attr *get_axp_ext_attr(struct device_attribute *attr)
+{
+	return container_of(attr, struct dev_ext_attribute, attr)->var;
+}
+
+static ssize_t axp20x_show_ext_attr(struct device *dev, struct device_attribute *attr,
+			     char *buf)
+{
+	struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev);
+	struct axp20x_pek_ext_attr *axp20x_ea = get_axp_ext_attr(attr);
+	unsigned int val;
+	int ret, i;
+	int cnt = 0;
+
+	ret = regmap_read(axp20x_pek->axp20x->regmap, AXP20X_PEK_KEY, &val);
+	if (ret != 0)
+		return ret;
+
+	val &= axp20x_ea->mask;
+	val >>= ffs(axp20x_ea->mask) - 1;
+
+	for (i = 0; i < 4; i++) {
+		if (val == i)
+			cnt += sprintf(buf + cnt, "[%s] ", axp20x_ea->str[i]);
+		else
+			cnt += sprintf(buf + cnt, "%s ", axp20x_ea->str[i]);
+	}
+
+	cnt += sprintf(buf + cnt, "\n");
+
+	return cnt;
+}
+
+static ssize_t axp20x_store_ext_attr(struct device *dev, struct device_attribute *attr,
+			      const char *buf, size_t count)
+{
+	struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev);
+	struct axp20x_pek_ext_attr *axp20x_ea = get_axp_ext_attr(attr);
+	char val_str[20];
+	int ret, i;
+	size_t len;
+
+	val_str[sizeof(val_str) - 1] = '\0';
+	strncpy(val_str, buf, sizeof(val_str) - 1);
+	len = strlen(val_str);
+
+	if (len && val_str[len - 1] == '\n')
+		val_str[len - 1] = '\0';
+
+	for (i = 0; i < 4; i++) {
+		if (!strcmp(val_str, axp20x_ea->str[i])) {
+
+			i <<= ffs(axp20x_ea->mask) - 1;
+			ret = regmap_update_bits(axp20x_pek->axp20x->regmap,
+						 AXP20X_PEK_KEY,
+						 axp20x_ea->mask, i);
+			if (ret != 0)
+				return -EINVAL;
+			return count;
+		}
+	}
+
+	return -EINVAL;
+}
+
+static struct dev_ext_attribute axp20x_dev_attr_startup = {
+	.attr	= __ATTR(startup, 0644, axp20x_show_ext_attr, axp20x_store_ext_attr),
+	.var	= &axp20x_pek_startup_ext_attr
+};
+
+static struct dev_ext_attribute axp20x_dev_attr_shutdown = {
+	__ATTR(shutdown, 0644, axp20x_show_ext_attr, axp20x_store_ext_attr),
+	&axp20x_pek_shutdown_ext_attr
+};
+
+static struct attribute *dev_attrs[] = {
+	&axp20x_dev_attr_startup.attr.attr,
+	&axp20x_dev_attr_shutdown.attr.attr,
+	NULL,
+};
+
+static struct attribute_group dev_attr_group = {
+	.attrs	= dev_attrs,
+};
+
+static const struct attribute_group *dev_attr_groups[] = {
+	&dev_attr_group,
+	NULL,
+};
+
+static irqreturn_t axp20x_pek_irq(int irq, void *pwr)
+{
+	struct input_dev *idev = pwr;
+	struct axp20x_pek *axp20x_pek = input_get_drvdata(idev);
+
+	if (irq == axp20x_pek->irq_dbr)
+		input_report_key(idev, KEY_POWER, true);
+	else if (irq == axp20x_pek->irq_dbf)
+		input_report_key(idev, KEY_POWER, false);
+
+	input_sync(idev);
+
+	return IRQ_HANDLED;
+}
+
+static int axp20x_pek_probe(struct platform_device *pdev)
+{
+	struct axp20x_pek *axp20x_pek;
+	struct axp20x_dev *axp20x;
+	struct input_dev *idev;
+	int error;
+
+	axp20x_pek = devm_kzalloc(&pdev->dev, sizeof(struct axp20x_pek),
+				  GFP_KERNEL);
+	if (!axp20x_pek)
+		return -ENOMEM;
+
+	axp20x_pek->axp20x = dev_get_drvdata(pdev->dev.parent);
+	axp20x = axp20x_pek->axp20x;
+
+	axp20x_pek->irq_dbr = platform_get_irq_byname(pdev, "PEK_DBR");
+	if (axp20x_pek->irq_dbr < 0) {
+		dev_err(&pdev->dev, "No IRQ for PEK_DBR, error=%d\n",
+				axp20x_pek->irq_dbr);
+		return axp20x_pek->irq_dbr;
+	}
+	axp20x_pek->irq_dbr = regmap_irq_get_virq(axp20x->regmap_irqc,
+						  axp20x_pek->irq_dbr);
+
+	axp20x_pek->irq_dbf = platform_get_irq_byname(pdev, "PEK_DBF");
+	if (axp20x_pek->irq_dbf < 0) {
+		dev_err(&pdev->dev, "No IRQ for PEK_DBF, error=%d\n",
+				axp20x_pek->irq_dbf);
+		return axp20x_pek->irq_dbf;
+	}
+	axp20x_pek->irq_dbf = regmap_irq_get_virq(axp20x->regmap_irqc,
+						  axp20x_pek->irq_dbf);
+
+	axp20x_pek->input = devm_input_allocate_device(&pdev->dev);
+	if (!axp20x_pek->input)
+		return -ENOMEM;
+
+	idev = axp20x_pek->input;
+
+	idev->name = "axp20x-pek";
+	idev->phys = "m1kbd/input2";
+	idev->dev.parent = &pdev->dev;
+
+	input_set_capability(idev, EV_KEY, KEY_POWER);
+
+	input_set_drvdata(idev, axp20x_pek);
+
+	error = devm_request_threaded_irq(&pdev->dev, axp20x_pek->irq_dbr,
+					  NULL, axp20x_pek_irq, 0,
+					  "axp20x-pek-dbr", idev);
+	if (error) {
+		dev_err(axp20x->dev, "Failed to request dbr IRQ#%d: %d\n",
+			axp20x_pek->irq_dbr, error);
+
+		return error;
+	}
+
+	error = devm_request_threaded_irq(&pdev->dev, axp20x_pek->irq_dbf,
+					  NULL, axp20x_pek_irq, 0,
+					  "axp20x-pek-dbf", idev);
+	if (error) {
+		dev_err(axp20x->dev, "Failed to request dbf IRQ#%d: %d\n",
+			axp20x_pek->irq_dbf, error);
+		return error;
+	}
+
+	idev->dev.groups = dev_attr_groups;
+	error = input_register_device(idev);
+	if (error) {
+		dev_err(axp20x->dev, "Can't register input device: %d\n", error);
+		return error;
+	}
+
+	platform_set_drvdata(pdev, axp20x_pek);
+
+	return 0;
+}
+
+static int axp20x_pek_remove(struct platform_device *pdev)

drivers/input/misc/axp20x-pek.c line 249

Quoted 10 lines
drivers/input/misc/axp20x-pek.c new file +10 -0
+{
+	struct axp20x_pek *axp20x_pek = platform_get_drvdata(pdev);
+
+	input_unregister_device(axp20x_pek->input);
+
+	return 0;
+}
+
+static const struct of_device_id axp20x_pek_match[] = {
+	{ .compatible = "x-powers,axp20x-pek", },

No pattern-matching compatible strings please.

Thanks!
Maxime

Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#18 lore raw

PATCH v2 3/8 input: misc: Add driver for AXP20x Power Enable Key

Quoted 29 lines · Lee Jones
Quoted 19 lines
Quoted 11 lines

This patch add support for the Power Enable Key found on MFD AXP202 and AXP209. Besides the basic support for the button, the driver adds two entries in sysfs to configure the time delay for power on/off.

---
 drivers/input/misc/Kconfig      |  11 ++
 drivers/input/misc/Makefile     |   1 +
 drivers/input/misc/axp20x-pek.c | 267 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 279 insertions(+)
 create mode 100644 drivers/input/misc/axp20x-pek.c

From what I understood of the MFD framework, you usually have a MFD core driver that gets loaded from the DT and instantiate its various functions through sub-devices, that are registered through mfd_add_devices, and the drivers for these sub-devices are supported in sub-drivers that are located in the driver/mfd, alongside the core driver.

Quoted 7 lines

I believe that such a pattern allows for two interesting things:
- You don't have to search around the whole kernel tree to find where a given sub-feature is supported.
- You don't have to cripple your DT with instantiation of all the subcomponents, while you only really have one device.

Do you have a reason for not following this pattern?

Sorry Maxime, this is not the case.

Quoted 7 lines

If an MFD contains Regulators and USB & GPIO Controllers, I'd expect to see the device represented in the following way:

drivers/mfd/<id>.c
drivers/{gpio,pinctrl}/{gpio,pinctrl}-<id>.c
drivers/regulator/<id>-regulator.c
drivers/usb/host/<id>.c

Oh, ok. Nevermind then :)

Just out of curiosity, some drivers at least seem to follow that trend in drivers/mfd, is there any reason for this (other than historical) ?

Thanks,
Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140318/f84d8126/attachment.sig>
#19 lore raw

PATCH v2 3/8 input: misc: Add driver for AXP20x Power Enable Key

Quoted 37 lines
Quoted 29 lines
Quoted 19 lines
Quoted 11 lines

This patch add support for the Power Enable Key found on MFD AXP202 and AXP209. Besides the basic support for the button, the driver adds two entries in sysfs to configure the time delay for power on/off.

---
 drivers/input/misc/Kconfig      |  11 ++
 drivers/input/misc/Makefile     |   1 +
 drivers/input/misc/axp20x-pek.c | 267 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 279 insertions(+)
 create mode 100644 drivers/input/misc/axp20x-pek.c

From what I understood of the MFD framework, you usually have a MFD core driver that gets loaded from the DT and instantiate its various functions through sub-devices, that are registered through mfd_add_devices, and the drivers for these sub-devices are supported in sub-drivers that are located in the driver/mfd, alongside the core driver.

Quoted 7 lines

I believe that such a pattern allows for two interesting things:
- You don't have to search around the whole kernel tree to find where a given sub-feature is supported.
- You don't have to cripple your DT with instantiation of all the subcomponents, while you only really have one device.

Do you have a reason for not following this pattern?

Sorry Maxime, this is not the case.

Quoted 7 lines

If an MFD contains Regulators and USB & GPIO Controllers, I'd expect to see the device represented in the following way:

drivers/mfd/<id>.c
drivers/{gpio,pinctrl}/{gpio,pinctrl}-<id>.c
drivers/regulator/<id>-regulator.c
drivers/usb/host/<id>.c

Quoted 4 lines

Oh, ok. Nevermind then :)

Just out of curiosity, some drivers at least seem to follow that trend in drivers/mfd, is there any reason for this (other than historical) ?

Would you mind providing an example?

Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#20 lore raw

PATCH v2 3/8 input: misc: Add driver for AXP20x Power Enable Key

Quoted 37 lines · Lee Jones
Quoted 37 lines
Quoted 36 lines
Quoted 19 lines
Quoted 11 lines

This patch add support for the Power Enable Key found on MFD AXP202 and AXP209. Besides the basic support for the button, the driver adds two entries in sysfs to configure the time delay for power on/off.

---
 drivers/input/misc/Kconfig      |  11 ++
 drivers/input/misc/Makefile     |   1 +
 drivers/input/misc/axp20x-pek.c | 267 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 279 insertions(+)
 create mode 100644 drivers/input/misc/axp20x-pek.c

From what I understood of the MFD framework, you usually have a MFD core driver that gets loaded from the DT and instantiate its various functions through sub-devices, that are registered through mfd_add_devices, and the drivers for these sub-devices are supported in sub-drivers that are located in the driver/mfd, alongside the core driver.

Quoted 7 lines

I believe that such a pattern allows for two interesting things:
- You don't have to search around the whole kernel tree to find where a given sub-feature is supported.
- You don't have to cripple your DT with instantiation of all the subcomponents, while you only really have one device.

Do you have a reason for not following this pattern?

Sorry Maxime, this is not the case.

If an MFD contains Regulators and USB & GPIO Controllers, I'd expect to see the device represented in the following way:

drivers/mfd/<id>.c
drivers/{gpio,pinctrl}/{gpio,pinctrl}-<id>.c
drivers/regulator/<id>-regulator.c
drivers/usb/host/<id>.c

Quoted 6 lines
Quoted 4 lines

Oh, ok. Nevermind then :)

Just out of curiosity, some drivers at least seem to follow that trend in drivers/mfd, is there any reason for this (other than historical) ?

Would you mind providing an example?

I was under this impression given the naming scheme that they were using. Looking into it just proved me how wrong I was :)

Sorry for the noise.

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140318/7395cd2d/attachment.sig>
#21 lore raw

PATCH v2 4/8 input: misc: Add ABI docs for AXP20x PEK

In reply to Carlo Caione

Add ABI entries for the PEK found on PMU X-Powers AXP202 and AXP209.

---
 Documentation/ABI/testing/sysfs-driver-input-axp-pek | 11 +++++++++++
 1 file changed, 11 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-driver-input-axp-pek
Documentation/ABI/testing/sysfs-driver-input-axp-pek new file +11 -0
new file mode 100644
index 0000000..f8cdad2
@@ -0,0 +1,11 @@
+What:		/sys/class/input/input(x)/startup
+Date:		March 2014
+Contact:	Carlo Caione <[email protected]>
+Description:	Startup time. Board is powered on if the button is pressed
+		for more than <startup_time>
+
+What:		/sys/class/input/input(x)/shutdown
+Date:		March 2014
+Contact:	Carlo Caione <[email protected]>
+Description:	Shutdown time. Board is powered off if the button is pressed
+		for more than <shutdown_time>
Signature · 1 line
1.8.3.2
#22 lore raw

PATCH v2 5/8 regulator: AXP20x: Add support for regulators subsystem

In reply to Carlo Caione

AXP202 and AXP209 come with two synchronous step-down DC-DCs and five LDOs. This patch introduces basic support for those regulators.

---
 drivers/regulator/Kconfig            |   7 +
 drivers/regulator/Makefile           |   1 +
 drivers/regulator/axp20x-regulator.c | 293 +++++++++++++++++++++++++++++++++++
 3 files changed, 301 insertions(+)
 create mode 100644 drivers/regulator/axp20x-regulator.c
drivers/regulator/Kconfig +7 -0
index 6a79328..9f3bc48 100644
@@ -139,6 +139,13 @@ config REGULATOR_AS3722
 	  AS3722 PMIC. This will enable support for all the software
 	  controllable DCDC/LDO regulators.
 
+config REGULATOR_AXP20X
+	tristate "X-POWERS AXP20X PMIC Regulators"
+	depends on MFD_AXP20X
+	help
+	  This driver provides support for the voltage regulators on the
+	  AXP20X PMIC.
+
 config REGULATOR_DA903X
 	tristate "Dialog Semiconductor DA9030/DA9034 regulators"
 	depends on PMIC_DA903X
drivers/regulator/Makefile +1 -0
index 979f9dd..1dd084a 100644
@@ -20,6 +20,7 @@ obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o
 obj-$(CONFIG_REGULATOR_ARIZONA) += arizona-micsupp.o arizona-ldo1.o
 obj-$(CONFIG_REGULATOR_AS3711) += as3711-regulator.o
 obj-$(CONFIG_REGULATOR_AS3722) += as3722-regulator.o
+obj-$(CONFIG_REGULATOR_AXP20X) += axp20x-regulator.o
 obj-$(CONFIG_REGULATOR_DA903X)	+= da903x.o
 obj-$(CONFIG_REGULATOR_DA9052)	+= da9052-regulator.o
 obj-$(CONFIG_REGULATOR_DA9055)	+= da9055-regulator.o
drivers/regulator/axp20x-regulator.c new file +293 -0

293 lines not on this page · raw message

Signature · 1 line
1.8.3.2
#23 lore raw

PATCH v2 5/8 regulator: AXP20x: Add support for regulators subsystem

Quoted 76 lines

AXP202 and AXP209 come with two synchronous step-down DC-DCs and five LDOs. This patch introduces basic support for those regulators.

---
 drivers/regulator/Kconfig            |   7 +
 drivers/regulator/Makefile           |   1 +
 drivers/regulator/axp20x-regulator.c | 293 +++++++++++++++++++++++++++++++++++
 3 files changed, 301 insertions(+)
 create mode 100644 drivers/regulator/axp20x-regulator.c
drivers/regulator/Kconfig +7 -0
index 6a79328..9f3bc48 100644
@@ -139,6 +139,13 @@ config REGULATOR_AS3722
 	  AS3722 PMIC. This will enable support for all the software
 	  controllable DCDC/LDO regulators.
 
+config REGULATOR_AXP20X
+	tristate "X-POWERS AXP20X PMIC Regulators"
+	depends on MFD_AXP20X
+	help
+	  This driver provides support for the voltage regulators on the
+	  AXP20X PMIC.
+
 config REGULATOR_DA903X
 	tristate "Dialog Semiconductor DA9030/DA9034 regulators"
 	depends on PMIC_DA903X
drivers/regulator/Makefile +1 -0
index 979f9dd..1dd084a 100644
@@ -20,6 +20,7 @@ obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o
 obj-$(CONFIG_REGULATOR_ARIZONA) += arizona-micsupp.o arizona-ldo1.o
 obj-$(CONFIG_REGULATOR_AS3711) += as3711-regulator.o
 obj-$(CONFIG_REGULATOR_AS3722) += as3722-regulator.o
+obj-$(CONFIG_REGULATOR_AXP20X) += axp20x-regulator.o
 obj-$(CONFIG_REGULATOR_DA903X)	+= da903x.o
 obj-$(CONFIG_REGULATOR_DA9052)	+= da9052-regulator.o
 obj-$(CONFIG_REGULATOR_DA9055)	+= da9055-regulator.o
drivers/regulator/axp20x-regulator.c new file +27 -0
new file mode 100644
index 0000000..f09fe35
@@ -0,0 +1,293 @@
+/*
+ * AXP20x regulators driver.
+ *
+ * Copyright (C) 2013 Carlo Caione <[email protected]>
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file "COPYING" in the main directory of this
+ * archive for more details.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/err.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+#include <linux/mfd/axp20x.h>
+#include <linux/regulator/driver.h>
+#include <linux/regulator/of_regulator.h>
+
+#define AXP20X_IO_ENABLED		(0x03)

drivers/regulator/axp20x-regulator.c line 37

Quoted 10 lines
drivers/regulator/axp20x-regulator.c new file +10 -0
+#define AXP20X_IO_DISABLED		(0x07)
+
+#define AXP20X_WORKMODE_DCDC2_MASK	BIT(2)
+#define AXP20X_WORKMODE_DCDC3_MASK	BIT(1)
+
+#define AXP20X_FREQ_DCDC_MASK		(0x0f)
+
+struct axp20x_regulators {
+	struct regulator_desc	rdesc[AXP20X_REG_ID_MAX];
+	struct regulator_dev	*rdev[AXP20X_REG_ID_MAX];

Hi,

You can get rid of 'rdev' field completely now since you are using devm_regulator_register(). It isn't used outside of probe().

The 'rdesc' field is also not essential. After removing it you can remove completely the state container (struct axp20x_regulators).

Quoted 82 lines
drivers/regulator/axp20x-regulator.c new file +82 -0
+	struct axp20x_dev	*axp20x;
+};
+
+#define AXP20X_DESC_IO(_id, _min, _max, _step, _vreg, _vmask, _ereg, _emask, 	\
+		       _enable_val, _disable_val)				\
+	[AXP20X_##_id] = {							\
+		.name		= #_id,						\
+		.type		= REGULATOR_VOLTAGE,				\
+		.id		= AXP20X_##_id,					\
+		.n_voltages	= (((_max) - (_min)) / (_step) + 1),		\
+		.owner		= THIS_MODULE,					\
+		.min_uV		= (_min) * 1000,				\
+		.uV_step	= (_step) * 1000,				\
+		.vsel_reg	= (_vreg),					\
+		.vsel_mask	= (_vmask),					\
+		.enable_reg	= (_ereg),					\
+		.enable_mask	= (_emask),					\
+		.enable_val	= (_enable_val),				\
+		.disable_val	= (_disable_val),				\
+		.ops		= &axp20x_ops,					\
+	}
+
+#define AXP20X_DESC(_id, _min, _max, _step, _vreg, _vmask, _ereg, _emask) 	\
+	AXP20X_DESC_IO(_id, _min, _max, _step, _vreg, _vmask, _ereg, _emask,	\
+		       0, 0)
+
+#define AXP20X_DESC_FIXED(_id, _volt)						\
+	[AXP20X_##_id] = {							\
+		.name		= #_id,						\
+		.type		= REGULATOR_VOLTAGE,				\
+		.id		= AXP20X_##_id,					\
+		.n_voltages	= 1,						\
+		.owner		= THIS_MODULE,					\
+		.min_uV		= (_volt) * 1000,				\
+		.ops		= &axp20x_ops,					\
+	}
+
+#define AXP20X_DESC_TABLE(_id, _table, _vreg, _vmask, _ereg, _emask)		\
+	[AXP20X_##_id] = {							\
+		.name		= #_id,						\
+		.type		= REGULATOR_VOLTAGE,				\
+		.id		= AXP20X_##_id,					\
+		.n_voltages	= ARRAY_SIZE(_table),				\
+		.owner		= THIS_MODULE,					\
+		.vsel_reg	= (_vreg),					\
+		.vsel_mask	= (_vmask),					\
+		.enable_reg	= (_ereg),					\
+		.enable_mask	= (_emask),					\
+		.volt_table	= (_table),					\
+		.ops		= &axp20x_ops_table,				\
+	}
+
+static int axp20x_ldo4_data[] = { 1250000, 1300000, 1400000, 1500000, 1600000, 1700000,
+				  1800000, 1900000, 2000000, 2500000, 2700000, 2800000,
+				  3000000, 3100000, 3200000, 3300000 };
+
+static int axp20x_set_suspend_voltage(struct regulator_dev *rdev, int uV)
+{
+	int sel = regulator_map_voltage_iterate(rdev, uV, uV);
+
+	if (sel < 0)
+		return sel;
+
+	return regulator_set_voltage_sel_regmap(rdev, sel);
+}
+
+static struct regulator_ops axp20x_ops_table = {
+	.set_voltage_sel	= regulator_set_voltage_sel_regmap,
+	.get_voltage_sel	= regulator_get_voltage_sel_regmap,
+	.list_voltage		= regulator_list_voltage_table,
+	.enable			= regulator_enable_regmap,
+	.disable		= regulator_disable_regmap,
+	.is_enabled		= regulator_is_enabled_regmap,
+	.set_suspend_enable	= regulator_enable_regmap,
+	.set_suspend_disable	= regulator_disable_regmap,
+	.set_suspend_voltage	= axp20x_set_suspend_voltage,
+};
+
+
+static struct regulator_ops axp20x_ops = {
+	.set_voltage_sel	= regulator_set_voltage_sel_regmap,
+	.get_voltage_sel	= regulator_get_voltage_sel_regmap,

drivers/regulator/axp20x-regulator.c line 129

Quoted 10 lines
drivers/regulator/axp20x-regulator.c new file +10 -0
+	.list_voltage		= regulator_list_voltage_linear,
+	.enable			= regulator_enable_regmap,
+	.disable		= regulator_disable_regmap,
+	.is_enabled		= regulator_is_enabled_regmap,
+	.set_suspend_enable	= regulator_enable_regmap,
+	.set_suspend_disable	= regulator_disable_regmap,
+	.set_suspend_voltage	= axp20x_set_suspend_voltage,
+};
+
+static struct regulator_desc axp20x_regulators[] = {

I think this should be 'static const'.

Best regards,
Krzysztof

maintainer
#24 lore raw

PATCH v2 5/8 regulator: AXP20x: Add support for regulators subsystem

In reply to Carlo Caione
Quoted 2 lines · Carlo Caione

AXP202 and AXP209 come with two synchronous step-down DC-DCs and five LDOs. This patch introduces basic support for those regulators.

This is mostly fine apart from the things Krzysztof mentioned and...

drivers/regulator/axp20x-regulator.c line 170

Quoted 9 lines
drivers/regulator/axp20x-regulator.c new file +9 -0
+static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq)
+{
+	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
+
+	if (dcdcfreq < 750)
+		dcdcfreq = 750;
+
+	if (dcdcfreq > 1875)
+		dcdcfreq = 1875;

I'd expect at least a warning on out of spec values being specified
here.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140317/d64f3f99/attachment.sig>

#25 lore raw

PATCH v2 6/8 ARM: sunxi: dt: Add x-powers-axp209.dtsi file

In reply to Carlo Caione

This dtsi describes the axp209 PMIC, and is to be included from inside the i2c controller node to which the axp209 is connected.

---
 arch/arm/boot/dts/x-powers-axp209.dtsi | 60 ++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)
 create mode 100644 arch/arm/boot/dts/x-powers-axp209.dtsi
arch/arm/boot/dts/x-powers-axp209.dtsi new file +60 -0
new file mode 100644
index 0000000..d272e67
@@ -0,0 +1,60 @@
+/*
+ * x-powers,axp209 common code to be include from inside the axp209 node
+ *
+ * Copyright 2014 - Carlo Caione <[email protected]>
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+	compatible = "x-powers,axp209";
+	interrupt-controller;
+	#interrupt-cells = <1>;
+
+	regulators {
+		dcdc-freq = "1500";
+
+		axp_dcdc2: dcdc2 {
+			regulator-min-microvolt = <700000>;
+			regulator-max-microvolt = <2275000>;
+			dcdc-workmode = <0>;
+			regulator-always-on;
+		};
+
+		axp_dcdc3: dcdc3 {
+			regulator-min-microvolt = <700000>;
+			regulator-max-microvolt = <3500000>;
+			dcdc-workmode = <0>;
+			regulator-always-on;
+		};
+
+		axp_ldo1: ldo1 {
+			regulator-min-microvolt = <1300000>;
+			regulator-max-microvolt = <1300000>;
+		};
+
+		axp_ldo2: ldo2 {
+			regulator-min-microvolt = <1800000>;
+			regulator-max-microvolt = <3300000>;
+			regulator-always-on;
+		};
+
+		axp_ldo3: ldo3 {
+			regulator-min-microvolt = <700000>;
+			regulator-max-microvolt = <3500000>;
+		};
+
+		axp_ldo4: ldo4 {
+			regulator-min-microvolt = <1250000>;
+			regulator-max-microvolt = <3300000>;
+		};
+
+		axp_ldo5: ldo5 {
+			regulator-min-microvolt = <1800000>;
+			regulator-max-microvolt = <3300000>;
+		};
+	};
Signature · 1 line
1.8.3.2
#26 lore raw

PATCH v2 6/8 ARM: sunxi: dt: Add x-powers-axp209.dtsi file

Quoted 19 lines · Carlo Caione

This dtsi describes the axp209 PMIC, and is to be included from inside the i2c controller node to which the axp209 is connected.

---
 arch/arm/boot/dts/x-powers-axp209.dtsi | 60 ++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)
 create mode 100644 arch/arm/boot/dts/x-powers-axp209.dtsi
arch/arm/boot/dts/x-powers-axp209.dtsi new file +3 -0
new file mode 100644
index 0000000..d272e67
@@ -0,0 +1,60 @@
+/*
+ * x-powers,axp209 common code to be include from inside the axp209 node
+ *

arch/arm/boot/dts/x-powers-axp209.dtsi line 13

Quoted 10 lines
arch/arm/boot/dts/x-powers-axp209.dtsi new file +10 -0
+ * Copyright 2014 - Carlo Caione <[email protected]>
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+

I didn't even know such a thing was possible :)
Nice hack.

arch/arm/boot/dts/x-powers-axp209.dtsi line 16

Quoted 3 lines
arch/arm/boot/dts/x-powers-axp209.dtsi new file +3 -0
+	compatible = "x-powers,axp209";
+	interrupt-controller;
+	#interrupt-cells = <1>;

However, I'd move this out of it, and in the board file, so that we actually get an idea by looking at the board DTS of what device we are actually registering at this given address, and what it's capable of.

Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140318/0887235f/attachment.sig>
#27 lore raw

[linux-sunxi] Re: [PATCH v2 6/8] ARM: sunxi: dt: Add x-powers-axp209.dtsi file

Quoted 25 lines · Maxime Ripard
Quoted 24 lines · Carlo Caione

This dtsi describes the axp209 PMIC, and is to be included from inside the i2c controller node to which the axp209 is connected.

---
 arch/arm/boot/dts/x-powers-axp209.dtsi | 60 ++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)
 create mode 100644 arch/arm/boot/dts/x-powers-axp209.dtsi
arch/arm/boot/dts/x-powers-axp209.dtsi new file +8 -0
new file mode 100644
index 0000000..d272e67
@@ -0,0 +1,60 @@
+/*
+ * x-powers,axp209 common code to be include from inside the axp209 node
+ *
+ * Copyright 2014 - Carlo Caione <[email protected]>
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
Quoted 8 lines

arch/arm/boot/dts/x-powers-axp209.dtsi line 13

Quoted 5 lines
arch/arm/boot/dts/x-powers-axp209.dtsi new file +5 -0
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+

I didn't even know such a thing was possible :)
Nice hack.

Kudos to Hans ;)

Quoted 8 lines

arch/arm/boot/dts/x-powers-axp209.dtsi line 16

Quoted 4 lines
arch/arm/boot/dts/x-powers-axp209.dtsi new file +3 -0
+	compatible = "x-powers,axp209";
+	interrupt-controller;
+	#interrupt-cells = <1>;

However, I'd move this out of it, and in the board file, so that we actually get an idea by looking at the board DTS of what device we are actually registering at this given address, and what it's capable of.

Do you mean the whole dtsi or just those three lines?

Signature · 1 line
Carlo Caione
#28 lore raw

[linux-sunxi] Re: [PATCH v2 6/8] ARM: sunxi: dt: Add x-powers-axp209.dtsi file

Quoted 9 lines · Carlo Caione
Quoted 7 lines

arch/arm/boot/dts/x-powers-axp209.dtsi line 16

Quoted 3 lines
arch/arm/boot/dts/x-powers-axp209.dtsi new file +3 -0
+	compatible = "x-powers,axp209";
+	interrupt-controller;
+	#interrupt-cells = <1>;

However, I'd move this out of it, and in the board file, so that we actually get an idea by looking at the board DTS of what device we are actually registering at this given address, and what it's capable of.

Do you mean the whole dtsi or just those three lines?

Just those three lines.

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140325/9be5dc49/attachment.sig>
#29 lore raw

PATCH v2 7/8 ARM: sun7i: dt: Add AXP209 support to various boards

In reply to Carlo Caione
---
 arch/arm/boot/dts/sun7i-a20-cubieboard2.dts     | 12 ++++++++++++
 arch/arm/boot/dts/sun7i-a20-cubietruck.dts      | 13 +++++++++++++
 arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts | 12 ++++++++++++
 3 files changed, 37 insertions(+)
arch/arm/boot/dts/sun7i-a20-cubieboard2.dts +12 -0
index 5c51cb8..9ad7da5 100644
@@ -53,6 +53,18 @@
 			pinctrl-names = "default";
 			pinctrl-0 = <&i2c0_pins_a>;
 			status = "okay";
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			axp: axp20x at 34 {
+				reg = <0x34>;
+				interrupt-parent = <&nmi_intc>;
+				interrupts = <0 8>;
+
+				axp,system-power-controller;
+
+				/include/ "x-powers-axp209.dtsi"
+			};
 		};
 
 		i2c1: i2c at 01c2b000 {
arch/arm/boot/dts/sun7i-a20-cubietruck.dts +13 -0
index f9dcb61..aab77f9 100644
@@ -38,6 +38,19 @@
 			pinctrl-names = "default";
 			pinctrl-0 = <&i2c0_pins_a>;
 			status = "okay";
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			axp: axp20x at 34 {
+				reg = <0x34>;
+				interrupt-parent = <&nmi_intc>;
+				interrupts = <0 8>;
+
+				axp,system-power-controller;
+
+				/include/ "x-powers-axp209.dtsi"
+			};
+
 		};
 
 		i2c1: i2c at 01c2b000 {
arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts +12 -0
index ead3013..a5fe5d0 100644
@@ -65,6 +65,18 @@
 			pinctrl-names = "default";
 			pinctrl-0 = <&i2c0_pins_a>;
 			status = "okay";
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			axp: axp20x at 34 {
+				reg = <0x34>;
+				interrupt-parent = <&nmi_intc>;
+				interrupts = <0 8>;
+
+				axp,system-power-controller;
+
+				/include/ "x-powers-axp209.dtsi"
+			};
 		};
 
 		i2c1: i2c at 01c2b000 {
Signature · 1 line
1.8.3.2
#30 lore raw

PATCH v2 7/8 ARM: sun7i: dt: Add AXP209 support to various boards

Hi,

Thanks for your continued work on this.

Quoted 15 lines · Carlo Caione
---
 arch/arm/boot/dts/sun7i-a20-cubieboard2.dts     | 12 ++++++++++++
 arch/arm/boot/dts/sun7i-a20-cubietruck.dts      | 13 +++++++++++++
 arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts | 12 ++++++++++++
 3 files changed, 37 insertions(+)
arch/arm/boot/dts/sun7i-a20-cubieboard2.dts +0 -0
index 5c51cb8..9ad7da5 100644
@@ -53,6 +53,18 @@
 			pinctrl-names = "default";
 			pinctrl-0 = <&i2c0_pins_a>;

arch/arm/boot/dts/sun7i-a20-cubieboard2.dts line 64

Quoted 10 lines
arch/arm/boot/dts/sun7i-a20-cubieboard2.dts +9 -0
 			status = "okay";
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			axp: axp20x at 34 {
+				reg = <0x34>;
+				interrupt-parent = <&nmi_intc>;
+				interrupts = <0 8>;
+
+				axp,system-power-controller;

Shouldn't this be dropped now (all 3 of them) ?

Regards,

Hans

Quoted 54 lines
arch/arm/boot/dts/sun7i-a20-cubieboard2.dts +3 -0
+
+				/include/ "x-powers-axp209.dtsi"
+			};
 		};
 
 		i2c1: i2c at 01c2b000 {
arch/arm/boot/dts/sun7i-a20-cubietruck.dts +13 -0
index f9dcb61..aab77f9 100644
@@ -38,6 +38,19 @@
 			pinctrl-names = "default";
 			pinctrl-0 = <&i2c0_pins_a>;
 			status = "okay";
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			axp: axp20x at 34 {
+				reg = <0x34>;
+				interrupt-parent = <&nmi_intc>;
+				interrupts = <0 8>;
+
+				axp,system-power-controller;
+
+				/include/ "x-powers-axp209.dtsi"
+			};
+
 		};
 
 		i2c1: i2c at 01c2b000 {
arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts +12 -0
index ead3013..a5fe5d0 100644
@@ -65,6 +65,18 @@
 			pinctrl-names = "default";
 			pinctrl-0 = <&i2c0_pins_a>;
 			status = "okay";
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			axp: axp20x at 34 {
+				reg = <0x34>;
+				interrupt-parent = <&nmi_intc>;
+				interrupts = <0 8>;
+
+				axp,system-power-controller;
+
+				/include/ "x-powers-axp209.dtsi"
+			};
 		};
 
 		i2c1: i2c at 01c2b000 {
#31 lore raw

PATCH v2 7/8 ARM: sun7i: dt: Add AXP209 support to various boards

Quoted 24 lines · Hans de Goede

Hi,

Thanks for your continued work on this.

Quoted 19 lines · Carlo Caione
---
 arch/arm/boot/dts/sun7i-a20-cubieboard2.dts     | 12 ++++++++++++
 arch/arm/boot/dts/sun7i-a20-cubietruck.dts      | 13 +++++++++++++
 arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts | 12 ++++++++++++
 3 files changed, 37 insertions(+)
arch/arm/boot/dts/sun7i-a20-cubieboard2.dts +3 -0
index 5c51cb8..9ad7da5 100644
@@ -53,6 +53,18 @@
 			pinctrl-names = "default";
 			pinctrl-0 = <&i2c0_pins_a>;
 			status = "okay";
+			#address-cells = <1>;
+			#size-cells = <0>;
+
Quoted 8 lines

arch/arm/boot/dts/sun7i-a20-cubieboard2.dts line 64

Quoted 6 lines
arch/arm/boot/dts/sun7i-a20-cubieboard2.dts +6 -0
+			axp: axp20x at 34 {
+				reg = <0x34>;
+				interrupt-parent = <&nmi_intc>;
+				interrupts = <0 8>;
+
+				axp,system-power-controller;

Shouldn't this be dropped now (all 3 of them) ?

Damn! Thank you for spotting it.
Fix coming.

Thanks,

Signature · 1 line
Carlo Caione
#32 lore raw

PATCH v2 8/8 ARM: sunxi: Add AXP20x support in defconfig

In reply to Carlo Caione
---
 arch/arm/configs/sunxi_defconfig | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/configs/sunxi_defconfig +4 -0
index 3e2259b..0cef101 100644
@@ -39,6 +39,8 @@ CONFIG_SUN4I_EMAC=y
 # CONFIG_NET_VENDOR_STMICRO is not set
 # CONFIG_NET_VENDOR_WIZNET is not set
 # CONFIG_WLAN is not set
+CONFIG_INPUT_MISC=y
+CONFIG_INPUT_AXP20X_PEK=y
 CONFIG_SERIAL_8250=y
 CONFIG_SERIAL_8250_CONSOLE=y
 CONFIG_SERIAL_8250_NR_UARTS=8
@@ -52,6 +54,7 @@ CONFIG_GPIO_SYSFS=y
 # CONFIG_HWMON is not set
 CONFIG_WATCHDOG=y
 CONFIG_SUNXI_WATCHDOG=y
+CONFIG_MFD_AXP20X=y
 # CONFIG_USB_SUPPORT is not set
 CONFIG_NEW_LEDS=y
 CONFIG_LEDS_CLASS=y
@@ -66,3 +69,4 @@ CONFIG_NFS_FS=y
 CONFIG_ROOT_NFS=y
 CONFIG_NLS=y
 CONFIG_PRINTK_TIME=y
+CONFIG_REGULATOR_AXP20X=y
Signature · 1 line
1.8.3.2
#33 lore raw

PATCH v2 8/8 ARM: sunxi: Add AXP20x support in defconfig

Quoted 4 lines · Carlo Caione
---
 arch/arm/configs/sunxi_defconfig | 4 ++++
 1 file changed, 4 insertions(+)

Could you add another patch doing the same with multi_v7 ?

Thanks!

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140318/685a8939/attachment.sig>