Support 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.
Signed-off-by: Christian Eggers
---
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
diff --git a/MAINTAINERS b/MAINTAINERS
index 068d6e94122b..673570414147 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -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
+L: linux-...@vger.kernel.org
+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
L: linux...@vger.kernel.org
diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig
index 182bd18c4bb2..cade6dc0305b 100644
--- a/drivers/iio/light/Kconfig
+++ b/drivers/iio/light/Kconfig
@@ -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
diff --git a/drivers/iio/light/Makefile b/drivers/iio/light/Makefile
index d1c8aa30b9a8..ea376deaca54 100644
--- a/drivers/iio/light/Makefile
+++ b/drivers/iio/light/Makefile
@@ -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
diff --git a/drivers/iio/light/as73211.c b/drivers/iio/light/as73211.c
new file mode 100644
index ..93f392f1bea1
--- /dev/null
+++ b/drivers/iio/light/as73211.c
@@ -0,0 +1,822 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * as73211.c - Support for AMS AS73211 JENCOLOR(R) Digital XYZ Sensor
+ *
+ * Author: Christian Eggers
+ *
+ * Copyright (c) 2020 ARRI Lighting
+ *
+ * Color light sensor with 16-bit channels for red, green, blue, clear);
+ * 7-bit I2C slave address 0x74 .. 0x77.
+ *
+ * Datasheet:
https://ams.com/documents/20143/36005/AS73211_DS000556_3-01.pdf/a65474c0-b302-c2fd-e30a-c98df87616df
+ *
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#define AS73211_DRV_NAME "as73211"
+
+/* AS73211 configuration registers */
+#define AS73211_REG_OSR0x0
+#define AS73211_REG_AGEN 0x2
+#define AS73211_REG_CREG1 0x6
+#define AS73211_REG_CREG2 0x7
+#define AS73211_REG_CREG3 0x8
+
+/* AS73211 output register bank */
+#define AS73211_OUT_OSR_STATUS0
+#define AS73211_OUT_TEMP 1
+#define AS73211_OUT_MRES1 2
+#define AS73211_OUT_MRES2 3
+#define AS73211_OUT_MRES3 4
+
+/* OSR */
+#define AS73211_OSR_SSBIT(7)
+#define AS73211_OSR_PDBIT(6)
+#define AS73211_OSR_SW_RESBIT(3)
+#define AS73211_OSR_DOS_SHIFT 0
+#define AS73211_OSR_DOS_MASK (0x7 << AS73211_OSR_DOS_SHIFT)
+#define AS73211_OSR_DOS_CONFIG(0x2 << AS73211_OSR_DOS_SHIFT)
+#define AS73211_OSR_DOS_MEASURE (0x3 << AS73211_OSR_DOS_SHIFT)
+
+/* AGEN */
+#define AS73211_AGEN_DEVID_SHIFT 4
+#define AS73211_AGEN_DEVID_MASK (0xf << AS73211_AGEN_DEVID_SHIFT)
+
+/* CREG1 */
+#define AS73211_CREG1_GAIN_SHIFT 4
+#define AS73211_CREG1_GAIN_MASK (0xf << AS73211_CREG1_GAIN_SHIFT)
+#define AS73211_CREG1_TIME_SHIFT 0
+#define AS73211_CREG1_TIME_MASK (0xf << AS73211_CREG1_TIME_SHIFT)
+
+/* CREG3 */
+#define AS73211_CREG3_CCLK_SHIFT 0
+#define AS73211_CREG3_CCLK_MASK (0x3 << AS73211_CREG3_CCLK_SHIFT)
+
+/* OSR_STATUS */
+#define AS73211_OSR_STATUS_OUTCONVOF BIT(15)
+#define AS73211_OSR_STATUS_MRESOF BIT(14)
+#define AS73211_OSR_STATUS_ADCOF BIT(13)
+#define