From: David Heidelberg <david@ixit.cz>
To: sajattack@postmarketos.org, Lee Jones <lee@kernel.org>,
Pavel Machek <pavel@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Nikita Travkin <nikitos.tr@gmail.com>,
Alexey Min <alexeymin@minlexx.ru>,
Griffin Kroah-Hartman <griffin@kroah.com>
Cc: Nikita Travkin <nikita@trvn.ru>,
linux-leds@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, phone-devel@vger.kernel.org
Subject: Re: [PATCH v6 2/3] leds: aw2013: Add AW2027 support
Date: Sat, 14 Nov 2026 16:27:39 +0100 [thread overview]
Message-ID: <47fb5b06-3ffb-42a1-91cf-e4d098438ebe@ixit.cz> (raw)
In-Reply-To: <20261112-aw2013-aw20xx-rename-v6-2-251eca340abc@postmarketos.org>
On 13/11/2026 01:01, Paul Sajna via B4 Relay wrote:
> From: Paul Sajna <sajattack@postmarketos.org>
>
> The AW2027 is basically the same as the AW2013.
>
> It differs in:
> - the max current (30mA rather than 15)
> - the number of current levels for colour-mixing (16 rather than 4)
> - the supply voltage max
> - the charge indicator (unsupported by our driver at this time)
>
> The max current register (imax) also moves from LCFG to GCR2, and the
> selectable current levels for colour-mixing (LCFG_CUR) take their place.
>
> The current driver implementation provided here sets the global imax to
> it's maximum, and scales each led to the closest value using the local
> imax. It's the best result achievable short of adding custom sysfs
> entries and mucking up the linux interfaces.
>
> Comparison of all AW20XX chips https://www.awinic.com/en/productCompareList?id=47&ids=1022,74,96,75,72,71,928,927,73,76,578
> AW2027 datasheet: https://doc.awinic.com/doc/202507/77b87097-27bf-48cd-af9b-9b615064c1e1.pdf
> Vendor driver: https://www.awinic.com/en/driver/AW2027DNR/454
>
> Signed-off-by: Paul Sajna <sajattack@postmarketos.org>
> ---
> drivers/leds/leds-aw2013.c | 190 ++++++++++++++++++++++++++++++++++++++-------
> 1 file changed, 163 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/leds/leds-aw2013.c b/drivers/leds/leds-aw2013.c
> index cf20e94920fd..5ff9887086a6 100644
> --- a/drivers/leds/leds-aw2013.c
> +++ b/drivers/leds/leds-aw2013.c
> @@ -1,5 +1,5 @@
> // SPDX-License-Identifier: GPL-2.0+
> -// Driver for Awinic AW2013 3-channel LED driver
> +// Driver for Awinic AW2013/AW2027 3-channel LED drivers
>
> #include <linux/i2c.h>
> #include <linux/leds.h>
> @@ -20,13 +20,15 @@
> #define AW2013_GCR 0x01
> #define AW2013_GCR_ENABLE BIT(0)
>
> +#define AW20XX_GCR2 0x04
> +
> /* LED channel enable register */
> #define AW2013_LCTR 0x30
> #define AW2013_LCTR_LE(x) BIT((x))
>
> /* LED channel control registers */
> #define AW2013_LCFG(x) (0x31 + (x))
> -#define AW2013_LCFG_IMAX_MASK (BIT(0) | BIT(1)) // Should be 0-3
> +#define AW2013_IMAX_MASK (BIT(0) | BIT(1)) // Should be 0-3
> #define AW2013_LCFG_MD BIT(4)
> #define AW2013_LCFG_FI BIT(5)
> #define AW2013_LCFG_FO BIT(6)
> @@ -51,6 +53,16 @@
>
> #define AW2013_TIME_STEP 130 /* ms */
>
> +/* AW2027-specific defines */
> +#define AW2016_23_27_33_CHIPID 0x09 /* vendor shared same chipid between several chips */
> +#define AW2027_REG_MAX 0x7F /* copied from vendor driver, but only up to 0x3F is documented */
just in case you'll be sending next revision, 0x7f (hex should go always lower
case).
> +#define AW2027_LOCAL_IMAX_MASK GENMASK(3, 0)
> +
> +#define AW2027_GLOBAL_IMAX_15MA 0
> +#define AW2027_GLOBAL_IMAX_30MA 1
> +#define AW2027_GLOBAL_IMAX_5MA 2
> +#define AW2027_GLOBAL_IMAX_10MA 3
> +
> struct aw2013;
>
[...]
> @@ -142,9 +261,7 @@ static int aw2013_chip_enable(struct aw2013 *chip)
>
> static bool aw2013_chip_in_use(struct aw2013 *chip)
> {
> - int i;
My comment regarding to using C99 was aimed only at the new code, as you
introducing it. If you modernizing existing code, you should do that in separate
commit. Let maintainer decide if the split is needed here or it's ok as is :)
David
[...]
next prev parent reply other threads:[~2026-11-14 15:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 0:01 [PATCH v6 0/3] " Paul Sajna via B4 Relay
2026-11-13 0:01 ` [PATCH v6 1/3] dt-bindings: leds: aw2013: Add awinic,aw2027 compatible Paul Sajna via B4 Relay
2026-11-13 0:01 ` [PATCH v6 2/3] leds: aw2013: Add AW2027 support Paul Sajna via B4 Relay
2026-11-14 15:27 ` David Heidelberg [this message]
2026-11-13 0:01 ` [PATCH v6 3/3] leds: aw2013: Use dev_err_probe Paul Sajna via B4 Relay
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=47fb5b06-3ffb-42a1-91cf-e4d098438ebe@ixit.cz \
--to=david@ixit.cz \
--cc=alexeymin@minlexx.ru \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=griffin@kroah.com \
--cc=krzk+dt@kernel.org \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=nikita@trvn.ru \
--cc=nikitos.tr@gmail.com \
--cc=pavel@kernel.org \
--cc=phone-devel@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sajattack@postmarketos.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
all inboxes | Powered by JetHome®