Add the Renesas X9250 potentiometers IIO support
Herve Codina
maintainercover Add the Renesas X9250 potentiometers IIO support
Hi,
The Renesas X9250 integrated four digitally controlled potentiometers. On each potentiometer, the X9250T has a 100 kOhms total resistance and the X9250U has a 50 kOhms total resistance.
Best regards,
Herve Codina
Herve Codina (3):
dt-bindings: iio: potentiometer: Add the Renesas X9250 potentiometers
iio: potentiometer: Add support for the Renesas X9250 potentiometers
MAINTAINERS: add the Renesas X9250 driver entry
.../iio/potentiometer/renesas,x9250.yaml | 56 +++++ MAINTAINERS | 7 + drivers/iio/potentiometer/Kconfig | 10 + drivers/iio/potentiometer/Makefile | 1 + drivers/iio/potentiometer/x9250.c | 233 ++++++++++++++++++ 5 files changed, 307 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/potentiometer/renesas,x9250.yaml create mode 100644 drivers/iio/potentiometer/x9250.c
Signature · 1 line
2.39.2
Herve Codina
maintainerPATCH 1/3 dt-bindings: iio: potentiometer: Add the Renesas X9250 potentiometers
The Renesas X9250 is a quad digitally controlled potentiometers.
--- .../iio/potentiometer/renesas,x9250.yaml | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/potentiometer/renesas,x9250.yaml
Documentation/devicetree/bindings/iio/potentiometer/renesas,x9250.yaml new file +56 -0
@@ -0,0 +1,56 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/potentiometer/renesas,x9250.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Renesas X9250 quad potentiometers + +maintainers: + - Herve Codina <[email protected]> + +description: + The Renesas X9250 integrates four digitally controlled potentiometers. + On each potentiometer, the X9250T has a 100 kOhms total resistance and the + X9250U has a 50 kOhms total resistance. + +allOf: + - $ref: /schemas/spi/spi-peripheral-props.yaml + - $ref: /schemas/iio/iio.yaml + +properties: + compatible: + enum: + - renesas,x9250t + - renesas,x9250u + + reg: + description: + SPI device address. + maxItems: 1 + + '#io-channel-cells': + const: 1 + + spi-max-frequency: + maximum: 2000000 + +required: + - compatible + - reg + - '#io-channel-cells' + +unevaluatedProperties: false + +examples: + - | + spi { + #address-cells = <1>; + #size-cells = <0>; + x9250@0 { + compatible = "renesas,x9250t"; + reg = <0>; + spi-max-frequency = <2000000>; + #io-channel-cells = <1>; + }; + };
Signature · 1 line
2.39.2
Re: [PATCH 1/3] dt-bindings: iio: potentiometer: Add the Renesas X9250 potentiometers
Quoted 2 lines · Herve Codina
The Renesas X9250 is a quad digitally controlled potentiometers.
Thank you for your patch. There is something to discuss/improve.
Quoted 11 lines
Documentation/devicetree/bindings/iio/potentiometer/renesas,x9250.yaml new file +11
-0+maintainers: + - Herve Codina <[email protected]> + +description: + The Renesas X9250 integrates four digitally controlled potentiometers. + On each potentiometer, the X9250T has a 100 kOhms total resistance and the + X9250U has a 50 kOhms total resistance. + +allOf: + - $ref: /schemas/spi/spi-peripheral-props.yaml + - $ref: /schemas/iio/iio.yaml
Documentation/devicetree/bindings/iio/potentiometer/renesas,x9250.yaml line 29
Quoted 10 lines
Documentation/devicetree/bindings/iio/potentiometer/renesas,x9250.yaml new file +10
-0+ +properties: + compatible: + enum: + - renesas,x9250t + - renesas,x9250u + + reg: + description: + SPI device address.
SPI bus does not have device addresses, AFAIR. Drop description.
Quoted 11 lines
Documentation/devicetree/bindings/iio/potentiometer/renesas,x9250.yaml new file +11
-0+ maxItems: 1 + + '#io-channel-cells': + const: 1 + + spi-max-frequency: + maximum: 2000000 + +required: + - compatible + - reg
Documentation/devicetree/bindings/iio/potentiometer/renesas,x9250.yaml line 50
Quoted 10 lines
Documentation/devicetree/bindings/iio/potentiometer/renesas,x9250.yaml new file +10
-0+ - '#io-channel-cells' + +unevaluatedProperties: false + +examples: + - | + spi { + #address-cells = <1>; + #size-cells = <0>; + x9250@0 {
Node names should be generic.
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendation
Documentation/devicetree/bindings/iio/potentiometer/renesas,x9250.yaml line 56
Quoted 6 lines
Documentation/devicetree/bindings/iio/potentiometer/renesas,x9250.yaml new file +6
-0+ compatible = "renesas,x9250t"; + reg = <0>; + spi-max-frequency = <2000000>; + #io-channel-cells = <1>; + }; + };
Best regards,
Krzysztof
Herve Codina
maintainerRe: [PATCH 1/3] dt-bindings: iio: potentiometer: Add the Renesas X9250 potentiometers
Hi Krzysztof,
Quoted 21 lines · On Fri, 21 Apr 2023 09:32:57 +0200 Krzysztof Kozlowski…
Quoted 2 lines · Herve Codina
The Renesas X9250 is a quad digitally controlled potentiometers.
Thank you for your patch. There is something to discuss/improve.
Quoted 15 lines
Documentation/devicetree/bindings/iio/potentiometer/renesas,x9250.yaml new file +15
-0+maintainers: + - Herve Codina <[email protected]> + +description: + The Renesas X9250 integrates four digitally controlled potentiometers. + On each potentiometer, the X9250T has a 100 kOhms total resistance and the + X9250U has a 50 kOhms total resistance. + +allOf: + - $ref: /schemas/spi/spi-peripheral-props.yaml + - $ref: /schemas/iio/iio.yaml + +properties: + compatible: + enum:
Quoted 8 lines
Documentation/devicetree/bindings/iio/potentiometer/renesas,x9250.yaml line 29
Quoted 6 lines
Documentation/devicetree/bindings/iio/potentiometer/renesas,x9250.yaml new file +6
-0+ - renesas,x9250t + - renesas,x9250u + + reg: + description: + SPI device address.SPI bus does not have device addresses, AFAIR. Drop description.
Indeed, SPI has chip-select.
I will drop the description
Quoted 17 lines
Quoted 17 lines
Documentation/devicetree/bindings/iio/potentiometer/renesas,x9250.yaml new file +16
-0+ maxItems: 1 + + '#io-channel-cells': + const: 1 + + spi-max-frequency: + maximum: 2000000 + +required: + - compatible + - reg + - '#io-channel-cells' + +unevaluatedProperties: false + +examples:
Quoted 8 lines
Documentation/devicetree/bindings/iio/potentiometer/renesas,x9250.yaml line 50
Quoted 5 lines
Documentation/devicetree/bindings/iio/potentiometer/renesas,x9250.yaml new file +5
-0+ - | + spi { + #address-cells = <1>; + #size-cells = <0>; + x9250@0 {Node names should be generic.
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendation
Will be change to potentiometer@0
Quoted 11 lines
Documentation/devicetree/bindings/iio/potentiometer/renesas,x9250.yaml line 56
Quoted 7 lines
Documentation/devicetree/bindings/iio/potentiometer/renesas,x9250.yaml new file +6
-0+ compatible = "renesas,x9250t"; + reg = <0>; + spi-max-frequency = <2000000>; + #io-channel-cells = <1>; + }; + };Best regards,
Krzysztof
The modifications will be present on v3 as v2 was already sent.
Thanks for the review,
Hervé
Herve Codina
maintainerPATCH 2/3 iio: potentiometer: Add support for the Renesas X9250 potentiometers
In reply to Herve CodinaThe Renesas X9250 integrates four digitally controlled potentiometers. On each potentiometer, the X9250T has a 100 kOhms total resistance and the X9250U has a 50 kOhms total resistance.
--- drivers/iio/potentiometer/Kconfig | 10 ++ drivers/iio/potentiometer/Makefile | 1 + drivers/iio/potentiometer/x9250.c | 233 +++++++++++++++++++++++++++++ 3 files changed, 244 insertions(+) create mode 100644 drivers/iio/potentiometer/x9250.c
drivers/iio/potentiometer/Kconfig +10 -0
@@ -136,4 +136,14 @@ config TPL0102 To compile this driver as a module, choose M here: the module will be called tpl0102. +config X9250 + tristate "Renesas X9250 quad controlled potentiometers" + depends on SPI + help + Enable support for the Renesas X9250 quad controlled + potentiometers. + + To compile this driver as a module, choose M here: the module + will be called x9250. + endmenu
drivers/iio/potentiometer/Makefile +1 -0
@@ -15,3 +15,4 @@ obj-$(CONFIG_MCP4131) += mcp4131.o obj-$(CONFIG_MCP4531) += mcp4531.o obj-$(CONFIG_MCP41010) += mcp41010.o obj-$(CONFIG_TPL0102) += tpl0102.o +obj-$(CONFIG_X9250) += x9250.o
drivers/iio/potentiometer/x9250.c new file +233 -0
233 lines not on this page · raw message
Signature · 1 line
2.39.2
Re: [PATCH 2/3] iio: potentiometer: Add support for the Renesas X9250 potentiometers
Quoted 5 lines · Herve Codina
The Renesas X9250 integrates four digitally controlled potentiometers. On each potentiometer, the X9250T has a 100 kOhms total resistance and the X9250U has a 50 kOhms total resistance.
Signed-off-by Herve Codina <[email protected]>
Hi,
Looks perfect! Just one small comment.
drivers/iio/potentiometer/x9250.c line 45
Quoted 13 lines
drivers/iio/potentiometer/x9250.c new file +13
-0+static int x9250_write8 (struct x9250 *x9250,u8 cmd,u8 val) +{ +struct spi_transfer xfer = { + .tx_buf = &x9250->spi_tx_buf, + .len =3 , + }; +int ret; + +BUILD_BUG_ON (sizeof (x9250->spi_tx_buf) <3 ); + +mutex_lock (&x9250->lock); + + x9250->spi_tx_buf[0 ] =0x50 ;
The 0x50 shows up as a magic constant in multiple places, a define for it would be nice.
Quoted 9 lines
drivers/iio/potentiometer/x9250.c new file +9
-0+ x9250->spi_tx_buf[1 ] = cmd; + x9250->spi_tx_buf[2 ] = val; + + ret =spi_sync_transfer (x9250->spi, &xfer,1 ); + +mutex_unlock (&x9250->lock); + +return ret; +}
Herve Codina
maintainerRe: [PATCH 2/3] iio: potentiometer: Add support for the Renesas X9250 potentiometers
Quoted 11 lines · On Thu, 20 Apr 2023 06:47:32 -0700 Lars-Peter Clausen <[email protected]> wrote:
Quoted 5 lines · Herve Codina
The Renesas X9250 integrates four digitally controlled potentiometers. On each potentiometer, the X9250T has a 100 kOhms total resistance and the X9250U has a 50 kOhms total resistance.
Signed-off-by Herve Codina <[email protected]>Hi,
Looks perfect! Just one small comment.
Quoted 15 lines
drivers/iio/potentiometer/x9250.c line 45
Quoted 13 lines
drivers/iio/potentiometer/x9250.c new file +13
-0+static int x9250_write8 (struct x9250 *x9250,u8 cmd,u8 val) +{ +struct spi_transfer xfer = { + .tx_buf = &x9250->spi_tx_buf, + .len =3 , + }; +int ret; + +BUILD_BUG_ON (sizeof (x9250->spi_tx_buf) <3 ); + +mutex_lock (&x9250->lock); + + x9250->spi_tx_buf[0 ] =0x50 ;The
0x50shows up as a magic constant in multiple places, a define for it would be nice.
Sure, a define will be present in next iteration.
Quoted 9 lines
drivers/iio/potentiometer/x9250.c line 54
Quoted 9 lines
drivers/iio/potentiometer/x9250.c new file +9
-0+ x9250->spi_tx_buf[1 ] = cmd; + x9250->spi_tx_buf[2 ] = val; + + ret =spi_sync_transfer (x9250->spi, &xfer,1 ); + +mutex_unlock (&x9250->lock); + +return ret; +}
Thanks for the review,
Hervé
Signature · 3 lines
Hervé Codina, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Herve Codina
maintainerPATCH 3/3 MAINTAINERS: add the Renesas X9250 driver entry
In reply to Herve CodinaAfter contributing the driver, add myself as the maintainer for the Renesas X9250 IIO driver.
--- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+)
MAINTAINERS +7 -0
@@ -17926,6 +17926,13 @@ S: Maintained F: Documentation/devicetree/bindings/clock/renesas,versaclock7.yaml F: drivers/clk/clk-versaclock7.c +RENESAS X9250 DIGITAL POTENTIOMETERS DRIVER +M: Herve Codina <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/iio/potentiometer/renesas,x9250.yaml +F: drivers/iio/potentiometer/x9250.c + RESET CONTROLLER FRAMEWORK M: Philipp Zabel <[email protected]> S: Maintained
Signature · 1 line
2.39.2