linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matti Vaittinen <mazziesaccount@gmail.com>
To: Andreas Kemnade <andreas@kemnade.info>
Cc: Lee Jones <lee@kernel.org>,
	Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>,
	Pavel Machek <pavel@kernel.org>, Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Sebastian Reichel <sre@kernel.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Bartosz Golaszewski <brgl@bgdev.pl>,
	linux-leds@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-gpio@vger.kernel.org
Subject: Re: [RFC PATCH 06/13] mfd: bd71828: Support ROHM BD72720
Date: Wed, 15 Oct 2025 10:46:18 +0300	[thread overview]
Message-ID: <07bd2e21-8631-4812-9021-3d3b2dbc7050@gmail.com> (raw)
In-Reply-To: <5ef55577-b8ae-4c8d-a965-ee356c47c691@gmail.com>

On 14/10/2025 08:41, Matti Vaittinen wrote:
> On 13/10/2025 16:19, Andreas Kemnade wrote:
>> On Mon, 13 Oct 2025 12:27:33 +0300
>> Matti Vaittinen <mazziesaccount@gmail.com> wrote:
>>
>>> Hi Andreas!
>>>
>>> First of all, thanks for taking a look at this!
>>>
>>> On 10/10/2025 16:03, Andreas Kemnade wrote:
>>>> On Fri, 10 Oct 2025 15:09:07 +0300
>>>> Matti Vaittinen <mazziesaccount@gmail.com> wrote:
>>>>>>> +static int bd72720_get_secondary_regmap(struct i2c_client *i2c,
>>>>>>
>>>>>> Does this 'secondary' have a specific purpose or a better name?
>>>>>
>>>>> I am not entirely sure. When I asked this from the designers they just
>>>>> told me that they needed more than 255 registers so they added another
>>>>> slave address... (I'm not sure what would have been wrong with using a
>>>>> page register). So, I assume they just placed stuff that didn't fit in
>>>>> first 255 register there. But yeah, it looks like most of the 
>>>>> registers
>>>>> there are related to the charger. So, perhaps it isn't completely
>>>>> misleading to use "charger regmap"? The data-sheet seems to be just
>>>>> using "Register map 1" and "Register map 2" in the tables listing 
>>>>> these
>>>>> registers. I kind of like using something which maps easily to the
>>>>> data-sheet, but I really have no strong opinion on this.
>>>>
>>>> just another idea: What about one regmap with custom functions covering
>>>> both these adresses? Maybe that could even be added to the regmap
>>>> functionality, maybe with a 0x100 offset for the second range.
>>>> That way the rest of the code only needs to real with one regmap
>>>> and properly defined registers.
>>>
>>> Interesting idea.
>>>
>>> I suppose you mean something like implementing custom remap_read() and
>>> regmap_write() - which would practically select the I2C adapter to use
>>> based on the register address - and then doing same thing as the
>>> regmap_i2c_smbus_i2c_write() / regmap_i2c_smbus_i2c_read() do?
>>>
>>> I suppose this would mean duplicating the functionality provided by the
>>> regmap_i2c_smbus_i2c_write() and the regmap_i2c_smbus_i2c_read(), which
>>> are static. It'd also mean we'll lose the 1 to 1 mapping between the
>>> register addresses in driver and addresses in the data-sheet. I agree
>>> this wouldn't be such a huge thing if we used offset like 0x100 though.
>>>
>> Well, you could also stack regmaps like ntxec.c is doing (but there
>> for some very weird reason). That would avoid duplicating code.
> 
// snip
> 
> If this works, then I kind of like this. It avoids using the platform 
> data and simplifies the regmap getting in the power_supply driver. 
> Thanks for the good idea Andreas!

Hmm. This morning I tested this approach. I converted the MFD driver and 
some sub-devices, and I mostly liked it. Mostly.

When adding the offset only to the addresses behind the 'secondary 
slave', the addresses behind the 'real slave' (which the MFD driver is 
bound), can be accessed using both the 'wrapper' and the 'real' regmap. 
Assuming the cache is kept in the 'real' regmaps. This is a small 
performance penalty compared to having the cache already in the wrapper, 
but it allows the drivers like the regulator driver, which only use the 
'primary slave' to just get a regmap from the MFD parent, no matter 
whether they get the 'wrapper' of the 'real' one. So, no deviation in 
these slave devices - nice.

MFD gains a tad more complexity due to the additional wrapper regmap. 
That's not bad though. MFD also needs to use the 'unwrapped' register 
addresses for the slave regmap config (ranges and max register). This 
won't get extremely ugly though as we can do some simple macros for 
'unwrapping'.

What I do dislike is the fact that the register addresses for the 
secondary slave will now be 9 bits. This will require some modifications 
in the power-supply driver, which currently stores the addresses using 
u8. The register values can still be 8-bits though, so maybe it won't 
get that bad. I haven't tested this yet.

As a result, I am not entirely convinced, but not totally against this 
idea either.

I'll be away for a bit more than a week, starting from Friday, so it may 
be I won't spin the next version until around the last days of the October.

Yours,
	-- Matti.

  reply	other threads:[~2025-10-15  7:46 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-07  8:32 [RFC PATCH 00/13] Support ROHM BD72720 PMIC Matti Vaittinen
2025-10-07  8:32 ` [RFC PATCH 01/13] dt-bindings: regulator: ROHM BD72720 Matti Vaittinen
2025-10-07  8:33 ` [RFC PATCH 02/13] dt-bindings: Add trickle-charge upper limit Matti Vaittinen
2025-10-13 12:31   ` Linus Walleij
2025-10-07  8:33 ` [RFC PATCH 03/13] dt-bindings: power: supply: BD72720 managed battery Matti Vaittinen
2025-10-13 12:45   ` Linus Walleij
2025-10-13 13:00     ` Matti Vaittinen
2025-10-14 10:29       ` Linus Walleij
2025-10-07  8:33 ` [RFC PATCH 04/13] dt-bindings: mfd: ROHM BD72720 Matti Vaittinen
2025-10-13 12:58   ` Linus Walleij
2025-10-14 12:11     ` Matti Vaittinen
2025-10-14 12:58       ` Linus Walleij
2025-10-07  8:33 ` [RFC PATCH 05/13] dt-bindings: leds: bd72720: Add BD72720 Matti Vaittinen
2025-10-07  8:33 ` [RFC PATCH 06/13] mfd: bd71828: Support ROHM BD72720 Matti Vaittinen
2025-10-09 16:18   ` Lee Jones
2025-10-10 12:09     ` Matti Vaittinen
2025-10-10 13:03       ` Andreas Kemnade
2025-10-13  9:27         ` Matti Vaittinen
2025-10-13 13:19           ` Andreas Kemnade
2025-10-14  5:41             ` Matti Vaittinen
2025-10-15  7:46               ` Matti Vaittinen [this message]
2025-10-10 14:45       ` Lee Jones
2025-10-13 12:28         ` Matti Vaittinen
2025-10-16 15:27           ` Lee Jones
2025-10-07  8:34 ` [RFC PATCH 07/13] regulator: bd71828: rename IC specific entities Matti Vaittinen
2025-10-07  8:34 ` [RFC PATCH 08/13] regulator: bd71828: Support ROHM BD72720 Matti Vaittinen
2025-10-07  8:34 ` [RFC PATCH 09/13] gpio: Support ROHM BD72720 gpios Matti Vaittinen
2025-10-13 12:54   ` Linus Walleij
2025-10-16 11:04   ` Bartosz Golaszewski
2025-10-07  8:34 ` [RFC PATCH 10/13] clk: clk-bd718x7: Support BD72720 clk gate Matti Vaittinen
2025-10-07  8:34 ` [RFC PATCH 11/13] rtc: bd70528: Support BD72720 rtc Matti Vaittinen
2025-10-07  8:35 ` [RFC PATCH 12/13] power: supply: bd71828-power: Support ROHM BD72720 Matti Vaittinen
2025-10-07  8:35 ` [RFC PATCH 13/13] MAINTAINERS: Add ROHM BD72720 PMIC Matti Vaittinen

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=07bd2e21-8631-4812-9021-3d3b2dbc7050@gmail.com \
    --to=mazziesaccount@gmail.com \
    --cc=andreas@kemnade.info \
    --cc=brgl@bgdev.pl \
    --cc=broonie@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=lee@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=matti.vaittinen@fi.rohmeurope.com \
    --cc=pavel@kernel.org \
    --cc=robh@kernel.org \
    --cc=sre@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;
as well as URLs for NNTP newsgroup(s).