From: Matti Vaittinen <mazziesaccount@gmail.com>
To: Marek Vasut <marex@denx.de>, linux-iio@vger.kernel.org
Cc: Alexander Stein <alexander.stein@ew.tq-group.com>,
Andre Werner <andre.werner@systec-electronic.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Bjorn Helgaas <bhelgaas@google.com>,
Conor Dooley <conor+dt@kernel.org>,
Fabio Estevam <festevam@denx.de>,
Guenter Roeck <linux@roeck-us.net>,
Jonathan Cameron <jic23@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Lars-Peter Clausen <lars@metafoo.de>,
Luca Ceresoli <luca.ceresoli@bootlin.com>,
Mark Brown <broonie@kernel.org>,
Naresh Solanki <naresh.solanki@9elements.com>,
Patrick Rudolph <patrick.rudolph@9elements.com>,
Rob Herring <robh+dt@kernel.org>,
Stefan Windfeldt-Prytz <stefan.windfeldt-prytz@axis.com>,
Vincent Tremblay <vincent@vtremblay.dev>,
devicetree@vger.kernel.org
Subject: Re: [PATCH v4 2/2] iio: light: isl76682: Add ISL76682 driver
Date: Thu, 23 Nov 2023 09:24:42 +0200 [thread overview]
Message-ID: <4a39aff2-bb1a-447c-8c33-8bfad06777e3@gmail.com> (raw)
In-Reply-To: <cd21c72f-d9ff-471d-a08d-9b67bf180950@denx.de>
On 11/23/23 02:26, Marek Vasut wrote:
> On 11/22/23 13:17, Matti Vaittinen wrote:
>> On 11/21/23 05:10, Marek Vasut wrote:
>>> The ISL76682 is very basic ALS which only supports ALS or IR mode
>>> in four ranges, 1k/4k/16k/64k LUX. There is no IRQ support or any
>>> other fancy functionality.
>>>
>>> Signed-off-by: Marek Vasut <marex@denx.de>
>>> ---
...
>>
>> I like this table-based look-up for write (and read) of scales.
>> Looking at this I see an analogy to some of the regulator stuff, like
>> for example the ramp-up values. What I do very much like in the
>> regulator subsystem is the drivers/regulator/helpers.c
>>
>> I wonder if similar approach would be usable in IIO as well? I mean,
>> providing readily written iio_regmap_read/write_raw_<functionality>()
>> and iio_available_*() helpers for the simple devices where we just
>> have value-register mapping? I mean, driver would just populate
>> something like:
>>
>> struct iio_scale_desc {
>> int *scale_val_table;
>> int *scale_val2_table;
>> int num_scales;
>
> You'd also need type here (fractional, int+micro, ...), right ?
Well, my thinking was to go with baby-steps. Eg, start by supporting
just int+micro - but yes. As I wrote below, this can be expanded by
allowing specifying the type.
>> int scale_reg_addr;
>> int scale_reg_mask;
>> };
>>
>> and call helper like
>> int iio_regmap_read_raw_scale(struct iio_dev *idev,
>> struct iio_scale_desc *sd, int *val,
>> int *val2)"
>> provided by IIO framework.
>>
>> Similar helper for writing new scales and getting available scales.
>>
>> Later this could be expanded by allowing specifying the type of
>> provided values (in the example case, IIO_VAL_INT_PLUS_x - but maybe
>> this would be extensible (and worth) to support also the other options?)
>>
>> I know it's a bit much to be done in the context of this series. Hence
>> I am definitely not insisting this to be done here! OTOH, the embedded
>> Linux is not in EU next year so maybe Marek would forgive me before we
>> meet next time :pondering:
>
> toffee-- forgive++ , hehehe , no worries.
At least I know what I need to pack in the suitcase! ;) Oh, by the way,
the wafers were great!
>> Anyways - does this sound like a sensible thing to do? I guess it
>> could help simplifying some drivers a little.
>
> The only thing I would wonder about is, should such a thing go into
> regmap so it can be reused cross-subsystem instead of making this iio
> specific ?
I definitely think a relation "register value" <=> "item from a table"
is very much used also outside the IIO. So yes, a generic regmap helper
for doing write as a "look value from table and write corresponding
value to a register" and "read value from register and return me a
corresponding item from a table" would be very usable.
There is a tradeoff when doing a generic one instead of making it
targeted for IIO use. Supporting different types of data is likely to
make the code a bit hairy. Also, the IIO way of having these IIO_VAL_*
flags does probably require IIO - specific wrappers in any case.
>> Oh. Only after writing of this I noticed the range is written in HW
>> only together with the 'start' command. I guess this is how the IC
>> operates -
>
> The IC is just simple, a few bits in command register to control it and
> nothing fancy, so it is just easier to write the 8 bits at a time
> instead of doing RMW .
>
>> you need to write all configs together with starting the measurement?
>> Or is that just an optimization to avoid extra writes? If it's the
>> first, then a suggested iio_regmap_*() -helper wouldn't work here. I
>> might've added a comment explaining why range is written in
>> isl76682_get() and not here to the isl76682_get().
>
> It is just easier and cheaper to write it all at once instead of RMW .
> It also isn't like RMW would win anything here, rather the opposite.
Yep. Kind of makes sense. It's just me who is already used to see the
regmap writes straight in the scale setting function - and RMW provided
by regmap is really pretty simple when regmap lock is used. But this is
very much Ok for me just like you wrote it.
Yours,
-- Matti
--
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland
~~ When things go utterly wrong vim users can always type :help! ~~
next prev parent reply other threads:[~2023-11-23 7:24 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-21 3:10 [PATCH v4 1/2] dt-bindings: iio: light: isl76682: Document ISL76682 Marek Vasut
2023-11-21 3:10 ` [PATCH v4 2/2] iio: light: isl76682: Add ISL76682 driver Marek Vasut
2023-11-21 18:09 ` Andy Shevchenko
2023-11-22 0:06 ` Marek Vasut
2023-11-22 12:17 ` Matti Vaittinen
2023-11-23 0:26 ` Marek Vasut
2023-11-23 7:24 ` Matti Vaittinen [this message]
2023-12-15 12:06 ` Matti Vaittinen
2023-12-17 13:06 ` Jonathan Cameron
2023-12-18 9:36 ` Matti Vaittinen
2023-11-25 18:06 ` Jonathan Cameron
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=4a39aff2-bb1a-447c-8c33-8bfad06777e3@gmail.com \
--to=mazziesaccount@gmail.com \
--cc=alexander.stein@ew.tq-group.com \
--cc=andre.werner@systec-electronic.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=bhelgaas@google.com \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=festevam@denx.de \
--cc=jic23@kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=luca.ceresoli@bootlin.com \
--cc=marex@denx.de \
--cc=naresh.solanki@9elements.com \
--cc=patrick.rudolph@9elements.com \
--cc=robh+dt@kernel.org \
--cc=stefan.windfeldt-prytz@axis.com \
--cc=vincent@vtremblay.dev \
/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).