From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Biju Das <biju.das.jz@bp.renesas.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>,
Geert Uytterhoeven <geert+renesas@glider.be>,
Magnus Damm <magnus.damm@gmail.com>, Lee Jones <lee@kernel.org>,
linux-rtc@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
Fabrizio Castro <fabrizio.castro.jz@renesas.com>
Subject: Re: [PATCH RFC 5/6] rtc: isl1208: Add support for the built-in RTC on the PMIC RAA215300
Date: Wed, 3 May 2023 12:56:49 +0200 [thread overview]
Message-ID: <20230503105649cd039d9a@mail.local> (raw)
In-Reply-To: <20230503084608.14008-6-biju.das.jz@bp.renesas.com>
On 03/05/2023 09:46:07+0100, Biju Das wrote:
> The built-in RTC found on PMIC RAA215300 is the same as ISL1208.
> However, the external oscillator polarity is determined by the
> PMIC version. For eg: the PMIC version has inverted polarity for
> the external oscillator and the corresponding bit in RTC need to
> be inverted(XTOSCB). This info needs to be shared from PMIC driver
> to RTC driver, so that it can support all versions without any code
> changes.
>
> Add a new compatible renesas,raa215300-isl1208 to support RTC found
> on PMIC RAA215300 and renesas,raa215300-pmic property to support
> different versions.
>
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
> drivers/rtc/rtc-isl1208.c | 50 +++++++++++++++++++++++++++++++++++++++
> 1 file changed, 50 insertions(+)
>
> diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
> index 73cc6aaf9b8b..f4ea19691ac1 100644
> --- a/drivers/rtc/rtc-isl1208.c
> +++ b/drivers/rtc/rtc-isl1208.c
> @@ -74,6 +74,7 @@ enum isl1208_id {
> TYPE_ISL1209,
> TYPE_ISL1218,
> TYPE_ISL1219,
> + TYPE_RAA215300_ISL1208,
> ISL_LAST_ID
> };
>
> @@ -83,11 +84,13 @@ static const struct isl1208_config {
> unsigned int nvmem_length;
> unsigned has_tamper:1;
> unsigned has_timestamp:1;
> + unsigned has_pmic_parent:1;
> } isl1208_configs[] = {
> [TYPE_ISL1208] = { "isl1208", 2, false, false },
> [TYPE_ISL1209] = { "isl1209", 2, true, false },
> [TYPE_ISL1218] = { "isl1218", 8, false, false },
> [TYPE_ISL1219] = { "isl1219", 2, true, true },
> + [TYPE_RAA215300_ISL1208] = { "isl1208", 2, false, false, true },
> };
>
> static const struct i2c_device_id isl1208_id[] = {
> @@ -104,6 +107,10 @@ static const __maybe_unused struct of_device_id isl1208_of_match[] = {
> { .compatible = "isil,isl1209", .data = &isl1208_configs[TYPE_ISL1209] },
> { .compatible = "isil,isl1218", .data = &isl1208_configs[TYPE_ISL1218] },
> { .compatible = "isil,isl1219", .data = &isl1208_configs[TYPE_ISL1219] },
> + {
> + .compatible = "renesas,raa215300-isl1208",
> + .data = &isl1208_configs[TYPE_RAA215300_ISL1208]
> + },
> { }
> };
> MODULE_DEVICE_TABLE(of, isl1208_of_match);
> @@ -166,6 +173,43 @@ isl1208_i2c_validate_client(struct i2c_client *client)
> return 0;
> }
>
> +static bool isl1208_is_xtosc_polarity_inverted(struct i2c_client *client)
I'd remove polarity from the name of this function
> +{
> + struct device *dev = &client->dev;
> + struct i2c_client *pmic_dev;
> + unsigned int *pmic_version;
> + struct device_node *np;
> + bool ret = false;
> +
> + np = of_parse_phandle(dev->of_node, "renesas,raa215300-pmic", 0);
> + if (np)
> + pmic_dev = of_find_i2c_device_by_node(np);
> +
> + of_node_put(np);
> + if (!pmic_dev)
> + return ret;
> +
> + pmic_version = dev_get_drvdata(&pmic_dev->dev);
> + /* External Oscillator polarity is inverted on revision 0x12 onwards */
s/polarity/bit/
My understanding is that the bit meaning is inverted. It is still a
on/off bit.
> + if (*pmic_version >= 0x12)
> + ret = true;
> +
> + put_device(&pmic_dev->dev);
> +
> + return ret;
> +}
> +
> +static int
> +isl1208_set_ext_osc_based_on_pmic_version(struct i2c_client *client, int rc)
> +{
> + if (isl1208_is_xtosc_polarity_inverted(client))
> + rc &= ~ISL1208_REG_SR_XTOSCB;
> + else
> + rc |= ISL1208_REG_SR_XTOSCB;
> +
> + return i2c_smbus_write_byte_data(client, ISL1208_REG_SR, rc);
> +}
> +
> static int
> isl1208_i2c_get_sr(struct i2c_client *client)
> {
> @@ -845,6 +889,12 @@ isl1208_probe(struct i2c_client *client)
> return rc;
> }
>
> + if (isl1208->config->has_pmic_parent) {
> + rc = isl1208_set_ext_osc_based_on_pmic_version(client, rc);
> + if (rc)
> + return rc;
> + }
> +
> if (rc & ISL1208_REG_SR_RTCF)
> dev_warn(&client->dev, "rtc power failure detected, "
> "please set clock.\n");
> --
> 2.25.1
>
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
next prev parent reply other threads:[~2023-05-03 10:57 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-03 8:46 [PATCH RFC 0/6] Add Renesas PMIC RAA215300 and built-in RTC support Biju Das
2023-05-03 8:46 ` [PATCH RFC 3/6] dt-bindings: rtc: isl1208: Convert to json-schema Biju Das
2023-05-03 9:24 ` Biju Das
2023-05-03 10:36 ` Biju Das
2023-05-04 16:22 ` Biju Das
2023-05-04 16:39 ` Krzysztof Kozlowski
2023-05-05 6:14 ` Biju Das
2023-05-03 9:25 ` Geert Uytterhoeven
2023-05-03 9:28 ` Geert Uytterhoeven
2023-05-03 9:49 ` Biju Das
2023-05-03 8:46 ` [PATCH RFC 4/6] dt-bindings: rtc: isl1208: Document built-in RTC device on PMIC RAA215300 Biju Das
2023-05-03 9:36 ` Geert Uytterhoeven
2023-05-03 10:08 ` Biju Das
2023-05-03 12:08 ` Geert Uytterhoeven
2023-05-04 7:10 ` Krzysztof Kozlowski
2023-05-04 7:47 ` Geert Uytterhoeven
2023-05-04 8:10 ` Krzysztof Kozlowski
2023-05-04 16:08 ` Biju Das
2023-05-04 16:16 ` Biju Das
2023-05-03 8:46 ` [PATCH RFC 5/6] rtc: isl1208: Add support for the built-in RTC on the " Biju Das
2023-05-03 10:56 ` Alexandre Belloni [this message]
2023-05-03 11:42 ` Biju Das
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=20230503105649cd039d9a@mail.local \
--to=alexandre.belloni@bootlin.com \
--cc=a.zummo@towertech.it \
--cc=biju.das.jz@bp.renesas.com \
--cc=fabrizio.castro.jz@renesas.com \
--cc=geert+renesas@glider.be \
--cc=lee@kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=magnus.damm@gmail.com \
/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