From: lee.jones@linaro.org (Lee Jones)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4 1/7] mfd: axp20x: add AXP221 PMIC support
Date: Wed, 18 Jun 2014 09:36:05 +0100 [thread overview]
Message-ID: <20140618083605.GQ21030@lee--X1> (raw)
In-Reply-To: <1402990723-28138-2-git-send-email-boris.brezillon@free-electrons.com>
On Tue, 17 Jun 2014, Boris BREZILLON wrote:
> Add support for the AXP221 PMIC device to the existing AXP20x driver.
>
> The AXP221 defines a new set of registers, power supplies and regulators,
> but most of the API is similar to the AXP20x ones.
> The AXP20x irq chip definition is reused, though some interrupts are not
> available in the AXP221.
>
> Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
> ---
> drivers/mfd/axp20x.c | 64 ++++++++++++++++++++++++++++++++++++++++++----
> include/linux/mfd/axp20x.h | 56 ++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 115 insertions(+), 5 deletions(-)
Looks good to me now.
Acked-by: Lee Jones <lee.jones@linaro.org>
Can this go in independently to the other patches in the set?
> diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
> index dee6539..ad4c177 100644
> --- a/drivers/mfd/axp20x.c
> +++ b/drivers/mfd/axp20x.c
> @@ -33,6 +33,11 @@ static const struct regmap_range axp20x_writeable_ranges[] = {
> regmap_reg_range(AXP20X_DCDC_MODE, AXP20X_FG_RES),
> };
>
> +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 axp20x_volatile_ranges[] = {
> regmap_reg_range(AXP20X_IRQ1_EN, AXP20X_IRQ5_STATE),
> };
> @@ -42,6 +47,11 @@ static const struct regmap_access_table axp20x_writeable_table = {
> .n_yes_ranges = ARRAY_SIZE(axp20x_writeable_ranges),
> };
>
> +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 axp20x_volatile_table = {
> .yes_ranges = axp20x_volatile_ranges,
> .n_yes_ranges = ARRAY_SIZE(axp20x_volatile_ranges),
> @@ -70,6 +80,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 = &axp20x_volatile_table,
> + .max_register = AXP22X_BATLOW_THRES1,
> + .cache_type = REGCACHE_RBTREE,
> +};
> +
> #define AXP20X_IRQ(_irq, _off, _mask) \
> [AXP20X_IRQ_##_irq] = { .reg_offset = (_off), .mask = BIT(_mask) }
>
> @@ -116,6 +135,7 @@ static const struct regmap_irq axp20x_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);
> @@ -149,6 +169,21 @@ static const char * const axp20x_supplies[] = {
> "ldo5in",
> };
>
> +static const char *axp22x_supplies[] = {
> + "vbus",
> + "acin",
> + "vin1",
> + "vin2",
> + "vin3",
> + "vin4",
> + "vin5",
> + "aldoin",
> + "dldoin",
> + "eldoin",
> + "ldoioin",
> + "rtcldoin",
> +};
> +
> static struct mfd_cell axp20x_cells[] = {
> {
> .name = "axp20x-pek",
> @@ -161,6 +196,14 @@ static struct mfd_cell axp20x_cells[] = {
> },
> };
>
> +static struct mfd_cell axp22x_cells[] = {
> + {
> + .name = "axp20x-regulator",
> + .parent_supplies = axp22x_supplies,
> + .num_parent_supplies = ARRAY_SIZE(axp22x_supplies),
> + },
> +};
> +
> static struct axp20x_dev *axp20x_pm_power_off;
> static void axp20x_power_off(void)
> {
> @@ -171,8 +214,11 @@ static void axp20x_power_off(void)
> static int axp20x_i2c_probe(struct i2c_client *i2c,
> const struct i2c_device_id *id)
> {
> - struct axp20x_dev *axp20x;
> + const struct regmap_config *regmap_cfg;
> const struct of_device_id *of_id;
> + struct axp20x_dev *axp20x;
> + struct mfd_cell *cells;
> + int ncells;
> int ret;
>
> axp20x = devm_kzalloc(&i2c->dev, sizeof(*axp20x), GFP_KERNEL);
> @@ -190,7 +236,17 @@ static int axp20x_i2c_probe(struct i2c_client *i2c,
> axp20x->dev = &i2c->dev;
> dev_set_drvdata(axp20x->dev, axp20x);
>
> - axp20x->regmap = devm_regmap_init_i2c(i2c, &axp20x_regmap_config);
> + if (axp20x->variant == AXP221_ID) {
> + regmap_cfg = &axp22x_regmap_config;
> + cells = axp22x_cells;
> + ncells = ARRAY_SIZE(axp22x_cells);
> + } else {
> + regmap_cfg = &axp20x_regmap_config;
> + cells = axp20x_cells;
> + ncells = ARRAY_SIZE(axp20x_cells);
> + }
> +
> + axp20x->regmap = devm_regmap_init_i2c(i2c, regmap_cfg);
> if (IS_ERR(axp20x->regmap)) {
> ret = PTR_ERR(axp20x->regmap);
> dev_err(&i2c->dev, "regmap init failed: %d\n", ret);
> @@ -206,9 +262,7 @@ static int axp20x_i2c_probe(struct i2c_client *i2c,
> return ret;
> }
>
> - ret = mfd_add_devices(axp20x->dev, -1, axp20x_cells,
> - ARRAY_SIZE(axp20x_cells), NULL, 0, NULL);
> -
> + ret = mfd_add_devices(axp20x->dev, -1, cells, ncells, NULL, 0, NULL);
> if (ret) {
> dev_err(&i2c->dev, "failed to add MFD devices: %d\n", ret);
> regmap_del_irq_chip(i2c->irq, axp20x->regmap_irqc);
> diff --git a/include/linux/mfd/axp20x.h b/include/linux/mfd/axp20x.h
> index d0e31a2..8a8ce02 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,
> };
>
> #define AXP20X_DATACACHE(m) (0x04 + (m))
> @@ -43,6 +44,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
> @@ -96,6 +119,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
> @@ -104,6 +130,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
> @@ -116,6 +147,8 @@ enum {
> #define AXP20X_CC_CTRL 0xb8
> #define AXP20X_FG_RES 0xb9
>
> +#define AXP22X_BATLOW_THRES1 0xe6
> +
> /* Regulators IDs */
> enum {
> AXP20X_LDO1 = 0,
> @@ -128,6 +161,29 @@ enum {
> AXP20X_REG_ID_MAX,
> };
>
> +enum {
> + AXP22X_DCDC1 = 0,
> + AXP22X_DCDC2,
> + AXP22X_DCDC3,
> + AXP22X_DCDC4,
> + AXP22X_DCDC5,
> + 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,
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
WARNING: multiple messages have this Message-ID (diff)
From: Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
To: Boris BREZILLON
<boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
Cc: Samuel Ortiz <sameo-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
Liam Girdwood <lgirdwood-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Maxime Ripard
<maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>,
Carlo Caione <carlo-KA+7E9HrN00dnm+yROfE0A@public.gmane.org>,
Shuge <shuge-0TFLnhJekD6UEPyfVivIlAC/G2K4zDHf@public.gmane.org>,
kevin-0TFLnhJekD6UEPyfVivIlAC/G2K4zDHf@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
dev-3kdeTeqwOZ9EV1b7eY7vFQ@public.gmane.org
Subject: Re: [PATCH v4 1/7] mfd: axp20x: add AXP221 PMIC support
Date: Wed, 18 Jun 2014 09:36:05 +0100 [thread overview]
Message-ID: <20140618083605.GQ21030@lee--X1> (raw)
In-Reply-To: <1402990723-28138-2-git-send-email-boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
On Tue, 17 Jun 2014, Boris BREZILLON wrote:
> Add support for the AXP221 PMIC device to the existing AXP20x driver.
>
> The AXP221 defines a new set of registers, power supplies and regulators,
> but most of the API is similar to the AXP20x ones.
> The AXP20x irq chip definition is reused, though some interrupts are not
> available in the AXP221.
>
> Signed-off-by: Boris BREZILLON <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> ---
> drivers/mfd/axp20x.c | 64 ++++++++++++++++++++++++++++++++++++++++++----
> include/linux/mfd/axp20x.h | 56 ++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 115 insertions(+), 5 deletions(-)
Looks good to me now.
Acked-by: Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Can this go in independently to the other patches in the set?
> diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
> index dee6539..ad4c177 100644
> --- a/drivers/mfd/axp20x.c
> +++ b/drivers/mfd/axp20x.c
> @@ -33,6 +33,11 @@ static const struct regmap_range axp20x_writeable_ranges[] = {
> regmap_reg_range(AXP20X_DCDC_MODE, AXP20X_FG_RES),
> };
>
> +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 axp20x_volatile_ranges[] = {
> regmap_reg_range(AXP20X_IRQ1_EN, AXP20X_IRQ5_STATE),
> };
> @@ -42,6 +47,11 @@ static const struct regmap_access_table axp20x_writeable_table = {
> .n_yes_ranges = ARRAY_SIZE(axp20x_writeable_ranges),
> };
>
> +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 axp20x_volatile_table = {
> .yes_ranges = axp20x_volatile_ranges,
> .n_yes_ranges = ARRAY_SIZE(axp20x_volatile_ranges),
> @@ -70,6 +80,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 = &axp20x_volatile_table,
> + .max_register = AXP22X_BATLOW_THRES1,
> + .cache_type = REGCACHE_RBTREE,
> +};
> +
> #define AXP20X_IRQ(_irq, _off, _mask) \
> [AXP20X_IRQ_##_irq] = { .reg_offset = (_off), .mask = BIT(_mask) }
>
> @@ -116,6 +135,7 @@ static const struct regmap_irq axp20x_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);
> @@ -149,6 +169,21 @@ static const char * const axp20x_supplies[] = {
> "ldo5in",
> };
>
> +static const char *axp22x_supplies[] = {
> + "vbus",
> + "acin",
> + "vin1",
> + "vin2",
> + "vin3",
> + "vin4",
> + "vin5",
> + "aldoin",
> + "dldoin",
> + "eldoin",
> + "ldoioin",
> + "rtcldoin",
> +};
> +
> static struct mfd_cell axp20x_cells[] = {
> {
> .name = "axp20x-pek",
> @@ -161,6 +196,14 @@ static struct mfd_cell axp20x_cells[] = {
> },
> };
>
> +static struct mfd_cell axp22x_cells[] = {
> + {
> + .name = "axp20x-regulator",
> + .parent_supplies = axp22x_supplies,
> + .num_parent_supplies = ARRAY_SIZE(axp22x_supplies),
> + },
> +};
> +
> static struct axp20x_dev *axp20x_pm_power_off;
> static void axp20x_power_off(void)
> {
> @@ -171,8 +214,11 @@ static void axp20x_power_off(void)
> static int axp20x_i2c_probe(struct i2c_client *i2c,
> const struct i2c_device_id *id)
> {
> - struct axp20x_dev *axp20x;
> + const struct regmap_config *regmap_cfg;
> const struct of_device_id *of_id;
> + struct axp20x_dev *axp20x;
> + struct mfd_cell *cells;
> + int ncells;
> int ret;
>
> axp20x = devm_kzalloc(&i2c->dev, sizeof(*axp20x), GFP_KERNEL);
> @@ -190,7 +236,17 @@ static int axp20x_i2c_probe(struct i2c_client *i2c,
> axp20x->dev = &i2c->dev;
> dev_set_drvdata(axp20x->dev, axp20x);
>
> - axp20x->regmap = devm_regmap_init_i2c(i2c, &axp20x_regmap_config);
> + if (axp20x->variant == AXP221_ID) {
> + regmap_cfg = &axp22x_regmap_config;
> + cells = axp22x_cells;
> + ncells = ARRAY_SIZE(axp22x_cells);
> + } else {
> + regmap_cfg = &axp20x_regmap_config;
> + cells = axp20x_cells;
> + ncells = ARRAY_SIZE(axp20x_cells);
> + }
> +
> + axp20x->regmap = devm_regmap_init_i2c(i2c, regmap_cfg);
> if (IS_ERR(axp20x->regmap)) {
> ret = PTR_ERR(axp20x->regmap);
> dev_err(&i2c->dev, "regmap init failed: %d\n", ret);
> @@ -206,9 +262,7 @@ static int axp20x_i2c_probe(struct i2c_client *i2c,
> return ret;
> }
>
> - ret = mfd_add_devices(axp20x->dev, -1, axp20x_cells,
> - ARRAY_SIZE(axp20x_cells), NULL, 0, NULL);
> -
> + ret = mfd_add_devices(axp20x->dev, -1, cells, ncells, NULL, 0, NULL);
> if (ret) {
> dev_err(&i2c->dev, "failed to add MFD devices: %d\n", ret);
> regmap_del_irq_chip(i2c->irq, axp20x->regmap_irqc);
> diff --git a/include/linux/mfd/axp20x.h b/include/linux/mfd/axp20x.h
> index d0e31a2..8a8ce02 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,
> };
>
> #define AXP20X_DATACACHE(m) (0x04 + (m))
> @@ -43,6 +44,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
> @@ -96,6 +119,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
> @@ -104,6 +130,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
> @@ -116,6 +147,8 @@ enum {
> #define AXP20X_CC_CTRL 0xb8
> #define AXP20X_FG_RES 0xb9
>
> +#define AXP22X_BATLOW_THRES1 0xe6
> +
> /* Regulators IDs */
> enum {
> AXP20X_LDO1 = 0,
> @@ -128,6 +161,29 @@ enum {
> AXP20X_REG_ID_MAX,
> };
>
> +enum {
> + AXP22X_DCDC1 = 0,
> + AXP22X_DCDC2,
> + AXP22X_DCDC3,
> + AXP22X_DCDC4,
> + AXP22X_DCDC5,
> + 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,
--
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.
WARNING: multiple messages have this Message-ID (diff)
From: Lee Jones <lee.jones@linaro.org>
To: Boris BREZILLON <boris.brezillon@free-electrons.com>
Cc: Samuel Ortiz <sameo@linux.intel.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
Maxime Ripard <maxime.ripard@free-electrons.com>,
Carlo Caione <carlo@caione.org>, Shuge <shuge@allwinnertech.com>,
kevin@allwinnertech.com, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org,
linux-doc@vger.kernel.org, dev@linux-sunxi.org
Subject: Re: [PATCH v4 1/7] mfd: axp20x: add AXP221 PMIC support
Date: Wed, 18 Jun 2014 09:36:05 +0100 [thread overview]
Message-ID: <20140618083605.GQ21030@lee--X1> (raw)
In-Reply-To: <1402990723-28138-2-git-send-email-boris.brezillon@free-electrons.com>
On Tue, 17 Jun 2014, Boris BREZILLON wrote:
> Add support for the AXP221 PMIC device to the existing AXP20x driver.
>
> The AXP221 defines a new set of registers, power supplies and regulators,
> but most of the API is similar to the AXP20x ones.
> The AXP20x irq chip definition is reused, though some interrupts are not
> available in the AXP221.
>
> Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
> ---
> drivers/mfd/axp20x.c | 64 ++++++++++++++++++++++++++++++++++++++++++----
> include/linux/mfd/axp20x.h | 56 ++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 115 insertions(+), 5 deletions(-)
Looks good to me now.
Acked-by: Lee Jones <lee.jones@linaro.org>
Can this go in independently to the other patches in the set?
> diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
> index dee6539..ad4c177 100644
> --- a/drivers/mfd/axp20x.c
> +++ b/drivers/mfd/axp20x.c
> @@ -33,6 +33,11 @@ static const struct regmap_range axp20x_writeable_ranges[] = {
> regmap_reg_range(AXP20X_DCDC_MODE, AXP20X_FG_RES),
> };
>
> +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 axp20x_volatile_ranges[] = {
> regmap_reg_range(AXP20X_IRQ1_EN, AXP20X_IRQ5_STATE),
> };
> @@ -42,6 +47,11 @@ static const struct regmap_access_table axp20x_writeable_table = {
> .n_yes_ranges = ARRAY_SIZE(axp20x_writeable_ranges),
> };
>
> +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 axp20x_volatile_table = {
> .yes_ranges = axp20x_volatile_ranges,
> .n_yes_ranges = ARRAY_SIZE(axp20x_volatile_ranges),
> @@ -70,6 +80,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 = &axp20x_volatile_table,
> + .max_register = AXP22X_BATLOW_THRES1,
> + .cache_type = REGCACHE_RBTREE,
> +};
> +
> #define AXP20X_IRQ(_irq, _off, _mask) \
> [AXP20X_IRQ_##_irq] = { .reg_offset = (_off), .mask = BIT(_mask) }
>
> @@ -116,6 +135,7 @@ static const struct regmap_irq axp20x_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);
> @@ -149,6 +169,21 @@ static const char * const axp20x_supplies[] = {
> "ldo5in",
> };
>
> +static const char *axp22x_supplies[] = {
> + "vbus",
> + "acin",
> + "vin1",
> + "vin2",
> + "vin3",
> + "vin4",
> + "vin5",
> + "aldoin",
> + "dldoin",
> + "eldoin",
> + "ldoioin",
> + "rtcldoin",
> +};
> +
> static struct mfd_cell axp20x_cells[] = {
> {
> .name = "axp20x-pek",
> @@ -161,6 +196,14 @@ static struct mfd_cell axp20x_cells[] = {
> },
> };
>
> +static struct mfd_cell axp22x_cells[] = {
> + {
> + .name = "axp20x-regulator",
> + .parent_supplies = axp22x_supplies,
> + .num_parent_supplies = ARRAY_SIZE(axp22x_supplies),
> + },
> +};
> +
> static struct axp20x_dev *axp20x_pm_power_off;
> static void axp20x_power_off(void)
> {
> @@ -171,8 +214,11 @@ static void axp20x_power_off(void)
> static int axp20x_i2c_probe(struct i2c_client *i2c,
> const struct i2c_device_id *id)
> {
> - struct axp20x_dev *axp20x;
> + const struct regmap_config *regmap_cfg;
> const struct of_device_id *of_id;
> + struct axp20x_dev *axp20x;
> + struct mfd_cell *cells;
> + int ncells;
> int ret;
>
> axp20x = devm_kzalloc(&i2c->dev, sizeof(*axp20x), GFP_KERNEL);
> @@ -190,7 +236,17 @@ static int axp20x_i2c_probe(struct i2c_client *i2c,
> axp20x->dev = &i2c->dev;
> dev_set_drvdata(axp20x->dev, axp20x);
>
> - axp20x->regmap = devm_regmap_init_i2c(i2c, &axp20x_regmap_config);
> + if (axp20x->variant == AXP221_ID) {
> + regmap_cfg = &axp22x_regmap_config;
> + cells = axp22x_cells;
> + ncells = ARRAY_SIZE(axp22x_cells);
> + } else {
> + regmap_cfg = &axp20x_regmap_config;
> + cells = axp20x_cells;
> + ncells = ARRAY_SIZE(axp20x_cells);
> + }
> +
> + axp20x->regmap = devm_regmap_init_i2c(i2c, regmap_cfg);
> if (IS_ERR(axp20x->regmap)) {
> ret = PTR_ERR(axp20x->regmap);
> dev_err(&i2c->dev, "regmap init failed: %d\n", ret);
> @@ -206,9 +262,7 @@ static int axp20x_i2c_probe(struct i2c_client *i2c,
> return ret;
> }
>
> - ret = mfd_add_devices(axp20x->dev, -1, axp20x_cells,
> - ARRAY_SIZE(axp20x_cells), NULL, 0, NULL);
> -
> + ret = mfd_add_devices(axp20x->dev, -1, cells, ncells, NULL, 0, NULL);
> if (ret) {
> dev_err(&i2c->dev, "failed to add MFD devices: %d\n", ret);
> regmap_del_irq_chip(i2c->irq, axp20x->regmap_irqc);
> diff --git a/include/linux/mfd/axp20x.h b/include/linux/mfd/axp20x.h
> index d0e31a2..8a8ce02 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,
> };
>
> #define AXP20X_DATACACHE(m) (0x04 + (m))
> @@ -43,6 +44,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
> @@ -96,6 +119,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
> @@ -104,6 +130,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
> @@ -116,6 +147,8 @@ enum {
> #define AXP20X_CC_CTRL 0xb8
> #define AXP20X_FG_RES 0xb9
>
> +#define AXP22X_BATLOW_THRES1 0xe6
> +
> /* Regulators IDs */
> enum {
> AXP20X_LDO1 = 0,
> @@ -128,6 +161,29 @@ enum {
> AXP20X_REG_ID_MAX,
> };
>
> +enum {
> + AXP22X_DCDC1 = 0,
> + AXP22X_DCDC2,
> + AXP22X_DCDC3,
> + AXP22X_DCDC4,
> + AXP22X_DCDC5,
> + 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,
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
next prev parent reply other threads:[~2014-06-18 8:36 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-17 7:38 [PATCH v4 0/7] mfd: axp20x: add AXP221 PMIC support Boris BREZILLON
2014-06-17 7:38 ` Boris BREZILLON
2014-06-17 7:38 ` Boris BREZILLON
2014-06-17 7:38 ` [PATCH v4 1/7] " Boris BREZILLON
2014-06-17 7:38 ` Boris BREZILLON
2014-06-17 7:38 ` Boris BREZILLON
2014-06-18 8:36 ` Lee Jones [this message]
2014-06-18 8:36 ` Lee Jones
2014-06-18 8:36 ` Lee Jones
2014-06-18 8:46 ` Boris BREZILLON
2014-06-18 8:46 ` Boris BREZILLON
2014-06-18 8:46 ` Boris BREZILLON
2014-06-18 9:28 ` Lee Jones
2014-06-18 9:28 ` Lee Jones
2014-06-18 9:28 ` Lee Jones
2014-06-17 7:38 ` [PATCH v4 2/7] regulator: axp20x: prepare support for multiple AXP chip families Boris BREZILLON
2014-06-17 7:38 ` Boris BREZILLON
2014-06-17 7:38 ` Boris BREZILLON
2014-06-17 7:38 ` [PATCH v4 3/7] regulator: axp20x: add support for AXP221 regulators Boris BREZILLON
2014-06-17 7:38 ` Boris BREZILLON
2014-06-17 7:38 ` Boris BREZILLON
2014-06-17 7:38 ` [PATCH v4 4/7] regulator: axp20x: reset probe data before each probe Boris BREZILLON
2014-06-17 7:38 ` Boris BREZILLON
2014-06-17 7:38 ` Boris BREZILLON
2014-06-17 20:44 ` Maxime Ripard
2014-06-17 20:44 ` Maxime Ripard
2014-06-17 20:44 ` Maxime Ripard
2014-06-18 7:11 ` Boris BREZILLON
2014-06-18 7:11 ` Boris BREZILLON
2014-06-18 8:32 ` [linux-sunxi] " Hans de Goede
2014-06-18 8:32 ` Hans de Goede
2014-06-18 8:32 ` Hans de Goede
2014-06-18 12:44 ` Maxime Ripard
2014-06-18 12:44 ` Maxime Ripard
2014-06-18 12:44 ` Maxime Ripard
2014-06-17 7:38 ` [PATCH v4 5/7] regulator: add support for regulator set registration Boris BREZILLON
2014-06-17 7:38 ` Boris BREZILLON
2014-06-17 7:38 ` Boris BREZILLON
2014-06-17 7:38 ` [PATCH v4 6/7] regulator: axp20x: make use of devm_regulator_set_register Boris BREZILLON
2014-06-17 7:38 ` Boris BREZILLON
2014-06-17 7:38 ` Boris BREZILLON
2014-06-17 20:46 ` Maxime Ripard
2014-06-17 20:46 ` Maxime Ripard
2014-06-17 20:46 ` Maxime Ripard
2014-06-18 7:12 ` Boris BREZILLON
2014-06-18 7:12 ` Boris BREZILLON
2014-06-17 7:38 ` [PATCH v4 7/7] mfd: AXP20x: add "x-powers, axp221" compatible string to DT bindings doc Boris BREZILLON
2014-06-17 7:38 ` [PATCH v4 7/7] mfd: AXP20x: add "x-powers,axp221" " Boris BREZILLON
2014-06-17 7:38 ` Boris BREZILLON
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140618083605.GQ21030@lee--X1 \
--to=lee.jones@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.