iio: light: opt3001: add support for TI's opt3002 light sensor
Subsystems (2)
v4 cover iio: light: opt3001: add support for TI's opt3002 light sensor
TI's opt3002 light-to-digital sensor provides the functionality of an optical power meter within a single device. It shares a lot of similarities with their opt3001 model but has a wide spectral bandwidth, ranging from 300 nm to 1000 nm.
This patch set adds support for the TI opt3002 by extending the opt3001 driver. In addition, a missing full-scale range value for the opt3001 is added, resulting in higher precision when setting event trigger values.
Datasheet: http://www.ti.com/product/OPT3002
---
Changes in v4:
- Drop applied patch: "iio: light: opt3001: add missing full-scale range value"
- Add num_channels field to opt3001_chip_info
- Use i2c_get_match_data() instead of device_get_match_data()
- Link to v3: https://lore.kernel.org/r/[email protected]
Changes in v3:
- Include difference between opt3001 and opt3002 in commit message for dt-binding patch.
- Remove whitespace between tags in commit message for opt3002 patch.
- Rename opt300x_chip_info to opt3001_chip_info.
- Add documentation for mathematical constants in opt3001_chip_info.
- Only check return value after opt3001_read_id if chip has id register in opt3001_probe.
- Change opt3002 channel mask to IIO_CHAN_INFO_RAW.
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Move dt-binding patch to before implementation.
- Fix dt-binding compatible definition.
- Clarify bug description for missing full-scale range value.
- Remove model enum from chip info and all in-function switch-case statements.
- Move model-specific channels and mathematic constants to chip info.
- Add valid match data to opt3001_id array
- Skip call to function opt3001_read_id() if model doesn't have a device id register.
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Emil Gedenryd (2):
dt-bindings: iio: light: opt3001: add compatible for opt3002
iio: light: opt3001: add support for TI's opt3002 light sensor
.../devicetree/bindings/iio/light/ti,opt3001.yaml | 4 +- drivers/iio/light/Kconfig | 2 +- drivers/iio/light/opt3001.c | 189 +++++++++++++++++---- 3 files changed, 160 insertions(+), 35 deletions(-)
---
base-commit: e2df62bb0fadc8ae16aa3bb88ee05ee7e037046b
change-id: 20240828-add_opt3002-40552c1a2f77
Best regards,
Signature · 1 line
Emil Gedenryd <[email protected]>
PATCH v4 1/2 dt-bindings: iio: light: opt3001: add compatible for opt3002
The opt3002 is a Light-to-Digital Sensor by TI with support for wide-range spectrum light. It shares most properties with their opt3001 model with the exception of having a wide spectral bandwidth, ranging from 300 nm to 1000 nm.
Add the compatible string of opt3002.
--- Documentation/devicetree/bindings/iio/light/ti,opt3001.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/iio/light/ti,opt3001.yaml +3 -1
@@ -15,7 +15,9 @@ description: | properties: compatible: - const: ti,opt3001 + enum: + - ti,opt3001 + - ti,opt3002 reg: maxItems: 1
Signature · 1 line
2.39.2
PATCH v4 2/2 iio: light: opt3001: add support for TI's opt3002 light sensor
In reply to Emil GedenrydTI's opt3002 light sensor shares most properties with the opt3001 model, with the exception of supporting a wider spectrum range.
Add support for TI's opt3002 by extending the TI opt3001 driver.
Datasheet: https://www.ti.com/product/OPT3002
--- drivers/iio/light/Kconfig | 2 +- drivers/iio/light/opt3001.c | 189 ++++++++++++++++++++++++++++++++++++-------- 2 files changed, 157 insertions(+), 34 deletions(-)
drivers/iio/light/Kconfig +1 -1
@@ -461,7 +461,7 @@ config OPT3001 depends on I2C help If you say Y or M here, you get support for Texas Instruments - OPT3001 Ambient Light Sensor. + OPT3001 Ambient Light Sensor, OPT3002 Light-to-Digital Sensor. If built as a dynamically linked module, it will be called opt3001.
drivers/iio/light/opt3001.c +156 -33
314 lines not on this page · raw message
Signature · 1 line
2.39.2
Jonathan Cameron
maintainerQuoted 34 lines · On Thu, 3 Oct 2024 14:22:17 +0200 Emil Gedenryd <[email protected]> wrote:
TI's opt3002 light sensor shares most properties with the opt3001 model, with the exception of supporting a wider spectrum range.
Add support for TI's opt3002 by extending the TI opt3001 driver.
Datasheet: https://www.ti.com/product/OPT3002
Signed-off-by Emil Gedenryd <[email protected]>--- drivers/iio/light/Kconfig | 2 +- drivers/iio/light/opt3001.c | 189 ++++++++++++++++++++++++++++++++++++-------- 2 files changed, 157 insertions(+), 34 deletions(-)drivers/iio/light/Kconfig +1
-1@@ -461,7 +461,7 @@ config OPT3001 depends on I2C help If you say Y or M here, you get support for Texas Instruments - OPT3001 Ambient Light Sensor. + OPT3001 Ambient Light Sensor, OPT3002 Light-to-Digital Sensor. If built as a dynamically linked module, it will be called opt3001.drivers/iio/light/opt3001.c +1
-0@@ -70,6 +70,35 @@#define OPT3001_RESULT_READY_SHORT 150#define OPT3001_RESULT_READY_LONG 1000 +struct opt3001_scale {
drivers/iio/light/opt3001.c line 83
Quoted 10 lines
drivers/iio/light/opt3001.c +10
-0+int val; +int val2; +}; + +struct opt3001_chip_info { +const struct iio_chan_spec (*channels)[2 ]; +enum iio_chan_type chan_type; +int num_channels; + +const struct opt3001_scale (*scales)[12 ];
This doesn't compile for me as one of the two options only has 11 entries. You could either force them to be 12 entries each or use a pointer without the size and add a num_scales entry in here.
Jonathan
Quoted 14 lines · Jonathan Cameron
drivers/iio/light/opt3001.c line 83
Quoted 7 lines · On Thu, 3 Oct 2024 14:22:17 +0200 Emil Gedenryd <[email protected]> wrote:
drivers/iio/light/opt3001.c +6
-0+struct opt3001_chip_info { +const struct iio_chan_spec (*channels)[2 ]; +enum iio_chan_type chan_type; +int num_channels; + +const struct opt3001_scale (*scales)[12 ];This doesn't compile for me as one of the two options only has 11 entries. You could either force them to be 12 entries each or use a pointer without the size and add a
num_scalesentry in here.
Quoted 1 line
Jonathan
Hi Jonathan,
Are you building on top of the patch that was accepted in earlier versions of this patch set? That patch adds the twelfth missing scale value for the opt3001. See: https://lore.kernel.org/all/[email protected]/
Should I have added some tag to highlight the dependency for this version of the patch set?
Best regards,
Emil
Jonathan Cameron
maintainerQuoted 17 lines · On Mon, 7 Oct 2024 07:19:06 +0000 Emil Gedenryd <[email protected]> wrote:
Quoted 14 lines · Jonathan Cameron
drivers/iio/light/opt3001.c line 83
Quoted 7 lines · On Thu, 3 Oct 2024 14:22:17 +0200 Emil Gedenryd <[email protected]> wrote:
drivers/iio/light/opt3001.c +6
-0+struct opt3001_chip_info { +const struct iio_chan_spec (*channels)[2 ]; +enum iio_chan_type chan_type; +int num_channels; + +const struct opt3001_scale (*scales)[12 ];This doesn't compile for me as one of the two options only has 11 entries. You could either force them to be 12 entries each or use a pointer without the size and add a
num_scalesentry in here.Quoted 1 line
Jonathan
Quoted 8 lines
Hi Jonathan,
Are you building on top of the patch that was accepted in earlier versions of this patch set? That patch adds the twelfth missing scale value for the opt3001. See: https://lore.kernel.org/all/[email protected]/
Should I have added some tag to highlight the dependency for this version of the patch set?
Ah. Yes, I was half asleep.
They are going via different branches (slow and fast) so I'll have to sit on this series until after that fix is in the upstream for the togreg branch of iio.git.
If I seem to have lost it after that is the case feel free to give me a poke.
Jonathan
Quoted 3 lines
Best regards,
Emil
Quoted 28 lines · Jonathan Cameron
Quoted 17 lines · On Mon, 7 Oct 2024 07:19:06 +0000 Emil Gedenryd <[email protected]> wrote:
Quoted 14 lines · Jonathan Cameron
drivers/iio/light/opt3001.c line 83
Quoted 7 lines · On Thu, 3 Oct 2024 14:22:17 +0200 Emil Gedenryd <[email protected]> wrote:
drivers/iio/light/opt3001.c +6
-0+struct opt3001_chip_info { +const struct iio_chan_spec (*channels)[2 ]; +enum iio_chan_type chan_type; +int num_channels; + +const struct opt3001_scale (*scales)[12 ];This doesn't compile for me as one of the two options only has 11 entries. You could either force them to be 12 entries each or use a pointer without the size and add a
num_scalesentry in here.Quoted 1 line
Jonathan
Quoted 8 lines
Hi Jonathan,
Are you building on top of the patch that was accepted in earlier versions of this patch set? That patch adds the twelfth missing scale value for the opt3001. See: https://lore.kernel.org/all/[email protected]/
Should I have added some tag to highlight the dependency for this version of the patch set?
Quoted 9 lines
Ah. Yes, I was half asleep.
They are going via different branches (slow and fast) so I'll have to sit on this series until after that fix is in the upstream for the togreg branch of iio.git.If I seem to have lost it after that is the case feel free to give me a poke.
Jonathan
Hi,
No worries. Just to clarify, do you mean sit on it as that you will continue reviewing the code after the fix is in upstream, or should I consider this patch to be approved?
Also, do you have an approximation of what time frame we're talking about?
Best Regards,
Emil
Jonathan Cameron
maintainerQuoted 34 lines · On Fri, 11 Oct 2024 07:12:05 +0000 Emil Gedenryd <[email protected]> wrote:
Quoted 33 lines · Jonathan Cameron
Quoted 17 lines · On Mon, 7 Oct 2024 07:19:06 +0000 Emil Gedenryd <[email protected]> wrote:
Quoted 14 lines · Jonathan Cameron
drivers/iio/light/opt3001.c line 83
Quoted 7 lines · On Thu, 3 Oct 2024 14:22:17 +0200 Emil Gedenryd <[email protected]> wrote:
drivers/iio/light/opt3001.c +6
-0+struct opt3001_chip_info { +const struct iio_chan_spec (*channels)[2 ]; +enum iio_chan_type chan_type; +int num_channels; + +const struct opt3001_scale (*scales)[12 ];This doesn't compile for me as one of the two options only has 11 entries. You could either force them to be 12 entries each or use a pointer without the size and add a
num_scalesentry in here.Quoted 1 line
Jonathan
Quoted 8 lines
Hi Jonathan,
Are you building on top of the patch that was accepted in earlier versions of this patch set? That patch adds the twelfth missing scale value for the opt3001. See: https://lore.kernel.org/all/[email protected]/
Should I have added some tag to highlight the dependency for this version of the patch set?
Ah. Yes, I was half asleep.
They are going via different branches (slow and fast) so I'll have to sit on this series until after that fix is in the upstream for the togreg branch of iio.git.
Quoted 8 lines
Quoted 4 lines
If I seem to have lost it after that is the case feel free to give me a poke.
Jonathan
Hi,
No worries. Just to clarify, do you mean sit on it as that you will continue reviewing the code after the fix is in upstream, or should I consider this patch to be approved?
Assuming not other review comes in, I consider this ready to go.
Quoted 2 lines
Also, do you have an approximation of what time frame we're talking about?
2 weeks most likely.
I've just sent Greg KH a pull request with the fix in it. He will hopefully pick that up and then send a pull request on to Linus. Then we wait for the next rc after that at which point Greg will probably pull it into char-misc-next or I can always merge it into my togreg branch once it is in a release candidate of Linus' tree.
In parallel with that I'll probably do a pull request for what is already in the togreg tree to get a lot of stuff in char-misc-next for the next cycle. That makes the history a little cleaner as I can fast forward my tree and end up with whatever is in char-misc-next (hopefully including this).
Anyhow, a bit of tree juggling for me, but we have plenty of time as rc3 will probably be out tomorrow and it normally goes to rc7 at one rc a week
Thanks,
Jonathan
Quoted 3 lines
Best Regards,
Emil
Quoted 39 lines · Jonathan Cameron
Quoted 36 lines · On Fri, 11 Oct 2024 07:12:05 +0000 Emil Gedenryd <[email protected]> wrote:
Quoted 35 lines · Jonathan Cameron
Quoted 17 lines · On Mon, 7 Oct 2024 07:19:06 +0000 Emil Gedenryd <[email protected]> wrote:
Quoted 14 lines · Jonathan Cameron
drivers/iio/light/opt3001.c line 83
Quoted 7 lines · On Thu, 3 Oct 2024 14:22:17 +0200 Emil Gedenryd <[email protected]> wrote:
drivers/iio/light/opt3001.c +6
-0+struct opt3001_chip_info { +const struct iio_chan_spec (*channels)[2 ]; +enum iio_chan_type chan_type; +int num_channels; + +const struct opt3001_scale (*scales)[12 ];This doesn't compile for me as one of the two options only has 11 entries. You could either force them to be 12 entries each or use a pointer without the size and add a
num_scalesentry in here.Quoted 1 line
Jonathan
Quoted 8 lines
Hi Jonathan,
Are you building on top of the patch that was accepted in earlier versions of this patch set? That patch adds the twelfth missing scale value for the opt3001. See: https://lore.kernel.org/all/[email protected]/
Should I have added some tag to highlight the dependency for this version of the patch set?
Ah. Yes, I was half asleep.
They are going via different branches (slow and fast) so I'll have to sit on this series until after that fix is in the upstream for the togreg branch of iio.git.If I seem to have lost it after that is the case feel free to give me a poke.
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
Jonathan
Hi,
No worries. Just to clarify, do you mean sit on it as that you will continue reviewing the code after the fix is in upstream, or should I consider this patch to be approved?
Assuming not other review comes in, I consider this ready to go.
Great, thank you!
Quoted 10 lines
Quoted 2 lines
Also, do you have an approximation of what time frame we're talking about?
2 weeks most likely.
I've just sent Greg KH a pull request with the fix in it. He will hopefully pick that up and then send a pull request on to Linus. Then we wait for the next rc after that at which point Greg will probably pull it into char-misc-next or I can always merge it into my togreg branch once it is in a release candidate of Linus' tree.
Quoted 7 lines
In parallel with that I'll probably do a pull request for what is already in the togreg tree to get a lot of stuff in char-misc-next for the next cycle. That makes the history a little cleaner as I can fast forward my tree and end up with whatever is in char-misc-next (hopefully including this).
Anyhow, a bit of tree juggling for me, but we have plenty of time as rc3 will probably be out tomorrow and it normally goes to rc7 at one rc a week
Thank you for the information and for the help during the review process for this patch. Best regards,
Emil
Quoted 8 lines
Thanks,
Jonathan
Quoted 3 lines
Best Regards,
Emil
Jonathan Cameron
maintainerQuoted 65 lines · On Mon, 14 Oct 2024 06:18:29 +0000 Emil Gedenryd <[email protected]> wrote:
Quoted 39 lines · Jonathan Cameron
Quoted 36 lines · On Fri, 11 Oct 2024 07:12:05 +0000 Emil Gedenryd <[email protected]> wrote:
Quoted 35 lines · Jonathan Cameron
Quoted 17 lines · On Mon, 7 Oct 2024 07:19:06 +0000 Emil Gedenryd <[email protected]> wrote:
Quoted 14 lines · Jonathan Cameron
Review
Quoted 7 lines · On Thu, 3 Oct 2024 14:22:17 +0200 Emil Gedenryd <[email protected]> wrote:
(quoted diff) +6
-0+struct opt3001_chip_info { + const struct iio_chan_spec (*channels)[2]; + enum iio_chan_type chan_type; + int num_channels; + + const struct opt3001_scale (*scales)[12];This doesn't compile for me as one of the two options only has 11 entries. You could either force them to be 12 entries each or use a pointer without the size and add a
num_scalesentry in here.Quoted 1 line
Jonathan
Quoted 8 lines
Hi Jonathan,
Are you building on top of the patch that was accepted in earlier versions of this patch set? That patch adds the twelfth missing scale value for the opt3001. See: https://lore.kernel.org/all/[email protected]/
Should I have added some tag to highlight the dependency for this version of the patch set?
Ah. Yes, I was half asleep.
They are going via different branches (slow and fast) so I'll have to sit on this series until after that fix is in the upstream for the togreg branch of iio.git.If I seem to have lost it after that is the case feel free to give me a poke.
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
Jonathan
Hi,
No worries. Just to clarify, do you mean sit on it as that you will continue reviewing the code after the fix is in upstream, or should I consider this patch to be approved?
Assuming not other review comes in, I consider this ready to go.
Great, thank you!
Quoted 15 lines
Quoted 2 lines
Also, do you have an approximation of what time frame we're talking about?
2 weeks most likely.
I've just sent Greg KH a pull request with the fix in it. He will hopefully pick that up and then send a pull request on to Linus. Then we wait for the next rc after that at which point Greg will probably pull it into char-misc-next or I can always merge it into my togreg branch once it is in a release candidate of Linus' tree.
In parallel with that I'll probably do a pull request for what is already in the togreg tree to get a lot of stuff in char-misc-next for the next cycle. That makes the history a little cleaner as I can fast forward my tree and end up with whatever is in char-misc-next (hopefully including this).
Quoted 6 lines
Quoted 2 lines
Anyhow, a bit of tree juggling for me, but we have plenty of time as rc3 will probably be out tomorrow and it normally goes to rc7 at one rc a week
Thank you for the information and for the help during the review process for this patch. Best regards,
Emil
Applied to the togreg branch of iio.git and pushed out initially as testing to let the build bots see if they can find anything we missed.
I'll push it out for linux-next to pick up in a few days.
Jonathan
Quoted 9 lines
Quoted 8 lines
Thanks,
Jonathan
Quoted 3 lines
Best Regards,
Emil
Quoted 75 lines · Jonathan Cameron
Quoted 65 lines · On Mon, 14 Oct 2024 06:18:29 +0000 Emil Gedenryd <[email protected]> wrote:
Quoted 39 lines · Jonathan Cameron
Quoted 36 lines · On Fri, 11 Oct 2024 07:12:05 +0000 Emil Gedenryd <[email protected]> wrote:
Quoted 35 lines · Jonathan Cameron
Quoted 17 lines · On Mon, 7 Oct 2024 07:19:06 +0000 Emil Gedenryd <[email protected]> wrote:
Quoted 14 lines · Jonathan Cameron
Review
Quoted 7 lines · On Thu, 3 Oct 2024 14:22:17 +0200 Emil Gedenryd <[email protected]> wrote:
(quoted diff) +6
-0+struct opt3001_chip_info { + const struct iio_chan_spec (*channels)[2]; + enum iio_chan_type chan_type; + int num_channels; + + const struct opt3001_scale (*scales)[12];This doesn't compile for me as one of the two options only has 11 entries. You could either force them to be 12 entries each or use a pointer without the size and add a
num_scalesentry in here.Quoted 1 line
Jonathan
Quoted 8 lines
Hi Jonathan,
Are you building on top of the patch that was accepted in earlier versions of this patch set? That patch adds the twelfth missing scale value for the opt3001. See: https://lore.kernel.org/all/[email protected]/
Should I have added some tag to highlight the dependency for this version of the patch set?
Ah. Yes, I was half asleep.
They are going via different branches (slow and fast) so I'll have to sit on this series until after that fix is in the upstream for the togreg branch of iio.git.If I seem to have lost it after that is the case feel free to give me a poke.
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
Jonathan
Hi,
No worries. Just to clarify, do you mean sit on it as that you will continue reviewing the code after the fix is in upstream, or should I consider this patch to be approved?
Assuming not other review comes in, I consider this ready to go.
Great, thank you!
Quoted 15 lines
Quoted 2 lines
Also, do you have an approximation of what time frame we're talking about?
2 weeks most likely.
I've just sent Greg KH a pull request with the fix in it. He will hopefully pick that up and then send a pull request on to Linus. Then we wait for the next rc after that at which point Greg will probably pull it into char-misc-next or I can always merge it into my togreg branch once it is in a release candidate of Linus' tree.
In parallel with that I'll probably do a pull request for what is already in the togreg tree to get a lot of stuff in char-misc-next for the next cycle. That makes the history a little cleaner as I can fast forward my tree and end up with whatever is in char-misc-next (hopefully including this).
Quoted 6 lines
Quoted 2 lines
Anyhow, a bit of tree juggling for me, but we have plenty of time as rc3 will probably be out tomorrow and it normally goes to rc7 at one rc a week
Thank you for the information and for the help during the review process for this patch. Best regards,
Emil
Quoted 6 lines
Applied to the togreg branch of iio.git and pushed out initially as testing to let the build bots see if they can find anything we missed.
I'll push it out for linux-next to pick up in a few days.
Jonathan
Hi Jonathan, thank you for the update!
Best regards,
Emil
Quoted 11 lines
Quoted 10 lines
Quoted 9 lines
Thanks,
Jonathan
Quoted 3 lines
Best Regards,
Emil