From: Lee Jones <lee@kernel.org>
To: Svyatoslav Ryhel <clamor95@gmail.com>
Cc: Pavel Machek <pavel@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
Daniel Thompson <danielt@kernel.org>,
Jingoo Han <jingoohan1@gmail.com>,
linux-leds@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, mfd@lists.linux.dev,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3 3/4] mfd: aat2870: Convert to use OF bindings
Date: Mon, 19 Oct 2026 15:51:04 +0100 [thread overview]
Message-ID: <179198329794.839288.10569542357230656958@kernel.org> (raw)
In-Reply-To: <20261013180933.487013-4-clamor95@gmail.com>
On Tue, 13 Oct 2026, Svyatoslav Ryhel wrote:
> Conversion of the AAT2870 driver to use OF bindings requires a few complex
> changes that should be done simultaneously.
>
> The AAT2870 essentially provides two functions via child devices:
> backlight and regulators. Both functions are fairly self-sufficient and
> may not be populated on the final board. Consequently, the MFD
> registration API was replaced with of_platform_populate(), and each
> sub-device was given its own compatible string.
>
> Additionally, aat2870-core utilizes an enable GPIO. Obtaining this GPIO
> was converted to use modern gpiod/OF helpers, allowing the redundant
> aat2870_enable() and aat2870_disable() helpers to be removed.
>
> The aat2870-regulator driver was updated to register each of the four LDOs
> from a dedicated OF node using modern regulator framework.
>
> The aat2870-backlight driver was changed to populate all required
> properties from a dedicated Device Tree node. Its channel map was updated
> to use u8 instead of int. Furthermore, because the maximum current is now
> parsed as an absolute value rather than an enum entry, the calculation and
> application of the maximum current were updated accordingly.
>
> All of the changes above allow platform data to be removed entirely.
>
> Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> ---
> drivers/mfd/aat2870-core.c | 115 +++++--------------
> drivers/regulator/aat2870-regulator.c | 159 +++++++++++---------------
> drivers/video/backlight/aat2870_bl.c | 51 +++++----
> include/linux/mfd/aat2870.h | 95 +--------------
> 4 files changed, 121 insertions(+), 299 deletions(-)
>
> diff --git a/drivers/mfd/aat2870-core.c b/drivers/mfd/aat2870-core.c
> index 0d56cd6fbc6a5..909c14ee60323 100644
> --- a/drivers/mfd/aat2870-core.c
> +++ b/drivers/mfd/aat2870-core.c
> @@ -16,8 +16,15 @@
> #include <linux/gpio/legacy.h>
> #include <linux/mfd/core.h>
> #include <linux/mfd/aat2870.h>
> +#include <linux/of_platform.h>
> #include <linux/regulator/machine.h>
Since we are moving away from legacy GPIO and MFD APIs here, does it
make sense to replace '<linux/gpio/legacy.h>' and '<linux/mfd/core.h>'
with '<linux/gpio/consumer.h>'?
> +struct aat2870_register {
> + bool readable;
> + bool writeable;
> + u8 value;
> +};
> +
> static struct aat2870_register aat2870_regs[AAT2870_REG_NUM] = {
> /* readable, writeable, value */
> { 0, 1, 0x00 }, /* 0x00 AAT2870_BL_CH_EN */
> @@ -61,34 +68,6 @@ static struct aat2870_register aat2870_regs[AAT2870_REG_NUM] = {
> { 0, 1, 0x00 }, /* 0x26 AAT2870_LDO_EN */
> };
>
> -static struct mfd_cell aat2870_devs[] = {
> - {
> - .name = "aat2870-backlight",
> - .id = AAT2870_ID_BL,
> - .pdata_size = sizeof(struct aat2870_bl_platform_data),
> - },
> - {
> - .name = "aat2870-regulator",
> - .id = AAT2870_ID_LDOA,
> - .pdata_size = sizeof(struct regulator_init_data),
> - },
> - {
> - .name = "aat2870-regulator",
> - .id = AAT2870_ID_LDOB,
> - .pdata_size = sizeof(struct regulator_init_data),
> - },
> - {
> - .name = "aat2870-regulator",
> - .id = AAT2870_ID_LDOC,
> - .pdata_size = sizeof(struct regulator_init_data),
> - },
> - {
> - .name = "aat2870-regulator",
> - .id = AAT2870_ID_LDOD,
> - .pdata_size = sizeof(struct regulator_init_data),
> - },
> -};
> -
> static int __aat2870_read(struct aat2870_data *aat2870, u8 addr, u8 *val)
> {
> int ret;
> @@ -196,22 +175,6 @@ static int aat2870_update(struct aat2870_data *aat2870, u8 addr, u8 mask,
> return ret;
> }
>
> -static inline void aat2870_enable(struct aat2870_data *aat2870)
> -{
> - if (aat2870->en_pin >= 0)
> - gpio_set_value(aat2870->en_pin, 1);
> -
> - aat2870->is_enable = 1;
> -}
> -
> -static inline void aat2870_disable(struct aat2870_data *aat2870)
> -{
> - if (aat2870->en_pin >= 0)
> - gpio_set_value(aat2870->en_pin, 0);
> -
> - aat2870->is_enable = 0;
> -}
> -
> #ifdef CONFIG_DEBUG_FS
> static ssize_t aat2870_dump_reg(struct aat2870_data *aat2870, char *buf)
> {
> @@ -332,9 +295,7 @@ static inline void aat2870_init_debugfs(struct aat2870_data *aat2870)
>
> static int aat2870_i2c_probe(struct i2c_client *client)
> {
> - struct aat2870_platform_data *pdata = dev_get_platdata(&client->dev);
> struct aat2870_data *aat2870;
> - int i, j;
> int ret = 0;
>
> aat2870 = devm_kzalloc(&client->dev, sizeof(struct aat2870_data),
> @@ -348,60 +309,29 @@ static int aat2870_i2c_probe(struct i2c_client *client)
>
> aat2870->reg_cache = aat2870_regs;
>
> - if (pdata->en_pin < 0)
> - aat2870->en_pin = -1;
> - else
> - aat2870->en_pin = pdata->en_pin;
> + aat2870->en_pin = devm_gpiod_get_optional(&client->dev, "enable",
> + GPIOD_OUT_HIGH);
> + if (IS_ERR(aat2870->en_pin))
> + return dev_err_probe(&client->dev, PTR_ERR(aat2870->en_pin),
> + "Failed to get EN GPIO\n");
>
> - aat2870->init = pdata->init;
> - aat2870->uninit = pdata->uninit;
> aat2870->read = aat2870_read;
> aat2870->write = aat2870_write;
> aat2870->update = aat2870_update;
>
> mutex_init(&aat2870->io_lock);
>
> - if (aat2870->init)
> - aat2870->init(aat2870);
> -
> - if (aat2870->en_pin >= 0) {
> - ret = devm_gpio_request_one(&client->dev, aat2870->en_pin,
> - GPIOF_OUT_INIT_HIGH, "aat2870-en");
> - if (ret < 0) {
> - dev_err(&client->dev,
> - "Failed to request GPIO %d\n", aat2870->en_pin);
> - return ret;
> - }
> - }
> -
> - aat2870_enable(aat2870);
> -
> - for (i = 0; i < pdata->num_subdevs; i++) {
> - for (j = 0; j < ARRAY_SIZE(aat2870_devs); j++) {
> - if ((pdata->subdevs[i].id == aat2870_devs[j].id) &&
> - !strcmp(pdata->subdevs[i].name,
> - aat2870_devs[j].name)) {
> - aat2870_devs[j].platform_data =
> - pdata->subdevs[i].platform_data;
> - break;
> - }
> - }
> - }
> + gpiod_set_value(aat2870->en_pin, 1);
Is this needed when 'devm_gpiod_get_optional()' already requested the pin with
'GPIOD_OUT_HIGH'?
>
> - ret = mfd_add_devices(aat2870->dev, 0, aat2870_devs,
> - ARRAY_SIZE(aat2870_devs), NULL, 0, NULL);
> - if (ret != 0) {
> - dev_err(aat2870->dev, "Failed to add subdev: %d\n", ret);
> - goto out_disable;
> + ret = devm_of_platform_populate(&client->dev);
> + if (ret) {
> + gpiod_set_value(aat2870->en_pin, 0);
> + return dev_err_probe(&client->dev, ret, "Failed to populate cells\n");
> }
>
> aat2870_init_debugfs(aat2870);
>
> return 0;
> -
> -out_disable:
> - aat2870_disable(aat2870);
> - return ret;
> }
>
> static int aat2870_i2c_suspend(struct device *dev)
> @@ -409,7 +339,7 @@ static int aat2870_i2c_suspend(struct device *dev)
> struct i2c_client *client = to_i2c_client(dev);
> struct aat2870_data *aat2870 = i2c_get_clientdata(client);
>
> - aat2870_disable(aat2870);
> + gpiod_set_value(aat2870->en_pin, 0);
>
> return 0;
> }
> @@ -421,7 +351,7 @@ static int aat2870_i2c_resume(struct device *dev)
> struct aat2870_register *reg = NULL;
> int i;
>
> - aat2870_enable(aat2870);
> + gpiod_set_value(aat2870->en_pin, 1);
>
> /* restore registers */
> for (i = 0; i < AAT2870_REG_NUM; i++) {
> @@ -436,6 +366,12 @@ static int aat2870_i2c_resume(struct device *dev)
> static DEFINE_SIMPLE_DEV_PM_OPS(aat2870_pm_ops, aat2870_i2c_suspend,
> aat2870_i2c_resume);
>
> +static const struct of_device_id aat2870_match_table[] = {
> + { .compatible = "skyworks,aat2870" },
> + { }
> +};
> +MODULE_DEVICE_TABLE(of, aat2870_match_table);
> +
> static const struct i2c_device_id aat2870_i2c_id_table[] = {
> { "aat2870" },
> { }
> @@ -444,6 +380,7 @@ static const struct i2c_device_id aat2870_i2c_id_table[] = {
> static struct i2c_driver aat2870_i2c_driver = {
> .driver = {
> .name = "aat2870",
> + .of_match_table = aat2870_match_table,
> .pm = pm_sleep_ptr(&aat2870_pm_ops),
> .suppress_bind_attrs = true,
> },
--
Lee Jones
next prev parent reply other threads:[~2026-10-19 14:51 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 18:09 [PATCH v3 0/4] mfd: aat2870: Convert to use OF bindings Svyatoslav Ryhel
2026-10-13 18:09 ` [PATCH v3 1/4] dt-bindings: mfd: Document Skyworks AAT2870 Svyatoslav Ryhel
2026-10-16 15:23 ` Daniel Thompson
2026-10-19 14:52 ` Lee Jones
2026-10-19 14:59 ` Svyatoslav Ryhel
2026-10-19 16:02 ` Lee Jones
2026-10-19 16:07 ` Svyatoslav Ryhel
2026-10-13 18:09 ` [PATCH v3 2/4] mfd: aat2870: Derive brightness steps from max current Svyatoslav Ryhel
2026-10-13 18:16 ` sashiko-bot
2026-10-16 15:30 ` Daniel Thompson
2026-10-16 16:27 ` Svyatoslav Ryhel
2026-10-19 14:44 ` Lee Jones
2026-10-19 14:55 ` Svyatoslav Ryhel
2026-10-19 16:02 ` Lee Jones
2026-10-13 18:09 ` [PATCH v3 3/4] mfd: aat2870: Convert to use OF bindings Svyatoslav Ryhel
2026-10-13 18:21 ` sashiko-bot
2026-10-16 15:34 ` Daniel Thompson
2026-10-19 14:51 ` Lee Jones [this message]
2026-10-19 14:56 ` Svyatoslav Ryhel
2026-10-13 18:09 ` [PATCH v3 4/4] mfd: aat2870: Add support for VIN and IN-LDO power supplies Svyatoslav Ryhel
2026-10-13 18:18 ` sashiko-bot
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=179198329794.839288.10569542357230656958@kernel.org \
--to=lee@kernel.org \
--cc=broonie@kernel.org \
--cc=clamor95@gmail.com \
--cc=conor+dt@kernel.org \
--cc=danielt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=jingoohan1@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=mfd@lists.linux.dev \
--cc=pavel@kernel.org \
--cc=robh@kernel.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