All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RESEND v6 0/6] mfd: axp20x: add AXP221 PMIC support
@ 2015-04-10  4:09 ` Chen-Yu Tsai
  0 siblings, 0 replies; 54+ messages in thread
From: Chen-Yu Tsai @ 2015-04-10  4:09 UTC (permalink / raw)
  To: Lee Jones, Samuel Ortiz, Mark Brown, Liam Girdwood, Rob Herring,
	Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala
  Cc: Chen-Yu Tsai, Maxime Ripard, Carlo Caione, linux-arm-kernel,
	devicetree, linux-kernel, linux-sunxi

Hi Lee,

This is a resend of the AXP221 PMIC series, rebased onto the latest
for-mfd-next.

Original changelog

Changes since v5:

    - Rebased onto mfd-for-next (ba867bc60a44)

    - Dropped dts patches

    - Removed double line spacing

Changes since v4:

  - Rebased onto v4.0-rc1 and axp20x bindings v10

  - Dropped regulator set registration patches

  - Group regmap ranges/tables by AXP variant

  - Fix AXP221 interrupt numbers to match datasheet

  - Handle AXP variants when setting DC-DC regulator work mode

  - Add "switch" type regulator DC1SW, which is a secondary output
    of DCDC1 with a separate on/off switch.

  - Add AXP221 to DT bindings


Regards
ChenYu

Boris BREZILLON (3):
  mfd: axp20x: add AXP22x PMIC support
  regulator: axp20x: prepare support for multiple AXP chip families
  regulator: axp20x: add support for AXP22X regulators

Chen-Yu Tsai (3):
  mfd: axp20x: update DT bindings with AXP22x compatibles
  mfd: axp20x: Add AXP22x regulator information to DT bindings
  mfd: axp20x: Enable AXP22X regulators

 Documentation/devicetree/bindings/mfd/axp20x.txt |  32 ++-
 drivers/mfd/axp20x.c                             | 100 ++++++++++
 drivers/regulator/axp20x-regulator.c             | 239 ++++++++++++++++++-----
 include/linux/mfd/axp20x.h                       |  86 ++++++++
 4 files changed, 405 insertions(+), 52 deletions(-)

-- 
2.1.4


^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH RESEND v6 0/6] mfd: axp20x: add AXP221 PMIC support
@ 2015-04-10  4:09 ` Chen-Yu Tsai
  0 siblings, 0 replies; 54+ messages in thread
From: Chen-Yu Tsai @ 2015-04-10  4:09 UTC (permalink / raw)
  To: Lee Jones, Samuel Ortiz, Mark Brown, Liam Girdwood, Rob Herring,
	Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala
  Cc: Chen-Yu Tsai, Maxime Ripard, Carlo Caione,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw

Hi Lee,

This is a resend of the AXP221 PMIC series, rebased onto the latest
for-mfd-next.

Original changelog

Changes since v5:

    - Rebased onto mfd-for-next (ba867bc60a44)

    - Dropped dts patches

    - Removed double line spacing

Changes since v4:

  - Rebased onto v4.0-rc1 and axp20x bindings v10

  - Dropped regulator set registration patches

  - Group regmap ranges/tables by AXP variant

  - Fix AXP221 interrupt numbers to match datasheet

  - Handle AXP variants when setting DC-DC regulator work mode

  - Add "switch" type regulator DC1SW, which is a secondary output
    of DCDC1 with a separate on/off switch.

  - Add AXP221 to DT bindings


Regards
ChenYu

Boris BREZILLON (3):
  mfd: axp20x: add AXP22x PMIC support
  regulator: axp20x: prepare support for multiple AXP chip families
  regulator: axp20x: add support for AXP22X regulators

Chen-Yu Tsai (3):
  mfd: axp20x: update DT bindings with AXP22x compatibles
  mfd: axp20x: Add AXP22x regulator information to DT bindings
  mfd: axp20x: Enable AXP22X regulators

 Documentation/devicetree/bindings/mfd/axp20x.txt |  32 ++-
 drivers/mfd/axp20x.c                             | 100 ++++++++++
 drivers/regulator/axp20x-regulator.c             | 239 ++++++++++++++++++-----
 include/linux/mfd/axp20x.h                       |  86 ++++++++
 4 files changed, 405 insertions(+), 52 deletions(-)

-- 
2.1.4

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH RESEND v6 0/6] mfd: axp20x: add AXP221 PMIC support
@ 2015-04-10  4:09 ` Chen-Yu Tsai
  0 siblings, 0 replies; 54+ messages in thread
From: Chen-Yu Tsai @ 2015-04-10  4:09 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Lee,

This is a resend of the AXP221 PMIC series, rebased onto the latest
for-mfd-next.

Original changelog

Changes since v5:

    - Rebased onto mfd-for-next (ba867bc60a44)

    - Dropped dts patches

    - Removed double line spacing

Changes since v4:

  - Rebased onto v4.0-rc1 and axp20x bindings v10

  - Dropped regulator set registration patches

  - Group regmap ranges/tables by AXP variant

  - Fix AXP221 interrupt numbers to match datasheet

  - Handle AXP variants when setting DC-DC regulator work mode

  - Add "switch" type regulator DC1SW, which is a secondary output
    of DCDC1 with a separate on/off switch.

  - Add AXP221 to DT bindings


Regards
ChenYu

Boris BREZILLON (3):
  mfd: axp20x: add AXP22x PMIC support
  regulator: axp20x: prepare support for multiple AXP chip families
  regulator: axp20x: add support for AXP22X regulators

Chen-Yu Tsai (3):
  mfd: axp20x: update DT bindings with AXP22x compatibles
  mfd: axp20x: Add AXP22x regulator information to DT bindings
  mfd: axp20x: Enable AXP22X regulators

 Documentation/devicetree/bindings/mfd/axp20x.txt |  32 ++-
 drivers/mfd/axp20x.c                             | 100 ++++++++++
 drivers/regulator/axp20x-regulator.c             | 239 ++++++++++++++++++-----
 include/linux/mfd/axp20x.h                       |  86 ++++++++
 4 files changed, 405 insertions(+), 52 deletions(-)

-- 
2.1.4

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH RESEND v6 1/6] mfd: axp20x: add AXP22x PMIC support
@ 2015-04-10  4:09   ` Chen-Yu Tsai
  0 siblings, 0 replies; 54+ messages in thread
From: Chen-Yu Tsai @ 2015-04-10  4:09 UTC (permalink / raw)
  To: Lee Jones, Samuel Ortiz, Mark Brown, Liam Girdwood, Rob Herring,
	Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala
  Cc: Boris BREZILLON, Maxime Ripard, Carlo Caione, linux-arm-kernel,
	devicetree, linux-kernel, linux-sunxi, Chen-Yu Tsai

From: Boris BREZILLON <boris.brezillon@free-electrons.com>

Add support for the AXP22x PMIC devices to the existing AXP20x driver.
This includes the AXP221 and AXP223, which are identical except for
the external data bus. Only AXP221 is added for now. AXP223 will be
added after it's Reduced Serial Bus (RSB) interface is supported.

AXP22x defines a new set of registers, power supplies and regulators,
but most of the API is similar to the AXP20x ones.

A new irq chip definition is used, even though the available interrupts
on AXP22x is a subset of those on AXP20x. This is done so the interrupt
numbers match those on the datasheet.

This patch only enables the interrupts, system power-off function, and PEK
sub-device. The regulator driver must first support different variants
before we enable it from the mfd driver.

Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
[wens@csie.org: fix interrupts and move regulators to separate patch]
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Acked-by: Lee Jones <lee.jones@linaro.org>
---

Hi Lee,

I've asked Mark about merging the regulator patches through the mfd tree
(in the 4th patch). If he agrees, could you take the whole series?

Thanks.

ChenYu

---
 drivers/mfd/axp20x.c       | 98 ++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/axp20x.h | 86 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 184 insertions(+)

diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
index d18029be6a78..cfbb7d7aead6 100644
--- a/drivers/mfd/axp20x.c
+++ b/drivers/mfd/axp20x.c
@@ -32,6 +32,7 @@
 static const char * const axp20x_model_names[] = {
 	"AXP202",
 	"AXP209",
+	"AXP221",
 	"AXP288",
 };
 
@@ -54,6 +55,25 @@ static const struct regmap_access_table axp20x_volatile_table = {
 	.n_yes_ranges	= ARRAY_SIZE(axp20x_volatile_ranges),
 };
 
+static const struct regmap_range axp22x_writeable_ranges[] = {
+	regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_IRQ5_STATE),
+	regmap_reg_range(AXP20X_DCDC_MODE, AXP22X_BATLOW_THRES1),
+};
+
+static const struct regmap_range axp22x_volatile_ranges[] = {
+	regmap_reg_range(AXP20X_IRQ1_EN, AXP20X_IRQ5_STATE),
+};
+
+static const struct regmap_access_table axp22x_writeable_table = {
+	.yes_ranges	= axp22x_writeable_ranges,
+	.n_yes_ranges	= ARRAY_SIZE(axp22x_writeable_ranges),
+};
+
+static const struct regmap_access_table axp22x_volatile_table = {
+	.yes_ranges	= axp22x_volatile_ranges,
+	.n_yes_ranges	= ARRAY_SIZE(axp22x_volatile_ranges),
+};
+
 static const struct regmap_range axp288_writeable_ranges[] = {
 	regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_IRQ6_STATE),
 	regmap_reg_range(AXP20X_DCDC_MODE, AXP288_FG_TUNE5),
@@ -87,6 +107,20 @@ static struct resource axp20x_pek_resources[] = {
 	},
 };
 
+static struct resource axp22x_pek_resources[] = {
+	{
+		.name   = "PEK_DBR",
+		.start  = AXP22X_IRQ_PEK_RIS_EDGE,
+		.end    = AXP22X_IRQ_PEK_RIS_EDGE,
+		.flags  = IORESOURCE_IRQ,
+	}, {
+		.name   = "PEK_DBF",
+		.start  = AXP22X_IRQ_PEK_FAL_EDGE,
+		.end    = AXP22X_IRQ_PEK_FAL_EDGE,
+		.flags  = IORESOURCE_IRQ,
+	},
+};
+
 static struct resource axp288_fuel_gauge_resources[] = {
 	{
 		.start = AXP288_IRQ_QWBTU,
@@ -129,6 +163,15 @@ static const struct regmap_config axp20x_regmap_config = {
 	.cache_type	= REGCACHE_RBTREE,
 };
 
+static const struct regmap_config axp22x_regmap_config = {
+	.reg_bits	= 8,
+	.val_bits	= 8,
+	.wr_table	= &axp22x_writeable_table,
+	.volatile_table	= &axp22x_volatile_table,
+	.max_register	= AXP22X_BATLOW_THRES1,
+	.cache_type	= REGCACHE_RBTREE,
+};
+
 static const struct regmap_config axp288_regmap_config = {
 	.reg_bits	= 8,
 	.val_bits	= 8,
@@ -181,6 +224,34 @@ static const struct regmap_irq axp20x_regmap_irqs[] = {
 	INIT_REGMAP_IRQ(AXP20X, GPIO0_INPUT,		4, 0),
 };
 
+static const struct regmap_irq axp22x_regmap_irqs[] = {
+	INIT_REGMAP_IRQ(AXP22X, ACIN_OVER_V,		0, 7),
+	INIT_REGMAP_IRQ(AXP22X, ACIN_PLUGIN,		0, 6),
+	INIT_REGMAP_IRQ(AXP22X, ACIN_REMOVAL,	        0, 5),
+	INIT_REGMAP_IRQ(AXP22X, VBUS_OVER_V,		0, 4),
+	INIT_REGMAP_IRQ(AXP22X, VBUS_PLUGIN,		0, 3),
+	INIT_REGMAP_IRQ(AXP22X, VBUS_REMOVAL,	        0, 2),
+	INIT_REGMAP_IRQ(AXP22X, VBUS_V_LOW,		0, 1),
+	INIT_REGMAP_IRQ(AXP22X, BATT_PLUGIN,		1, 7),
+	INIT_REGMAP_IRQ(AXP22X, BATT_REMOVAL,	        1, 6),
+	INIT_REGMAP_IRQ(AXP22X, BATT_ENT_ACT_MODE,	1, 5),
+	INIT_REGMAP_IRQ(AXP22X, BATT_EXIT_ACT_MODE,	1, 4),
+	INIT_REGMAP_IRQ(AXP22X, CHARG,		        1, 3),
+	INIT_REGMAP_IRQ(AXP22X, CHARG_DONE,		1, 2),
+	INIT_REGMAP_IRQ(AXP22X, BATT_TEMP_HIGH,	        1, 1),
+	INIT_REGMAP_IRQ(AXP22X, BATT_TEMP_LOW,	        1, 0),
+	INIT_REGMAP_IRQ(AXP22X, DIE_TEMP_HIGH,	        2, 7),
+	INIT_REGMAP_IRQ(AXP22X, PEK_SHORT,		2, 1),
+	INIT_REGMAP_IRQ(AXP22X, PEK_LONG,		2, 0),
+	INIT_REGMAP_IRQ(AXP22X, LOW_PWR_LVL1,	        3, 1),
+	INIT_REGMAP_IRQ(AXP22X, LOW_PWR_LVL2,	        3, 0),
+	INIT_REGMAP_IRQ(AXP22X, TIMER,		        4, 7),
+	INIT_REGMAP_IRQ(AXP22X, PEK_RIS_EDGE,	        4, 6),
+	INIT_REGMAP_IRQ(AXP22X, PEK_FAL_EDGE,	        4, 5),
+	INIT_REGMAP_IRQ(AXP22X, GPIO1_INPUT,		4, 1),
+	INIT_REGMAP_IRQ(AXP22X, GPIO0_INPUT,		4, 0),
+};
+
 /* some IRQs are compatible with axp20x models */
 static const struct regmap_irq axp288_regmap_irqs[] = {
 	INIT_REGMAP_IRQ(AXP288, VBUS_FALL,              0, 2),
@@ -224,6 +295,7 @@ static const struct regmap_irq axp288_regmap_irqs[] = {
 static const struct of_device_id axp20x_of_match[] = {
 	{ .compatible = "x-powers,axp202", .data = (void *) AXP202_ID },
 	{ .compatible = "x-powers,axp209", .data = (void *) AXP209_ID },
+	{ .compatible = "x-powers,axp221", .data = (void *) AXP221_ID },
 	{ },
 };
 MODULE_DEVICE_TABLE(of, axp20x_of_match);
@@ -258,6 +330,18 @@ static const struct regmap_irq_chip axp20x_regmap_irq_chip = {
 
 };
 
+static const struct regmap_irq_chip axp22x_regmap_irq_chip = {
+	.name			= "axp22x_irq_chip",
+	.status_base		= AXP20X_IRQ1_STATE,
+	.ack_base		= AXP20X_IRQ1_STATE,
+	.mask_base		= AXP20X_IRQ1_EN,
+	.mask_invert		= true,
+	.init_ack_masked	= true,
+	.irqs			= axp22x_regmap_irqs,
+	.num_irqs		= ARRAY_SIZE(axp22x_regmap_irqs),
+	.num_regs		= 5,
+};
+
 static const struct regmap_irq_chip axp288_regmap_irq_chip = {
 	.name			= "axp288_irq_chip",
 	.status_base		= AXP20X_IRQ1_STATE,
@@ -281,6 +365,14 @@ static struct mfd_cell axp20x_cells[] = {
 	},
 };
 
+static struct mfd_cell axp22x_cells[] = {
+	{
+		.name			= "axp20x-pek",
+		.num_resources		= ARRAY_SIZE(axp22x_pek_resources),
+		.resources		= axp22x_pek_resources,
+	},
+};
+
 static struct resource axp288_adc_resources[] = {
 	{
 		.name  = "GPADC",
@@ -426,6 +518,12 @@ static int axp20x_match_device(struct axp20x_dev *axp20x, struct device *dev)
 		axp20x->regmap_cfg = &axp20x_regmap_config;
 		axp20x->regmap_irq_chip = &axp20x_regmap_irq_chip;
 		break;
+	case AXP221_ID:
+		axp20x->nr_cells = ARRAY_SIZE(axp22x_cells);
+		axp20x->cells = axp22x_cells;
+		axp20x->regmap_cfg = &axp22x_regmap_config;
+		axp20x->regmap_irq_chip = &axp22x_regmap_irq_chip;
+		break;
 	case AXP288_ID:
 		axp20x->cells = axp288_cells;
 		axp20x->nr_cells = ARRAY_SIZE(axp288_cells);
diff --git a/include/linux/mfd/axp20x.h b/include/linux/mfd/axp20x.h
index dfabd6db7ddf..95568eb798c3 100644
--- a/include/linux/mfd/axp20x.h
+++ b/include/linux/mfd/axp20x.h
@@ -14,6 +14,7 @@
 enum {
 	AXP202_ID = 0,
 	AXP209_ID,
+	AXP221_ID,
 	AXP288_ID,
 	NR_AXP20X_VARIANTS,
 };
@@ -45,6 +46,28 @@ enum {
 #define AXP20X_V_LTF_DISCHRG		0x3c
 #define AXP20X_V_HTF_DISCHRG		0x3d
 
+#define AXP22X_PWR_OUT_CTRL1		0x10
+#define AXP22X_PWR_OUT_CTRL2		0x12
+#define AXP22X_PWR_OUT_CTRL3		0x13
+#define AXP22X_DLDO1_V_OUT		0x15
+#define AXP22X_DLDO2_V_OUT		0x16
+#define AXP22X_DLDO3_V_OUT		0x17
+#define AXP22X_DLDO4_V_OUT		0x18
+#define AXP22X_ELDO1_V_OUT		0x19
+#define AXP22X_ELDO2_V_OUT		0x1a
+#define AXP22X_ELDO3_V_OUT		0x1b
+#define AXP22X_DC5LDO_V_OUT		0x1c
+#define AXP22X_DCDC1_V_OUT		0x21
+#define AXP22X_DCDC2_V_OUT		0x22
+#define AXP22X_DCDC3_V_OUT		0x23
+#define AXP22X_DCDC4_V_OUT		0x24
+#define AXP22X_DCDC5_V_OUT		0x25
+#define AXP22X_DCDC23_V_RAMP_CTRL	0x27
+#define AXP22X_ALDO1_V_OUT		0x28
+#define AXP22X_ALDO2_V_OUT		0x29
+#define AXP22X_ALDO3_V_OUT		0x2a
+#define AXP22X_CHRG_CTRL3		0x35
+
 /* Interrupt */
 #define AXP20X_IRQ1_EN			0x40
 #define AXP20X_IRQ2_EN			0x41
@@ -100,6 +123,9 @@ enum {
 #define AXP20X_VBUS_MON			0x8b
 #define AXP20X_OVER_TMP			0x8f
 
+#define AXP22X_PWREN_CTRL1		0x8c
+#define AXP22X_PWREN_CTRL2		0x8d
+
 /* GPIO */
 #define AXP20X_GPIO0_CTRL		0x90
 #define AXP20X_LDO5_V_OUT		0x91
@@ -108,6 +134,11 @@ enum {
 #define AXP20X_GPIO20_SS		0x94
 #define AXP20X_GPIO3_CTRL		0x95
 
+#define AXP22X_LDO_IO0_V_OUT		0x91
+#define AXP22X_LDO_IO1_V_OUT		0x93
+#define AXP22X_GPIO_STATE		0x94
+#define AXP22X_GPIO_PULL_DOWN		0x95
+
 /* Battery */
 #define AXP20X_CHRG_CC_31_24		0xb0
 #define AXP20X_CHRG_CC_23_16		0xb1
@@ -120,6 +151,9 @@ enum {
 #define AXP20X_CC_CTRL			0xb8
 #define AXP20X_FG_RES			0xb9
 
+/* AXP22X specific registers */
+#define AXP22X_BATLOW_THRES1		0xe6
+
 /* AXP288 specific registers */
 #define AXP288_PMIC_ADC_H               0x56
 #define AXP288_PMIC_ADC_L               0x57
@@ -158,6 +192,30 @@ enum {
 	AXP20X_REG_ID_MAX,
 };
 
+enum {
+	AXP22X_DCDC1 = 0,
+	AXP22X_DCDC2,
+	AXP22X_DCDC3,
+	AXP22X_DCDC4,
+	AXP22X_DCDC5,
+	AXP22X_DC1SW,
+	AXP22X_DC5LDO,
+	AXP22X_ALDO1,
+	AXP22X_ALDO2,
+	AXP22X_ALDO3,
+	AXP22X_ELDO1,
+	AXP22X_ELDO2,
+	AXP22X_ELDO3,
+	AXP22X_DLDO1,
+	AXP22X_DLDO2,
+	AXP22X_DLDO3,
+	AXP22X_DLDO4,
+	AXP22X_RTC_LDO,
+	AXP22X_LDO_IO0,
+	AXP22X_LDO_IO1,
+	AXP22X_REG_ID_MAX,
+};
+
 /* IRQs */
 enum {
 	AXP20X_IRQ_ACIN_OVER_V = 1,
@@ -199,6 +257,34 @@ enum {
 	AXP20X_IRQ_GPIO0_INPUT,
 };
 
+enum axp22x_irqs {
+	AXP22X_IRQ_ACIN_OVER_V = 1,
+	AXP22X_IRQ_ACIN_PLUGIN,
+	AXP22X_IRQ_ACIN_REMOVAL,
+	AXP22X_IRQ_VBUS_OVER_V,
+	AXP22X_IRQ_VBUS_PLUGIN,
+	AXP22X_IRQ_VBUS_REMOVAL,
+	AXP22X_IRQ_VBUS_V_LOW,
+	AXP22X_IRQ_BATT_PLUGIN,
+	AXP22X_IRQ_BATT_REMOVAL,
+	AXP22X_IRQ_BATT_ENT_ACT_MODE,
+	AXP22X_IRQ_BATT_EXIT_ACT_MODE,
+	AXP22X_IRQ_CHARG,
+	AXP22X_IRQ_CHARG_DONE,
+	AXP22X_IRQ_BATT_TEMP_HIGH,
+	AXP22X_IRQ_BATT_TEMP_LOW,
+	AXP22X_IRQ_DIE_TEMP_HIGH,
+	AXP22X_IRQ_PEK_SHORT,
+	AXP22X_IRQ_PEK_LONG,
+	AXP22X_IRQ_LOW_PWR_LVL1,
+	AXP22X_IRQ_LOW_PWR_LVL2,
+	AXP22X_IRQ_TIMER,
+	AXP22X_IRQ_PEK_RIS_EDGE,
+	AXP22X_IRQ_PEK_FAL_EDGE,
+	AXP22X_IRQ_GPIO1_INPUT,
+	AXP22X_IRQ_GPIO0_INPUT,
+};
+
 enum axp288_irqs {
 	AXP288_IRQ_VBUS_FALL     = 2,
 	AXP288_IRQ_VBUS_RISE,
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH RESEND v6 1/6] mfd: axp20x: add AXP22x PMIC support
@ 2015-04-10  4:09   ` Chen-Yu Tsai
  0 siblings, 0 replies; 54+ messages in thread
From: Chen-Yu Tsai @ 2015-04-10  4:09 UTC (permalink / raw)
  To: Lee Jones, Samuel Ortiz, Mark Brown, Liam Girdwood, Rob Herring,
	Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala
  Cc: Boris BREZILLON, Maxime Ripard, Carlo Caione,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw, Chen-Yu Tsai

From: Boris BREZILLON <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>

Add support for the AXP22x PMIC devices to the existing AXP20x driver.
This includes the AXP221 and AXP223, which are identical except for
the external data bus. Only AXP221 is added for now. AXP223 will be
added after it's Reduced Serial Bus (RSB) interface is supported.

AXP22x defines a new set of registers, power supplies and regulators,
but most of the API is similar to the AXP20x ones.

A new irq chip definition is used, even though the available interrupts
on AXP22x is a subset of those on AXP20x. This is done so the interrupt
numbers match those on the datasheet.

This patch only enables the interrupts, system power-off function, and PEK
sub-device. The regulator driver must first support different variants
before we enable it from the mfd driver.

Signed-off-by: Boris BREZILLON <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
[wens-jdAy2FN1RRM@public.gmane.org: fix interrupts and move regulators to separate patch]
Signed-off-by: Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>
Acked-by: Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---

Hi Lee,

I've asked Mark about merging the regulator patches through the mfd tree
(in the 4th patch). If he agrees, could you take the whole series?

Thanks.

ChenYu

---
 drivers/mfd/axp20x.c       | 98 ++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/axp20x.h | 86 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 184 insertions(+)

diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
index d18029be6a78..cfbb7d7aead6 100644
--- a/drivers/mfd/axp20x.c
+++ b/drivers/mfd/axp20x.c
@@ -32,6 +32,7 @@
 static const char * const axp20x_model_names[] = {
 	"AXP202",
 	"AXP209",
+	"AXP221",
 	"AXP288",
 };
 
@@ -54,6 +55,25 @@ static const struct regmap_access_table axp20x_volatile_table = {
 	.n_yes_ranges	= ARRAY_SIZE(axp20x_volatile_ranges),
 };
 
+static const struct regmap_range axp22x_writeable_ranges[] = {
+	regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_IRQ5_STATE),
+	regmap_reg_range(AXP20X_DCDC_MODE, AXP22X_BATLOW_THRES1),
+};
+
+static const struct regmap_range axp22x_volatile_ranges[] = {
+	regmap_reg_range(AXP20X_IRQ1_EN, AXP20X_IRQ5_STATE),
+};
+
+static const struct regmap_access_table axp22x_writeable_table = {
+	.yes_ranges	= axp22x_writeable_ranges,
+	.n_yes_ranges	= ARRAY_SIZE(axp22x_writeable_ranges),
+};
+
+static const struct regmap_access_table axp22x_volatile_table = {
+	.yes_ranges	= axp22x_volatile_ranges,
+	.n_yes_ranges	= ARRAY_SIZE(axp22x_volatile_ranges),
+};
+
 static const struct regmap_range axp288_writeable_ranges[] = {
 	regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_IRQ6_STATE),
 	regmap_reg_range(AXP20X_DCDC_MODE, AXP288_FG_TUNE5),
@@ -87,6 +107,20 @@ static struct resource axp20x_pek_resources[] = {
 	},
 };
 
+static struct resource axp22x_pek_resources[] = {
+	{
+		.name   = "PEK_DBR",
+		.start  = AXP22X_IRQ_PEK_RIS_EDGE,
+		.end    = AXP22X_IRQ_PEK_RIS_EDGE,
+		.flags  = IORESOURCE_IRQ,
+	}, {
+		.name   = "PEK_DBF",
+		.start  = AXP22X_IRQ_PEK_FAL_EDGE,
+		.end    = AXP22X_IRQ_PEK_FAL_EDGE,
+		.flags  = IORESOURCE_IRQ,
+	},
+};
+
 static struct resource axp288_fuel_gauge_resources[] = {
 	{
 		.start = AXP288_IRQ_QWBTU,
@@ -129,6 +163,15 @@ static const struct regmap_config axp20x_regmap_config = {
 	.cache_type	= REGCACHE_RBTREE,
 };
 
+static const struct regmap_config axp22x_regmap_config = {
+	.reg_bits	= 8,
+	.val_bits	= 8,
+	.wr_table	= &axp22x_writeable_table,
+	.volatile_table	= &axp22x_volatile_table,
+	.max_register	= AXP22X_BATLOW_THRES1,
+	.cache_type	= REGCACHE_RBTREE,
+};
+
 static const struct regmap_config axp288_regmap_config = {
 	.reg_bits	= 8,
 	.val_bits	= 8,
@@ -181,6 +224,34 @@ static const struct regmap_irq axp20x_regmap_irqs[] = {
 	INIT_REGMAP_IRQ(AXP20X, GPIO0_INPUT,		4, 0),
 };
 
+static const struct regmap_irq axp22x_regmap_irqs[] = {
+	INIT_REGMAP_IRQ(AXP22X, ACIN_OVER_V,		0, 7),
+	INIT_REGMAP_IRQ(AXP22X, ACIN_PLUGIN,		0, 6),
+	INIT_REGMAP_IRQ(AXP22X, ACIN_REMOVAL,	        0, 5),
+	INIT_REGMAP_IRQ(AXP22X, VBUS_OVER_V,		0, 4),
+	INIT_REGMAP_IRQ(AXP22X, VBUS_PLUGIN,		0, 3),
+	INIT_REGMAP_IRQ(AXP22X, VBUS_REMOVAL,	        0, 2),
+	INIT_REGMAP_IRQ(AXP22X, VBUS_V_LOW,		0, 1),
+	INIT_REGMAP_IRQ(AXP22X, BATT_PLUGIN,		1, 7),
+	INIT_REGMAP_IRQ(AXP22X, BATT_REMOVAL,	        1, 6),
+	INIT_REGMAP_IRQ(AXP22X, BATT_ENT_ACT_MODE,	1, 5),
+	INIT_REGMAP_IRQ(AXP22X, BATT_EXIT_ACT_MODE,	1, 4),
+	INIT_REGMAP_IRQ(AXP22X, CHARG,		        1, 3),
+	INIT_REGMAP_IRQ(AXP22X, CHARG_DONE,		1, 2),
+	INIT_REGMAP_IRQ(AXP22X, BATT_TEMP_HIGH,	        1, 1),
+	INIT_REGMAP_IRQ(AXP22X, BATT_TEMP_LOW,	        1, 0),
+	INIT_REGMAP_IRQ(AXP22X, DIE_TEMP_HIGH,	        2, 7),
+	INIT_REGMAP_IRQ(AXP22X, PEK_SHORT,		2, 1),
+	INIT_REGMAP_IRQ(AXP22X, PEK_LONG,		2, 0),
+	INIT_REGMAP_IRQ(AXP22X, LOW_PWR_LVL1,	        3, 1),
+	INIT_REGMAP_IRQ(AXP22X, LOW_PWR_LVL2,	        3, 0),
+	INIT_REGMAP_IRQ(AXP22X, TIMER,		        4, 7),
+	INIT_REGMAP_IRQ(AXP22X, PEK_RIS_EDGE,	        4, 6),
+	INIT_REGMAP_IRQ(AXP22X, PEK_FAL_EDGE,	        4, 5),
+	INIT_REGMAP_IRQ(AXP22X, GPIO1_INPUT,		4, 1),
+	INIT_REGMAP_IRQ(AXP22X, GPIO0_INPUT,		4, 0),
+};
+
 /* some IRQs are compatible with axp20x models */
 static const struct regmap_irq axp288_regmap_irqs[] = {
 	INIT_REGMAP_IRQ(AXP288, VBUS_FALL,              0, 2),
@@ -224,6 +295,7 @@ static const struct regmap_irq axp288_regmap_irqs[] = {
 static const struct of_device_id axp20x_of_match[] = {
 	{ .compatible = "x-powers,axp202", .data = (void *) AXP202_ID },
 	{ .compatible = "x-powers,axp209", .data = (void *) AXP209_ID },
+	{ .compatible = "x-powers,axp221", .data = (void *) AXP221_ID },
 	{ },
 };
 MODULE_DEVICE_TABLE(of, axp20x_of_match);
@@ -258,6 +330,18 @@ static const struct regmap_irq_chip axp20x_regmap_irq_chip = {
 
 };
 
+static const struct regmap_irq_chip axp22x_regmap_irq_chip = {
+	.name			= "axp22x_irq_chip",
+	.status_base		= AXP20X_IRQ1_STATE,
+	.ack_base		= AXP20X_IRQ1_STATE,
+	.mask_base		= AXP20X_IRQ1_EN,
+	.mask_invert		= true,
+	.init_ack_masked	= true,
+	.irqs			= axp22x_regmap_irqs,
+	.num_irqs		= ARRAY_SIZE(axp22x_regmap_irqs),
+	.num_regs		= 5,
+};
+
 static const struct regmap_irq_chip axp288_regmap_irq_chip = {
 	.name			= "axp288_irq_chip",
 	.status_base		= AXP20X_IRQ1_STATE,
@@ -281,6 +365,14 @@ static struct mfd_cell axp20x_cells[] = {
 	},
 };
 
+static struct mfd_cell axp22x_cells[] = {
+	{
+		.name			= "axp20x-pek",
+		.num_resources		= ARRAY_SIZE(axp22x_pek_resources),
+		.resources		= axp22x_pek_resources,
+	},
+};
+
 static struct resource axp288_adc_resources[] = {
 	{
 		.name  = "GPADC",
@@ -426,6 +518,12 @@ static int axp20x_match_device(struct axp20x_dev *axp20x, struct device *dev)
 		axp20x->regmap_cfg = &axp20x_regmap_config;
 		axp20x->regmap_irq_chip = &axp20x_regmap_irq_chip;
 		break;
+	case AXP221_ID:
+		axp20x->nr_cells = ARRAY_SIZE(axp22x_cells);
+		axp20x->cells = axp22x_cells;
+		axp20x->regmap_cfg = &axp22x_regmap_config;
+		axp20x->regmap_irq_chip = &axp22x_regmap_irq_chip;
+		break;
 	case AXP288_ID:
 		axp20x->cells = axp288_cells;
 		axp20x->nr_cells = ARRAY_SIZE(axp288_cells);
diff --git a/include/linux/mfd/axp20x.h b/include/linux/mfd/axp20x.h
index dfabd6db7ddf..95568eb798c3 100644
--- a/include/linux/mfd/axp20x.h
+++ b/include/linux/mfd/axp20x.h
@@ -14,6 +14,7 @@
 enum {
 	AXP202_ID = 0,
 	AXP209_ID,
+	AXP221_ID,
 	AXP288_ID,
 	NR_AXP20X_VARIANTS,
 };
@@ -45,6 +46,28 @@ enum {
 #define AXP20X_V_LTF_DISCHRG		0x3c
 #define AXP20X_V_HTF_DISCHRG		0x3d
 
+#define AXP22X_PWR_OUT_CTRL1		0x10
+#define AXP22X_PWR_OUT_CTRL2		0x12
+#define AXP22X_PWR_OUT_CTRL3		0x13
+#define AXP22X_DLDO1_V_OUT		0x15
+#define AXP22X_DLDO2_V_OUT		0x16
+#define AXP22X_DLDO3_V_OUT		0x17
+#define AXP22X_DLDO4_V_OUT		0x18
+#define AXP22X_ELDO1_V_OUT		0x19
+#define AXP22X_ELDO2_V_OUT		0x1a
+#define AXP22X_ELDO3_V_OUT		0x1b
+#define AXP22X_DC5LDO_V_OUT		0x1c
+#define AXP22X_DCDC1_V_OUT		0x21
+#define AXP22X_DCDC2_V_OUT		0x22
+#define AXP22X_DCDC3_V_OUT		0x23
+#define AXP22X_DCDC4_V_OUT		0x24
+#define AXP22X_DCDC5_V_OUT		0x25
+#define AXP22X_DCDC23_V_RAMP_CTRL	0x27
+#define AXP22X_ALDO1_V_OUT		0x28
+#define AXP22X_ALDO2_V_OUT		0x29
+#define AXP22X_ALDO3_V_OUT		0x2a
+#define AXP22X_CHRG_CTRL3		0x35
+
 /* Interrupt */
 #define AXP20X_IRQ1_EN			0x40
 #define AXP20X_IRQ2_EN			0x41
@@ -100,6 +123,9 @@ enum {
 #define AXP20X_VBUS_MON			0x8b
 #define AXP20X_OVER_TMP			0x8f
 
+#define AXP22X_PWREN_CTRL1		0x8c
+#define AXP22X_PWREN_CTRL2		0x8d
+
 /* GPIO */
 #define AXP20X_GPIO0_CTRL		0x90
 #define AXP20X_LDO5_V_OUT		0x91
@@ -108,6 +134,11 @@ enum {
 #define AXP20X_GPIO20_SS		0x94
 #define AXP20X_GPIO3_CTRL		0x95
 
+#define AXP22X_LDO_IO0_V_OUT		0x91
+#define AXP22X_LDO_IO1_V_OUT		0x93
+#define AXP22X_GPIO_STATE		0x94
+#define AXP22X_GPIO_PULL_DOWN		0x95
+
 /* Battery */
 #define AXP20X_CHRG_CC_31_24		0xb0
 #define AXP20X_CHRG_CC_23_16		0xb1
@@ -120,6 +151,9 @@ enum {
 #define AXP20X_CC_CTRL			0xb8
 #define AXP20X_FG_RES			0xb9
 
+/* AXP22X specific registers */
+#define AXP22X_BATLOW_THRES1		0xe6
+
 /* AXP288 specific registers */
 #define AXP288_PMIC_ADC_H               0x56
 #define AXP288_PMIC_ADC_L               0x57
@@ -158,6 +192,30 @@ enum {
 	AXP20X_REG_ID_MAX,
 };
 
+enum {
+	AXP22X_DCDC1 = 0,
+	AXP22X_DCDC2,
+	AXP22X_DCDC3,
+	AXP22X_DCDC4,
+	AXP22X_DCDC5,
+	AXP22X_DC1SW,
+	AXP22X_DC5LDO,
+	AXP22X_ALDO1,
+	AXP22X_ALDO2,
+	AXP22X_ALDO3,
+	AXP22X_ELDO1,
+	AXP22X_ELDO2,
+	AXP22X_ELDO3,
+	AXP22X_DLDO1,
+	AXP22X_DLDO2,
+	AXP22X_DLDO3,
+	AXP22X_DLDO4,
+	AXP22X_RTC_LDO,
+	AXP22X_LDO_IO0,
+	AXP22X_LDO_IO1,
+	AXP22X_REG_ID_MAX,
+};
+
 /* IRQs */
 enum {
 	AXP20X_IRQ_ACIN_OVER_V = 1,
@@ -199,6 +257,34 @@ enum {
 	AXP20X_IRQ_GPIO0_INPUT,
 };
 
+enum axp22x_irqs {
+	AXP22X_IRQ_ACIN_OVER_V = 1,
+	AXP22X_IRQ_ACIN_PLUGIN,
+	AXP22X_IRQ_ACIN_REMOVAL,
+	AXP22X_IRQ_VBUS_OVER_V,
+	AXP22X_IRQ_VBUS_PLUGIN,
+	AXP22X_IRQ_VBUS_REMOVAL,
+	AXP22X_IRQ_VBUS_V_LOW,
+	AXP22X_IRQ_BATT_PLUGIN,
+	AXP22X_IRQ_BATT_REMOVAL,
+	AXP22X_IRQ_BATT_ENT_ACT_MODE,
+	AXP22X_IRQ_BATT_EXIT_ACT_MODE,
+	AXP22X_IRQ_CHARG,
+	AXP22X_IRQ_CHARG_DONE,
+	AXP22X_IRQ_BATT_TEMP_HIGH,
+	AXP22X_IRQ_BATT_TEMP_LOW,
+	AXP22X_IRQ_DIE_TEMP_HIGH,
+	AXP22X_IRQ_PEK_SHORT,
+	AXP22X_IRQ_PEK_LONG,
+	AXP22X_IRQ_LOW_PWR_LVL1,
+	AXP22X_IRQ_LOW_PWR_LVL2,
+	AXP22X_IRQ_TIMER,
+	AXP22X_IRQ_PEK_RIS_EDGE,
+	AXP22X_IRQ_PEK_FAL_EDGE,
+	AXP22X_IRQ_GPIO1_INPUT,
+	AXP22X_IRQ_GPIO0_INPUT,
+};
+
 enum axp288_irqs {
 	AXP288_IRQ_VBUS_FALL     = 2,
 	AXP288_IRQ_VBUS_RISE,
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH RESEND v6 1/6] mfd: axp20x: add AXP22x PMIC support
@ 2015-04-10  4:09   ` Chen-Yu Tsai
  0 siblings, 0 replies; 54+ messages in thread
From: Chen-Yu Tsai @ 2015-04-10  4:09 UTC (permalink / raw)
  To: linux-arm-kernel

From: Boris BREZILLON <boris.brezillon@free-electrons.com>

Add support for the AXP22x PMIC devices to the existing AXP20x driver.
This includes the AXP221 and AXP223, which are identical except for
the external data bus. Only AXP221 is added for now. AXP223 will be
added after it's Reduced Serial Bus (RSB) interface is supported.

AXP22x defines a new set of registers, power supplies and regulators,
but most of the API is similar to the AXP20x ones.

A new irq chip definition is used, even though the available interrupts
on AXP22x is a subset of those on AXP20x. This is done so the interrupt
numbers match those on the datasheet.

This patch only enables the interrupts, system power-off function, and PEK
sub-device. The regulator driver must first support different variants
before we enable it from the mfd driver.

Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
[wens at csie.org: fix interrupts and move regulators to separate patch]
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Acked-by: Lee Jones <lee.jones@linaro.org>
---

Hi Lee,

I've asked Mark about merging the regulator patches through the mfd tree
(in the 4th patch). If he agrees, could you take the whole series?

Thanks.

ChenYu

---
 drivers/mfd/axp20x.c       | 98 ++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/axp20x.h | 86 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 184 insertions(+)

diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
index d18029be6a78..cfbb7d7aead6 100644
--- a/drivers/mfd/axp20x.c
+++ b/drivers/mfd/axp20x.c
@@ -32,6 +32,7 @@
 static const char * const axp20x_model_names[] = {
 	"AXP202",
 	"AXP209",
+	"AXP221",
 	"AXP288",
 };
 
@@ -54,6 +55,25 @@ static const struct regmap_access_table axp20x_volatile_table = {
 	.n_yes_ranges	= ARRAY_SIZE(axp20x_volatile_ranges),
 };
 
+static const struct regmap_range axp22x_writeable_ranges[] = {
+	regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_IRQ5_STATE),
+	regmap_reg_range(AXP20X_DCDC_MODE, AXP22X_BATLOW_THRES1),
+};
+
+static const struct regmap_range axp22x_volatile_ranges[] = {
+	regmap_reg_range(AXP20X_IRQ1_EN, AXP20X_IRQ5_STATE),
+};
+
+static const struct regmap_access_table axp22x_writeable_table = {
+	.yes_ranges	= axp22x_writeable_ranges,
+	.n_yes_ranges	= ARRAY_SIZE(axp22x_writeable_ranges),
+};
+
+static const struct regmap_access_table axp22x_volatile_table = {
+	.yes_ranges	= axp22x_volatile_ranges,
+	.n_yes_ranges	= ARRAY_SIZE(axp22x_volatile_ranges),
+};
+
 static const struct regmap_range axp288_writeable_ranges[] = {
 	regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_IRQ6_STATE),
 	regmap_reg_range(AXP20X_DCDC_MODE, AXP288_FG_TUNE5),
@@ -87,6 +107,20 @@ static struct resource axp20x_pek_resources[] = {
 	},
 };
 
+static struct resource axp22x_pek_resources[] = {
+	{
+		.name   = "PEK_DBR",
+		.start  = AXP22X_IRQ_PEK_RIS_EDGE,
+		.end    = AXP22X_IRQ_PEK_RIS_EDGE,
+		.flags  = IORESOURCE_IRQ,
+	}, {
+		.name   = "PEK_DBF",
+		.start  = AXP22X_IRQ_PEK_FAL_EDGE,
+		.end    = AXP22X_IRQ_PEK_FAL_EDGE,
+		.flags  = IORESOURCE_IRQ,
+	},
+};
+
 static struct resource axp288_fuel_gauge_resources[] = {
 	{
 		.start = AXP288_IRQ_QWBTU,
@@ -129,6 +163,15 @@ static const struct regmap_config axp20x_regmap_config = {
 	.cache_type	= REGCACHE_RBTREE,
 };
 
+static const struct regmap_config axp22x_regmap_config = {
+	.reg_bits	= 8,
+	.val_bits	= 8,
+	.wr_table	= &axp22x_writeable_table,
+	.volatile_table	= &axp22x_volatile_table,
+	.max_register	= AXP22X_BATLOW_THRES1,
+	.cache_type	= REGCACHE_RBTREE,
+};
+
 static const struct regmap_config axp288_regmap_config = {
 	.reg_bits	= 8,
 	.val_bits	= 8,
@@ -181,6 +224,34 @@ static const struct regmap_irq axp20x_regmap_irqs[] = {
 	INIT_REGMAP_IRQ(AXP20X, GPIO0_INPUT,		4, 0),
 };
 
+static const struct regmap_irq axp22x_regmap_irqs[] = {
+	INIT_REGMAP_IRQ(AXP22X, ACIN_OVER_V,		0, 7),
+	INIT_REGMAP_IRQ(AXP22X, ACIN_PLUGIN,		0, 6),
+	INIT_REGMAP_IRQ(AXP22X, ACIN_REMOVAL,	        0, 5),
+	INIT_REGMAP_IRQ(AXP22X, VBUS_OVER_V,		0, 4),
+	INIT_REGMAP_IRQ(AXP22X, VBUS_PLUGIN,		0, 3),
+	INIT_REGMAP_IRQ(AXP22X, VBUS_REMOVAL,	        0, 2),
+	INIT_REGMAP_IRQ(AXP22X, VBUS_V_LOW,		0, 1),
+	INIT_REGMAP_IRQ(AXP22X, BATT_PLUGIN,		1, 7),
+	INIT_REGMAP_IRQ(AXP22X, BATT_REMOVAL,	        1, 6),
+	INIT_REGMAP_IRQ(AXP22X, BATT_ENT_ACT_MODE,	1, 5),
+	INIT_REGMAP_IRQ(AXP22X, BATT_EXIT_ACT_MODE,	1, 4),
+	INIT_REGMAP_IRQ(AXP22X, CHARG,		        1, 3),
+	INIT_REGMAP_IRQ(AXP22X, CHARG_DONE,		1, 2),
+	INIT_REGMAP_IRQ(AXP22X, BATT_TEMP_HIGH,	        1, 1),
+	INIT_REGMAP_IRQ(AXP22X, BATT_TEMP_LOW,	        1, 0),
+	INIT_REGMAP_IRQ(AXP22X, DIE_TEMP_HIGH,	        2, 7),
+	INIT_REGMAP_IRQ(AXP22X, PEK_SHORT,		2, 1),
+	INIT_REGMAP_IRQ(AXP22X, PEK_LONG,		2, 0),
+	INIT_REGMAP_IRQ(AXP22X, LOW_PWR_LVL1,	        3, 1),
+	INIT_REGMAP_IRQ(AXP22X, LOW_PWR_LVL2,	        3, 0),
+	INIT_REGMAP_IRQ(AXP22X, TIMER,		        4, 7),
+	INIT_REGMAP_IRQ(AXP22X, PEK_RIS_EDGE,	        4, 6),
+	INIT_REGMAP_IRQ(AXP22X, PEK_FAL_EDGE,	        4, 5),
+	INIT_REGMAP_IRQ(AXP22X, GPIO1_INPUT,		4, 1),
+	INIT_REGMAP_IRQ(AXP22X, GPIO0_INPUT,		4, 0),
+};
+
 /* some IRQs are compatible with axp20x models */
 static const struct regmap_irq axp288_regmap_irqs[] = {
 	INIT_REGMAP_IRQ(AXP288, VBUS_FALL,              0, 2),
@@ -224,6 +295,7 @@ static const struct regmap_irq axp288_regmap_irqs[] = {
 static const struct of_device_id axp20x_of_match[] = {
 	{ .compatible = "x-powers,axp202", .data = (void *) AXP202_ID },
 	{ .compatible = "x-powers,axp209", .data = (void *) AXP209_ID },
+	{ .compatible = "x-powers,axp221", .data = (void *) AXP221_ID },
 	{ },
 };
 MODULE_DEVICE_TABLE(of, axp20x_of_match);
@@ -258,6 +330,18 @@ static const struct regmap_irq_chip axp20x_regmap_irq_chip = {
 
 };
 
+static const struct regmap_irq_chip axp22x_regmap_irq_chip = {
+	.name			= "axp22x_irq_chip",
+	.status_base		= AXP20X_IRQ1_STATE,
+	.ack_base		= AXP20X_IRQ1_STATE,
+	.mask_base		= AXP20X_IRQ1_EN,
+	.mask_invert		= true,
+	.init_ack_masked	= true,
+	.irqs			= axp22x_regmap_irqs,
+	.num_irqs		= ARRAY_SIZE(axp22x_regmap_irqs),
+	.num_regs		= 5,
+};
+
 static const struct regmap_irq_chip axp288_regmap_irq_chip = {
 	.name			= "axp288_irq_chip",
 	.status_base		= AXP20X_IRQ1_STATE,
@@ -281,6 +365,14 @@ static struct mfd_cell axp20x_cells[] = {
 	},
 };
 
+static struct mfd_cell axp22x_cells[] = {
+	{
+		.name			= "axp20x-pek",
+		.num_resources		= ARRAY_SIZE(axp22x_pek_resources),
+		.resources		= axp22x_pek_resources,
+	},
+};
+
 static struct resource axp288_adc_resources[] = {
 	{
 		.name  = "GPADC",
@@ -426,6 +518,12 @@ static int axp20x_match_device(struct axp20x_dev *axp20x, struct device *dev)
 		axp20x->regmap_cfg = &axp20x_regmap_config;
 		axp20x->regmap_irq_chip = &axp20x_regmap_irq_chip;
 		break;
+	case AXP221_ID:
+		axp20x->nr_cells = ARRAY_SIZE(axp22x_cells);
+		axp20x->cells = axp22x_cells;
+		axp20x->regmap_cfg = &axp22x_regmap_config;
+		axp20x->regmap_irq_chip = &axp22x_regmap_irq_chip;
+		break;
 	case AXP288_ID:
 		axp20x->cells = axp288_cells;
 		axp20x->nr_cells = ARRAY_SIZE(axp288_cells);
diff --git a/include/linux/mfd/axp20x.h b/include/linux/mfd/axp20x.h
index dfabd6db7ddf..95568eb798c3 100644
--- a/include/linux/mfd/axp20x.h
+++ b/include/linux/mfd/axp20x.h
@@ -14,6 +14,7 @@
 enum {
 	AXP202_ID = 0,
 	AXP209_ID,
+	AXP221_ID,
 	AXP288_ID,
 	NR_AXP20X_VARIANTS,
 };
@@ -45,6 +46,28 @@ enum {
 #define AXP20X_V_LTF_DISCHRG		0x3c
 #define AXP20X_V_HTF_DISCHRG		0x3d
 
+#define AXP22X_PWR_OUT_CTRL1		0x10
+#define AXP22X_PWR_OUT_CTRL2		0x12
+#define AXP22X_PWR_OUT_CTRL3		0x13
+#define AXP22X_DLDO1_V_OUT		0x15
+#define AXP22X_DLDO2_V_OUT		0x16
+#define AXP22X_DLDO3_V_OUT		0x17
+#define AXP22X_DLDO4_V_OUT		0x18
+#define AXP22X_ELDO1_V_OUT		0x19
+#define AXP22X_ELDO2_V_OUT		0x1a
+#define AXP22X_ELDO3_V_OUT		0x1b
+#define AXP22X_DC5LDO_V_OUT		0x1c
+#define AXP22X_DCDC1_V_OUT		0x21
+#define AXP22X_DCDC2_V_OUT		0x22
+#define AXP22X_DCDC3_V_OUT		0x23
+#define AXP22X_DCDC4_V_OUT		0x24
+#define AXP22X_DCDC5_V_OUT		0x25
+#define AXP22X_DCDC23_V_RAMP_CTRL	0x27
+#define AXP22X_ALDO1_V_OUT		0x28
+#define AXP22X_ALDO2_V_OUT		0x29
+#define AXP22X_ALDO3_V_OUT		0x2a
+#define AXP22X_CHRG_CTRL3		0x35
+
 /* Interrupt */
 #define AXP20X_IRQ1_EN			0x40
 #define AXP20X_IRQ2_EN			0x41
@@ -100,6 +123,9 @@ enum {
 #define AXP20X_VBUS_MON			0x8b
 #define AXP20X_OVER_TMP			0x8f
 
+#define AXP22X_PWREN_CTRL1		0x8c
+#define AXP22X_PWREN_CTRL2		0x8d
+
 /* GPIO */
 #define AXP20X_GPIO0_CTRL		0x90
 #define AXP20X_LDO5_V_OUT		0x91
@@ -108,6 +134,11 @@ enum {
 #define AXP20X_GPIO20_SS		0x94
 #define AXP20X_GPIO3_CTRL		0x95
 
+#define AXP22X_LDO_IO0_V_OUT		0x91
+#define AXP22X_LDO_IO1_V_OUT		0x93
+#define AXP22X_GPIO_STATE		0x94
+#define AXP22X_GPIO_PULL_DOWN		0x95
+
 /* Battery */
 #define AXP20X_CHRG_CC_31_24		0xb0
 #define AXP20X_CHRG_CC_23_16		0xb1
@@ -120,6 +151,9 @@ enum {
 #define AXP20X_CC_CTRL			0xb8
 #define AXP20X_FG_RES			0xb9
 
+/* AXP22X specific registers */
+#define AXP22X_BATLOW_THRES1		0xe6
+
 /* AXP288 specific registers */
 #define AXP288_PMIC_ADC_H               0x56
 #define AXP288_PMIC_ADC_L               0x57
@@ -158,6 +192,30 @@ enum {
 	AXP20X_REG_ID_MAX,
 };
 
+enum {
+	AXP22X_DCDC1 = 0,
+	AXP22X_DCDC2,
+	AXP22X_DCDC3,
+	AXP22X_DCDC4,
+	AXP22X_DCDC5,
+	AXP22X_DC1SW,
+	AXP22X_DC5LDO,
+	AXP22X_ALDO1,
+	AXP22X_ALDO2,
+	AXP22X_ALDO3,
+	AXP22X_ELDO1,
+	AXP22X_ELDO2,
+	AXP22X_ELDO3,
+	AXP22X_DLDO1,
+	AXP22X_DLDO2,
+	AXP22X_DLDO3,
+	AXP22X_DLDO4,
+	AXP22X_RTC_LDO,
+	AXP22X_LDO_IO0,
+	AXP22X_LDO_IO1,
+	AXP22X_REG_ID_MAX,
+};
+
 /* IRQs */
 enum {
 	AXP20X_IRQ_ACIN_OVER_V = 1,
@@ -199,6 +257,34 @@ enum {
 	AXP20X_IRQ_GPIO0_INPUT,
 };
 
+enum axp22x_irqs {
+	AXP22X_IRQ_ACIN_OVER_V = 1,
+	AXP22X_IRQ_ACIN_PLUGIN,
+	AXP22X_IRQ_ACIN_REMOVAL,
+	AXP22X_IRQ_VBUS_OVER_V,
+	AXP22X_IRQ_VBUS_PLUGIN,
+	AXP22X_IRQ_VBUS_REMOVAL,
+	AXP22X_IRQ_VBUS_V_LOW,
+	AXP22X_IRQ_BATT_PLUGIN,
+	AXP22X_IRQ_BATT_REMOVAL,
+	AXP22X_IRQ_BATT_ENT_ACT_MODE,
+	AXP22X_IRQ_BATT_EXIT_ACT_MODE,
+	AXP22X_IRQ_CHARG,
+	AXP22X_IRQ_CHARG_DONE,
+	AXP22X_IRQ_BATT_TEMP_HIGH,
+	AXP22X_IRQ_BATT_TEMP_LOW,
+	AXP22X_IRQ_DIE_TEMP_HIGH,
+	AXP22X_IRQ_PEK_SHORT,
+	AXP22X_IRQ_PEK_LONG,
+	AXP22X_IRQ_LOW_PWR_LVL1,
+	AXP22X_IRQ_LOW_PWR_LVL2,
+	AXP22X_IRQ_TIMER,
+	AXP22X_IRQ_PEK_RIS_EDGE,
+	AXP22X_IRQ_PEK_FAL_EDGE,
+	AXP22X_IRQ_GPIO1_INPUT,
+	AXP22X_IRQ_GPIO0_INPUT,
+};
+
 enum axp288_irqs {
 	AXP288_IRQ_VBUS_FALL     = 2,
 	AXP288_IRQ_VBUS_RISE,
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH RESEND v6 2/6] mfd: axp20x: update DT bindings with AXP22x compatibles
@ 2015-04-10  4:09   ` Chen-Yu Tsai
  0 siblings, 0 replies; 54+ messages in thread
From: Chen-Yu Tsai @ 2015-04-10  4:09 UTC (permalink / raw)
  To: Lee Jones, Samuel Ortiz, Mark Brown, Liam Girdwood, Rob Herring,
	Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala
  Cc: Chen-Yu Tsai, Maxime Ripard, Carlo Caione, linux-arm-kernel,
	devicetree, linux-kernel, linux-sunxi

Add AXP221 to the list of supported devices.

Also replace any mention of AXP20x in the document with a
generic "PMIC".

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Acked-by: Lee Jones <lee.jones@linaro.org>
---
 Documentation/devicetree/bindings/mfd/axp20x.txt | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/mfd/axp20x.txt b/Documentation/devicetree/bindings/mfd/axp20x.txt
index 98685f291a72..3914a3f91ff6 100644
--- a/Documentation/devicetree/bindings/mfd/axp20x.txt
+++ b/Documentation/devicetree/bindings/mfd/axp20x.txt
@@ -1,15 +1,16 @@
-AXP202/AXP209 device tree bindings
+AXP family PMIC device tree bindings
 
 The axp20x family current members :
 axp202 (X-Powers)
 axp209 (X-Powers)
+axp221 (X-Powers)
 
 Required properties:
-- compatible: "x-powers,axp202" or "x-powers,axp209"
+- compatible: "x-powers,axp202", "x-powers,axp209", "x-powers,axp221"
 - reg: The I2C slave address for the AXP chip
 - interrupt-parent: The parent interrupt controller
 - interrupts: SoC NMI / GPIO interrupt connected to the PMIC's IRQ pin
-- interrupt-controller: axp20x has its own internal IRQs
+- interrupt-controller: The PMIC has its own internal IRQs
 - #interrupt-cells: Should be set to 1
 
 Optional properties:
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH RESEND v6 2/6] mfd: axp20x: update DT bindings with AXP22x compatibles
@ 2015-04-10  4:09   ` Chen-Yu Tsai
  0 siblings, 0 replies; 54+ messages in thread
From: Chen-Yu Tsai @ 2015-04-10  4:09 UTC (permalink / raw)
  To: Lee Jones, Samuel Ortiz, Mark Brown, Liam Girdwood, Rob Herring,
	Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala
  Cc: Chen-Yu Tsai, Maxime Ripard, Carlo Caione,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw

Add AXP221 to the list of supported devices.

Also replace any mention of AXP20x in the document with a
generic "PMIC".

Signed-off-by: Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>
Acked-by: Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
 Documentation/devicetree/bindings/mfd/axp20x.txt | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/mfd/axp20x.txt b/Documentation/devicetree/bindings/mfd/axp20x.txt
index 98685f291a72..3914a3f91ff6 100644
--- a/Documentation/devicetree/bindings/mfd/axp20x.txt
+++ b/Documentation/devicetree/bindings/mfd/axp20x.txt
@@ -1,15 +1,16 @@
-AXP202/AXP209 device tree bindings
+AXP family PMIC device tree bindings
 
 The axp20x family current members :
 axp202 (X-Powers)
 axp209 (X-Powers)
+axp221 (X-Powers)
 
 Required properties:
-- compatible: "x-powers,axp202" or "x-powers,axp209"
+- compatible: "x-powers,axp202", "x-powers,axp209", "x-powers,axp221"
 - reg: The I2C slave address for the AXP chip
 - interrupt-parent: The parent interrupt controller
 - interrupts: SoC NMI / GPIO interrupt connected to the PMIC's IRQ pin
-- interrupt-controller: axp20x has its own internal IRQs
+- interrupt-controller: The PMIC has its own internal IRQs
 - #interrupt-cells: Should be set to 1
 
 Optional properties:
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH RESEND v6 2/6] mfd: axp20x: update DT bindings with AXP22x compatibles
@ 2015-04-10  4:09   ` Chen-Yu Tsai
  0 siblings, 0 replies; 54+ messages in thread
From: Chen-Yu Tsai @ 2015-04-10  4:09 UTC (permalink / raw)
  To: linux-arm-kernel

Add AXP221 to the list of supported devices.

Also replace any mention of AXP20x in the document with a
generic "PMIC".

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Acked-by: Lee Jones <lee.jones@linaro.org>
---
 Documentation/devicetree/bindings/mfd/axp20x.txt | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/mfd/axp20x.txt b/Documentation/devicetree/bindings/mfd/axp20x.txt
index 98685f291a72..3914a3f91ff6 100644
--- a/Documentation/devicetree/bindings/mfd/axp20x.txt
+++ b/Documentation/devicetree/bindings/mfd/axp20x.txt
@@ -1,15 +1,16 @@
-AXP202/AXP209 device tree bindings
+AXP family PMIC device tree bindings
 
 The axp20x family current members :
 axp202 (X-Powers)
 axp209 (X-Powers)
+axp221 (X-Powers)
 
 Required properties:
-- compatible: "x-powers,axp202" or "x-powers,axp209"
+- compatible: "x-powers,axp202", "x-powers,axp209", "x-powers,axp221"
 - reg: The I2C slave address for the AXP chip
 - interrupt-parent: The parent interrupt controller
 - interrupts: SoC NMI / GPIO interrupt connected to the PMIC's IRQ pin
-- interrupt-controller: axp20x has its own internal IRQs
+- interrupt-controller: The PMIC has its own internal IRQs
 - #interrupt-cells: Should be set to 1
 
 Optional properties:
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH RESEND v6 3/6] regulator: axp20x: prepare support for multiple AXP chip families
@ 2015-04-10  4:09   ` Chen-Yu Tsai
  0 siblings, 0 replies; 54+ messages in thread
From: Chen-Yu Tsai @ 2015-04-10  4:09 UTC (permalink / raw)
  To: Lee Jones, Samuel Ortiz, Mark Brown, Liam Girdwood, Rob Herring,
	Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala
  Cc: Boris BREZILLON, Maxime Ripard, Carlo Caione, linux-arm-kernel,
	devicetree, linux-kernel, linux-sunxi, Chen-Yu Tsai

From: Boris BREZILLON <boris.brezillon@free-electrons.com>

Rework the AXP20X_ macros and probe function to support the several chip
families, so that each family can define it's own set of regulators.

Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
[wens@csie.org: Support different DC-DC work frequency ranges]
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Reviewed-by: Mark Brown <broonie@kernel.org>
---
 drivers/regulator/axp20x-regulator.c | 143 +++++++++++++++++++++++------------
 1 file changed, 94 insertions(+), 49 deletions(-)

diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c
index e4331f5e5d7d..50ae0b5f2c0c 100644
--- a/drivers/regulator/axp20x-regulator.c
+++ b/drivers/regulator/axp20x-regulator.c
@@ -32,15 +32,15 @@
 
 #define AXP20X_FREQ_DCDC_MASK		0x0f
 
-#define AXP20X_DESC_IO(_id, _match, _supply, _min, _max, _step, _vreg, _vmask,	\
-		       _ereg, _emask, _enable_val, _disable_val)		\
-	[AXP20X_##_id] = {							\
+#define AXP_DESC_IO(_family, _id, _match, _supply, _min, _max, _step, _vreg,	\
+		    _vmask, _ereg, _emask, _enable_val, _disable_val)		\
+	[_family##_##_id] = {							\
 		.name		= #_id,						\
 		.supply_name	= (_supply),					\
 		.of_match	= of_match_ptr(_match),				\
 		.regulators_node = of_match_ptr("regulators"),			\
 		.type		= REGULATOR_VOLTAGE,				\
-		.id		= AXP20X_##_id,					\
+		.id		= _family##_##_id,				\
 		.n_voltages	= (((_max) - (_min)) / (_step) + 1),		\
 		.owner		= THIS_MODULE,					\
 		.min_uV		= (_min) * 1000,				\
@@ -54,15 +54,15 @@
 		.ops		= &axp20x_ops,					\
 	}
 
-#define AXP20X_DESC(_id, _match, _supply, _min, _max, _step, _vreg, _vmask,	\
-		    _ereg, _emask)						\
-	[AXP20X_##_id] = {							\
+#define AXP_DESC(_family, _id, _match, _supply, _min, _max, _step, _vreg,	\
+		 _vmask, _ereg, _emask) 					\
+	[_family##_##_id] = {							\
 		.name		= #_id,						\
 		.supply_name	= (_supply),					\
 		.of_match	= of_match_ptr(_match),				\
 		.regulators_node = of_match_ptr("regulators"),			\
 		.type		= REGULATOR_VOLTAGE,				\
-		.id		= AXP20X_##_id,					\
+		.id		= _family##_##_id,				\
 		.n_voltages	= (((_max) - (_min)) / (_step) + 1),		\
 		.owner		= THIS_MODULE,					\
 		.min_uV		= (_min) * 1000,				\
@@ -74,29 +74,29 @@
 		.ops		= &axp20x_ops,					\
 	}
 
-#define AXP20X_DESC_FIXED(_id, _match, _supply, _volt)				\
-	[AXP20X_##_id] = {							\
+#define AXP_DESC_FIXED(_family, _id, _match, _supply, _volt)			\
+	[_family##_##_id] = {							\
 		.name		= #_id,						\
 		.supply_name	= (_supply),					\
 		.of_match	= of_match_ptr(_match),				\
 		.regulators_node = of_match_ptr("regulators"),			\
 		.type		= REGULATOR_VOLTAGE,				\
-		.id		= AXP20X_##_id,					\
+		.id		= _family##_##_id,				\
 		.n_voltages	= 1,						\
 		.owner		= THIS_MODULE,					\
 		.min_uV		= (_volt) * 1000,				\
 		.ops		= &axp20x_ops_fixed				\
 	}
 
-#define AXP20X_DESC_TABLE(_id, _match, _supply, _table, _vreg, _vmask, _ereg,	\
-			  _emask)						\
-	[AXP20X_##_id] = {							\
+#define AXP_DESC_TABLE(_family, _id, _match, _supply, _table, _vreg, _vmask,	\
+		       _ereg, _emask)						\
+	[_family##_##_id] = {							\
 		.name		= #_id,						\
 		.supply_name	= (_supply),					\
 		.of_match	= of_match_ptr(_match),				\
 		.regulators_node = of_match_ptr("regulators"),			\
 		.type		= REGULATOR_VOLTAGE,				\
-		.id		= AXP20X_##_id,					\
+		.id		= _family##_##_id,				\
 		.n_voltages	= ARRAY_SIZE(_table),				\
 		.owner		= THIS_MODULE,					\
 		.vsel_reg	= (_vreg),					\
@@ -136,37 +136,57 @@ static struct regulator_ops axp20x_ops = {
 };
 
 static const struct regulator_desc axp20x_regulators[] = {
-	AXP20X_DESC(DCDC2, "dcdc2", "vin2", 700, 2275, 25, AXP20X_DCDC2_V_OUT,
-		    0x3f, AXP20X_PWR_OUT_CTRL, 0x10),
-	AXP20X_DESC(DCDC3, "dcdc3", "vin3", 700, 3500, 25, AXP20X_DCDC3_V_OUT,
-		    0x7f, AXP20X_PWR_OUT_CTRL, 0x02),
-	AXP20X_DESC_FIXED(LDO1, "ldo1", "acin", 1300),
-	AXP20X_DESC(LDO2, "ldo2", "ldo24in", 1800, 3300, 100,
-		    AXP20X_LDO24_V_OUT, 0xf0, AXP20X_PWR_OUT_CTRL, 0x04),
-	AXP20X_DESC(LDO3, "ldo3", "ldo3in", 700, 3500, 25, AXP20X_LDO3_V_OUT,
-		    0x7f, AXP20X_PWR_OUT_CTRL, 0x40),
-	AXP20X_DESC_TABLE(LDO4, "ldo4", "ldo24in", axp20x_ldo4_data,
-			  AXP20X_LDO24_V_OUT, 0x0f, AXP20X_PWR_OUT_CTRL, 0x08),
-	AXP20X_DESC_IO(LDO5, "ldo5", "ldo5in", 1800, 3300, 100,
-		       AXP20X_LDO5_V_OUT, 0xf0, AXP20X_GPIO0_CTRL, 0x07,
-		       AXP20X_IO_ENABLED, AXP20X_IO_DISABLED),
+	AXP_DESC(AXP20X, DCDC2, "dcdc2", "vin2", 700, 2275, 25,
+		 AXP20X_DCDC2_V_OUT, 0x3f, AXP20X_PWR_OUT_CTRL, 0x10),
+	AXP_DESC(AXP20X, DCDC3, "dcdc3", "vin3", 700, 3500, 25,
+		 AXP20X_DCDC3_V_OUT, 0x7f, AXP20X_PWR_OUT_CTRL, 0x02),
+	AXP_DESC_FIXED(AXP20X, LDO1, "ldo1", "acin", 1300),
+	AXP_DESC(AXP20X, LDO2, "ldo2", "ldo24in", 1800, 3300, 100,
+		 AXP20X_LDO24_V_OUT, 0xf0, AXP20X_PWR_OUT_CTRL, 0x04),
+	AXP_DESC(AXP20X, LDO3, "ldo3", "ldo3in", 700, 3500, 25,
+		 AXP20X_LDO3_V_OUT, 0x7f, AXP20X_PWR_OUT_CTRL, 0x40),
+	AXP_DESC_TABLE(AXP20X, LDO4, "ldo4", "ldo24in", axp20x_ldo4_data,
+		       AXP20X_LDO24_V_OUT, 0x0f, AXP20X_PWR_OUT_CTRL, 0x08),
+	AXP_DESC_IO(AXP20X, LDO5, "ldo5", "ldo5in", 1800, 3300, 100,
+		    AXP20X_LDO5_V_OUT, 0xf0, AXP20X_GPIO0_CTRL, 0x07,
+		    AXP20X_IO_ENABLED, AXP20X_IO_DISABLED),
 };
 
 static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq)
 {
 	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
+	u32 min, max, def, step;
+
+	switch (axp20x->variant) {
+	case AXP202_ID:
+	case AXP209_ID:
+		min = 750;
+		max = 1875;
+		def = 1500;
+		step = 75;
+		break;
+	default:
+		dev_err(&pdev->dev,
+			"Setting DCDC frequency for unsupported AXP variant\n");
+		return -EINVAL;
+	}
+
+	if (dcdcfreq == 0)
+		dcdcfreq = def;
 
-	if (dcdcfreq < 750) {
-		dcdcfreq = 750;
-		dev_warn(&pdev->dev, "DCDC frequency too low. Set to 750kHz\n");
+	if (dcdcfreq < min) {
+		dcdcfreq = min;
+		dev_warn(&pdev->dev, "DCDC frequency too low. Set to %ukHz\n",
+			 min);
 	}
 
-	if (dcdcfreq > 1875) {
-		dcdcfreq = 1875;
-		dev_warn(&pdev->dev, "DCDC frequency too high. Set to 1875kHz\n");
+	if (dcdcfreq > max) {
+		dcdcfreq = max;
+		dev_warn(&pdev->dev, "DCDC frequency too high. Set to %ukHz\n",
+			 max);
 	}
 
-	dcdcfreq = (dcdcfreq - 750) / 75;
+	dcdcfreq = (dcdcfreq - min) / step;
 
 	return regmap_update_bits(axp20x->regmap, AXP20X_DCDC_FREQ,
 				  AXP20X_FREQ_DCDC_MASK, dcdcfreq);
@@ -176,7 +196,7 @@ static int axp20x_regulator_parse_dt(struct platform_device *pdev)
 {
 	struct device_node *np, *regulators;
 	int ret;
-	u32 dcdcfreq;
+	u32 dcdcfreq = 0;
 
 	np = of_node_get(pdev->dev.parent->of_node);
 	if (!np)
@@ -186,7 +206,6 @@ static int axp20x_regulator_parse_dt(struct platform_device *pdev)
 	if (!regulators) {
 		dev_warn(&pdev->dev, "regulators node not found\n");
 	} else {
-		dcdcfreq = 1500;
 		of_property_read_u32(regulators, "x-powers,dcdc-freq", &dcdcfreq);
 		ret = axp20x_set_dcdc_freq(pdev, dcdcfreq);
 		if (ret < 0) {
@@ -202,15 +221,27 @@ static int axp20x_regulator_parse_dt(struct platform_device *pdev)
 
 static int axp20x_set_dcdc_workmode(struct regulator_dev *rdev, int id, u32 workmode)
 {
-	unsigned int mask = AXP20X_WORKMODE_DCDC2_MASK;
+	struct axp20x_dev *axp20x = rdev_get_drvdata(rdev);
+	unsigned int mask;
 
-	if ((id != AXP20X_DCDC2) && (id != AXP20X_DCDC3))
-		return -EINVAL;
+	switch (axp20x->variant) {
+	case AXP202_ID:
+	case AXP209_ID:
+		if ((id != AXP20X_DCDC2) && (id != AXP20X_DCDC3))
+			return -EINVAL;
+
+		mask = AXP20X_WORKMODE_DCDC2_MASK;
+		if (id == AXP20X_DCDC3)
+			mask = AXP20X_WORKMODE_DCDC3_MASK;
 
-	if (id == AXP20X_DCDC3)
-		mask = AXP20X_WORKMODE_DCDC3_MASK;
+		workmode <<= ffs(mask) - 1;
+		break;
 
-	workmode <<= ffs(mask) - 1;
+	default:
+		/* should not happen */
+		WARN_ON(1);
+		return -EINVAL;
+	}
 
 	return regmap_update_bits(rdev->regmap, AXP20X_DCDC_MODE, mask, workmode);
 }
@@ -219,22 +250,36 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
 {
 	struct regulator_dev *rdev;
 	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
+	const struct regulator_desc *regulators;
 	struct regulator_config config = {
 		.dev = pdev->dev.parent,
 		.regmap = axp20x->regmap,
+		.driver_data = axp20x,
 	};
-	int ret, i;
+	int ret, i, nregulators;
 	u32 workmode;
 
+	switch (axp20x->variant) {
+	case AXP202_ID:
+	case AXP209_ID:
+		regulators = axp20x_regulators;
+		nregulators = AXP20X_REG_ID_MAX;
+		break;
+	default:
+		dev_err(&pdev->dev, "Unsupported AXP variant: %ld\n",
+			axp20x->variant);
+		return -EINVAL;
+	}
+
 	/* This only sets the dcdc freq. Ignore any errors */
 	axp20x_regulator_parse_dt(pdev);
 
-	for (i = 0; i < AXP20X_REG_ID_MAX; i++) {
-		rdev = devm_regulator_register(&pdev->dev, &axp20x_regulators[i],
+	for (i = 0; i < nregulators; i++) {
+		rdev = devm_regulator_register(&pdev->dev, &regulators[i],
 					       &config);
 		if (IS_ERR(rdev)) {
 			dev_err(&pdev->dev, "Failed to register %s\n",
-				axp20x_regulators[i].name);
+				regulators[i].name);
 
 			return PTR_ERR(rdev);
 		}
@@ -245,7 +290,7 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
 		if (!ret) {
 			if (axp20x_set_dcdc_workmode(rdev, i, workmode))
 				dev_err(&pdev->dev, "Failed to set workmode on %s\n",
-					axp20x_regulators[i].name);
+					rdev->desc->name);
 		}
 	}
 
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH RESEND v6 3/6] regulator: axp20x: prepare support for multiple AXP chip families
@ 2015-04-10  4:09   ` Chen-Yu Tsai
  0 siblings, 0 replies; 54+ messages in thread
From: Chen-Yu Tsai @ 2015-04-10  4:09 UTC (permalink / raw)
  To: Lee Jones, Samuel Ortiz, Mark Brown, Liam Girdwood, Rob Herring,
	Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala
  Cc: Boris BREZILLON, Maxime Ripard, Carlo Caione,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw, Chen-Yu Tsai

From: Boris BREZILLON <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>

Rework the AXP20X_ macros and probe function to support the several chip
families, so that each family can define it's own set of regulators.

Signed-off-by: Boris BREZILLON <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
[wens-jdAy2FN1RRM@public.gmane.org: Support different DC-DC work frequency ranges]
Signed-off-by: Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>
Reviewed-by: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
---
 drivers/regulator/axp20x-regulator.c | 143 +++++++++++++++++++++++------------
 1 file changed, 94 insertions(+), 49 deletions(-)

diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c
index e4331f5e5d7d..50ae0b5f2c0c 100644
--- a/drivers/regulator/axp20x-regulator.c
+++ b/drivers/regulator/axp20x-regulator.c
@@ -32,15 +32,15 @@
 
 #define AXP20X_FREQ_DCDC_MASK		0x0f
 
-#define AXP20X_DESC_IO(_id, _match, _supply, _min, _max, _step, _vreg, _vmask,	\
-		       _ereg, _emask, _enable_val, _disable_val)		\
-	[AXP20X_##_id] = {							\
+#define AXP_DESC_IO(_family, _id, _match, _supply, _min, _max, _step, _vreg,	\
+		    _vmask, _ereg, _emask, _enable_val, _disable_val)		\
+	[_family##_##_id] = {							\
 		.name		= #_id,						\
 		.supply_name	= (_supply),					\
 		.of_match	= of_match_ptr(_match),				\
 		.regulators_node = of_match_ptr("regulators"),			\
 		.type		= REGULATOR_VOLTAGE,				\
-		.id		= AXP20X_##_id,					\
+		.id		= _family##_##_id,				\
 		.n_voltages	= (((_max) - (_min)) / (_step) + 1),		\
 		.owner		= THIS_MODULE,					\
 		.min_uV		= (_min) * 1000,				\
@@ -54,15 +54,15 @@
 		.ops		= &axp20x_ops,					\
 	}
 
-#define AXP20X_DESC(_id, _match, _supply, _min, _max, _step, _vreg, _vmask,	\
-		    _ereg, _emask)						\
-	[AXP20X_##_id] = {							\
+#define AXP_DESC(_family, _id, _match, _supply, _min, _max, _step, _vreg,	\
+		 _vmask, _ereg, _emask) 					\
+	[_family##_##_id] = {							\
 		.name		= #_id,						\
 		.supply_name	= (_supply),					\
 		.of_match	= of_match_ptr(_match),				\
 		.regulators_node = of_match_ptr("regulators"),			\
 		.type		= REGULATOR_VOLTAGE,				\
-		.id		= AXP20X_##_id,					\
+		.id		= _family##_##_id,				\
 		.n_voltages	= (((_max) - (_min)) / (_step) + 1),		\
 		.owner		= THIS_MODULE,					\
 		.min_uV		= (_min) * 1000,				\
@@ -74,29 +74,29 @@
 		.ops		= &axp20x_ops,					\
 	}
 
-#define AXP20X_DESC_FIXED(_id, _match, _supply, _volt)				\
-	[AXP20X_##_id] = {							\
+#define AXP_DESC_FIXED(_family, _id, _match, _supply, _volt)			\
+	[_family##_##_id] = {							\
 		.name		= #_id,						\
 		.supply_name	= (_supply),					\
 		.of_match	= of_match_ptr(_match),				\
 		.regulators_node = of_match_ptr("regulators"),			\
 		.type		= REGULATOR_VOLTAGE,				\
-		.id		= AXP20X_##_id,					\
+		.id		= _family##_##_id,				\
 		.n_voltages	= 1,						\
 		.owner		= THIS_MODULE,					\
 		.min_uV		= (_volt) * 1000,				\
 		.ops		= &axp20x_ops_fixed				\
 	}
 
-#define AXP20X_DESC_TABLE(_id, _match, _supply, _table, _vreg, _vmask, _ereg,	\
-			  _emask)						\
-	[AXP20X_##_id] = {							\
+#define AXP_DESC_TABLE(_family, _id, _match, _supply, _table, _vreg, _vmask,	\
+		       _ereg, _emask)						\
+	[_family##_##_id] = {							\
 		.name		= #_id,						\
 		.supply_name	= (_supply),					\
 		.of_match	= of_match_ptr(_match),				\
 		.regulators_node = of_match_ptr("regulators"),			\
 		.type		= REGULATOR_VOLTAGE,				\
-		.id		= AXP20X_##_id,					\
+		.id		= _family##_##_id,				\
 		.n_voltages	= ARRAY_SIZE(_table),				\
 		.owner		= THIS_MODULE,					\
 		.vsel_reg	= (_vreg),					\
@@ -136,37 +136,57 @@ static struct regulator_ops axp20x_ops = {
 };
 
 static const struct regulator_desc axp20x_regulators[] = {
-	AXP20X_DESC(DCDC2, "dcdc2", "vin2", 700, 2275, 25, AXP20X_DCDC2_V_OUT,
-		    0x3f, AXP20X_PWR_OUT_CTRL, 0x10),
-	AXP20X_DESC(DCDC3, "dcdc3", "vin3", 700, 3500, 25, AXP20X_DCDC3_V_OUT,
-		    0x7f, AXP20X_PWR_OUT_CTRL, 0x02),
-	AXP20X_DESC_FIXED(LDO1, "ldo1", "acin", 1300),
-	AXP20X_DESC(LDO2, "ldo2", "ldo24in", 1800, 3300, 100,
-		    AXP20X_LDO24_V_OUT, 0xf0, AXP20X_PWR_OUT_CTRL, 0x04),
-	AXP20X_DESC(LDO3, "ldo3", "ldo3in", 700, 3500, 25, AXP20X_LDO3_V_OUT,
-		    0x7f, AXP20X_PWR_OUT_CTRL, 0x40),
-	AXP20X_DESC_TABLE(LDO4, "ldo4", "ldo24in", axp20x_ldo4_data,
-			  AXP20X_LDO24_V_OUT, 0x0f, AXP20X_PWR_OUT_CTRL, 0x08),
-	AXP20X_DESC_IO(LDO5, "ldo5", "ldo5in", 1800, 3300, 100,
-		       AXP20X_LDO5_V_OUT, 0xf0, AXP20X_GPIO0_CTRL, 0x07,
-		       AXP20X_IO_ENABLED, AXP20X_IO_DISABLED),
+	AXP_DESC(AXP20X, DCDC2, "dcdc2", "vin2", 700, 2275, 25,
+		 AXP20X_DCDC2_V_OUT, 0x3f, AXP20X_PWR_OUT_CTRL, 0x10),
+	AXP_DESC(AXP20X, DCDC3, "dcdc3", "vin3", 700, 3500, 25,
+		 AXP20X_DCDC3_V_OUT, 0x7f, AXP20X_PWR_OUT_CTRL, 0x02),
+	AXP_DESC_FIXED(AXP20X, LDO1, "ldo1", "acin", 1300),
+	AXP_DESC(AXP20X, LDO2, "ldo2", "ldo24in", 1800, 3300, 100,
+		 AXP20X_LDO24_V_OUT, 0xf0, AXP20X_PWR_OUT_CTRL, 0x04),
+	AXP_DESC(AXP20X, LDO3, "ldo3", "ldo3in", 700, 3500, 25,
+		 AXP20X_LDO3_V_OUT, 0x7f, AXP20X_PWR_OUT_CTRL, 0x40),
+	AXP_DESC_TABLE(AXP20X, LDO4, "ldo4", "ldo24in", axp20x_ldo4_data,
+		       AXP20X_LDO24_V_OUT, 0x0f, AXP20X_PWR_OUT_CTRL, 0x08),
+	AXP_DESC_IO(AXP20X, LDO5, "ldo5", "ldo5in", 1800, 3300, 100,
+		    AXP20X_LDO5_V_OUT, 0xf0, AXP20X_GPIO0_CTRL, 0x07,
+		    AXP20X_IO_ENABLED, AXP20X_IO_DISABLED),
 };
 
 static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq)
 {
 	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
+	u32 min, max, def, step;
+
+	switch (axp20x->variant) {
+	case AXP202_ID:
+	case AXP209_ID:
+		min = 750;
+		max = 1875;
+		def = 1500;
+		step = 75;
+		break;
+	default:
+		dev_err(&pdev->dev,
+			"Setting DCDC frequency for unsupported AXP variant\n");
+		return -EINVAL;
+	}
+
+	if (dcdcfreq == 0)
+		dcdcfreq = def;
 
-	if (dcdcfreq < 750) {
-		dcdcfreq = 750;
-		dev_warn(&pdev->dev, "DCDC frequency too low. Set to 750kHz\n");
+	if (dcdcfreq < min) {
+		dcdcfreq = min;
+		dev_warn(&pdev->dev, "DCDC frequency too low. Set to %ukHz\n",
+			 min);
 	}
 
-	if (dcdcfreq > 1875) {
-		dcdcfreq = 1875;
-		dev_warn(&pdev->dev, "DCDC frequency too high. Set to 1875kHz\n");
+	if (dcdcfreq > max) {
+		dcdcfreq = max;
+		dev_warn(&pdev->dev, "DCDC frequency too high. Set to %ukHz\n",
+			 max);
 	}
 
-	dcdcfreq = (dcdcfreq - 750) / 75;
+	dcdcfreq = (dcdcfreq - min) / step;
 
 	return regmap_update_bits(axp20x->regmap, AXP20X_DCDC_FREQ,
 				  AXP20X_FREQ_DCDC_MASK, dcdcfreq);
@@ -176,7 +196,7 @@ static int axp20x_regulator_parse_dt(struct platform_device *pdev)
 {
 	struct device_node *np, *regulators;
 	int ret;
-	u32 dcdcfreq;
+	u32 dcdcfreq = 0;
 
 	np = of_node_get(pdev->dev.parent->of_node);
 	if (!np)
@@ -186,7 +206,6 @@ static int axp20x_regulator_parse_dt(struct platform_device *pdev)
 	if (!regulators) {
 		dev_warn(&pdev->dev, "regulators node not found\n");
 	} else {
-		dcdcfreq = 1500;
 		of_property_read_u32(regulators, "x-powers,dcdc-freq", &dcdcfreq);
 		ret = axp20x_set_dcdc_freq(pdev, dcdcfreq);
 		if (ret < 0) {
@@ -202,15 +221,27 @@ static int axp20x_regulator_parse_dt(struct platform_device *pdev)
 
 static int axp20x_set_dcdc_workmode(struct regulator_dev *rdev, int id, u32 workmode)
 {
-	unsigned int mask = AXP20X_WORKMODE_DCDC2_MASK;
+	struct axp20x_dev *axp20x = rdev_get_drvdata(rdev);
+	unsigned int mask;
 
-	if ((id != AXP20X_DCDC2) && (id != AXP20X_DCDC3))
-		return -EINVAL;
+	switch (axp20x->variant) {
+	case AXP202_ID:
+	case AXP209_ID:
+		if ((id != AXP20X_DCDC2) && (id != AXP20X_DCDC3))
+			return -EINVAL;
+
+		mask = AXP20X_WORKMODE_DCDC2_MASK;
+		if (id == AXP20X_DCDC3)
+			mask = AXP20X_WORKMODE_DCDC3_MASK;
 
-	if (id == AXP20X_DCDC3)
-		mask = AXP20X_WORKMODE_DCDC3_MASK;
+		workmode <<= ffs(mask) - 1;
+		break;
 
-	workmode <<= ffs(mask) - 1;
+	default:
+		/* should not happen */
+		WARN_ON(1);
+		return -EINVAL;
+	}
 
 	return regmap_update_bits(rdev->regmap, AXP20X_DCDC_MODE, mask, workmode);
 }
@@ -219,22 +250,36 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
 {
 	struct regulator_dev *rdev;
 	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
+	const struct regulator_desc *regulators;
 	struct regulator_config config = {
 		.dev = pdev->dev.parent,
 		.regmap = axp20x->regmap,
+		.driver_data = axp20x,
 	};
-	int ret, i;
+	int ret, i, nregulators;
 	u32 workmode;
 
+	switch (axp20x->variant) {
+	case AXP202_ID:
+	case AXP209_ID:
+		regulators = axp20x_regulators;
+		nregulators = AXP20X_REG_ID_MAX;
+		break;
+	default:
+		dev_err(&pdev->dev, "Unsupported AXP variant: %ld\n",
+			axp20x->variant);
+		return -EINVAL;
+	}
+
 	/* This only sets the dcdc freq. Ignore any errors */
 	axp20x_regulator_parse_dt(pdev);
 
-	for (i = 0; i < AXP20X_REG_ID_MAX; i++) {
-		rdev = devm_regulator_register(&pdev->dev, &axp20x_regulators[i],
+	for (i = 0; i < nregulators; i++) {
+		rdev = devm_regulator_register(&pdev->dev, &regulators[i],
 					       &config);
 		if (IS_ERR(rdev)) {
 			dev_err(&pdev->dev, "Failed to register %s\n",
-				axp20x_regulators[i].name);
+				regulators[i].name);
 
 			return PTR_ERR(rdev);
 		}
@@ -245,7 +290,7 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
 		if (!ret) {
 			if (axp20x_set_dcdc_workmode(rdev, i, workmode))
 				dev_err(&pdev->dev, "Failed to set workmode on %s\n",
-					axp20x_regulators[i].name);
+					rdev->desc->name);
 		}
 	}
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH RESEND v6 3/6] regulator: axp20x: prepare support for multiple AXP chip families
@ 2015-04-10  4:09   ` Chen-Yu Tsai
  0 siblings, 0 replies; 54+ messages in thread
From: Chen-Yu Tsai @ 2015-04-10  4:09 UTC (permalink / raw)
  To: linux-arm-kernel

From: Boris BREZILLON <boris.brezillon@free-electrons.com>

Rework the AXP20X_ macros and probe function to support the several chip
families, so that each family can define it's own set of regulators.

Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
[wens at csie.org: Support different DC-DC work frequency ranges]
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Reviewed-by: Mark Brown <broonie@kernel.org>
---
 drivers/regulator/axp20x-regulator.c | 143 +++++++++++++++++++++++------------
 1 file changed, 94 insertions(+), 49 deletions(-)

diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c
index e4331f5e5d7d..50ae0b5f2c0c 100644
--- a/drivers/regulator/axp20x-regulator.c
+++ b/drivers/regulator/axp20x-regulator.c
@@ -32,15 +32,15 @@
 
 #define AXP20X_FREQ_DCDC_MASK		0x0f
 
-#define AXP20X_DESC_IO(_id, _match, _supply, _min, _max, _step, _vreg, _vmask,	\
-		       _ereg, _emask, _enable_val, _disable_val)		\
-	[AXP20X_##_id] = {							\
+#define AXP_DESC_IO(_family, _id, _match, _supply, _min, _max, _step, _vreg,	\
+		    _vmask, _ereg, _emask, _enable_val, _disable_val)		\
+	[_family##_##_id] = {							\
 		.name		= #_id,						\
 		.supply_name	= (_supply),					\
 		.of_match	= of_match_ptr(_match),				\
 		.regulators_node = of_match_ptr("regulators"),			\
 		.type		= REGULATOR_VOLTAGE,				\
-		.id		= AXP20X_##_id,					\
+		.id		= _family##_##_id,				\
 		.n_voltages	= (((_max) - (_min)) / (_step) + 1),		\
 		.owner		= THIS_MODULE,					\
 		.min_uV		= (_min) * 1000,				\
@@ -54,15 +54,15 @@
 		.ops		= &axp20x_ops,					\
 	}
 
-#define AXP20X_DESC(_id, _match, _supply, _min, _max, _step, _vreg, _vmask,	\
-		    _ereg, _emask)						\
-	[AXP20X_##_id] = {							\
+#define AXP_DESC(_family, _id, _match, _supply, _min, _max, _step, _vreg,	\
+		 _vmask, _ereg, _emask) 					\
+	[_family##_##_id] = {							\
 		.name		= #_id,						\
 		.supply_name	= (_supply),					\
 		.of_match	= of_match_ptr(_match),				\
 		.regulators_node = of_match_ptr("regulators"),			\
 		.type		= REGULATOR_VOLTAGE,				\
-		.id		= AXP20X_##_id,					\
+		.id		= _family##_##_id,				\
 		.n_voltages	= (((_max) - (_min)) / (_step) + 1),		\
 		.owner		= THIS_MODULE,					\
 		.min_uV		= (_min) * 1000,				\
@@ -74,29 +74,29 @@
 		.ops		= &axp20x_ops,					\
 	}
 
-#define AXP20X_DESC_FIXED(_id, _match, _supply, _volt)				\
-	[AXP20X_##_id] = {							\
+#define AXP_DESC_FIXED(_family, _id, _match, _supply, _volt)			\
+	[_family##_##_id] = {							\
 		.name		= #_id,						\
 		.supply_name	= (_supply),					\
 		.of_match	= of_match_ptr(_match),				\
 		.regulators_node = of_match_ptr("regulators"),			\
 		.type		= REGULATOR_VOLTAGE,				\
-		.id		= AXP20X_##_id,					\
+		.id		= _family##_##_id,				\
 		.n_voltages	= 1,						\
 		.owner		= THIS_MODULE,					\
 		.min_uV		= (_volt) * 1000,				\
 		.ops		= &axp20x_ops_fixed				\
 	}
 
-#define AXP20X_DESC_TABLE(_id, _match, _supply, _table, _vreg, _vmask, _ereg,	\
-			  _emask)						\
-	[AXP20X_##_id] = {							\
+#define AXP_DESC_TABLE(_family, _id, _match, _supply, _table, _vreg, _vmask,	\
+		       _ereg, _emask)						\
+	[_family##_##_id] = {							\
 		.name		= #_id,						\
 		.supply_name	= (_supply),					\
 		.of_match	= of_match_ptr(_match),				\
 		.regulators_node = of_match_ptr("regulators"),			\
 		.type		= REGULATOR_VOLTAGE,				\
-		.id		= AXP20X_##_id,					\
+		.id		= _family##_##_id,				\
 		.n_voltages	= ARRAY_SIZE(_table),				\
 		.owner		= THIS_MODULE,					\
 		.vsel_reg	= (_vreg),					\
@@ -136,37 +136,57 @@ static struct regulator_ops axp20x_ops = {
 };
 
 static const struct regulator_desc axp20x_regulators[] = {
-	AXP20X_DESC(DCDC2, "dcdc2", "vin2", 700, 2275, 25, AXP20X_DCDC2_V_OUT,
-		    0x3f, AXP20X_PWR_OUT_CTRL, 0x10),
-	AXP20X_DESC(DCDC3, "dcdc3", "vin3", 700, 3500, 25, AXP20X_DCDC3_V_OUT,
-		    0x7f, AXP20X_PWR_OUT_CTRL, 0x02),
-	AXP20X_DESC_FIXED(LDO1, "ldo1", "acin", 1300),
-	AXP20X_DESC(LDO2, "ldo2", "ldo24in", 1800, 3300, 100,
-		    AXP20X_LDO24_V_OUT, 0xf0, AXP20X_PWR_OUT_CTRL, 0x04),
-	AXP20X_DESC(LDO3, "ldo3", "ldo3in", 700, 3500, 25, AXP20X_LDO3_V_OUT,
-		    0x7f, AXP20X_PWR_OUT_CTRL, 0x40),
-	AXP20X_DESC_TABLE(LDO4, "ldo4", "ldo24in", axp20x_ldo4_data,
-			  AXP20X_LDO24_V_OUT, 0x0f, AXP20X_PWR_OUT_CTRL, 0x08),
-	AXP20X_DESC_IO(LDO5, "ldo5", "ldo5in", 1800, 3300, 100,
-		       AXP20X_LDO5_V_OUT, 0xf0, AXP20X_GPIO0_CTRL, 0x07,
-		       AXP20X_IO_ENABLED, AXP20X_IO_DISABLED),
+	AXP_DESC(AXP20X, DCDC2, "dcdc2", "vin2", 700, 2275, 25,
+		 AXP20X_DCDC2_V_OUT, 0x3f, AXP20X_PWR_OUT_CTRL, 0x10),
+	AXP_DESC(AXP20X, DCDC3, "dcdc3", "vin3", 700, 3500, 25,
+		 AXP20X_DCDC3_V_OUT, 0x7f, AXP20X_PWR_OUT_CTRL, 0x02),
+	AXP_DESC_FIXED(AXP20X, LDO1, "ldo1", "acin", 1300),
+	AXP_DESC(AXP20X, LDO2, "ldo2", "ldo24in", 1800, 3300, 100,
+		 AXP20X_LDO24_V_OUT, 0xf0, AXP20X_PWR_OUT_CTRL, 0x04),
+	AXP_DESC(AXP20X, LDO3, "ldo3", "ldo3in", 700, 3500, 25,
+		 AXP20X_LDO3_V_OUT, 0x7f, AXP20X_PWR_OUT_CTRL, 0x40),
+	AXP_DESC_TABLE(AXP20X, LDO4, "ldo4", "ldo24in", axp20x_ldo4_data,
+		       AXP20X_LDO24_V_OUT, 0x0f, AXP20X_PWR_OUT_CTRL, 0x08),
+	AXP_DESC_IO(AXP20X, LDO5, "ldo5", "ldo5in", 1800, 3300, 100,
+		    AXP20X_LDO5_V_OUT, 0xf0, AXP20X_GPIO0_CTRL, 0x07,
+		    AXP20X_IO_ENABLED, AXP20X_IO_DISABLED),
 };
 
 static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq)
 {
 	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
+	u32 min, max, def, step;
+
+	switch (axp20x->variant) {
+	case AXP202_ID:
+	case AXP209_ID:
+		min = 750;
+		max = 1875;
+		def = 1500;
+		step = 75;
+		break;
+	default:
+		dev_err(&pdev->dev,
+			"Setting DCDC frequency for unsupported AXP variant\n");
+		return -EINVAL;
+	}
+
+	if (dcdcfreq == 0)
+		dcdcfreq = def;
 
-	if (dcdcfreq < 750) {
-		dcdcfreq = 750;
-		dev_warn(&pdev->dev, "DCDC frequency too low. Set to 750kHz\n");
+	if (dcdcfreq < min) {
+		dcdcfreq = min;
+		dev_warn(&pdev->dev, "DCDC frequency too low. Set to %ukHz\n",
+			 min);
 	}
 
-	if (dcdcfreq > 1875) {
-		dcdcfreq = 1875;
-		dev_warn(&pdev->dev, "DCDC frequency too high. Set to 1875kHz\n");
+	if (dcdcfreq > max) {
+		dcdcfreq = max;
+		dev_warn(&pdev->dev, "DCDC frequency too high. Set to %ukHz\n",
+			 max);
 	}
 
-	dcdcfreq = (dcdcfreq - 750) / 75;
+	dcdcfreq = (dcdcfreq - min) / step;
 
 	return regmap_update_bits(axp20x->regmap, AXP20X_DCDC_FREQ,
 				  AXP20X_FREQ_DCDC_MASK, dcdcfreq);
@@ -176,7 +196,7 @@ static int axp20x_regulator_parse_dt(struct platform_device *pdev)
 {
 	struct device_node *np, *regulators;
 	int ret;
-	u32 dcdcfreq;
+	u32 dcdcfreq = 0;
 
 	np = of_node_get(pdev->dev.parent->of_node);
 	if (!np)
@@ -186,7 +206,6 @@ static int axp20x_regulator_parse_dt(struct platform_device *pdev)
 	if (!regulators) {
 		dev_warn(&pdev->dev, "regulators node not found\n");
 	} else {
-		dcdcfreq = 1500;
 		of_property_read_u32(regulators, "x-powers,dcdc-freq", &dcdcfreq);
 		ret = axp20x_set_dcdc_freq(pdev, dcdcfreq);
 		if (ret < 0) {
@@ -202,15 +221,27 @@ static int axp20x_regulator_parse_dt(struct platform_device *pdev)
 
 static int axp20x_set_dcdc_workmode(struct regulator_dev *rdev, int id, u32 workmode)
 {
-	unsigned int mask = AXP20X_WORKMODE_DCDC2_MASK;
+	struct axp20x_dev *axp20x = rdev_get_drvdata(rdev);
+	unsigned int mask;
 
-	if ((id != AXP20X_DCDC2) && (id != AXP20X_DCDC3))
-		return -EINVAL;
+	switch (axp20x->variant) {
+	case AXP202_ID:
+	case AXP209_ID:
+		if ((id != AXP20X_DCDC2) && (id != AXP20X_DCDC3))
+			return -EINVAL;
+
+		mask = AXP20X_WORKMODE_DCDC2_MASK;
+		if (id == AXP20X_DCDC3)
+			mask = AXP20X_WORKMODE_DCDC3_MASK;
 
-	if (id == AXP20X_DCDC3)
-		mask = AXP20X_WORKMODE_DCDC3_MASK;
+		workmode <<= ffs(mask) - 1;
+		break;
 
-	workmode <<= ffs(mask) - 1;
+	default:
+		/* should not happen */
+		WARN_ON(1);
+		return -EINVAL;
+	}
 
 	return regmap_update_bits(rdev->regmap, AXP20X_DCDC_MODE, mask, workmode);
 }
@@ -219,22 +250,36 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
 {
 	struct regulator_dev *rdev;
 	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
+	const struct regulator_desc *regulators;
 	struct regulator_config config = {
 		.dev = pdev->dev.parent,
 		.regmap = axp20x->regmap,
+		.driver_data = axp20x,
 	};
-	int ret, i;
+	int ret, i, nregulators;
 	u32 workmode;
 
+	switch (axp20x->variant) {
+	case AXP202_ID:
+	case AXP209_ID:
+		regulators = axp20x_regulators;
+		nregulators = AXP20X_REG_ID_MAX;
+		break;
+	default:
+		dev_err(&pdev->dev, "Unsupported AXP variant: %ld\n",
+			axp20x->variant);
+		return -EINVAL;
+	}
+
 	/* This only sets the dcdc freq. Ignore any errors */
 	axp20x_regulator_parse_dt(pdev);
 
-	for (i = 0; i < AXP20X_REG_ID_MAX; i++) {
-		rdev = devm_regulator_register(&pdev->dev, &axp20x_regulators[i],
+	for (i = 0; i < nregulators; i++) {
+		rdev = devm_regulator_register(&pdev->dev, &regulators[i],
 					       &config);
 		if (IS_ERR(rdev)) {
 			dev_err(&pdev->dev, "Failed to register %s\n",
-				axp20x_regulators[i].name);
+				regulators[i].name);
 
 			return PTR_ERR(rdev);
 		}
@@ -245,7 +290,7 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
 		if (!ret) {
 			if (axp20x_set_dcdc_workmode(rdev, i, workmode))
 				dev_err(&pdev->dev, "Failed to set workmode on %s\n",
-					axp20x_regulators[i].name);
+					rdev->desc->name);
 		}
 	}
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH RESEND v6 4/6] regulator: axp20x: add support for AXP22X regulators
@ 2015-04-10  4:09   ` Chen-Yu Tsai
  0 siblings, 0 replies; 54+ messages in thread
From: Chen-Yu Tsai @ 2015-04-10  4:09 UTC (permalink / raw)
  To: Lee Jones, Samuel Ortiz, Mark Brown, Liam Girdwood, Rob Herring,
	Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala
  Cc: Boris BREZILLON, Maxime Ripard, Carlo Caione, linux-arm-kernel,
	devicetree, linux-kernel, linux-sunxi, Chen-Yu Tsai

From: Boris BREZILLON <boris.brezillon@free-electrons.com>

Add AXP22X regulator definitions and variant id associations.
This introduces a new "switch" type output for one of the regulators.
It is a switchable secondary output of one regulator, with the same
voltage level as the primary output.

Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
[wens@csie.org: Moved variant choosing to multi family support patch]
[wens@csie.org: Add dc-dc work frequency range]
[wens@csie.org: Add "switch" type output regulator DC1SW]
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Reviewed-by: Mark Brown <broonie@kernel.org>
---

Hi Mark,
    
This patch depends on the previous patch "regulator: axp20x: prepare
support for multiple AXP chip families" and the mfd header from the
first patch "mfd: axp20x: add AXP22x PMIC support".

Could we merge both regulator patches through the mfd tree, with the
other patches in the series? There are no other external dependencies.

ChenYu

---
 drivers/regulator/axp20x-regulator.c | 96 ++++++++++++++++++++++++++++++++++++
 1 file changed, 96 insertions(+)

diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c
index 50ae0b5f2c0c..646829132b59 100644
--- a/drivers/regulator/axp20x-regulator.c
+++ b/drivers/regulator/axp20x-regulator.c
@@ -27,8 +27,12 @@
 #define AXP20X_IO_ENABLED		0x03
 #define AXP20X_IO_DISABLED		0x07
 
+#define AXP22X_IO_ENABLED		0x04
+#define AXP22X_IO_DISABLED		0x03
+
 #define AXP20X_WORKMODE_DCDC2_MASK	BIT(2)
 #define AXP20X_WORKMODE_DCDC3_MASK	BIT(1)
+#define AXP22X_WORKMODE_DCDCX_MASK(x)	BIT(x)
 
 #define AXP20X_FREQ_DCDC_MASK		0x0f
 
@@ -74,6 +78,26 @@
 		.ops		= &axp20x_ops,					\
 	}
 
+#define AXP_DESC_SW(_family, _id, _match, _supply, _min, _max, _step, _vreg,	\
+		    _vmask, _ereg, _emask) 					\
+	[_family##_##_id] = {							\
+		.name		= #_id,						\
+		.supply_name	= (_supply),					\
+		.of_match	= of_match_ptr(_match),				\
+		.regulators_node = of_match_ptr("regulators"),			\
+		.type		= REGULATOR_VOLTAGE,				\
+		.id		= _family##_##_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),					\
+		.ops		= &axp20x_ops_sw,				\
+	}
+
 #define AXP_DESC_FIXED(_family, _id, _match, _supply, _volt)			\
 	[_family##_##_id] = {							\
 		.name		= #_id,						\
@@ -135,6 +159,14 @@ static struct regulator_ops axp20x_ops = {
 	.is_enabled		= regulator_is_enabled_regmap,
 };
 
+static struct regulator_ops axp20x_ops_sw = {
+	.get_voltage_sel	= regulator_get_voltage_sel_regmap,
+	.list_voltage		= regulator_list_voltage_linear,
+	.enable			= regulator_enable_regmap,
+	.disable		= regulator_disable_regmap,
+	.is_enabled		= regulator_is_enabled_regmap,
+};
+
 static const struct regulator_desc axp20x_regulators[] = {
 	AXP_DESC(AXP20X, DCDC2, "dcdc2", "vin2", 700, 2275, 25,
 		 AXP20X_DCDC2_V_OUT, 0x3f, AXP20X_PWR_OUT_CTRL, 0x10),
@@ -152,6 +184,52 @@ static const struct regulator_desc axp20x_regulators[] = {
 		    AXP20X_IO_ENABLED, AXP20X_IO_DISABLED),
 };
 
+static const struct regulator_desc axp22x_regulators[] = {
+	AXP_DESC(AXP22X, DCDC1, "dcdc1", "vin1", 1600, 3400, 100,
+		 AXP22X_DCDC1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL1, BIT(1)),
+	AXP_DESC(AXP22X, DCDC2, "dcdc2", "vin2", 600, 1540, 20,
+		 AXP22X_DCDC2_V_OUT, 0x3f, AXP22X_PWR_OUT_CTRL1, BIT(2)),
+	AXP_DESC(AXP22X, DCDC3, "dcdc3", "vin3", 600, 1860, 20,
+		 AXP22X_DCDC3_V_OUT, 0x3f, AXP22X_PWR_OUT_CTRL1, BIT(3)),
+	AXP_DESC(AXP22X, DCDC4, "dcdc4", "vin4", 600, 1540, 20,
+		 AXP22X_DCDC4_V_OUT, 0x3f, AXP22X_PWR_OUT_CTRL1, BIT(3)),
+	AXP_DESC(AXP22X, DCDC5, "dcdc5", "vin5", 1000, 2550, 50,
+		 AXP22X_DCDC5_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL1, BIT(4)),
+	/* secondary switchable output of DCDC1 */
+	AXP_DESC_SW(AXP22X, DC1SW, "dc1sw", "dcdc1", 1600, 3400, 100,
+		    AXP22X_DCDC1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(7)),
+	/* LDO regulator internally chained to DCDC5 */
+	AXP_DESC(AXP22X, DC5LDO, "dc5ldo", "dcdc5", 700, 1400, 100,
+		 AXP22X_DC5LDO_V_OUT, 0x7, AXP22X_PWR_OUT_CTRL1, BIT(0)),
+	AXP_DESC(AXP22X, ALDO1, "aldo1", "aldoin", 700, 3300, 100,
+		 AXP22X_ALDO1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL1, BIT(6)),
+	AXP_DESC(AXP22X, ALDO2, "aldo2", "aldoin", 700, 3300, 100,
+		 AXP22X_ALDO2_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL1, BIT(7)),
+	AXP_DESC(AXP22X, ALDO3, "aldo3", "aldoin", 700, 3300, 100,
+		 AXP22X_ALDO3_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL3, BIT(7)),
+	AXP_DESC(AXP22X, DLDO1, "dldo1", "dldoin", 700, 3300, 100,
+		 AXP22X_DLDO1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(3)),
+	AXP_DESC(AXP22X, DLDO2, "dldo2", "dldoin", 700, 3300, 100,
+		 AXP22X_DLDO2_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(4)),
+	AXP_DESC(AXP22X, DLDO3, "dldo3", "dldoin", 700, 3300, 100,
+		 AXP22X_DLDO3_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(5)),
+	AXP_DESC(AXP22X, DLDO4, "dldo4", "dldoin", 700, 3300, 100,
+		 AXP22X_DLDO4_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(6)),
+	AXP_DESC(AXP22X, ELDO1, "eldo1", "eldoin", 700, 3300, 100,
+		 AXP22X_ELDO1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(0)),
+	AXP_DESC(AXP22X, ELDO2, "eldo2", "eldoin", 700, 3300, 100,
+		 AXP22X_ELDO2_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(1)),
+	AXP_DESC(AXP22X, ELDO3, "eldo3", "eldoin", 700, 3300, 100,
+		 AXP22X_ELDO3_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(2)),
+	AXP_DESC_IO(AXP22X, LDO_IO0, "ldo_io0", "ips", 1800, 3300, 100,
+		    AXP22X_LDO_IO0_V_OUT, 0x1f, AXP20X_GPIO0_CTRL, 0x07,
+		    AXP22X_IO_ENABLED, AXP22X_IO_DISABLED),
+	AXP_DESC_IO(AXP22X, LDO_IO1, "ldo_io1", "ips", 1800, 3300, 100,
+		    AXP22X_LDO_IO1_V_OUT, 0x1f, AXP20X_GPIO1_CTRL, 0x07,
+		    AXP22X_IO_ENABLED, AXP22X_IO_DISABLED),
+	AXP_DESC_FIXED(AXP22X, RTC_LDO, "rtc_ldo", "ips", 3000),
+};
+
 static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq)
 {
 	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
@@ -165,6 +243,12 @@ static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq)
 		def = 1500;
 		step = 75;
 		break;
+	case AXP221_ID:
+		min = 1800;
+		max = 4050;
+		def = 3000;
+		step = 150;
+		break;
 	default:
 		dev_err(&pdev->dev,
 			"Setting DCDC frequency for unsupported AXP variant\n");
@@ -237,6 +321,14 @@ static int axp20x_set_dcdc_workmode(struct regulator_dev *rdev, int id, u32 work
 		workmode <<= ffs(mask) - 1;
 		break;
 
+	case AXP221_ID:
+		if (id < AXP22X_DCDC1 || id > AXP22X_DCDC5)
+			return -EINVAL;
+
+		mask = AXP22X_WORKMODE_DCDCX_MASK(id - AXP22X_DCDC1);
+		workmode <<= id - AXP22X_DCDC1;
+		break;
+
 	default:
 		/* should not happen */
 		WARN_ON(1);
@@ -265,6 +357,10 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
 		regulators = axp20x_regulators;
 		nregulators = AXP20X_REG_ID_MAX;
 		break;
+	case AXP221_ID:
+		regulators = axp22x_regulators;
+		nregulators = AXP22X_REG_ID_MAX;
+		break;
 	default:
 		dev_err(&pdev->dev, "Unsupported AXP variant: %ld\n",
 			axp20x->variant);
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH RESEND v6 4/6] regulator: axp20x: add support for AXP22X regulators
@ 2015-04-10  4:09   ` Chen-Yu Tsai
  0 siblings, 0 replies; 54+ messages in thread
From: Chen-Yu Tsai @ 2015-04-10  4:09 UTC (permalink / raw)
  To: Lee Jones, Samuel Ortiz, Mark Brown, Liam Girdwood, Rob Herring,
	Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala
  Cc: Boris BREZILLON, Maxime Ripard, Carlo Caione,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw, Chen-Yu Tsai

From: Boris BREZILLON <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>

Add AXP22X regulator definitions and variant id associations.
This introduces a new "switch" type output for one of the regulators.
It is a switchable secondary output of one regulator, with the same
voltage level as the primary output.

Signed-off-by: Boris BREZILLON <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
[wens-jdAy2FN1RRM@public.gmane.org: Moved variant choosing to multi family support patch]
[wens-jdAy2FN1RRM@public.gmane.org: Add dc-dc work frequency range]
[wens-jdAy2FN1RRM@public.gmane.org: Add "switch" type output regulator DC1SW]
Signed-off-by: Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>
Reviewed-by: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
---

Hi Mark,
    
This patch depends on the previous patch "regulator: axp20x: prepare
support for multiple AXP chip families" and the mfd header from the
first patch "mfd: axp20x: add AXP22x PMIC support".

Could we merge both regulator patches through the mfd tree, with the
other patches in the series? There are no other external dependencies.

ChenYu

---
 drivers/regulator/axp20x-regulator.c | 96 ++++++++++++++++++++++++++++++++++++
 1 file changed, 96 insertions(+)

diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c
index 50ae0b5f2c0c..646829132b59 100644
--- a/drivers/regulator/axp20x-regulator.c
+++ b/drivers/regulator/axp20x-regulator.c
@@ -27,8 +27,12 @@
 #define AXP20X_IO_ENABLED		0x03
 #define AXP20X_IO_DISABLED		0x07
 
+#define AXP22X_IO_ENABLED		0x04
+#define AXP22X_IO_DISABLED		0x03
+
 #define AXP20X_WORKMODE_DCDC2_MASK	BIT(2)
 #define AXP20X_WORKMODE_DCDC3_MASK	BIT(1)
+#define AXP22X_WORKMODE_DCDCX_MASK(x)	BIT(x)
 
 #define AXP20X_FREQ_DCDC_MASK		0x0f
 
@@ -74,6 +78,26 @@
 		.ops		= &axp20x_ops,					\
 	}
 
+#define AXP_DESC_SW(_family, _id, _match, _supply, _min, _max, _step, _vreg,	\
+		    _vmask, _ereg, _emask) 					\
+	[_family##_##_id] = {							\
+		.name		= #_id,						\
+		.supply_name	= (_supply),					\
+		.of_match	= of_match_ptr(_match),				\
+		.regulators_node = of_match_ptr("regulators"),			\
+		.type		= REGULATOR_VOLTAGE,				\
+		.id		= _family##_##_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),					\
+		.ops		= &axp20x_ops_sw,				\
+	}
+
 #define AXP_DESC_FIXED(_family, _id, _match, _supply, _volt)			\
 	[_family##_##_id] = {							\
 		.name		= #_id,						\
@@ -135,6 +159,14 @@ static struct regulator_ops axp20x_ops = {
 	.is_enabled		= regulator_is_enabled_regmap,
 };
 
+static struct regulator_ops axp20x_ops_sw = {
+	.get_voltage_sel	= regulator_get_voltage_sel_regmap,
+	.list_voltage		= regulator_list_voltage_linear,
+	.enable			= regulator_enable_regmap,
+	.disable		= regulator_disable_regmap,
+	.is_enabled		= regulator_is_enabled_regmap,
+};
+
 static const struct regulator_desc axp20x_regulators[] = {
 	AXP_DESC(AXP20X, DCDC2, "dcdc2", "vin2", 700, 2275, 25,
 		 AXP20X_DCDC2_V_OUT, 0x3f, AXP20X_PWR_OUT_CTRL, 0x10),
@@ -152,6 +184,52 @@ static const struct regulator_desc axp20x_regulators[] = {
 		    AXP20X_IO_ENABLED, AXP20X_IO_DISABLED),
 };
 
+static const struct regulator_desc axp22x_regulators[] = {
+	AXP_DESC(AXP22X, DCDC1, "dcdc1", "vin1", 1600, 3400, 100,
+		 AXP22X_DCDC1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL1, BIT(1)),
+	AXP_DESC(AXP22X, DCDC2, "dcdc2", "vin2", 600, 1540, 20,
+		 AXP22X_DCDC2_V_OUT, 0x3f, AXP22X_PWR_OUT_CTRL1, BIT(2)),
+	AXP_DESC(AXP22X, DCDC3, "dcdc3", "vin3", 600, 1860, 20,
+		 AXP22X_DCDC3_V_OUT, 0x3f, AXP22X_PWR_OUT_CTRL1, BIT(3)),
+	AXP_DESC(AXP22X, DCDC4, "dcdc4", "vin4", 600, 1540, 20,
+		 AXP22X_DCDC4_V_OUT, 0x3f, AXP22X_PWR_OUT_CTRL1, BIT(3)),
+	AXP_DESC(AXP22X, DCDC5, "dcdc5", "vin5", 1000, 2550, 50,
+		 AXP22X_DCDC5_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL1, BIT(4)),
+	/* secondary switchable output of DCDC1 */
+	AXP_DESC_SW(AXP22X, DC1SW, "dc1sw", "dcdc1", 1600, 3400, 100,
+		    AXP22X_DCDC1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(7)),
+	/* LDO regulator internally chained to DCDC5 */
+	AXP_DESC(AXP22X, DC5LDO, "dc5ldo", "dcdc5", 700, 1400, 100,
+		 AXP22X_DC5LDO_V_OUT, 0x7, AXP22X_PWR_OUT_CTRL1, BIT(0)),
+	AXP_DESC(AXP22X, ALDO1, "aldo1", "aldoin", 700, 3300, 100,
+		 AXP22X_ALDO1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL1, BIT(6)),
+	AXP_DESC(AXP22X, ALDO2, "aldo2", "aldoin", 700, 3300, 100,
+		 AXP22X_ALDO2_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL1, BIT(7)),
+	AXP_DESC(AXP22X, ALDO3, "aldo3", "aldoin", 700, 3300, 100,
+		 AXP22X_ALDO3_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL3, BIT(7)),
+	AXP_DESC(AXP22X, DLDO1, "dldo1", "dldoin", 700, 3300, 100,
+		 AXP22X_DLDO1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(3)),
+	AXP_DESC(AXP22X, DLDO2, "dldo2", "dldoin", 700, 3300, 100,
+		 AXP22X_DLDO2_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(4)),
+	AXP_DESC(AXP22X, DLDO3, "dldo3", "dldoin", 700, 3300, 100,
+		 AXP22X_DLDO3_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(5)),
+	AXP_DESC(AXP22X, DLDO4, "dldo4", "dldoin", 700, 3300, 100,
+		 AXP22X_DLDO4_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(6)),
+	AXP_DESC(AXP22X, ELDO1, "eldo1", "eldoin", 700, 3300, 100,
+		 AXP22X_ELDO1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(0)),
+	AXP_DESC(AXP22X, ELDO2, "eldo2", "eldoin", 700, 3300, 100,
+		 AXP22X_ELDO2_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(1)),
+	AXP_DESC(AXP22X, ELDO3, "eldo3", "eldoin", 700, 3300, 100,
+		 AXP22X_ELDO3_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(2)),
+	AXP_DESC_IO(AXP22X, LDO_IO0, "ldo_io0", "ips", 1800, 3300, 100,
+		    AXP22X_LDO_IO0_V_OUT, 0x1f, AXP20X_GPIO0_CTRL, 0x07,
+		    AXP22X_IO_ENABLED, AXP22X_IO_DISABLED),
+	AXP_DESC_IO(AXP22X, LDO_IO1, "ldo_io1", "ips", 1800, 3300, 100,
+		    AXP22X_LDO_IO1_V_OUT, 0x1f, AXP20X_GPIO1_CTRL, 0x07,
+		    AXP22X_IO_ENABLED, AXP22X_IO_DISABLED),
+	AXP_DESC_FIXED(AXP22X, RTC_LDO, "rtc_ldo", "ips", 3000),
+};
+
 static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq)
 {
 	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
@@ -165,6 +243,12 @@ static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq)
 		def = 1500;
 		step = 75;
 		break;
+	case AXP221_ID:
+		min = 1800;
+		max = 4050;
+		def = 3000;
+		step = 150;
+		break;
 	default:
 		dev_err(&pdev->dev,
 			"Setting DCDC frequency for unsupported AXP variant\n");
@@ -237,6 +321,14 @@ static int axp20x_set_dcdc_workmode(struct regulator_dev *rdev, int id, u32 work
 		workmode <<= ffs(mask) - 1;
 		break;
 
+	case AXP221_ID:
+		if (id < AXP22X_DCDC1 || id > AXP22X_DCDC5)
+			return -EINVAL;
+
+		mask = AXP22X_WORKMODE_DCDCX_MASK(id - AXP22X_DCDC1);
+		workmode <<= id - AXP22X_DCDC1;
+		break;
+
 	default:
 		/* should not happen */
 		WARN_ON(1);
@@ -265,6 +357,10 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
 		regulators = axp20x_regulators;
 		nregulators = AXP20X_REG_ID_MAX;
 		break;
+	case AXP221_ID:
+		regulators = axp22x_regulators;
+		nregulators = AXP22X_REG_ID_MAX;
+		break;
 	default:
 		dev_err(&pdev->dev, "Unsupported AXP variant: %ld\n",
 			axp20x->variant);
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH RESEND v6 4/6] regulator: axp20x: add support for AXP22X regulators
@ 2015-04-10  4:09   ` Chen-Yu Tsai
  0 siblings, 0 replies; 54+ messages in thread
From: Chen-Yu Tsai @ 2015-04-10  4:09 UTC (permalink / raw)
  To: linux-arm-kernel

From: Boris BREZILLON <boris.brezillon@free-electrons.com>

Add AXP22X regulator definitions and variant id associations.
This introduces a new "switch" type output for one of the regulators.
It is a switchable secondary output of one regulator, with the same
voltage level as the primary output.

Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
[wens at csie.org: Moved variant choosing to multi family support patch]
[wens at csie.org: Add dc-dc work frequency range]
[wens at csie.org: Add "switch" type output regulator DC1SW]
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Reviewed-by: Mark Brown <broonie@kernel.org>
---

Hi Mark,
    
This patch depends on the previous patch "regulator: axp20x: prepare
support for multiple AXP chip families" and the mfd header from the
first patch "mfd: axp20x: add AXP22x PMIC support".

Could we merge both regulator patches through the mfd tree, with the
other patches in the series? There are no other external dependencies.

ChenYu

---
 drivers/regulator/axp20x-regulator.c | 96 ++++++++++++++++++++++++++++++++++++
 1 file changed, 96 insertions(+)

diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c
index 50ae0b5f2c0c..646829132b59 100644
--- a/drivers/regulator/axp20x-regulator.c
+++ b/drivers/regulator/axp20x-regulator.c
@@ -27,8 +27,12 @@
 #define AXP20X_IO_ENABLED		0x03
 #define AXP20X_IO_DISABLED		0x07
 
+#define AXP22X_IO_ENABLED		0x04
+#define AXP22X_IO_DISABLED		0x03
+
 #define AXP20X_WORKMODE_DCDC2_MASK	BIT(2)
 #define AXP20X_WORKMODE_DCDC3_MASK	BIT(1)
+#define AXP22X_WORKMODE_DCDCX_MASK(x)	BIT(x)
 
 #define AXP20X_FREQ_DCDC_MASK		0x0f
 
@@ -74,6 +78,26 @@
 		.ops		= &axp20x_ops,					\
 	}
 
+#define AXP_DESC_SW(_family, _id, _match, _supply, _min, _max, _step, _vreg,	\
+		    _vmask, _ereg, _emask) 					\
+	[_family##_##_id] = {							\
+		.name		= #_id,						\
+		.supply_name	= (_supply),					\
+		.of_match	= of_match_ptr(_match),				\
+		.regulators_node = of_match_ptr("regulators"),			\
+		.type		= REGULATOR_VOLTAGE,				\
+		.id		= _family##_##_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),					\
+		.ops		= &axp20x_ops_sw,				\
+	}
+
 #define AXP_DESC_FIXED(_family, _id, _match, _supply, _volt)			\
 	[_family##_##_id] = {							\
 		.name		= #_id,						\
@@ -135,6 +159,14 @@ static struct regulator_ops axp20x_ops = {
 	.is_enabled		= regulator_is_enabled_regmap,
 };
 
+static struct regulator_ops axp20x_ops_sw = {
+	.get_voltage_sel	= regulator_get_voltage_sel_regmap,
+	.list_voltage		= regulator_list_voltage_linear,
+	.enable			= regulator_enable_regmap,
+	.disable		= regulator_disable_regmap,
+	.is_enabled		= regulator_is_enabled_regmap,
+};
+
 static const struct regulator_desc axp20x_regulators[] = {
 	AXP_DESC(AXP20X, DCDC2, "dcdc2", "vin2", 700, 2275, 25,
 		 AXP20X_DCDC2_V_OUT, 0x3f, AXP20X_PWR_OUT_CTRL, 0x10),
@@ -152,6 +184,52 @@ static const struct regulator_desc axp20x_regulators[] = {
 		    AXP20X_IO_ENABLED, AXP20X_IO_DISABLED),
 };
 
+static const struct regulator_desc axp22x_regulators[] = {
+	AXP_DESC(AXP22X, DCDC1, "dcdc1", "vin1", 1600, 3400, 100,
+		 AXP22X_DCDC1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL1, BIT(1)),
+	AXP_DESC(AXP22X, DCDC2, "dcdc2", "vin2", 600, 1540, 20,
+		 AXP22X_DCDC2_V_OUT, 0x3f, AXP22X_PWR_OUT_CTRL1, BIT(2)),
+	AXP_DESC(AXP22X, DCDC3, "dcdc3", "vin3", 600, 1860, 20,
+		 AXP22X_DCDC3_V_OUT, 0x3f, AXP22X_PWR_OUT_CTRL1, BIT(3)),
+	AXP_DESC(AXP22X, DCDC4, "dcdc4", "vin4", 600, 1540, 20,
+		 AXP22X_DCDC4_V_OUT, 0x3f, AXP22X_PWR_OUT_CTRL1, BIT(3)),
+	AXP_DESC(AXP22X, DCDC5, "dcdc5", "vin5", 1000, 2550, 50,
+		 AXP22X_DCDC5_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL1, BIT(4)),
+	/* secondary switchable output of DCDC1 */
+	AXP_DESC_SW(AXP22X, DC1SW, "dc1sw", "dcdc1", 1600, 3400, 100,
+		    AXP22X_DCDC1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(7)),
+	/* LDO regulator internally chained to DCDC5 */
+	AXP_DESC(AXP22X, DC5LDO, "dc5ldo", "dcdc5", 700, 1400, 100,
+		 AXP22X_DC5LDO_V_OUT, 0x7, AXP22X_PWR_OUT_CTRL1, BIT(0)),
+	AXP_DESC(AXP22X, ALDO1, "aldo1", "aldoin", 700, 3300, 100,
+		 AXP22X_ALDO1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL1, BIT(6)),
+	AXP_DESC(AXP22X, ALDO2, "aldo2", "aldoin", 700, 3300, 100,
+		 AXP22X_ALDO2_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL1, BIT(7)),
+	AXP_DESC(AXP22X, ALDO3, "aldo3", "aldoin", 700, 3300, 100,
+		 AXP22X_ALDO3_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL3, BIT(7)),
+	AXP_DESC(AXP22X, DLDO1, "dldo1", "dldoin", 700, 3300, 100,
+		 AXP22X_DLDO1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(3)),
+	AXP_DESC(AXP22X, DLDO2, "dldo2", "dldoin", 700, 3300, 100,
+		 AXP22X_DLDO2_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(4)),
+	AXP_DESC(AXP22X, DLDO3, "dldo3", "dldoin", 700, 3300, 100,
+		 AXP22X_DLDO3_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(5)),
+	AXP_DESC(AXP22X, DLDO4, "dldo4", "dldoin", 700, 3300, 100,
+		 AXP22X_DLDO4_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(6)),
+	AXP_DESC(AXP22X, ELDO1, "eldo1", "eldoin", 700, 3300, 100,
+		 AXP22X_ELDO1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(0)),
+	AXP_DESC(AXP22X, ELDO2, "eldo2", "eldoin", 700, 3300, 100,
+		 AXP22X_ELDO2_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(1)),
+	AXP_DESC(AXP22X, ELDO3, "eldo3", "eldoin", 700, 3300, 100,
+		 AXP22X_ELDO3_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(2)),
+	AXP_DESC_IO(AXP22X, LDO_IO0, "ldo_io0", "ips", 1800, 3300, 100,
+		    AXP22X_LDO_IO0_V_OUT, 0x1f, AXP20X_GPIO0_CTRL, 0x07,
+		    AXP22X_IO_ENABLED, AXP22X_IO_DISABLED),
+	AXP_DESC_IO(AXP22X, LDO_IO1, "ldo_io1", "ips", 1800, 3300, 100,
+		    AXP22X_LDO_IO1_V_OUT, 0x1f, AXP20X_GPIO1_CTRL, 0x07,
+		    AXP22X_IO_ENABLED, AXP22X_IO_DISABLED),
+	AXP_DESC_FIXED(AXP22X, RTC_LDO, "rtc_ldo", "ips", 3000),
+};
+
 static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq)
 {
 	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
@@ -165,6 +243,12 @@ static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq)
 		def = 1500;
 		step = 75;
 		break;
+	case AXP221_ID:
+		min = 1800;
+		max = 4050;
+		def = 3000;
+		step = 150;
+		break;
 	default:
 		dev_err(&pdev->dev,
 			"Setting DCDC frequency for unsupported AXP variant\n");
@@ -237,6 +321,14 @@ static int axp20x_set_dcdc_workmode(struct regulator_dev *rdev, int id, u32 work
 		workmode <<= ffs(mask) - 1;
 		break;
 
+	case AXP221_ID:
+		if (id < AXP22X_DCDC1 || id > AXP22X_DCDC5)
+			return -EINVAL;
+
+		mask = AXP22X_WORKMODE_DCDCX_MASK(id - AXP22X_DCDC1);
+		workmode <<= id - AXP22X_DCDC1;
+		break;
+
 	default:
 		/* should not happen */
 		WARN_ON(1);
@@ -265,6 +357,10 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
 		regulators = axp20x_regulators;
 		nregulators = AXP20X_REG_ID_MAX;
 		break;
+	case AXP221_ID:
+		regulators = axp22x_regulators;
+		nregulators = AXP22X_REG_ID_MAX;
+		break;
 	default:
 		dev_err(&pdev->dev, "Unsupported AXP variant: %ld\n",
 			axp20x->variant);
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH RESEND v6 5/6] mfd: axp20x: Add AXP22x regulator information to DT bindings
@ 2015-04-10  4:09   ` Chen-Yu Tsai
  0 siblings, 0 replies; 54+ messages in thread
From: Chen-Yu Tsai @ 2015-04-10  4:09 UTC (permalink / raw)
  To: Lee Jones, Samuel Ortiz, Mark Brown, Liam Girdwood, Rob Herring,
	Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala
  Cc: Chen-Yu Tsai, Maxime Ripard, Carlo Caione, linux-arm-kernel,
	devicetree, linux-kernel, linux-sunxi

Add the list of regulators for AXP22x to the DT bindings.
This includes the names and supply names.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 Documentation/devicetree/bindings/mfd/axp20x.txt | 25 ++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/Documentation/devicetree/bindings/mfd/axp20x.txt b/Documentation/devicetree/bindings/mfd/axp20x.txt
index 3914a3f91ff6..753f14f46e85 100644
--- a/Documentation/devicetree/bindings/mfd/axp20x.txt
+++ b/Documentation/devicetree/bindings/mfd/axp20x.txt
@@ -49,6 +49,31 @@ LDO3		: LDO		: ldo3in-supply
 LDO4		: LDO		: ldo24in-supply	: shared supply
 LDO5		: LDO		: ldo5in-supply
 
+AXP221 regulators, type, and corresponding input supply names:
+
+Regulator	  Type		  Supply Name		  Notes
+---------	  ----		  -----------		  -----
+DCDC1		: DC-DC buck	: vin1-supply
+DCDC2		: DC-DC buck	: vin2-supply
+DCDC3		: DC-DC	buck	: vin3-supply
+DCDC4		: DC-DC	buck	: vin4-supply
+DCDC5		: DC-DC	buck	: vin5-supply
+DC1SW		: On/Off Switch	: dcdc1-supply		: DCDC1 secondary output
+DC5LDO		: LDO		: dcdc5-supply		: input from DCDC5
+ALDO1		: LDO		: aldoin-supply		: shared supply
+ALDO2		: LDO		: aldoin-supply		: shared supply
+ALDO3		: LDO		: aldoin-supply		: shared supply
+DLDO1		: LDO		: dldoin-supply		: shared supply
+DLDO2		: LDO		: dldoin-supply		: shared supply
+DLDO3		: LDO		: dldoin-supply		: shared supply
+DLDO4		: LDO		: dldoin-supply		: shared supply
+ELDO1		: LDO		: eldoin-supply		: shared supply
+ELDO2		: LDO		: eldoin-supply		: shared supply
+ELDO3		: LDO		: eldoin-supply		: shared supply
+LDO_IO0		: LDO		: ips-supply		: GPIO 0
+LDO_IO1		: LDO		: ips-supply		: GPIO 1
+RTC_LDO		: LDO		: ips-supply		: always on
+
 Example:
 
 axp209: pmic@34 {
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH RESEND v6 5/6] mfd: axp20x: Add AXP22x regulator information to DT bindings
@ 2015-04-10  4:09   ` Chen-Yu Tsai
  0 siblings, 0 replies; 54+ messages in thread
From: Chen-Yu Tsai @ 2015-04-10  4:09 UTC (permalink / raw)
  To: Lee Jones, Samuel Ortiz, Mark Brown, Liam Girdwood, Rob Herring,
	Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala
  Cc: Chen-Yu Tsai, Maxime Ripard, Carlo Caione,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw

Add the list of regulators for AXP22x to the DT bindings.
This includes the names and supply names.

Signed-off-by: Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>
---
 Documentation/devicetree/bindings/mfd/axp20x.txt | 25 ++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/Documentation/devicetree/bindings/mfd/axp20x.txt b/Documentation/devicetree/bindings/mfd/axp20x.txt
index 3914a3f91ff6..753f14f46e85 100644
--- a/Documentation/devicetree/bindings/mfd/axp20x.txt
+++ b/Documentation/devicetree/bindings/mfd/axp20x.txt
@@ -49,6 +49,31 @@ LDO3		: LDO		: ldo3in-supply
 LDO4		: LDO		: ldo24in-supply	: shared supply
 LDO5		: LDO		: ldo5in-supply
 
+AXP221 regulators, type, and corresponding input supply names:
+
+Regulator	  Type		  Supply Name		  Notes
+---------	  ----		  -----------		  -----
+DCDC1		: DC-DC buck	: vin1-supply
+DCDC2		: DC-DC buck	: vin2-supply
+DCDC3		: DC-DC	buck	: vin3-supply
+DCDC4		: DC-DC	buck	: vin4-supply
+DCDC5		: DC-DC	buck	: vin5-supply
+DC1SW		: On/Off Switch	: dcdc1-supply		: DCDC1 secondary output
+DC5LDO		: LDO		: dcdc5-supply		: input from DCDC5
+ALDO1		: LDO		: aldoin-supply		: shared supply
+ALDO2		: LDO		: aldoin-supply		: shared supply
+ALDO3		: LDO		: aldoin-supply		: shared supply
+DLDO1		: LDO		: dldoin-supply		: shared supply
+DLDO2		: LDO		: dldoin-supply		: shared supply
+DLDO3		: LDO		: dldoin-supply		: shared supply
+DLDO4		: LDO		: dldoin-supply		: shared supply
+ELDO1		: LDO		: eldoin-supply		: shared supply
+ELDO2		: LDO		: eldoin-supply		: shared supply
+ELDO3		: LDO		: eldoin-supply		: shared supply
+LDO_IO0		: LDO		: ips-supply		: GPIO 0
+LDO_IO1		: LDO		: ips-supply		: GPIO 1
+RTC_LDO		: LDO		: ips-supply		: always on
+
 Example:
 
 axp209: pmic@34 {
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH RESEND v6 5/6] mfd: axp20x: Add AXP22x regulator information to DT bindings
@ 2015-04-10  4:09   ` Chen-Yu Tsai
  0 siblings, 0 replies; 54+ messages in thread
From: Chen-Yu Tsai @ 2015-04-10  4:09 UTC (permalink / raw)
  To: linux-arm-kernel

Add the list of regulators for AXP22x to the DT bindings.
This includes the names and supply names.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 Documentation/devicetree/bindings/mfd/axp20x.txt | 25 ++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/Documentation/devicetree/bindings/mfd/axp20x.txt b/Documentation/devicetree/bindings/mfd/axp20x.txt
index 3914a3f91ff6..753f14f46e85 100644
--- a/Documentation/devicetree/bindings/mfd/axp20x.txt
+++ b/Documentation/devicetree/bindings/mfd/axp20x.txt
@@ -49,6 +49,31 @@ LDO3		: LDO		: ldo3in-supply
 LDO4		: LDO		: ldo24in-supply	: shared supply
 LDO5		: LDO		: ldo5in-supply
 
+AXP221 regulators, type, and corresponding input supply names:
+
+Regulator	  Type		  Supply Name		  Notes
+---------	  ----		  -----------		  -----
+DCDC1		: DC-DC buck	: vin1-supply
+DCDC2		: DC-DC buck	: vin2-supply
+DCDC3		: DC-DC	buck	: vin3-supply
+DCDC4		: DC-DC	buck	: vin4-supply
+DCDC5		: DC-DC	buck	: vin5-supply
+DC1SW		: On/Off Switch	: dcdc1-supply		: DCDC1 secondary output
+DC5LDO		: LDO		: dcdc5-supply		: input from DCDC5
+ALDO1		: LDO		: aldoin-supply		: shared supply
+ALDO2		: LDO		: aldoin-supply		: shared supply
+ALDO3		: LDO		: aldoin-supply		: shared supply
+DLDO1		: LDO		: dldoin-supply		: shared supply
+DLDO2		: LDO		: dldoin-supply		: shared supply
+DLDO3		: LDO		: dldoin-supply		: shared supply
+DLDO4		: LDO		: dldoin-supply		: shared supply
+ELDO1		: LDO		: eldoin-supply		: shared supply
+ELDO2		: LDO		: eldoin-supply		: shared supply
+ELDO3		: LDO		: eldoin-supply		: shared supply
+LDO_IO0		: LDO		: ips-supply		: GPIO 0
+LDO_IO1		: LDO		: ips-supply		: GPIO 1
+RTC_LDO		: LDO		: ips-supply		: always on
+
 Example:
 
 axp209: pmic at 34 {
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH RESEND v6 6/6] mfd: axp20x: Enable AXP22X regulators
@ 2015-04-10  4:09   ` Chen-Yu Tsai
  0 siblings, 0 replies; 54+ messages in thread
From: Chen-Yu Tsai @ 2015-04-10  4:09 UTC (permalink / raw)
  To: Lee Jones, Samuel Ortiz, Mark Brown, Liam Girdwood, Rob Herring,
	Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala
  Cc: Chen-Yu Tsai, Maxime Ripard, Carlo Caione, linux-arm-kernel,
	devicetree, linux-kernel, linux-sunxi

Now that the axp20x-regulators driver supports different variants of the
AXP family, we can enable regulator support for AXP22X without the risk
of incorrectly configuring regulators.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Acked-by: Lee Jones <lee.jones@linaro.org>
---
 drivers/mfd/axp20x.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
index cfbb7d7aead6..6df91556faf3 100644
--- a/drivers/mfd/axp20x.c
+++ b/drivers/mfd/axp20x.c
@@ -370,6 +370,8 @@ static struct mfd_cell axp22x_cells[] = {
 		.name			= "axp20x-pek",
 		.num_resources		= ARRAY_SIZE(axp22x_pek_resources),
 		.resources		= axp22x_pek_resources,
+	}, {
+		.name			= "axp20x-regulator",
 	},
 };
 
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH RESEND v6 6/6] mfd: axp20x: Enable AXP22X regulators
@ 2015-04-10  4:09   ` Chen-Yu Tsai
  0 siblings, 0 replies; 54+ messages in thread
From: Chen-Yu Tsai @ 2015-04-10  4:09 UTC (permalink / raw)
  To: Lee Jones, Samuel Ortiz, Mark Brown, Liam Girdwood, Rob Herring,
	Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala
  Cc: Chen-Yu Tsai, Maxime Ripard, Carlo Caione,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw

Now that the axp20x-regulators driver supports different variants of the
AXP family, we can enable regulator support for AXP22X without the risk
of incorrectly configuring regulators.

Signed-off-by: Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>
Acked-by: Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
 drivers/mfd/axp20x.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
index cfbb7d7aead6..6df91556faf3 100644
--- a/drivers/mfd/axp20x.c
+++ b/drivers/mfd/axp20x.c
@@ -370,6 +370,8 @@ static struct mfd_cell axp22x_cells[] = {
 		.name			= "axp20x-pek",
 		.num_resources		= ARRAY_SIZE(axp22x_pek_resources),
 		.resources		= axp22x_pek_resources,
+	}, {
+		.name			= "axp20x-regulator",
 	},
 };
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* [PATCH RESEND v6 6/6] mfd: axp20x: Enable AXP22X regulators
@ 2015-04-10  4:09   ` Chen-Yu Tsai
  0 siblings, 0 replies; 54+ messages in thread
From: Chen-Yu Tsai @ 2015-04-10  4:09 UTC (permalink / raw)
  To: linux-arm-kernel

Now that the axp20x-regulators driver supports different variants of the
AXP family, we can enable regulator support for AXP22X without the risk
of incorrectly configuring regulators.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Acked-by: Lee Jones <lee.jones@linaro.org>
---
 drivers/mfd/axp20x.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
index cfbb7d7aead6..6df91556faf3 100644
--- a/drivers/mfd/axp20x.c
+++ b/drivers/mfd/axp20x.c
@@ -370,6 +370,8 @@ static struct mfd_cell axp22x_cells[] = {
 		.name			= "axp20x-pek",
 		.num_resources		= ARRAY_SIZE(axp22x_pek_resources),
 		.resources		= axp22x_pek_resources,
+	}, {
+		.name			= "axp20x-regulator",
 	},
 };
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 54+ messages in thread

* Re: [PATCH RESEND v6 1/6] mfd: axp20x: add AXP22x PMIC support
@ 2015-04-10  9:25     ` Lee Jones
  0 siblings, 0 replies; 54+ messages in thread
From: Lee Jones @ 2015-04-10  9:25 UTC (permalink / raw)
  To: Chen-Yu Tsai
  Cc: Samuel Ortiz, Mark Brown, Liam Girdwood, Rob Herring, Pawel Moll,
	Mark Rutland, Ian Campbell, Kumar Gala, Boris BREZILLON,
	Maxime Ripard, Carlo Caione, linux-arm-kernel, devicetree,
	linux-kernel, linux-sunxi

On Fri, 10 Apr 2015, Chen-Yu Tsai wrote:

> From: Boris BREZILLON <boris.brezillon@free-electrons.com>
> 
> Add support for the AXP22x PMIC devices to the existing AXP20x driver.
> This includes the AXP221 and AXP223, which are identical except for
> the external data bus. Only AXP221 is added for now. AXP223 will be
> added after it's Reduced Serial Bus (RSB) interface is supported.
> 
> AXP22x defines a new set of registers, power supplies and regulators,
> but most of the API is similar to the AXP20x ones.
> 
> A new irq chip definition is used, even though the available interrupts
> on AXP22x is a subset of those on AXP20x. This is done so the interrupt
> numbers match those on the datasheet.
> 
> This patch only enables the interrupts, system power-off function, and PEK
> sub-device. The regulator driver must first support different variants
> before we enable it from the mfd driver.
> 
> Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
> [wens@csie.org: fix interrupts and move regulators to separate patch]
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> Acked-by: Lee Jones <lee.jones@linaro.org>
> ---
> 
> Hi Lee,
> 
> I've asked Mark about merging the regulator patches through the mfd tree
> (in the 4th patch). If he agrees, could you take the whole series?

These sorts of messages are best left in PATCH 0/X rather than hidden
in a random patch.  But yes, I'll take these patches though the MFD
tree.  It's too late to take, test and send out pull-requests for v4.1
now, but I will take them in once the merge-window closes.

> ---
>  drivers/mfd/axp20x.c       | 98 ++++++++++++++++++++++++++++++++++++++++++++++
>  include/linux/mfd/axp20x.h | 86 ++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 184 insertions(+)
> 
> diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
> index d18029be6a78..cfbb7d7aead6 100644
> --- a/drivers/mfd/axp20x.c
> +++ b/drivers/mfd/axp20x.c
> @@ -32,6 +32,7 @@
>  static const char * const axp20x_model_names[] = {
>  	"AXP202",
>  	"AXP209",
> +	"AXP221",
>  	"AXP288",
>  };
>  
> @@ -54,6 +55,25 @@ static const struct regmap_access_table axp20x_volatile_table = {
>  	.n_yes_ranges	= ARRAY_SIZE(axp20x_volatile_ranges),
>  };
>  
> +static const struct regmap_range axp22x_writeable_ranges[] = {
> +	regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_IRQ5_STATE),
> +	regmap_reg_range(AXP20X_DCDC_MODE, AXP22X_BATLOW_THRES1),
> +};
> +
> +static const struct regmap_range axp22x_volatile_ranges[] = {
> +	regmap_reg_range(AXP20X_IRQ1_EN, AXP20X_IRQ5_STATE),
> +};
> +
> +static const struct regmap_access_table axp22x_writeable_table = {
> +	.yes_ranges	= axp22x_writeable_ranges,
> +	.n_yes_ranges	= ARRAY_SIZE(axp22x_writeable_ranges),
> +};
> +
> +static const struct regmap_access_table axp22x_volatile_table = {
> +	.yes_ranges	= axp22x_volatile_ranges,
> +	.n_yes_ranges	= ARRAY_SIZE(axp22x_volatile_ranges),
> +};
> +
>  static const struct regmap_range axp288_writeable_ranges[] = {
>  	regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_IRQ6_STATE),
>  	regmap_reg_range(AXP20X_DCDC_MODE, AXP288_FG_TUNE5),
> @@ -87,6 +107,20 @@ static struct resource axp20x_pek_resources[] = {
>  	},
>  };
>  
> +static struct resource axp22x_pek_resources[] = {
> +	{
> +		.name   = "PEK_DBR",
> +		.start  = AXP22X_IRQ_PEK_RIS_EDGE,
> +		.end    = AXP22X_IRQ_PEK_RIS_EDGE,
> +		.flags  = IORESOURCE_IRQ,
> +	}, {
> +		.name   = "PEK_DBF",
> +		.start  = AXP22X_IRQ_PEK_FAL_EDGE,
> +		.end    = AXP22X_IRQ_PEK_FAL_EDGE,
> +		.flags  = IORESOURCE_IRQ,
> +	},
> +};
> +
>  static struct resource axp288_fuel_gauge_resources[] = {
>  	{
>  		.start = AXP288_IRQ_QWBTU,
> @@ -129,6 +163,15 @@ static const struct regmap_config axp20x_regmap_config = {
>  	.cache_type	= REGCACHE_RBTREE,
>  };
>  
> +static const struct regmap_config axp22x_regmap_config = {
> +	.reg_bits	= 8,
> +	.val_bits	= 8,
> +	.wr_table	= &axp22x_writeable_table,
> +	.volatile_table	= &axp22x_volatile_table,
> +	.max_register	= AXP22X_BATLOW_THRES1,
> +	.cache_type	= REGCACHE_RBTREE,
> +};
> +
>  static const struct regmap_config axp288_regmap_config = {
>  	.reg_bits	= 8,
>  	.val_bits	= 8,
> @@ -181,6 +224,34 @@ static const struct regmap_irq axp20x_regmap_irqs[] = {
>  	INIT_REGMAP_IRQ(AXP20X, GPIO0_INPUT,		4, 0),
>  };
>  
> +static const struct regmap_irq axp22x_regmap_irqs[] = {
> +	INIT_REGMAP_IRQ(AXP22X, ACIN_OVER_V,		0, 7),
> +	INIT_REGMAP_IRQ(AXP22X, ACIN_PLUGIN,		0, 6),
> +	INIT_REGMAP_IRQ(AXP22X, ACIN_REMOVAL,	        0, 5),
> +	INIT_REGMAP_IRQ(AXP22X, VBUS_OVER_V,		0, 4),
> +	INIT_REGMAP_IRQ(AXP22X, VBUS_PLUGIN,		0, 3),
> +	INIT_REGMAP_IRQ(AXP22X, VBUS_REMOVAL,	        0, 2),
> +	INIT_REGMAP_IRQ(AXP22X, VBUS_V_LOW,		0, 1),
> +	INIT_REGMAP_IRQ(AXP22X, BATT_PLUGIN,		1, 7),
> +	INIT_REGMAP_IRQ(AXP22X, BATT_REMOVAL,	        1, 6),
> +	INIT_REGMAP_IRQ(AXP22X, BATT_ENT_ACT_MODE,	1, 5),
> +	INIT_REGMAP_IRQ(AXP22X, BATT_EXIT_ACT_MODE,	1, 4),
> +	INIT_REGMAP_IRQ(AXP22X, CHARG,		        1, 3),
> +	INIT_REGMAP_IRQ(AXP22X, CHARG_DONE,		1, 2),
> +	INIT_REGMAP_IRQ(AXP22X, BATT_TEMP_HIGH,	        1, 1),
> +	INIT_REGMAP_IRQ(AXP22X, BATT_TEMP_LOW,	        1, 0),
> +	INIT_REGMAP_IRQ(AXP22X, DIE_TEMP_HIGH,	        2, 7),
> +	INIT_REGMAP_IRQ(AXP22X, PEK_SHORT,		2, 1),
> +	INIT_REGMAP_IRQ(AXP22X, PEK_LONG,		2, 0),
> +	INIT_REGMAP_IRQ(AXP22X, LOW_PWR_LVL1,	        3, 1),
> +	INIT_REGMAP_IRQ(AXP22X, LOW_PWR_LVL2,	        3, 0),
> +	INIT_REGMAP_IRQ(AXP22X, TIMER,		        4, 7),
> +	INIT_REGMAP_IRQ(AXP22X, PEK_RIS_EDGE,	        4, 6),
> +	INIT_REGMAP_IRQ(AXP22X, PEK_FAL_EDGE,	        4, 5),
> +	INIT_REGMAP_IRQ(AXP22X, GPIO1_INPUT,		4, 1),
> +	INIT_REGMAP_IRQ(AXP22X, GPIO0_INPUT,		4, 0),
> +};
> +
>  /* some IRQs are compatible with axp20x models */
>  static const struct regmap_irq axp288_regmap_irqs[] = {
>  	INIT_REGMAP_IRQ(AXP288, VBUS_FALL,              0, 2),
> @@ -224,6 +295,7 @@ static const struct regmap_irq axp288_regmap_irqs[] = {
>  static const struct of_device_id axp20x_of_match[] = {
>  	{ .compatible = "x-powers,axp202", .data = (void *) AXP202_ID },
>  	{ .compatible = "x-powers,axp209", .data = (void *) AXP209_ID },
> +	{ .compatible = "x-powers,axp221", .data = (void *) AXP221_ID },
>  	{ },
>  };
>  MODULE_DEVICE_TABLE(of, axp20x_of_match);
> @@ -258,6 +330,18 @@ static const struct regmap_irq_chip axp20x_regmap_irq_chip = {
>  
>  };
>  
> +static const struct regmap_irq_chip axp22x_regmap_irq_chip = {
> +	.name			= "axp22x_irq_chip",
> +	.status_base		= AXP20X_IRQ1_STATE,
> +	.ack_base		= AXP20X_IRQ1_STATE,
> +	.mask_base		= AXP20X_IRQ1_EN,
> +	.mask_invert		= true,
> +	.init_ack_masked	= true,
> +	.irqs			= axp22x_regmap_irqs,
> +	.num_irqs		= ARRAY_SIZE(axp22x_regmap_irqs),
> +	.num_regs		= 5,
> +};
> +
>  static const struct regmap_irq_chip axp288_regmap_irq_chip = {
>  	.name			= "axp288_irq_chip",
>  	.status_base		= AXP20X_IRQ1_STATE,
> @@ -281,6 +365,14 @@ static struct mfd_cell axp20x_cells[] = {
>  	},
>  };
>  
> +static struct mfd_cell axp22x_cells[] = {
> +	{
> +		.name			= "axp20x-pek",
> +		.num_resources		= ARRAY_SIZE(axp22x_pek_resources),
> +		.resources		= axp22x_pek_resources,
> +	},
> +};
> +
>  static struct resource axp288_adc_resources[] = {
>  	{
>  		.name  = "GPADC",
> @@ -426,6 +518,12 @@ static int axp20x_match_device(struct axp20x_dev *axp20x, struct device *dev)
>  		axp20x->regmap_cfg = &axp20x_regmap_config;
>  		axp20x->regmap_irq_chip = &axp20x_regmap_irq_chip;
>  		break;
> +	case AXP221_ID:
> +		axp20x->nr_cells = ARRAY_SIZE(axp22x_cells);
> +		axp20x->cells = axp22x_cells;
> +		axp20x->regmap_cfg = &axp22x_regmap_config;
> +		axp20x->regmap_irq_chip = &axp22x_regmap_irq_chip;
> +		break;
>  	case AXP288_ID:
>  		axp20x->cells = axp288_cells;
>  		axp20x->nr_cells = ARRAY_SIZE(axp288_cells);
> diff --git a/include/linux/mfd/axp20x.h b/include/linux/mfd/axp20x.h
> index dfabd6db7ddf..95568eb798c3 100644
> --- a/include/linux/mfd/axp20x.h
> +++ b/include/linux/mfd/axp20x.h
> @@ -14,6 +14,7 @@
>  enum {
>  	AXP202_ID = 0,
>  	AXP209_ID,
> +	AXP221_ID,
>  	AXP288_ID,
>  	NR_AXP20X_VARIANTS,
>  };
> @@ -45,6 +46,28 @@ enum {
>  #define AXP20X_V_LTF_DISCHRG		0x3c
>  #define AXP20X_V_HTF_DISCHRG		0x3d
>  
> +#define AXP22X_PWR_OUT_CTRL1		0x10
> +#define AXP22X_PWR_OUT_CTRL2		0x12
> +#define AXP22X_PWR_OUT_CTRL3		0x13
> +#define AXP22X_DLDO1_V_OUT		0x15
> +#define AXP22X_DLDO2_V_OUT		0x16
> +#define AXP22X_DLDO3_V_OUT		0x17
> +#define AXP22X_DLDO4_V_OUT		0x18
> +#define AXP22X_ELDO1_V_OUT		0x19
> +#define AXP22X_ELDO2_V_OUT		0x1a
> +#define AXP22X_ELDO3_V_OUT		0x1b
> +#define AXP22X_DC5LDO_V_OUT		0x1c
> +#define AXP22X_DCDC1_V_OUT		0x21
> +#define AXP22X_DCDC2_V_OUT		0x22
> +#define AXP22X_DCDC3_V_OUT		0x23
> +#define AXP22X_DCDC4_V_OUT		0x24
> +#define AXP22X_DCDC5_V_OUT		0x25
> +#define AXP22X_DCDC23_V_RAMP_CTRL	0x27
> +#define AXP22X_ALDO1_V_OUT		0x28
> +#define AXP22X_ALDO2_V_OUT		0x29
> +#define AXP22X_ALDO3_V_OUT		0x2a
> +#define AXP22X_CHRG_CTRL3		0x35
> +
>  /* Interrupt */
>  #define AXP20X_IRQ1_EN			0x40
>  #define AXP20X_IRQ2_EN			0x41
> @@ -100,6 +123,9 @@ enum {
>  #define AXP20X_VBUS_MON			0x8b
>  #define AXP20X_OVER_TMP			0x8f
>  
> +#define AXP22X_PWREN_CTRL1		0x8c
> +#define AXP22X_PWREN_CTRL2		0x8d
> +
>  /* GPIO */
>  #define AXP20X_GPIO0_CTRL		0x90
>  #define AXP20X_LDO5_V_OUT		0x91
> @@ -108,6 +134,11 @@ enum {
>  #define AXP20X_GPIO20_SS		0x94
>  #define AXP20X_GPIO3_CTRL		0x95
>  
> +#define AXP22X_LDO_IO0_V_OUT		0x91
> +#define AXP22X_LDO_IO1_V_OUT		0x93
> +#define AXP22X_GPIO_STATE		0x94
> +#define AXP22X_GPIO_PULL_DOWN		0x95
> +
>  /* Battery */
>  #define AXP20X_CHRG_CC_31_24		0xb0
>  #define AXP20X_CHRG_CC_23_16		0xb1
> @@ -120,6 +151,9 @@ enum {
>  #define AXP20X_CC_CTRL			0xb8
>  #define AXP20X_FG_RES			0xb9
>  
> +/* AXP22X specific registers */
> +#define AXP22X_BATLOW_THRES1		0xe6
> +
>  /* AXP288 specific registers */
>  #define AXP288_PMIC_ADC_H               0x56
>  #define AXP288_PMIC_ADC_L               0x57
> @@ -158,6 +192,30 @@ enum {
>  	AXP20X_REG_ID_MAX,
>  };
>  
> +enum {
> +	AXP22X_DCDC1 = 0,
> +	AXP22X_DCDC2,
> +	AXP22X_DCDC3,
> +	AXP22X_DCDC4,
> +	AXP22X_DCDC5,
> +	AXP22X_DC1SW,
> +	AXP22X_DC5LDO,
> +	AXP22X_ALDO1,
> +	AXP22X_ALDO2,
> +	AXP22X_ALDO3,
> +	AXP22X_ELDO1,
> +	AXP22X_ELDO2,
> +	AXP22X_ELDO3,
> +	AXP22X_DLDO1,
> +	AXP22X_DLDO2,
> +	AXP22X_DLDO3,
> +	AXP22X_DLDO4,
> +	AXP22X_RTC_LDO,
> +	AXP22X_LDO_IO0,
> +	AXP22X_LDO_IO1,
> +	AXP22X_REG_ID_MAX,
> +};
> +
>  /* IRQs */
>  enum {
>  	AXP20X_IRQ_ACIN_OVER_V = 1,
> @@ -199,6 +257,34 @@ enum {
>  	AXP20X_IRQ_GPIO0_INPUT,
>  };
>  
> +enum axp22x_irqs {
> +	AXP22X_IRQ_ACIN_OVER_V = 1,
> +	AXP22X_IRQ_ACIN_PLUGIN,
> +	AXP22X_IRQ_ACIN_REMOVAL,
> +	AXP22X_IRQ_VBUS_OVER_V,
> +	AXP22X_IRQ_VBUS_PLUGIN,
> +	AXP22X_IRQ_VBUS_REMOVAL,
> +	AXP22X_IRQ_VBUS_V_LOW,
> +	AXP22X_IRQ_BATT_PLUGIN,
> +	AXP22X_IRQ_BATT_REMOVAL,
> +	AXP22X_IRQ_BATT_ENT_ACT_MODE,
> +	AXP22X_IRQ_BATT_EXIT_ACT_MODE,
> +	AXP22X_IRQ_CHARG,
> +	AXP22X_IRQ_CHARG_DONE,
> +	AXP22X_IRQ_BATT_TEMP_HIGH,
> +	AXP22X_IRQ_BATT_TEMP_LOW,
> +	AXP22X_IRQ_DIE_TEMP_HIGH,
> +	AXP22X_IRQ_PEK_SHORT,
> +	AXP22X_IRQ_PEK_LONG,
> +	AXP22X_IRQ_LOW_PWR_LVL1,
> +	AXP22X_IRQ_LOW_PWR_LVL2,
> +	AXP22X_IRQ_TIMER,
> +	AXP22X_IRQ_PEK_RIS_EDGE,
> +	AXP22X_IRQ_PEK_FAL_EDGE,
> +	AXP22X_IRQ_GPIO1_INPUT,
> +	AXP22X_IRQ_GPIO0_INPUT,
> +};
> +
>  enum axp288_irqs {
>  	AXP288_IRQ_VBUS_FALL     = 2,
>  	AXP288_IRQ_VBUS_RISE,

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH RESEND v6 1/6] mfd: axp20x: add AXP22x PMIC support
@ 2015-04-10  9:25     ` Lee Jones
  0 siblings, 0 replies; 54+ messages in thread
From: Lee Jones @ 2015-04-10  9:25 UTC (permalink / raw)
  To: Chen-Yu Tsai
  Cc: Samuel Ortiz, Mark Brown, Liam Girdwood, Rob Herring, Pawel Moll,
	Mark Rutland, Ian Campbell, Kumar Gala, Boris BREZILLON,
	Maxime Ripard, Carlo Caione,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw

On Fri, 10 Apr 2015, Chen-Yu Tsai wrote:

> From: Boris BREZILLON <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> 
> Add support for the AXP22x PMIC devices to the existing AXP20x driver.
> This includes the AXP221 and AXP223, which are identical except for
> the external data bus. Only AXP221 is added for now. AXP223 will be
> added after it's Reduced Serial Bus (RSB) interface is supported.
> 
> AXP22x defines a new set of registers, power supplies and regulators,
> but most of the API is similar to the AXP20x ones.
> 
> A new irq chip definition is used, even though the available interrupts
> on AXP22x is a subset of those on AXP20x. This is done so the interrupt
> numbers match those on the datasheet.
> 
> This patch only enables the interrupts, system power-off function, and PEK
> sub-device. The regulator driver must first support different variants
> before we enable it from the mfd driver.
> 
> Signed-off-by: Boris BREZILLON <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> [wens-jdAy2FN1RRM@public.gmane.org: fix interrupts and move regulators to separate patch]
> Signed-off-by: Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>
> Acked-by: Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> ---
> 
> Hi Lee,
> 
> I've asked Mark about merging the regulator patches through the mfd tree
> (in the 4th patch). If he agrees, could you take the whole series?

These sorts of messages are best left in PATCH 0/X rather than hidden
in a random patch.  But yes, I'll take these patches though the MFD
tree.  It's too late to take, test and send out pull-requests for v4.1
now, but I will take them in once the merge-window closes.

> ---
>  drivers/mfd/axp20x.c       | 98 ++++++++++++++++++++++++++++++++++++++++++++++
>  include/linux/mfd/axp20x.h | 86 ++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 184 insertions(+)
> 
> diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
> index d18029be6a78..cfbb7d7aead6 100644
> --- a/drivers/mfd/axp20x.c
> +++ b/drivers/mfd/axp20x.c
> @@ -32,6 +32,7 @@
>  static const char * const axp20x_model_names[] = {
>  	"AXP202",
>  	"AXP209",
> +	"AXP221",
>  	"AXP288",
>  };
>  
> @@ -54,6 +55,25 @@ static const struct regmap_access_table axp20x_volatile_table = {
>  	.n_yes_ranges	= ARRAY_SIZE(axp20x_volatile_ranges),
>  };
>  
> +static const struct regmap_range axp22x_writeable_ranges[] = {
> +	regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_IRQ5_STATE),
> +	regmap_reg_range(AXP20X_DCDC_MODE, AXP22X_BATLOW_THRES1),
> +};
> +
> +static const struct regmap_range axp22x_volatile_ranges[] = {
> +	regmap_reg_range(AXP20X_IRQ1_EN, AXP20X_IRQ5_STATE),
> +};
> +
> +static const struct regmap_access_table axp22x_writeable_table = {
> +	.yes_ranges	= axp22x_writeable_ranges,
> +	.n_yes_ranges	= ARRAY_SIZE(axp22x_writeable_ranges),
> +};
> +
> +static const struct regmap_access_table axp22x_volatile_table = {
> +	.yes_ranges	= axp22x_volatile_ranges,
> +	.n_yes_ranges	= ARRAY_SIZE(axp22x_volatile_ranges),
> +};
> +
>  static const struct regmap_range axp288_writeable_ranges[] = {
>  	regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_IRQ6_STATE),
>  	regmap_reg_range(AXP20X_DCDC_MODE, AXP288_FG_TUNE5),
> @@ -87,6 +107,20 @@ static struct resource axp20x_pek_resources[] = {
>  	},
>  };
>  
> +static struct resource axp22x_pek_resources[] = {
> +	{
> +		.name   = "PEK_DBR",
> +		.start  = AXP22X_IRQ_PEK_RIS_EDGE,
> +		.end    = AXP22X_IRQ_PEK_RIS_EDGE,
> +		.flags  = IORESOURCE_IRQ,
> +	}, {
> +		.name   = "PEK_DBF",
> +		.start  = AXP22X_IRQ_PEK_FAL_EDGE,
> +		.end    = AXP22X_IRQ_PEK_FAL_EDGE,
> +		.flags  = IORESOURCE_IRQ,
> +	},
> +};
> +
>  static struct resource axp288_fuel_gauge_resources[] = {
>  	{
>  		.start = AXP288_IRQ_QWBTU,
> @@ -129,6 +163,15 @@ static const struct regmap_config axp20x_regmap_config = {
>  	.cache_type	= REGCACHE_RBTREE,
>  };
>  
> +static const struct regmap_config axp22x_regmap_config = {
> +	.reg_bits	= 8,
> +	.val_bits	= 8,
> +	.wr_table	= &axp22x_writeable_table,
> +	.volatile_table	= &axp22x_volatile_table,
> +	.max_register	= AXP22X_BATLOW_THRES1,
> +	.cache_type	= REGCACHE_RBTREE,
> +};
> +
>  static const struct regmap_config axp288_regmap_config = {
>  	.reg_bits	= 8,
>  	.val_bits	= 8,
> @@ -181,6 +224,34 @@ static const struct regmap_irq axp20x_regmap_irqs[] = {
>  	INIT_REGMAP_IRQ(AXP20X, GPIO0_INPUT,		4, 0),
>  };
>  
> +static const struct regmap_irq axp22x_regmap_irqs[] = {
> +	INIT_REGMAP_IRQ(AXP22X, ACIN_OVER_V,		0, 7),
> +	INIT_REGMAP_IRQ(AXP22X, ACIN_PLUGIN,		0, 6),
> +	INIT_REGMAP_IRQ(AXP22X, ACIN_REMOVAL,	        0, 5),
> +	INIT_REGMAP_IRQ(AXP22X, VBUS_OVER_V,		0, 4),
> +	INIT_REGMAP_IRQ(AXP22X, VBUS_PLUGIN,		0, 3),
> +	INIT_REGMAP_IRQ(AXP22X, VBUS_REMOVAL,	        0, 2),
> +	INIT_REGMAP_IRQ(AXP22X, VBUS_V_LOW,		0, 1),
> +	INIT_REGMAP_IRQ(AXP22X, BATT_PLUGIN,		1, 7),
> +	INIT_REGMAP_IRQ(AXP22X, BATT_REMOVAL,	        1, 6),
> +	INIT_REGMAP_IRQ(AXP22X, BATT_ENT_ACT_MODE,	1, 5),
> +	INIT_REGMAP_IRQ(AXP22X, BATT_EXIT_ACT_MODE,	1, 4),
> +	INIT_REGMAP_IRQ(AXP22X, CHARG,		        1, 3),
> +	INIT_REGMAP_IRQ(AXP22X, CHARG_DONE,		1, 2),
> +	INIT_REGMAP_IRQ(AXP22X, BATT_TEMP_HIGH,	        1, 1),
> +	INIT_REGMAP_IRQ(AXP22X, BATT_TEMP_LOW,	        1, 0),
> +	INIT_REGMAP_IRQ(AXP22X, DIE_TEMP_HIGH,	        2, 7),
> +	INIT_REGMAP_IRQ(AXP22X, PEK_SHORT,		2, 1),
> +	INIT_REGMAP_IRQ(AXP22X, PEK_LONG,		2, 0),
> +	INIT_REGMAP_IRQ(AXP22X, LOW_PWR_LVL1,	        3, 1),
> +	INIT_REGMAP_IRQ(AXP22X, LOW_PWR_LVL2,	        3, 0),
> +	INIT_REGMAP_IRQ(AXP22X, TIMER,		        4, 7),
> +	INIT_REGMAP_IRQ(AXP22X, PEK_RIS_EDGE,	        4, 6),
> +	INIT_REGMAP_IRQ(AXP22X, PEK_FAL_EDGE,	        4, 5),
> +	INIT_REGMAP_IRQ(AXP22X, GPIO1_INPUT,		4, 1),
> +	INIT_REGMAP_IRQ(AXP22X, GPIO0_INPUT,		4, 0),
> +};
> +
>  /* some IRQs are compatible with axp20x models */
>  static const struct regmap_irq axp288_regmap_irqs[] = {
>  	INIT_REGMAP_IRQ(AXP288, VBUS_FALL,              0, 2),
> @@ -224,6 +295,7 @@ static const struct regmap_irq axp288_regmap_irqs[] = {
>  static const struct of_device_id axp20x_of_match[] = {
>  	{ .compatible = "x-powers,axp202", .data = (void *) AXP202_ID },
>  	{ .compatible = "x-powers,axp209", .data = (void *) AXP209_ID },
> +	{ .compatible = "x-powers,axp221", .data = (void *) AXP221_ID },
>  	{ },
>  };
>  MODULE_DEVICE_TABLE(of, axp20x_of_match);
> @@ -258,6 +330,18 @@ static const struct regmap_irq_chip axp20x_regmap_irq_chip = {
>  
>  };
>  
> +static const struct regmap_irq_chip axp22x_regmap_irq_chip = {
> +	.name			= "axp22x_irq_chip",
> +	.status_base		= AXP20X_IRQ1_STATE,
> +	.ack_base		= AXP20X_IRQ1_STATE,
> +	.mask_base		= AXP20X_IRQ1_EN,
> +	.mask_invert		= true,
> +	.init_ack_masked	= true,
> +	.irqs			= axp22x_regmap_irqs,
> +	.num_irqs		= ARRAY_SIZE(axp22x_regmap_irqs),
> +	.num_regs		= 5,
> +};
> +
>  static const struct regmap_irq_chip axp288_regmap_irq_chip = {
>  	.name			= "axp288_irq_chip",
>  	.status_base		= AXP20X_IRQ1_STATE,
> @@ -281,6 +365,14 @@ static struct mfd_cell axp20x_cells[] = {
>  	},
>  };
>  
> +static struct mfd_cell axp22x_cells[] = {
> +	{
> +		.name			= "axp20x-pek",
> +		.num_resources		= ARRAY_SIZE(axp22x_pek_resources),
> +		.resources		= axp22x_pek_resources,
> +	},
> +};
> +
>  static struct resource axp288_adc_resources[] = {
>  	{
>  		.name  = "GPADC",
> @@ -426,6 +518,12 @@ static int axp20x_match_device(struct axp20x_dev *axp20x, struct device *dev)
>  		axp20x->regmap_cfg = &axp20x_regmap_config;
>  		axp20x->regmap_irq_chip = &axp20x_regmap_irq_chip;
>  		break;
> +	case AXP221_ID:
> +		axp20x->nr_cells = ARRAY_SIZE(axp22x_cells);
> +		axp20x->cells = axp22x_cells;
> +		axp20x->regmap_cfg = &axp22x_regmap_config;
> +		axp20x->regmap_irq_chip = &axp22x_regmap_irq_chip;
> +		break;
>  	case AXP288_ID:
>  		axp20x->cells = axp288_cells;
>  		axp20x->nr_cells = ARRAY_SIZE(axp288_cells);
> diff --git a/include/linux/mfd/axp20x.h b/include/linux/mfd/axp20x.h
> index dfabd6db7ddf..95568eb798c3 100644
> --- a/include/linux/mfd/axp20x.h
> +++ b/include/linux/mfd/axp20x.h
> @@ -14,6 +14,7 @@
>  enum {
>  	AXP202_ID = 0,
>  	AXP209_ID,
> +	AXP221_ID,
>  	AXP288_ID,
>  	NR_AXP20X_VARIANTS,
>  };
> @@ -45,6 +46,28 @@ enum {
>  #define AXP20X_V_LTF_DISCHRG		0x3c
>  #define AXP20X_V_HTF_DISCHRG		0x3d
>  
> +#define AXP22X_PWR_OUT_CTRL1		0x10
> +#define AXP22X_PWR_OUT_CTRL2		0x12
> +#define AXP22X_PWR_OUT_CTRL3		0x13
> +#define AXP22X_DLDO1_V_OUT		0x15
> +#define AXP22X_DLDO2_V_OUT		0x16
> +#define AXP22X_DLDO3_V_OUT		0x17
> +#define AXP22X_DLDO4_V_OUT		0x18
> +#define AXP22X_ELDO1_V_OUT		0x19
> +#define AXP22X_ELDO2_V_OUT		0x1a
> +#define AXP22X_ELDO3_V_OUT		0x1b
> +#define AXP22X_DC5LDO_V_OUT		0x1c
> +#define AXP22X_DCDC1_V_OUT		0x21
> +#define AXP22X_DCDC2_V_OUT		0x22
> +#define AXP22X_DCDC3_V_OUT		0x23
> +#define AXP22X_DCDC4_V_OUT		0x24
> +#define AXP22X_DCDC5_V_OUT		0x25
> +#define AXP22X_DCDC23_V_RAMP_CTRL	0x27
> +#define AXP22X_ALDO1_V_OUT		0x28
> +#define AXP22X_ALDO2_V_OUT		0x29
> +#define AXP22X_ALDO3_V_OUT		0x2a
> +#define AXP22X_CHRG_CTRL3		0x35
> +
>  /* Interrupt */
>  #define AXP20X_IRQ1_EN			0x40
>  #define AXP20X_IRQ2_EN			0x41
> @@ -100,6 +123,9 @@ enum {
>  #define AXP20X_VBUS_MON			0x8b
>  #define AXP20X_OVER_TMP			0x8f
>  
> +#define AXP22X_PWREN_CTRL1		0x8c
> +#define AXP22X_PWREN_CTRL2		0x8d
> +
>  /* GPIO */
>  #define AXP20X_GPIO0_CTRL		0x90
>  #define AXP20X_LDO5_V_OUT		0x91
> @@ -108,6 +134,11 @@ enum {
>  #define AXP20X_GPIO20_SS		0x94
>  #define AXP20X_GPIO3_CTRL		0x95
>  
> +#define AXP22X_LDO_IO0_V_OUT		0x91
> +#define AXP22X_LDO_IO1_V_OUT		0x93
> +#define AXP22X_GPIO_STATE		0x94
> +#define AXP22X_GPIO_PULL_DOWN		0x95
> +
>  /* Battery */
>  #define AXP20X_CHRG_CC_31_24		0xb0
>  #define AXP20X_CHRG_CC_23_16		0xb1
> @@ -120,6 +151,9 @@ enum {
>  #define AXP20X_CC_CTRL			0xb8
>  #define AXP20X_FG_RES			0xb9
>  
> +/* AXP22X specific registers */
> +#define AXP22X_BATLOW_THRES1		0xe6
> +
>  /* AXP288 specific registers */
>  #define AXP288_PMIC_ADC_H               0x56
>  #define AXP288_PMIC_ADC_L               0x57
> @@ -158,6 +192,30 @@ enum {
>  	AXP20X_REG_ID_MAX,
>  };
>  
> +enum {
> +	AXP22X_DCDC1 = 0,
> +	AXP22X_DCDC2,
> +	AXP22X_DCDC3,
> +	AXP22X_DCDC4,
> +	AXP22X_DCDC5,
> +	AXP22X_DC1SW,
> +	AXP22X_DC5LDO,
> +	AXP22X_ALDO1,
> +	AXP22X_ALDO2,
> +	AXP22X_ALDO3,
> +	AXP22X_ELDO1,
> +	AXP22X_ELDO2,
> +	AXP22X_ELDO3,
> +	AXP22X_DLDO1,
> +	AXP22X_DLDO2,
> +	AXP22X_DLDO3,
> +	AXP22X_DLDO4,
> +	AXP22X_RTC_LDO,
> +	AXP22X_LDO_IO0,
> +	AXP22X_LDO_IO1,
> +	AXP22X_REG_ID_MAX,
> +};
> +
>  /* IRQs */
>  enum {
>  	AXP20X_IRQ_ACIN_OVER_V = 1,
> @@ -199,6 +257,34 @@ enum {
>  	AXP20X_IRQ_GPIO0_INPUT,
>  };
>  
> +enum axp22x_irqs {
> +	AXP22X_IRQ_ACIN_OVER_V = 1,
> +	AXP22X_IRQ_ACIN_PLUGIN,
> +	AXP22X_IRQ_ACIN_REMOVAL,
> +	AXP22X_IRQ_VBUS_OVER_V,
> +	AXP22X_IRQ_VBUS_PLUGIN,
> +	AXP22X_IRQ_VBUS_REMOVAL,
> +	AXP22X_IRQ_VBUS_V_LOW,
> +	AXP22X_IRQ_BATT_PLUGIN,
> +	AXP22X_IRQ_BATT_REMOVAL,
> +	AXP22X_IRQ_BATT_ENT_ACT_MODE,
> +	AXP22X_IRQ_BATT_EXIT_ACT_MODE,
> +	AXP22X_IRQ_CHARG,
> +	AXP22X_IRQ_CHARG_DONE,
> +	AXP22X_IRQ_BATT_TEMP_HIGH,
> +	AXP22X_IRQ_BATT_TEMP_LOW,
> +	AXP22X_IRQ_DIE_TEMP_HIGH,
> +	AXP22X_IRQ_PEK_SHORT,
> +	AXP22X_IRQ_PEK_LONG,
> +	AXP22X_IRQ_LOW_PWR_LVL1,
> +	AXP22X_IRQ_LOW_PWR_LVL2,
> +	AXP22X_IRQ_TIMER,
> +	AXP22X_IRQ_PEK_RIS_EDGE,
> +	AXP22X_IRQ_PEK_FAL_EDGE,
> +	AXP22X_IRQ_GPIO1_INPUT,
> +	AXP22X_IRQ_GPIO0_INPUT,
> +};
> +
>  enum axp288_irqs {
>  	AXP288_IRQ_VBUS_FALL     = 2,
>  	AXP288_IRQ_VBUS_RISE,

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

-- 
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/d/optout.

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH RESEND v6 1/6] mfd: axp20x: add AXP22x PMIC support
@ 2015-04-10  9:25     ` Lee Jones
  0 siblings, 0 replies; 54+ messages in thread
From: Lee Jones @ 2015-04-10  9:25 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, 10 Apr 2015, Chen-Yu Tsai wrote:

> From: Boris BREZILLON <boris.brezillon@free-electrons.com>
> 
> Add support for the AXP22x PMIC devices to the existing AXP20x driver.
> This includes the AXP221 and AXP223, which are identical except for
> the external data bus. Only AXP221 is added for now. AXP223 will be
> added after it's Reduced Serial Bus (RSB) interface is supported.
> 
> AXP22x defines a new set of registers, power supplies and regulators,
> but most of the API is similar to the AXP20x ones.
> 
> A new irq chip definition is used, even though the available interrupts
> on AXP22x is a subset of those on AXP20x. This is done so the interrupt
> numbers match those on the datasheet.
> 
> This patch only enables the interrupts, system power-off function, and PEK
> sub-device. The regulator driver must first support different variants
> before we enable it from the mfd driver.
> 
> Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
> [wens at csie.org: fix interrupts and move regulators to separate patch]
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> Acked-by: Lee Jones <lee.jones@linaro.org>
> ---
> 
> Hi Lee,
> 
> I've asked Mark about merging the regulator patches through the mfd tree
> (in the 4th patch). If he agrees, could you take the whole series?

These sorts of messages are best left in PATCH 0/X rather than hidden
in a random patch.  But yes, I'll take these patches though the MFD
tree.  It's too late to take, test and send out pull-requests for v4.1
now, but I will take them in once the merge-window closes.

> ---
>  drivers/mfd/axp20x.c       | 98 ++++++++++++++++++++++++++++++++++++++++++++++
>  include/linux/mfd/axp20x.h | 86 ++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 184 insertions(+)
> 
> diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
> index d18029be6a78..cfbb7d7aead6 100644
> --- a/drivers/mfd/axp20x.c
> +++ b/drivers/mfd/axp20x.c
> @@ -32,6 +32,7 @@
>  static const char * const axp20x_model_names[] = {
>  	"AXP202",
>  	"AXP209",
> +	"AXP221",
>  	"AXP288",
>  };
>  
> @@ -54,6 +55,25 @@ static const struct regmap_access_table axp20x_volatile_table = {
>  	.n_yes_ranges	= ARRAY_SIZE(axp20x_volatile_ranges),
>  };
>  
> +static const struct regmap_range axp22x_writeable_ranges[] = {
> +	regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_IRQ5_STATE),
> +	regmap_reg_range(AXP20X_DCDC_MODE, AXP22X_BATLOW_THRES1),
> +};
> +
> +static const struct regmap_range axp22x_volatile_ranges[] = {
> +	regmap_reg_range(AXP20X_IRQ1_EN, AXP20X_IRQ5_STATE),
> +};
> +
> +static const struct regmap_access_table axp22x_writeable_table = {
> +	.yes_ranges	= axp22x_writeable_ranges,
> +	.n_yes_ranges	= ARRAY_SIZE(axp22x_writeable_ranges),
> +};
> +
> +static const struct regmap_access_table axp22x_volatile_table = {
> +	.yes_ranges	= axp22x_volatile_ranges,
> +	.n_yes_ranges	= ARRAY_SIZE(axp22x_volatile_ranges),
> +};
> +
>  static const struct regmap_range axp288_writeable_ranges[] = {
>  	regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_IRQ6_STATE),
>  	regmap_reg_range(AXP20X_DCDC_MODE, AXP288_FG_TUNE5),
> @@ -87,6 +107,20 @@ static struct resource axp20x_pek_resources[] = {
>  	},
>  };
>  
> +static struct resource axp22x_pek_resources[] = {
> +	{
> +		.name   = "PEK_DBR",
> +		.start  = AXP22X_IRQ_PEK_RIS_EDGE,
> +		.end    = AXP22X_IRQ_PEK_RIS_EDGE,
> +		.flags  = IORESOURCE_IRQ,
> +	}, {
> +		.name   = "PEK_DBF",
> +		.start  = AXP22X_IRQ_PEK_FAL_EDGE,
> +		.end    = AXP22X_IRQ_PEK_FAL_EDGE,
> +		.flags  = IORESOURCE_IRQ,
> +	},
> +};
> +
>  static struct resource axp288_fuel_gauge_resources[] = {
>  	{
>  		.start = AXP288_IRQ_QWBTU,
> @@ -129,6 +163,15 @@ static const struct regmap_config axp20x_regmap_config = {
>  	.cache_type	= REGCACHE_RBTREE,
>  };
>  
> +static const struct regmap_config axp22x_regmap_config = {
> +	.reg_bits	= 8,
> +	.val_bits	= 8,
> +	.wr_table	= &axp22x_writeable_table,
> +	.volatile_table	= &axp22x_volatile_table,
> +	.max_register	= AXP22X_BATLOW_THRES1,
> +	.cache_type	= REGCACHE_RBTREE,
> +};
> +
>  static const struct regmap_config axp288_regmap_config = {
>  	.reg_bits	= 8,
>  	.val_bits	= 8,
> @@ -181,6 +224,34 @@ static const struct regmap_irq axp20x_regmap_irqs[] = {
>  	INIT_REGMAP_IRQ(AXP20X, GPIO0_INPUT,		4, 0),
>  };
>  
> +static const struct regmap_irq axp22x_regmap_irqs[] = {
> +	INIT_REGMAP_IRQ(AXP22X, ACIN_OVER_V,		0, 7),
> +	INIT_REGMAP_IRQ(AXP22X, ACIN_PLUGIN,		0, 6),
> +	INIT_REGMAP_IRQ(AXP22X, ACIN_REMOVAL,	        0, 5),
> +	INIT_REGMAP_IRQ(AXP22X, VBUS_OVER_V,		0, 4),
> +	INIT_REGMAP_IRQ(AXP22X, VBUS_PLUGIN,		0, 3),
> +	INIT_REGMAP_IRQ(AXP22X, VBUS_REMOVAL,	        0, 2),
> +	INIT_REGMAP_IRQ(AXP22X, VBUS_V_LOW,		0, 1),
> +	INIT_REGMAP_IRQ(AXP22X, BATT_PLUGIN,		1, 7),
> +	INIT_REGMAP_IRQ(AXP22X, BATT_REMOVAL,	        1, 6),
> +	INIT_REGMAP_IRQ(AXP22X, BATT_ENT_ACT_MODE,	1, 5),
> +	INIT_REGMAP_IRQ(AXP22X, BATT_EXIT_ACT_MODE,	1, 4),
> +	INIT_REGMAP_IRQ(AXP22X, CHARG,		        1, 3),
> +	INIT_REGMAP_IRQ(AXP22X, CHARG_DONE,		1, 2),
> +	INIT_REGMAP_IRQ(AXP22X, BATT_TEMP_HIGH,	        1, 1),
> +	INIT_REGMAP_IRQ(AXP22X, BATT_TEMP_LOW,	        1, 0),
> +	INIT_REGMAP_IRQ(AXP22X, DIE_TEMP_HIGH,	        2, 7),
> +	INIT_REGMAP_IRQ(AXP22X, PEK_SHORT,		2, 1),
> +	INIT_REGMAP_IRQ(AXP22X, PEK_LONG,		2, 0),
> +	INIT_REGMAP_IRQ(AXP22X, LOW_PWR_LVL1,	        3, 1),
> +	INIT_REGMAP_IRQ(AXP22X, LOW_PWR_LVL2,	        3, 0),
> +	INIT_REGMAP_IRQ(AXP22X, TIMER,		        4, 7),
> +	INIT_REGMAP_IRQ(AXP22X, PEK_RIS_EDGE,	        4, 6),
> +	INIT_REGMAP_IRQ(AXP22X, PEK_FAL_EDGE,	        4, 5),
> +	INIT_REGMAP_IRQ(AXP22X, GPIO1_INPUT,		4, 1),
> +	INIT_REGMAP_IRQ(AXP22X, GPIO0_INPUT,		4, 0),
> +};
> +
>  /* some IRQs are compatible with axp20x models */
>  static const struct regmap_irq axp288_regmap_irqs[] = {
>  	INIT_REGMAP_IRQ(AXP288, VBUS_FALL,              0, 2),
> @@ -224,6 +295,7 @@ static const struct regmap_irq axp288_regmap_irqs[] = {
>  static const struct of_device_id axp20x_of_match[] = {
>  	{ .compatible = "x-powers,axp202", .data = (void *) AXP202_ID },
>  	{ .compatible = "x-powers,axp209", .data = (void *) AXP209_ID },
> +	{ .compatible = "x-powers,axp221", .data = (void *) AXP221_ID },
>  	{ },
>  };
>  MODULE_DEVICE_TABLE(of, axp20x_of_match);
> @@ -258,6 +330,18 @@ static const struct regmap_irq_chip axp20x_regmap_irq_chip = {
>  
>  };
>  
> +static const struct regmap_irq_chip axp22x_regmap_irq_chip = {
> +	.name			= "axp22x_irq_chip",
> +	.status_base		= AXP20X_IRQ1_STATE,
> +	.ack_base		= AXP20X_IRQ1_STATE,
> +	.mask_base		= AXP20X_IRQ1_EN,
> +	.mask_invert		= true,
> +	.init_ack_masked	= true,
> +	.irqs			= axp22x_regmap_irqs,
> +	.num_irqs		= ARRAY_SIZE(axp22x_regmap_irqs),
> +	.num_regs		= 5,
> +};
> +
>  static const struct regmap_irq_chip axp288_regmap_irq_chip = {
>  	.name			= "axp288_irq_chip",
>  	.status_base		= AXP20X_IRQ1_STATE,
> @@ -281,6 +365,14 @@ static struct mfd_cell axp20x_cells[] = {
>  	},
>  };
>  
> +static struct mfd_cell axp22x_cells[] = {
> +	{
> +		.name			= "axp20x-pek",
> +		.num_resources		= ARRAY_SIZE(axp22x_pek_resources),
> +		.resources		= axp22x_pek_resources,
> +	},
> +};
> +
>  static struct resource axp288_adc_resources[] = {
>  	{
>  		.name  = "GPADC",
> @@ -426,6 +518,12 @@ static int axp20x_match_device(struct axp20x_dev *axp20x, struct device *dev)
>  		axp20x->regmap_cfg = &axp20x_regmap_config;
>  		axp20x->regmap_irq_chip = &axp20x_regmap_irq_chip;
>  		break;
> +	case AXP221_ID:
> +		axp20x->nr_cells = ARRAY_SIZE(axp22x_cells);
> +		axp20x->cells = axp22x_cells;
> +		axp20x->regmap_cfg = &axp22x_regmap_config;
> +		axp20x->regmap_irq_chip = &axp22x_regmap_irq_chip;
> +		break;
>  	case AXP288_ID:
>  		axp20x->cells = axp288_cells;
>  		axp20x->nr_cells = ARRAY_SIZE(axp288_cells);
> diff --git a/include/linux/mfd/axp20x.h b/include/linux/mfd/axp20x.h
> index dfabd6db7ddf..95568eb798c3 100644
> --- a/include/linux/mfd/axp20x.h
> +++ b/include/linux/mfd/axp20x.h
> @@ -14,6 +14,7 @@
>  enum {
>  	AXP202_ID = 0,
>  	AXP209_ID,
> +	AXP221_ID,
>  	AXP288_ID,
>  	NR_AXP20X_VARIANTS,
>  };
> @@ -45,6 +46,28 @@ enum {
>  #define AXP20X_V_LTF_DISCHRG		0x3c
>  #define AXP20X_V_HTF_DISCHRG		0x3d
>  
> +#define AXP22X_PWR_OUT_CTRL1		0x10
> +#define AXP22X_PWR_OUT_CTRL2		0x12
> +#define AXP22X_PWR_OUT_CTRL3		0x13
> +#define AXP22X_DLDO1_V_OUT		0x15
> +#define AXP22X_DLDO2_V_OUT		0x16
> +#define AXP22X_DLDO3_V_OUT		0x17
> +#define AXP22X_DLDO4_V_OUT		0x18
> +#define AXP22X_ELDO1_V_OUT		0x19
> +#define AXP22X_ELDO2_V_OUT		0x1a
> +#define AXP22X_ELDO3_V_OUT		0x1b
> +#define AXP22X_DC5LDO_V_OUT		0x1c
> +#define AXP22X_DCDC1_V_OUT		0x21
> +#define AXP22X_DCDC2_V_OUT		0x22
> +#define AXP22X_DCDC3_V_OUT		0x23
> +#define AXP22X_DCDC4_V_OUT		0x24
> +#define AXP22X_DCDC5_V_OUT		0x25
> +#define AXP22X_DCDC23_V_RAMP_CTRL	0x27
> +#define AXP22X_ALDO1_V_OUT		0x28
> +#define AXP22X_ALDO2_V_OUT		0x29
> +#define AXP22X_ALDO3_V_OUT		0x2a
> +#define AXP22X_CHRG_CTRL3		0x35
> +
>  /* Interrupt */
>  #define AXP20X_IRQ1_EN			0x40
>  #define AXP20X_IRQ2_EN			0x41
> @@ -100,6 +123,9 @@ enum {
>  #define AXP20X_VBUS_MON			0x8b
>  #define AXP20X_OVER_TMP			0x8f
>  
> +#define AXP22X_PWREN_CTRL1		0x8c
> +#define AXP22X_PWREN_CTRL2		0x8d
> +
>  /* GPIO */
>  #define AXP20X_GPIO0_CTRL		0x90
>  #define AXP20X_LDO5_V_OUT		0x91
> @@ -108,6 +134,11 @@ enum {
>  #define AXP20X_GPIO20_SS		0x94
>  #define AXP20X_GPIO3_CTRL		0x95
>  
> +#define AXP22X_LDO_IO0_V_OUT		0x91
> +#define AXP22X_LDO_IO1_V_OUT		0x93
> +#define AXP22X_GPIO_STATE		0x94
> +#define AXP22X_GPIO_PULL_DOWN		0x95
> +
>  /* Battery */
>  #define AXP20X_CHRG_CC_31_24		0xb0
>  #define AXP20X_CHRG_CC_23_16		0xb1
> @@ -120,6 +151,9 @@ enum {
>  #define AXP20X_CC_CTRL			0xb8
>  #define AXP20X_FG_RES			0xb9
>  
> +/* AXP22X specific registers */
> +#define AXP22X_BATLOW_THRES1		0xe6
> +
>  /* AXP288 specific registers */
>  #define AXP288_PMIC_ADC_H               0x56
>  #define AXP288_PMIC_ADC_L               0x57
> @@ -158,6 +192,30 @@ enum {
>  	AXP20X_REG_ID_MAX,
>  };
>  
> +enum {
> +	AXP22X_DCDC1 = 0,
> +	AXP22X_DCDC2,
> +	AXP22X_DCDC3,
> +	AXP22X_DCDC4,
> +	AXP22X_DCDC5,
> +	AXP22X_DC1SW,
> +	AXP22X_DC5LDO,
> +	AXP22X_ALDO1,
> +	AXP22X_ALDO2,
> +	AXP22X_ALDO3,
> +	AXP22X_ELDO1,
> +	AXP22X_ELDO2,
> +	AXP22X_ELDO3,
> +	AXP22X_DLDO1,
> +	AXP22X_DLDO2,
> +	AXP22X_DLDO3,
> +	AXP22X_DLDO4,
> +	AXP22X_RTC_LDO,
> +	AXP22X_LDO_IO0,
> +	AXP22X_LDO_IO1,
> +	AXP22X_REG_ID_MAX,
> +};
> +
>  /* IRQs */
>  enum {
>  	AXP20X_IRQ_ACIN_OVER_V = 1,
> @@ -199,6 +257,34 @@ enum {
>  	AXP20X_IRQ_GPIO0_INPUT,
>  };
>  
> +enum axp22x_irqs {
> +	AXP22X_IRQ_ACIN_OVER_V = 1,
> +	AXP22X_IRQ_ACIN_PLUGIN,
> +	AXP22X_IRQ_ACIN_REMOVAL,
> +	AXP22X_IRQ_VBUS_OVER_V,
> +	AXP22X_IRQ_VBUS_PLUGIN,
> +	AXP22X_IRQ_VBUS_REMOVAL,
> +	AXP22X_IRQ_VBUS_V_LOW,
> +	AXP22X_IRQ_BATT_PLUGIN,
> +	AXP22X_IRQ_BATT_REMOVAL,
> +	AXP22X_IRQ_BATT_ENT_ACT_MODE,
> +	AXP22X_IRQ_BATT_EXIT_ACT_MODE,
> +	AXP22X_IRQ_CHARG,
> +	AXP22X_IRQ_CHARG_DONE,
> +	AXP22X_IRQ_BATT_TEMP_HIGH,
> +	AXP22X_IRQ_BATT_TEMP_LOW,
> +	AXP22X_IRQ_DIE_TEMP_HIGH,
> +	AXP22X_IRQ_PEK_SHORT,
> +	AXP22X_IRQ_PEK_LONG,
> +	AXP22X_IRQ_LOW_PWR_LVL1,
> +	AXP22X_IRQ_LOW_PWR_LVL2,
> +	AXP22X_IRQ_TIMER,
> +	AXP22X_IRQ_PEK_RIS_EDGE,
> +	AXP22X_IRQ_PEK_FAL_EDGE,
> +	AXP22X_IRQ_GPIO1_INPUT,
> +	AXP22X_IRQ_GPIO0_INPUT,
> +};
> +
>  enum axp288_irqs {
>  	AXP288_IRQ_VBUS_FALL     = 2,
>  	AXP288_IRQ_VBUS_RISE,

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH RESEND v6 4/6] regulator: axp20x: add support for AXP22X regulators
@ 2015-04-10 15:48     ` Mark Brown
  0 siblings, 0 replies; 54+ messages in thread
From: Mark Brown @ 2015-04-10 15:48 UTC (permalink / raw)
  To: Chen-Yu Tsai
  Cc: Lee Jones, Samuel Ortiz, Liam Girdwood, Rob Herring, Pawel Moll,
	Mark Rutland, Ian Campbell, Kumar Gala, Boris BREZILLON,
	Maxime Ripard, Carlo Caione, linux-arm-kernel, devicetree,
	linux-kernel, linux-sunxi

[-- Attachment #1: Type: text/plain, Size: 589 bytes --]

On Fri, Apr 10, 2015 at 12:09:04PM +0800, Chen-Yu Tsai wrote:

> This patch depends on the previous patch "regulator: axp20x: prepare
> support for multiple AXP chip families" and the mfd header from the
> first patch "mfd: axp20x: add AXP22x PMIC support".

> Could we merge both regulator patches through the mfd tree, with the
> other patches in the series? There are no other external dependencies.

Yes, of course we can - that's the whole point of me sending a
Reviewed-by!  Half of what I'm trying to do with that is to cut down on
the number of reposts of MFD series I get sent :(

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH RESEND v6 4/6] regulator: axp20x: add support for AXP22X regulators
@ 2015-04-10 15:48     ` Mark Brown
  0 siblings, 0 replies; 54+ messages in thread
From: Mark Brown @ 2015-04-10 15:48 UTC (permalink / raw)
  To: Chen-Yu Tsai
  Cc: Lee Jones, Samuel Ortiz, Liam Girdwood, Rob Herring, Pawel Moll,
	Mark Rutland, Ian Campbell, Kumar Gala, Boris BREZILLON,
	Maxime Ripard, Carlo Caione,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw

[-- Attachment #1: Type: text/plain, Size: 588 bytes --]

On Fri, Apr 10, 2015 at 12:09:04PM +0800, Chen-Yu Tsai wrote:

> This patch depends on the previous patch "regulator: axp20x: prepare
> support for multiple AXP chip families" and the mfd header from the
> first patch "mfd: axp20x: add AXP22x PMIC support".

> Could we merge both regulator patches through the mfd tree, with the
> other patches in the series? There are no other external dependencies.

Yes, of course we can - that's the whole point of me sending a
Reviewed-by!  Half of what I'm trying to do with that is to cut down on
the number of reposts of MFD series I get sent :(

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH RESEND v6 4/6] regulator: axp20x: add support for AXP22X regulators
@ 2015-04-10 15:48     ` Mark Brown
  0 siblings, 0 replies; 54+ messages in thread
From: Mark Brown @ 2015-04-10 15:48 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Apr 10, 2015 at 12:09:04PM +0800, Chen-Yu Tsai wrote:

> This patch depends on the previous patch "regulator: axp20x: prepare
> support for multiple AXP chip families" and the mfd header from the
> first patch "mfd: axp20x: add AXP22x PMIC support".

> Could we merge both regulator patches through the mfd tree, with the
> other patches in the series? There are no other external dependencies.

Yes, of course we can - that's the whole point of me sending a
Reviewed-by!  Half of what I'm trying to do with that is to cut down on
the number of reposts of MFD series I get sent :(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150410/87044ca6/attachment.sig>

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH RESEND v6 4/6] regulator: axp20x: add support for AXP22X regulators
@ 2015-04-14  6:45       ` Lee Jones
  0 siblings, 0 replies; 54+ messages in thread
From: Lee Jones @ 2015-04-14  6:45 UTC (permalink / raw)
  To: Mark Brown
  Cc: Chen-Yu Tsai, Samuel Ortiz, Liam Girdwood, Rob Herring,
	Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Boris BREZILLON, Maxime Ripard, Carlo Caione, linux-arm-kernel,
	devicetree, linux-kernel, linux-sunxi

On Fri, 10 Apr 2015, Mark Brown wrote:

> On Fri, Apr 10, 2015 at 12:09:04PM +0800, Chen-Yu Tsai wrote:
> 
> > This patch depends on the previous patch "regulator: axp20x: prepare
> > support for multiple AXP chip families" and the mfd header from the
> > first patch "mfd: axp20x: add AXP22x PMIC support".
> 
> > Could we merge both regulator patches through the mfd tree, with the
> > other patches in the series? There are no other external dependencies.
> 
> Yes, of course we can - that's the whole point of me sending a
> Reviewed-by!  Half of what I'm trying to do with that is to cut down on
> the number of reposts of MFD series I get sent :(

Welcome to my world!

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH RESEND v6 4/6] regulator: axp20x: add support for AXP22X regulators
@ 2015-04-14  6:45       ` Lee Jones
  0 siblings, 0 replies; 54+ messages in thread
From: Lee Jones @ 2015-04-14  6:45 UTC (permalink / raw)
  To: Mark Brown
  Cc: Chen-Yu Tsai, Samuel Ortiz, Liam Girdwood, Rob Herring,
	Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Boris BREZILLON, Maxime Ripard, Carlo Caione,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw

On Fri, 10 Apr 2015, Mark Brown wrote:

> On Fri, Apr 10, 2015 at 12:09:04PM +0800, Chen-Yu Tsai wrote:
> 
> > This patch depends on the previous patch "regulator: axp20x: prepare
> > support for multiple AXP chip families" and the mfd header from the
> > first patch "mfd: axp20x: add AXP22x PMIC support".
> 
> > Could we merge both regulator patches through the mfd tree, with the
> > other patches in the series? There are no other external dependencies.
> 
> Yes, of course we can - that's the whole point of me sending a
> Reviewed-by!  Half of what I'm trying to do with that is to cut down on
> the number of reposts of MFD series I get sent :(

Welcome to my world!

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

-- 
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/d/optout.

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH RESEND v6 4/6] regulator: axp20x: add support for AXP22X regulators
@ 2015-04-14  6:45       ` Lee Jones
  0 siblings, 0 replies; 54+ messages in thread
From: Lee Jones @ 2015-04-14  6:45 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, 10 Apr 2015, Mark Brown wrote:

> On Fri, Apr 10, 2015 at 12:09:04PM +0800, Chen-Yu Tsai wrote:
> 
> > This patch depends on the previous patch "regulator: axp20x: prepare
> > support for multiple AXP chip families" and the mfd header from the
> > first patch "mfd: axp20x: add AXP22x PMIC support".
> 
> > Could we merge both regulator patches through the mfd tree, with the
> > other patches in the series? There are no other external dependencies.
> 
> Yes, of course we can - that's the whole point of me sending a
> Reviewed-by!  Half of what I'm trying to do with that is to cut down on
> the number of reposts of MFD series I get sent :(

Welcome to my world!

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH RESEND v6 4/6] regulator: axp20x: add support for AXP22X regulators
@ 2015-04-29 12:36       ` Lee Jones
  0 siblings, 0 replies; 54+ messages in thread
From: Lee Jones @ 2015-04-29 12:36 UTC (permalink / raw)
  To: Mark Brown
  Cc: Chen-Yu Tsai, Samuel Ortiz, Liam Girdwood, Rob Herring,
	Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Boris BREZILLON, Maxime Ripard, Carlo Caione, linux-arm-kernel,
	devicetree, linux-kernel, linux-sunxi

On Fri, 10 Apr 2015, Mark Brown wrote:

> On Fri, Apr 10, 2015 at 12:09:04PM +0800, Chen-Yu Tsai wrote:
> 
> > This patch depends on the previous patch "regulator: axp20x: prepare
> > support for multiple AXP chip families" and the mfd header from the
> > first patch "mfd: axp20x: add AXP22x PMIC support".
> 
> > Could we merge both regulator patches through the mfd tree, with the
> > other patches in the series? There are no other external dependencies.
> 
> Yes, of course we can - that's the whole point of me sending a
> Reviewed-by!  Half of what I'm trying to do with that is to cut down on
> the number of reposts of MFD series I get sent :(

Okay, I'm ready to take this now.

Mark,

  Do you want a pull-request, or are you happy for me to just apply?

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH RESEND v6 4/6] regulator: axp20x: add support for AXP22X regulators
@ 2015-04-29 12:36       ` Lee Jones
  0 siblings, 0 replies; 54+ messages in thread
From: Lee Jones @ 2015-04-29 12:36 UTC (permalink / raw)
  To: Mark Brown
  Cc: Chen-Yu Tsai, Samuel Ortiz, Liam Girdwood, Rob Herring,
	Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Boris BREZILLON, Maxime Ripard, Carlo Caione,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw

On Fri, 10 Apr 2015, Mark Brown wrote:

> On Fri, Apr 10, 2015 at 12:09:04PM +0800, Chen-Yu Tsai wrote:
> 
> > This patch depends on the previous patch "regulator: axp20x: prepare
> > support for multiple AXP chip families" and the mfd header from the
> > first patch "mfd: axp20x: add AXP22x PMIC support".
> 
> > Could we merge both regulator patches through the mfd tree, with the
> > other patches in the series? There are no other external dependencies.
> 
> Yes, of course we can - that's the whole point of me sending a
> Reviewed-by!  Half of what I'm trying to do with that is to cut down on
> the number of reposts of MFD series I get sent :(

Okay, I'm ready to take this now.

Mark,

  Do you want a pull-request, or are you happy for me to just apply?

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

-- 
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/d/optout.

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH RESEND v6 4/6] regulator: axp20x: add support for AXP22X regulators
@ 2015-04-29 12:36       ` Lee Jones
  0 siblings, 0 replies; 54+ messages in thread
From: Lee Jones @ 2015-04-29 12:36 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, 10 Apr 2015, Mark Brown wrote:

> On Fri, Apr 10, 2015 at 12:09:04PM +0800, Chen-Yu Tsai wrote:
> 
> > This patch depends on the previous patch "regulator: axp20x: prepare
> > support for multiple AXP chip families" and the mfd header from the
> > first patch "mfd: axp20x: add AXP22x PMIC support".
> 
> > Could we merge both regulator patches through the mfd tree, with the
> > other patches in the series? There are no other external dependencies.
> 
> Yes, of course we can - that's the whole point of me sending a
> Reviewed-by!  Half of what I'm trying to do with that is to cut down on
> the number of reposts of MFD series I get sent :(

Okay, I'm ready to take this now.

Mark,

  Do you want a pull-request, or are you happy for me to just apply?

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH RESEND v6 1/6] mfd: axp20x: add AXP22x PMIC support
@ 2015-05-13 15:30     ` Lee Jones
  0 siblings, 0 replies; 54+ messages in thread
From: Lee Jones @ 2015-05-13 15:30 UTC (permalink / raw)
  To: Chen-Yu Tsai
  Cc: Samuel Ortiz, Mark Brown, Liam Girdwood, Rob Herring, Pawel Moll,
	Mark Rutland, Ian Campbell, Kumar Gala, Boris BREZILLON,
	Maxime Ripard, Carlo Caione, linux-arm-kernel, devicetree,
	linux-kernel, linux-sunxi

On Fri, 10 Apr 2015, Chen-Yu Tsai wrote:

> From: Boris BREZILLON <boris.brezillon@free-electrons.com>
> 
> Add support for the AXP22x PMIC devices to the existing AXP20x driver.
> This includes the AXP221 and AXP223, which are identical except for
> the external data bus. Only AXP221 is added for now. AXP223 will be
> added after it's Reduced Serial Bus (RSB) interface is supported.
> 
> AXP22x defines a new set of registers, power supplies and regulators,
> but most of the API is similar to the AXP20x ones.
> 
> A new irq chip definition is used, even though the available interrupts
> on AXP22x is a subset of those on AXP20x. This is done so the interrupt
> numbers match those on the datasheet.
> 
> This patch only enables the interrupts, system power-off function, and PEK
> sub-device. The regulator driver must first support different variants
> before we enable it from the mfd driver.
> 
> Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
> [wens@csie.org: fix interrupts and move regulators to separate patch]
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> Acked-by: Lee Jones <lee.jones@linaro.org>
> ---
> 
> Hi Lee,
> 
> I've asked Mark about merging the regulator patches through the mfd tree
> (in the 4th patch). If he agrees, could you take the whole series?
> 
> Thanks.
> 
> ChenYu
> 
> ---
>  drivers/mfd/axp20x.c       | 98 ++++++++++++++++++++++++++++++++++++++++++++++
>  include/linux/mfd/axp20x.h | 86 ++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 184 insertions(+)

Applied, thanks.

> diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
> index d18029be6a78..cfbb7d7aead6 100644
> --- a/drivers/mfd/axp20x.c
> +++ b/drivers/mfd/axp20x.c
> @@ -32,6 +32,7 @@
>  static const char * const axp20x_model_names[] = {
>  	"AXP202",
>  	"AXP209",
> +	"AXP221",
>  	"AXP288",
>  };
>  
> @@ -54,6 +55,25 @@ static const struct regmap_access_table axp20x_volatile_table = {
>  	.n_yes_ranges	= ARRAY_SIZE(axp20x_volatile_ranges),
>  };
>  
> +static const struct regmap_range axp22x_writeable_ranges[] = {
> +	regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_IRQ5_STATE),
> +	regmap_reg_range(AXP20X_DCDC_MODE, AXP22X_BATLOW_THRES1),
> +};
> +
> +static const struct regmap_range axp22x_volatile_ranges[] = {
> +	regmap_reg_range(AXP20X_IRQ1_EN, AXP20X_IRQ5_STATE),
> +};
> +
> +static const struct regmap_access_table axp22x_writeable_table = {
> +	.yes_ranges	= axp22x_writeable_ranges,
> +	.n_yes_ranges	= ARRAY_SIZE(axp22x_writeable_ranges),
> +};
> +
> +static const struct regmap_access_table axp22x_volatile_table = {
> +	.yes_ranges	= axp22x_volatile_ranges,
> +	.n_yes_ranges	= ARRAY_SIZE(axp22x_volatile_ranges),
> +};
> +
>  static const struct regmap_range axp288_writeable_ranges[] = {
>  	regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_IRQ6_STATE),
>  	regmap_reg_range(AXP20X_DCDC_MODE, AXP288_FG_TUNE5),
> @@ -87,6 +107,20 @@ static struct resource axp20x_pek_resources[] = {
>  	},
>  };
>  
> +static struct resource axp22x_pek_resources[] = {
> +	{
> +		.name   = "PEK_DBR",
> +		.start  = AXP22X_IRQ_PEK_RIS_EDGE,
> +		.end    = AXP22X_IRQ_PEK_RIS_EDGE,
> +		.flags  = IORESOURCE_IRQ,
> +	}, {
> +		.name   = "PEK_DBF",
> +		.start  = AXP22X_IRQ_PEK_FAL_EDGE,
> +		.end    = AXP22X_IRQ_PEK_FAL_EDGE,
> +		.flags  = IORESOURCE_IRQ,
> +	},
> +};
> +
>  static struct resource axp288_fuel_gauge_resources[] = {
>  	{
>  		.start = AXP288_IRQ_QWBTU,
> @@ -129,6 +163,15 @@ static const struct regmap_config axp20x_regmap_config = {
>  	.cache_type	= REGCACHE_RBTREE,
>  };
>  
> +static const struct regmap_config axp22x_regmap_config = {
> +	.reg_bits	= 8,
> +	.val_bits	= 8,
> +	.wr_table	= &axp22x_writeable_table,
> +	.volatile_table	= &axp22x_volatile_table,
> +	.max_register	= AXP22X_BATLOW_THRES1,
> +	.cache_type	= REGCACHE_RBTREE,
> +};
> +
>  static const struct regmap_config axp288_regmap_config = {
>  	.reg_bits	= 8,
>  	.val_bits	= 8,
> @@ -181,6 +224,34 @@ static const struct regmap_irq axp20x_regmap_irqs[] = {
>  	INIT_REGMAP_IRQ(AXP20X, GPIO0_INPUT,		4, 0),
>  };
>  
> +static const struct regmap_irq axp22x_regmap_irqs[] = {
> +	INIT_REGMAP_IRQ(AXP22X, ACIN_OVER_V,		0, 7),
> +	INIT_REGMAP_IRQ(AXP22X, ACIN_PLUGIN,		0, 6),
> +	INIT_REGMAP_IRQ(AXP22X, ACIN_REMOVAL,	        0, 5),
> +	INIT_REGMAP_IRQ(AXP22X, VBUS_OVER_V,		0, 4),
> +	INIT_REGMAP_IRQ(AXP22X, VBUS_PLUGIN,		0, 3),
> +	INIT_REGMAP_IRQ(AXP22X, VBUS_REMOVAL,	        0, 2),
> +	INIT_REGMAP_IRQ(AXP22X, VBUS_V_LOW,		0, 1),
> +	INIT_REGMAP_IRQ(AXP22X, BATT_PLUGIN,		1, 7),
> +	INIT_REGMAP_IRQ(AXP22X, BATT_REMOVAL,	        1, 6),
> +	INIT_REGMAP_IRQ(AXP22X, BATT_ENT_ACT_MODE,	1, 5),
> +	INIT_REGMAP_IRQ(AXP22X, BATT_EXIT_ACT_MODE,	1, 4),
> +	INIT_REGMAP_IRQ(AXP22X, CHARG,		        1, 3),
> +	INIT_REGMAP_IRQ(AXP22X, CHARG_DONE,		1, 2),
> +	INIT_REGMAP_IRQ(AXP22X, BATT_TEMP_HIGH,	        1, 1),
> +	INIT_REGMAP_IRQ(AXP22X, BATT_TEMP_LOW,	        1, 0),
> +	INIT_REGMAP_IRQ(AXP22X, DIE_TEMP_HIGH,	        2, 7),
> +	INIT_REGMAP_IRQ(AXP22X, PEK_SHORT,		2, 1),
> +	INIT_REGMAP_IRQ(AXP22X, PEK_LONG,		2, 0),
> +	INIT_REGMAP_IRQ(AXP22X, LOW_PWR_LVL1,	        3, 1),
> +	INIT_REGMAP_IRQ(AXP22X, LOW_PWR_LVL2,	        3, 0),
> +	INIT_REGMAP_IRQ(AXP22X, TIMER,		        4, 7),
> +	INIT_REGMAP_IRQ(AXP22X, PEK_RIS_EDGE,	        4, 6),
> +	INIT_REGMAP_IRQ(AXP22X, PEK_FAL_EDGE,	        4, 5),
> +	INIT_REGMAP_IRQ(AXP22X, GPIO1_INPUT,		4, 1),
> +	INIT_REGMAP_IRQ(AXP22X, GPIO0_INPUT,		4, 0),
> +};
> +
>  /* some IRQs are compatible with axp20x models */
>  static const struct regmap_irq axp288_regmap_irqs[] = {
>  	INIT_REGMAP_IRQ(AXP288, VBUS_FALL,              0, 2),
> @@ -224,6 +295,7 @@ static const struct regmap_irq axp288_regmap_irqs[] = {
>  static const struct of_device_id axp20x_of_match[] = {
>  	{ .compatible = "x-powers,axp202", .data = (void *) AXP202_ID },
>  	{ .compatible = "x-powers,axp209", .data = (void *) AXP209_ID },
> +	{ .compatible = "x-powers,axp221", .data = (void *) AXP221_ID },
>  	{ },
>  };
>  MODULE_DEVICE_TABLE(of, axp20x_of_match);
> @@ -258,6 +330,18 @@ static const struct regmap_irq_chip axp20x_regmap_irq_chip = {
>  
>  };
>  
> +static const struct regmap_irq_chip axp22x_regmap_irq_chip = {
> +	.name			= "axp22x_irq_chip",
> +	.status_base		= AXP20X_IRQ1_STATE,
> +	.ack_base		= AXP20X_IRQ1_STATE,
> +	.mask_base		= AXP20X_IRQ1_EN,
> +	.mask_invert		= true,
> +	.init_ack_masked	= true,
> +	.irqs			= axp22x_regmap_irqs,
> +	.num_irqs		= ARRAY_SIZE(axp22x_regmap_irqs),
> +	.num_regs		= 5,
> +};
> +
>  static const struct regmap_irq_chip axp288_regmap_irq_chip = {
>  	.name			= "axp288_irq_chip",
>  	.status_base		= AXP20X_IRQ1_STATE,
> @@ -281,6 +365,14 @@ static struct mfd_cell axp20x_cells[] = {
>  	},
>  };
>  
> +static struct mfd_cell axp22x_cells[] = {
> +	{
> +		.name			= "axp20x-pek",
> +		.num_resources		= ARRAY_SIZE(axp22x_pek_resources),
> +		.resources		= axp22x_pek_resources,
> +	},
> +};
> +
>  static struct resource axp288_adc_resources[] = {
>  	{
>  		.name  = "GPADC",
> @@ -426,6 +518,12 @@ static int axp20x_match_device(struct axp20x_dev *axp20x, struct device *dev)
>  		axp20x->regmap_cfg = &axp20x_regmap_config;
>  		axp20x->regmap_irq_chip = &axp20x_regmap_irq_chip;
>  		break;
> +	case AXP221_ID:
> +		axp20x->nr_cells = ARRAY_SIZE(axp22x_cells);
> +		axp20x->cells = axp22x_cells;
> +		axp20x->regmap_cfg = &axp22x_regmap_config;
> +		axp20x->regmap_irq_chip = &axp22x_regmap_irq_chip;
> +		break;
>  	case AXP288_ID:
>  		axp20x->cells = axp288_cells;
>  		axp20x->nr_cells = ARRAY_SIZE(axp288_cells);
> diff --git a/include/linux/mfd/axp20x.h b/include/linux/mfd/axp20x.h
> index dfabd6db7ddf..95568eb798c3 100644
> --- a/include/linux/mfd/axp20x.h
> +++ b/include/linux/mfd/axp20x.h
> @@ -14,6 +14,7 @@
>  enum {
>  	AXP202_ID = 0,
>  	AXP209_ID,
> +	AXP221_ID,
>  	AXP288_ID,
>  	NR_AXP20X_VARIANTS,
>  };
> @@ -45,6 +46,28 @@ enum {
>  #define AXP20X_V_LTF_DISCHRG		0x3c
>  #define AXP20X_V_HTF_DISCHRG		0x3d
>  
> +#define AXP22X_PWR_OUT_CTRL1		0x10
> +#define AXP22X_PWR_OUT_CTRL2		0x12
> +#define AXP22X_PWR_OUT_CTRL3		0x13
> +#define AXP22X_DLDO1_V_OUT		0x15
> +#define AXP22X_DLDO2_V_OUT		0x16
> +#define AXP22X_DLDO3_V_OUT		0x17
> +#define AXP22X_DLDO4_V_OUT		0x18
> +#define AXP22X_ELDO1_V_OUT		0x19
> +#define AXP22X_ELDO2_V_OUT		0x1a
> +#define AXP22X_ELDO3_V_OUT		0x1b
> +#define AXP22X_DC5LDO_V_OUT		0x1c
> +#define AXP22X_DCDC1_V_OUT		0x21
> +#define AXP22X_DCDC2_V_OUT		0x22
> +#define AXP22X_DCDC3_V_OUT		0x23
> +#define AXP22X_DCDC4_V_OUT		0x24
> +#define AXP22X_DCDC5_V_OUT		0x25
> +#define AXP22X_DCDC23_V_RAMP_CTRL	0x27
> +#define AXP22X_ALDO1_V_OUT		0x28
> +#define AXP22X_ALDO2_V_OUT		0x29
> +#define AXP22X_ALDO3_V_OUT		0x2a
> +#define AXP22X_CHRG_CTRL3		0x35
> +
>  /* Interrupt */
>  #define AXP20X_IRQ1_EN			0x40
>  #define AXP20X_IRQ2_EN			0x41
> @@ -100,6 +123,9 @@ enum {
>  #define AXP20X_VBUS_MON			0x8b
>  #define AXP20X_OVER_TMP			0x8f
>  
> +#define AXP22X_PWREN_CTRL1		0x8c
> +#define AXP22X_PWREN_CTRL2		0x8d
> +
>  /* GPIO */
>  #define AXP20X_GPIO0_CTRL		0x90
>  #define AXP20X_LDO5_V_OUT		0x91
> @@ -108,6 +134,11 @@ enum {
>  #define AXP20X_GPIO20_SS		0x94
>  #define AXP20X_GPIO3_CTRL		0x95
>  
> +#define AXP22X_LDO_IO0_V_OUT		0x91
> +#define AXP22X_LDO_IO1_V_OUT		0x93
> +#define AXP22X_GPIO_STATE		0x94
> +#define AXP22X_GPIO_PULL_DOWN		0x95
> +
>  /* Battery */
>  #define AXP20X_CHRG_CC_31_24		0xb0
>  #define AXP20X_CHRG_CC_23_16		0xb1
> @@ -120,6 +151,9 @@ enum {
>  #define AXP20X_CC_CTRL			0xb8
>  #define AXP20X_FG_RES			0xb9
>  
> +/* AXP22X specific registers */
> +#define AXP22X_BATLOW_THRES1		0xe6
> +
>  /* AXP288 specific registers */
>  #define AXP288_PMIC_ADC_H               0x56
>  #define AXP288_PMIC_ADC_L               0x57
> @@ -158,6 +192,30 @@ enum {
>  	AXP20X_REG_ID_MAX,
>  };
>  
> +enum {
> +	AXP22X_DCDC1 = 0,
> +	AXP22X_DCDC2,
> +	AXP22X_DCDC3,
> +	AXP22X_DCDC4,
> +	AXP22X_DCDC5,
> +	AXP22X_DC1SW,
> +	AXP22X_DC5LDO,
> +	AXP22X_ALDO1,
> +	AXP22X_ALDO2,
> +	AXP22X_ALDO3,
> +	AXP22X_ELDO1,
> +	AXP22X_ELDO2,
> +	AXP22X_ELDO3,
> +	AXP22X_DLDO1,
> +	AXP22X_DLDO2,
> +	AXP22X_DLDO3,
> +	AXP22X_DLDO4,
> +	AXP22X_RTC_LDO,
> +	AXP22X_LDO_IO0,
> +	AXP22X_LDO_IO1,
> +	AXP22X_REG_ID_MAX,
> +};
> +
>  /* IRQs */
>  enum {
>  	AXP20X_IRQ_ACIN_OVER_V = 1,
> @@ -199,6 +257,34 @@ enum {
>  	AXP20X_IRQ_GPIO0_INPUT,
>  };
>  
> +enum axp22x_irqs {
> +	AXP22X_IRQ_ACIN_OVER_V = 1,
> +	AXP22X_IRQ_ACIN_PLUGIN,
> +	AXP22X_IRQ_ACIN_REMOVAL,
> +	AXP22X_IRQ_VBUS_OVER_V,
> +	AXP22X_IRQ_VBUS_PLUGIN,
> +	AXP22X_IRQ_VBUS_REMOVAL,
> +	AXP22X_IRQ_VBUS_V_LOW,
> +	AXP22X_IRQ_BATT_PLUGIN,
> +	AXP22X_IRQ_BATT_REMOVAL,
> +	AXP22X_IRQ_BATT_ENT_ACT_MODE,
> +	AXP22X_IRQ_BATT_EXIT_ACT_MODE,
> +	AXP22X_IRQ_CHARG,
> +	AXP22X_IRQ_CHARG_DONE,
> +	AXP22X_IRQ_BATT_TEMP_HIGH,
> +	AXP22X_IRQ_BATT_TEMP_LOW,
> +	AXP22X_IRQ_DIE_TEMP_HIGH,
> +	AXP22X_IRQ_PEK_SHORT,
> +	AXP22X_IRQ_PEK_LONG,
> +	AXP22X_IRQ_LOW_PWR_LVL1,
> +	AXP22X_IRQ_LOW_PWR_LVL2,
> +	AXP22X_IRQ_TIMER,
> +	AXP22X_IRQ_PEK_RIS_EDGE,
> +	AXP22X_IRQ_PEK_FAL_EDGE,
> +	AXP22X_IRQ_GPIO1_INPUT,
> +	AXP22X_IRQ_GPIO0_INPUT,
> +};
> +
>  enum axp288_irqs {
>  	AXP288_IRQ_VBUS_FALL     = 2,
>  	AXP288_IRQ_VBUS_RISE,

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH RESEND v6 1/6] mfd: axp20x: add AXP22x PMIC support
@ 2015-05-13 15:30     ` Lee Jones
  0 siblings, 0 replies; 54+ messages in thread
From: Lee Jones @ 2015-05-13 15:30 UTC (permalink / raw)
  To: Chen-Yu Tsai
  Cc: Samuel Ortiz, Mark Brown, Liam Girdwood, Rob Herring, Pawel Moll,
	Mark Rutland, Ian Campbell, Kumar Gala, Boris BREZILLON,
	Maxime Ripard, Carlo Caione,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw

On Fri, 10 Apr 2015, Chen-Yu Tsai wrote:

> From: Boris BREZILLON <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> 
> Add support for the AXP22x PMIC devices to the existing AXP20x driver.
> This includes the AXP221 and AXP223, which are identical except for
> the external data bus. Only AXP221 is added for now. AXP223 will be
> added after it's Reduced Serial Bus (RSB) interface is supported.
> 
> AXP22x defines a new set of registers, power supplies and regulators,
> but most of the API is similar to the AXP20x ones.
> 
> A new irq chip definition is used, even though the available interrupts
> on AXP22x is a subset of those on AXP20x. This is done so the interrupt
> numbers match those on the datasheet.
> 
> This patch only enables the interrupts, system power-off function, and PEK
> sub-device. The regulator driver must first support different variants
> before we enable it from the mfd driver.
> 
> Signed-off-by: Boris BREZILLON <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> [wens-jdAy2FN1RRM@public.gmane.org: fix interrupts and move regulators to separate patch]
> Signed-off-by: Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>
> Acked-by: Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> ---
> 
> Hi Lee,
> 
> I've asked Mark about merging the regulator patches through the mfd tree
> (in the 4th patch). If he agrees, could you take the whole series?
> 
> Thanks.
> 
> ChenYu
> 
> ---
>  drivers/mfd/axp20x.c       | 98 ++++++++++++++++++++++++++++++++++++++++++++++
>  include/linux/mfd/axp20x.h | 86 ++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 184 insertions(+)

Applied, thanks.

> diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
> index d18029be6a78..cfbb7d7aead6 100644
> --- a/drivers/mfd/axp20x.c
> +++ b/drivers/mfd/axp20x.c
> @@ -32,6 +32,7 @@
>  static const char * const axp20x_model_names[] = {
>  	"AXP202",
>  	"AXP209",
> +	"AXP221",
>  	"AXP288",
>  };
>  
> @@ -54,6 +55,25 @@ static const struct regmap_access_table axp20x_volatile_table = {
>  	.n_yes_ranges	= ARRAY_SIZE(axp20x_volatile_ranges),
>  };
>  
> +static const struct regmap_range axp22x_writeable_ranges[] = {
> +	regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_IRQ5_STATE),
> +	regmap_reg_range(AXP20X_DCDC_MODE, AXP22X_BATLOW_THRES1),
> +};
> +
> +static const struct regmap_range axp22x_volatile_ranges[] = {
> +	regmap_reg_range(AXP20X_IRQ1_EN, AXP20X_IRQ5_STATE),
> +};
> +
> +static const struct regmap_access_table axp22x_writeable_table = {
> +	.yes_ranges	= axp22x_writeable_ranges,
> +	.n_yes_ranges	= ARRAY_SIZE(axp22x_writeable_ranges),
> +};
> +
> +static const struct regmap_access_table axp22x_volatile_table = {
> +	.yes_ranges	= axp22x_volatile_ranges,
> +	.n_yes_ranges	= ARRAY_SIZE(axp22x_volatile_ranges),
> +};
> +
>  static const struct regmap_range axp288_writeable_ranges[] = {
>  	regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_IRQ6_STATE),
>  	regmap_reg_range(AXP20X_DCDC_MODE, AXP288_FG_TUNE5),
> @@ -87,6 +107,20 @@ static struct resource axp20x_pek_resources[] = {
>  	},
>  };
>  
> +static struct resource axp22x_pek_resources[] = {
> +	{
> +		.name   = "PEK_DBR",
> +		.start  = AXP22X_IRQ_PEK_RIS_EDGE,
> +		.end    = AXP22X_IRQ_PEK_RIS_EDGE,
> +		.flags  = IORESOURCE_IRQ,
> +	}, {
> +		.name   = "PEK_DBF",
> +		.start  = AXP22X_IRQ_PEK_FAL_EDGE,
> +		.end    = AXP22X_IRQ_PEK_FAL_EDGE,
> +		.flags  = IORESOURCE_IRQ,
> +	},
> +};
> +
>  static struct resource axp288_fuel_gauge_resources[] = {
>  	{
>  		.start = AXP288_IRQ_QWBTU,
> @@ -129,6 +163,15 @@ static const struct regmap_config axp20x_regmap_config = {
>  	.cache_type	= REGCACHE_RBTREE,
>  };
>  
> +static const struct regmap_config axp22x_regmap_config = {
> +	.reg_bits	= 8,
> +	.val_bits	= 8,
> +	.wr_table	= &axp22x_writeable_table,
> +	.volatile_table	= &axp22x_volatile_table,
> +	.max_register	= AXP22X_BATLOW_THRES1,
> +	.cache_type	= REGCACHE_RBTREE,
> +};
> +
>  static const struct regmap_config axp288_regmap_config = {
>  	.reg_bits	= 8,
>  	.val_bits	= 8,
> @@ -181,6 +224,34 @@ static const struct regmap_irq axp20x_regmap_irqs[] = {
>  	INIT_REGMAP_IRQ(AXP20X, GPIO0_INPUT,		4, 0),
>  };
>  
> +static const struct regmap_irq axp22x_regmap_irqs[] = {
> +	INIT_REGMAP_IRQ(AXP22X, ACIN_OVER_V,		0, 7),
> +	INIT_REGMAP_IRQ(AXP22X, ACIN_PLUGIN,		0, 6),
> +	INIT_REGMAP_IRQ(AXP22X, ACIN_REMOVAL,	        0, 5),
> +	INIT_REGMAP_IRQ(AXP22X, VBUS_OVER_V,		0, 4),
> +	INIT_REGMAP_IRQ(AXP22X, VBUS_PLUGIN,		0, 3),
> +	INIT_REGMAP_IRQ(AXP22X, VBUS_REMOVAL,	        0, 2),
> +	INIT_REGMAP_IRQ(AXP22X, VBUS_V_LOW,		0, 1),
> +	INIT_REGMAP_IRQ(AXP22X, BATT_PLUGIN,		1, 7),
> +	INIT_REGMAP_IRQ(AXP22X, BATT_REMOVAL,	        1, 6),
> +	INIT_REGMAP_IRQ(AXP22X, BATT_ENT_ACT_MODE,	1, 5),
> +	INIT_REGMAP_IRQ(AXP22X, BATT_EXIT_ACT_MODE,	1, 4),
> +	INIT_REGMAP_IRQ(AXP22X, CHARG,		        1, 3),
> +	INIT_REGMAP_IRQ(AXP22X, CHARG_DONE,		1, 2),
> +	INIT_REGMAP_IRQ(AXP22X, BATT_TEMP_HIGH,	        1, 1),
> +	INIT_REGMAP_IRQ(AXP22X, BATT_TEMP_LOW,	        1, 0),
> +	INIT_REGMAP_IRQ(AXP22X, DIE_TEMP_HIGH,	        2, 7),
> +	INIT_REGMAP_IRQ(AXP22X, PEK_SHORT,		2, 1),
> +	INIT_REGMAP_IRQ(AXP22X, PEK_LONG,		2, 0),
> +	INIT_REGMAP_IRQ(AXP22X, LOW_PWR_LVL1,	        3, 1),
> +	INIT_REGMAP_IRQ(AXP22X, LOW_PWR_LVL2,	        3, 0),
> +	INIT_REGMAP_IRQ(AXP22X, TIMER,		        4, 7),
> +	INIT_REGMAP_IRQ(AXP22X, PEK_RIS_EDGE,	        4, 6),
> +	INIT_REGMAP_IRQ(AXP22X, PEK_FAL_EDGE,	        4, 5),
> +	INIT_REGMAP_IRQ(AXP22X, GPIO1_INPUT,		4, 1),
> +	INIT_REGMAP_IRQ(AXP22X, GPIO0_INPUT,		4, 0),
> +};
> +
>  /* some IRQs are compatible with axp20x models */
>  static const struct regmap_irq axp288_regmap_irqs[] = {
>  	INIT_REGMAP_IRQ(AXP288, VBUS_FALL,              0, 2),
> @@ -224,6 +295,7 @@ static const struct regmap_irq axp288_regmap_irqs[] = {
>  static const struct of_device_id axp20x_of_match[] = {
>  	{ .compatible = "x-powers,axp202", .data = (void *) AXP202_ID },
>  	{ .compatible = "x-powers,axp209", .data = (void *) AXP209_ID },
> +	{ .compatible = "x-powers,axp221", .data = (void *) AXP221_ID },
>  	{ },
>  };
>  MODULE_DEVICE_TABLE(of, axp20x_of_match);
> @@ -258,6 +330,18 @@ static const struct regmap_irq_chip axp20x_regmap_irq_chip = {
>  
>  };
>  
> +static const struct regmap_irq_chip axp22x_regmap_irq_chip = {
> +	.name			= "axp22x_irq_chip",
> +	.status_base		= AXP20X_IRQ1_STATE,
> +	.ack_base		= AXP20X_IRQ1_STATE,
> +	.mask_base		= AXP20X_IRQ1_EN,
> +	.mask_invert		= true,
> +	.init_ack_masked	= true,
> +	.irqs			= axp22x_regmap_irqs,
> +	.num_irqs		= ARRAY_SIZE(axp22x_regmap_irqs),
> +	.num_regs		= 5,
> +};
> +
>  static const struct regmap_irq_chip axp288_regmap_irq_chip = {
>  	.name			= "axp288_irq_chip",
>  	.status_base		= AXP20X_IRQ1_STATE,
> @@ -281,6 +365,14 @@ static struct mfd_cell axp20x_cells[] = {
>  	},
>  };
>  
> +static struct mfd_cell axp22x_cells[] = {
> +	{
> +		.name			= "axp20x-pek",
> +		.num_resources		= ARRAY_SIZE(axp22x_pek_resources),
> +		.resources		= axp22x_pek_resources,
> +	},
> +};
> +
>  static struct resource axp288_adc_resources[] = {
>  	{
>  		.name  = "GPADC",
> @@ -426,6 +518,12 @@ static int axp20x_match_device(struct axp20x_dev *axp20x, struct device *dev)
>  		axp20x->regmap_cfg = &axp20x_regmap_config;
>  		axp20x->regmap_irq_chip = &axp20x_regmap_irq_chip;
>  		break;
> +	case AXP221_ID:
> +		axp20x->nr_cells = ARRAY_SIZE(axp22x_cells);
> +		axp20x->cells = axp22x_cells;
> +		axp20x->regmap_cfg = &axp22x_regmap_config;
> +		axp20x->regmap_irq_chip = &axp22x_regmap_irq_chip;
> +		break;
>  	case AXP288_ID:
>  		axp20x->cells = axp288_cells;
>  		axp20x->nr_cells = ARRAY_SIZE(axp288_cells);
> diff --git a/include/linux/mfd/axp20x.h b/include/linux/mfd/axp20x.h
> index dfabd6db7ddf..95568eb798c3 100644
> --- a/include/linux/mfd/axp20x.h
> +++ b/include/linux/mfd/axp20x.h
> @@ -14,6 +14,7 @@
>  enum {
>  	AXP202_ID = 0,
>  	AXP209_ID,
> +	AXP221_ID,
>  	AXP288_ID,
>  	NR_AXP20X_VARIANTS,
>  };
> @@ -45,6 +46,28 @@ enum {
>  #define AXP20X_V_LTF_DISCHRG		0x3c
>  #define AXP20X_V_HTF_DISCHRG		0x3d
>  
> +#define AXP22X_PWR_OUT_CTRL1		0x10
> +#define AXP22X_PWR_OUT_CTRL2		0x12
> +#define AXP22X_PWR_OUT_CTRL3		0x13
> +#define AXP22X_DLDO1_V_OUT		0x15
> +#define AXP22X_DLDO2_V_OUT		0x16
> +#define AXP22X_DLDO3_V_OUT		0x17
> +#define AXP22X_DLDO4_V_OUT		0x18
> +#define AXP22X_ELDO1_V_OUT		0x19
> +#define AXP22X_ELDO2_V_OUT		0x1a
> +#define AXP22X_ELDO3_V_OUT		0x1b
> +#define AXP22X_DC5LDO_V_OUT		0x1c
> +#define AXP22X_DCDC1_V_OUT		0x21
> +#define AXP22X_DCDC2_V_OUT		0x22
> +#define AXP22X_DCDC3_V_OUT		0x23
> +#define AXP22X_DCDC4_V_OUT		0x24
> +#define AXP22X_DCDC5_V_OUT		0x25
> +#define AXP22X_DCDC23_V_RAMP_CTRL	0x27
> +#define AXP22X_ALDO1_V_OUT		0x28
> +#define AXP22X_ALDO2_V_OUT		0x29
> +#define AXP22X_ALDO3_V_OUT		0x2a
> +#define AXP22X_CHRG_CTRL3		0x35
> +
>  /* Interrupt */
>  #define AXP20X_IRQ1_EN			0x40
>  #define AXP20X_IRQ2_EN			0x41
> @@ -100,6 +123,9 @@ enum {
>  #define AXP20X_VBUS_MON			0x8b
>  #define AXP20X_OVER_TMP			0x8f
>  
> +#define AXP22X_PWREN_CTRL1		0x8c
> +#define AXP22X_PWREN_CTRL2		0x8d
> +
>  /* GPIO */
>  #define AXP20X_GPIO0_CTRL		0x90
>  #define AXP20X_LDO5_V_OUT		0x91
> @@ -108,6 +134,11 @@ enum {
>  #define AXP20X_GPIO20_SS		0x94
>  #define AXP20X_GPIO3_CTRL		0x95
>  
> +#define AXP22X_LDO_IO0_V_OUT		0x91
> +#define AXP22X_LDO_IO1_V_OUT		0x93
> +#define AXP22X_GPIO_STATE		0x94
> +#define AXP22X_GPIO_PULL_DOWN		0x95
> +
>  /* Battery */
>  #define AXP20X_CHRG_CC_31_24		0xb0
>  #define AXP20X_CHRG_CC_23_16		0xb1
> @@ -120,6 +151,9 @@ enum {
>  #define AXP20X_CC_CTRL			0xb8
>  #define AXP20X_FG_RES			0xb9
>  
> +/* AXP22X specific registers */
> +#define AXP22X_BATLOW_THRES1		0xe6
> +
>  /* AXP288 specific registers */
>  #define AXP288_PMIC_ADC_H               0x56
>  #define AXP288_PMIC_ADC_L               0x57
> @@ -158,6 +192,30 @@ enum {
>  	AXP20X_REG_ID_MAX,
>  };
>  
> +enum {
> +	AXP22X_DCDC1 = 0,
> +	AXP22X_DCDC2,
> +	AXP22X_DCDC3,
> +	AXP22X_DCDC4,
> +	AXP22X_DCDC5,
> +	AXP22X_DC1SW,
> +	AXP22X_DC5LDO,
> +	AXP22X_ALDO1,
> +	AXP22X_ALDO2,
> +	AXP22X_ALDO3,
> +	AXP22X_ELDO1,
> +	AXP22X_ELDO2,
> +	AXP22X_ELDO3,
> +	AXP22X_DLDO1,
> +	AXP22X_DLDO2,
> +	AXP22X_DLDO3,
> +	AXP22X_DLDO4,
> +	AXP22X_RTC_LDO,
> +	AXP22X_LDO_IO0,
> +	AXP22X_LDO_IO1,
> +	AXP22X_REG_ID_MAX,
> +};
> +
>  /* IRQs */
>  enum {
>  	AXP20X_IRQ_ACIN_OVER_V = 1,
> @@ -199,6 +257,34 @@ enum {
>  	AXP20X_IRQ_GPIO0_INPUT,
>  };
>  
> +enum axp22x_irqs {
> +	AXP22X_IRQ_ACIN_OVER_V = 1,
> +	AXP22X_IRQ_ACIN_PLUGIN,
> +	AXP22X_IRQ_ACIN_REMOVAL,
> +	AXP22X_IRQ_VBUS_OVER_V,
> +	AXP22X_IRQ_VBUS_PLUGIN,
> +	AXP22X_IRQ_VBUS_REMOVAL,
> +	AXP22X_IRQ_VBUS_V_LOW,
> +	AXP22X_IRQ_BATT_PLUGIN,
> +	AXP22X_IRQ_BATT_REMOVAL,
> +	AXP22X_IRQ_BATT_ENT_ACT_MODE,
> +	AXP22X_IRQ_BATT_EXIT_ACT_MODE,
> +	AXP22X_IRQ_CHARG,
> +	AXP22X_IRQ_CHARG_DONE,
> +	AXP22X_IRQ_BATT_TEMP_HIGH,
> +	AXP22X_IRQ_BATT_TEMP_LOW,
> +	AXP22X_IRQ_DIE_TEMP_HIGH,
> +	AXP22X_IRQ_PEK_SHORT,
> +	AXP22X_IRQ_PEK_LONG,
> +	AXP22X_IRQ_LOW_PWR_LVL1,
> +	AXP22X_IRQ_LOW_PWR_LVL2,
> +	AXP22X_IRQ_TIMER,
> +	AXP22X_IRQ_PEK_RIS_EDGE,
> +	AXP22X_IRQ_PEK_FAL_EDGE,
> +	AXP22X_IRQ_GPIO1_INPUT,
> +	AXP22X_IRQ_GPIO0_INPUT,
> +};
> +
>  enum axp288_irqs {
>  	AXP288_IRQ_VBUS_FALL     = 2,
>  	AXP288_IRQ_VBUS_RISE,

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

-- 
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/d/optout.

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH RESEND v6 1/6] mfd: axp20x: add AXP22x PMIC support
@ 2015-05-13 15:30     ` Lee Jones
  0 siblings, 0 replies; 54+ messages in thread
From: Lee Jones @ 2015-05-13 15:30 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, 10 Apr 2015, Chen-Yu Tsai wrote:

> From: Boris BREZILLON <boris.brezillon@free-electrons.com>
> 
> Add support for the AXP22x PMIC devices to the existing AXP20x driver.
> This includes the AXP221 and AXP223, which are identical except for
> the external data bus. Only AXP221 is added for now. AXP223 will be
> added after it's Reduced Serial Bus (RSB) interface is supported.
> 
> AXP22x defines a new set of registers, power supplies and regulators,
> but most of the API is similar to the AXP20x ones.
> 
> A new irq chip definition is used, even though the available interrupts
> on AXP22x is a subset of those on AXP20x. This is done so the interrupt
> numbers match those on the datasheet.
> 
> This patch only enables the interrupts, system power-off function, and PEK
> sub-device. The regulator driver must first support different variants
> before we enable it from the mfd driver.
> 
> Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
> [wens at csie.org: fix interrupts and move regulators to separate patch]
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> Acked-by: Lee Jones <lee.jones@linaro.org>
> ---
> 
> Hi Lee,
> 
> I've asked Mark about merging the regulator patches through the mfd tree
> (in the 4th patch). If he agrees, could you take the whole series?
> 
> Thanks.
> 
> ChenYu
> 
> ---
>  drivers/mfd/axp20x.c       | 98 ++++++++++++++++++++++++++++++++++++++++++++++
>  include/linux/mfd/axp20x.h | 86 ++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 184 insertions(+)

Applied, thanks.

> diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
> index d18029be6a78..cfbb7d7aead6 100644
> --- a/drivers/mfd/axp20x.c
> +++ b/drivers/mfd/axp20x.c
> @@ -32,6 +32,7 @@
>  static const char * const axp20x_model_names[] = {
>  	"AXP202",
>  	"AXP209",
> +	"AXP221",
>  	"AXP288",
>  };
>  
> @@ -54,6 +55,25 @@ static const struct regmap_access_table axp20x_volatile_table = {
>  	.n_yes_ranges	= ARRAY_SIZE(axp20x_volatile_ranges),
>  };
>  
> +static const struct regmap_range axp22x_writeable_ranges[] = {
> +	regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_IRQ5_STATE),
> +	regmap_reg_range(AXP20X_DCDC_MODE, AXP22X_BATLOW_THRES1),
> +};
> +
> +static const struct regmap_range axp22x_volatile_ranges[] = {
> +	regmap_reg_range(AXP20X_IRQ1_EN, AXP20X_IRQ5_STATE),
> +};
> +
> +static const struct regmap_access_table axp22x_writeable_table = {
> +	.yes_ranges	= axp22x_writeable_ranges,
> +	.n_yes_ranges	= ARRAY_SIZE(axp22x_writeable_ranges),
> +};
> +
> +static const struct regmap_access_table axp22x_volatile_table = {
> +	.yes_ranges	= axp22x_volatile_ranges,
> +	.n_yes_ranges	= ARRAY_SIZE(axp22x_volatile_ranges),
> +};
> +
>  static const struct regmap_range axp288_writeable_ranges[] = {
>  	regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_IRQ6_STATE),
>  	regmap_reg_range(AXP20X_DCDC_MODE, AXP288_FG_TUNE5),
> @@ -87,6 +107,20 @@ static struct resource axp20x_pek_resources[] = {
>  	},
>  };
>  
> +static struct resource axp22x_pek_resources[] = {
> +	{
> +		.name   = "PEK_DBR",
> +		.start  = AXP22X_IRQ_PEK_RIS_EDGE,
> +		.end    = AXP22X_IRQ_PEK_RIS_EDGE,
> +		.flags  = IORESOURCE_IRQ,
> +	}, {
> +		.name   = "PEK_DBF",
> +		.start  = AXP22X_IRQ_PEK_FAL_EDGE,
> +		.end    = AXP22X_IRQ_PEK_FAL_EDGE,
> +		.flags  = IORESOURCE_IRQ,
> +	},
> +};
> +
>  static struct resource axp288_fuel_gauge_resources[] = {
>  	{
>  		.start = AXP288_IRQ_QWBTU,
> @@ -129,6 +163,15 @@ static const struct regmap_config axp20x_regmap_config = {
>  	.cache_type	= REGCACHE_RBTREE,
>  };
>  
> +static const struct regmap_config axp22x_regmap_config = {
> +	.reg_bits	= 8,
> +	.val_bits	= 8,
> +	.wr_table	= &axp22x_writeable_table,
> +	.volatile_table	= &axp22x_volatile_table,
> +	.max_register	= AXP22X_BATLOW_THRES1,
> +	.cache_type	= REGCACHE_RBTREE,
> +};
> +
>  static const struct regmap_config axp288_regmap_config = {
>  	.reg_bits	= 8,
>  	.val_bits	= 8,
> @@ -181,6 +224,34 @@ static const struct regmap_irq axp20x_regmap_irqs[] = {
>  	INIT_REGMAP_IRQ(AXP20X, GPIO0_INPUT,		4, 0),
>  };
>  
> +static const struct regmap_irq axp22x_regmap_irqs[] = {
> +	INIT_REGMAP_IRQ(AXP22X, ACIN_OVER_V,		0, 7),
> +	INIT_REGMAP_IRQ(AXP22X, ACIN_PLUGIN,		0, 6),
> +	INIT_REGMAP_IRQ(AXP22X, ACIN_REMOVAL,	        0, 5),
> +	INIT_REGMAP_IRQ(AXP22X, VBUS_OVER_V,		0, 4),
> +	INIT_REGMAP_IRQ(AXP22X, VBUS_PLUGIN,		0, 3),
> +	INIT_REGMAP_IRQ(AXP22X, VBUS_REMOVAL,	        0, 2),
> +	INIT_REGMAP_IRQ(AXP22X, VBUS_V_LOW,		0, 1),
> +	INIT_REGMAP_IRQ(AXP22X, BATT_PLUGIN,		1, 7),
> +	INIT_REGMAP_IRQ(AXP22X, BATT_REMOVAL,	        1, 6),
> +	INIT_REGMAP_IRQ(AXP22X, BATT_ENT_ACT_MODE,	1, 5),
> +	INIT_REGMAP_IRQ(AXP22X, BATT_EXIT_ACT_MODE,	1, 4),
> +	INIT_REGMAP_IRQ(AXP22X, CHARG,		        1, 3),
> +	INIT_REGMAP_IRQ(AXP22X, CHARG_DONE,		1, 2),
> +	INIT_REGMAP_IRQ(AXP22X, BATT_TEMP_HIGH,	        1, 1),
> +	INIT_REGMAP_IRQ(AXP22X, BATT_TEMP_LOW,	        1, 0),
> +	INIT_REGMAP_IRQ(AXP22X, DIE_TEMP_HIGH,	        2, 7),
> +	INIT_REGMAP_IRQ(AXP22X, PEK_SHORT,		2, 1),
> +	INIT_REGMAP_IRQ(AXP22X, PEK_LONG,		2, 0),
> +	INIT_REGMAP_IRQ(AXP22X, LOW_PWR_LVL1,	        3, 1),
> +	INIT_REGMAP_IRQ(AXP22X, LOW_PWR_LVL2,	        3, 0),
> +	INIT_REGMAP_IRQ(AXP22X, TIMER,		        4, 7),
> +	INIT_REGMAP_IRQ(AXP22X, PEK_RIS_EDGE,	        4, 6),
> +	INIT_REGMAP_IRQ(AXP22X, PEK_FAL_EDGE,	        4, 5),
> +	INIT_REGMAP_IRQ(AXP22X, GPIO1_INPUT,		4, 1),
> +	INIT_REGMAP_IRQ(AXP22X, GPIO0_INPUT,		4, 0),
> +};
> +
>  /* some IRQs are compatible with axp20x models */
>  static const struct regmap_irq axp288_regmap_irqs[] = {
>  	INIT_REGMAP_IRQ(AXP288, VBUS_FALL,              0, 2),
> @@ -224,6 +295,7 @@ static const struct regmap_irq axp288_regmap_irqs[] = {
>  static const struct of_device_id axp20x_of_match[] = {
>  	{ .compatible = "x-powers,axp202", .data = (void *) AXP202_ID },
>  	{ .compatible = "x-powers,axp209", .data = (void *) AXP209_ID },
> +	{ .compatible = "x-powers,axp221", .data = (void *) AXP221_ID },
>  	{ },
>  };
>  MODULE_DEVICE_TABLE(of, axp20x_of_match);
> @@ -258,6 +330,18 @@ static const struct regmap_irq_chip axp20x_regmap_irq_chip = {
>  
>  };
>  
> +static const struct regmap_irq_chip axp22x_regmap_irq_chip = {
> +	.name			= "axp22x_irq_chip",
> +	.status_base		= AXP20X_IRQ1_STATE,
> +	.ack_base		= AXP20X_IRQ1_STATE,
> +	.mask_base		= AXP20X_IRQ1_EN,
> +	.mask_invert		= true,
> +	.init_ack_masked	= true,
> +	.irqs			= axp22x_regmap_irqs,
> +	.num_irqs		= ARRAY_SIZE(axp22x_regmap_irqs),
> +	.num_regs		= 5,
> +};
> +
>  static const struct regmap_irq_chip axp288_regmap_irq_chip = {
>  	.name			= "axp288_irq_chip",
>  	.status_base		= AXP20X_IRQ1_STATE,
> @@ -281,6 +365,14 @@ static struct mfd_cell axp20x_cells[] = {
>  	},
>  };
>  
> +static struct mfd_cell axp22x_cells[] = {
> +	{
> +		.name			= "axp20x-pek",
> +		.num_resources		= ARRAY_SIZE(axp22x_pek_resources),
> +		.resources		= axp22x_pek_resources,
> +	},
> +};
> +
>  static struct resource axp288_adc_resources[] = {
>  	{
>  		.name  = "GPADC",
> @@ -426,6 +518,12 @@ static int axp20x_match_device(struct axp20x_dev *axp20x, struct device *dev)
>  		axp20x->regmap_cfg = &axp20x_regmap_config;
>  		axp20x->regmap_irq_chip = &axp20x_regmap_irq_chip;
>  		break;
> +	case AXP221_ID:
> +		axp20x->nr_cells = ARRAY_SIZE(axp22x_cells);
> +		axp20x->cells = axp22x_cells;
> +		axp20x->regmap_cfg = &axp22x_regmap_config;
> +		axp20x->regmap_irq_chip = &axp22x_regmap_irq_chip;
> +		break;
>  	case AXP288_ID:
>  		axp20x->cells = axp288_cells;
>  		axp20x->nr_cells = ARRAY_SIZE(axp288_cells);
> diff --git a/include/linux/mfd/axp20x.h b/include/linux/mfd/axp20x.h
> index dfabd6db7ddf..95568eb798c3 100644
> --- a/include/linux/mfd/axp20x.h
> +++ b/include/linux/mfd/axp20x.h
> @@ -14,6 +14,7 @@
>  enum {
>  	AXP202_ID = 0,
>  	AXP209_ID,
> +	AXP221_ID,
>  	AXP288_ID,
>  	NR_AXP20X_VARIANTS,
>  };
> @@ -45,6 +46,28 @@ enum {
>  #define AXP20X_V_LTF_DISCHRG		0x3c
>  #define AXP20X_V_HTF_DISCHRG		0x3d
>  
> +#define AXP22X_PWR_OUT_CTRL1		0x10
> +#define AXP22X_PWR_OUT_CTRL2		0x12
> +#define AXP22X_PWR_OUT_CTRL3		0x13
> +#define AXP22X_DLDO1_V_OUT		0x15
> +#define AXP22X_DLDO2_V_OUT		0x16
> +#define AXP22X_DLDO3_V_OUT		0x17
> +#define AXP22X_DLDO4_V_OUT		0x18
> +#define AXP22X_ELDO1_V_OUT		0x19
> +#define AXP22X_ELDO2_V_OUT		0x1a
> +#define AXP22X_ELDO3_V_OUT		0x1b
> +#define AXP22X_DC5LDO_V_OUT		0x1c
> +#define AXP22X_DCDC1_V_OUT		0x21
> +#define AXP22X_DCDC2_V_OUT		0x22
> +#define AXP22X_DCDC3_V_OUT		0x23
> +#define AXP22X_DCDC4_V_OUT		0x24
> +#define AXP22X_DCDC5_V_OUT		0x25
> +#define AXP22X_DCDC23_V_RAMP_CTRL	0x27
> +#define AXP22X_ALDO1_V_OUT		0x28
> +#define AXP22X_ALDO2_V_OUT		0x29
> +#define AXP22X_ALDO3_V_OUT		0x2a
> +#define AXP22X_CHRG_CTRL3		0x35
> +
>  /* Interrupt */
>  #define AXP20X_IRQ1_EN			0x40
>  #define AXP20X_IRQ2_EN			0x41
> @@ -100,6 +123,9 @@ enum {
>  #define AXP20X_VBUS_MON			0x8b
>  #define AXP20X_OVER_TMP			0x8f
>  
> +#define AXP22X_PWREN_CTRL1		0x8c
> +#define AXP22X_PWREN_CTRL2		0x8d
> +
>  /* GPIO */
>  #define AXP20X_GPIO0_CTRL		0x90
>  #define AXP20X_LDO5_V_OUT		0x91
> @@ -108,6 +134,11 @@ enum {
>  #define AXP20X_GPIO20_SS		0x94
>  #define AXP20X_GPIO3_CTRL		0x95
>  
> +#define AXP22X_LDO_IO0_V_OUT		0x91
> +#define AXP22X_LDO_IO1_V_OUT		0x93
> +#define AXP22X_GPIO_STATE		0x94
> +#define AXP22X_GPIO_PULL_DOWN		0x95
> +
>  /* Battery */
>  #define AXP20X_CHRG_CC_31_24		0xb0
>  #define AXP20X_CHRG_CC_23_16		0xb1
> @@ -120,6 +151,9 @@ enum {
>  #define AXP20X_CC_CTRL			0xb8
>  #define AXP20X_FG_RES			0xb9
>  
> +/* AXP22X specific registers */
> +#define AXP22X_BATLOW_THRES1		0xe6
> +
>  /* AXP288 specific registers */
>  #define AXP288_PMIC_ADC_H               0x56
>  #define AXP288_PMIC_ADC_L               0x57
> @@ -158,6 +192,30 @@ enum {
>  	AXP20X_REG_ID_MAX,
>  };
>  
> +enum {
> +	AXP22X_DCDC1 = 0,
> +	AXP22X_DCDC2,
> +	AXP22X_DCDC3,
> +	AXP22X_DCDC4,
> +	AXP22X_DCDC5,
> +	AXP22X_DC1SW,
> +	AXP22X_DC5LDO,
> +	AXP22X_ALDO1,
> +	AXP22X_ALDO2,
> +	AXP22X_ALDO3,
> +	AXP22X_ELDO1,
> +	AXP22X_ELDO2,
> +	AXP22X_ELDO3,
> +	AXP22X_DLDO1,
> +	AXP22X_DLDO2,
> +	AXP22X_DLDO3,
> +	AXP22X_DLDO4,
> +	AXP22X_RTC_LDO,
> +	AXP22X_LDO_IO0,
> +	AXP22X_LDO_IO1,
> +	AXP22X_REG_ID_MAX,
> +};
> +
>  /* IRQs */
>  enum {
>  	AXP20X_IRQ_ACIN_OVER_V = 1,
> @@ -199,6 +257,34 @@ enum {
>  	AXP20X_IRQ_GPIO0_INPUT,
>  };
>  
> +enum axp22x_irqs {
> +	AXP22X_IRQ_ACIN_OVER_V = 1,
> +	AXP22X_IRQ_ACIN_PLUGIN,
> +	AXP22X_IRQ_ACIN_REMOVAL,
> +	AXP22X_IRQ_VBUS_OVER_V,
> +	AXP22X_IRQ_VBUS_PLUGIN,
> +	AXP22X_IRQ_VBUS_REMOVAL,
> +	AXP22X_IRQ_VBUS_V_LOW,
> +	AXP22X_IRQ_BATT_PLUGIN,
> +	AXP22X_IRQ_BATT_REMOVAL,
> +	AXP22X_IRQ_BATT_ENT_ACT_MODE,
> +	AXP22X_IRQ_BATT_EXIT_ACT_MODE,
> +	AXP22X_IRQ_CHARG,
> +	AXP22X_IRQ_CHARG_DONE,
> +	AXP22X_IRQ_BATT_TEMP_HIGH,
> +	AXP22X_IRQ_BATT_TEMP_LOW,
> +	AXP22X_IRQ_DIE_TEMP_HIGH,
> +	AXP22X_IRQ_PEK_SHORT,
> +	AXP22X_IRQ_PEK_LONG,
> +	AXP22X_IRQ_LOW_PWR_LVL1,
> +	AXP22X_IRQ_LOW_PWR_LVL2,
> +	AXP22X_IRQ_TIMER,
> +	AXP22X_IRQ_PEK_RIS_EDGE,
> +	AXP22X_IRQ_PEK_FAL_EDGE,
> +	AXP22X_IRQ_GPIO1_INPUT,
> +	AXP22X_IRQ_GPIO0_INPUT,
> +};
> +
>  enum axp288_irqs {
>  	AXP288_IRQ_VBUS_FALL     = 2,
>  	AXP288_IRQ_VBUS_RISE,

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH RESEND v6 2/6] mfd: axp20x: update DT bindings with AXP22x compatibles
@ 2015-05-13 15:30     ` Lee Jones
  0 siblings, 0 replies; 54+ messages in thread
From: Lee Jones @ 2015-05-13 15:30 UTC (permalink / raw)
  To: Chen-Yu Tsai
  Cc: Samuel Ortiz, Mark Brown, Liam Girdwood, Rob Herring, Pawel Moll,
	Mark Rutland, Ian Campbell, Kumar Gala, Maxime Ripard,
	Carlo Caione, linux-arm-kernel, devicetree, linux-kernel,
	linux-sunxi

On Fri, 10 Apr 2015, Chen-Yu Tsai wrote:

> Add AXP221 to the list of supported devices.
> 
> Also replace any mention of AXP20x in the document with a
> generic "PMIC".
> 
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> Acked-by: Lee Jones <lee.jones@linaro.org>
> ---
>  Documentation/devicetree/bindings/mfd/axp20x.txt | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)

Applied, thanks.

> diff --git a/Documentation/devicetree/bindings/mfd/axp20x.txt b/Documentation/devicetree/bindings/mfd/axp20x.txt
> index 98685f291a72..3914a3f91ff6 100644
> --- a/Documentation/devicetree/bindings/mfd/axp20x.txt
> +++ b/Documentation/devicetree/bindings/mfd/axp20x.txt
> @@ -1,15 +1,16 @@
> -AXP202/AXP209 device tree bindings
> +AXP family PMIC device tree bindings
>  
>  The axp20x family current members :
>  axp202 (X-Powers)
>  axp209 (X-Powers)
> +axp221 (X-Powers)
>  
>  Required properties:
> -- compatible: "x-powers,axp202" or "x-powers,axp209"
> +- compatible: "x-powers,axp202", "x-powers,axp209", "x-powers,axp221"
>  - reg: The I2C slave address for the AXP chip
>  - interrupt-parent: The parent interrupt controller
>  - interrupts: SoC NMI / GPIO interrupt connected to the PMIC's IRQ pin
> -- interrupt-controller: axp20x has its own internal IRQs
> +- interrupt-controller: The PMIC has its own internal IRQs
>  - #interrupt-cells: Should be set to 1
>  
>  Optional properties:

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH RESEND v6 2/6] mfd: axp20x: update DT bindings with AXP22x compatibles
@ 2015-05-13 15:30     ` Lee Jones
  0 siblings, 0 replies; 54+ messages in thread
From: Lee Jones @ 2015-05-13 15:30 UTC (permalink / raw)
  To: Chen-Yu Tsai
  Cc: Samuel Ortiz, Mark Brown, Liam Girdwood, Rob Herring, Pawel Moll,
	Mark Rutland, Ian Campbell, Kumar Gala, Maxime Ripard,
	Carlo Caione, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw

On Fri, 10 Apr 2015, Chen-Yu Tsai wrote:

> Add AXP221 to the list of supported devices.
> 
> Also replace any mention of AXP20x in the document with a
> generic "PMIC".
> 
> Signed-off-by: Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>
> Acked-by: Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> ---
>  Documentation/devicetree/bindings/mfd/axp20x.txt | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)

Applied, thanks.

> diff --git a/Documentation/devicetree/bindings/mfd/axp20x.txt b/Documentation/devicetree/bindings/mfd/axp20x.txt
> index 98685f291a72..3914a3f91ff6 100644
> --- a/Documentation/devicetree/bindings/mfd/axp20x.txt
> +++ b/Documentation/devicetree/bindings/mfd/axp20x.txt
> @@ -1,15 +1,16 @@
> -AXP202/AXP209 device tree bindings
> +AXP family PMIC device tree bindings
>  
>  The axp20x family current members :
>  axp202 (X-Powers)
>  axp209 (X-Powers)
> +axp221 (X-Powers)
>  
>  Required properties:
> -- compatible: "x-powers,axp202" or "x-powers,axp209"
> +- compatible: "x-powers,axp202", "x-powers,axp209", "x-powers,axp221"
>  - reg: The I2C slave address for the AXP chip
>  - interrupt-parent: The parent interrupt controller
>  - interrupts: SoC NMI / GPIO interrupt connected to the PMIC's IRQ pin
> -- interrupt-controller: axp20x has its own internal IRQs
> +- interrupt-controller: The PMIC has its own internal IRQs
>  - #interrupt-cells: Should be set to 1
>  
>  Optional properties:

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

-- 
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/d/optout.

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH RESEND v6 2/6] mfd: axp20x: update DT bindings with AXP22x compatibles
@ 2015-05-13 15:30     ` Lee Jones
  0 siblings, 0 replies; 54+ messages in thread
From: Lee Jones @ 2015-05-13 15:30 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, 10 Apr 2015, Chen-Yu Tsai wrote:

> Add AXP221 to the list of supported devices.
> 
> Also replace any mention of AXP20x in the document with a
> generic "PMIC".
> 
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> Acked-by: Lee Jones <lee.jones@linaro.org>
> ---
>  Documentation/devicetree/bindings/mfd/axp20x.txt | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)

Applied, thanks.

> diff --git a/Documentation/devicetree/bindings/mfd/axp20x.txt b/Documentation/devicetree/bindings/mfd/axp20x.txt
> index 98685f291a72..3914a3f91ff6 100644
> --- a/Documentation/devicetree/bindings/mfd/axp20x.txt
> +++ b/Documentation/devicetree/bindings/mfd/axp20x.txt
> @@ -1,15 +1,16 @@
> -AXP202/AXP209 device tree bindings
> +AXP family PMIC device tree bindings
>  
>  The axp20x family current members :
>  axp202 (X-Powers)
>  axp209 (X-Powers)
> +axp221 (X-Powers)
>  
>  Required properties:
> -- compatible: "x-powers,axp202" or "x-powers,axp209"
> +- compatible: "x-powers,axp202", "x-powers,axp209", "x-powers,axp221"
>  - reg: The I2C slave address for the AXP chip
>  - interrupt-parent: The parent interrupt controller
>  - interrupts: SoC NMI / GPIO interrupt connected to the PMIC's IRQ pin
> -- interrupt-controller: axp20x has its own internal IRQs
> +- interrupt-controller: The PMIC has its own internal IRQs
>  - #interrupt-cells: Should be set to 1
>  
>  Optional properties:

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH RESEND v6 3/6] regulator: axp20x: prepare support for multiple AXP chip families
@ 2015-05-13 15:30     ` Lee Jones
  0 siblings, 0 replies; 54+ messages in thread
From: Lee Jones @ 2015-05-13 15:30 UTC (permalink / raw)
  To: Chen-Yu Tsai
  Cc: Samuel Ortiz, Mark Brown, Liam Girdwood, Rob Herring, Pawel Moll,
	Mark Rutland, Ian Campbell, Kumar Gala, Boris BREZILLON,
	Maxime Ripard, Carlo Caione, linux-arm-kernel, devicetree,
	linux-kernel, linux-sunxi

On Fri, 10 Apr 2015, Chen-Yu Tsai wrote:

> From: Boris BREZILLON <boris.brezillon@free-electrons.com>
> 
> Rework the AXP20X_ macros and probe function to support the several chip
> families, so that each family can define it's own set of regulators.
> 
> Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
> [wens@csie.org: Support different DC-DC work frequency ranges]
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> Reviewed-by: Mark Brown <broonie@kernel.org>
> ---
>  drivers/regulator/axp20x-regulator.c | 143 +++++++++++++++++++++++------------
>  1 file changed, 94 insertions(+), 49 deletions(-)

Applied, thanks.

> diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c
> index e4331f5e5d7d..50ae0b5f2c0c 100644
> --- a/drivers/regulator/axp20x-regulator.c
> +++ b/drivers/regulator/axp20x-regulator.c
> @@ -32,15 +32,15 @@
>  
>  #define AXP20X_FREQ_DCDC_MASK		0x0f
>  
> -#define AXP20X_DESC_IO(_id, _match, _supply, _min, _max, _step, _vreg, _vmask,	\
> -		       _ereg, _emask, _enable_val, _disable_val)		\
> -	[AXP20X_##_id] = {							\
> +#define AXP_DESC_IO(_family, _id, _match, _supply, _min, _max, _step, _vreg,	\
> +		    _vmask, _ereg, _emask, _enable_val, _disable_val)		\
> +	[_family##_##_id] = {							\
>  		.name		= #_id,						\
>  		.supply_name	= (_supply),					\
>  		.of_match	= of_match_ptr(_match),				\
>  		.regulators_node = of_match_ptr("regulators"),			\
>  		.type		= REGULATOR_VOLTAGE,				\
> -		.id		= AXP20X_##_id,					\
> +		.id		= _family##_##_id,				\
>  		.n_voltages	= (((_max) - (_min)) / (_step) + 1),		\
>  		.owner		= THIS_MODULE,					\
>  		.min_uV		= (_min) * 1000,				\
> @@ -54,15 +54,15 @@
>  		.ops		= &axp20x_ops,					\
>  	}
>  
> -#define AXP20X_DESC(_id, _match, _supply, _min, _max, _step, _vreg, _vmask,	\
> -		    _ereg, _emask)						\
> -	[AXP20X_##_id] = {							\
> +#define AXP_DESC(_family, _id, _match, _supply, _min, _max, _step, _vreg,	\
> +		 _vmask, _ereg, _emask) 					\
> +	[_family##_##_id] = {							\
>  		.name		= #_id,						\
>  		.supply_name	= (_supply),					\
>  		.of_match	= of_match_ptr(_match),				\
>  		.regulators_node = of_match_ptr("regulators"),			\
>  		.type		= REGULATOR_VOLTAGE,				\
> -		.id		= AXP20X_##_id,					\
> +		.id		= _family##_##_id,				\
>  		.n_voltages	= (((_max) - (_min)) / (_step) + 1),		\
>  		.owner		= THIS_MODULE,					\
>  		.min_uV		= (_min) * 1000,				\
> @@ -74,29 +74,29 @@
>  		.ops		= &axp20x_ops,					\
>  	}
>  
> -#define AXP20X_DESC_FIXED(_id, _match, _supply, _volt)				\
> -	[AXP20X_##_id] = {							\
> +#define AXP_DESC_FIXED(_family, _id, _match, _supply, _volt)			\
> +	[_family##_##_id] = {							\
>  		.name		= #_id,						\
>  		.supply_name	= (_supply),					\
>  		.of_match	= of_match_ptr(_match),				\
>  		.regulators_node = of_match_ptr("regulators"),			\
>  		.type		= REGULATOR_VOLTAGE,				\
> -		.id		= AXP20X_##_id,					\
> +		.id		= _family##_##_id,				\
>  		.n_voltages	= 1,						\
>  		.owner		= THIS_MODULE,					\
>  		.min_uV		= (_volt) * 1000,				\
>  		.ops		= &axp20x_ops_fixed				\
>  	}
>  
> -#define AXP20X_DESC_TABLE(_id, _match, _supply, _table, _vreg, _vmask, _ereg,	\
> -			  _emask)						\
> -	[AXP20X_##_id] = {							\
> +#define AXP_DESC_TABLE(_family, _id, _match, _supply, _table, _vreg, _vmask,	\
> +		       _ereg, _emask)						\
> +	[_family##_##_id] = {							\
>  		.name		= #_id,						\
>  		.supply_name	= (_supply),					\
>  		.of_match	= of_match_ptr(_match),				\
>  		.regulators_node = of_match_ptr("regulators"),			\
>  		.type		= REGULATOR_VOLTAGE,				\
> -		.id		= AXP20X_##_id,					\
> +		.id		= _family##_##_id,				\
>  		.n_voltages	= ARRAY_SIZE(_table),				\
>  		.owner		= THIS_MODULE,					\
>  		.vsel_reg	= (_vreg),					\
> @@ -136,37 +136,57 @@ static struct regulator_ops axp20x_ops = {
>  };
>  
>  static const struct regulator_desc axp20x_regulators[] = {
> -	AXP20X_DESC(DCDC2, "dcdc2", "vin2", 700, 2275, 25, AXP20X_DCDC2_V_OUT,
> -		    0x3f, AXP20X_PWR_OUT_CTRL, 0x10),
> -	AXP20X_DESC(DCDC3, "dcdc3", "vin3", 700, 3500, 25, AXP20X_DCDC3_V_OUT,
> -		    0x7f, AXP20X_PWR_OUT_CTRL, 0x02),
> -	AXP20X_DESC_FIXED(LDO1, "ldo1", "acin", 1300),
> -	AXP20X_DESC(LDO2, "ldo2", "ldo24in", 1800, 3300, 100,
> -		    AXP20X_LDO24_V_OUT, 0xf0, AXP20X_PWR_OUT_CTRL, 0x04),
> -	AXP20X_DESC(LDO3, "ldo3", "ldo3in", 700, 3500, 25, AXP20X_LDO3_V_OUT,
> -		    0x7f, AXP20X_PWR_OUT_CTRL, 0x40),
> -	AXP20X_DESC_TABLE(LDO4, "ldo4", "ldo24in", axp20x_ldo4_data,
> -			  AXP20X_LDO24_V_OUT, 0x0f, AXP20X_PWR_OUT_CTRL, 0x08),
> -	AXP20X_DESC_IO(LDO5, "ldo5", "ldo5in", 1800, 3300, 100,
> -		       AXP20X_LDO5_V_OUT, 0xf0, AXP20X_GPIO0_CTRL, 0x07,
> -		       AXP20X_IO_ENABLED, AXP20X_IO_DISABLED),
> +	AXP_DESC(AXP20X, DCDC2, "dcdc2", "vin2", 700, 2275, 25,
> +		 AXP20X_DCDC2_V_OUT, 0x3f, AXP20X_PWR_OUT_CTRL, 0x10),
> +	AXP_DESC(AXP20X, DCDC3, "dcdc3", "vin3", 700, 3500, 25,
> +		 AXP20X_DCDC3_V_OUT, 0x7f, AXP20X_PWR_OUT_CTRL, 0x02),
> +	AXP_DESC_FIXED(AXP20X, LDO1, "ldo1", "acin", 1300),
> +	AXP_DESC(AXP20X, LDO2, "ldo2", "ldo24in", 1800, 3300, 100,
> +		 AXP20X_LDO24_V_OUT, 0xf0, AXP20X_PWR_OUT_CTRL, 0x04),
> +	AXP_DESC(AXP20X, LDO3, "ldo3", "ldo3in", 700, 3500, 25,
> +		 AXP20X_LDO3_V_OUT, 0x7f, AXP20X_PWR_OUT_CTRL, 0x40),
> +	AXP_DESC_TABLE(AXP20X, LDO4, "ldo4", "ldo24in", axp20x_ldo4_data,
> +		       AXP20X_LDO24_V_OUT, 0x0f, AXP20X_PWR_OUT_CTRL, 0x08),
> +	AXP_DESC_IO(AXP20X, LDO5, "ldo5", "ldo5in", 1800, 3300, 100,
> +		    AXP20X_LDO5_V_OUT, 0xf0, AXP20X_GPIO0_CTRL, 0x07,
> +		    AXP20X_IO_ENABLED, AXP20X_IO_DISABLED),
>  };
>  
>  static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq)
>  {
>  	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
> +	u32 min, max, def, step;
> +
> +	switch (axp20x->variant) {
> +	case AXP202_ID:
> +	case AXP209_ID:
> +		min = 750;
> +		max = 1875;
> +		def = 1500;
> +		step = 75;
> +		break;
> +	default:
> +		dev_err(&pdev->dev,
> +			"Setting DCDC frequency for unsupported AXP variant\n");
> +		return -EINVAL;
> +	}
> +
> +	if (dcdcfreq == 0)
> +		dcdcfreq = def;
>  
> -	if (dcdcfreq < 750) {
> -		dcdcfreq = 750;
> -		dev_warn(&pdev->dev, "DCDC frequency too low. Set to 750kHz\n");
> +	if (dcdcfreq < min) {
> +		dcdcfreq = min;
> +		dev_warn(&pdev->dev, "DCDC frequency too low. Set to %ukHz\n",
> +			 min);
>  	}
>  
> -	if (dcdcfreq > 1875) {
> -		dcdcfreq = 1875;
> -		dev_warn(&pdev->dev, "DCDC frequency too high. Set to 1875kHz\n");
> +	if (dcdcfreq > max) {
> +		dcdcfreq = max;
> +		dev_warn(&pdev->dev, "DCDC frequency too high. Set to %ukHz\n",
> +			 max);
>  	}
>  
> -	dcdcfreq = (dcdcfreq - 750) / 75;
> +	dcdcfreq = (dcdcfreq - min) / step;
>  
>  	return regmap_update_bits(axp20x->regmap, AXP20X_DCDC_FREQ,
>  				  AXP20X_FREQ_DCDC_MASK, dcdcfreq);
> @@ -176,7 +196,7 @@ static int axp20x_regulator_parse_dt(struct platform_device *pdev)
>  {
>  	struct device_node *np, *regulators;
>  	int ret;
> -	u32 dcdcfreq;
> +	u32 dcdcfreq = 0;
>  
>  	np = of_node_get(pdev->dev.parent->of_node);
>  	if (!np)
> @@ -186,7 +206,6 @@ static int axp20x_regulator_parse_dt(struct platform_device *pdev)
>  	if (!regulators) {
>  		dev_warn(&pdev->dev, "regulators node not found\n");
>  	} else {
> -		dcdcfreq = 1500;
>  		of_property_read_u32(regulators, "x-powers,dcdc-freq", &dcdcfreq);
>  		ret = axp20x_set_dcdc_freq(pdev, dcdcfreq);
>  		if (ret < 0) {
> @@ -202,15 +221,27 @@ static int axp20x_regulator_parse_dt(struct platform_device *pdev)
>  
>  static int axp20x_set_dcdc_workmode(struct regulator_dev *rdev, int id, u32 workmode)
>  {
> -	unsigned int mask = AXP20X_WORKMODE_DCDC2_MASK;
> +	struct axp20x_dev *axp20x = rdev_get_drvdata(rdev);
> +	unsigned int mask;
>  
> -	if ((id != AXP20X_DCDC2) && (id != AXP20X_DCDC3))
> -		return -EINVAL;
> +	switch (axp20x->variant) {
> +	case AXP202_ID:
> +	case AXP209_ID:
> +		if ((id != AXP20X_DCDC2) && (id != AXP20X_DCDC3))
> +			return -EINVAL;
> +
> +		mask = AXP20X_WORKMODE_DCDC2_MASK;
> +		if (id == AXP20X_DCDC3)
> +			mask = AXP20X_WORKMODE_DCDC3_MASK;
>  
> -	if (id == AXP20X_DCDC3)
> -		mask = AXP20X_WORKMODE_DCDC3_MASK;
> +		workmode <<= ffs(mask) - 1;
> +		break;
>  
> -	workmode <<= ffs(mask) - 1;
> +	default:
> +		/* should not happen */
> +		WARN_ON(1);
> +		return -EINVAL;
> +	}
>  
>  	return regmap_update_bits(rdev->regmap, AXP20X_DCDC_MODE, mask, workmode);
>  }
> @@ -219,22 +250,36 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
>  {
>  	struct regulator_dev *rdev;
>  	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
> +	const struct regulator_desc *regulators;
>  	struct regulator_config config = {
>  		.dev = pdev->dev.parent,
>  		.regmap = axp20x->regmap,
> +		.driver_data = axp20x,
>  	};
> -	int ret, i;
> +	int ret, i, nregulators;
>  	u32 workmode;
>  
> +	switch (axp20x->variant) {
> +	case AXP202_ID:
> +	case AXP209_ID:
> +		regulators = axp20x_regulators;
> +		nregulators = AXP20X_REG_ID_MAX;
> +		break;
> +	default:
> +		dev_err(&pdev->dev, "Unsupported AXP variant: %ld\n",
> +			axp20x->variant);
> +		return -EINVAL;
> +	}
> +
>  	/* This only sets the dcdc freq. Ignore any errors */
>  	axp20x_regulator_parse_dt(pdev);
>  
> -	for (i = 0; i < AXP20X_REG_ID_MAX; i++) {
> -		rdev = devm_regulator_register(&pdev->dev, &axp20x_regulators[i],
> +	for (i = 0; i < nregulators; i++) {
> +		rdev = devm_regulator_register(&pdev->dev, &regulators[i],
>  					       &config);
>  		if (IS_ERR(rdev)) {
>  			dev_err(&pdev->dev, "Failed to register %s\n",
> -				axp20x_regulators[i].name);
> +				regulators[i].name);
>  
>  			return PTR_ERR(rdev);
>  		}
> @@ -245,7 +290,7 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
>  		if (!ret) {
>  			if (axp20x_set_dcdc_workmode(rdev, i, workmode))
>  				dev_err(&pdev->dev, "Failed to set workmode on %s\n",
> -					axp20x_regulators[i].name);
> +					rdev->desc->name);
>  		}
>  	}
>  

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH RESEND v6 3/6] regulator: axp20x: prepare support for multiple AXP chip families
@ 2015-05-13 15:30     ` Lee Jones
  0 siblings, 0 replies; 54+ messages in thread
From: Lee Jones @ 2015-05-13 15:30 UTC (permalink / raw)
  To: Chen-Yu Tsai
  Cc: Samuel Ortiz, Mark Brown, Liam Girdwood, Rob Herring, Pawel Moll,
	Mark Rutland, Ian Campbell, Kumar Gala, Boris BREZILLON,
	Maxime Ripard, Carlo Caione,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw

On Fri, 10 Apr 2015, Chen-Yu Tsai wrote:

> From: Boris BREZILLON <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> 
> Rework the AXP20X_ macros and probe function to support the several chip
> families, so that each family can define it's own set of regulators.
> 
> Signed-off-by: Boris BREZILLON <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> [wens-jdAy2FN1RRM@public.gmane.org: Support different DC-DC work frequency ranges]
> Signed-off-by: Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>
> Reviewed-by: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> ---
>  drivers/regulator/axp20x-regulator.c | 143 +++++++++++++++++++++++------------
>  1 file changed, 94 insertions(+), 49 deletions(-)

Applied, thanks.

> diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c
> index e4331f5e5d7d..50ae0b5f2c0c 100644
> --- a/drivers/regulator/axp20x-regulator.c
> +++ b/drivers/regulator/axp20x-regulator.c
> @@ -32,15 +32,15 @@
>  
>  #define AXP20X_FREQ_DCDC_MASK		0x0f
>  
> -#define AXP20X_DESC_IO(_id, _match, _supply, _min, _max, _step, _vreg, _vmask,	\
> -		       _ereg, _emask, _enable_val, _disable_val)		\
> -	[AXP20X_##_id] = {							\
> +#define AXP_DESC_IO(_family, _id, _match, _supply, _min, _max, _step, _vreg,	\
> +		    _vmask, _ereg, _emask, _enable_val, _disable_val)		\
> +	[_family##_##_id] = {							\
>  		.name		= #_id,						\
>  		.supply_name	= (_supply),					\
>  		.of_match	= of_match_ptr(_match),				\
>  		.regulators_node = of_match_ptr("regulators"),			\
>  		.type		= REGULATOR_VOLTAGE,				\
> -		.id		= AXP20X_##_id,					\
> +		.id		= _family##_##_id,				\
>  		.n_voltages	= (((_max) - (_min)) / (_step) + 1),		\
>  		.owner		= THIS_MODULE,					\
>  		.min_uV		= (_min) * 1000,				\
> @@ -54,15 +54,15 @@
>  		.ops		= &axp20x_ops,					\
>  	}
>  
> -#define AXP20X_DESC(_id, _match, _supply, _min, _max, _step, _vreg, _vmask,	\
> -		    _ereg, _emask)						\
> -	[AXP20X_##_id] = {							\
> +#define AXP_DESC(_family, _id, _match, _supply, _min, _max, _step, _vreg,	\
> +		 _vmask, _ereg, _emask) 					\
> +	[_family##_##_id] = {							\
>  		.name		= #_id,						\
>  		.supply_name	= (_supply),					\
>  		.of_match	= of_match_ptr(_match),				\
>  		.regulators_node = of_match_ptr("regulators"),			\
>  		.type		= REGULATOR_VOLTAGE,				\
> -		.id		= AXP20X_##_id,					\
> +		.id		= _family##_##_id,				\
>  		.n_voltages	= (((_max) - (_min)) / (_step) + 1),		\
>  		.owner		= THIS_MODULE,					\
>  		.min_uV		= (_min) * 1000,				\
> @@ -74,29 +74,29 @@
>  		.ops		= &axp20x_ops,					\
>  	}
>  
> -#define AXP20X_DESC_FIXED(_id, _match, _supply, _volt)				\
> -	[AXP20X_##_id] = {							\
> +#define AXP_DESC_FIXED(_family, _id, _match, _supply, _volt)			\
> +	[_family##_##_id] = {							\
>  		.name		= #_id,						\
>  		.supply_name	= (_supply),					\
>  		.of_match	= of_match_ptr(_match),				\
>  		.regulators_node = of_match_ptr("regulators"),			\
>  		.type		= REGULATOR_VOLTAGE,				\
> -		.id		= AXP20X_##_id,					\
> +		.id		= _family##_##_id,				\
>  		.n_voltages	= 1,						\
>  		.owner		= THIS_MODULE,					\
>  		.min_uV		= (_volt) * 1000,				\
>  		.ops		= &axp20x_ops_fixed				\
>  	}
>  
> -#define AXP20X_DESC_TABLE(_id, _match, _supply, _table, _vreg, _vmask, _ereg,	\
> -			  _emask)						\
> -	[AXP20X_##_id] = {							\
> +#define AXP_DESC_TABLE(_family, _id, _match, _supply, _table, _vreg, _vmask,	\
> +		       _ereg, _emask)						\
> +	[_family##_##_id] = {							\
>  		.name		= #_id,						\
>  		.supply_name	= (_supply),					\
>  		.of_match	= of_match_ptr(_match),				\
>  		.regulators_node = of_match_ptr("regulators"),			\
>  		.type		= REGULATOR_VOLTAGE,				\
> -		.id		= AXP20X_##_id,					\
> +		.id		= _family##_##_id,				\
>  		.n_voltages	= ARRAY_SIZE(_table),				\
>  		.owner		= THIS_MODULE,					\
>  		.vsel_reg	= (_vreg),					\
> @@ -136,37 +136,57 @@ static struct regulator_ops axp20x_ops = {
>  };
>  
>  static const struct regulator_desc axp20x_regulators[] = {
> -	AXP20X_DESC(DCDC2, "dcdc2", "vin2", 700, 2275, 25, AXP20X_DCDC2_V_OUT,
> -		    0x3f, AXP20X_PWR_OUT_CTRL, 0x10),
> -	AXP20X_DESC(DCDC3, "dcdc3", "vin3", 700, 3500, 25, AXP20X_DCDC3_V_OUT,
> -		    0x7f, AXP20X_PWR_OUT_CTRL, 0x02),
> -	AXP20X_DESC_FIXED(LDO1, "ldo1", "acin", 1300),
> -	AXP20X_DESC(LDO2, "ldo2", "ldo24in", 1800, 3300, 100,
> -		    AXP20X_LDO24_V_OUT, 0xf0, AXP20X_PWR_OUT_CTRL, 0x04),
> -	AXP20X_DESC(LDO3, "ldo3", "ldo3in", 700, 3500, 25, AXP20X_LDO3_V_OUT,
> -		    0x7f, AXP20X_PWR_OUT_CTRL, 0x40),
> -	AXP20X_DESC_TABLE(LDO4, "ldo4", "ldo24in", axp20x_ldo4_data,
> -			  AXP20X_LDO24_V_OUT, 0x0f, AXP20X_PWR_OUT_CTRL, 0x08),
> -	AXP20X_DESC_IO(LDO5, "ldo5", "ldo5in", 1800, 3300, 100,
> -		       AXP20X_LDO5_V_OUT, 0xf0, AXP20X_GPIO0_CTRL, 0x07,
> -		       AXP20X_IO_ENABLED, AXP20X_IO_DISABLED),
> +	AXP_DESC(AXP20X, DCDC2, "dcdc2", "vin2", 700, 2275, 25,
> +		 AXP20X_DCDC2_V_OUT, 0x3f, AXP20X_PWR_OUT_CTRL, 0x10),
> +	AXP_DESC(AXP20X, DCDC3, "dcdc3", "vin3", 700, 3500, 25,
> +		 AXP20X_DCDC3_V_OUT, 0x7f, AXP20X_PWR_OUT_CTRL, 0x02),
> +	AXP_DESC_FIXED(AXP20X, LDO1, "ldo1", "acin", 1300),
> +	AXP_DESC(AXP20X, LDO2, "ldo2", "ldo24in", 1800, 3300, 100,
> +		 AXP20X_LDO24_V_OUT, 0xf0, AXP20X_PWR_OUT_CTRL, 0x04),
> +	AXP_DESC(AXP20X, LDO3, "ldo3", "ldo3in", 700, 3500, 25,
> +		 AXP20X_LDO3_V_OUT, 0x7f, AXP20X_PWR_OUT_CTRL, 0x40),
> +	AXP_DESC_TABLE(AXP20X, LDO4, "ldo4", "ldo24in", axp20x_ldo4_data,
> +		       AXP20X_LDO24_V_OUT, 0x0f, AXP20X_PWR_OUT_CTRL, 0x08),
> +	AXP_DESC_IO(AXP20X, LDO5, "ldo5", "ldo5in", 1800, 3300, 100,
> +		    AXP20X_LDO5_V_OUT, 0xf0, AXP20X_GPIO0_CTRL, 0x07,
> +		    AXP20X_IO_ENABLED, AXP20X_IO_DISABLED),
>  };
>  
>  static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq)
>  {
>  	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
> +	u32 min, max, def, step;
> +
> +	switch (axp20x->variant) {
> +	case AXP202_ID:
> +	case AXP209_ID:
> +		min = 750;
> +		max = 1875;
> +		def = 1500;
> +		step = 75;
> +		break;
> +	default:
> +		dev_err(&pdev->dev,
> +			"Setting DCDC frequency for unsupported AXP variant\n");
> +		return -EINVAL;
> +	}
> +
> +	if (dcdcfreq == 0)
> +		dcdcfreq = def;
>  
> -	if (dcdcfreq < 750) {
> -		dcdcfreq = 750;
> -		dev_warn(&pdev->dev, "DCDC frequency too low. Set to 750kHz\n");
> +	if (dcdcfreq < min) {
> +		dcdcfreq = min;
> +		dev_warn(&pdev->dev, "DCDC frequency too low. Set to %ukHz\n",
> +			 min);
>  	}
>  
> -	if (dcdcfreq > 1875) {
> -		dcdcfreq = 1875;
> -		dev_warn(&pdev->dev, "DCDC frequency too high. Set to 1875kHz\n");
> +	if (dcdcfreq > max) {
> +		dcdcfreq = max;
> +		dev_warn(&pdev->dev, "DCDC frequency too high. Set to %ukHz\n",
> +			 max);
>  	}
>  
> -	dcdcfreq = (dcdcfreq - 750) / 75;
> +	dcdcfreq = (dcdcfreq - min) / step;
>  
>  	return regmap_update_bits(axp20x->regmap, AXP20X_DCDC_FREQ,
>  				  AXP20X_FREQ_DCDC_MASK, dcdcfreq);
> @@ -176,7 +196,7 @@ static int axp20x_regulator_parse_dt(struct platform_device *pdev)
>  {
>  	struct device_node *np, *regulators;
>  	int ret;
> -	u32 dcdcfreq;
> +	u32 dcdcfreq = 0;
>  
>  	np = of_node_get(pdev->dev.parent->of_node);
>  	if (!np)
> @@ -186,7 +206,6 @@ static int axp20x_regulator_parse_dt(struct platform_device *pdev)
>  	if (!regulators) {
>  		dev_warn(&pdev->dev, "regulators node not found\n");
>  	} else {
> -		dcdcfreq = 1500;
>  		of_property_read_u32(regulators, "x-powers,dcdc-freq", &dcdcfreq);
>  		ret = axp20x_set_dcdc_freq(pdev, dcdcfreq);
>  		if (ret < 0) {
> @@ -202,15 +221,27 @@ static int axp20x_regulator_parse_dt(struct platform_device *pdev)
>  
>  static int axp20x_set_dcdc_workmode(struct regulator_dev *rdev, int id, u32 workmode)
>  {
> -	unsigned int mask = AXP20X_WORKMODE_DCDC2_MASK;
> +	struct axp20x_dev *axp20x = rdev_get_drvdata(rdev);
> +	unsigned int mask;
>  
> -	if ((id != AXP20X_DCDC2) && (id != AXP20X_DCDC3))
> -		return -EINVAL;
> +	switch (axp20x->variant) {
> +	case AXP202_ID:
> +	case AXP209_ID:
> +		if ((id != AXP20X_DCDC2) && (id != AXP20X_DCDC3))
> +			return -EINVAL;
> +
> +		mask = AXP20X_WORKMODE_DCDC2_MASK;
> +		if (id == AXP20X_DCDC3)
> +			mask = AXP20X_WORKMODE_DCDC3_MASK;
>  
> -	if (id == AXP20X_DCDC3)
> -		mask = AXP20X_WORKMODE_DCDC3_MASK;
> +		workmode <<= ffs(mask) - 1;
> +		break;
>  
> -	workmode <<= ffs(mask) - 1;
> +	default:
> +		/* should not happen */
> +		WARN_ON(1);
> +		return -EINVAL;
> +	}
>  
>  	return regmap_update_bits(rdev->regmap, AXP20X_DCDC_MODE, mask, workmode);
>  }
> @@ -219,22 +250,36 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
>  {
>  	struct regulator_dev *rdev;
>  	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
> +	const struct regulator_desc *regulators;
>  	struct regulator_config config = {
>  		.dev = pdev->dev.parent,
>  		.regmap = axp20x->regmap,
> +		.driver_data = axp20x,
>  	};
> -	int ret, i;
> +	int ret, i, nregulators;
>  	u32 workmode;
>  
> +	switch (axp20x->variant) {
> +	case AXP202_ID:
> +	case AXP209_ID:
> +		regulators = axp20x_regulators;
> +		nregulators = AXP20X_REG_ID_MAX;
> +		break;
> +	default:
> +		dev_err(&pdev->dev, "Unsupported AXP variant: %ld\n",
> +			axp20x->variant);
> +		return -EINVAL;
> +	}
> +
>  	/* This only sets the dcdc freq. Ignore any errors */
>  	axp20x_regulator_parse_dt(pdev);
>  
> -	for (i = 0; i < AXP20X_REG_ID_MAX; i++) {
> -		rdev = devm_regulator_register(&pdev->dev, &axp20x_regulators[i],
> +	for (i = 0; i < nregulators; i++) {
> +		rdev = devm_regulator_register(&pdev->dev, &regulators[i],
>  					       &config);
>  		if (IS_ERR(rdev)) {
>  			dev_err(&pdev->dev, "Failed to register %s\n",
> -				axp20x_regulators[i].name);
> +				regulators[i].name);
>  
>  			return PTR_ERR(rdev);
>  		}
> @@ -245,7 +290,7 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
>  		if (!ret) {
>  			if (axp20x_set_dcdc_workmode(rdev, i, workmode))
>  				dev_err(&pdev->dev, "Failed to set workmode on %s\n",
> -					axp20x_regulators[i].name);
> +					rdev->desc->name);
>  		}
>  	}
>  

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

-- 
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/d/optout.

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH RESEND v6 3/6] regulator: axp20x: prepare support for multiple AXP chip families
@ 2015-05-13 15:30     ` Lee Jones
  0 siblings, 0 replies; 54+ messages in thread
From: Lee Jones @ 2015-05-13 15:30 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, 10 Apr 2015, Chen-Yu Tsai wrote:

> From: Boris BREZILLON <boris.brezillon@free-electrons.com>
> 
> Rework the AXP20X_ macros and probe function to support the several chip
> families, so that each family can define it's own set of regulators.
> 
> Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
> [wens at csie.org: Support different DC-DC work frequency ranges]
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> Reviewed-by: Mark Brown <broonie@kernel.org>
> ---
>  drivers/regulator/axp20x-regulator.c | 143 +++++++++++++++++++++++------------
>  1 file changed, 94 insertions(+), 49 deletions(-)

Applied, thanks.

> diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c
> index e4331f5e5d7d..50ae0b5f2c0c 100644
> --- a/drivers/regulator/axp20x-regulator.c
> +++ b/drivers/regulator/axp20x-regulator.c
> @@ -32,15 +32,15 @@
>  
>  #define AXP20X_FREQ_DCDC_MASK		0x0f
>  
> -#define AXP20X_DESC_IO(_id, _match, _supply, _min, _max, _step, _vreg, _vmask,	\
> -		       _ereg, _emask, _enable_val, _disable_val)		\
> -	[AXP20X_##_id] = {							\
> +#define AXP_DESC_IO(_family, _id, _match, _supply, _min, _max, _step, _vreg,	\
> +		    _vmask, _ereg, _emask, _enable_val, _disable_val)		\
> +	[_family##_##_id] = {							\
>  		.name		= #_id,						\
>  		.supply_name	= (_supply),					\
>  		.of_match	= of_match_ptr(_match),				\
>  		.regulators_node = of_match_ptr("regulators"),			\
>  		.type		= REGULATOR_VOLTAGE,				\
> -		.id		= AXP20X_##_id,					\
> +		.id		= _family##_##_id,				\
>  		.n_voltages	= (((_max) - (_min)) / (_step) + 1),		\
>  		.owner		= THIS_MODULE,					\
>  		.min_uV		= (_min) * 1000,				\
> @@ -54,15 +54,15 @@
>  		.ops		= &axp20x_ops,					\
>  	}
>  
> -#define AXP20X_DESC(_id, _match, _supply, _min, _max, _step, _vreg, _vmask,	\
> -		    _ereg, _emask)						\
> -	[AXP20X_##_id] = {							\
> +#define AXP_DESC(_family, _id, _match, _supply, _min, _max, _step, _vreg,	\
> +		 _vmask, _ereg, _emask) 					\
> +	[_family##_##_id] = {							\
>  		.name		= #_id,						\
>  		.supply_name	= (_supply),					\
>  		.of_match	= of_match_ptr(_match),				\
>  		.regulators_node = of_match_ptr("regulators"),			\
>  		.type		= REGULATOR_VOLTAGE,				\
> -		.id		= AXP20X_##_id,					\
> +		.id		= _family##_##_id,				\
>  		.n_voltages	= (((_max) - (_min)) / (_step) + 1),		\
>  		.owner		= THIS_MODULE,					\
>  		.min_uV		= (_min) * 1000,				\
> @@ -74,29 +74,29 @@
>  		.ops		= &axp20x_ops,					\
>  	}
>  
> -#define AXP20X_DESC_FIXED(_id, _match, _supply, _volt)				\
> -	[AXP20X_##_id] = {							\
> +#define AXP_DESC_FIXED(_family, _id, _match, _supply, _volt)			\
> +	[_family##_##_id] = {							\
>  		.name		= #_id,						\
>  		.supply_name	= (_supply),					\
>  		.of_match	= of_match_ptr(_match),				\
>  		.regulators_node = of_match_ptr("regulators"),			\
>  		.type		= REGULATOR_VOLTAGE,				\
> -		.id		= AXP20X_##_id,					\
> +		.id		= _family##_##_id,				\
>  		.n_voltages	= 1,						\
>  		.owner		= THIS_MODULE,					\
>  		.min_uV		= (_volt) * 1000,				\
>  		.ops		= &axp20x_ops_fixed				\
>  	}
>  
> -#define AXP20X_DESC_TABLE(_id, _match, _supply, _table, _vreg, _vmask, _ereg,	\
> -			  _emask)						\
> -	[AXP20X_##_id] = {							\
> +#define AXP_DESC_TABLE(_family, _id, _match, _supply, _table, _vreg, _vmask,	\
> +		       _ereg, _emask)						\
> +	[_family##_##_id] = {							\
>  		.name		= #_id,						\
>  		.supply_name	= (_supply),					\
>  		.of_match	= of_match_ptr(_match),				\
>  		.regulators_node = of_match_ptr("regulators"),			\
>  		.type		= REGULATOR_VOLTAGE,				\
> -		.id		= AXP20X_##_id,					\
> +		.id		= _family##_##_id,				\
>  		.n_voltages	= ARRAY_SIZE(_table),				\
>  		.owner		= THIS_MODULE,					\
>  		.vsel_reg	= (_vreg),					\
> @@ -136,37 +136,57 @@ static struct regulator_ops axp20x_ops = {
>  };
>  
>  static const struct regulator_desc axp20x_regulators[] = {
> -	AXP20X_DESC(DCDC2, "dcdc2", "vin2", 700, 2275, 25, AXP20X_DCDC2_V_OUT,
> -		    0x3f, AXP20X_PWR_OUT_CTRL, 0x10),
> -	AXP20X_DESC(DCDC3, "dcdc3", "vin3", 700, 3500, 25, AXP20X_DCDC3_V_OUT,
> -		    0x7f, AXP20X_PWR_OUT_CTRL, 0x02),
> -	AXP20X_DESC_FIXED(LDO1, "ldo1", "acin", 1300),
> -	AXP20X_DESC(LDO2, "ldo2", "ldo24in", 1800, 3300, 100,
> -		    AXP20X_LDO24_V_OUT, 0xf0, AXP20X_PWR_OUT_CTRL, 0x04),
> -	AXP20X_DESC(LDO3, "ldo3", "ldo3in", 700, 3500, 25, AXP20X_LDO3_V_OUT,
> -		    0x7f, AXP20X_PWR_OUT_CTRL, 0x40),
> -	AXP20X_DESC_TABLE(LDO4, "ldo4", "ldo24in", axp20x_ldo4_data,
> -			  AXP20X_LDO24_V_OUT, 0x0f, AXP20X_PWR_OUT_CTRL, 0x08),
> -	AXP20X_DESC_IO(LDO5, "ldo5", "ldo5in", 1800, 3300, 100,
> -		       AXP20X_LDO5_V_OUT, 0xf0, AXP20X_GPIO0_CTRL, 0x07,
> -		       AXP20X_IO_ENABLED, AXP20X_IO_DISABLED),
> +	AXP_DESC(AXP20X, DCDC2, "dcdc2", "vin2", 700, 2275, 25,
> +		 AXP20X_DCDC2_V_OUT, 0x3f, AXP20X_PWR_OUT_CTRL, 0x10),
> +	AXP_DESC(AXP20X, DCDC3, "dcdc3", "vin3", 700, 3500, 25,
> +		 AXP20X_DCDC3_V_OUT, 0x7f, AXP20X_PWR_OUT_CTRL, 0x02),
> +	AXP_DESC_FIXED(AXP20X, LDO1, "ldo1", "acin", 1300),
> +	AXP_DESC(AXP20X, LDO2, "ldo2", "ldo24in", 1800, 3300, 100,
> +		 AXP20X_LDO24_V_OUT, 0xf0, AXP20X_PWR_OUT_CTRL, 0x04),
> +	AXP_DESC(AXP20X, LDO3, "ldo3", "ldo3in", 700, 3500, 25,
> +		 AXP20X_LDO3_V_OUT, 0x7f, AXP20X_PWR_OUT_CTRL, 0x40),
> +	AXP_DESC_TABLE(AXP20X, LDO4, "ldo4", "ldo24in", axp20x_ldo4_data,
> +		       AXP20X_LDO24_V_OUT, 0x0f, AXP20X_PWR_OUT_CTRL, 0x08),
> +	AXP_DESC_IO(AXP20X, LDO5, "ldo5", "ldo5in", 1800, 3300, 100,
> +		    AXP20X_LDO5_V_OUT, 0xf0, AXP20X_GPIO0_CTRL, 0x07,
> +		    AXP20X_IO_ENABLED, AXP20X_IO_DISABLED),
>  };
>  
>  static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq)
>  {
>  	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
> +	u32 min, max, def, step;
> +
> +	switch (axp20x->variant) {
> +	case AXP202_ID:
> +	case AXP209_ID:
> +		min = 750;
> +		max = 1875;
> +		def = 1500;
> +		step = 75;
> +		break;
> +	default:
> +		dev_err(&pdev->dev,
> +			"Setting DCDC frequency for unsupported AXP variant\n");
> +		return -EINVAL;
> +	}
> +
> +	if (dcdcfreq == 0)
> +		dcdcfreq = def;
>  
> -	if (dcdcfreq < 750) {
> -		dcdcfreq = 750;
> -		dev_warn(&pdev->dev, "DCDC frequency too low. Set to 750kHz\n");
> +	if (dcdcfreq < min) {
> +		dcdcfreq = min;
> +		dev_warn(&pdev->dev, "DCDC frequency too low. Set to %ukHz\n",
> +			 min);
>  	}
>  
> -	if (dcdcfreq > 1875) {
> -		dcdcfreq = 1875;
> -		dev_warn(&pdev->dev, "DCDC frequency too high. Set to 1875kHz\n");
> +	if (dcdcfreq > max) {
> +		dcdcfreq = max;
> +		dev_warn(&pdev->dev, "DCDC frequency too high. Set to %ukHz\n",
> +			 max);
>  	}
>  
> -	dcdcfreq = (dcdcfreq - 750) / 75;
> +	dcdcfreq = (dcdcfreq - min) / step;
>  
>  	return regmap_update_bits(axp20x->regmap, AXP20X_DCDC_FREQ,
>  				  AXP20X_FREQ_DCDC_MASK, dcdcfreq);
> @@ -176,7 +196,7 @@ static int axp20x_regulator_parse_dt(struct platform_device *pdev)
>  {
>  	struct device_node *np, *regulators;
>  	int ret;
> -	u32 dcdcfreq;
> +	u32 dcdcfreq = 0;
>  
>  	np = of_node_get(pdev->dev.parent->of_node);
>  	if (!np)
> @@ -186,7 +206,6 @@ static int axp20x_regulator_parse_dt(struct platform_device *pdev)
>  	if (!regulators) {
>  		dev_warn(&pdev->dev, "regulators node not found\n");
>  	} else {
> -		dcdcfreq = 1500;
>  		of_property_read_u32(regulators, "x-powers,dcdc-freq", &dcdcfreq);
>  		ret = axp20x_set_dcdc_freq(pdev, dcdcfreq);
>  		if (ret < 0) {
> @@ -202,15 +221,27 @@ static int axp20x_regulator_parse_dt(struct platform_device *pdev)
>  
>  static int axp20x_set_dcdc_workmode(struct regulator_dev *rdev, int id, u32 workmode)
>  {
> -	unsigned int mask = AXP20X_WORKMODE_DCDC2_MASK;
> +	struct axp20x_dev *axp20x = rdev_get_drvdata(rdev);
> +	unsigned int mask;
>  
> -	if ((id != AXP20X_DCDC2) && (id != AXP20X_DCDC3))
> -		return -EINVAL;
> +	switch (axp20x->variant) {
> +	case AXP202_ID:
> +	case AXP209_ID:
> +		if ((id != AXP20X_DCDC2) && (id != AXP20X_DCDC3))
> +			return -EINVAL;
> +
> +		mask = AXP20X_WORKMODE_DCDC2_MASK;
> +		if (id == AXP20X_DCDC3)
> +			mask = AXP20X_WORKMODE_DCDC3_MASK;
>  
> -	if (id == AXP20X_DCDC3)
> -		mask = AXP20X_WORKMODE_DCDC3_MASK;
> +		workmode <<= ffs(mask) - 1;
> +		break;
>  
> -	workmode <<= ffs(mask) - 1;
> +	default:
> +		/* should not happen */
> +		WARN_ON(1);
> +		return -EINVAL;
> +	}
>  
>  	return regmap_update_bits(rdev->regmap, AXP20X_DCDC_MODE, mask, workmode);
>  }
> @@ -219,22 +250,36 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
>  {
>  	struct regulator_dev *rdev;
>  	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
> +	const struct regulator_desc *regulators;
>  	struct regulator_config config = {
>  		.dev = pdev->dev.parent,
>  		.regmap = axp20x->regmap,
> +		.driver_data = axp20x,
>  	};
> -	int ret, i;
> +	int ret, i, nregulators;
>  	u32 workmode;
>  
> +	switch (axp20x->variant) {
> +	case AXP202_ID:
> +	case AXP209_ID:
> +		regulators = axp20x_regulators;
> +		nregulators = AXP20X_REG_ID_MAX;
> +		break;
> +	default:
> +		dev_err(&pdev->dev, "Unsupported AXP variant: %ld\n",
> +			axp20x->variant);
> +		return -EINVAL;
> +	}
> +
>  	/* This only sets the dcdc freq. Ignore any errors */
>  	axp20x_regulator_parse_dt(pdev);
>  
> -	for (i = 0; i < AXP20X_REG_ID_MAX; i++) {
> -		rdev = devm_regulator_register(&pdev->dev, &axp20x_regulators[i],
> +	for (i = 0; i < nregulators; i++) {
> +		rdev = devm_regulator_register(&pdev->dev, &regulators[i],
>  					       &config);
>  		if (IS_ERR(rdev)) {
>  			dev_err(&pdev->dev, "Failed to register %s\n",
> -				axp20x_regulators[i].name);
> +				regulators[i].name);
>  
>  			return PTR_ERR(rdev);
>  		}
> @@ -245,7 +290,7 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
>  		if (!ret) {
>  			if (axp20x_set_dcdc_workmode(rdev, i, workmode))
>  				dev_err(&pdev->dev, "Failed to set workmode on %s\n",
> -					axp20x_regulators[i].name);
> +					rdev->desc->name);
>  		}
>  	}
>  

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH RESEND v6 4/6] regulator: axp20x: add support for AXP22X regulators
@ 2015-05-13 15:30     ` Lee Jones
  0 siblings, 0 replies; 54+ messages in thread
From: Lee Jones @ 2015-05-13 15:30 UTC (permalink / raw)
  To: Chen-Yu Tsai
  Cc: Samuel Ortiz, Mark Brown, Liam Girdwood, Rob Herring, Pawel Moll,
	Mark Rutland, Ian Campbell, Kumar Gala, Boris BREZILLON,
	Maxime Ripard, Carlo Caione, linux-arm-kernel, devicetree,
	linux-kernel, linux-sunxi

On Fri, 10 Apr 2015, Chen-Yu Tsai wrote:

> From: Boris BREZILLON <boris.brezillon@free-electrons.com>
> 
> Add AXP22X regulator definitions and variant id associations.
> This introduces a new "switch" type output for one of the regulators.
> It is a switchable secondary output of one regulator, with the same
> voltage level as the primary output.
> 
> Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
> [wens@csie.org: Moved variant choosing to multi family support patch]
> [wens@csie.org: Add dc-dc work frequency range]
> [wens@csie.org: Add "switch" type output regulator DC1SW]
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> Reviewed-by: Mark Brown <broonie@kernel.org>
> ---
> 
> Hi Mark,
>     
> This patch depends on the previous patch "regulator: axp20x: prepare
> support for multiple AXP chip families" and the mfd header from the
> first patch "mfd: axp20x: add AXP22x PMIC support".
> 
> Could we merge both regulator patches through the mfd tree, with the
> other patches in the series? There are no other external dependencies.
> 
> ChenYu
> 
> ---
>  drivers/regulator/axp20x-regulator.c | 96 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 96 insertions(+)

Applied, thanks.

> diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c
> index 50ae0b5f2c0c..646829132b59 100644
> --- a/drivers/regulator/axp20x-regulator.c
> +++ b/drivers/regulator/axp20x-regulator.c
> @@ -27,8 +27,12 @@
>  #define AXP20X_IO_ENABLED		0x03
>  #define AXP20X_IO_DISABLED		0x07
>  
> +#define AXP22X_IO_ENABLED		0x04
> +#define AXP22X_IO_DISABLED		0x03
> +
>  #define AXP20X_WORKMODE_DCDC2_MASK	BIT(2)
>  #define AXP20X_WORKMODE_DCDC3_MASK	BIT(1)
> +#define AXP22X_WORKMODE_DCDCX_MASK(x)	BIT(x)
>  
>  #define AXP20X_FREQ_DCDC_MASK		0x0f
>  
> @@ -74,6 +78,26 @@
>  		.ops		= &axp20x_ops,					\
>  	}
>  
> +#define AXP_DESC_SW(_family, _id, _match, _supply, _min, _max, _step, _vreg,	\
> +		    _vmask, _ereg, _emask) 					\
> +	[_family##_##_id] = {							\
> +		.name		= #_id,						\
> +		.supply_name	= (_supply),					\
> +		.of_match	= of_match_ptr(_match),				\
> +		.regulators_node = of_match_ptr("regulators"),			\
> +		.type		= REGULATOR_VOLTAGE,				\
> +		.id		= _family##_##_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),					\
> +		.ops		= &axp20x_ops_sw,				\
> +	}
> +
>  #define AXP_DESC_FIXED(_family, _id, _match, _supply, _volt)			\
>  	[_family##_##_id] = {							\
>  		.name		= #_id,						\
> @@ -135,6 +159,14 @@ static struct regulator_ops axp20x_ops = {
>  	.is_enabled		= regulator_is_enabled_regmap,
>  };
>  
> +static struct regulator_ops axp20x_ops_sw = {
> +	.get_voltage_sel	= regulator_get_voltage_sel_regmap,
> +	.list_voltage		= regulator_list_voltage_linear,
> +	.enable			= regulator_enable_regmap,
> +	.disable		= regulator_disable_regmap,
> +	.is_enabled		= regulator_is_enabled_regmap,
> +};
> +
>  static const struct regulator_desc axp20x_regulators[] = {
>  	AXP_DESC(AXP20X, DCDC2, "dcdc2", "vin2", 700, 2275, 25,
>  		 AXP20X_DCDC2_V_OUT, 0x3f, AXP20X_PWR_OUT_CTRL, 0x10),
> @@ -152,6 +184,52 @@ static const struct regulator_desc axp20x_regulators[] = {
>  		    AXP20X_IO_ENABLED, AXP20X_IO_DISABLED),
>  };
>  
> +static const struct regulator_desc axp22x_regulators[] = {
> +	AXP_DESC(AXP22X, DCDC1, "dcdc1", "vin1", 1600, 3400, 100,
> +		 AXP22X_DCDC1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL1, BIT(1)),
> +	AXP_DESC(AXP22X, DCDC2, "dcdc2", "vin2", 600, 1540, 20,
> +		 AXP22X_DCDC2_V_OUT, 0x3f, AXP22X_PWR_OUT_CTRL1, BIT(2)),
> +	AXP_DESC(AXP22X, DCDC3, "dcdc3", "vin3", 600, 1860, 20,
> +		 AXP22X_DCDC3_V_OUT, 0x3f, AXP22X_PWR_OUT_CTRL1, BIT(3)),
> +	AXP_DESC(AXP22X, DCDC4, "dcdc4", "vin4", 600, 1540, 20,
> +		 AXP22X_DCDC4_V_OUT, 0x3f, AXP22X_PWR_OUT_CTRL1, BIT(3)),
> +	AXP_DESC(AXP22X, DCDC5, "dcdc5", "vin5", 1000, 2550, 50,
> +		 AXP22X_DCDC5_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL1, BIT(4)),
> +	/* secondary switchable output of DCDC1 */
> +	AXP_DESC_SW(AXP22X, DC1SW, "dc1sw", "dcdc1", 1600, 3400, 100,
> +		    AXP22X_DCDC1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(7)),
> +	/* LDO regulator internally chained to DCDC5 */
> +	AXP_DESC(AXP22X, DC5LDO, "dc5ldo", "dcdc5", 700, 1400, 100,
> +		 AXP22X_DC5LDO_V_OUT, 0x7, AXP22X_PWR_OUT_CTRL1, BIT(0)),
> +	AXP_DESC(AXP22X, ALDO1, "aldo1", "aldoin", 700, 3300, 100,
> +		 AXP22X_ALDO1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL1, BIT(6)),
> +	AXP_DESC(AXP22X, ALDO2, "aldo2", "aldoin", 700, 3300, 100,
> +		 AXP22X_ALDO2_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL1, BIT(7)),
> +	AXP_DESC(AXP22X, ALDO3, "aldo3", "aldoin", 700, 3300, 100,
> +		 AXP22X_ALDO3_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL3, BIT(7)),
> +	AXP_DESC(AXP22X, DLDO1, "dldo1", "dldoin", 700, 3300, 100,
> +		 AXP22X_DLDO1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(3)),
> +	AXP_DESC(AXP22X, DLDO2, "dldo2", "dldoin", 700, 3300, 100,
> +		 AXP22X_DLDO2_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(4)),
> +	AXP_DESC(AXP22X, DLDO3, "dldo3", "dldoin", 700, 3300, 100,
> +		 AXP22X_DLDO3_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(5)),
> +	AXP_DESC(AXP22X, DLDO4, "dldo4", "dldoin", 700, 3300, 100,
> +		 AXP22X_DLDO4_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(6)),
> +	AXP_DESC(AXP22X, ELDO1, "eldo1", "eldoin", 700, 3300, 100,
> +		 AXP22X_ELDO1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(0)),
> +	AXP_DESC(AXP22X, ELDO2, "eldo2", "eldoin", 700, 3300, 100,
> +		 AXP22X_ELDO2_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(1)),
> +	AXP_DESC(AXP22X, ELDO3, "eldo3", "eldoin", 700, 3300, 100,
> +		 AXP22X_ELDO3_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(2)),
> +	AXP_DESC_IO(AXP22X, LDO_IO0, "ldo_io0", "ips", 1800, 3300, 100,
> +		    AXP22X_LDO_IO0_V_OUT, 0x1f, AXP20X_GPIO0_CTRL, 0x07,
> +		    AXP22X_IO_ENABLED, AXP22X_IO_DISABLED),
> +	AXP_DESC_IO(AXP22X, LDO_IO1, "ldo_io1", "ips", 1800, 3300, 100,
> +		    AXP22X_LDO_IO1_V_OUT, 0x1f, AXP20X_GPIO1_CTRL, 0x07,
> +		    AXP22X_IO_ENABLED, AXP22X_IO_DISABLED),
> +	AXP_DESC_FIXED(AXP22X, RTC_LDO, "rtc_ldo", "ips", 3000),
> +};
> +
>  static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq)
>  {
>  	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
> @@ -165,6 +243,12 @@ static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq)
>  		def = 1500;
>  		step = 75;
>  		break;
> +	case AXP221_ID:
> +		min = 1800;
> +		max = 4050;
> +		def = 3000;
> +		step = 150;
> +		break;
>  	default:
>  		dev_err(&pdev->dev,
>  			"Setting DCDC frequency for unsupported AXP variant\n");
> @@ -237,6 +321,14 @@ static int axp20x_set_dcdc_workmode(struct regulator_dev *rdev, int id, u32 work
>  		workmode <<= ffs(mask) - 1;
>  		break;
>  
> +	case AXP221_ID:
> +		if (id < AXP22X_DCDC1 || id > AXP22X_DCDC5)
> +			return -EINVAL;
> +
> +		mask = AXP22X_WORKMODE_DCDCX_MASK(id - AXP22X_DCDC1);
> +		workmode <<= id - AXP22X_DCDC1;
> +		break;
> +
>  	default:
>  		/* should not happen */
>  		WARN_ON(1);
> @@ -265,6 +357,10 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
>  		regulators = axp20x_regulators;
>  		nregulators = AXP20X_REG_ID_MAX;
>  		break;
> +	case AXP221_ID:
> +		regulators = axp22x_regulators;
> +		nregulators = AXP22X_REG_ID_MAX;
> +		break;
>  	default:
>  		dev_err(&pdev->dev, "Unsupported AXP variant: %ld\n",
>  			axp20x->variant);

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH RESEND v6 4/6] regulator: axp20x: add support for AXP22X regulators
@ 2015-05-13 15:30     ` Lee Jones
  0 siblings, 0 replies; 54+ messages in thread
From: Lee Jones @ 2015-05-13 15:30 UTC (permalink / raw)
  To: Chen-Yu Tsai
  Cc: Samuel Ortiz, Mark Brown, Liam Girdwood, Rob Herring, Pawel Moll,
	Mark Rutland, Ian Campbell, Kumar Gala, Boris BREZILLON,
	Maxime Ripard, Carlo Caione,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw

On Fri, 10 Apr 2015, Chen-Yu Tsai wrote:

> From: Boris BREZILLON <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> 
> Add AXP22X regulator definitions and variant id associations.
> This introduces a new "switch" type output for one of the regulators.
> It is a switchable secondary output of one regulator, with the same
> voltage level as the primary output.
> 
> Signed-off-by: Boris BREZILLON <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> [wens-jdAy2FN1RRM@public.gmane.org: Moved variant choosing to multi family support patch]
> [wens-jdAy2FN1RRM@public.gmane.org: Add dc-dc work frequency range]
> [wens-jdAy2FN1RRM@public.gmane.org: Add "switch" type output regulator DC1SW]
> Signed-off-by: Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>
> Reviewed-by: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> ---
> 
> Hi Mark,
>     
> This patch depends on the previous patch "regulator: axp20x: prepare
> support for multiple AXP chip families" and the mfd header from the
> first patch "mfd: axp20x: add AXP22x PMIC support".
> 
> Could we merge both regulator patches through the mfd tree, with the
> other patches in the series? There are no other external dependencies.
> 
> ChenYu
> 
> ---
>  drivers/regulator/axp20x-regulator.c | 96 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 96 insertions(+)

Applied, thanks.

> diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c
> index 50ae0b5f2c0c..646829132b59 100644
> --- a/drivers/regulator/axp20x-regulator.c
> +++ b/drivers/regulator/axp20x-regulator.c
> @@ -27,8 +27,12 @@
>  #define AXP20X_IO_ENABLED		0x03
>  #define AXP20X_IO_DISABLED		0x07
>  
> +#define AXP22X_IO_ENABLED		0x04
> +#define AXP22X_IO_DISABLED		0x03
> +
>  #define AXP20X_WORKMODE_DCDC2_MASK	BIT(2)
>  #define AXP20X_WORKMODE_DCDC3_MASK	BIT(1)
> +#define AXP22X_WORKMODE_DCDCX_MASK(x)	BIT(x)
>  
>  #define AXP20X_FREQ_DCDC_MASK		0x0f
>  
> @@ -74,6 +78,26 @@
>  		.ops		= &axp20x_ops,					\
>  	}
>  
> +#define AXP_DESC_SW(_family, _id, _match, _supply, _min, _max, _step, _vreg,	\
> +		    _vmask, _ereg, _emask) 					\
> +	[_family##_##_id] = {							\
> +		.name		= #_id,						\
> +		.supply_name	= (_supply),					\
> +		.of_match	= of_match_ptr(_match),				\
> +		.regulators_node = of_match_ptr("regulators"),			\
> +		.type		= REGULATOR_VOLTAGE,				\
> +		.id		= _family##_##_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),					\
> +		.ops		= &axp20x_ops_sw,				\
> +	}
> +
>  #define AXP_DESC_FIXED(_family, _id, _match, _supply, _volt)			\
>  	[_family##_##_id] = {							\
>  		.name		= #_id,						\
> @@ -135,6 +159,14 @@ static struct regulator_ops axp20x_ops = {
>  	.is_enabled		= regulator_is_enabled_regmap,
>  };
>  
> +static struct regulator_ops axp20x_ops_sw = {
> +	.get_voltage_sel	= regulator_get_voltage_sel_regmap,
> +	.list_voltage		= regulator_list_voltage_linear,
> +	.enable			= regulator_enable_regmap,
> +	.disable		= regulator_disable_regmap,
> +	.is_enabled		= regulator_is_enabled_regmap,
> +};
> +
>  static const struct regulator_desc axp20x_regulators[] = {
>  	AXP_DESC(AXP20X, DCDC2, "dcdc2", "vin2", 700, 2275, 25,
>  		 AXP20X_DCDC2_V_OUT, 0x3f, AXP20X_PWR_OUT_CTRL, 0x10),
> @@ -152,6 +184,52 @@ static const struct regulator_desc axp20x_regulators[] = {
>  		    AXP20X_IO_ENABLED, AXP20X_IO_DISABLED),
>  };
>  
> +static const struct regulator_desc axp22x_regulators[] = {
> +	AXP_DESC(AXP22X, DCDC1, "dcdc1", "vin1", 1600, 3400, 100,
> +		 AXP22X_DCDC1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL1, BIT(1)),
> +	AXP_DESC(AXP22X, DCDC2, "dcdc2", "vin2", 600, 1540, 20,
> +		 AXP22X_DCDC2_V_OUT, 0x3f, AXP22X_PWR_OUT_CTRL1, BIT(2)),
> +	AXP_DESC(AXP22X, DCDC3, "dcdc3", "vin3", 600, 1860, 20,
> +		 AXP22X_DCDC3_V_OUT, 0x3f, AXP22X_PWR_OUT_CTRL1, BIT(3)),
> +	AXP_DESC(AXP22X, DCDC4, "dcdc4", "vin4", 600, 1540, 20,
> +		 AXP22X_DCDC4_V_OUT, 0x3f, AXP22X_PWR_OUT_CTRL1, BIT(3)),
> +	AXP_DESC(AXP22X, DCDC5, "dcdc5", "vin5", 1000, 2550, 50,
> +		 AXP22X_DCDC5_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL1, BIT(4)),
> +	/* secondary switchable output of DCDC1 */
> +	AXP_DESC_SW(AXP22X, DC1SW, "dc1sw", "dcdc1", 1600, 3400, 100,
> +		    AXP22X_DCDC1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(7)),
> +	/* LDO regulator internally chained to DCDC5 */
> +	AXP_DESC(AXP22X, DC5LDO, "dc5ldo", "dcdc5", 700, 1400, 100,
> +		 AXP22X_DC5LDO_V_OUT, 0x7, AXP22X_PWR_OUT_CTRL1, BIT(0)),
> +	AXP_DESC(AXP22X, ALDO1, "aldo1", "aldoin", 700, 3300, 100,
> +		 AXP22X_ALDO1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL1, BIT(6)),
> +	AXP_DESC(AXP22X, ALDO2, "aldo2", "aldoin", 700, 3300, 100,
> +		 AXP22X_ALDO2_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL1, BIT(7)),
> +	AXP_DESC(AXP22X, ALDO3, "aldo3", "aldoin", 700, 3300, 100,
> +		 AXP22X_ALDO3_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL3, BIT(7)),
> +	AXP_DESC(AXP22X, DLDO1, "dldo1", "dldoin", 700, 3300, 100,
> +		 AXP22X_DLDO1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(3)),
> +	AXP_DESC(AXP22X, DLDO2, "dldo2", "dldoin", 700, 3300, 100,
> +		 AXP22X_DLDO2_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(4)),
> +	AXP_DESC(AXP22X, DLDO3, "dldo3", "dldoin", 700, 3300, 100,
> +		 AXP22X_DLDO3_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(5)),
> +	AXP_DESC(AXP22X, DLDO4, "dldo4", "dldoin", 700, 3300, 100,
> +		 AXP22X_DLDO4_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(6)),
> +	AXP_DESC(AXP22X, ELDO1, "eldo1", "eldoin", 700, 3300, 100,
> +		 AXP22X_ELDO1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(0)),
> +	AXP_DESC(AXP22X, ELDO2, "eldo2", "eldoin", 700, 3300, 100,
> +		 AXP22X_ELDO2_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(1)),
> +	AXP_DESC(AXP22X, ELDO3, "eldo3", "eldoin", 700, 3300, 100,
> +		 AXP22X_ELDO3_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(2)),
> +	AXP_DESC_IO(AXP22X, LDO_IO0, "ldo_io0", "ips", 1800, 3300, 100,
> +		    AXP22X_LDO_IO0_V_OUT, 0x1f, AXP20X_GPIO0_CTRL, 0x07,
> +		    AXP22X_IO_ENABLED, AXP22X_IO_DISABLED),
> +	AXP_DESC_IO(AXP22X, LDO_IO1, "ldo_io1", "ips", 1800, 3300, 100,
> +		    AXP22X_LDO_IO1_V_OUT, 0x1f, AXP20X_GPIO1_CTRL, 0x07,
> +		    AXP22X_IO_ENABLED, AXP22X_IO_DISABLED),
> +	AXP_DESC_FIXED(AXP22X, RTC_LDO, "rtc_ldo", "ips", 3000),
> +};
> +
>  static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq)
>  {
>  	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
> @@ -165,6 +243,12 @@ static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq)
>  		def = 1500;
>  		step = 75;
>  		break;
> +	case AXP221_ID:
> +		min = 1800;
> +		max = 4050;
> +		def = 3000;
> +		step = 150;
> +		break;
>  	default:
>  		dev_err(&pdev->dev,
>  			"Setting DCDC frequency for unsupported AXP variant\n");
> @@ -237,6 +321,14 @@ static int axp20x_set_dcdc_workmode(struct regulator_dev *rdev, int id, u32 work
>  		workmode <<= ffs(mask) - 1;
>  		break;
>  
> +	case AXP221_ID:
> +		if (id < AXP22X_DCDC1 || id > AXP22X_DCDC5)
> +			return -EINVAL;
> +
> +		mask = AXP22X_WORKMODE_DCDCX_MASK(id - AXP22X_DCDC1);
> +		workmode <<= id - AXP22X_DCDC1;
> +		break;
> +
>  	default:
>  		/* should not happen */
>  		WARN_ON(1);
> @@ -265,6 +357,10 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
>  		regulators = axp20x_regulators;
>  		nregulators = AXP20X_REG_ID_MAX;
>  		break;
> +	case AXP221_ID:
> +		regulators = axp22x_regulators;
> +		nregulators = AXP22X_REG_ID_MAX;
> +		break;
>  	default:
>  		dev_err(&pdev->dev, "Unsupported AXP variant: %ld\n",
>  			axp20x->variant);

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

-- 
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/d/optout.

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH RESEND v6 4/6] regulator: axp20x: add support for AXP22X regulators
@ 2015-05-13 15:30     ` Lee Jones
  0 siblings, 0 replies; 54+ messages in thread
From: Lee Jones @ 2015-05-13 15:30 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, 10 Apr 2015, Chen-Yu Tsai wrote:

> From: Boris BREZILLON <boris.brezillon@free-electrons.com>
> 
> Add AXP22X regulator definitions and variant id associations.
> This introduces a new "switch" type output for one of the regulators.
> It is a switchable secondary output of one regulator, with the same
> voltage level as the primary output.
> 
> Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
> [wens at csie.org: Moved variant choosing to multi family support patch]
> [wens at csie.org: Add dc-dc work frequency range]
> [wens at csie.org: Add "switch" type output regulator DC1SW]
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> Reviewed-by: Mark Brown <broonie@kernel.org>
> ---
> 
> Hi Mark,
>     
> This patch depends on the previous patch "regulator: axp20x: prepare
> support for multiple AXP chip families" and the mfd header from the
> first patch "mfd: axp20x: add AXP22x PMIC support".
> 
> Could we merge both regulator patches through the mfd tree, with the
> other patches in the series? There are no other external dependencies.
> 
> ChenYu
> 
> ---
>  drivers/regulator/axp20x-regulator.c | 96 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 96 insertions(+)

Applied, thanks.

> diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c
> index 50ae0b5f2c0c..646829132b59 100644
> --- a/drivers/regulator/axp20x-regulator.c
> +++ b/drivers/regulator/axp20x-regulator.c
> @@ -27,8 +27,12 @@
>  #define AXP20X_IO_ENABLED		0x03
>  #define AXP20X_IO_DISABLED		0x07
>  
> +#define AXP22X_IO_ENABLED		0x04
> +#define AXP22X_IO_DISABLED		0x03
> +
>  #define AXP20X_WORKMODE_DCDC2_MASK	BIT(2)
>  #define AXP20X_WORKMODE_DCDC3_MASK	BIT(1)
> +#define AXP22X_WORKMODE_DCDCX_MASK(x)	BIT(x)
>  
>  #define AXP20X_FREQ_DCDC_MASK		0x0f
>  
> @@ -74,6 +78,26 @@
>  		.ops		= &axp20x_ops,					\
>  	}
>  
> +#define AXP_DESC_SW(_family, _id, _match, _supply, _min, _max, _step, _vreg,	\
> +		    _vmask, _ereg, _emask) 					\
> +	[_family##_##_id] = {							\
> +		.name		= #_id,						\
> +		.supply_name	= (_supply),					\
> +		.of_match	= of_match_ptr(_match),				\
> +		.regulators_node = of_match_ptr("regulators"),			\
> +		.type		= REGULATOR_VOLTAGE,				\
> +		.id		= _family##_##_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),					\
> +		.ops		= &axp20x_ops_sw,				\
> +	}
> +
>  #define AXP_DESC_FIXED(_family, _id, _match, _supply, _volt)			\
>  	[_family##_##_id] = {							\
>  		.name		= #_id,						\
> @@ -135,6 +159,14 @@ static struct regulator_ops axp20x_ops = {
>  	.is_enabled		= regulator_is_enabled_regmap,
>  };
>  
> +static struct regulator_ops axp20x_ops_sw = {
> +	.get_voltage_sel	= regulator_get_voltage_sel_regmap,
> +	.list_voltage		= regulator_list_voltage_linear,
> +	.enable			= regulator_enable_regmap,
> +	.disable		= regulator_disable_regmap,
> +	.is_enabled		= regulator_is_enabled_regmap,
> +};
> +
>  static const struct regulator_desc axp20x_regulators[] = {
>  	AXP_DESC(AXP20X, DCDC2, "dcdc2", "vin2", 700, 2275, 25,
>  		 AXP20X_DCDC2_V_OUT, 0x3f, AXP20X_PWR_OUT_CTRL, 0x10),
> @@ -152,6 +184,52 @@ static const struct regulator_desc axp20x_regulators[] = {
>  		    AXP20X_IO_ENABLED, AXP20X_IO_DISABLED),
>  };
>  
> +static const struct regulator_desc axp22x_regulators[] = {
> +	AXP_DESC(AXP22X, DCDC1, "dcdc1", "vin1", 1600, 3400, 100,
> +		 AXP22X_DCDC1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL1, BIT(1)),
> +	AXP_DESC(AXP22X, DCDC2, "dcdc2", "vin2", 600, 1540, 20,
> +		 AXP22X_DCDC2_V_OUT, 0x3f, AXP22X_PWR_OUT_CTRL1, BIT(2)),
> +	AXP_DESC(AXP22X, DCDC3, "dcdc3", "vin3", 600, 1860, 20,
> +		 AXP22X_DCDC3_V_OUT, 0x3f, AXP22X_PWR_OUT_CTRL1, BIT(3)),
> +	AXP_DESC(AXP22X, DCDC4, "dcdc4", "vin4", 600, 1540, 20,
> +		 AXP22X_DCDC4_V_OUT, 0x3f, AXP22X_PWR_OUT_CTRL1, BIT(3)),
> +	AXP_DESC(AXP22X, DCDC5, "dcdc5", "vin5", 1000, 2550, 50,
> +		 AXP22X_DCDC5_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL1, BIT(4)),
> +	/* secondary switchable output of DCDC1 */
> +	AXP_DESC_SW(AXP22X, DC1SW, "dc1sw", "dcdc1", 1600, 3400, 100,
> +		    AXP22X_DCDC1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(7)),
> +	/* LDO regulator internally chained to DCDC5 */
> +	AXP_DESC(AXP22X, DC5LDO, "dc5ldo", "dcdc5", 700, 1400, 100,
> +		 AXP22X_DC5LDO_V_OUT, 0x7, AXP22X_PWR_OUT_CTRL1, BIT(0)),
> +	AXP_DESC(AXP22X, ALDO1, "aldo1", "aldoin", 700, 3300, 100,
> +		 AXP22X_ALDO1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL1, BIT(6)),
> +	AXP_DESC(AXP22X, ALDO2, "aldo2", "aldoin", 700, 3300, 100,
> +		 AXP22X_ALDO2_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL1, BIT(7)),
> +	AXP_DESC(AXP22X, ALDO3, "aldo3", "aldoin", 700, 3300, 100,
> +		 AXP22X_ALDO3_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL3, BIT(7)),
> +	AXP_DESC(AXP22X, DLDO1, "dldo1", "dldoin", 700, 3300, 100,
> +		 AXP22X_DLDO1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(3)),
> +	AXP_DESC(AXP22X, DLDO2, "dldo2", "dldoin", 700, 3300, 100,
> +		 AXP22X_DLDO2_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(4)),
> +	AXP_DESC(AXP22X, DLDO3, "dldo3", "dldoin", 700, 3300, 100,
> +		 AXP22X_DLDO3_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(5)),
> +	AXP_DESC(AXP22X, DLDO4, "dldo4", "dldoin", 700, 3300, 100,
> +		 AXP22X_DLDO4_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(6)),
> +	AXP_DESC(AXP22X, ELDO1, "eldo1", "eldoin", 700, 3300, 100,
> +		 AXP22X_ELDO1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(0)),
> +	AXP_DESC(AXP22X, ELDO2, "eldo2", "eldoin", 700, 3300, 100,
> +		 AXP22X_ELDO2_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(1)),
> +	AXP_DESC(AXP22X, ELDO3, "eldo3", "eldoin", 700, 3300, 100,
> +		 AXP22X_ELDO3_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(2)),
> +	AXP_DESC_IO(AXP22X, LDO_IO0, "ldo_io0", "ips", 1800, 3300, 100,
> +		    AXP22X_LDO_IO0_V_OUT, 0x1f, AXP20X_GPIO0_CTRL, 0x07,
> +		    AXP22X_IO_ENABLED, AXP22X_IO_DISABLED),
> +	AXP_DESC_IO(AXP22X, LDO_IO1, "ldo_io1", "ips", 1800, 3300, 100,
> +		    AXP22X_LDO_IO1_V_OUT, 0x1f, AXP20X_GPIO1_CTRL, 0x07,
> +		    AXP22X_IO_ENABLED, AXP22X_IO_DISABLED),
> +	AXP_DESC_FIXED(AXP22X, RTC_LDO, "rtc_ldo", "ips", 3000),
> +};
> +
>  static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq)
>  {
>  	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
> @@ -165,6 +243,12 @@ static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq)
>  		def = 1500;
>  		step = 75;
>  		break;
> +	case AXP221_ID:
> +		min = 1800;
> +		max = 4050;
> +		def = 3000;
> +		step = 150;
> +		break;
>  	default:
>  		dev_err(&pdev->dev,
>  			"Setting DCDC frequency for unsupported AXP variant\n");
> @@ -237,6 +321,14 @@ static int axp20x_set_dcdc_workmode(struct regulator_dev *rdev, int id, u32 work
>  		workmode <<= ffs(mask) - 1;
>  		break;
>  
> +	case AXP221_ID:
> +		if (id < AXP22X_DCDC1 || id > AXP22X_DCDC5)
> +			return -EINVAL;
> +
> +		mask = AXP22X_WORKMODE_DCDCX_MASK(id - AXP22X_DCDC1);
> +		workmode <<= id - AXP22X_DCDC1;
> +		break;
> +
>  	default:
>  		/* should not happen */
>  		WARN_ON(1);
> @@ -265,6 +357,10 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
>  		regulators = axp20x_regulators;
>  		nregulators = AXP20X_REG_ID_MAX;
>  		break;
> +	case AXP221_ID:
> +		regulators = axp22x_regulators;
> +		nregulators = AXP22X_REG_ID_MAX;
> +		break;
>  	default:
>  		dev_err(&pdev->dev, "Unsupported AXP variant: %ld\n",
>  			axp20x->variant);

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH RESEND v6 5/6] mfd: axp20x: Add AXP22x regulator information to DT bindings
@ 2015-05-13 15:30     ` Lee Jones
  0 siblings, 0 replies; 54+ messages in thread
From: Lee Jones @ 2015-05-13 15:30 UTC (permalink / raw)
  To: Chen-Yu Tsai
  Cc: Samuel Ortiz, Mark Brown, Liam Girdwood, Rob Herring, Pawel Moll,
	Mark Rutland, Ian Campbell, Kumar Gala, Maxime Ripard,
	Carlo Caione, linux-arm-kernel, devicetree, linux-kernel,
	linux-sunxi

On Fri, 10 Apr 2015, Chen-Yu Tsai wrote:

> Add the list of regulators for AXP22x to the DT bindings.
> This includes the names and supply names.
> 
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> ---
>  Documentation/devicetree/bindings/mfd/axp20x.txt | 25 ++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)

Applied, thanks.

> diff --git a/Documentation/devicetree/bindings/mfd/axp20x.txt b/Documentation/devicetree/bindings/mfd/axp20x.txt
> index 3914a3f91ff6..753f14f46e85 100644
> --- a/Documentation/devicetree/bindings/mfd/axp20x.txt
> +++ b/Documentation/devicetree/bindings/mfd/axp20x.txt
> @@ -49,6 +49,31 @@ LDO3		: LDO		: ldo3in-supply
>  LDO4		: LDO		: ldo24in-supply	: shared supply
>  LDO5		: LDO		: ldo5in-supply
>  
> +AXP221 regulators, type, and corresponding input supply names:
> +
> +Regulator	  Type		  Supply Name		  Notes
> +---------	  ----		  -----------		  -----
> +DCDC1		: DC-DC buck	: vin1-supply
> +DCDC2		: DC-DC buck	: vin2-supply
> +DCDC3		: DC-DC	buck	: vin3-supply
> +DCDC4		: DC-DC	buck	: vin4-supply
> +DCDC5		: DC-DC	buck	: vin5-supply
> +DC1SW		: On/Off Switch	: dcdc1-supply		: DCDC1 secondary output
> +DC5LDO		: LDO		: dcdc5-supply		: input from DCDC5
> +ALDO1		: LDO		: aldoin-supply		: shared supply
> +ALDO2		: LDO		: aldoin-supply		: shared supply
> +ALDO3		: LDO		: aldoin-supply		: shared supply
> +DLDO1		: LDO		: dldoin-supply		: shared supply
> +DLDO2		: LDO		: dldoin-supply		: shared supply
> +DLDO3		: LDO		: dldoin-supply		: shared supply
> +DLDO4		: LDO		: dldoin-supply		: shared supply
> +ELDO1		: LDO		: eldoin-supply		: shared supply
> +ELDO2		: LDO		: eldoin-supply		: shared supply
> +ELDO3		: LDO		: eldoin-supply		: shared supply
> +LDO_IO0		: LDO		: ips-supply		: GPIO 0
> +LDO_IO1		: LDO		: ips-supply		: GPIO 1
> +RTC_LDO		: LDO		: ips-supply		: always on
> +
>  Example:
>  
>  axp209: pmic@34 {

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH RESEND v6 5/6] mfd: axp20x: Add AXP22x regulator information to DT bindings
@ 2015-05-13 15:30     ` Lee Jones
  0 siblings, 0 replies; 54+ messages in thread
From: Lee Jones @ 2015-05-13 15:30 UTC (permalink / raw)
  To: Chen-Yu Tsai
  Cc: Samuel Ortiz, Mark Brown, Liam Girdwood, Rob Herring, Pawel Moll,
	Mark Rutland, Ian Campbell, Kumar Gala, Maxime Ripard,
	Carlo Caione, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw

On Fri, 10 Apr 2015, Chen-Yu Tsai wrote:

> Add the list of regulators for AXP22x to the DT bindings.
> This includes the names and supply names.
> 
> Signed-off-by: Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>
> ---
>  Documentation/devicetree/bindings/mfd/axp20x.txt | 25 ++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)

Applied, thanks.

> diff --git a/Documentation/devicetree/bindings/mfd/axp20x.txt b/Documentation/devicetree/bindings/mfd/axp20x.txt
> index 3914a3f91ff6..753f14f46e85 100644
> --- a/Documentation/devicetree/bindings/mfd/axp20x.txt
> +++ b/Documentation/devicetree/bindings/mfd/axp20x.txt
> @@ -49,6 +49,31 @@ LDO3		: LDO		: ldo3in-supply
>  LDO4		: LDO		: ldo24in-supply	: shared supply
>  LDO5		: LDO		: ldo5in-supply
>  
> +AXP221 regulators, type, and corresponding input supply names:
> +
> +Regulator	  Type		  Supply Name		  Notes
> +---------	  ----		  -----------		  -----
> +DCDC1		: DC-DC buck	: vin1-supply
> +DCDC2		: DC-DC buck	: vin2-supply
> +DCDC3		: DC-DC	buck	: vin3-supply
> +DCDC4		: DC-DC	buck	: vin4-supply
> +DCDC5		: DC-DC	buck	: vin5-supply
> +DC1SW		: On/Off Switch	: dcdc1-supply		: DCDC1 secondary output
> +DC5LDO		: LDO		: dcdc5-supply		: input from DCDC5
> +ALDO1		: LDO		: aldoin-supply		: shared supply
> +ALDO2		: LDO		: aldoin-supply		: shared supply
> +ALDO3		: LDO		: aldoin-supply		: shared supply
> +DLDO1		: LDO		: dldoin-supply		: shared supply
> +DLDO2		: LDO		: dldoin-supply		: shared supply
> +DLDO3		: LDO		: dldoin-supply		: shared supply
> +DLDO4		: LDO		: dldoin-supply		: shared supply
> +ELDO1		: LDO		: eldoin-supply		: shared supply
> +ELDO2		: LDO		: eldoin-supply		: shared supply
> +ELDO3		: LDO		: eldoin-supply		: shared supply
> +LDO_IO0		: LDO		: ips-supply		: GPIO 0
> +LDO_IO1		: LDO		: ips-supply		: GPIO 1
> +RTC_LDO		: LDO		: ips-supply		: always on
> +
>  Example:
>  
>  axp209: pmic@34 {

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

-- 
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/d/optout.

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH RESEND v6 5/6] mfd: axp20x: Add AXP22x regulator information to DT bindings
@ 2015-05-13 15:30     ` Lee Jones
  0 siblings, 0 replies; 54+ messages in thread
From: Lee Jones @ 2015-05-13 15:30 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, 10 Apr 2015, Chen-Yu Tsai wrote:

> Add the list of regulators for AXP22x to the DT bindings.
> This includes the names and supply names.
> 
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> ---
>  Documentation/devicetree/bindings/mfd/axp20x.txt | 25 ++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)

Applied, thanks.

> diff --git a/Documentation/devicetree/bindings/mfd/axp20x.txt b/Documentation/devicetree/bindings/mfd/axp20x.txt
> index 3914a3f91ff6..753f14f46e85 100644
> --- a/Documentation/devicetree/bindings/mfd/axp20x.txt
> +++ b/Documentation/devicetree/bindings/mfd/axp20x.txt
> @@ -49,6 +49,31 @@ LDO3		: LDO		: ldo3in-supply
>  LDO4		: LDO		: ldo24in-supply	: shared supply
>  LDO5		: LDO		: ldo5in-supply
>  
> +AXP221 regulators, type, and corresponding input supply names:
> +
> +Regulator	  Type		  Supply Name		  Notes
> +---------	  ----		  -----------		  -----
> +DCDC1		: DC-DC buck	: vin1-supply
> +DCDC2		: DC-DC buck	: vin2-supply
> +DCDC3		: DC-DC	buck	: vin3-supply
> +DCDC4		: DC-DC	buck	: vin4-supply
> +DCDC5		: DC-DC	buck	: vin5-supply
> +DC1SW		: On/Off Switch	: dcdc1-supply		: DCDC1 secondary output
> +DC5LDO		: LDO		: dcdc5-supply		: input from DCDC5
> +ALDO1		: LDO		: aldoin-supply		: shared supply
> +ALDO2		: LDO		: aldoin-supply		: shared supply
> +ALDO3		: LDO		: aldoin-supply		: shared supply
> +DLDO1		: LDO		: dldoin-supply		: shared supply
> +DLDO2		: LDO		: dldoin-supply		: shared supply
> +DLDO3		: LDO		: dldoin-supply		: shared supply
> +DLDO4		: LDO		: dldoin-supply		: shared supply
> +ELDO1		: LDO		: eldoin-supply		: shared supply
> +ELDO2		: LDO		: eldoin-supply		: shared supply
> +ELDO3		: LDO		: eldoin-supply		: shared supply
> +LDO_IO0		: LDO		: ips-supply		: GPIO 0
> +LDO_IO1		: LDO		: ips-supply		: GPIO 1
> +RTC_LDO		: LDO		: ips-supply		: always on
> +
>  Example:
>  
>  axp209: pmic at 34 {

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH RESEND v6 6/6] mfd: axp20x: Enable AXP22X regulators
@ 2015-05-13 15:31     ` Lee Jones
  0 siblings, 0 replies; 54+ messages in thread
From: Lee Jones @ 2015-05-13 15:31 UTC (permalink / raw)
  To: Chen-Yu Tsai
  Cc: Samuel Ortiz, Mark Brown, Liam Girdwood, Rob Herring, Pawel Moll,
	Mark Rutland, Ian Campbell, Kumar Gala, Maxime Ripard,
	Carlo Caione, linux-arm-kernel, devicetree, linux-kernel,
	linux-sunxi

On Fri, 10 Apr 2015, Chen-Yu Tsai wrote:

> Now that the axp20x-regulators driver supports different variants of the
> AXP family, we can enable regulator support for AXP22X without the risk
> of incorrectly configuring regulators.
> 
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> Acked-by: Lee Jones <lee.jones@linaro.org>
> ---
>  drivers/mfd/axp20x.c | 2 ++
>  1 file changed, 2 insertions(+)

Applied, thanks.

> diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
> index cfbb7d7aead6..6df91556faf3 100644
> --- a/drivers/mfd/axp20x.c
> +++ b/drivers/mfd/axp20x.c
> @@ -370,6 +370,8 @@ static struct mfd_cell axp22x_cells[] = {
>  		.name			= "axp20x-pek",
>  		.num_resources		= ARRAY_SIZE(axp22x_pek_resources),
>  		.resources		= axp22x_pek_resources,
> +	}, {
> +		.name			= "axp20x-regulator",
>  	},
>  };
>  

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH RESEND v6 6/6] mfd: axp20x: Enable AXP22X regulators
@ 2015-05-13 15:31     ` Lee Jones
  0 siblings, 0 replies; 54+ messages in thread
From: Lee Jones @ 2015-05-13 15:31 UTC (permalink / raw)
  To: Chen-Yu Tsai
  Cc: Samuel Ortiz, Mark Brown, Liam Girdwood, Rob Herring, Pawel Moll,
	Mark Rutland, Ian Campbell, Kumar Gala, Maxime Ripard,
	Carlo Caione, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw

On Fri, 10 Apr 2015, Chen-Yu Tsai wrote:

> Now that the axp20x-regulators driver supports different variants of the
> AXP family, we can enable regulator support for AXP22X without the risk
> of incorrectly configuring regulators.
> 
> Signed-off-by: Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>
> Acked-by: Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> ---
>  drivers/mfd/axp20x.c | 2 ++
>  1 file changed, 2 insertions(+)

Applied, thanks.

> diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
> index cfbb7d7aead6..6df91556faf3 100644
> --- a/drivers/mfd/axp20x.c
> +++ b/drivers/mfd/axp20x.c
> @@ -370,6 +370,8 @@ static struct mfd_cell axp22x_cells[] = {
>  		.name			= "axp20x-pek",
>  		.num_resources		= ARRAY_SIZE(axp22x_pek_resources),
>  		.resources		= axp22x_pek_resources,
> +	}, {
> +		.name			= "axp20x-regulator",
>  	},
>  };
>  

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

-- 
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/d/optout.

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH RESEND v6 6/6] mfd: axp20x: Enable AXP22X regulators
@ 2015-05-13 15:31     ` Lee Jones
  0 siblings, 0 replies; 54+ messages in thread
From: Lee Jones @ 2015-05-13 15:31 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, 10 Apr 2015, Chen-Yu Tsai wrote:

> Now that the axp20x-regulators driver supports different variants of the
> AXP family, we can enable regulator support for AXP22X without the risk
> of incorrectly configuring regulators.
> 
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> Acked-by: Lee Jones <lee.jones@linaro.org>
> ---
>  drivers/mfd/axp20x.c | 2 ++
>  1 file changed, 2 insertions(+)

Applied, thanks.

> diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
> index cfbb7d7aead6..6df91556faf3 100644
> --- a/drivers/mfd/axp20x.c
> +++ b/drivers/mfd/axp20x.c
> @@ -370,6 +370,8 @@ static struct mfd_cell axp22x_cells[] = {
>  		.name			= "axp20x-pek",
>  		.num_resources		= ARRAY_SIZE(axp22x_pek_resources),
>  		.resources		= axp22x_pek_resources,
> +	}, {
> +		.name			= "axp20x-regulator",
>  	},
>  };
>  

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH RESEND v6 0/6] mfd: axp20x: add AXP221 PMIC support
@ 2015-05-13 15:41   ` Lee Jones
  0 siblings, 0 replies; 54+ messages in thread
From: Lee Jones @ 2015-05-13 15:41 UTC (permalink / raw)
  To: Chen-Yu Tsai
  Cc: Samuel Ortiz, Mark Brown, Liam Girdwood, Rob Herring, Pawel Moll,
	Mark Rutland, Ian Campbell, Kumar Gala, Maxime Ripard,
	Carlo Caione, linux-arm-kernel, devicetree, linux-kernel,
	linux-sunxi

Hi Mark,

Enjoy!

The following changes since commit 5ebe6afaf0057ac3eaeb98defd5456894b446d22:

  Linux 4.1-rc2 (2015-05-03 19:22:23 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git tags/ib-mfd-regulator-v4.2

for you to fetch changes up to 6d4fa89dcd85e2427da83319ce75e5df5febcc96:

  mfd: axp20x: Enable AXP22X regulators (2015-05-13 16:26:34 +0100)

----------------------------------------------------------------
Immutable branch between MFD and Regulator, due for v4.2

----------------------------------------------------------------
Boris BREZILLON (3):
      mfd: axp20x: Add AXP22x PMIC support
      regulator: axp20x: Prepare support for multiple AXP chip families
      regulator: axp20x: Add support for AXP22X regulators

Chen-Yu Tsai (3):
      mfd: axp20x: Update DT bindings with AXP22x compatibles
      mfd: axp20x: Add AXP22x regulator information to DT bindings
      mfd: axp20x: Enable AXP22X regulators

 Documentation/devicetree/bindings/mfd/axp20x.txt |  32 ++-
 drivers/mfd/axp20x.c                             | 100 ++++++++++
 drivers/regulator/axp20x-regulator.c             | 239 ++++++++++++++++++-----
 include/linux/mfd/axp20x.h                       |  86 ++++++++
 4 files changed, 405 insertions(+), 52 deletions(-)

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH RESEND v6 0/6] mfd: axp20x: add AXP221 PMIC support
@ 2015-05-13 15:41   ` Lee Jones
  0 siblings, 0 replies; 54+ messages in thread
From: Lee Jones @ 2015-05-13 15:41 UTC (permalink / raw)
  To: Chen-Yu Tsai
  Cc: Samuel Ortiz, Mark Brown, Liam Girdwood, Rob Herring, Pawel Moll,
	Mark Rutland, Ian Campbell, Kumar Gala, Maxime Ripard,
	Carlo Caione, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw

Hi Mark,

Enjoy!

The following changes since commit 5ebe6afaf0057ac3eaeb98defd5456894b446d22:

  Linux 4.1-rc2 (2015-05-03 19:22:23 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git tags/ib-mfd-regulator-v4.2

for you to fetch changes up to 6d4fa89dcd85e2427da83319ce75e5df5febcc96:

  mfd: axp20x: Enable AXP22X regulators (2015-05-13 16:26:34 +0100)

----------------------------------------------------------------
Immutable branch between MFD and Regulator, due for v4.2

----------------------------------------------------------------
Boris BREZILLON (3):
      mfd: axp20x: Add AXP22x PMIC support
      regulator: axp20x: Prepare support for multiple AXP chip families
      regulator: axp20x: Add support for AXP22X regulators

Chen-Yu Tsai (3):
      mfd: axp20x: Update DT bindings with AXP22x compatibles
      mfd: axp20x: Add AXP22x regulator information to DT bindings
      mfd: axp20x: Enable AXP22X regulators

 Documentation/devicetree/bindings/mfd/axp20x.txt |  32 ++-
 drivers/mfd/axp20x.c                             | 100 ++++++++++
 drivers/regulator/axp20x-regulator.c             | 239 ++++++++++++++++++-----
 include/linux/mfd/axp20x.h                       |  86 ++++++++
 4 files changed, 405 insertions(+), 52 deletions(-)

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

-- 
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/d/optout.

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH RESEND v6 0/6] mfd: axp20x: add AXP221 PMIC support
@ 2015-05-13 15:41   ` Lee Jones
  0 siblings, 0 replies; 54+ messages in thread
From: Lee Jones @ 2015-05-13 15:41 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Mark,

Enjoy!

The following changes since commit 5ebe6afaf0057ac3eaeb98defd5456894b446d22:

  Linux 4.1-rc2 (2015-05-03 19:22:23 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git tags/ib-mfd-regulator-v4.2

for you to fetch changes up to 6d4fa89dcd85e2427da83319ce75e5df5febcc96:

  mfd: axp20x: Enable AXP22X regulators (2015-05-13 16:26:34 +0100)

----------------------------------------------------------------
Immutable branch between MFD and Regulator, due for v4.2

----------------------------------------------------------------
Boris BREZILLON (3):
      mfd: axp20x: Add AXP22x PMIC support
      regulator: axp20x: Prepare support for multiple AXP chip families
      regulator: axp20x: Add support for AXP22X regulators

Chen-Yu Tsai (3):
      mfd: axp20x: Update DT bindings with AXP22x compatibles
      mfd: axp20x: Add AXP22x regulator information to DT bindings
      mfd: axp20x: Enable AXP22X regulators

 Documentation/devicetree/bindings/mfd/axp20x.txt |  32 ++-
 drivers/mfd/axp20x.c                             | 100 ++++++++++
 drivers/regulator/axp20x-regulator.c             | 239 ++++++++++++++++++-----
 include/linux/mfd/axp20x.h                       |  86 ++++++++
 4 files changed, 405 insertions(+), 52 deletions(-)

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 54+ messages in thread

end of thread, other threads:[~2015-05-13 15:41 UTC | newest]

Thread overview: 54+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-10  4:09 [PATCH RESEND v6 0/6] mfd: axp20x: add AXP221 PMIC support Chen-Yu Tsai
2015-04-10  4:09 ` Chen-Yu Tsai
2015-04-10  4:09 ` Chen-Yu Tsai
2015-04-10  4:09 ` [PATCH RESEND v6 1/6] mfd: axp20x: add AXP22x " Chen-Yu Tsai
2015-04-10  4:09   ` Chen-Yu Tsai
2015-04-10  4:09   ` Chen-Yu Tsai
2015-04-10  9:25   ` Lee Jones
2015-04-10  9:25     ` Lee Jones
2015-04-10  9:25     ` Lee Jones
2015-05-13 15:30   ` Lee Jones
2015-05-13 15:30     ` Lee Jones
2015-05-13 15:30     ` Lee Jones
2015-04-10  4:09 ` [PATCH RESEND v6 2/6] mfd: axp20x: update DT bindings with AXP22x compatibles Chen-Yu Tsai
2015-04-10  4:09   ` Chen-Yu Tsai
2015-04-10  4:09   ` Chen-Yu Tsai
2015-05-13 15:30   ` Lee Jones
2015-05-13 15:30     ` Lee Jones
2015-05-13 15:30     ` Lee Jones
2015-04-10  4:09 ` [PATCH RESEND v6 3/6] regulator: axp20x: prepare support for multiple AXP chip families Chen-Yu Tsai
2015-04-10  4:09   ` Chen-Yu Tsai
2015-04-10  4:09   ` Chen-Yu Tsai
2015-05-13 15:30   ` Lee Jones
2015-05-13 15:30     ` Lee Jones
2015-05-13 15:30     ` Lee Jones
2015-04-10  4:09 ` [PATCH RESEND v6 4/6] regulator: axp20x: add support for AXP22X regulators Chen-Yu Tsai
2015-04-10  4:09   ` Chen-Yu Tsai
2015-04-10  4:09   ` Chen-Yu Tsai
2015-04-10 15:48   ` Mark Brown
2015-04-10 15:48     ` Mark Brown
2015-04-10 15:48     ` Mark Brown
2015-04-14  6:45     ` Lee Jones
2015-04-14  6:45       ` Lee Jones
2015-04-14  6:45       ` Lee Jones
2015-04-29 12:36     ` Lee Jones
2015-04-29 12:36       ` Lee Jones
2015-04-29 12:36       ` Lee Jones
2015-05-13 15:30   ` Lee Jones
2015-05-13 15:30     ` Lee Jones
2015-05-13 15:30     ` Lee Jones
2015-04-10  4:09 ` [PATCH RESEND v6 5/6] mfd: axp20x: Add AXP22x regulator information to DT bindings Chen-Yu Tsai
2015-04-10  4:09   ` Chen-Yu Tsai
2015-04-10  4:09   ` Chen-Yu Tsai
2015-05-13 15:30   ` Lee Jones
2015-05-13 15:30     ` Lee Jones
2015-05-13 15:30     ` Lee Jones
2015-04-10  4:09 ` [PATCH RESEND v6 6/6] mfd: axp20x: Enable AXP22X regulators Chen-Yu Tsai
2015-04-10  4:09   ` Chen-Yu Tsai
2015-04-10  4:09   ` Chen-Yu Tsai
2015-05-13 15:31   ` Lee Jones
2015-05-13 15:31     ` Lee Jones
2015-05-13 15:31     ` Lee Jones
2015-05-13 15:41 ` [PATCH RESEND v6 0/6] mfd: axp20x: add AXP221 PMIC support Lee Jones
2015-05-13 15:41   ` Lee Jones
2015-05-13 15:41   ` Lee Jones

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.