Linux RTC
 help / color / mirror / Atom feed
From: Trent Piepho <tpiepho@gmail.com>
To: Alessandro Zummo <a.zummo@towertech.it>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	Biju Das <biju.das.jz@bp.renesas.com>
Cc: Biju Das <biju.das.jz@bp.renesas.com>,
	linux-rtc@vger.kernel.org,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Fabrizio Castro <fabrizio.castro.jz@renesas.com>,
	linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH v6 10/11] rtc: isl1208: Add isl1208_set_xtoscb()
Date: Fri, 09 Jun 2023 01:08:04 -0700	[thread overview]
Message-ID: <5820492.tdWV9SEqCh@zen.local> (raw)
In-Reply-To: <20230602142426.438375-11-biju.das.jz@bp.renesas.com>

On Friday, June 2, 2023 7:24:25 AM PDT Biju Das wrote:
> 
> +static int isl1208_set_xtoscb(struct i2c_client *client, int sr, int xtosb_val) +{
> +	if (xtosb_val)
> +		sr &= ~ISL1208_REG_SR_XTOSCB;
> +	else
> +		sr |= ISL1208_REG_SR_XTOSCB;
> +
> +	return i2c_smbus_write_byte_data(client, ISL1208_REG_SR, sr);
> +}

Since the contents of this register are preserved by battery power, it will
normally already have the correct value.

Setting it this way adds an extra I2C transaction to every driver init to
set the register to the value it's already at.

It would be better to check if the bit is not set correctly, and then only
set it and write to the register if it is not.

You can do that like this:

/* Strangely, xtosb_val of 0 means to set the bit and 1 means to clear it!
 * Hopefully, that is really what you want to do.  Seems backward of what
 * I would expect.
 */
static int isl1208_set_xtoscb(struct i2c_client *client, int sr, int xtosb_val)
{
        /* Do nothing if bit is already set to desired value */
        if (!(st & ISL1208_REG_SR_XTOSCB) == xtosb_val)
                return 0;
        sr ^= ISL1208_REG_SR_XTOSCB;
        return i2c_smbus_write_byte_data(client, ISL1208_REG_SR, sr);
}


>  static int
>  isl1208_probe(struct i2c_client *client)
>  {
> -	int rc = 0;
>  	struct isl1208_state *isl1208;
>  	int evdet_irq = -1;
> +	int xtosb_val = 1;

So you assume XTOSCB should be unset by default?  Prior behavior of the
driver was to preserve this bit.  Maybe it was set the bootloader to the
correct value?  This would break such a setup.

> +	rc = isl1208_clk_present(client, "xin");
> +	if (rc < 0)
> +		return rc;
> +
> +	if (!rc) {
> +		rc = isl1208_clk_present(client, "clkin");

Why do you support two names for the same clock?  I don't see this discussed
in any of the threads.





  parent reply	other threads:[~2023-06-09  8:09 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-02 14:24 [PATCH v6 00/11] Add Renesas PMIC RAA215300 and built-in RTC support Biju Das
2023-06-02 14:24 ` [PATCH v6 05/11] dt-bindings: rtc: isl1208: Convert to json-schema Biju Das
2023-06-09  6:42   ` Biju Das
2023-06-09 13:48     ` Alexandre Belloni
2023-06-09 14:03       ` Conor Dooley
2023-06-09  7:48   ` Trent Piepho
2023-06-09  7:58     ` Biju Das
2023-06-02 14:24 ` [PATCH v6 06/11] dt-bindings: rtc: isil,isl1208: Document clock and clock-names properties Biju Das
2023-06-02 14:24 ` [PATCH v6 07/11] rtc: isl1208: Drop name variable Biju Das
2023-06-02 14:24 ` [PATCH v6 08/11] rtc: isl1208: Make similar I2C and DT-based matching table Biju Das
2023-06-02 14:24 ` [PATCH v6 09/11] rtc: isl1208: Drop enum isl1208_id and split isl1208_configs[] Biju Das
2023-06-02 14:24 ` [PATCH v6 10/11] rtc: isl1208: Add isl1208_set_xtoscb() Biju Das
2023-06-05 11:52   ` Geert Uytterhoeven
2023-06-05 12:20     ` Biju Das
2023-06-09  8:08   ` Trent Piepho [this message]
2023-06-09  8:47     ` Biju Das
2023-06-02 14:24 ` [PATCH v6 11/11] rtc: isl1208: Add support for the built-in RTC on the PMIC RAA215300 Biju Das
2023-06-05 11:56   ` Geert Uytterhoeven
2023-06-05 12:22     ` Biju Das
2023-06-05 13:04 ` [PATCH v6 00/11] Add Renesas PMIC RAA215300 and built-in RTC support Alexandre Belloni
2023-06-05 13:09   ` Biju Das
2023-06-05 13:10 ` Mark Brown
2023-06-05 13:27   ` 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=5820492.tdWV9SEqCh@zen.local \
    --to=tpiepho@gmail.com \
    --cc=a.zummo@towertech.it \
    --cc=alexandre.belloni@bootlin.com \
    --cc=biju.das.jz@bp.renesas.com \
    --cc=fabrizio.castro.jz@renesas.com \
    --cc=geert+renesas@glider.be \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux-rtc@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