mbox series

[v6,0/6] clockevent: add low power STM32 timer

Message ID 20200401083909.18886-1-benjamin.gaignard@st.com
Headers show
Series clockevent: add low power STM32 timer | expand

Message

Benjamin GAIGNARD April 1, 2020, 8:39 a.m. UTC
This series add low power timer as boadcast clockevent device.
Low power timer could runs even when CPUs are in idle mode and 
could wakeup them.

version 6:
- simplify binding, DT and code to use only one interrupt

version 5:
- document interrupts and interrupt-names bindings
- use a different wake up interrupt
- add device-tree patch
- make STM32MP157 select low power timer configuration flag
- enable fast_io in regmap configuration

version 4:
- move defines in mfd/stm32-lptimer.h
- change compatible and subnode names
- document wakeup-source property
- reword commit message
- make driver Kconfig depends of MFD_STM32_LPTIMER
- remove useless include
- remove rate and clk fields from the private structure
- to add comments about the registers sequence in stm32_clkevent_lp_set_timer
- rework probe function and use devm_request_irq()
- do not allow module to be removed

version 3:
- fix timer set sequence
- don't forget to free irq on remove function
- use devm_kzalloc to simplify errors handling in probe function

version 2:
- stm32 clkevent driver is now a child of the stm32 lp timer node
- add a probe function and adpat the driver to use regmap provide
  by it parent
- stop using timer_of helpers



Benjamin Gaignard (6):
  dt-bindings: mfd: Document STM32 low power timer bindings
  ARM: dts: stm32: Add timer subnodes on stm32mp15 SoCs
  mfd: stm32: Add defines to be used for clkevent purpose
  mfd: stm32: enable regmap fast_io for stm32-lptimer
  clocksource: Add Low Power STM32 timers driver
  ARM: mach-stm32: select low power timer for STM32MP157

 .../devicetree/bindings/mfd/st,stm32-lptimer.yaml  |  21 ++
 arch/arm/boot/dts/stm32mp151.dtsi                  |  35 ++++
 arch/arm/mach-stm32/Kconfig                        |   1 +
 drivers/clocksource/Kconfig                        |   4 +
 drivers/clocksource/Makefile                       |   1 +
 drivers/clocksource/timer-stm32-lp.c               | 221 +++++++++++++++++++++
 drivers/mfd/stm32-lptimer.c                        |   1 +
 include/linux/mfd/stm32-lptimer.h                  |   5 +
 8 files changed, 289 insertions(+)
 create mode 100644 drivers/clocksource/timer-stm32-lp.c

Comments

Fabrice Gasnier April 1, 2020, 8:52 a.m. UTC | #1
On 4/1/20 10:39 AM, Benjamin Gaignard wrote:
> Add defines to be able to enable/clear irq and configure one shot mode.
> 
> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@st.com>
> Acked-by: Lee Jones <lee.jones@linaro.org>
> ---
>  include/linux/mfd/stm32-lptimer.h | 5 +++++
>  1 file changed, 5 insertions(+)

Hi Benjamin,

Acked-by: Fabrice Gasnier <fabrice.gasnier@st.com>

Thanks,
Fabrice

> 
> diff --git a/include/linux/mfd/stm32-lptimer.h b/include/linux/mfd/stm32-lptimer.h
> index 605f62264825..90b20550c1c8 100644
> --- a/include/linux/mfd/stm32-lptimer.h
> +++ b/include/linux/mfd/stm32-lptimer.h
> @@ -27,10 +27,15 @@
>  #define STM32_LPTIM_CMPOK		BIT(3)
>  
>  /* STM32_LPTIM_ICR - bit fields */
> +#define STM32_LPTIM_ARRMCF		BIT(1)
>  #define STM32_LPTIM_CMPOKCF_ARROKCF	GENMASK(4, 3)
>  
> +/* STM32_LPTIM_IER - bit flieds */
> +#define STM32_LPTIM_ARRMIE	BIT(1)
> +
>  /* STM32_LPTIM_CR - bit fields */
>  #define STM32_LPTIM_CNTSTRT	BIT(2)
> +#define STM32_LPTIM_SNGSTRT	BIT(1)
>  #define STM32_LPTIM_ENABLE	BIT(0)
>  
>  /* STM32_LPTIM_CFGR - bit fields */
>
Fabrice Gasnier April 1, 2020, 8:52 a.m. UTC | #2
On 4/1/20 10:39 AM, Benjamin Gaignard wrote:
> Because stm32-lptimer need to write in registers in interrupt context
> enable regmap fast_io to use a spin_lock to protect registers access
> rather than a mutex.
> 
> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@st.com>
> ---
>  drivers/mfd/stm32-lptimer.c | 1 +
>  1 file changed, 1 insertion(+)
Hi Benjamin,

Acked-by: Fabrice Gasnier <fabrice.gasnier@st.com>

Thanks,
Fabrice
> 
> diff --git a/drivers/mfd/stm32-lptimer.c b/drivers/mfd/stm32-lptimer.c
> index a00f99f36559..746e51a17cc8 100644
> --- a/drivers/mfd/stm32-lptimer.c
> +++ b/drivers/mfd/stm32-lptimer.c
> @@ -17,6 +17,7 @@ static const struct regmap_config stm32_lptimer_regmap_cfg = {
>  	.val_bits = 32,
>  	.reg_stride = sizeof(u32),
>  	.max_register = STM32_LPTIM_MAX_REGISTER,
> +	.fast_io = true,
>  };
>  
>  static int stm32_lptimer_detect_encoder(struct stm32_lptimer *ddata)
>
Lee Jones April 16, 2020, 7:03 a.m. UTC | #3
On Wed, 01 Apr 2020, Benjamin Gaignard wrote:

> Because stm32-lptimer need to write in registers in interrupt context
> enable regmap fast_io to use a spin_lock to protect registers access
> rather than a mutex.
> 
> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@st.com>
> ---
>  drivers/mfd/stm32-lptimer.c | 1 +
>  1 file changed, 1 insertion(+)

For my own reference:
  Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>
Lee Jones April 16, 2020, 7:04 a.m. UTC | #4
On Wed, 01 Apr 2020, Benjamin Gaignard wrote:

> This series add low power timer as boadcast clockevent device.
> Low power timer could runs even when CPUs are in idle mode and 
> could wakeup them.
> 
> version 6:
> - simplify binding, DT and code to use only one interrupt
> 
> version 5:
> - document interrupts and interrupt-names bindings
> - use a different wake up interrupt
> - add device-tree patch
> - make STM32MP157 select low power timer configuration flag
> - enable fast_io in regmap configuration
> 
> version 4:
> - move defines in mfd/stm32-lptimer.h
> - change compatible and subnode names
> - document wakeup-source property
> - reword commit message
> - make driver Kconfig depends of MFD_STM32_LPTIMER
> - remove useless include
> - remove rate and clk fields from the private structure
> - to add comments about the registers sequence in stm32_clkevent_lp_set_timer
> - rework probe function and use devm_request_irq()
> - do not allow module to be removed
> 
> version 3:
> - fix timer set sequence
> - don't forget to free irq on remove function
> - use devm_kzalloc to simplify errors handling in probe function
> 
> version 2:
> - stm32 clkevent driver is now a child of the stm32 lp timer node
> - add a probe function and adpat the driver to use regmap provide
>   by it parent
> - stop using timer_of helpers
> 
> 
> Benjamin Gaignard (6):
>   dt-bindings: mfd: Document STM32 low power timer bindings
>   ARM: dts: stm32: Add timer subnodes on stm32mp15 SoCs
>   mfd: stm32: Add defines to be used for clkevent purpose
>   mfd: stm32: enable regmap fast_io for stm32-lptimer
>   clocksource: Add Low Power STM32 timers driver
>   ARM: mach-stm32: select low power timer for STM32MP157
> 
>  .../devicetree/bindings/mfd/st,stm32-lptimer.yaml  |  21 ++
>  arch/arm/boot/dts/stm32mp151.dtsi                  |  35 ++++
>  arch/arm/mach-stm32/Kconfig                        |   1 +
>  drivers/clocksource/Kconfig                        |   4 +
>  drivers/clocksource/Makefile                       |   1 +
>  drivers/clocksource/timer-stm32-lp.c               | 221 +++++++++++++++++++++
>  drivers/mfd/stm32-lptimer.c                        |   1 +
>  include/linux/mfd/stm32-lptimer.h                  |   5 +

I'd be happy to take this set, but you need Acks from the other
subsystem Maintainers before I can do so.

>  8 files changed, 289 insertions(+)
>  create mode 100644 drivers/clocksource/timer-stm32-lp.c
>