iio: light: Support AMS AS73211 digital XYZ sensor
Subsystems (3)
Christian Eggers
maintainerPATCH 1/1 iio: light: Support AMS AS73211 digital XYZ sensor
This series adds support for the AMS AS73211 digital XYZ sensor.
Christian Eggers
maintainerPATCH 1/2 dt-bindings: iio: light: add AMS AS73211 support
Add DT bindings for AMS AS73211 XYZ True Color Sensor.
--- .../bindings/iio/light/ams,as73211.yaml | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/light/ams,as73211.yaml
Documentation/devicetree/bindings/iio/light/ams,as73211.yaml new file +54 -0
@@ -0,0 +1,54 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/light/as73211.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: AMS AS73211 JENCOLOR(R) Digital XYZ Sensor + +maintainers: + - Christian Eggers <[email protected]> + +description: | + XYZ True Color Sensor with I2C Interface + https://ams.com/documents/20143/36005/AS73211_DS000556_3-01.pdf/a65474c0-b302-c2fd-e30a-c98df87616df + +properties: + compatible: + enum: + - ams,as73211 + + reg: + description: + I2C address of the device (0x74). + maxItems: 1 + + interrupts: + description: + Interrupt specifier for the READY interrupt generated by the device. + maxItems: 1 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + as73211@74 { + compatible = "ams,as73211"; + reg = <0x74>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_color_sensor>; + interrupt-parent = <&gpio2>; + interrupts = <19 IRQ_TYPE_EDGE_RISING>; /* READY */ + }; + }; +...
Signature · 8 lines
Christian Eggers Embedded software developer Arnold & Richter Cine Technik GmbH & Co. Betriebs KG Sitz: Muenchen - Registergericht: Amtsgericht Muenchen - Handelsregisternummer: HRA 57918 Persoenlich haftender Gesellschafter: Arnold & Richter Cine Technik GmbH Sitz: Muenchen - Registergericht: Amtsgericht Muenchen - Handelsregisternummer: HRB 54477 Geschaeftsfuehrer: Dr. Michael Neuhaeuser; Stephan Schenk; Walter Trauninger; Markus Zeiler
Rob Herring
maintainerRe: [PATCH 1/2] dt-bindings: iio: light: add AMS AS73211 support
Quoted 8 lines · Christian Eggers
Add DT bindings for AMS AS73211 XYZ True Color Sensor.
Signed-off-by Christian Eggers <[email protected]>--- .../bindings/iio/light/ams,as73211.yaml | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/light/ams,as73211.yaml
My bot found errors running 'make dt_binding_check' on your patch:
Documentation/devicetree/bindings/iio/light/ams,as73211.yaml: $id: relative path/filename doesn't match actual path or filename
expected: http://devicetree.org/schemas/iio/light/ams,as73211.yaml#
See https://patchwork.ozlabs.org/patch/1337022
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure dt-schema is up to date:
pip3 install git+https://github.com/devicetree-org/dt-schema.git@master --upgrade
Please check and re-submit.
Christian Eggers
maintainerPATCH 2/2 iio: light: as73211: New driver
In reply to Christian EggersSupport for AMS AS73211 JENCOLOR(R) Digital XYZ Sensor.
This driver has no built-in trigger. In order for making triggered measurements, an external (software) trigger driver like iio-trig-hrtimer or iio-trig-sysfs is required.
The sensor supports single and continuous measurement modes. The latter is not used by design as this would require tight timing synchronization between hardware and driver without much benefit.
--- MAINTAINERS | 7 + drivers/iio/light/Kconfig | 15 + drivers/iio/light/Makefile | 1 + drivers/iio/light/as73211.c | 822 ++++++++++++++++++++++++++++++++++++ 4 files changed, 845 insertions(+) create mode 100644 drivers/iio/light/as73211.c
MAINTAINERS +7 -0
@@ -934,6 +934,13 @@ S: Supported F: arch/arm64/boot/dts/amd/amd-seattle-xgbe*.dtsi F: drivers/net/ethernet/amd/xgbe/ +AMS AS73211 DRIVER +M: Christian Eggers <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/iio/light/ams,as73211.yaml +F: drivers/iio/light/as73211.c + ANALOG DEVICES INC AD5686 DRIVER M: Michael Hennerich <[email protected]> L: [email protected]
drivers/iio/light/Kconfig +15 -0
@@ -86,6 +86,21 @@ config APDS9960 To compile this driver as a module, choose M here: the module will be called apds9960 +config AS73211 + tristate "AMS AS73211 XYZ color sensor" + depends on I2C + select IIO_BUFFER + select IIO_TRIGGERED_BUFFER + help + If you say yes here you get support for the AMS AS73211 + JENCOLOR(R) Digital XYZ Sensor. + + For triggered measurements, you will need an additional trigger driver + like IIO_HRTIMER_TRIGGER or IIO_SYSFS_TRIGGER. + + This driver can also be built as a module. If so, the module + will be called as73211. + config BH1750 tristate "ROHM BH1750 ambient light sensor" depends on I2C
drivers/iio/light/Makefile +1 -0
@@ -11,6 +11,7 @@ obj-$(CONFIG_AL3010) += al3010.o obj-$(CONFIG_AL3320A) += al3320a.o obj-$(CONFIG_APDS9300) += apds9300.o obj-$(CONFIG_APDS9960) += apds9960.o +obj-$(CONFIG_AS73211) += as73211.o obj-$(CONFIG_BH1750) += bh1750.o obj-$(CONFIG_BH1780) += bh1780.o obj-$(CONFIG_CM32181) += cm32181.o
drivers/iio/light/as73211.c new file +822 -0
822 lines not on this page · raw message
Signature · 8 lines
Christian Eggers Embedded software developer Arnold & Richter Cine Technik GmbH & Co. Betriebs KG Sitz: Muenchen - Registergericht: Amtsgericht Muenchen - Handelsregisternummer: HRA 57918 Persoenlich haftender Gesellschafter: Arnold & Richter Cine Technik GmbH Sitz: Muenchen - Registergericht: Amtsgericht Muenchen - Handelsregisternummer: HRB 54477 Geschaeftsfuehrer: Dr. Michael Neuhaeuser; Stephan Schenk; Walter Trauninger; Markus Zeiler
kernel test robot
build botRe: [PATCH 2/2] iio: light: as73211: New driver
I love your patch! Perhaps something to improve:
Hi Christian,
I love your patch! Perhaps something to improve:
[auto build test WARNING on iio/togreg]
[also build test WARNING on robh/for-next linux/master linus/master v5.8-rc7 next-20200727] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Christian-Eggers/dt-bindings-iio-light-add-AMS-AS73211-support/20200727-234842 base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg config: sparc64-randconfig-s031-20200728 (attached as .config) compiler: sparc64-linux-gcc (GCC) 9.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.2-94-geb6779f6-dirty
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=sparc64
If you fix the issue, kindly add following tag as appropriate
sparse warnings: (new ones prefixed by >>)
>> drivers/iio/light/as73211.c:473:35: sparse: sparse: cast to restricted __le16 >> drivers/iio/light/as73211.c:473:35: sparse: sparse: cast to restricted __le16 >> drivers/iio/light/as73211.c:473:35: sparse: sparse: cast to restricted __le16 >> drivers/iio/light/as73211.c:473:35: sparse: sparse: cast to restricted __le16
drivers/iio/light/as73211.c:477:43: sparse: sparse: cast to restricted __le16 drivers/iio/light/as73211.c:477:43: sparse: sparse: cast to restricted __le16 drivers/iio/light/as73211.c:477:43: sparse: sparse: cast to restricted __le16 drivers/iio/light/as73211.c:477:43: sparse: sparse: cast to restricted __le16 drivers/iio/light/as73211.c:478:43: sparse: sparse: cast to restricted __le16 drivers/iio/light/as73211.c:478:43: sparse: sparse: cast to restricted __le16 drivers/iio/light/as73211.c:478:43: sparse: sparse: cast to restricted __le16 drivers/iio/light/as73211.c:478:43: sparse: sparse: cast to restricted __le16 drivers/iio/light/as73211.c:479:43: sparse: sparse: cast to restricted __le16 drivers/iio/light/as73211.c:479:43: sparse: sparse: cast to restricted __le16 drivers/iio/light/as73211.c:479:43: sparse: sparse: cast to restricted __le16 drivers/iio/light/as73211.c:479:43: sparse: sparse: cast to restricted __le16 drivers/iio/light/as73211.c:498:43: sparse: sparse: cast to restricted __le16 drivers/iio/light/as73211.c:498:43: sparse: sparse: cast to restricted __le16 drivers/iio/light/as73211.c:498:43: sparse: sparse: cast to restricted __le16 drivers/iio/light/as73211.c:498:43: sparse: sparse: cast to restricted __le16 drivers/iio/light/as73211.c:499:43: sparse: sparse: cast to restricted __le16 drivers/iio/light/as73211.c:499:43: sparse: sparse: cast to restricted __le16 drivers/iio/light/as73211.c:499:43: sparse: sparse: cast to restricted __le16 drivers/iio/light/as73211.c:499:43: sparse: sparse: cast to restricted __le16 drivers/iio/light/as73211.c:500:43: sparse: sparse: cast to restricted __le16 drivers/iio/light/as73211.c:500:43: sparse: sparse: cast to restricted __le16 drivers/iio/light/as73211.c:500:43: sparse: sparse: cast to restricted __le16 drivers/iio/light/as73211.c:500:43: sparse: sparse: cast to restricted __le16
vim +473 drivers/iio/light/as73211.c
439
440 static irqreturn_t as73211_trigger_handler(int irq __always_unused, void *p)
441 {
442 struct iio_poll_func *pf = p;
443 struct iio_dev *indio_dev = pf->indio_dev;
444 struct as73211_data *data = iio_priv(indio_dev);
445 int data_result, ret;
446
447 mutex_lock(&data->mutex);
448
449 data_result = as73211_req_data(data);
450
451 /* Optimization for reading all (color + temperature) channels */
452 if (*indio_dev->active_scan_mask == 0xf) {
453 u8 addr = as73211_channels[0].address;
454 struct i2c_msg msgs[] = {
455 {
456 .addr = data->client->addr,
457 .flags = 0,
458 .len = 1,
459 .buf = &addr
460 },
461 {
462 .addr = data->client->addr,
463 .flags = I2C_M_RD,
464 .len = 4 * sizeof(*data->buffer),
465 .buf = (u8 *)&data->buffer[0]
466 },
467 };
468 ret = i2c_transfer(data->client->adapter, msgs, ARRAY_SIZE(msgs));
469 if (ret < 0)
470 goto done;
471
472 /* Temperature channel is not affected by overflows */
> 473 data->buffer[0] = le16_to_cpu(data->buffer[0]);
474
475 if (data_result == 0) {
476 /* convert byte order (AS73211 sends LSB first) */
477 data->buffer[1] = le16_to_cpu(data->buffer[1]);
478 data->buffer[2] = le16_to_cpu(data->buffer[2]);
479 data->buffer[3] = le16_to_cpu(data->buffer[3]);
480 } else {
481 /* saturate all channels (useful for overflows) */
482 data->buffer[1] = 0xffff;
483 data->buffer[2] = 0xffff;
484 data->buffer[3] = 0xffff;
485 }
486
487 }
488 /* Optimization for reading all color channels */
489 else if (*indio_dev->active_scan_mask == 0xe) {
490 /* AS73211 starts reading at address 2 */
491 ret = i2c_master_recv(data->client,
492 (char *)&data->buffer[1], 3 * sizeof(*data->buffer));
493 if (ret < 0)
494 goto done;
495
496 if (data_result == 0) {
497 /* convert byte order (as73211 sends LSB first) */
498 data->buffer[1] = le16_to_cpu(data->buffer[1]);
499 data->buffer[2] = le16_to_cpu(data->buffer[2]);
500 data->buffer[3] = le16_to_cpu(data->buffer[3]);
501 } else {
502 /* saturate all channels (useful for overflows) */
503 data->buffer[1] = 0xffff;
504 data->buffer[2] = 0xffff;
505 data->buffer[3] = 0xffff;
506 }
507 } else {
508 unsigned int i, j = 0;
509
510 /* generic case */
511 for_each_set_bit(i, indio_dev->active_scan_mask, indio_dev->masklength) {
512 struct iio_chan_spec const *channel = &as73211_channels[i];
513
514 /* Read data even on error in order to avoid "result buffer overrun" */
515 ret = i2c_smbus_read_word_data(data->client,
516 channel->address);
517 if (ret < 0)
518 goto done;
519
520 if (data_result == 0) {
521 data->buffer[j++] = ret;
522 } else {
523 /* saturate all channels (useful for overflows) */
524 data->buffer[j++] = 0xffff;
525 }
526 }
527 }
528
529 iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
530 iio_get_time_ns(indio_dev));
531
532 done:
533 mutex_unlock(&data->mutex);
534 iio_trigger_notify_done(indio_dev->trig);
535
536 return IRQ_HANDLED;
537 }
538
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org