linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>
Cc: linus.walleij@linaro.org, brgl@bgdev.pl, robh+dt@kernel.org,
	krzysztof.kozlowski+dt@linaro.org, wens@csie.org,
	jic23@kernel.org, sre@kernel.org, broonie@kernel.org,
	gregkh@linuxfoundation.org, lgirdwood@gmail.com, lars@metafoo.de,
	rafael@kernel.org, linux-gpio@vger.kernel.org,
	devicetree@vger.kernel.org, linux-iio@vger.kernel.org,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 06/10] mfd: axp20x: Add support for AXP192
Date: Mon, 27 Jun 2022 12:54:07 +0100	[thread overview]
Message-ID: <YrmaX6/dbYKAFDQ4@google.com> (raw)
In-Reply-To: <20220603135714.12007-7-aidanmacdonald.0x0@gmail.com>

On Fri, 03 Jun 2022, Aidan MacDonald wrote:

> The AXP192 PMIC is similar to the AXP202/AXP209, but with different
> regulators, additional GPIOs, and a different IRQ register layout.
> 
> Signed-off-by: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>
> ---
>  drivers/mfd/axp20x-i2c.c   |   2 +
>  drivers/mfd/axp20x.c       | 150 +++++++++++++++++++++++++++++++++++++
>  include/linux/mfd/axp20x.h |  84 +++++++++++++++++++++
>  3 files changed, 236 insertions(+)
> 
> diff --git a/drivers/mfd/axp20x-i2c.c b/drivers/mfd/axp20x-i2c.c
> index 00ab48018d8d..9ada58fad77f 100644
> --- a/drivers/mfd/axp20x-i2c.c
> +++ b/drivers/mfd/axp20x-i2c.c
> @@ -62,6 +62,7 @@ static int axp20x_i2c_remove(struct i2c_client *i2c)
>  #ifdef CONFIG_OF
>  static const struct of_device_id axp20x_i2c_of_match[] = {
>  	{ .compatible = "x-powers,axp152", .data = (void *)AXP152_ID },
> +	{ .compatible = "x-powers,axp192", .data = (void *)AXP192_ID },
>  	{ .compatible = "x-powers,axp202", .data = (void *)AXP202_ID },
>  	{ .compatible = "x-powers,axp209", .data = (void *)AXP209_ID },
>  	{ .compatible = "x-powers,axp221", .data = (void *)AXP221_ID },
> @@ -75,6 +76,7 @@ MODULE_DEVICE_TABLE(of, axp20x_i2c_of_match);
>  
>  static const struct i2c_device_id axp20x_i2c_id[] = {
>  	{ "axp152", 0 },
> +	{ "axp192", 0 },
>  	{ "axp202", 0 },
>  	{ "axp209", 0 },
>  	{ "axp221", 0 },
> diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
> index 8161a5dc68e8..7f64e5c83fe2 100644
> --- a/drivers/mfd/axp20x.c
> +++ b/drivers/mfd/axp20x.c
> @@ -34,6 +34,7 @@
>  
>  static const char * const axp20x_model_names[] = {
>  	"AXP152",
> +	"AXP192",
>  	"AXP202",
>  	"AXP209",
>  	"AXP221",
> @@ -92,6 +93,35 @@ static const struct regmap_access_table axp20x_volatile_table = {
>  	.n_yes_ranges	= ARRAY_SIZE(axp20x_volatile_ranges),
>  };
>  
> +static const struct regmap_range axp192_writeable_ranges[] = {
> +	regmap_reg_range(AXP192_DATACACHE(0), AXP192_DATACACHE(5)),
> +	regmap_reg_range(AXP192_PWR_OUT_CTRL, AXP192_IRQ5_STATE),
> +	regmap_reg_range(AXP20X_DCDC_MODE, AXP192_N_RSTO_CTRL),
> +	regmap_reg_range(AXP20X_CC_CTRL, AXP20X_CC_CTRL),
> +};
> +
> +static const struct regmap_range axp192_volatile_ranges[] = {
> +	regmap_reg_range(AXP20X_PWR_INPUT_STATUS, AXP192_USB_OTG_STATUS),
> +	regmap_reg_range(AXP192_IRQ1_STATE, AXP192_IRQ4_STATE),
> +	regmap_reg_range(AXP192_IRQ5_STATE, AXP192_IRQ5_STATE),
> +	regmap_reg_range(AXP20X_ACIN_V_ADC_H, AXP20X_IPSOUT_V_HIGH_L),
> +	regmap_reg_range(AXP20X_TIMER_CTRL, AXP20X_TIMER_CTRL),
> +	regmap_reg_range(AXP192_GPIO2_0_STATE, AXP192_GPIO2_0_STATE),
> +	regmap_reg_range(AXP192_GPIO4_3_STATE, AXP192_GPIO4_3_STATE),
> +	regmap_reg_range(AXP192_N_RSTO_CTRL, AXP192_N_RSTO_CTRL),
> +	regmap_reg_range(AXP20X_CHRG_CC_31_24, AXP20X_CC_CTRL),
> +};
> +
> +static const struct regmap_access_table axp192_writeable_table = {
> +	.yes_ranges	= axp192_writeable_ranges,
> +	.n_yes_ranges	= ARRAY_SIZE(axp192_writeable_ranges),
> +};
> +
> +static const struct regmap_access_table axp192_volatile_table = {
> +	.yes_ranges	= axp192_volatile_ranges,
> +	.n_yes_ranges	= ARRAY_SIZE(axp192_volatile_ranges),
> +};
> +
>  /* AXP22x ranges are shared with the AXP809, as they cover the same range */
>  static const struct regmap_range axp22x_writeable_ranges[] = {
>  	regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_IRQ5_STATE),
> @@ -173,6 +203,25 @@ static const struct resource axp152_pek_resources[] = {
>  	DEFINE_RES_IRQ_NAMED(AXP152_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
>  };
>  
> +static const struct resource axp192_gpio_resources[] = {
> +	DEFINE_RES_IRQ_NAMED(AXP192_IRQ_GPIO0_INPUT, "GPIO0"),
> +	DEFINE_RES_IRQ_NAMED(AXP192_IRQ_GPIO1_INPUT, "GPIO1"),
> +	DEFINE_RES_IRQ_NAMED(AXP192_IRQ_GPIO2_INPUT, "GPIO2"),
> +};
> +
> +static const struct resource axp192_ac_power_supply_resources[] = {
> +	DEFINE_RES_IRQ_NAMED(AXP192_IRQ_ACIN_PLUGIN, "ACIN_PLUGIN"),
> +	DEFINE_RES_IRQ_NAMED(AXP192_IRQ_ACIN_REMOVAL, "ACIN_REMOVAL"),
> +	DEFINE_RES_IRQ_NAMED(AXP192_IRQ_ACIN_OVER_V, "ACIN_OVER_V"),
> +};
> +
> +static const struct resource axp192_usb_power_supply_resources[] = {
> +	DEFINE_RES_IRQ_NAMED(AXP192_IRQ_VBUS_PLUGIN, "VBUS_PLUGIN"),
> +	DEFINE_RES_IRQ_NAMED(AXP192_IRQ_VBUS_REMOVAL, "VBUS_REMOVAL"),
> +	DEFINE_RES_IRQ_NAMED(AXP192_IRQ_VBUS_VALID, "VBUS_VALID"),
> +	DEFINE_RES_IRQ_NAMED(AXP192_IRQ_VBUS_NOT_VALID, "VBUS_NOT_VALID"),
> +};
> +
>  static const struct resource axp20x_ac_power_supply_resources[] = {
>  	DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_ACIN_PLUGIN, "ACIN_PLUGIN"),
>  	DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_ACIN_REMOVAL, "ACIN_REMOVAL"),
> @@ -245,6 +294,15 @@ static const struct regmap_config axp152_regmap_config = {
>  	.cache_type	= REGCACHE_RBTREE,
>  };
>  
> +static const struct regmap_config axp192_regmap_config = {
> +	.reg_bits	= 8,
> +	.val_bits	= 8,
> +	.wr_table	= &axp192_writeable_table,
> +	.volatile_table	= &axp192_volatile_table,
> +	.max_register	= AXP20X_CC_CTRL,
> +	.cache_type	= REGCACHE_RBTREE,
> +};
> +
>  static const struct regmap_config axp20x_regmap_config = {
>  	.reg_bits	= 8,
>  	.val_bits	= 8,
> @@ -304,6 +362,55 @@ static const struct regmap_irq axp152_regmap_irqs[] = {
>  	INIT_REGMAP_IRQ(AXP152, GPIO0_INPUT,		2, 0),
>  };
>  
> +static const struct regmap_irq axp192_regmap_irqs[] = {
> +	INIT_REGMAP_IRQ(AXP192, ACIN_OVER_V,		0, 7),
> +	INIT_REGMAP_IRQ(AXP192, ACIN_PLUGIN,		0, 6),
> +	INIT_REGMAP_IRQ(AXP192, ACIN_REMOVAL,		0, 5),
> +	INIT_REGMAP_IRQ(AXP192, VBUS_OVER_V,		0, 4),
> +	INIT_REGMAP_IRQ(AXP192, VBUS_PLUGIN,		0, 3),
> +	INIT_REGMAP_IRQ(AXP192, VBUS_REMOVAL,		0, 2),
> +	INIT_REGMAP_IRQ(AXP192, VBUS_V_LOW,		0, 1),
> +	INIT_REGMAP_IRQ(AXP192, BATT_PLUGIN,		1, 7),
> +	INIT_REGMAP_IRQ(AXP192, BATT_REMOVAL,	        1, 6),
> +	INIT_REGMAP_IRQ(AXP192, BATT_ENT_ACT_MODE,	1, 5),
> +	INIT_REGMAP_IRQ(AXP192, BATT_EXIT_ACT_MODE,	1, 4),
> +	INIT_REGMAP_IRQ(AXP192, CHARG,		        1, 3),
> +	INIT_REGMAP_IRQ(AXP192, CHARG_DONE,		1, 2),
> +	INIT_REGMAP_IRQ(AXP192, BATT_TEMP_HIGH,	        1, 1),
> +	INIT_REGMAP_IRQ(AXP192, BATT_TEMP_LOW,	        1, 0),
> +	INIT_REGMAP_IRQ(AXP192, DIE_TEMP_HIGH,	        2, 7),
> +	INIT_REGMAP_IRQ(AXP192, CHARG_I_LOW,		2, 6),
> +	INIT_REGMAP_IRQ(AXP192, DCDC1_V_LONG,	        2, 5),
> +	INIT_REGMAP_IRQ(AXP192, DCDC2_V_LONG,	        2, 4),
> +	INIT_REGMAP_IRQ(AXP192, DCDC3_V_LONG,	        2, 3),
> +	INIT_REGMAP_IRQ(AXP192, PEK_SHORT,		2, 1),
> +	INIT_REGMAP_IRQ(AXP192, PEK_LONG,		2, 0),
> +	INIT_REGMAP_IRQ(AXP192, N_OE_PWR_ON,		3, 7),
> +	INIT_REGMAP_IRQ(AXP192, N_OE_PWR_OFF,	        3, 6),
> +	INIT_REGMAP_IRQ(AXP192, VBUS_VALID,		3, 5),
> +	INIT_REGMAP_IRQ(AXP192, VBUS_NOT_VALID,	        3, 4),
> +	INIT_REGMAP_IRQ(AXP192, VBUS_SESS_VALID,	3, 3),
> +	INIT_REGMAP_IRQ(AXP192, VBUS_SESS_END,	        3, 2),
> +	INIT_REGMAP_IRQ(AXP192, LOW_PWR_LVL,	        3, 0),
> +	INIT_REGMAP_IRQ(AXP192, TIMER,			4, 7),
> +	INIT_REGMAP_IRQ(AXP192, GPIO2_INPUT,		4, 2),
> +	INIT_REGMAP_IRQ(AXP192, GPIO1_INPUT,		4, 1),
> +	INIT_REGMAP_IRQ(AXP192, GPIO0_INPUT,		4, 0),
> +};
> +
> +static int axp192_get_irq_reg(unsigned int base_reg, int i)

Nit: If you have to respin this set, please rename 'i'.

Unless used as an iterator, 'i' is a terrible variable name.

> +{
> +	/* linear mapping for IRQ1 to IRQ4 */
> +	if (i < 4)
> +		return base_reg + i;
> +
> +	/* handle IRQ5 separately */
> +	if (base_reg == AXP192_IRQ1_EN)
> +		return AXP192_IRQ5_EN;
> +	else
> +		return AXP192_IRQ5_STATE;
> +}
> +
>  static const struct regmap_irq axp20x_regmap_irqs[] = {
>  	INIT_REGMAP_IRQ(AXP20X, ACIN_OVER_V,		0, 7),
>  	INIT_REGMAP_IRQ(AXP20X, ACIN_PLUGIN,		0, 6),
> @@ -514,6 +621,19 @@ static const struct regmap_irq_chip axp152_regmap_irq_chip = {
>  	.num_regs		= 3,
>  };
>  
> +static const struct regmap_irq_chip axp192_regmap_irq_chip = {
> +	.name			= "axp192_irq_chip",
> +	.status_base		= AXP192_IRQ1_STATE,
> +	.ack_base		= AXP192_IRQ1_STATE,
> +	.mask_base		= AXP192_IRQ1_EN,
> +	.mask_invert		= true,
> +	.init_ack_masked	= true,
> +	.irqs			= axp192_regmap_irqs,
> +	.num_irqs		= ARRAY_SIZE(axp192_regmap_irqs),
> +	.num_regs		= 5,
> +	.get_irq_reg		= axp192_get_irq_reg,
> +};
> +
>  static const struct regmap_irq_chip axp20x_regmap_irq_chip = {
>  	.name			= "axp20x_irq_chip",
>  	.status_base		= AXP20X_IRQ1_STATE,
> @@ -588,6 +708,30 @@ static const struct regmap_irq_chip axp809_regmap_irq_chip = {
>  	.num_regs		= 5,
>  };
>  
> +static const struct mfd_cell axp192_cells[] = {
> +	{
> +		.name		= "axp192-gpio",
> +		.of_compatible	= "x-powers,axp192-gpio",
> +		.num_resources	= ARRAY_SIZE(axp192_gpio_resources),
> +		.resources	= axp192_gpio_resources,
> +	}, {
> +		.name		= "axp20x-regulator",

Nit: Is it possible to put one line entries at the bottom?

And format like this:

    { .name = "axp20x-regulator" }

> +	}, {
> +		.name		= "axp192-adc",
> +		.of_compatible	= "x-powers,axp192-adc",
> +	}, {
> +		.name		= "axp20x-ac-power-supply",
> +		.of_compatible	= "x-powers,axp202-ac-power-supply",
> +		.num_resources	= ARRAY_SIZE(axp192_ac_power_supply_resources),
> +		.resources	= axp192_ac_power_supply_resources,
> +	}, {
> +		.name		= "axp20x-usb-power-supply",
> +		.of_compatible	= "x-powers,axp192-usb-power-supply",
> +		.num_resources	= ARRAY_SIZE(axp192_usb_power_supply_resources),
> +		.resources	= axp192_usb_power_supply_resources,
> +	}
> +};

For my own reference (apply this as-is to your sign-off block):

  Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>

-- 
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog

  reply	other threads:[~2022-06-27 12:03 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-03 13:57 [PATCH 00/10] Add support for AXP192 PMIC Aidan MacDonald
2022-06-03 13:57 ` [PATCH 01/10] regmap-irq: Add get_irq_reg to support unusual register layouts Aidan MacDonald
2022-06-06 17:43   ` Guru Das Srinagesh
2022-06-07 10:46     ` Aidan MacDonald
2022-06-03 13:57 ` [PATCH 02/10] dt-bindings: mfd: add bindings for AXP192 MFD device Aidan MacDonald
2022-06-05 22:49   ` Rob Herring
2022-06-27 11:47   ` Lee Jones
2022-06-03 13:57 ` [PATCH 03/10] dt-bindings: iio: adc: axp209: Add AXP192 compatible Aidan MacDonald
2022-06-03 16:34   ` Jonathan Cameron
2022-06-04 11:33     ` Aidan MacDonald
2022-06-05 22:50   ` Rob Herring
2022-06-03 13:57 ` [PATCH 04/10] dt-bindings: power: supply: axp20x: " Aidan MacDonald
2022-06-05 22:50   ` Rob Herring
2022-06-03 13:57 ` [PATCH 05/10] dt-bindings: gpio: Add AXP192 GPIO bindings Aidan MacDonald
2022-06-05 22:55   ` Rob Herring
2022-06-07 10:34     ` Aidan MacDonald
2022-06-07 15:17       ` Rob Herring
2022-06-07 15:40         ` Aidan MacDonald
2022-06-03 13:57 ` [PATCH 06/10] mfd: axp20x: Add support for AXP192 Aidan MacDonald
2022-06-27 11:54   ` Lee Jones [this message]
2022-06-27 13:02     ` Aidan MacDonald
2022-06-03 13:57 ` [PATCH 07/10] regulator: " Aidan MacDonald
2022-06-06 14:36   ` Mark Brown
2022-06-03 13:57 ` [PATCH 08/10] iio: adc: axp20x_adc: " Aidan MacDonald
2022-06-03 16:47   ` Jonathan Cameron
2022-06-04 11:47     ` Aidan MacDonald
2022-06-04 14:27       ` Jonathan Cameron
2022-06-07 10:49         ` Aidan MacDonald
2022-06-03 13:57 ` [PATCH 09/10] power: supply: axp20x_usb_power: " Aidan MacDonald
2022-06-05 15:13   ` kernel test robot
2022-06-03 13:57 ` [PATCH 10/10] pinctrl: Add AXP192 pin control driver Aidan MacDonald
2022-06-15 13:44   ` Linus Walleij
2022-06-15 18:06     ` Michael Walle
2022-06-15 14:51   ` Andy Shevchenko
2022-06-17 12:15     ` Aidan MacDonald
2022-06-17 16:08       ` Andy Shevchenko

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=YrmaX6/dbYKAFDQ4@google.com \
    --to=lee.jones@linaro.org \
    --cc=aidanmacdonald.0x0@gmail.com \
    --cc=brgl@bgdev.pl \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jic23@kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lars@metafoo.de \
    --cc=lgirdwood@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=sre@kernel.org \
    --cc=wens@csie.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).