mbox series

[0/4] rtc: stm32: add pinctrl interface to handle RTC outs

Message ID 20240711140843.3201530-1-valentin.caron@foss.st.com (mailing list archive)
Headers show
Series rtc: stm32: add pinctrl interface to handle RTC outs | expand

Message

Valentin Caron July 11, 2024, 2:08 p.m. UTC
This series adds a pinctrl/pinmux interface to control STM32 RTC outputs.

Theses two signals output are possible:
 - LSCO (Low Speed Clock Output) that allow to output LSE clock on a pin.
   On STM32MPU Discovery boards, this feature is used to generate a clock
   to Wifi/Bluetooth module.
 - Alarm out that allow to send a pulse on a pin when alarm A of the RTC
   expires.

First attempt [1] was based on 'st,' vendor properties, this one is based
on pinctrl and pinmux framework.

As device-trees will be upstreamed separately, here is an example:

stm32-pinctrl {
    rtc_rsvd_pins_a: rtc-rsvd-0 {
        pins {
            pinmux = <STM32_PINMUX('B', 2, AF1)>, /* OUT2 */
                     <STM32_PINMUX('I', 8, ANALOG)>; /* OUT2_RMP */
        };
    };
};

stm32-rtc {
    pinctrl-0 = <&rtc_rsvd_pins_a &rtc_alarma_pins_a>;

    /* Enable by foo-device */
    rtc_lsco_pins_a: rtc-lsco-0 {
        pins = "out2_rmp";
        function = "lsco";
    };

    /* Enable by stm32-rtc hog */
    rtc_alarma_pins_a: rtc-alarma-0 {
        pins = "out2";
        function = "alarm-a";
    };
};

foo-device {
    pinctrl-0 = <&rtc_lsco_pins_a>;
};

[1] https://lore.kernel.org/linux-arm-kernel/20220504130617.331290-5-valentin.caron@foss.st.com/t/#m37935e92315e22bbe085775096175afc05b7ff09

Valentin Caron (4):
  dt-bindings: rtc: stm32: describe pinmux nodes
  rtc: stm32: add pinctrl and pinmux interfaces
  rtc: stm32: add Low Speed Clock Output (LSCO) support
  rtc: stm32: add alarm A out feature

 .../devicetree/bindings/rtc/st,stm32-rtc.yaml |  28 ++
 drivers/rtc/Kconfig                           |   1 +
 drivers/rtc/rtc-stm32.c                       | 281 ++++++++++++++++++
 3 files changed, 310 insertions(+)

Comments

Alexandre Belloni July 15, 2024, 9:12 p.m. UTC | #1
Hello,

On 11/07/2024 16:08:39+0200, Valentin Caron wrote:
> This series adds a pinctrl/pinmux interface to control STM32 RTC outputs.
> 
> Theses two signals output are possible:
>  - LSCO (Low Speed Clock Output) that allow to output LSE clock on a pin.
>    On STM32MPU Discovery boards, this feature is used to generate a clock
>    to Wifi/Bluetooth module.
>  - Alarm out that allow to send a pulse on a pin when alarm A of the RTC
>    expires.
> 
> First attempt [1] was based on 'st,' vendor properties, this one is based
> on pinctrl and pinmux framework.
> 
> As device-trees will be upstreamed separately, here is an example:
> 
> stm32-pinctrl {
>     rtc_rsvd_pins_a: rtc-rsvd-0 {
>         pins {
>             pinmux = <STM32_PINMUX('B', 2, AF1)>, /* OUT2 */
>                      <STM32_PINMUX('I', 8, ANALOG)>; /* OUT2_RMP */
>         };
>     };
> };
> 
> stm32-rtc {
>     pinctrl-0 = <&rtc_rsvd_pins_a &rtc_alarma_pins_a>;
> 
>     /* Enable by foo-device */
>     rtc_lsco_pins_a: rtc-lsco-0 {
>         pins = "out2_rmp";
>         function = "lsco";
>     };
> 
>     /* Enable by stm32-rtc hog */
>     rtc_alarma_pins_a: rtc-alarma-0 {
>         pins = "out2";
>         function = "alarm-a";
>     };
> };
> 
> foo-device {
>     pinctrl-0 = <&rtc_lsco_pins_a>;
> };
> 

This all seems good to me, I let you fix the various issues that have
been reported. I was just wondering whether the LSCO clock was registered
early enough to be used but I guess you tested that.
Valentin Caron July 17, 2024, 7:57 a.m. UTC | #2
On 7/15/24 23:12, Alexandre Belloni wrote:
> Hello,
> 
> On 11/07/2024 16:08:39+0200, Valentin Caron wrote:
>> This series adds a pinctrl/pinmux interface to control STM32 RTC outputs.
>>
>> Theses two signals output are possible:
>>   - LSCO (Low Speed Clock Output) that allow to output LSE clock on a pin.
>>     On STM32MPU Discovery boards, this feature is used to generate a clock
>>     to Wifi/Bluetooth module.
>>   - Alarm out that allow to send a pulse on a pin when alarm A of the RTC
>>     expires.
>>
>> First attempt [1] was based on 'st,' vendor properties, this one is based
>> on pinctrl and pinmux framework.
>>
>> As device-trees will be upstreamed separately, here is an example:
>>
>> stm32-pinctrl {
>>      rtc_rsvd_pins_a: rtc-rsvd-0 {
>>          pins {
>>              pinmux = <STM32_PINMUX('B', 2, AF1)>, /* OUT2 */
>>                       <STM32_PINMUX('I', 8, ANALOG)>; /* OUT2_RMP */
>>          };
>>      };
>> };
>>
>> stm32-rtc {
>>      pinctrl-0 = <&rtc_rsvd_pins_a &rtc_alarma_pins_a>;
>>
>>      /* Enable by foo-device */
>>      rtc_lsco_pins_a: rtc-lsco-0 {
>>          pins = "out2_rmp";
>>          function = "lsco";
>>      };
>>
>>      /* Enable by stm32-rtc hog */
>>      rtc_alarma_pins_a: rtc-alarma-0 {
>>          pins = "out2";
>>          function = "alarm-a";
>>      };
>> };
>>
>> foo-device {
>>      pinctrl-0 = <&rtc_lsco_pins_a>;
>> };
>>
> 
> This all seems good to me, I let you fix the various issues that have
> been reported. I was just wondering whether the LSCO clock was registered
> early enough to be used but I guess you tested that.
> 

Hi,

Here it is:
https://lore.kernel.org/lkml/20240717074835.2210411-1valentin.caron@foss.st.com/

Yes it works fine, RTC is probed early enough in the boot sequence, and 
so Wifi/BT module does not have an issue to get the LSCO clock.

Thanks,
Valentin