From: Lee Jones <lee.jones@linaro.org>
To: Andreas Kemnade <andreas@kemnade.info>, broonie@kernel.org
Cc: j.neuschaefer@gmx.net, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] mfd: ntxec: Support for EC in Tolino Shine 2 HD
Date: Wed, 10 Mar 2021 09:48:21 +0000 [thread overview]
Message-ID: <20210310094821.GB701493@dell> (raw)
In-Reply-To: <20210308212952.20774-1-andreas@kemnade.info>
Mark,
Could you take a look at this for me please:
On Mon, 08 Mar 2021, Andreas Kemnade wrote:
> Add the version of the EC in the Tolino Shine 2 HD
> to the supported versions. It seems not to have an RTC
> and does not ack data written to it.
> The vendor kernel happily ignores write errors, using
> I2C via userspace i2c-set also shows the error.
> So add a quirk to ignore that error.
>
> PWM can be successfully configured despite of that error.
>
> Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
> ---
> Changes in v2:
> - more comments about stacking regmap construction
> - fix accidential line removal
> - better naming for subdevices
>
> drivers/mfd/ntxec.c | 61 +++++++++++++++++++++++++++++++++++++--
> include/linux/mfd/ntxec.h | 1 +
> 2 files changed, 59 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mfd/ntxec.c b/drivers/mfd/ntxec.c
> index 957de2b03529..0bbd2e34e89c 100644
> --- a/drivers/mfd/ntxec.c
> +++ b/drivers/mfd/ntxec.c
> @@ -96,6 +96,38 @@ static struct notifier_block ntxec_restart_handler = {
> .priority = 128,
> };
>
> +static int regmap_ignore_write(void *context,
> + unsigned int reg, unsigned int val)
> +
> +{
> + struct regmap *regmap = context;
> +
> + regmap_write(regmap, reg, val);
> +
> + return 0;
> +}
> +
> +static int regmap_wrap_read(void *context, unsigned int reg,
> + unsigned int *val)
> +{
> + struct regmap *regmap = context;
> +
> + return regmap_read(regmap, reg, val);
> +}
> +
> +/*
> + * Some firmware versions do not ack written data, add a wrapper. It
> + * is used to stack another regmap on top.
> + */
> +static const struct regmap_config regmap_config_noack = {
> + .name = "ntxec_noack",
> + .reg_bits = 8,
> + .val_bits = 16,
> + .cache_type = REGCACHE_NONE,
> + .reg_write = regmap_ignore_write,
> + .reg_read = regmap_wrap_read
> +};
> +
> static const struct regmap_config regmap_config = {
> .name = "ntxec",
> .reg_bits = 8,
> @@ -104,15 +136,20 @@ static const struct regmap_config regmap_config = {
> .val_format_endian = REGMAP_ENDIAN_BIG,
> };
>
> -static const struct mfd_cell ntxec_subdevices[] = {
> +static const struct mfd_cell ntxec_subdev[] = {
> { .name = "ntxec-rtc" },
> { .name = "ntxec-pwm" },
> };
>
> +static const struct mfd_cell ntxec_subdev_pwm[] = {
> + { .name = "ntxec-pwm" },
> +};
> +
> static int ntxec_probe(struct i2c_client *client)
> {
> struct ntxec *ec;
> unsigned int version;
> + bool has_rtc;
> int res;
>
> ec = devm_kmalloc(&client->dev, sizeof(*ec), GFP_KERNEL);
> @@ -137,6 +174,16 @@ static int ntxec_probe(struct i2c_client *client)
> /* Bail out if we encounter an unknown firmware version */
> switch (version) {
> case NTXEC_VERSION_KOBO_AURA:
> + has_rtc = true;
> + break;
> + case NTXEC_VERSION_TOLINO_SHINE2:
> + has_rtc = false;
> + /* Another regmap stacked on top of the other */
> + ec->regmap = devm_regmap_init(ec->dev, NULL,
> + ec->regmap,
> + ®map_config_noack);
> + if (IS_ERR(ec->regmap))
> + return PTR_ERR(ec->regmap);
> break;
> default:
> dev_err(ec->dev,
> @@ -181,8 +228,16 @@ static int ntxec_probe(struct i2c_client *client)
>
> i2c_set_clientdata(client, ec);
>
> - res = devm_mfd_add_devices(ec->dev, PLATFORM_DEVID_NONE, ntxec_subdevices,
> - ARRAY_SIZE(ntxec_subdevices), NULL, 0, NULL);
> + if (has_rtc)
> + res = devm_mfd_add_devices(ec->dev, PLATFORM_DEVID_NONE,
> + ntxec_subdev,
> + ARRAY_SIZE(ntxec_subdev),
> + NULL, 0, NULL);
> + else
> + res = devm_mfd_add_devices(ec->dev, PLATFORM_DEVID_NONE,
> + ntxec_subdev_pwm,
> + ARRAY_SIZE(ntxec_subdev_pwm),
> + NULL, 0, NULL);
> if (res)
> dev_err(ec->dev, "Failed to add subdevices: %d\n", res);
>
> diff --git a/include/linux/mfd/ntxec.h b/include/linux/mfd/ntxec.h
> index 361204d125f1..26ab3b8eb612 100644
> --- a/include/linux/mfd/ntxec.h
> +++ b/include/linux/mfd/ntxec.h
> @@ -33,5 +33,6 @@ static inline __be16 ntxec_reg8(u8 value)
>
> /* Known firmware versions */
> #define NTXEC_VERSION_KOBO_AURA 0xd726 /* found in Kobo Aura */
> +#define NTXEC_VERSION_TOLINO_SHINE2 0xf110 /* found in Tolino Shine 2 HD */
>
> #endif
--
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
next prev parent reply other threads:[~2021-03-10 9:50 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-08 21:29 [PATCH v2] mfd: ntxec: Support for EC in Tolino Shine 2 HD Andreas Kemnade
2021-03-08 22:07 ` Jonathan Neuschäfer
2021-03-10 9:48 ` Lee Jones [this message]
2021-03-11 18:40 ` Mark Brown
2021-03-22 14:59 ` Lee Jones
2021-03-23 17:11 ` Mark Brown
2021-03-23 17:20 ` Lee Jones
2021-03-23 17:48 ` Mark Brown
2021-03-23 18:52 ` Lee Jones
2021-03-23 19:44 ` Mark Brown
2021-03-10 9:55 ` Lee Jones
2021-03-13 11:17 ` Jonathan Neuschäfer
2021-03-13 15:07 ` Andreas Kemnade
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=20210310094821.GB701493@dell \
--to=lee.jones@linaro.org \
--cc=andreas@kemnade.info \
--cc=broonie@kernel.org \
--cc=j.neuschaefer@gmx.net \
--cc=linux-kernel@vger.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