Message ID | 20221012142205.13041-1-olivier.moysan@foss.st.com |
---|---|
Headers | show |
Series | iio: stm32-adc: add support of adc for stm32mp13 | expand |
On Wed, Oct 12, 2022 at 5:23 PM Olivier Moysan <olivier.moysan@foss.st.com> wrote: > > On STM32MP13 SoCs, each ADC peripheral has a single ADC block. > These ADC peripherals, ADC1 and ADC2, are fully independent. > The STM32MP131 SoC provides only ADC2, while other STM32MP13x > SoCs provide both ADC1 and ADC2. > > The STM32MP13 ADC features and characteristics are slightly > different from STM32MP15 ADC ones, requiring a specific support > in the driver. > > This patchset enables the ADC peripheral on STM32MP135F-DK board. > > On STM32MP135F-DK board the ADC is connected to VDDA voltage > provided by the PMIC LOD1 supply, which has to be enabled through > SCMI regulator framework. > This serie introduces a fixed regulator to allow ADC probing, > while SCMI regulators support is not available. This does > not ensure ADC regulator enabling however. FWIW, Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> for patches 1,3, and 4. > Changes in v4: > - reformat patch 1 commit message > - reorder adc1 node > > v3: > - Remove blank line in tag block > - Use HZ_PER_MHZ unit for max frequency definition > - Coding style updates > > v2: > - Rework commit message length > - Add missing spaces > - Remove useless defines > > Olivier Moysan (8): > iio: adc: stm32-adc: fix channel sampling time init > dt-bindings: iio: adc: stm32-adc: add stm32mp13 compatibles > iio: adc: stm32-adc: add stm32mp13 support > iio: adc: stm32: manage min sampling time on all internal channels > ARM: dts: stm32: add adc support to stm32mp13 > ARM: dts: stm32: add adc pins muxing on stm32mp135f-dk > ARM: dts: stm32: add dummy vdd_adc regulator on stm32mp135f-dk > ARM: dts: stm32: add adc support on stm32mp135f-dk > > .../bindings/iio/adc/st,stm32-adc.yaml | 68 ++++- > arch/arm/boot/dts/stm32mp13-pinctrl.dtsi | 7 + > arch/arm/boot/dts/stm32mp131.dtsi | 43 +++ > arch/arm/boot/dts/stm32mp133.dtsi | 31 +++ > arch/arm/boot/dts/stm32mp135f-dk.dts | 33 +++ > drivers/iio/adc/stm32-adc-core.c | 30 ++- > drivers/iio/adc/stm32-adc-core.h | 30 +++ > drivers/iio/adc/stm32-adc.c | 247 +++++++++++++++--- > 8 files changed, 443 insertions(+), 46 deletions(-) > > -- > 2.25.1 >
On 10/12/22 16:22, Olivier Moysan wrote: > Add ADC1 and ADC2 support to STM32MP13 SoC family. > > The STM32MP131 provides only ADC2, while other STM32MP13 SoCs provide > both ADC1 and ADC2. > > Internal channels support limitations: > - VREFINT internal channel requires calibration data from OTP memory. > The nvmem properties used to access OTP are not defined for time being, > as OTP support is not yet enabled. > > - VBAT internal channel is not defined by default in SoC DT, and > has be defined in board DT when needed, instead. This avoids unwanted > current consumption on battery, when ADC conversions are performed > on any other channels. > > Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com> > --- > arch/arm/boot/dts/stm32mp131.dtsi | 43 +++++++++++++++++++++++++++++++ > arch/arm/boot/dts/stm32mp133.dtsi | 31 ++++++++++++++++++++++ > 2 files changed, 74 insertions(+) > > diff --git a/arch/arm/boot/dts/stm32mp131.dtsi b/arch/arm/boot/dts/stm32mp131.dtsi > index dd35a607073d..0b85e7744db5 100644 > --- a/arch/arm/boot/dts/stm32mp131.dtsi > +++ b/arch/arm/boot/dts/stm32mp131.dtsi > @@ -313,6 +313,49 @@ i2c5: i2c@4c006000 { > status = "disabled"; > }; > > + adc_2: adc@48004000 { Hi Olivier, Nodes should be sorted by address here. Maybe Alexandre will take care when applying ? With that fixed, you can add my: Reviewed-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com> Thanks, Fabrice > + compatible = "st,stm32mp13-adc-core"; > + reg = <0x48004000 0x400>; > + interrupts = <GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>; > + clocks = <&rcc ADC2>, <&rcc ADC2_K>; > + clock-names = "bus", "adc"; > + interrupt-controller; > + #interrupt-cells = <1>; > + #address-cells = <1>; > + #size-cells = <0>; > + status = "disabled"; > + > + adc2: adc@0 { > + compatible = "st,stm32mp13-adc"; > + #io-channel-cells = <1>; > + #address-cells = <1>; > + #size-cells = <0>; > + reg = <0x0>; > + interrupt-parent = <&adc_2>; > + interrupts = <0>; > + dmas = <&dmamux1 10 0x400 0x80000001>; > + dma-names = "rx"; > + status = "disabled"; > + > + channel@13 { > + reg = <13>; > + label = "vrefint"; > + }; > + channel@14 { > + reg = <14>; > + label = "vddcore"; > + }; > + channel@16 { > + reg = <16>; > + label = "vddcpu"; > + }; > + channel@17 { > + reg = <17>; > + label = "vddq_ddr"; > + }; > + }; > + }; > + > rcc: rcc@50000000 { > compatible = "st,stm32mp13-rcc", "syscon"; > reg = <0x50000000 0x1000>; > diff --git a/arch/arm/boot/dts/stm32mp133.dtsi b/arch/arm/boot/dts/stm32mp133.dtsi > index 531c263c9f46..df451c3c2a26 100644 > --- a/arch/arm/boot/dts/stm32mp133.dtsi > +++ b/arch/arm/boot/dts/stm32mp133.dtsi > @@ -33,5 +33,36 @@ m_can2: can@4400f000 { > bosch,mram-cfg = <0x1400 0 0 32 0 0 2 2>; > status = "disabled"; > }; > + > + adc_1: adc@48003000 { > + compatible = "st,stm32mp13-adc-core"; > + reg = <0x48003000 0x400>; > + interrupts = <GIC_SPI 18 IRQ_TYPE_LEVEL_HIGH>; > + clocks = <&rcc ADC1>, <&rcc ADC1_K>; > + clock-names = "bus", "adc"; > + interrupt-controller; > + #interrupt-cells = <1>; > + #address-cells = <1>; > + #size-cells = <0>; > + status = "disabled"; > + > + adc1: adc@0 { > + compatible = "st,stm32mp13-adc"; > + #io-channel-cells = <1>; > + #address-cells = <1>; > + #size-cells = <0>; > + reg = <0x0>; > + interrupt-parent = <&adc_1>; > + interrupts = <0>; > + dmas = <&dmamux1 9 0x400 0x80000001>; > + dma-names = "rx"; > + status = "disabled"; > + > + channel@18 { > + reg = <18>; > + label = "vrefint"; > + }; > + }; > + }; > }; > };
On 10/12/22 16:21, Olivier Moysan wrote: > On STM32MP13 SoCs, each ADC peripheral has a single ADC block. > These ADC peripherals, ADC1 and ADC2, are fully independent. > The STM32MP131 SoC provides only ADC2, while other STM32MP13x > SoCs provide both ADC1 and ADC2. > > The STM32MP13 ADC features and characteristics are slightly > different from STM32MP15 ADC ones, requiring a specific support > in the driver. > > This patchset enables the ADC peripheral on STM32MP135F-DK board. > > On STM32MP135F-DK board the ADC is connected to VDDA voltage > provided by the PMIC LOD1 supply, which has to be enabled through > SCMI regulator framework. > This serie introduces a fixed regulator to allow ADC probing, > while SCMI regulators support is not available. This does > not ensure ADC regulator enabling however. Hi Olivier, I've one tiny remark on PATCH 5/8, "ARM: dts: stm32: add adc support to stm32mp13" With that fixed, for the whole series, you can add my: Reviewed-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com> Thanks, Fabrice > > Changes in v4: > - reformat patch 1 commit message > - reorder adc1 node > > v3: > - Remove blank line in tag block > - Use HZ_PER_MHZ unit for max frequency definition > - Coding style updates > > v2: > - Rework commit message length > - Add missing spaces > - Remove useless defines > > Olivier Moysan (8): > iio: adc: stm32-adc: fix channel sampling time init > dt-bindings: iio: adc: stm32-adc: add stm32mp13 compatibles > iio: adc: stm32-adc: add stm32mp13 support > iio: adc: stm32: manage min sampling time on all internal channels > ARM: dts: stm32: add adc support to stm32mp13 > ARM: dts: stm32: add adc pins muxing on stm32mp135f-dk > ARM: dts: stm32: add dummy vdd_adc regulator on stm32mp135f-dk > ARM: dts: stm32: add adc support on stm32mp135f-dk > > .../bindings/iio/adc/st,stm32-adc.yaml | 68 ++++- > arch/arm/boot/dts/stm32mp13-pinctrl.dtsi | 7 + > arch/arm/boot/dts/stm32mp131.dtsi | 43 +++ > arch/arm/boot/dts/stm32mp133.dtsi | 31 +++ > arch/arm/boot/dts/stm32mp135f-dk.dts | 33 +++ > drivers/iio/adc/stm32-adc-core.c | 30 ++- > drivers/iio/adc/stm32-adc-core.h | 30 +++ > drivers/iio/adc/stm32-adc.c | 247 +++++++++++++++--- > 8 files changed, 443 insertions(+), 46 deletions(-) >
On Wed, 12 Oct 2022 16:21:58 +0200 Olivier Moysan <olivier.moysan@foss.st.com> wrote: > Fix channel init for ADC generic channel bindings. > In generic channel initialization, stm32_adc_smpr_init() is called to > initialize channel sampling time. The "st,min-sample-time-ns" property > is an optional property. If it is not defined, stm32_adc_smpr_init() is > currently skipped. > However stm32_adc_smpr_init() must always be called, to force a minimum > sampling time for the internal channels, as the minimum sampling time is > known. Make stm32_adc_smpr_init() call unconditional. > > Fixes: 796e5d0b1e9b ("iio: adc: stm32-adc: use generic binding for sample-time") > Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com> So I'm crossing my fingers a little that this fix and the rest of the series can go through different paths - looks like it should be clean. Applied to the fixes-togreg branch of iio.git and marked for stable. Thanks, Jonathan > --- > drivers/iio/adc/stm32-adc.c | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) > > diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c > index 6256977eb7f7..3cda529f081d 100644 > --- a/drivers/iio/adc/stm32-adc.c > +++ b/drivers/iio/adc/stm32-adc.c > @@ -2086,18 +2086,19 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev, > stm32_adc_chan_init_one(indio_dev, &channels[scan_index], val, > vin[1], scan_index, differential); > > + val = 0; > ret = fwnode_property_read_u32(child, "st,min-sample-time-ns", &val); > /* st,min-sample-time-ns is optional */ > - if (!ret) { > - stm32_adc_smpr_init(adc, channels[scan_index].channel, val); > - if (differential) > - stm32_adc_smpr_init(adc, vin[1], val); > - } else if (ret != -EINVAL) { > + if (ret && ret != -EINVAL) { > dev_err(&indio_dev->dev, "Invalid st,min-sample-time-ns property %d\n", > ret); > goto err; > } > > + stm32_adc_smpr_init(adc, channels[scan_index].channel, val); > + if (differential) > + stm32_adc_smpr_init(adc, vin[1], val); > + > scan_index++; > } >
On Fri, 14 Oct 2022 14:52:49 +0200 Fabrice Gasnier <fabrice.gasnier@foss.st.com> wrote: > On 10/12/22 16:21, Olivier Moysan wrote: > > On STM32MP13 SoCs, each ADC peripheral has a single ADC block. > > These ADC peripherals, ADC1 and ADC2, are fully independent. > > The STM32MP131 SoC provides only ADC2, while other STM32MP13x > > SoCs provide both ADC1 and ADC2. > > > > The STM32MP13 ADC features and characteristics are slightly > > different from STM32MP15 ADC ones, requiring a specific support > > in the driver. > > > > This patchset enables the ADC peripheral on STM32MP135F-DK board. > > > > On STM32MP135F-DK board the ADC is connected to VDDA voltage > > provided by the PMIC LOD1 supply, which has to be enabled through > > SCMI regulator framework. > > This serie introduces a fixed regulator to allow ADC probing, > > while SCMI regulators support is not available. This does > > not ensure ADC regulator enabling however. > > > Hi Olivier, > > I've one tiny remark on PATCH 5/8, "ARM: dts: stm32: add adc support to > stm32mp13" > > With that fixed, for the whole series, you can add my: > > Reviewed-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com> Applied 1 to the the fixes-togreg branch of iio.git and 2,3,4 to the togreg branch of iio.git (pushed out as testing only until I can rebase on rc1). No overlap in code affected, so this should work fine and means I don't have to remember to pick up the non fixes later in the cycle. Thanks, Jonathan > > Thanks, > Fabrice > > > > > Changes in v4: > > - reformat patch 1 commit message > > - reorder adc1 node > > > > v3: > > - Remove blank line in tag block > > - Use HZ_PER_MHZ unit for max frequency definition > > - Coding style updates > > > > v2: > > - Rework commit message length > > - Add missing spaces > > - Remove useless defines > > > > Olivier Moysan (8): > > iio: adc: stm32-adc: fix channel sampling time init > > dt-bindings: iio: adc: stm32-adc: add stm32mp13 compatibles > > iio: adc: stm32-adc: add stm32mp13 support > > iio: adc: stm32: manage min sampling time on all internal channels > > ARM: dts: stm32: add adc support to stm32mp13 > > ARM: dts: stm32: add adc pins muxing on stm32mp135f-dk > > ARM: dts: stm32: add dummy vdd_adc regulator on stm32mp135f-dk > > ARM: dts: stm32: add adc support on stm32mp135f-dk > > > > .../bindings/iio/adc/st,stm32-adc.yaml | 68 ++++- > > arch/arm/boot/dts/stm32mp13-pinctrl.dtsi | 7 + > > arch/arm/boot/dts/stm32mp131.dtsi | 43 +++ > > arch/arm/boot/dts/stm32mp133.dtsi | 31 +++ > > arch/arm/boot/dts/stm32mp135f-dk.dts | 33 +++ > > drivers/iio/adc/stm32-adc-core.c | 30 ++- > > drivers/iio/adc/stm32-adc-core.h | 30 +++ > > drivers/iio/adc/stm32-adc.c | 247 +++++++++++++++--- > > 8 files changed, 443 insertions(+), 46 deletions(-) > >
Hi Olivier On 10/12/22 16:21, Olivier Moysan wrote: > On STM32MP13 SoCs, each ADC peripheral has a single ADC block. > These ADC peripherals, ADC1 and ADC2, are fully independent. > The STM32MP131 SoC provides only ADC2, while other STM32MP13x > SoCs provide both ADC1 and ADC2. > > The STM32MP13 ADC features and characteristics are slightly > different from STM32MP15 ADC ones, requiring a specific support > in the driver. > > This patchset enables the ADC peripheral on STM32MP135F-DK board. > > On STM32MP135F-DK board the ADC is connected to VDDA voltage > provided by the PMIC LOD1 supply, which has to be enabled through > SCMI regulator framework. > This serie introduces a fixed regulator to allow ADC probing, > while SCMI regulators support is not available. This does > not ensure ADC regulator enabling however. > > Changes in v4: > - reformat patch 1 commit message > - reorder adc1 node > > v3: > - Remove blank line in tag block > - Use HZ_PER_MHZ unit for max frequency definition > - Coding style updates > > v2: > - Rework commit message length > - Add missing spaces > - Remove useless defines > > Olivier Moysan (8): > iio: adc: stm32-adc: fix channel sampling time init > dt-bindings: iio: adc: stm32-adc: add stm32mp13 compatibles > iio: adc: stm32-adc: add stm32mp13 support > iio: adc: stm32: manage min sampling time on all internal channels > ARM: dts: stm32: add adc support to stm32mp13 > ARM: dts: stm32: add adc pins muxing on stm32mp135f-dk > ARM: dts: stm32: add dummy vdd_adc regulator on stm32mp135f-dk > ARM: dts: stm32: add adc support on stm32mp135f-dk > DT patches [5 to 8] applied on stm32-next. Thanks Alex