[PATCH v2 5/6] iio: adc: ade9000: add support for ADE9430

Antoniu Miclaus <[email protected]>
Newsgroups org.kernel.vger.linux-doc,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-iio,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
The ADE9430 is a polyphase energy metering device that is register
compatible with the ADE9000. The differences relevant to the driver are
the absence of the on-chip dip/swell detection and the absence of an
on-chip digital integrator (the ADE9430 uses an external analog integrator
for Rogowski coils, so the DICOEFF register does not exist). Its full-scale
ADC codes are the same family-A values as the ADE9000.

Add a chip_info for the ADE9430, reusing the dip/swell-less channel table
first added for the ADE9078, and explicitly set has_digital_integrator to
false so the DICOEFF write is skipped. Wire up the SPI and OF device tables
and Kconfig.

Signed-off-by: Antoniu Miclaus <[email protected]>
---
Changes in v2:
- reuse ade9078_channels instead of adding a duplicate channel table.
- move the DICOEFF gating to a separate precursor patch.

 drivers/iio/adc/Kconfig   |  1 +
 drivers/iio/adc/ade9000.c | 12 ++++++++++++
 2 files changed, 13 insertions(+)

diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
index 7a60ffd0ddd8..3a3ae09fc10f 100644
--- a/drivers/iio/adc/Kconfig
+++ b/drivers/iio/adc/Kconfig
@@ -587,6 +587,7 @@ config ADE9000
 	  integrated circuits:
 	    - ADE9000
 	    - ADE9078
+	    - ADE9430
 
 	  The devices feature high-precision analog-to-digital converters
 	  and digital signal processing to compute RMS values, power factor,
diff --git a/drivers/iio/adc/ade9000.c b/drivers/iio/adc/ade9000.c
index 0167d5bcdb74..e0113b62a261 100644
--- a/drivers/iio/adc/ade9000.c
+++ b/drivers/iio/adc/ade9000.c
@@ -695,6 +695,16 @@ static const struct ade9000_chip_info ade9078_chip_info = {
 	.has_digital_integrator = true,
 };
 
+static const struct ade9000_chip_info ade9430_chip_info = {
+	.name = "ade9430",
+	.channels = ade9078_channels,
+	.num_channels = ARRAY_SIZE(ade9078_channels),
+	.rms_full_scale_codes = 52702092,
+	.watt_full_scale_codes = 20694066,
+	.pcf_full_scale_codes = 74532013,
+	.has_digital_integrator = false, /* no on-chip digital integrator */
+};
+
 static const struct reg_sequence ade9000_initialization_sequence[] = {
 	{ ADE9000_REG_PGA_GAIN, ADE9000_PGA_GAIN },
 	{ ADE9000_REG_CONFIG0, ADE9000_CONFIG0 },
@@ -1859,6 +1869,7 @@ static int ade9000_probe(struct spi_device *spi)
 static const struct spi_device_id ade9000_id[] = {
 	{ .name = "ade9000", .driver_data = (kernel_ulong_t)&ade9000_chip_info },
 	{ .name = "ade9078", .driver_data = (kernel_ulong_t)&ade9078_chip_info },
+	{ .name = "ade9430", .driver_data = (kernel_ulong_t)&ade9430_chip_info },
 	{ }
 };
 MODULE_DEVICE_TABLE(spi, ade9000_id);
@@ -1866,6 +1877,7 @@ MODULE_DEVICE_TABLE(spi, ade9000_id);
 static const struct of_device_id ade9000_of_match[] = {
 	{ .compatible = "adi,ade9000", .data = &ade9000_chip_info },
 	{ .compatible = "adi,ade9078", .data = &ade9078_chip_info },
+	{ .compatible = "adi,ade9430", .data = &ade9430_chip_info },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, ade9000_of_match);
-- 
2.43.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.