Support ROHM BD7971x family of DACs
Subsystems (3)
cover Support ROHM BD7971x family of DACs
Support ROHM BD7971x family of DACs (and fix existing binding doc)
The ROHM BD7971[0-3] are 10-bit DACs which have similar SPI command logic, channel numbering, and VCC / VFS pin logic with the 8-bit ROHM BD7970[0-3] family DACs.
Both families use 16-bit SPI transactions where the channel which DAC word is being set, can be specified by the SPI command. The SPI command resides in the first half of the transaction, and DAC word to be set follows. The of the SPI command and the DAC word differ, (as does the length of the DAC word).
While adding the support for the new family of DACs, I noticed I had misread the existing BD7970x family of DACs data-sheet. As a result, the information about VFS pin usage on BD79702 and BD79703 is incorrect. First patch in the series is a fix to the documentation.
Rest of the patches add support to the BD7971x family of the DACs to the existing BD7970x driver. The series is based on the v7.4-rc1 + driver VFS fix, which is identical to the one in the IIO tree's 'fixes-togreg' -branch:7b9c4d1c895f ("iio: dac: rohm-bd79703: Fix full-scale voltages")
The driver-fix patch shouldn't be needed for the binding part as I forgot to fix the bindings at the same time, hence missing it from the base shouldn't conflict (what comes to the code).
I can do rebasing / split the series as (if) needed.
Matti Vaittinen (4):
dt-bindings: iio: bd79703: Fix VFS explanation
dt-bindings: iio: dac: Add ROHM BD7971x
iio: dac: rohm-bd79703: Avoid copying chip-data
bd79703: Support ROHM BD7971x DACs
.../bindings/iio/dac/rohm,bd79703.yaml | 34 ++++-- drivers/iio/dac/rohm-bd79703.c | 108 ++++++++++++++++-- 2 files changed, 120 insertions(+), 22 deletions(-)
base-commit: 0723d51fa973f0204e1c436c08a784b7b1cca795
Signature · 1 line
2.56.1
PATCH 1/4 dt-bindings: iio: bd79703: Fix VFS explanation
From: Matti Vaittinen <[email protected]>
The BD79702 and BD79703 have a VFS-pin, which is used as a full-scale voltage for part of the outputs. The binding document claims that this voltage is used as full-scale voltage for all of the outputs.
Fix the binding document by listing the exact outputs and what is used for full-scale voltage.
--- .../devicetree/bindings/iio/dac/rohm,bd79703.yaml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/iio/dac/rohm,bd79703.yaml +5 -3
@@ -34,13 +34,15 @@ properties: vfs-supply: description: - The regulator to use as a full scale voltage. The voltage should be - between 2.7V .. VCC. Not present on BD79700 and BD79701. + The regulator to use as a full scale voltage for outputs AO1 and AO2 + on BD79702, and for AO1, AO2, and AO3 on the BD79703. The voltage + should be between 2.7V .. VCC. Not present on BD79700 and BD79701. vcc-supply: description: The regulator supplying the operating voltage. Should be between - 2.7V ... 5.5V. Is used also as a Vfs on BD79700 and BD79701. + 2.7V ... 5.5V. Is used also as a Vfs for all outputs on BD79700 and + BD79701, for AO3 and AO4 on BD79702, and AO4, AO5, and AO6 on BD79703. required: - compatible
Signature · 1 line
2.56.1
PATCH 2/4 dt-bindings: iio: dac: Add ROHM BD7971x
In reply to Matti VaittinenFrom: Matti Vaittinen <[email protected]>
The ROHM BD7971[0-3] are very similar to the ROHM BD7970[0-3]. Main difference is the amount of bits in the DAC word, BD7970x having 8-bit DAC and BD7971x having 10-bit DAC.
Support BD7971x by adding compatibles:
- rohm,bd79710
- rohm,bd79711
- rohm,bd79712
- rohm,bd79713
--- .../bindings/iio/dac/rohm,bd79703.yaml | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-)
Documentation/devicetree/bindings/iio/dac/rohm,bd79703.yaml +23 -11
@@ -5,18 +5,24 @@ $id: http://devicetree.org/schemas/iio/dac/rohm,bd79703.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: ROHM BD79700, BD79701, BD79702 and BD79703 DACs +title: ROHM BD7970x, and BD7971x DACs maintainers: - Matti Vaittinen <[email protected]> description: | - The ROHM BD7970[0,1,2,3] are 8-bit DACs. The BD79700 has 2 channels, - BD79701 3 channels, BD79702 4 channels and BD79703 has 6 channels. - Datasheets for BD79702 and BD79703 can be found from - https://fscdn.rohm.com/en/products/databook/datasheet/ic/data_converter/dac/bd79702fv-lb_bd79703fv-lb-e.pdf - and for the BD79700 and the BD79701 from - https://fscdn.rohm.com/en/products/databook/datasheet/ic/data_converter/dac/bd79700fvm-lb_bd79701fvm-lb-e.pdf + The ROHM BD7970[0-3] are 8-bit DACs and BD7971[0-3] are 10-bit DACs. The + BD797x0 has 2 channels, BD797x1 3 channels, BD797x2 4 channels and BD797x3 + has 6 channels. + Datasheets: + - BD79702 and BD79703 + https://fscdn.rohm.com/en/products/databook/datasheet/ic/data_converter/dac/bd79702fv-lb_bd79703fv-lb-e.pdf + - BD79700 and BD79701 + https://fscdn.rohm.com/en/products/databook/datasheet/ic/data_converter/dac/bd79700fvm-lb_bd79701fvm-lb-e.pdf + - BD79710 and BD79711 + https://fscdn.rohm.com/en/products/databook/datasheet/ic/data_converter/dac/bd7971xfvm-lb-e.pdf + - BD79712 and BD79713 + https://fscdn.rohm.com/en/products/databook/datasheet/ic/data_converter/dac/bd7971xfv-lb-e.pdf properties: compatible:
@@ -25,6 +31,10 @@ properties: - rohm,bd79701 - rohm,bd79702 - rohm,bd79703 + - rohm,bd79710 + - rohm,bd79711 + - rohm,bd79712 + - rohm,bd79713 reg: maxItems: 1
@@ -35,14 +45,14 @@ properties: vfs-supply: description: The regulator to use as a full scale voltage for outputs AO1 and AO2 - on BD79702, and for AO1, AO2, and AO3 on the BD79703. The voltage - should be between 2.7V .. VCC. Not present on BD79700 and BD79701. + on BD797x2, and for AO1, AO2, and AO3 on the BD797x3. The voltage + should be between 2.7V .. VCC. Not present on BD797x0 and BD797x1. vcc-supply: description: The regulator supplying the operating voltage. Should be between - 2.7V ... 5.5V. Is used also as a Vfs for all outputs on BD79700 and - BD79701, for AO3 and AO4 on BD79702, and AO4, AO5, and AO6 on BD79703. + 2.7V ... 5.5V. Is used also as a Vfs for all outputs on BD797x0 and + BD797x1, for AO3 and AO4 on BD797x2, and AO4, AO5, and AO6 on BD797x3. required: - compatible
@@ -57,6 +67,8 @@ if: enum: - rohm,bd79702 - rohm,bd79703 + - rohm,bd79712 + - rohm,bd79713 then: required: - vfs-supply
Signature · 1 line
2.56.1
Re: [PATCH 2/4] dt-bindings: iio: dac: Add ROHM BD7971x
Quoted 5 lines · Matti Vaittinen
From: Matti Vaittinen <[email protected]>
The ROHM BD7971[0-3] are very similar to the ROHM BD7970[0-3]. Main difference is the amount of bits in the DAC word, BD7970x having 8-bit DAC and BD7971x having 10-bit DAC.
From the driver there's more differences than this, and that's what justifies the devices not being comatible with one another. Please note that here.
With an explanation,
pw-bot: changes-requested
Thanks,
Conor.
Quoted 90 lines
Support BD7971x by adding compatibles:
- rohm,bd79710
- rohm,bd79711
- rohm,bd79712
- rohm,bd79713Signed-off-by Matti Vaittinen <[email protected]>--- .../bindings/iio/dac/rohm,bd79703.yaml | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-)Documentation/devicetree/bindings/iio/dac/rohm,bd79703.yaml +23
-11@@ -5,18 +5,24 @@ $id: http://devicetree.org/schemas/iio/dac/rohm,bd79703.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: ROHM BD79700, BD79701, BD79702 and BD79703 DACs +title: ROHM BD7970x, and BD7971x DACs maintainers: - Matti Vaittinen <[email protected]> description: | - The ROHM BD7970[0,1,2,3] are 8-bit DACs. The BD79700 has 2 channels, - BD79701 3 channels, BD79702 4 channels and BD79703 has 6 channels. - Datasheets for BD79702 and BD79703 can be found from - https://fscdn.rohm.com/en/products/databook/datasheet/ic/data_converter/dac/bd79702fv-lb_bd79703fv-lb-e.pdf - and for the BD79700 and the BD79701 from - https://fscdn.rohm.com/en/products/databook/datasheet/ic/data_converter/dac/bd79700fvm-lb_bd79701fvm-lb-e.pdf + The ROHM BD7970[0-3] are 8-bit DACs and BD7971[0-3] are 10-bit DACs. The + BD797x0 has 2 channels, BD797x1 3 channels, BD797x2 4 channels and BD797x3 + has 6 channels. + Datasheets: + - BD79702 and BD79703 + https://fscdn.rohm.com/en/products/databook/datasheet/ic/data_converter/dac/bd79702fv-lb_bd79703fv-lb-e.pdf + - BD79700 and BD79701 + https://fscdn.rohm.com/en/products/databook/datasheet/ic/data_converter/dac/bd79700fvm-lb_bd79701fvm-lb-e.pdf + - BD79710 and BD79711 + https://fscdn.rohm.com/en/products/databook/datasheet/ic/data_converter/dac/bd7971xfvm-lb-e.pdf + - BD79712 and BD79713 + https://fscdn.rohm.com/en/products/databook/datasheet/ic/data_converter/dac/bd7971xfv-lb-e.pdf properties: compatible:@@ -25,6 +31,10 @@ properties: - rohm,bd79701 - rohm,bd79702 - rohm,bd79703 + - rohm,bd79710 + - rohm,bd79711 + - rohm,bd79712 + - rohm,bd79713 reg: maxItems: 1@@ -35,14 +45,14 @@ properties: vfs-supply: description: The regulator to use as a full scale voltage for outputs AO1 and AO2 - on BD79702, and for AO1, AO2, and AO3 on the BD79703. The voltage - should be between 2.7V .. VCC. Not present on BD79700 and BD79701. + on BD797x2, and for AO1, AO2, and AO3 on the BD797x3. The voltage + should be between 2.7V .. VCC. Not present on BD797x0 and BD797x1. vcc-supply: description: The regulator supplying the operating voltage. Should be between - 2.7V ... 5.5V. Is used also as a Vfs for all outputs on BD79700 and - BD79701, for AO3 and AO4 on BD79702, and AO4, AO5, and AO6 on BD79703. + 2.7V ... 5.5V. Is used also as a Vfs for all outputs on BD797x0 and + BD797x1, for AO3 and AO4 on BD797x2, and AO4, AO5, and AO6 on BD797x3. required: - compatible@@ -57,6 +67,8 @@ if: enum: - rohm,bd79702 - rohm,bd79703 + - rohm,bd79712 + - rohm,bd79713 then: required: - vfs-supplySignature · 1 line
2.56.1
Matti Vaittinen
maintainerRe: [PATCH 2/4] dt-bindings: iio: dac: Add ROHM BD7971x
Quoted 9 lines · Conor Dooley
Quoted 5 lines · Matti Vaittinen
From: Matti Vaittinen <[email protected]>
The ROHM BD7971[0-3] are very similar to the ROHM BD7970[0-3]. Main difference is the amount of bits in the DAC word, BD7970x having 8-bit DAC and BD7971x having 10-bit DAC.
From the driver there's more differences than this, and that's what
justifies the devices not being comatible with one another.
Thanks for the review (once again) Conor!
I think the compatibility breaking changes are actually resulting from the DAC-word size change. The bd7970x (previous, 8-bit DAC IC family) SPI-protocol had only 8 bits reserved for the DAC-word. The SPI command was placed in the 4 bits directly after the 8 DAC bits. Hence, the 10-bit DAC word we have on BD7971x family, required SPI protocol to be changed. Furthermore, the size of the DAC-word needs any ways to be visible to the users so they can use the full range. Hence, the DAC-word change from 8-bit to 10-bit really broke the compatibility.
But yes, from the driver side the changes look following: The SPI command was moved to the first 4 bits of the transfer, DAC word was increased to 10-bits and it was also moved 2 bits left, while remaining last 2 bits are now required to be zero.
I can mention above to clarify things if you feel it is important, but this really was required (well, DAC word shifting and zeroing the last 2 bits was not) because the DAC size changed. Hence, from hardware description point of view, the DAC change was the big thing.
Quoted 100 lines
Please note
that here.
With an explanation,Acked-by Conor Dooley <[email protected]>pw-bot: changes-requested
Thanks,
Conor.Quoted 90 lines
Support BD7971x by adding compatibles:
- rohm,bd79710
- rohm,bd79711
- rohm,bd79712
- rohm,bd79713Signed-off-by Matti Vaittinen <[email protected]>--- .../bindings/iio/dac/rohm,bd79703.yaml | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-)Documentation/devicetree/bindings/iio/dac/rohm,bd79703.yaml +23
-11@@ -5,18 +5,24 @@ $id: http://devicetree.org/schemas/iio/dac/rohm,bd79703.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: ROHM BD79700, BD79701, BD79702 and BD79703 DACs +title: ROHM BD7970x, and BD7971x DACs maintainers: - Matti Vaittinen <[email protected]> description: | - The ROHM BD7970[0,1,2,3] are 8-bit DACs. The BD79700 has 2 channels, - BD79701 3 channels, BD79702 4 channels and BD79703 has 6 channels. - Datasheets for BD79702 and BD79703 can be found from - https://fscdn.rohm.com/en/products/databook/datasheet/ic/data_converter/dac/bd79702fv-lb_bd79703fv-lb-e.pdf - and for the BD79700 and the BD79701 from - https://fscdn.rohm.com/en/products/databook/datasheet/ic/data_converter/dac/bd79700fvm-lb_bd79701fvm-lb-e.pdf + The ROHM BD7970[0-3] are 8-bit DACs and BD7971[0-3] are 10-bit DACs. The + BD797x0 has 2 channels, BD797x1 3 channels, BD797x2 4 channels and BD797x3 + has 6 channels. + Datasheets: + - BD79702 and BD79703 + https://fscdn.rohm.com/en/products/databook/datasheet/ic/data_converter/dac/bd79702fv-lb_bd79703fv-lb-e.pdf + - BD79700 and BD79701 + https://fscdn.rohm.com/en/products/databook/datasheet/ic/data_converter/dac/bd79700fvm-lb_bd79701fvm-lb-e.pdf + - BD79710 and BD79711 + https://fscdn.rohm.com/en/products/databook/datasheet/ic/data_converter/dac/bd7971xfvm-lb-e.pdf + - BD79712 and BD79713 + https://fscdn.rohm.com/en/products/databook/datasheet/ic/data_converter/dac/bd7971xfv-lb-e.pdf properties: compatible:@@ -25,6 +31,10 @@ properties: - rohm,bd79701 - rohm,bd79702 - rohm,bd79703 + - rohm,bd79710 + - rohm,bd79711 + - rohm,bd79712 + - rohm,bd79713 reg: maxItems: 1@@ -35,14 +45,14 @@ properties: vfs-supply: description: The regulator to use as a full scale voltage for outputs AO1 and AO2 - on BD79702, and for AO1, AO2, and AO3 on the BD79703. The voltage - should be between 2.7V .. VCC. Not present on BD79700 and BD79701. + on BD797x2, and for AO1, AO2, and AO3 on the BD797x3. The voltage + should be between 2.7V .. VCC. Not present on BD797x0 and BD797x1. vcc-supply: description: The regulator supplying the operating voltage. Should be between - 2.7V ... 5.5V. Is used also as a Vfs for all outputs on BD79700 and - BD79701, for AO3 and AO4 on BD79702, and AO4, AO5, and AO6 on BD79703. + 2.7V ... 5.5V. Is used also as a Vfs for all outputs on BD797x0 and + BD797x1, for AO3 and AO4 on BD797x2, and AO4, AO5, and AO6 on BD797x3. required: - compatible@@ -57,6 +67,8 @@ if: enum: - rohm,bd79702 - rohm,bd79703 + - rohm,bd79712 + - rohm,bd79713 then: required: - vfs-supplySignature · 1 line
2.56.1
Signature · 5 lines
Matti Vaittinen Linux kernel developer at ROHM Semiconductor Oulu Finland ~~ When things go utterly wrong vim users can always type :help! ~~
Re: [PATCH 2/4] dt-bindings: iio: dac: Add ROHM BD7971x
Quoted 27 lines · Matti Vaittinen
Quoted 9 lines · Conor Dooley
Quoted 5 lines · Matti Vaittinen
From: Matti Vaittinen <[email protected]>
The ROHM BD7971[0-3] are very similar to the ROHM BD7970[0-3]. Main difference is the amount of bits in the DAC word, BD7970x having 8-bit DAC and BD7971x having 10-bit DAC.
From the driver there's more differences than this, and that's what
justifies the devices not being comatible with one another.Thanks for the review (once again) Conor!
I think the compatibility breaking changes are actually resulting from the DAC-word size change. The bd7970x (previous, 8-bit DAC IC family) SPI-protocol had only 8 bits reserved for the DAC-word. The SPI command was placed in the 4 bits directly after the 8 DAC bits. Hence, the 10-bit DAC word we have on BD7971x family, required SPI protocol to be changed. Furthermore, the size of the DAC-word needs any ways to be visible to the users so they can use the full range. Hence, the DAC-word change from 8-bit to 10-bit really broke the compatibility.
But yes, from the driver side the changes look following: The SPI command was moved to the first 4 bits of the transfer, DAC word was increased to 10-bits and it was also moved 2 bits left, while remaining last 2 bits are now required to be zero.
Quoted 4 lines
I can mention above to clarify things if you feel it is important, but this really was required (well, DAC word shifting and zeroing the last 2 bits was not) because the DAC size changed. Hence, from hardware description point of view, the DAC change was the big thing.
I believe you that the lack of fallbacks is a requirement, don't worry about that. I think we've crossed wires though - the 8/10-bit thing is already explained and it wasn't that I was looking for a note on. It's the lack of compatibility between all of the new devices that you're adding in this patch I was talking about.
I presume the answer is going to be channel count/capability related.
Cheers,
Conor.
Quoted 102 lines
Quoted 94 lines
Please note
that here.
With an explanation,Acked-by Conor Dooley <[email protected]>pw-bot: changes-requested
Thanks,
Conor.Quoted 83 lines
Support BD7971x by adding compatibles:
- rohm,bd79710
- rohm,bd79711
- rohm,bd79712
- rohm,bd79713Signed-off-by Matti Vaittinen <[email protected]>--- .../bindings/iio/dac/rohm,bd79703.yaml | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-)Documentation/devicetree/bindings/iio/dac/rohm,bd79703.yaml +23
-11@@ -5,18 +5,24 @@ $id: http://devicetree.org/schemas/iio/dac/rohm,bd79703.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: ROHM BD79700, BD79701, BD79702 and BD79703 DACs +title: ROHM BD7970x, and BD7971x DACs maintainers: - Matti Vaittinen <[email protected]> description: | - The ROHM BD7970[0,1,2,3] are 8-bit DACs. The BD79700 has 2 channels, - BD79701 3 channels, BD79702 4 channels and BD79703 has 6 channels. - Datasheets for BD79702 and BD79703 can be found from - https://fscdn.rohm.com/en/products/databook/datasheet/ic/data_converter/dac/bd79702fv-lb_bd79703fv-lb-e.pdf - and for the BD79700 and the BD79701 from - https://fscdn.rohm.com/en/products/databook/datasheet/ic/data_converter/dac/bd79700fvm-lb_bd79701fvm-lb-e.pdf + The ROHM BD7970[0-3] are 8-bit DACs and BD7971[0-3] are 10-bit DACs. The + BD797x0 has 2 channels, BD797x1 3 channels, BD797x2 4 channels and BD797x3 + has 6 channels. + Datasheets: + - BD79702 and BD79703 + https://fscdn.rohm.com/en/products/databook/datasheet/ic/data_converter/dac/bd79702fv-lb_bd79703fv-lb-e.pdf + - BD79700 and BD79701 + https://fscdn.rohm.com/en/products/databook/datasheet/ic/data_converter/dac/bd79700fvm-lb_bd79701fvm-lb-e.pdf + - BD79710 and BD79711 + https://fscdn.rohm.com/en/products/databook/datasheet/ic/data_converter/dac/bd7971xfvm-lb-e.pdf + - BD79712 and BD79713 + https://fscdn.rohm.com/en/products/databook/datasheet/ic/data_converter/dac/bd7971xfv-lb-e.pdf properties: compatible:@@ -25,6 +31,10 @@ properties: - rohm,bd79701 - rohm,bd79702 - rohm,bd79703 + - rohm,bd79710 + - rohm,bd79711 + - rohm,bd79712 + - rohm,bd79713 reg: maxItems: 1@@ -35,14 +45,14 @@ properties: vfs-supply: description: The regulator to use as a full scale voltage for outputs AO1 and AO2 - on BD79702, and for AO1, AO2, and AO3 on the BD79703. The voltage - should be between 2.7V .. VCC. Not present on BD79700 and BD79701. + on BD797x2, and for AO1, AO2, and AO3 on the BD797x3. The voltage + should be between 2.7V .. VCC. Not present on BD797x0 and BD797x1. vcc-supply: description: The regulator supplying the operating voltage. Should be between - 2.7V ... 5.5V. Is used also as a Vfs for all outputs on BD79700 and - BD79701, for AO3 and AO4 on BD79702, and AO4, AO5, and AO6 on BD79703. + 2.7V ... 5.5V. Is used also as a Vfs for all outputs on BD797x0 and + BD797x1, for AO3 and AO4 on BD797x2, and AO4, AO5, and AO6 on BD797x3. required: - compatible@@ -57,6 +67,8 @@ if: enum: - rohm,bd79702 - rohm,bd79703 + - rohm,bd79712 + - rohm,bd79713 then: required: - vfs-supplySignature · 1 line
2.56.1Signature · 5 lines
Matti Vaittinen Linux kernel developer at ROHM Semiconductor Oulu Finland ~~ When things go utterly wrong vim users can always type :help! ~~
Matti Vaittinen
maintainerRe: [PATCH 2/4] dt-bindings: iio: dac: Add ROHM BD7971x
Quoted 33 lines · Conor Dooley
Quoted 27 lines · Matti Vaittinen
Quoted 9 lines · Conor Dooley
Quoted 5 lines · Matti Vaittinen
From: Matti Vaittinen <[email protected]>
The ROHM BD7971[0-3] are very similar to the ROHM BD7970[0-3]. Main difference is the amount of bits in the DAC word, BD7970x having 8-bit DAC and BD7971x having 10-bit DAC.
From the driver there's more differences than this, and that's what
justifies the devices not being comatible with one another.Thanks for the review (once again) Conor!
I think the compatibility breaking changes are actually resulting from the DAC-word size change. The bd7970x (previous, 8-bit DAC IC family) SPI-protocol had only 8 bits reserved for the DAC-word. The SPI command was placed in the 4 bits directly after the 8 DAC bits. Hence, the 10-bit DAC word we have on BD7971x family, required SPI protocol to be changed. Furthermore, the size of the DAC-word needs any ways to be visible to the users so they can use the full range. Hence, the DAC-word change from 8-bit to 10-bit really broke the compatibility.
But yes, from the driver side the changes look following: The SPI command was moved to the first 4 bits of the transfer, DAC word was increased to 10-bits and it was also moved 2 bits left, while remaining last 2 bits are now required to be zero.
Quoted 4 lines
I can mention above to clarify things if you feel it is important, but this really was required (well, DAC word shifting and zeroing the last 2 bits was not) because the DAC size changed. Hence, from hardware description point of view, the DAC change was the big thing.
Quoted 6 lines
I believe you that the lack of fallbacks is a requirement, don't worry about that. I think we've crossed wires though - the 8/10-bit thing is already explained and it wasn't that I was looking for a note on. It's the lack of compatibility between all of the new devices that you're adding in this patch I was talking about.
I presume the answer is going to be channel count/capability related.
Ah, thanks for the explanation! Yes, I got it now. The amount of channels changed similarly for the already supported bd7970[0-3], so I somehow didn't see the need to explain it. I will add this information when re-spinning, will wait a while for the driver-side comments.
Yours,
-- Matti
Signature · 5 lines
Matti Vaittinen Linux kernel developer at ROHM Semiconductor Oulu Finland ~~ When things go utterly wrong vim users can always type :help! ~~
Matti Vaittinen
maintainerRe: [PATCH 2/4] dt-bindings: iio: dac: Add ROHM BD7971x
In reply to Conor DooleyQuoted 33 lines · Conor Dooley
Quoted 27 lines · Matti Vaittinen
Quoted 9 lines · Conor Dooley
Quoted 5 lines · Matti Vaittinen
From: Matti Vaittinen <[email protected]>
The ROHM BD7971[0-3] are very similar to the ROHM BD7970[0-3]. Main difference is the amount of bits in the DAC word, BD7970x having 8-bit DAC and BD7971x having 10-bit DAC.
From the driver there's more differences than this, and that's what
justifies the devices not being comatible with one another.Thanks for the review (once again) Conor!
I think the compatibility breaking changes are actually resulting from the DAC-word size change. The bd7970x (previous, 8-bit DAC IC family) SPI-protocol had only 8 bits reserved for the DAC-word. The SPI command was placed in the 4 bits directly after the 8 DAC bits. Hence, the 10-bit DAC word we have on BD7971x family, required SPI protocol to be changed. Furthermore, the size of the DAC-word needs any ways to be visible to the users so they can use the full range. Hence, the DAC-word change from 8-bit to 10-bit really broke the compatibility.
But yes, from the driver side the changes look following: The SPI command was moved to the first 4 bits of the transfer, DAC word was increased to 10-bits and it was also moved 2 bits left, while remaining last 2 bits are now required to be zero.
Quoted 4 lines
I can mention above to clarify things if you feel it is important, but this really was required (well, DAC word shifting and zeroing the last 2 bits was not) because the DAC size changed. Hence, from hardware description point of view, the DAC change was the big thing.
Quoted 6 lines
I believe you that the lack of fallbacks is a requirement, don't worry about that. I think we've crossed wires though - the 8/10-bit thing is already explained and it wasn't that I was looking for a note on. It's the lack of compatibility between all of the new devices that you're adding in this patch I was talking about.
I presume the answer is going to be channel count/capability related.
Hmm.. After re-reading the patch, the patch itself has this information:
...
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Documentation/devicetree/bindings/iio/dac/rohm,bd79703.yaml line 16
Quoted 10 lines
description: |
Documentation/devicetree/bindings/iio/dac/rohm,bd79703.yaml +3
-6- The ROHM BD7970[0,1,2,3] are 8-bit DACs. The BD79700 has 2 channels, - BD79701 3 channels, BD79702 4 channels and BD79703 has 6 channels. - Datasheets for BD79702 and BD79703 can be found from - https://fscdn.rohm.com/en/products/databook/datasheet/ic/data_converter/dac/bd79702fv-lb_bd79703fv-lb-e.pdf - and for the BD79700 and the BD79701 from - https://fscdn.rohm.com/en/products/databook/datasheet/ic/data_converter/dac/bd79700fvm-lb_bd79701fvm-lb-e.pdf + The ROHM BD7970[0-3] are 8-bit DACs and BD7971[0-3] are 10-bit DACs. The + BD797x0 has 2 channels, BD797x1 3 channels, BD797x2 4 channels and BD797x3 + has 6 channels.
You would like this to be explicitly stated said in the commit message too?
Yours,
-- Matti
Signature · 5 lines
Matti Vaittinen Linux kernel developer at ROHM Semiconductor Oulu Finland ~~ When things go utterly wrong vim users can always type :help! ~~
Re: [PATCH 2/4] dt-bindings: iio: dac: Add ROHM BD7971x
Quoted 55 lines · Matti Vaittinen
Quoted 33 lines · Conor Dooley
Quoted 27 lines · Matti Vaittinen
Quoted 9 lines · Conor Dooley
Quoted 5 lines · Matti Vaittinen
From: Matti Vaittinen <[email protected]>
The ROHM BD7971[0-3] are very similar to the ROHM BD7970[0-3]. Main difference is the amount of bits in the DAC word, BD7970x having 8-bit DAC and BD7971x having 10-bit DAC.
From the driver there's more differences than this, and that's what
justifies the devices not being comatible with one another.Thanks for the review (once again) Conor!
I think the compatibility breaking changes are actually resulting from the DAC-word size change. The bd7970x (previous, 8-bit DAC IC family) SPI-protocol had only 8 bits reserved for the DAC-word. The SPI command was placed in the 4 bits directly after the 8 DAC bits. Hence, the 10-bit DAC word we have on BD7971x family, required SPI protocol to be changed. Furthermore, the size of the DAC-word needs any ways to be visible to the users so they can use the full range. Hence, the DAC-word change from 8-bit to 10-bit really broke the compatibility.
But yes, from the driver side the changes look following: The SPI command was moved to the first 4 bits of the transfer, DAC word was increased to 10-bits and it was also moved 2 bits left, while remaining last 2 bits are now required to be zero.
Quoted 4 lines
I can mention above to clarify things if you feel it is important, but this really was required (well, DAC word shifting and zeroing the last 2 bits was not) because the DAC size changed. Hence, from hardware description point of view, the DAC change was the big thing.
Quoted 6 lines
I believe you that the lack of fallbacks is a requirement, don't worry about that. I think we've crossed wires though - the 8/10-bit thing is already explained and it wasn't that I was looking for a note on. It's the lack of compatibility between all of the new devices that you're adding in this patch I was talking about.
I presume the answer is going to be channel count/capability related.Hmm.. After re-reading the patch, the patch itself has this information:
...
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Documentation/devicetree/bindings/iio/dac/rohm,bd79703.yaml line 16
Quoted 10 lines
description: |
Documentation/devicetree/bindings/iio/dac/rohm,bd79703.yaml +3
-6- The ROHM BD7970[0,1,2,3] are 8-bit DACs. The BD79700 has 2 channels, - BD79701 3 channels, BD79702 4 channels and BD79703 has 6 channels. - Datasheets for BD79702 and BD79703 can be found from - https://fscdn.rohm.com/en/products/databook/datasheet/ic/data_converter/dac/bd79702fv-lb_bd79703fv-lb-e.pdf - and for the BD79700 and the BD79701 from - https://fscdn.rohm.com/en/products/databook/datasheet/ic/data_converter/dac/bd79700fvm-lb_bd79701fvm-lb-e.pdf + The ROHM BD7970[0-3] are 8-bit DACs and BD7971[0-3] are 10-bit DACs. The + BD797x0 has 2 channels, BD797x1 3 channels, BD797x2 4 channels and BD797x3 + has 6 channels.
Quoted 1 line
You would like this to be explicitly stated said in the commit message too?
Yes, I would like it spelt out. Often channel differences don't produce incompatibility because it's taken care of by channel@### subnodes. In this patch, the diff doesn't cover the whole binding so I can't tell by looking at this that this is the incompatibility.
Notes about the sources of incompatibility is one of my person crusades, because checking that wastes a lot of time on trivial patches, that could otherwise be entirely reviewed from my mailer without checking the other patches in the series mid-reply.
PATCH 3/4 iio: dac: rohm-bd79703: Avoid copying chip-data
In reply to Matti VaittinenFrom: Matti Vaittinen <[email protected]>
The bd79703 driver data has been divided into a static, chip specific data, and to an instance specific data, which can be modified at run-time.
At the moment, only the instance-specific data is usable after probe, and only chip-type dependent constant 'num_vfs_chan', is copied to instance-specific struct.
Upcoming support for bd7971x family of chips will introduce a need to use a few more chip-specific static values at runtime. Copying them to dynamic private data struct would get wasteful.
Save some bytes and minimize data copying by storing a pointer to the constant, chip-type specific data, instead of copying all the values into the instance specific data.
--- drivers/iio/dac/rohm-bd79703.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
drivers/iio/dac/rohm-bd79703.c +11 -10
@@ -38,14 +38,6 @@ static const struct regmap_config bd79703_regmap_config = { .cache_type = REGCACHE_MAPLE, }; -/* Dynamic driver private data */ -struct bd79703_data { -struct regmap *regmap; -int vcc_mv; -int vfs_mv; -unsigned int num_vfs_chan; -}; -/* Static, IC type specific data for different variants */ struct bd7970x_chip_data {const char *name;
@@ -58,6 +50,14 @@ struct bd7970x_chip_data {unsigned int num_vfs_chan; }; +/* Dynamic driver private data */ +struct bd79703_data { +struct regmap *regmap; +const struct bd7970x_chip_data *cd; +int vcc_mv; +int vfs_mv; +}; +static int bd79703_read_raw (struct iio_dev *idev,struct iio_chan_spec const *chan,int *val,int *val2,long mask)
@@ -67,7 +67,7 @@ static int bd79703_read_raw(struct iio_dev *idev,if (mask !=IIO_CHAN_INFO_SCALE )return -EINVAL ; -if (data->num_vfs_chan > chan->channel) +if (data->cd->num_vfs_chan > chan->channel) *val = data->vfs_mv;else *val = data->vcc_mv;
@@ -224,9 +224,10 @@ static int bd79703_probe(struct spi_device *spi)return dev_err_probe (dev, ret,"Failed to get Vfs\n" ); data->vfs_mv = ret /1000 ; - data->num_vfs_chan = cd->num_vfs_chan; } + data->cd = cd; + idev->channels = cd->channels; idev->num_channels = cd->num_channels; idev->modes =INDIO_DIRECT_MODE ;
Signature · 1 line
2.56.1
Re: [PATCH 3/4] iio: dac: rohm-bd79703: Avoid copying chip-data
Quoted 8 lines · Matti Vaittinen
The bd79703 driver data has been divided into a static, chip specific data, and to an instance specific data, which can be modified at run-time.
At the moment, only the instance-specific data is usable after probe, and only chip-type dependent constant '
num_vfs_chan', is copied to instance-specific struct.
Quoted 7 lines
Upcoming support for bd7971x family of chips will introduce a need to use a few more chip-specific static values at runtime. Copying them to dynamic private data struct would get wasteful.
Save some bytes and minimize data copying by storing a pointer to the constant, chip-type specific data, instead of copying all the values into the instance specific data.
Despite our discussion about SI unit suffices, this looks good.
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH 4/4 bd79703: Support ROHM BD7971x DACs
In reply to Matti VaittinenFrom: Matti Vaittinen <[email protected]>
The BD7971x are logically similar to BD7970x. Main difference is the amount of bits in DAC-word. The BD7970x had 8-bit DAC whereas the BD7971x use 10-bit DAC word.
The SPI data format differs. The BD7971x requires two least significant bits to be zeroes, and carries the DAC word in following 10 bits. The channel number is in highest 4 bits.
Add support for the BD7971x family of DACs.
--- drivers/iio/dac/rohm-bd79703.c | 91 ++++++++++++++++++++++++++++++++-- 1 file changed, 87 insertions(+), 4 deletions(-)
drivers/iio/dac/rohm-bd79703.c +87 -4
@@ -17,6 +17,8 @@#define BD79703_DAC_BITS 8#define BD79703_REG_OUT_ALL GENMASK(2, 0) +#define BD7971X_DAC_BITS 10 +/* * The BD79703 uses 12-bit SPI commands. First four bits (high bits) define * channel(s) which are operated on, and also the mode. The mode can be to set
@@ -38,11 +40,27 @@ static const struct regmap_config bd79703_regmap_config = { .cache_type = REGCACHE_MAPLE, }; +/* The BD7971X uses 16-bit data transfers. Four high bits define the channel +* and following 10 bits define the DAC word. Two last bits must be zero. +* +* Let's try having the 4 channel-bits as an address and following bits as data +*/ +static const struct regmap_config bd7971x_regmap_config = { + .reg_bits =4 , + .val_bits =12 , + .max_register =BD79703_MAX_REGISTER , + .cache_type =REGCACHE_MAPLE , +}; +/* Static, IC type specific data for different variants */ struct bd7970x_chip_data {const char *name; +const struct regmap_config *regmap_conf;const struct iio_chan_spec *channels;int num_channels; +unsigned int num_bits; +unsigned int l_shift;/* BD7971x have DAC word shifted by 2 */ +/* * Some ICs use VFS-pin for full-scale voltage for first N channels. * We need to know these channels to get correct scale
@@ -72,7 +90,7 @@ static int bd79703_read_raw(struct iio_dev *idev,else *val = data->vcc_mv; - *val2 =BD79703_DAC_BITS ; + *val2 = data->cd->num_bits;return IIO_VAL_FRACTIONAL_LOG2 ; }
@@ -82,14 +100,17 @@ static int bd79703_write_raw(struct iio_dev *idev, int val2, long mask) {struct bd79703_data *data =iio_priv (idev); +unsigned int tmp = val;if (mask !=IIO_CHAN_INFO_RAW )return -EINVAL ; -if (val <0 || val >=1 <<BD79703_DAC_BITS ) +if (tmp >=1 << data->cd->num_bits)return -EINVAL ; -return regmap_write (data->regmap, chan->address, val); + tmp <<= data->cd->l_shift; + +return regmap_write (data->regmap, chan->address, tmp); };static const struct iio_info bd79703_info = {
@@ -156,30 +177,84 @@ static const struct iio_chan_spec bd79703_channels[] = {static const struct bd7970x_chip_data bd79700_chip_data = { .name ="bd79700" , + .regmap_conf = &bd79703_regmap_config, .channels = bd79700_channels, .num_channels =ARRAY_SIZE (bd79700_channels), .num_vfs_chan =0 , + .num_bits =BD79703_DAC_BITS , };static const struct bd7970x_chip_data bd79701_chip_data = { .name ="bd79701" , + .regmap_conf = &bd79703_regmap_config, .channels = bd79701_channels, .num_channels =ARRAY_SIZE (bd79701_channels), .num_vfs_chan =0 , + .num_bits =BD79703_DAC_BITS , };static const struct bd7970x_chip_data bd79702_chip_data = { .name ="bd79702" , + .regmap_conf = &bd79703_regmap_config, .channels = bd79702_channels, .num_channels =ARRAY_SIZE (bd79702_channels), .num_vfs_chan =2 , + .num_bits =BD79703_DAC_BITS , };static const struct bd7970x_chip_data bd79703_chip_data = { .name ="bd79703" , + .regmap_conf = &bd79703_regmap_config, + .channels = bd79703_channels, + .num_channels =ARRAY_SIZE (bd79703_channels), + .num_vfs_chan =3 , + .num_bits =BD79703_DAC_BITS , +}; + +/* +* The BD7971[0,3] have same amount of channels as BD7970[0,3]. Also the SPI +* command number for 'set DAC and output fir channel N' is same, although +* bits where the value is placed differ. We can still use the same channel +* config and only provide a different regmap config. +*/ +static const struct bd7970x_chip_data bd79710_chip_data = { + .name ="bd79710" , + .regmap_conf = &bd7971x_regmap_config, + .channels = bd79700_channels, + .num_channels =ARRAY_SIZE (bd79700_channels), + .num_vfs_chan =0 , + .num_bits =BD7971X_DAC_BITS , + .l_shift =2 , +}; + +static const struct bd7970x_chip_data bd79711_chip_data = { + .name ="bd79711" , + .regmap_conf = &bd7971x_regmap_config, + .channels = bd79701_channels, + .num_channels =ARRAY_SIZE (bd79701_channels), + .num_vfs_chan =0 , + .num_bits =BD7971X_DAC_BITS , + .l_shift =2 , +}; + +static const struct bd7970x_chip_data bd79712_chip_data = { + .name ="bd79712" , + .regmap_conf = &bd7971x_regmap_config, + .channels = bd79702_channels, + .num_channels =ARRAY_SIZE (bd79702_channels), + .num_vfs_chan =2 , + .num_bits =BD7971X_DAC_BITS , + .l_shift =2 , +}; + +static const struct bd7970x_chip_data bd79713_chip_data = { + .name ="bd79713" , + .regmap_conf = &bd7971x_regmap_config, .channels = bd79703_channels, .num_channels =ARRAY_SIZE (bd79703_channels), .num_vfs_chan =3 , + .num_bits =BD7971X_DAC_BITS , + .l_shift =2 , };static int bd79703_probe (struct spi_device *spi)
@@ -200,7 +275,7 @@ static int bd79703_probe(struct spi_device *spi) data =iio_priv (idev); - data->regmap =devm_regmap_init_spi (spi, &bd79703_regmap_config); + data->regmap =devm_regmap_init_spi (spi, cd->regmap_conf);if (IS_ERR (data->regmap))return dev_err_probe (dev,PTR_ERR (data->regmap),"Failed to initialize Regmap\n" );
@@ -247,6 +322,10 @@ static const struct spi_device_id bd79703_id[] = { { .name = "bd79701", .driver_data = (kernel_ulong_t)&bd79701_chip_data }, { .name = "bd79702", .driver_data = (kernel_ulong_t)&bd79702_chip_data }, { .name = "bd79703", .driver_data = (kernel_ulong_t)&bd79703_chip_data }, + { .name = "bd79710", .driver_data = (kernel_ulong_t)&bd79710_chip_data }, + { .name = "bd79711", .driver_data = (kernel_ulong_t)&bd79711_chip_data }, + { .name = "bd79712", .driver_data = (kernel_ulong_t)&bd79712_chip_data }, + { .name = "bd79713", .driver_data = (kernel_ulong_t)&bd79713_chip_data }, { } };MODULE_DEVICE_TABLE (spi, bd79703_id);
@@ -256,6 +335,10 @@ static const struct of_device_id bd79703_of_match[] = { { .compatible = "rohm,bd79701", .data = &bd79701_chip_data }, { .compatible = "rohm,bd79702", .data = &bd79702_chip_data }, { .compatible = "rohm,bd79703", .data = &bd79703_chip_data }, + { .compatible = "rohm,bd79710", .data = &bd79710_chip_data }, + { .compatible = "rohm,bd79711", .data = &bd79711_chip_data }, + { .compatible = "rohm,bd79712", .data = &bd79712_chip_data }, + { .compatible = "rohm,bd79713", .data = &bd79713_chip_data }, { } };MODULE_DEVICE_TABLE (of, bd79703_of_match);
Signature · 1 line
2.56.1
Re: [PATCH 4/4] bd79703: Support ROHM BD7971x DACs
Quoted 9 lines · Matti Vaittinen
The BD7971x are logically similar to BD7970x. Main difference is the amount of bits in DAC-word. The BD7970x had 8-bit DAC whereas the BD7971x use 10-bit DAC word.
The SPI data format differs. The BD7971x requires two least significant bits to be zeroes, and carries the DAC word in following 10 bits. The channel number is in highest 4 bits.
Add support for the BD7971x family of DACs.
Subject went wrong (w/o required prefix).
...
Quoted 5 lines
+/* The BD7971X uses 16-bit data transfers. Four high bits define the channel
+ * and following 10 bits define the DAC word. Two last bits must be zero.
+ *
+ * Let's try having the 4 channel-bits as an address and following bits as data
+ */
/*
* The multi-line comment style should follow this
* example. It's even inconsistent to the one used
* in the driver.
*/
...
drivers/iio/dac/rohm-bd79703.c static int bd79703_write_raw(struct iio_dev *idev, · line 103
Quoted 2 lines
drivers/iio/dac/rohm-bd79703.c +1
-0struct bd79703_data *data =iio_priv (idev); +unsigned int tmp = val;
This signed->unsigned trick begs for a comment. It's quite easy to miss and someone might introduce some issues due to that.
Signature · 2 lines
With Best Regards, Andy Shevchenko