Xilinx AMS fixes
Subsystems (4)
cover Xilinx AMS fixes
Various fixes for the Xilinx AMS driver, and addition of the required references in the ZynqMP device tree files to use it.
Robert Hancock (4):
arm64: dts: zynqmp: add AMS driver to device tree
iio: adc: xilinx-ams: Fixed missing PS channels
iio: adc: xilinx-ams: Fixed wrong sequencer register settings
iio: adc: xilinx-ams: Fix single channel switching sequence
.../arm64/boot/dts/xilinx/zynqmp-clk-ccf.dtsi | 4 +++ arch/arm64/boot/dts/xilinx/zynqmp.dtsi | 26 +++++++++++++++++++ drivers/iio/adc/xilinx-ams.c | 15 ++++++++--- 3 files changed, 41 insertions(+), 4 deletions(-)
Signature · 1 line
2.31.1
PATCH 1/4 arm64: dts: zynqmp: add AMS driver to device tree
Add an entry to the ZynqMP device tree to support the AMS device which now has a driver in mainline.
--- .../arm64/boot/dts/xilinx/zynqmp-clk-ccf.dtsi | 4 +++ arch/arm64/boot/dts/xilinx/zynqmp.dtsi | 26 +++++++++++++++++++ 2 files changed, 30 insertions(+)
arch/arm64/boot/dts/xilinx/zynqmp-clk-ccf.dtsi +4 -0
@@ -239,6 +239,10 @@ &lpd_watchdog { clocks = <&zynqmp_clk LPD_WDT>; }; +&xilinx_ams { + clocks = <&zynqmp_clk AMS_REF>; +}; + &zynqmp_dpdma { clocks = <&zynqmp_clk DPDMA_REF>; };
arch/arm64/boot/dts/xilinx/zynqmp.dtsi +26 -0
@@ -878,6 +878,32 @@ lpd_watchdog: watchdog@ff150000 { timeout-sec = <10>; }; + xilinx_ams: ams@ffa50000 { + compatible = "xlnx,zynqmp-ams"; + status = "disabled"; + interrupt-parent = <&gic>; + interrupts = <0 56 4>; + reg = <0x0 0xffa50000 0x0 0x800>; + #address-cells = <1>; + #size-cells = <1>; + #io-channel-cells = <1>; + ranges = <0 0 0xffa50800 0x800>; + + ams_ps: ams_ps@0 { + compatible = "xlnx,zynqmp-ams-ps"; + status = "disabled"; + reg = <0x0 0x400>; + }; + + ams_pl: ams_pl@400 { + compatible = "xlnx,zynqmp-ams-pl"; + status = "disabled"; + reg = <0x400 0x400>; + #address-cells = <1>; + #size-cells = <0>; + }; + }; + zynqmp_dpdma: dma-controller@fd4c0000 { compatible = "xlnx,zynqmp-dpdma"; status = "disabled";
Signature · 1 line
2.31.1
Re: [PATCH 1/4] arm64: dts: zynqmp: add AMS driver to device tree
Quoted 4 lines · Robert Hancock
Add an entry to the ZynqMP device tree to support the AMS device which now has a driver in mainline.
Signed-off-by Robert Hancock <[email protected]>
Quoted 66 lines
--- .../arm64/boot/dts/xilinx/zynqmp-clk-ccf.dtsi | 4 +++ arch/arm64/boot/dts/xilinx/zynqmp.dtsi | 26 +++++++++++++++++++ 2 files changed, 30 insertions(+)arch/arm64/boot/dts/xilinx/zynqmp-clk-ccf.dtsi +4
-0@@ -239,6 +239,10 @@ &lpd_watchdog { clocks = <&zynqmp_clk LPD_WDT>; }; +&xilinx_ams { + clocks = <&zynqmp_clk AMS_REF>; +}; + &zynqmp_dpdma { clocks = <&zynqmp_clk DPDMA_REF>; };arch/arm64/boot/dts/xilinx/zynqmp.dtsi +26
-0@@ -878,6 +878,32 @@ lpd_watchdog: watchdog@ff150000 { timeout-sec = <10>; }; + xilinx_ams: ams@ffa50000 { + compatible = "xlnx,zynqmp-ams"; + status = "disabled"; + interrupt-parent = <&gic>; + interrupts = <0 56 4>; + reg = <0x0 0xffa50000 0x0 0x800>; + #address-cells = <1>; + #size-cells = <1>; + #io-channel-cells = <1>; + ranges = <0 0 0xffa50800 0x800>; + + ams_ps: ams_ps@0 { + compatible = "xlnx,zynqmp-ams-ps"; + status = "disabled"; + reg = <0x0 0x400>; + }; + + ams_pl: ams_pl@400 { + compatible = "xlnx,zynqmp-ams-pl"; + status = "disabled"; + reg = <0x400 0x400>; + #address-cells = <1>; + #size-cells = <0>; + }; + }; + zynqmp_dpdma: dma-controller@fd4c0000 { compatible = "xlnx,zynqmp-dpdma"; status = "disabled";Signature · 7 lines
2.31.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 1/4] arm64: dts: zynqmp: add AMS driver to device tree
In reply to Robert HancockQuoted 14 lines · Robert Hancock
Add an entry to the ZynqMP device tree to support the AMS device which now has a driver in mainline.
Signed-off-by Robert Hancock <[email protected]>--- .../arm64/boot/dts/xilinx/zynqmp-clk-ccf.dtsi | 4 +++ arch/arm64/boot/dts/xilinx/zynqmp.dtsi | 26 +++++++++++++++++++ 2 files changed, 30 insertions(+)arch/arm64/boot/dts/xilinx/zynqmp-clk-ccf.dtsi +0
-0
arch/arm64/boot/dts/xilinx/zynqmp-clk-ccf.dtsi &lpd_watchdog { · line 244
Quoted 6 lines
arch/arm64/boot/dts/xilinx/zynqmp-clk-ccf.dtsi +3
-0@@ -239,6 +239,10 @@ &lpd_watchdog { clocks = <&zynqmp_clk LPD_WDT>; }; +&xilinx_ams { + clocks = <&zynqmp_clk AMS_REF>; +};
Please send this patch out of the series. It should go via soc tree not via iio tree. And unfortunately clock is not listed in DT binding document and needs to be added there. Can you please send that patch too? dtbs_check reports it as issue.
Quoted 31 lines
arch/arm64/boot/dts/xilinx/zynqmp-clk-ccf.dtsi +1
-0+ &zynqmp_dpdma { clocks = <&zynqmp_clk DPDMA_REF>; };arch/arm64/boot/dts/xilinx/zynqmp.dtsi +19
-0@@ -878,6 +878,32 @@ lpd_watchdog: watchdog@ff150000 { timeout-sec = <10>; }; + xilinx_ams: ams@ffa50000 { + compatible = "xlnx,zynqmp-ams"; + status = "disabled"; + interrupt-parent = <&gic>; + interrupts = <0 56 4>; + reg = <0x0 0xffa50000 0x0 0x800>; + #address-cells = <1>; + #size-cells = <1>; + #io-channel-cells = <1>; + ranges = <0 0 0xffa50800 0x800>; + + ams_ps: ams_ps@0 { + compatible = "xlnx,zynqmp-ams-ps"; + status = "disabled"; + reg = <0x0 0x400>; + }; + + ams_pl: ams_pl@400 { + compatible = "xlnx,zynqmp-ams-pl";
arch/arm64/boot/dts/xilinx/zynqmp.dtsi lpd_watchdog: watchdog@ff150000 { · line 909
Quoted 10 lines
arch/arm64/boot/dts/xilinx/zynqmp.dtsi +7
-0+ status = "disabled"; + reg = <0x400 0x400>; + #address-cells = <1>; + #size-cells = <0>; + }; + }; + zynqmp_dpdma: dma-controller@fd4c0000 { compatible = "xlnx,zynqmp-dpdma"; status = "disabled";
And this second piece is completely aligned with dt binding that's why it is fine.
Thanks,
Michal
PATCH 2/4 iio: adc: xilinx-ams: Fixed missing PS channels
In reply to Robert HancockThe code forgot to increment num_channels for the PS channel inputs, resulting in them not being enabled as they should.
--- drivers/iio/adc/xilinx-ams.c | 1 + 1 file changed, 1 insertion(+)
drivers/iio/adc/xilinx-ams.c +1 -0
@@ -1224,6 +1224,7 @@ static int ams_init_module(struct iio_dev *indio_dev,/* add PS channels to iio device channels */ memcpy (channels, ams_ps_channels,sizeof (ams_ps_channels)); + num_channels =ARRAY_SIZE (ams_ps_channels); }else if (fwnode_property_match_string (fwnode,"compatible" ,"xlnx,zynqmp-ams-pl" ) ==0 ) { ams->pl_base =fwnode_iomap (fwnode,0 );
Signature · 1 line
2.31.1
Re: [PATCH 2/4] iio: adc: xilinx-ams: Fixed missing PS channels
Quoted 14 lines · Robert Hancock
The code forgot to increment
num_channelsfor the PS channel inputs, resulting in them not being enabled as they should.Fixes d5c70627a794 ("iio: adc: Add Xilinx AMS driver")Signed-off-by Robert Hancock <[email protected]>--- drivers/iio/adc/xilinx-ams.c | 1 + 1 file changed, 1 insertion(+)drivers/iio/adc/xilinx-ams.c +0
-0
drivers/iio/adc/xilinx-ams.c static int ams_init_module(struct iio_dev *indio_dev, · line 1230
Quoted 7 lines
drivers/iio/adc/xilinx-ams.c +1
-0@@ -1224,6 +1224,7 @@ static int ams_init_module(struct iio_dev *indio_dev,/* add PS channels to iio device channels */ memcpy (channels, ams_ps_channels,sizeof (ams_ps_channels)); + num_channels =ARRAY_SIZE (ams_ps_channels); }else if (fwnode_property_match_string (fwnode,"compatible" ,"xlnx,zynqmp-ams-pl" ) ==0 ) { ams->pl_base =fwnode_iomap (fwnode,0 );
Looks like this is the same change just submitted by Michael Tretter ("iio:
adc: xilinx-ams: Fix num_channels for PS channels").
Signature · 3 lines
Robert Hancock Senior Hardware Designer, Calian Advanced Technologies www.calian.com
Michael Tretter
Reviewed-byRe: [PATCH 2/4] iio: adc: xilinx-ams: Fixed missing PS channels
Quoted 16 lines · Robert Hancock
Quoted 15 lines · Robert Hancock
The code forgot to increment
num_channelsfor the PS channel inputs, resulting in them not being enabled as they should.Fixes d5c70627a794 ("iio: adc: Add Xilinx AMS driver")Signed-off-by Robert Hancock <[email protected]>--- drivers/iio/adc/xilinx-ams.c | 1 + 1 file changed, 1 insertion(+)drivers/iio/adc/xilinx-ams.c +0
-0@@ -1224,6 +1224,7 @@ static int ams_init_module(struct iio_dev *indio_dev,
Quoted 9 lines
drivers/iio/adc/xilinx-ams.c static int ams_init_module(struct iio_dev *indio_dev, · line 1230
Quoted 6 lines
drivers/iio/adc/xilinx-ams.c +1
-0/* add PS channels to iio device channels */ memcpy (channels, ams_ps_channels,sizeof (ams_ps_channels)); + num_channels =ARRAY_SIZE (ams_ps_channels); }else if (fwnode_property_match_string (fwnode,"compatible" ,"xlnx,zynqmp-ams-pl" ) ==0 ) { ams->pl_base =fwnode_iomap (fwnode,0 );Looks like this is the same change just submitted by Michael Tretter ("iio:
adc: xilinx-ams: Fixnum_channelsfor PS channels").
Thanks for pointing me here.
Michael
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Jonathan Cameron
maintainerRe: [PATCH 2/4] iio: adc: xilinx-ams: Fixed missing PS channels
Quoted 27 lines · On Tue, 25 Jan 2022 09:06:34 +0100 Michael Tretter <[email protected]>…
Quoted 16 lines · Robert Hancock
Quoted 15 lines · Robert Hancock
The code forgot to increment
num_channelsfor the PS channel inputs, resulting in them not being enabled as they should.Fixes d5c70627a794 ("iio: adc: Add Xilinx AMS driver")Signed-off-by Robert Hancock <[email protected]>--- drivers/iio/adc/xilinx-ams.c | 1 + 1 file changed, 1 insertion(+)drivers/iio/adc/xilinx-ams.c +0
-0@@ -1224,6 +1224,7 @@ static int ams_init_module(struct iio_dev *indio_dev,Quoted 9 lines
drivers/iio/adc/xilinx-ams.c static int ams_init_module(struct iio_dev *indio_dev, · line 1230
Quoted 6 lines
drivers/iio/adc/xilinx-ams.c +1
-0/* add PS channels to iio device channels */ memcpy (channels, ams_ps_channels,sizeof (ams_ps_channels)); + num_channels =ARRAY_SIZE (ams_ps_channels); }else if (fwnode_property_match_string (fwnode,"compatible" ,"xlnx,zynqmp-ams-pl" ) ==0 ) { ams->pl_base =fwnode_iomap (fwnode,0 );Looks like this is the same change just submitted by Michael Tretter ("iio:
adc: xilinx-ams: Fixnum_channelsfor PS channels").
Quoted 3 lines
Thanks for pointing me here.
Reviewed-by Michael Tretter <[email protected]>
I picked up Michael's patch and will drop this one...
(based on random email reading order. I'd argue his was first in time, but then someone would point out next time I pick a patch up that is later than another one :)
Thanks,
Quoted 2 lines
Michael
PATCH 3/4 iio: adc: xilinx-ams: Fixed wrong sequencer register settings
In reply to Robert HancockRegister settings used for the sequencer configuration register were incorrect, causing some inputs to not be read properly.
--- drivers/iio/adc/xilinx-ams.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/adc/xilinx-ams.c +2 -2
@@ -91,8 +91,8 @@#define AMS_CONF1_SEQ_MASK GENMASK(15, 12)#define AMS_CONF1_SEQ_DEFAULT FIELD_PREP(AMS_CONF1_SEQ_MASK, 0) -#define AMS_CONF1_SEQ_CONTINUOUS FIELD_PREP(AMS_CONF1_SEQ_MASK, 1) -#define AMS_CONF1_SEQ_SINGLE_CHANNEL FIELD_PREP(AMS_CONF1_SEQ_MASK, 2) +#define AMS_CONF1_SEQ_CONTINUOUS FIELD_PREP(AMS_CONF1_SEQ_MASK, 2) +#define AMS_CONF1_SEQ_SINGLE_CHANNEL FIELD_PREP(AMS_CONF1_SEQ_MASK, 3)#define AMS_REG_SEQ0_MASK GENMASK(15, 0)#define AMS_REG_SEQ2_MASK GENMASK(21, 16)
Signature · 1 line
2.31.1
Re: [PATCH 3/4] iio: adc: xilinx-ams: Fixed wrong sequencer register settings
Quoted 14 lines · Robert Hancock
Register settings used for the sequencer configuration register were incorrect, causing some inputs to not be read properly.
Fixes d5c70627a794 ("iio: adc: Add Xilinx AMS driver")Signed-off-by Robert Hancock <[email protected]>--- drivers/iio/adc/xilinx-ams.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/iio/adc/xilinx-ams.c +0
-0
drivers/iio/adc/xilinx-ams.c line 95
Quoted 7 lines
drivers/iio/adc/xilinx-ams.c +2
-2@@ -91,8 +91,8 @@#define AMS_CONF1_SEQ_MASK GENMASK(15, 12)#define AMS_CONF1_SEQ_DEFAULT FIELD_PREP(AMS_CONF1_SEQ_MASK, 0) -#define AMS_CONF1_SEQ_CONTINUOUS FIELD_PREP(AMS_CONF1_SEQ_MASK, 1) -#define AMS_CONF1_SEQ_SINGLE_CHANNEL FIELD_PREP(AMS_CONF1_SEQ_MASK, 2) +#define AMS_CONF1_SEQ_CONTINUOUS FIELD_PREP(AMS_CONF1_SEQ_MASK, 2) +#define AMS_CONF1_SEQ_SINGLE_CHANNEL FIELD_PREP(AMS_CONF1_SEQ_MASK, 3)
The TRM states that Continuous Loop Mode is 2, but Single Pass Sequence Mode is 1, not 3. Is there a reason, why you need to set both bits?
Michael
Quoted 12 lines
drivers/iio/adc/xilinx-ams.c +0
-0#define AMS_REG_SEQ0_MASK GENMASK(15, 0)#define AMS_REG_SEQ2_MASK GENMASK(21, 16)Signature · 7 lines
2.31.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 3/4] iio: adc: xilinx-ams: Fixed wrong sequencer register settings
Quoted 16 lines · Michael Tretter
Quoted 15 lines · Robert Hancock
Register settings used for the sequencer configuration register were incorrect, causing some inputs to not be read properly.
Fixes d5c70627a794 ("iio: adc: Add Xilinx AMS driver")Signed-off-by Robert Hancock <[email protected]>--- drivers/iio/adc/xilinx-ams.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/iio/adc/xilinx-ams.c +0
-0@@ -91,8 +91,8 @@
Quoted 12 lines
drivers/iio/adc/xilinx-ams.c line 98
Quoted 9 lines
drivers/iio/adc/xilinx-ams.c +2
-2#define AMS_CONF1_SEQ_MASK GENMASK(15, 12)#define AMS_CONF1_SEQ_DEFAULT FIELD_PREP(AMS_CONF1_SEQ_MASK, 0) -#define AMS_CONF1_SEQ_CONTINUOUS FIELD_PREP(AMS_CONF1_SEQ_MASK, 1) -#define AMS_CONF1_SEQ_SINGLE_CHANNEL FIELD_PREP(AMS_CONF1_SEQ_MASK, 2) +#define AMS_CONF1_SEQ_CONTINUOUS FIELD_PREP(AMS_CONF1_SEQ_MASK, 2) +#define AMS_CONF1_SEQ_SINGLE_CHANNEL FIELD_PREP(AMS_CONF1_SEQ_MASK, 3)The TRM states that Continuous Loop Mode is 2, but Single Pass Sequence Mode is 1, not 3. Is there a reason, why you need to set both bits?
Single pass sequence mode (1) just runs the same sequence only once. To read these values it needs to switch to single channel mode (3).
The register bits are defined in Table 3-8 of
https://www.xilinx.com/support/documentation/user_guides/ug580-ultrascale-sysmon.pdf
.
Quoted 15 lines
Michael
Quoted 12 lines
#define
AMS_REG_SEQ0_MASKGENMASK(15, 0)
#defineAMS_REG_SEQ2_MASKGENMASK(21, 16)Signature · 7 lines
2.31.1 _______________________________________________ linux-arm-kernel mailing list [email protected] https://urldefense.com/v3/__http://lists.infradead.org/mailman/listinfo/linux-arm-kernel__;!!IOGos0k!yGFEjSC1BL20lwurby914len0HCLXyzarwxKJP9Jx30qv_qrERSkRJUiVo_2MdusMVA$
Signature · 3 lines
Robert Hancock Senior Hardware Designer, Calian Advanced Technologies www.calian.com
Michael Tretter
Reviewed-byRe: [PATCH 3/4] iio: adc: xilinx-ams: Fixed wrong sequencer register settings
Quoted 30 lines · Robert Hancock
Quoted 16 lines · Michael Tretter
Quoted 15 lines · Robert Hancock
Register settings used for the sequencer configuration register were incorrect, causing some inputs to not be read properly.
Fixes d5c70627a794 ("iio: adc: Add Xilinx AMS driver")Signed-off-by Robert Hancock <[email protected]>--- drivers/iio/adc/xilinx-ams.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/iio/adc/xilinx-ams.c +0
-0@@ -91,8 +91,8 @@Quoted 12 lines
drivers/iio/adc/xilinx-ams.c line 98
Quoted 9 lines
drivers/iio/adc/xilinx-ams.c +2
-2#define AMS_CONF1_SEQ_MASK GENMASK(15, 12)#define AMS_CONF1_SEQ_DEFAULT FIELD_PREP(AMS_CONF1_SEQ_MASK, 0) -#define AMS_CONF1_SEQ_CONTINUOUS FIELD_PREP(AMS_CONF1_SEQ_MASK, 1) -#define AMS_CONF1_SEQ_SINGLE_CHANNEL FIELD_PREP(AMS_CONF1_SEQ_MASK, 2) +#define AMS_CONF1_SEQ_CONTINUOUS FIELD_PREP(AMS_CONF1_SEQ_MASK, 2) +#define AMS_CONF1_SEQ_SINGLE_CHANNEL FIELD_PREP(AMS_CONF1_SEQ_MASK, 3)The TRM states that Continuous Loop Mode is 2, but Single Pass Sequence Mode is 1, not 3. Is there a reason, why you need to set both bits?
Quoted 6 lines
Single pass sequence mode (1) just runs the same sequence only once. To read these values it needs to switch to single channel mode (3).
The register bits are defined in Table 3-8 of
https://www.xilinx.com/support/documentation/user_guides/ug580-ultrascale-sysmon.pdf
.
Thanks for the clarification.
Quoted 20 lines
Quoted 16 lines
Michael
Quoted 12 lines
#define
AMS_REG_SEQ0_MASKGENMASK(15, 0)
#defineAMS_REG_SEQ2_MASKGENMASK(21, 16)Signature · 7 lines
2.31.1 _______________________________________________ linux-arm-kernel mailing list [email protected] https://urldefense.com/v3/__http://lists.infradead.org/mailman/listinfo/linux-arm-kernel__;!!IOGos0k!yGFEjSC1BL20lwurby914len0HCLXyzarwxKJP9Jx30qv_qrERSkRJUiVo_2MdusMVA$Signature · 3 lines
Robert Hancock Senior Hardware Designer, Calian Advanced Technologies www.calian.com
Re: [PATCH 3/4] iio: adc: xilinx-ams: Fixed wrong sequencer register settings
Quoted 34 lines · On Wed, 26 Jan 2022 10:12:50 +0100 Michael Tretter <[email protected]>…
Quoted 33 lines · Robert Hancock
Quoted 16 lines · Michael Tretter
Quoted 15 lines · Robert Hancock
Register settings used for the sequencer configuration register were incorrect, causing some inputs to not be read properly.
Fixes d5c70627a794 ("iio: adc: Add Xilinx AMS driver")Signed-off-by Robert Hancock <[email protected]>--- drivers/iio/adc/xilinx-ams.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/iio/adc/xilinx-ams.c +0
-0@@ -91,8 +91,8 @@Quoted 12 lines
drivers/iio/adc/xilinx-ams.c line 98
Quoted 9 lines
drivers/iio/adc/xilinx-ams.c +2
-2#define AMS_CONF1_SEQ_MASK GENMASK(15, 12)#define AMS_CONF1_SEQ_DEFAULT FIELD_PREP(AMS_CONF1_SEQ_MASK, 0) -#define AMS_CONF1_SEQ_CONTINUOUS FIELD_PREP(AMS_CONF1_SEQ_MASK, 1) -#define AMS_CONF1_SEQ_SINGLE_CHANNEL FIELD_PREP(AMS_CONF1_SEQ_MASK, 2) +#define AMS_CONF1_SEQ_CONTINUOUS FIELD_PREP(AMS_CONF1_SEQ_MASK, 2) +#define AMS_CONF1_SEQ_SINGLE_CHANNEL FIELD_PREP(AMS_CONF1_SEQ_MASK, 3)The TRM states that Continuous Loop Mode is 2, but Single Pass Sequence Mode is 1, not 3. Is there a reason, why you need to set both bits?
Single pass sequence mode (1) just runs the same sequence only once. To read these values it needs to switch to single channel mode (3).
Quoted 7 lines
Quoted 3 lines
The register bits are defined in Table 3-8 of
https://www.xilinx.com/support/documentation/user_guides/ug580-ultrascale-sysmon.pdf
.Thanks for the clarification.
Reviewed-by Michael Tretter <[email protected]>
Applied to the fixes-togreg branch of iio.git
Thanks,
Jonathan
PATCH 4/4 iio: adc: xilinx-ams: Fix single channel switching sequence
In reply to Robert HancockSome of the AMS channels need to be read by switching into single-channel mode from the normal polling sequence. There was a logic issue in this switching code that could cause the first read of these channels to read back as zero.
It appears that the sequencer should be set back to default mode before changing the channel selection, and the channel should be set before switching the sequencer back into single-channel mode.
Also, write 1 to the EOC bit in the status register to clear it before waiting for it to become set, so that we actually wait for a new conversion to complete, and don't proceed based on a previous conversion completing.
--- drivers/iio/adc/xilinx-ams.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/iio/adc/xilinx-ams.c +8 -2
@@ -530,14 +530,18 @@ static int ams_enable_single_channel(struct ams *ams, unsigned int offset)return -EINVAL ; } -/* set single channel, sequencer off mode */ +/* put sysmon in a soft reset to change the sequence */ ams_ps_update_reg (ams,AMS_REG_CONFIG1 ,AMS_CONF1_SEQ_MASK , -AMS_CONF1_SEQ_SINGLE_CHANNEL ); +AMS_CONF1_SEQ_DEFAULT );/* write the channel number */ ams_ps_update_reg (ams,AMS_REG_CONFIG0 ,AMS_CONF0_CHANNEL_NUM_MASK , channel_num); +/* set single channel, sequencer off mode */ +ams_ps_update_reg (ams,AMS_REG_CONFIG1 ,AMS_CONF1_SEQ_MASK , +AMS_CONF1_SEQ_SINGLE_CHANNEL ); +return 0 ; }
@@ -551,6 +555,8 @@ static int ams_read_vcc_reg(struct ams *ams, unsigned int offset, u32 *data)if (ret)return ret; +/* clear end-of-conversion flag, wait for next conversion to complete */ +writel (expect, ams->base +AMS_ISR_1 ); ret =readl_poll_timeout (ams->base +AMS_ISR_1 , reg, (reg & expect),AMS_INIT_POLL_TIME_US ,AMS_INIT_TIMEOUT_US );if (ret)
Signature · 1 line
2.31.1
Jonathan Cameron
maintainerRe: [PATCH 4/4] iio: adc: xilinx-ams: Fix single channel switching sequence
Quoted 9 lines · On Wed, 19 Jan 2022 19:02:46 -0600 Robert Hancock <[email protected]>…
Some of the AMS channels need to be read by switching into single-channel mode from the normal polling sequence. There was a logic issue in this switching code that could cause the first read of these channels to read back as zero.
It appears that the sequencer should be set back to default mode before changing the channel selection, and the channel should be set before switching the sequencer back into single-channel mode.
Quoted 7 lines
Also, write 1 to the EOC bit in the status register to clear it before waiting for it to become set, so that we actually wait for a new conversion to complete, and don't proceed based on a previous conversion completing.
Fixes d5c70627a794 ("iio: adc: Add Xilinx AMS driver")Signed-off-by Robert Hancock <[email protected]>
Looking for an Ack from Anand or someone else familiar with this device.
Thanks,
Jonathan
Quoted 38 lines
--- drivers/iio/adc/xilinx-ams.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)drivers/iio/adc/xilinx-ams.c +8
-2@@ -530,14 +530,18 @@ static int ams_enable_single_channel(struct ams *ams, unsigned int offset)return -EINVAL ; } -/* set single channel, sequencer off mode */ +/* put sysmon in a soft reset to change the sequence */ ams_ps_update_reg (ams,AMS_REG_CONFIG1 ,AMS_CONF1_SEQ_MASK , -AMS_CONF1_SEQ_SINGLE_CHANNEL ); +AMS_CONF1_SEQ_DEFAULT );/* write the channel number */ ams_ps_update_reg (ams,AMS_REG_CONFIG0 ,AMS_CONF0_CHANNEL_NUM_MASK , channel_num); +/* set single channel, sequencer off mode */ +ams_ps_update_reg (ams,AMS_REG_CONFIG1 ,AMS_CONF1_SEQ_MASK , +AMS_CONF1_SEQ_SINGLE_CHANNEL ); +return 0 ; }@@ -551,6 +555,8 @@ static int ams_read_vcc_reg(struct ams *ams, unsigned int offset, u32 *data)if (ret)return ret; +/* clear end-of-conversion flag, wait for next conversion to complete */ +writel (expect, ams->base +AMS_ISR_1 ); ret =readl_poll_timeout (ams->base +AMS_ISR_1 , reg, (reg & expect),AMS_INIT_POLL_TIME_US ,AMS_INIT_TIMEOUT_US );if (ret)