From: Andrej Picej <andrej.picej@norik.com>
To: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: a.zummo@towertech.it, linux-rtc@vger.kernel.org,
linux-kernel@vger.kernel.org, upstream@phytec.de
Subject: Re: [PATCH] rtc: rv3028: Improve trickle charger logic
Date: Thu, 15 Jun 2023 08:06:29 +0200 [thread overview]
Message-ID: <31ed2ed3-8b59-3903-c491-a10a4702c23d@norik.com> (raw)
In-Reply-To: <73bc2f5c-bdae-e57f-73ab-db5e453e0c7f@norik.com>
On 8. 06. 23 12:35, Andrej Picej wrote:
> Hi Alexandre,
>
> On 8. 06. 23 11:31, Alexandre Belloni wrote:
>> Hello,
>>
>> On 08/06/2023 11:04:46+0200, Andrej Picej wrote:
>>> + ret = regmap_read(rv3028->regmap, RV3028_BACKUP, &val_old);
>>> + if (ret < 0)
>>> + return ret;
>>> +
>>> + /* mask out only trickle charger bits */
>>> + val_old = val_old & (RV3028_BACKUP_TCE | RV3028_BACKUP_TCR_MASK);
>>> +
>>> /* setup trickle charger */
>>> - if (!device_property_read_u32(&client->dev,
>>> "trickle-resistor-ohms",
>>> - &ohms)) {
>>> + if (device_property_read_u32(&client->dev,
>>> "trickle-resistor-ohms", &ohms)) {
>>> + /* disable the trickle charger */
>>> + val = 0;
>>
>> You can't do that, this will break existing users that may set the
>> trickle charger from their bootloader for example.
>
> hmm...ok I understand that idea. I thought that might be a problem. I
> guess keeping default as it is has a higher priority.
>
> What do you say if setting this property to 0 (or maybe -1) disabled the
> trickle charger?
> So if users add:
>
> trickle-resistor-ohms = <0>;
> or
> trickle-resistor-ohms = <(-1)>;
>
> this would mean disable the trickle charger?
>
> I know it is far from optimal, but this would solve both things:
> * not braking existing implementation,
> * users could disable the trickle charger.
>
> What do you say.
Gentle ping. Would this be something you would consider?
Thanks,
Andrej
>
> Thanks for your review.
>
> Best regards,
> Andrej
>
>>
>>> + } else {
>>> int i;
>>> for (i = 0; i < ARRAY_SIZE(rv3028_trickle_resistors); i++)
>>> @@ -947,15 +957,21 @@ static int rv3028_probe(struct i2c_client *client)
>>> break;
>>> if (i < ARRAY_SIZE(rv3028_trickle_resistors)) {
>>> - ret = rv3028_update_cfg(rv3028, RV3028_BACKUP,
>>> RV3028_BACKUP_TCE |
>>> - RV3028_BACKUP_TCR_MASK, RV3028_BACKUP_TCE |
>>> i);
>>> - if (ret)
>>> - return ret;
>>> + /* enable the trickle charger and setup its resistor
>>> accordingly */
>>> + val = RV3028_BACKUP_TCE | i;
>>> } else {
>>> dev_warn(&client->dev, "invalid trickle resistor
>>> value\n");
>>> }
>>> }
>>> + /* only update EEPROM if changes are necessary */
>>> + if (val_old != val) {
>>> + ret = rv3028_update_cfg(rv3028, RV3028_BACKUP,
>>> RV3028_BACKUP_TCE |
>>> + RV3028_BACKUP_TCR_MASK, val);
>>> + if (ret)
>>> + return ret;
>>> + }
>>> +
>>> ret = rtc_add_group(rv3028->rtc, &rv3028_attr_group);
>>> if (ret)
>>> return ret;
>>> --
>>> 2.25.1
>>>
>>
next prev parent reply other threads:[~2023-06-15 6:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-08 9:04 Andrej Picej
2023-06-08 9:31 ` Alexandre Belloni
2023-06-08 10:35 ` Andrej Picej
2023-06-15 6:06 ` Andrej Picej [this message]
2023-06-08 14:48 ` kernel test robot
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=31ed2ed3-8b59-3903-c491-a10a4702c23d@norik.com \
--to=andrej.picej@norik.com \
--cc=a.zummo@towertech.it \
--cc=alexandre.belloni@bootlin.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=upstream@phytec.de \
/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®