* [PATCH 0/5] Add support for LTC2499 ADC
@ 2022-09-16 14:09 Ciprian Regus
2022-09-16 14:09 ` [PATCH 1/5] Remove duplicate matching entry Ciprian Regus
` (5 more replies)
0 siblings, 6 replies; 8+ messages in thread
From: Ciprian Regus @ 2022-09-16 14:09 UTC (permalink / raw)
To: jic23, linux-iio, devicetree, linux-kernel; +Cc: Ciprian Regus
The LTC2499 is a 16-channel (eight differential), 24-bit,
ADC with Easy Drive technology and a 2-wire, I2C interface.
This adds support for the LTC2499 ADC by extending the LTC2497
driver.
There is also a removal of a MAINTAINERS entry duplicate.
Note: This fix is required to be applied first:
https://patchwork.kernel.org/project/linux-iio/patch/20220815091647.1523532-1-dzagorui@cisco.com
Ciprian Regus (5):
Remove duplicate matching entry
dt-bindings: iio: adc: Add docs for LTC2499
Add MAINTAINERS entries for LTC2497 and LTC2496
drivers: iio: adc: LTC2499 support
drivers: iio: adc: Rename the LTC2499 iio device
.../bindings/iio/adc/lltc,ltc2497.yaml | 8 ++-
MAINTAINERS | 3 +-
drivers/iio/adc/ltc2496.c | 9 ++-
drivers/iio/adc/ltc2497-core.c | 12 +++-
drivers/iio/adc/ltc2497.c | 63 +++++++++++++++++--
drivers/iio/adc/ltc2497.h | 6 ++
6 files changed, 90 insertions(+), 11 deletions(-)
--
2.30.2
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH 1/5] Remove duplicate matching entry 2022-09-16 14:09 [PATCH 0/5] Add support for LTC2499 ADC Ciprian Regus @ 2022-09-16 14:09 ` Ciprian Regus 2022-09-16 14:09 ` [PATCH 2/5] dt-bindings: iio: adc: Add docs for LTC2499 Ciprian Regus ` (4 subsequent siblings) 5 siblings, 0 replies; 8+ messages in thread From: Ciprian Regus @ 2022-09-16 14:09 UTC (permalink / raw) To: jic23, linux-iio, devicetree, linux-kernel; +Cc: Ciprian Regus Remove the specific entry for ad5758, since Documentation/devicetree/bindings/iio/*/adi,* already matches the path. Signed-off-by: Ciprian Regus <ciprian.regus@analog.com> --- changes in v3: - reordered as the first patch in the series. MAINTAINERS | 1 - 1 file changed, 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index 9d7f64dc0efe..ed31866e4c4e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1327,7 +1327,6 @@ W: https://ez.analog.com/linux-software-drivers F: Documentation/ABI/testing/sysfs-bus-iio-frequency-ad9523 F: Documentation/ABI/testing/sysfs-bus-iio-frequency-adf4350 F: Documentation/devicetree/bindings/iio/*/adi,* -F: Documentation/devicetree/bindings/iio/dac/adi,ad5758.yaml F: drivers/iio/*/ad* F: drivers/iio/adc/ltc249* F: drivers/iio/amplifiers/hmc425a.c -- 2.30.2 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/5] dt-bindings: iio: adc: Add docs for LTC2499 2022-09-16 14:09 [PATCH 0/5] Add support for LTC2499 ADC Ciprian Regus 2022-09-16 14:09 ` [PATCH 1/5] Remove duplicate matching entry Ciprian Regus @ 2022-09-16 14:09 ` Ciprian Regus 2022-09-16 14:09 ` [PATCH 3/5] Add MAINTAINERS entries for LTC2497 and LTC2496 Ciprian Regus ` (3 subsequent siblings) 5 siblings, 0 replies; 8+ messages in thread From: Ciprian Regus @ 2022-09-16 14:09 UTC (permalink / raw) To: jic23, linux-iio, devicetree, linux-kernel Cc: Ciprian Regus, Krzysztof Kozlowski Update the bindings documentation for ltc2497 to include the ltc2499. Signed-off-by: Ciprian Regus <ciprian.regus@analog.com> Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> --- changes in V3: - moved the MAINTAINERS entry in another patch. .../devicetree/bindings/iio/adc/lltc,ltc2497.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/adc/lltc,ltc2497.yaml b/Documentation/devicetree/bindings/iio/adc/lltc,ltc2497.yaml index c1772b568cd1..875f394576c2 100644 --- a/Documentation/devicetree/bindings/iio/adc/lltc,ltc2497.yaml +++ b/Documentation/devicetree/bindings/iio/adc/lltc,ltc2497.yaml @@ -13,10 +13,14 @@ description: | 16bit ADC supporting up to 16 single ended or 8 differential inputs. I2C interface. + https://www.analog.com/media/en/technical-documentation/data-sheets/2497fb.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/2499fe.pdf + properties: compatible: - const: - lltc,ltc2497 + enum: + - lltc,ltc2497 + - lltc,ltc2499 reg: true vref-supply: true -- 2.30.2 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/5] Add MAINTAINERS entries for LTC2497 and LTC2496 2022-09-16 14:09 [PATCH 0/5] Add support for LTC2499 ADC Ciprian Regus 2022-09-16 14:09 ` [PATCH 1/5] Remove duplicate matching entry Ciprian Regus 2022-09-16 14:09 ` [PATCH 2/5] dt-bindings: iio: adc: Add docs for LTC2499 Ciprian Regus @ 2022-09-16 14:09 ` Ciprian Regus 2022-09-16 14:09 ` [PATCH 4/5] drivers: iio: adc: LTC2499 support Ciprian Regus ` (2 subsequent siblings) 5 siblings, 0 replies; 8+ messages in thread From: Ciprian Regus @ 2022-09-16 14:09 UTC (permalink / raw) To: jic23, linux-iio, devicetree, linux-kernel; +Cc: Ciprian Regus Update the MAINTAINERS file to include the path for the LTC2497 and LTC2496 devicetree bindings documentation. Signed-off-by: Ciprian Regus <ciprian.regus@analog.com> --- changes in v3: - added entry for ltc2497. - updated the patch title and description. MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index ed31866e4c4e..ca7fc57173c9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1327,6 +1327,8 @@ W: https://ez.analog.com/linux-software-drivers F: Documentation/ABI/testing/sysfs-bus-iio-frequency-ad9523 F: Documentation/ABI/testing/sysfs-bus-iio-frequency-adf4350 F: Documentation/devicetree/bindings/iio/*/adi,* +F: Documentation/devicetree/bindings/iio/adc/lltc,ltc2496.yaml +F: Documentation/devicetree/bindings/iio/adc/lltc,ltc2497.yaml F: drivers/iio/*/ad* F: drivers/iio/adc/ltc249* F: drivers/iio/amplifiers/hmc425a.c -- 2.30.2 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/5] drivers: iio: adc: LTC2499 support 2022-09-16 14:09 [PATCH 0/5] Add support for LTC2499 ADC Ciprian Regus ` (2 preceding siblings ...) 2022-09-16 14:09 ` [PATCH 3/5] Add MAINTAINERS entries for LTC2497 and LTC2496 Ciprian Regus @ 2022-09-16 14:09 ` Ciprian Regus 2022-09-18 14:30 ` Jonathan Cameron 2022-09-16 14:09 ` [PATCH 5/5] drivers: iio: adc: Rename the LTC2499 iio device Ciprian Regus 2022-09-18 14:33 ` [PATCH 0/5] Add support for LTC2499 ADC Jonathan Cameron 5 siblings, 1 reply; 8+ messages in thread From: Ciprian Regus @ 2022-09-16 14:09 UTC (permalink / raw) To: jic23, linux-iio, devicetree, linux-kernel; +Cc: Ciprian Regus The LTC2499 is a 16-channel (eight differential), 24-bit, ADC with Easy Drive technology and a 2-wire, I2C interface. Implement support for the LTC2499 ADC by extending the LTC2497 driver. A new chip_info struct is added to differentiate between chip types and resolutions when reading data from the device. Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/2499fe.pdf Signed-off-by: Ciprian Regus <ciprian.regus@analog.com> --- changes in v3: - set the correct chip info indexes for i2c_device_id entries. - added the asm/unaligned.h header. - removed TYPE_LTC2496. - moved the ltc2497_chip_type enum to ltc2497.c file. - removed the name setting. drivers/iio/adc/ltc2496.c | 8 ++++- drivers/iio/adc/ltc2497-core.c | 2 +- drivers/iio/adc/ltc2497.c | 61 +++++++++++++++++++++++++++++++--- drivers/iio/adc/ltc2497.h | 5 +++ 4 files changed, 69 insertions(+), 7 deletions(-) diff --git a/drivers/iio/adc/ltc2496.c b/drivers/iio/adc/ltc2496.c index dfb3bb5997e5..bf89d5ae19af 100644 --- a/drivers/iio/adc/ltc2496.c +++ b/drivers/iio/adc/ltc2496.c @@ -15,6 +15,7 @@ #include <linux/iio/driver.h> #include <linux/module.h> #include <linux/mod_devicetable.h> +#include <linux/property.h> #include "ltc2497.h" @@ -74,6 +75,7 @@ static int ltc2496_probe(struct spi_device *spi) spi_set_drvdata(spi, indio_dev); st->spi = spi; st->common_ddata.result_and_measure = ltc2496_result_and_measure; + st->common_ddata.chip_info = device_get_match_data(dev); return ltc2497core_probe(dev, indio_dev); } @@ -85,8 +87,12 @@ static void ltc2496_remove(struct spi_device *spi) ltc2497core_remove(indio_dev); } +static const struct ltc2497_chip_info ltc2496_info = { + .resolution = 16, +}; + static const struct of_device_id ltc2496_of_match[] = { - { .compatible = "lltc,ltc2496", }, + { .compatible = "lltc,ltc2496", .data = <c2496_info, }, {}, }; MODULE_DEVICE_TABLE(of, ltc2496_of_match); diff --git a/drivers/iio/adc/ltc2497-core.c b/drivers/iio/adc/ltc2497-core.c index 2a485c8a1940..b2752399402c 100644 --- a/drivers/iio/adc/ltc2497-core.c +++ b/drivers/iio/adc/ltc2497-core.c @@ -95,7 +95,7 @@ static int ltc2497core_read_raw(struct iio_dev *indio_dev, return ret; *val = ret / 1000; - *val2 = 17; + *val2 = ddata->chip_info->resolution + 1; return IIO_VAL_FRACTIONAL_LOG2; diff --git a/drivers/iio/adc/ltc2497.c b/drivers/iio/adc/ltc2497.c index f7c786f37ceb..36248423a7a6 100644 --- a/drivers/iio/adc/ltc2497.c +++ b/drivers/iio/adc/ltc2497.c @@ -12,18 +12,31 @@ #include <linux/iio/driver.h> #include <linux/module.h> #include <linux/mod_devicetable.h> +#include <linux/property.h> + +#include <asm/unaligned.h> #include "ltc2497.h" +enum ltc2497_chip_type { + TYPE_LTC2497, + TYPE_LTC2499, +}; + struct ltc2497_driverdata { /* this must be the first member */ struct ltc2497core_driverdata common_ddata; struct i2c_client *client; + u32 recv_size; + u32 sub_lsb; /* * DMA (thus cache coherency maintenance) may require the * transfer buffers to live in their own cache lines. */ - __be32 buf __aligned(IIO_DMA_MINALIGN); + union { + __be32 d32; + u8 d8[3]; + } data __aligned(IIO_DMA_MINALIGN); }; static int ltc2497_result_and_measure(struct ltc2497core_driverdata *ddata, @@ -34,13 +47,29 @@ static int ltc2497_result_and_measure(struct ltc2497core_driverdata *ddata, int ret; if (val) { - ret = i2c_master_recv(st->client, (char *)&st->buf, 3); + if (st->recv_size == 3) + ret = i2c_master_recv(st->client, (char *)&st->data.d8, st->recv_size); + else + ret = i2c_master_recv(st->client, (char *)&st->data.d32, st->recv_size); + if (ret < 0) { dev_err(&st->client->dev, "i2c_master_recv failed\n"); return ret; } - *val = (be32_to_cpu(st->buf) >> 14) - (1 << 17); + /* + * The data format is 16/24 bit 2s complement, but with an upper sign bit on the + * resolution + 1 position, which is set for positive values only. Given this + * bit's value, subtracting BIT(resolution + 1) from the ADC's result is + * equivalent to a sign extension. + */ + if (st->recv_size == 3) { + *val = (get_unaligned_be24(st->data.d8) >> st->sub_lsb) + - BIT(ddata->chip_info->resolution + 1); + } else { + *val = (be32_to_cpu(st->data.d32) >> st->sub_lsb) + - BIT(ddata->chip_info->resolution + 1); + } } ret = i2c_smbus_write_byte(st->client, @@ -54,9 +83,11 @@ static int ltc2497_result_and_measure(struct ltc2497core_driverdata *ddata, static int ltc2497_probe(struct i2c_client *client, const struct i2c_device_id *id) { + const struct ltc2497_chip_info *chip_info; struct iio_dev *indio_dev; struct ltc2497_driverdata *st; struct device *dev = &client->dev; + u32 resolution; if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C | I2C_FUNC_SMBUS_WRITE_BYTE)) @@ -71,6 +102,15 @@ static int ltc2497_probe(struct i2c_client *client, st->client = client; st->common_ddata.result_and_measure = ltc2497_result_and_measure; + chip_info = device_get_match_data(dev); + if (!chip_info) + chip_info = (const struct ltc2497_chip_info *)id->driver_data; + st->common_ddata.chip_info = chip_info; + + resolution = chip_info->resolution; + st->sub_lsb = 31 - (resolution + 1); + st->recv_size = BITS_TO_BYTES(resolution) + 1; + return ltc2497core_probe(dev, indio_dev); } @@ -83,14 +123,25 @@ static int ltc2497_remove(struct i2c_client *client) return 0; } +static const struct ltc2497_chip_info ltc2497_info[] = { + [TYPE_LTC2497] = { + .resolution = 16, + }, + [TYPE_LTC2499] = { + .resolution = 24, + }, +}; + static const struct i2c_device_id ltc2497_id[] = { - { "ltc2497", 0 }, + { "ltc2497", (kernel_ulong_t)<c2497_info[TYPE_LTC2497] }, + { "ltc2499", (kernel_ulong_t)<c2497_info[TYPE_LTC2499] }, { } }; MODULE_DEVICE_TABLE(i2c, ltc2497_id); static const struct of_device_id ltc2497_of_match[] = { - { .compatible = "lltc,ltc2497", }, + { .compatible = "lltc,ltc2497", .data = <c2497_info[TYPE_LTC2497] }, + { .compatible = "lltc,ltc2499", .data = <c2497_info[TYPE_LTC2499] }, {}, }; MODULE_DEVICE_TABLE(of, ltc2497_of_match); diff --git a/drivers/iio/adc/ltc2497.h b/drivers/iio/adc/ltc2497.h index d0b42dd6b8ad..71957fc7e1ba 100644 --- a/drivers/iio/adc/ltc2497.h +++ b/drivers/iio/adc/ltc2497.h @@ -4,9 +4,14 @@ #define LTC2497_CONFIG_DEFAULT LTC2497_ENABLE #define LTC2497_CONVERSION_TIME_MS 150ULL +struct ltc2497_chip_info { + u32 resolution; +}; + struct ltc2497core_driverdata { struct regulator *ref; ktime_t time_prev; + const struct ltc2497_chip_info *chip_info; u8 addr_prev; int (*result_and_measure)(struct ltc2497core_driverdata *ddata, u8 address, int *val); -- 2.30.2 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 4/5] drivers: iio: adc: LTC2499 support 2022-09-16 14:09 ` [PATCH 4/5] drivers: iio: adc: LTC2499 support Ciprian Regus @ 2022-09-18 14:30 ` Jonathan Cameron 0 siblings, 0 replies; 8+ messages in thread From: Jonathan Cameron @ 2022-09-18 14:30 UTC (permalink / raw) To: Ciprian Regus; +Cc: linux-iio, devicetree, linux-kernel On Fri, 16 Sep 2022 17:09:21 +0300 Ciprian Regus <ciprian.regus@analog.com> wrote: > The LTC2499 is a 16-channel (eight differential), 24-bit, > ADC with Easy Drive technology and a 2-wire, I2C interface. > > Implement support for the LTC2499 ADC by extending the LTC2497 > driver. A new chip_info struct is added to differentiate between > chip types and resolutions when reading data from the device. > > Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/2499fe.pdf > Signed-off-by: Ciprian Regus <ciprian.regus@analog.com> I'm not certain why (as I have the prerequisit on the tree) but this didn't apply cleanly. Please give the result of my manual intervention a quick sanity check. Thanks, Jonathan > --- > changes in v3: > - set the correct chip info indexes for i2c_device_id entries. > - added the asm/unaligned.h header. > - removed TYPE_LTC2496. > - moved the ltc2497_chip_type enum to ltc2497.c file. > - removed the name setting. > drivers/iio/adc/ltc2496.c | 8 ++++- > drivers/iio/adc/ltc2497-core.c | 2 +- > drivers/iio/adc/ltc2497.c | 61 +++++++++++++++++++++++++++++++--- > drivers/iio/adc/ltc2497.h | 5 +++ > 4 files changed, 69 insertions(+), 7 deletions(-) > > diff --git a/drivers/iio/adc/ltc2496.c b/drivers/iio/adc/ltc2496.c > index dfb3bb5997e5..bf89d5ae19af 100644 > --- a/drivers/iio/adc/ltc2496.c > +++ b/drivers/iio/adc/ltc2496.c > @@ -15,6 +15,7 @@ > #include <linux/iio/driver.h> > #include <linux/module.h> > #include <linux/mod_devicetable.h> > +#include <linux/property.h> > > #include "ltc2497.h" > > @@ -74,6 +75,7 @@ static int ltc2496_probe(struct spi_device *spi) > spi_set_drvdata(spi, indio_dev); > st->spi = spi; > st->common_ddata.result_and_measure = ltc2496_result_and_measure; > + st->common_ddata.chip_info = device_get_match_data(dev); > > return ltc2497core_probe(dev, indio_dev); > } > @@ -85,8 +87,12 @@ static void ltc2496_remove(struct spi_device *spi) > ltc2497core_remove(indio_dev); > } > > +static const struct ltc2497_chip_info ltc2496_info = { > + .resolution = 16, > +}; > + > static const struct of_device_id ltc2496_of_match[] = { > - { .compatible = "lltc,ltc2496", }, > + { .compatible = "lltc,ltc2496", .data = <c2496_info, }, > {}, > }; > MODULE_DEVICE_TABLE(of, ltc2496_of_match); > diff --git a/drivers/iio/adc/ltc2497-core.c b/drivers/iio/adc/ltc2497-core.c > index 2a485c8a1940..b2752399402c 100644 > --- a/drivers/iio/adc/ltc2497-core.c > +++ b/drivers/iio/adc/ltc2497-core.c > @@ -95,7 +95,7 @@ static int ltc2497core_read_raw(struct iio_dev *indio_dev, > return ret; > > *val = ret / 1000; > - *val2 = 17; > + *val2 = ddata->chip_info->resolution + 1; > > return IIO_VAL_FRACTIONAL_LOG2; > > diff --git a/drivers/iio/adc/ltc2497.c b/drivers/iio/adc/ltc2497.c > index f7c786f37ceb..36248423a7a6 100644 > --- a/drivers/iio/adc/ltc2497.c > +++ b/drivers/iio/adc/ltc2497.c > @@ -12,18 +12,31 @@ > #include <linux/iio/driver.h> > #include <linux/module.h> > #include <linux/mod_devicetable.h> > +#include <linux/property.h> > + > +#include <asm/unaligned.h> > > #include "ltc2497.h" > > +enum ltc2497_chip_type { > + TYPE_LTC2497, > + TYPE_LTC2499, > +}; > + > struct ltc2497_driverdata { > /* this must be the first member */ > struct ltc2497core_driverdata common_ddata; > struct i2c_client *client; > + u32 recv_size; > + u32 sub_lsb; > /* > * DMA (thus cache coherency maintenance) may require the > * transfer buffers to live in their own cache lines. > */ > - __be32 buf __aligned(IIO_DMA_MINALIGN); > + union { > + __be32 d32; > + u8 d8[3]; > + } data __aligned(IIO_DMA_MINALIGN); > }; > > static int ltc2497_result_and_measure(struct ltc2497core_driverdata *ddata, > @@ -34,13 +47,29 @@ static int ltc2497_result_and_measure(struct ltc2497core_driverdata *ddata, > int ret; > > if (val) { > - ret = i2c_master_recv(st->client, (char *)&st->buf, 3); > + if (st->recv_size == 3) > + ret = i2c_master_recv(st->client, (char *)&st->data.d8, st->recv_size); > + else > + ret = i2c_master_recv(st->client, (char *)&st->data.d32, st->recv_size); > + > if (ret < 0) { > dev_err(&st->client->dev, "i2c_master_recv failed\n"); > return ret; > } > > - *val = (be32_to_cpu(st->buf) >> 14) - (1 << 17); > + /* > + * The data format is 16/24 bit 2s complement, but with an upper sign bit on the > + * resolution + 1 position, which is set for positive values only. Given this > + * bit's value, subtracting BIT(resolution + 1) from the ADC's result is > + * equivalent to a sign extension. > + */ > + if (st->recv_size == 3) { > + *val = (get_unaligned_be24(st->data.d8) >> st->sub_lsb) > + - BIT(ddata->chip_info->resolution + 1); > + } else { > + *val = (be32_to_cpu(st->data.d32) >> st->sub_lsb) > + - BIT(ddata->chip_info->resolution + 1); > + } > } > > ret = i2c_smbus_write_byte(st->client, > @@ -54,9 +83,11 @@ static int ltc2497_result_and_measure(struct ltc2497core_driverdata *ddata, > static int ltc2497_probe(struct i2c_client *client, > const struct i2c_device_id *id) > { > + const struct ltc2497_chip_info *chip_info; > struct iio_dev *indio_dev; > struct ltc2497_driverdata *st; > struct device *dev = &client->dev; > + u32 resolution; > > if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C | > I2C_FUNC_SMBUS_WRITE_BYTE)) > @@ -71,6 +102,15 @@ static int ltc2497_probe(struct i2c_client *client, > st->client = client; > st->common_ddata.result_and_measure = ltc2497_result_and_measure; > > + chip_info = device_get_match_data(dev); > + if (!chip_info) > + chip_info = (const struct ltc2497_chip_info *)id->driver_data; > + st->common_ddata.chip_info = chip_info; > + > + resolution = chip_info->resolution; > + st->sub_lsb = 31 - (resolution + 1); > + st->recv_size = BITS_TO_BYTES(resolution) + 1; > + > return ltc2497core_probe(dev, indio_dev); > } > > @@ -83,14 +123,25 @@ static int ltc2497_remove(struct i2c_client *client) > return 0; > } > > +static const struct ltc2497_chip_info ltc2497_info[] = { > + [TYPE_LTC2497] = { > + .resolution = 16, > + }, > + [TYPE_LTC2499] = { > + .resolution = 24, > + }, > +}; > + > static const struct i2c_device_id ltc2497_id[] = { > - { "ltc2497", 0 }, > + { "ltc2497", (kernel_ulong_t)<c2497_info[TYPE_LTC2497] }, > + { "ltc2499", (kernel_ulong_t)<c2497_info[TYPE_LTC2499] }, > { } > }; > MODULE_DEVICE_TABLE(i2c, ltc2497_id); > > static const struct of_device_id ltc2497_of_match[] = { > - { .compatible = "lltc,ltc2497", }, > + { .compatible = "lltc,ltc2497", .data = <c2497_info[TYPE_LTC2497] }, > + { .compatible = "lltc,ltc2499", .data = <c2497_info[TYPE_LTC2499] }, > {}, > }; > MODULE_DEVICE_TABLE(of, ltc2497_of_match); > diff --git a/drivers/iio/adc/ltc2497.h b/drivers/iio/adc/ltc2497.h > index d0b42dd6b8ad..71957fc7e1ba 100644 > --- a/drivers/iio/adc/ltc2497.h > +++ b/drivers/iio/adc/ltc2497.h > @@ -4,9 +4,14 @@ > #define LTC2497_CONFIG_DEFAULT LTC2497_ENABLE > #define LTC2497_CONVERSION_TIME_MS 150ULL > > +struct ltc2497_chip_info { > + u32 resolution; > +}; > + > struct ltc2497core_driverdata { > struct regulator *ref; > ktime_t time_prev; > + const struct ltc2497_chip_info *chip_info; > u8 addr_prev; > int (*result_and_measure)(struct ltc2497core_driverdata *ddata, > u8 address, int *val); ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 5/5] drivers: iio: adc: Rename the LTC2499 iio device 2022-09-16 14:09 [PATCH 0/5] Add support for LTC2499 ADC Ciprian Regus ` (3 preceding siblings ...) 2022-09-16 14:09 ` [PATCH 4/5] drivers: iio: adc: LTC2499 support Ciprian Regus @ 2022-09-16 14:09 ` Ciprian Regus 2022-09-18 14:33 ` [PATCH 0/5] Add support for LTC2499 ADC Jonathan Cameron 5 siblings, 0 replies; 8+ messages in thread From: Ciprian Regus @ 2022-09-16 14:09 UTC (permalink / raw) To: jic23, linux-iio, devicetree, linux-kernel; +Cc: Ciprian Regus Set the iio device's name based on the chip used for the LTC2499 only. The most common way for IIO clients to interact with a device is to address it based on it's name. By using the dev_name() function, the name will be set based on a i2c_client's kobj name, which has the format i2c_instance-i2c_address (1-0076 for example). This is not ideal, since it makes a requirement for userspace to have knowledge about the hardware connections of the device. The name field is set to NULL for the LTC2497 and LTC2496, so that the old name can kept as it is, since changing it will result in an ABI breakage. Signed-off-by: Ciprian Regus <ciprian.regus@analog.com> --- changes in v3: - moved the chip info name field setting in this patch. drivers/iio/adc/ltc2496.c | 1 + drivers/iio/adc/ltc2497-core.c | 10 +++++++++- drivers/iio/adc/ltc2497.c | 2 ++ drivers/iio/adc/ltc2497.h | 1 + 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/ltc2496.c b/drivers/iio/adc/ltc2496.c index bf89d5ae19af..2593fa4322eb 100644 --- a/drivers/iio/adc/ltc2496.c +++ b/drivers/iio/adc/ltc2496.c @@ -89,6 +89,7 @@ static void ltc2496_remove(struct spi_device *spi) static const struct ltc2497_chip_info ltc2496_info = { .resolution = 16, + .name = NULL, }; static const struct of_device_id ltc2496_of_match[] = { diff --git a/drivers/iio/adc/ltc2497-core.c b/drivers/iio/adc/ltc2497-core.c index b2752399402c..f52d37af4d1f 100644 --- a/drivers/iio/adc/ltc2497-core.c +++ b/drivers/iio/adc/ltc2497-core.c @@ -169,7 +169,15 @@ int ltc2497core_probe(struct device *dev, struct iio_dev *indio_dev) struct ltc2497core_driverdata *ddata = iio_priv(indio_dev); int ret; - indio_dev->name = dev_name(dev); + /* + * Keep using dev_name() for the iio_dev's name on some of the parts, + * since updating it would result in a ABI breakage. + */ + if (ddata->chip_info->name) + indio_dev->name = ddata->chip_info->name; + else + indio_dev->name = dev_name(dev); + indio_dev->info = <c2497core_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = ltc2497core_channel; diff --git a/drivers/iio/adc/ltc2497.c b/drivers/iio/adc/ltc2497.c index 36248423a7a6..ea76436adaf3 100644 --- a/drivers/iio/adc/ltc2497.c +++ b/drivers/iio/adc/ltc2497.c @@ -126,9 +126,11 @@ static int ltc2497_remove(struct i2c_client *client) static const struct ltc2497_chip_info ltc2497_info[] = { [TYPE_LTC2497] = { .resolution = 16, + .name = NULL, }, [TYPE_LTC2499] = { .resolution = 24, + .name = "ltc2499", }, }; diff --git a/drivers/iio/adc/ltc2497.h b/drivers/iio/adc/ltc2497.h index 71957fc7e1ba..e023de0d88c4 100644 --- a/drivers/iio/adc/ltc2497.h +++ b/drivers/iio/adc/ltc2497.h @@ -6,6 +6,7 @@ struct ltc2497_chip_info { u32 resolution; + const char *name; }; struct ltc2497core_driverdata { -- 2.30.2 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 0/5] Add support for LTC2499 ADC 2022-09-16 14:09 [PATCH 0/5] Add support for LTC2499 ADC Ciprian Regus ` (4 preceding siblings ...) 2022-09-16 14:09 ` [PATCH 5/5] drivers: iio: adc: Rename the LTC2499 iio device Ciprian Regus @ 2022-09-18 14:33 ` Jonathan Cameron 5 siblings, 0 replies; 8+ messages in thread From: Jonathan Cameron @ 2022-09-18 14:33 UTC (permalink / raw) To: Ciprian Regus; +Cc: linux-iio, devicetree, linux-kernel On Fri, 16 Sep 2022 17:09:17 +0300 Ciprian Regus <ciprian.regus@analog.com> wrote: > The LTC2499 is a 16-channel (eight differential), 24-bit, > ADC with Easy Drive technology and a 2-wire, I2C interface. > > This adds support for the LTC2499 ADC by extending the LTC2497 > driver. > > There is also a removal of a MAINTAINERS entry duplicate. > > Note: This fix is required to be applied first: > https://patchwork.kernel.org/project/linux-iio/patch/20220815091647.1523532-1-dzagorui@cisco.com Hi Ciprian, This lost it's version number which may confuse some scripts etc. Anyhow, I think b4 found the right versions. Applied to the togreg branch of iio.git and pushed out as testing for 0-day to take a look. Note I plan to rebase that tree sometime this week so don't use it as a stable base. I tweaked a few patch descriptions to make it clearer what driver was involved and wrapped long lines whilst applying. Thanks, Jonathan > > Ciprian Regus (5): > Remove duplicate matching entry > dt-bindings: iio: adc: Add docs for LTC2499 > Add MAINTAINERS entries for LTC2497 and LTC2496 > drivers: iio: adc: LTC2499 support > drivers: iio: adc: Rename the LTC2499 iio device > > .../bindings/iio/adc/lltc,ltc2497.yaml | 8 ++- > MAINTAINERS | 3 +- > drivers/iio/adc/ltc2496.c | 9 ++- > drivers/iio/adc/ltc2497-core.c | 12 +++- > drivers/iio/adc/ltc2497.c | 63 +++++++++++++++++-- > drivers/iio/adc/ltc2497.h | 6 ++ > 6 files changed, 90 insertions(+), 11 deletions(-) > ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-09-18 14:33 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-09-16 14:09 [PATCH 0/5] Add support for LTC2499 ADC Ciprian Regus 2022-09-16 14:09 ` [PATCH 1/5] Remove duplicate matching entry Ciprian Regus 2022-09-16 14:09 ` [PATCH 2/5] dt-bindings: iio: adc: Add docs for LTC2499 Ciprian Regus 2022-09-16 14:09 ` [PATCH 3/5] Add MAINTAINERS entries for LTC2497 and LTC2496 Ciprian Regus 2022-09-16 14:09 ` [PATCH 4/5] drivers: iio: adc: LTC2499 support Ciprian Regus 2022-09-18 14:30 ` Jonathan Cameron 2022-09-16 14:09 ` [PATCH 5/5] drivers: iio: adc: Rename the LTC2499 iio device Ciprian Regus 2022-09-18 14:33 ` [PATCH 0/5] Add support for LTC2499 ADC Jonathan Cameron
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox