* [PATCH 1/9] dt-bindings: mfd: stm32-timers: add support for stm32mp25
2024-12-18 9:01 [PATCH 0/9] Add STM32MP25 timers support: MFD, PWM, IIO and counter drivers Fabrice Gasnier
@ 2024-12-18 9:01 ` Fabrice Gasnier
2024-12-18 17:05 ` Conor Dooley
2024-12-18 9:01 ` [PATCH 2/9] " Fabrice Gasnier
` (7 subsequent siblings)
8 siblings, 1 reply; 16+ messages in thread
From: Fabrice Gasnier @ 2024-12-18 9:01 UTC (permalink / raw)
To: lee, robh, krzk+dt, conor+dt, alexandre.torgue, wbg, jic23,
ukleinek
Cc: catalin.marinas, will, devicetree, linux-stm32, linux-arm-kernel,
linux-kernel, linux-iio, linux-pwm, olivier.moysan
Add a new stm32mp25 compatible to stm32-timer dt-bindings in order to
support the STM32MP25 SoC. Some features has been added or updated in
the stm32-timer timer such as:
- hardware configuration and identification registers to read the timer
version and capabilities (counter width, number of channels...)
- dithering mode (can be used to extend PWM resolution)
- input triggers list
- new counter modes
- various bit-field updates
- power-domains property
Timer trigger identifier can be up to 19 (from timer 20)
Signed-off-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
---
.../bindings/mfd/st,stm32-timers.yaml | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/Documentation/devicetree/bindings/mfd/st,stm32-timers.yaml b/Documentation/devicetree/bindings/mfd/st,stm32-timers.yaml
index b0e438ff4950..66aa1550a4e5 100644
--- a/Documentation/devicetree/bindings/mfd/st,stm32-timers.yaml
+++ b/Documentation/devicetree/bindings/mfd/st,stm32-timers.yaml
@@ -21,7 +21,9 @@ maintainers:
properties:
compatible:
- const: st,stm32-timers
+ enum:
+ - st,stm32-timers
+ - st,stm32mp25-timers
reg:
maxItems: 1
@@ -36,6 +38,9 @@ properties:
resets:
maxItems: 1
+ power-domains:
+ maxItems: 1
+
dmas:
minItems: 1
maxItems: 7
@@ -77,7 +82,9 @@ properties:
properties:
compatible:
- const: st,stm32-pwm
+ enum:
+ - st,stm32-pwm
+ - st,stm32mp25-pwm
"#pwm-cells":
const: 3
@@ -113,7 +120,9 @@ properties:
properties:
compatible:
- const: st,stm32-timer-counter
+ enum:
+ - st,stm32-timer-counter
+ - st,stm32mp25-timer-counter
required:
- compatible
@@ -128,12 +137,13 @@ patternProperties:
enum:
- st,stm32-timer-trigger
- st,stm32h7-timer-trigger
+ - st,stm32mp25-timer-trigger
reg:
description: Identify trigger hardware block.
items:
minimum: 0
- maximum: 16
+ maximum: 19
required:
- compatible
--
2.25.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 1/9] dt-bindings: mfd: stm32-timers: add support for stm32mp25
2024-12-18 9:01 ` [PATCH 1/9] dt-bindings: mfd: stm32-timers: add support for stm32mp25 Fabrice Gasnier
@ 2024-12-18 17:05 ` Conor Dooley
0 siblings, 0 replies; 16+ messages in thread
From: Conor Dooley @ 2024-12-18 17:05 UTC (permalink / raw)
To: Fabrice Gasnier
Cc: lee, robh, krzk+dt, conor+dt, alexandre.torgue, wbg, jic23,
ukleinek, catalin.marinas, will, devicetree, linux-stm32,
linux-arm-kernel, linux-kernel, linux-iio, linux-pwm,
olivier.moysan
[-- Attachment #1: Type: text/plain, Size: 739 bytes --]
On Wed, Dec 18, 2024 at 10:01:45AM +0100, Fabrice Gasnier wrote:
> Add a new stm32mp25 compatible to stm32-timer dt-bindings in order to
> support the STM32MP25 SoC. Some features has been added or updated in
> the stm32-timer timer such as:
> - hardware configuration and identification registers to read the timer
> version and capabilities (counter width, number of channels...)
> - dithering mode (can be used to extend PWM resolution)
> - input triggers list
> - new counter modes
> - various bit-field updates
> - power-domains property
> Timer trigger identifier can be up to 19 (from timer 20)
>
> Signed-off-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 2/9] mfd: stm32-timers: add support for stm32mp25
2024-12-18 9:01 [PATCH 0/9] Add STM32MP25 timers support: MFD, PWM, IIO and counter drivers Fabrice Gasnier
2024-12-18 9:01 ` [PATCH 1/9] dt-bindings: mfd: stm32-timers: add support for stm32mp25 Fabrice Gasnier
@ 2024-12-18 9:01 ` Fabrice Gasnier
2025-01-09 10:49 ` Lee Jones
2024-12-18 9:01 ` [PATCH 3/9] iio: trigger: stm32-timer: " Fabrice Gasnier
` (6 subsequent siblings)
8 siblings, 1 reply; 16+ messages in thread
From: Fabrice Gasnier @ 2024-12-18 9:01 UTC (permalink / raw)
To: lee, robh, krzk+dt, conor+dt, alexandre.torgue, wbg, jic23,
ukleinek
Cc: catalin.marinas, will, devicetree, linux-stm32, linux-arm-kernel,
linux-kernel, linux-iio, linux-pwm, olivier.moysan
Add support for STM32MP25 SoC. Use newly introduced compatible, to handle
new features.
Identification and hardware configuration registers allow to read the
timer version and capabilities (counter width, number of channels...).
So, rework the probe to avoid touching ARR register by simply read the
counter width when available. This may avoid messing with a possibly
running timer.
Also add useful bit fields to stm32-timers header file.
Signed-off-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
---
drivers/mfd/stm32-timers.c | 32 +++++++++++++++++++++++++++++++-
include/linux/mfd/stm32-timers.h | 9 +++++++++
2 files changed, 40 insertions(+), 1 deletion(-)
diff --git a/drivers/mfd/stm32-timers.c b/drivers/mfd/stm32-timers.c
index 650724e19b88..6f217c32482c 100644
--- a/drivers/mfd/stm32-timers.c
+++ b/drivers/mfd/stm32-timers.c
@@ -9,6 +9,7 @@
#include <linux/module.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h>
+#include <linux/property.h>
#include <linux/reset.h>
#define STM32_TIMERS_MAX_REGISTERS 0x3fc
@@ -173,6 +174,32 @@ static void stm32_timers_get_arr_size(struct stm32_timers *ddata)
regmap_write(ddata->regmap, TIM_ARR, arr);
}
+static int stm32_timers_probe_hwcfgr(struct device *dev, struct stm32_timers *ddata)
+{
+ u32 val;
+
+ ddata->ipidr = (uintptr_t)device_get_match_data(dev);
+ if (!ddata->ipidr) {
+ /* fallback to legacy method for probing counter width */
+ stm32_timers_get_arr_size(ddata);
+ return 0;
+ }
+
+ regmap_read(ddata->regmap, TIM_IPIDR, &val);
+ /* Sanity check on IP identification register */
+ if (val != ddata->ipidr) {
+ dev_err(dev, "Unexpected identification: %u\n", val);
+ return -EINVAL;
+ }
+
+ regmap_read(ddata->regmap, TIM_HWCFGR2, &val);
+ /* Counter width in bits, max reload value is BIT(width) - 1 */
+ ddata->max_arr = BIT(FIELD_GET(TIM_HWCFGR2_CNT_WIDTH, val)) - 1;
+ dev_dbg(dev, "TIM width: %ld\n", FIELD_GET(TIM_HWCFGR2_CNT_WIDTH, val));
+
+ return 0;
+}
+
static int stm32_timers_dma_probe(struct device *dev,
struct stm32_timers *ddata)
{
@@ -285,7 +312,9 @@ static int stm32_timers_probe(struct platform_device *pdev)
if (IS_ERR(ddata->clk))
return PTR_ERR(ddata->clk);
- stm32_timers_get_arr_size(ddata);
+ ret = stm32_timers_probe_hwcfgr(dev, ddata);
+ if (ret)
+ return ret;
ret = stm32_timers_irq_probe(pdev, ddata);
if (ret)
@@ -320,6 +349,7 @@ static void stm32_timers_remove(struct platform_device *pdev)
static const struct of_device_id stm32_timers_of_match[] = {
{ .compatible = "st,stm32-timers", },
+ { .compatible = "st,stm32mp25-timers", .data = (void *)STM32MP25_TIM_IPIDR },
{ /* end node */ },
};
MODULE_DEVICE_TABLE(of, stm32_timers_of_match);
diff --git a/include/linux/mfd/stm32-timers.h b/include/linux/mfd/stm32-timers.h
index f09ba598c97a..23b0cae4a9f8 100644
--- a/include/linux/mfd/stm32-timers.h
+++ b/include/linux/mfd/stm32-timers.h
@@ -33,6 +33,9 @@
#define TIM_DCR 0x48 /* DMA control register */
#define TIM_DMAR 0x4C /* DMA register for transfer */
#define TIM_TISEL 0x68 /* Input Selection */
+#define TIM_HWCFGR2 0x3EC /* hardware configuration 2 Reg (MP25) */
+#define TIM_HWCFGR1 0x3F0 /* hardware configuration 1 Reg (MP25) */
+#define TIM_IPIDR 0x3F8 /* IP identification Reg (MP25) */
#define TIM_CR1_CEN BIT(0) /* Counter Enable */
#define TIM_CR1_DIR BIT(4) /* Counter Direction */
@@ -100,6 +103,9 @@
#define TIM_BDTR_BKF(x) (0xf << (16 + (x) * 4))
#define TIM_DCR_DBA GENMASK(4, 0) /* DMA base addr */
#define TIM_DCR_DBL GENMASK(12, 8) /* DMA burst len */
+#define TIM_HWCFGR1_NB_OF_CC GENMASK(3, 0) /* Capture/compare channels */
+#define TIM_HWCFGR1_NB_OF_DT GENMASK(7, 4) /* Complementary outputs & dead-time generators */
+#define TIM_HWCFGR2_CNT_WIDTH GENMASK(15, 8) /* Counter width */
#define MAX_TIM_PSC 0xFFFF
#define MAX_TIM_ICPSC 0x3
@@ -113,6 +119,8 @@
#define TIM_BDTR_BKF_MASK 0xF
#define TIM_BDTR_BKF_SHIFT(x) (16 + (x) * 4)
+#define STM32MP25_TIM_IPIDR 0x00120002
+
enum stm32_timers_dmas {
STM32_TIMERS_DMA_CH1,
STM32_TIMERS_DMA_CH2,
@@ -151,6 +159,7 @@ struct stm32_timers_dma {
struct stm32_timers {
struct clk *clk;
+ u32 ipidr;
struct regmap *regmap;
u32 max_arr;
struct stm32_timers_dma dma; /* Only to be used by the parent */
--
2.25.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 2/9] mfd: stm32-timers: add support for stm32mp25
2024-12-18 9:01 ` [PATCH 2/9] " Fabrice Gasnier
@ 2025-01-09 10:49 ` Lee Jones
2025-01-09 16:29 ` Fabrice Gasnier
0 siblings, 1 reply; 16+ messages in thread
From: Lee Jones @ 2025-01-09 10:49 UTC (permalink / raw)
To: Fabrice Gasnier
Cc: robh, krzk+dt, conor+dt, alexandre.torgue, wbg, jic23, ukleinek,
catalin.marinas, will, devicetree, linux-stm32, linux-arm-kernel,
linux-kernel, linux-iio, linux-pwm, olivier.moysan
On Wed, 18 Dec 2024, Fabrice Gasnier wrote:
> Add support for STM32MP25 SoC. Use newly introduced compatible, to handle
> new features.
> Identification and hardware configuration registers allow to read the
> timer version and capabilities (counter width, number of channels...).
> So, rework the probe to avoid touching ARR register by simply read the
> counter width when available. This may avoid messing with a possibly
> running timer.
> Also add useful bit fields to stm32-timers header file.
>
> Signed-off-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
> ---
> drivers/mfd/stm32-timers.c | 32 +++++++++++++++++++++++++++++++-
> include/linux/mfd/stm32-timers.h | 9 +++++++++
> 2 files changed, 40 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mfd/stm32-timers.c b/drivers/mfd/stm32-timers.c
> index 650724e19b88..6f217c32482c 100644
> --- a/drivers/mfd/stm32-timers.c
> +++ b/drivers/mfd/stm32-timers.c
> @@ -9,6 +9,7 @@
> #include <linux/module.h>
> #include <linux/of_platform.h>
> #include <linux/platform_device.h>
> +#include <linux/property.h>
> #include <linux/reset.h>
>
> #define STM32_TIMERS_MAX_REGISTERS 0x3fc
> @@ -173,6 +174,32 @@ static void stm32_timers_get_arr_size(struct stm32_timers *ddata)
> regmap_write(ddata->regmap, TIM_ARR, arr);
> }
>
> +static int stm32_timers_probe_hwcfgr(struct device *dev, struct stm32_timers *ddata)
> +{
> + u32 val;
> +
> + ddata->ipidr = (uintptr_t)device_get_match_data(dev);
Are you sure this cast is needed?
> + if (!ddata->ipidr) {
> + /* fallback to legacy method for probing counter width */
Sentences start with uppercase chars.
> + stm32_timers_get_arr_size(ddata);
> + return 0;
> + }
> +
> + regmap_read(ddata->regmap, TIM_IPIDR, &val);
> + /* Sanity check on IP identification register */
This seems obvious, thus superfluous.
> + if (val != ddata->ipidr) {
> + dev_err(dev, "Unexpected identification: %u\n", val);
"Unexpected model number"?
"Unsupported device detected"?
> + return -EINVAL;
> + }
> +
> + regmap_read(ddata->regmap, TIM_HWCFGR2, &val);
'/n' here.
> + /* Counter width in bits, max reload value is BIT(width) - 1 */
> + ddata->max_arr = BIT(FIELD_GET(TIM_HWCFGR2_CNT_WIDTH, val)) - 1;
> + dev_dbg(dev, "TIM width: %ld\n", FIELD_GET(TIM_HWCFGR2_CNT_WIDTH, val));
How useful is this now the driver has been developed?
> + return 0;
> +}
> +
> static int stm32_timers_dma_probe(struct device *dev,
> struct stm32_timers *ddata)
> {
> @@ -285,7 +312,9 @@ static int stm32_timers_probe(struct platform_device *pdev)
> if (IS_ERR(ddata->clk))
> return PTR_ERR(ddata->clk);
>
> - stm32_timers_get_arr_size(ddata);
> + ret = stm32_timers_probe_hwcfgr(dev, ddata);
> + if (ret)
> + return ret;
>
> ret = stm32_timers_irq_probe(pdev, ddata);
> if (ret)
> @@ -320,6 +349,7 @@ static void stm32_timers_remove(struct platform_device *pdev)
>
> static const struct of_device_id stm32_timers_of_match[] = {
> { .compatible = "st,stm32-timers", },
> + { .compatible = "st,stm32mp25-timers", .data = (void *)STM32MP25_TIM_IPIDR },
> { /* end node */ },
> };
> MODULE_DEVICE_TABLE(of, stm32_timers_of_match);
> diff --git a/include/linux/mfd/stm32-timers.h b/include/linux/mfd/stm32-timers.h
> index f09ba598c97a..23b0cae4a9f8 100644
> --- a/include/linux/mfd/stm32-timers.h
> +++ b/include/linux/mfd/stm32-timers.h
> @@ -33,6 +33,9 @@
> #define TIM_DCR 0x48 /* DMA control register */
> #define TIM_DMAR 0x4C /* DMA register for transfer */
> #define TIM_TISEL 0x68 /* Input Selection */
> +#define TIM_HWCFGR2 0x3EC /* hardware configuration 2 Reg (MP25) */
> +#define TIM_HWCFGR1 0x3F0 /* hardware configuration 1 Reg (MP25) */
> +#define TIM_IPIDR 0x3F8 /* IP identification Reg (MP25) */
>
> #define TIM_CR1_CEN BIT(0) /* Counter Enable */
> #define TIM_CR1_DIR BIT(4) /* Counter Direction */
> @@ -100,6 +103,9 @@
> #define TIM_BDTR_BKF(x) (0xf << (16 + (x) * 4))
> #define TIM_DCR_DBA GENMASK(4, 0) /* DMA base addr */
> #define TIM_DCR_DBL GENMASK(12, 8) /* DMA burst len */
> +#define TIM_HWCFGR1_NB_OF_CC GENMASK(3, 0) /* Capture/compare channels */
> +#define TIM_HWCFGR1_NB_OF_DT GENMASK(7, 4) /* Complementary outputs & dead-time generators */
> +#define TIM_HWCFGR2_CNT_WIDTH GENMASK(15, 8) /* Counter width */
>
> #define MAX_TIM_PSC 0xFFFF
> #define MAX_TIM_ICPSC 0x3
> @@ -113,6 +119,8 @@
> #define TIM_BDTR_BKF_MASK 0xF
> #define TIM_BDTR_BKF_SHIFT(x) (16 + (x) * 4)
>
> +#define STM32MP25_TIM_IPIDR 0x00120002
> +
> enum stm32_timers_dmas {
> STM32_TIMERS_DMA_CH1,
> STM32_TIMERS_DMA_CH2,
> @@ -151,6 +159,7 @@ struct stm32_timers_dma {
>
> struct stm32_timers {
> struct clk *clk;
> + u32 ipidr;
> struct regmap *regmap;
> u32 max_arr;
> struct stm32_timers_dma dma; /* Only to be used by the parent */
> --
> 2.25.1
>
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/9] mfd: stm32-timers: add support for stm32mp25
2025-01-09 10:49 ` Lee Jones
@ 2025-01-09 16:29 ` Fabrice Gasnier
0 siblings, 0 replies; 16+ messages in thread
From: Fabrice Gasnier @ 2025-01-09 16:29 UTC (permalink / raw)
To: Lee Jones
Cc: robh, krzk+dt, conor+dt, alexandre.torgue, wbg, jic23, ukleinek,
catalin.marinas, will, devicetree, linux-stm32, linux-arm-kernel,
linux-kernel, linux-iio, linux-pwm, olivier.moysan
On 1/9/25 11:49, Lee Jones wrote:
> On Wed, 18 Dec 2024, Fabrice Gasnier wrote:
>
>> Add support for STM32MP25 SoC. Use newly introduced compatible, to handle
>> new features.
>> Identification and hardware configuration registers allow to read the
>> timer version and capabilities (counter width, number of channels...).
>> So, rework the probe to avoid touching ARR register by simply read the
>> counter width when available. This may avoid messing with a possibly
>> running timer.
>> Also add useful bit fields to stm32-timers header file.
>>
>> Signed-off-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
>> ---
>> drivers/mfd/stm32-timers.c | 32 +++++++++++++++++++++++++++++++-
>> include/linux/mfd/stm32-timers.h | 9 +++++++++
>> 2 files changed, 40 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/mfd/stm32-timers.c b/drivers/mfd/stm32-timers.c
>> index 650724e19b88..6f217c32482c 100644
>> --- a/drivers/mfd/stm32-timers.c
>> +++ b/drivers/mfd/stm32-timers.c
>> @@ -9,6 +9,7 @@
>> #include <linux/module.h>
>> #include <linux/of_platform.h>
>> #include <linux/platform_device.h>
>> +#include <linux/property.h>
>> #include <linux/reset.h>
>>
>> #define STM32_TIMERS_MAX_REGISTERS 0x3fc
>> @@ -173,6 +174,32 @@ static void stm32_timers_get_arr_size(struct stm32_timers *ddata)
>> regmap_write(ddata->regmap, TIM_ARR, arr);
>> }
>>
>> +static int stm32_timers_probe_hwcfgr(struct device *dev, struct stm32_timers *ddata)
>> +{
>> + u32 val;
>> +
>> + ddata->ipidr = (uintptr_t)device_get_match_data(dev);
>
> Are you sure this cast is needed?
Hi Lee,
Yes, I can see a warning pops-up without it:
drivers/mfd/stm32-timers.c:181:22: warning: assignment to ‘u32’ {aka
‘unsigned int’} from ‘const void *’ makes integer from pointer without a
cast [-Wint-conversion]
181 | ddata->ipidr = device_get_match_data(dev);
| ^
>
>> + if (!ddata->ipidr) {
>> + /* fallback to legacy method for probing counter width */
>
> Sentences start with uppercase chars.
Ack
>
>> + stm32_timers_get_arr_size(ddata);
>> + return 0;
>> + }
>> +
>> + regmap_read(ddata->regmap, TIM_IPIDR, &val);
>> + /* Sanity check on IP identification register */
>
> This seems obvious, thus superfluous.
Ack
>
>> + if (val != ddata->ipidr) {
>> + dev_err(dev, "Unexpected identification: %u\n", val);
>
> "Unexpected model number"?
> "Unsupported device detected"?
Ack
>
>> + return -EINVAL;
>> + }
>> +
>> + regmap_read(ddata->regmap, TIM_HWCFGR2, &val);
>
> '/n' here.
Ack
>
>> + /* Counter width in bits, max reload value is BIT(width) - 1 */
>> + ddata->max_arr = BIT(FIELD_GET(TIM_HWCFGR2_CNT_WIDTH, val)) - 1;
>> + dev_dbg(dev, "TIM width: %ld\n", FIELD_GET(TIM_HWCFGR2_CNT_WIDTH, val));
>
> How useful is this now the driver has been developed?
Well... that's just debug. I'll remove it and send a V3.
Thanks for reviewing,
BR,
Fabrice
>
>> + return 0;
>> +}
>> +
>> static int stm32_timers_dma_probe(struct device *dev,
>> struct stm32_timers *ddata)
>> {
>> @@ -285,7 +312,9 @@ static int stm32_timers_probe(struct platform_device *pdev)
>> if (IS_ERR(ddata->clk))
>> return PTR_ERR(ddata->clk);
>>
>> - stm32_timers_get_arr_size(ddata);
>> + ret = stm32_timers_probe_hwcfgr(dev, ddata);
>> + if (ret)
>> + return ret;
>>
>> ret = stm32_timers_irq_probe(pdev, ddata);
>> if (ret)
>> @@ -320,6 +349,7 @@ static void stm32_timers_remove(struct platform_device *pdev)
>>
>> static const struct of_device_id stm32_timers_of_match[] = {
>> { .compatible = "st,stm32-timers", },
>> + { .compatible = "st,stm32mp25-timers", .data = (void *)STM32MP25_TIM_IPIDR },
>> { /* end node */ },
>> };
>> MODULE_DEVICE_TABLE(of, stm32_timers_of_match);
>> diff --git a/include/linux/mfd/stm32-timers.h b/include/linux/mfd/stm32-timers.h
>> index f09ba598c97a..23b0cae4a9f8 100644
>> --- a/include/linux/mfd/stm32-timers.h
>> +++ b/include/linux/mfd/stm32-timers.h
>> @@ -33,6 +33,9 @@
>> #define TIM_DCR 0x48 /* DMA control register */
>> #define TIM_DMAR 0x4C /* DMA register for transfer */
>> #define TIM_TISEL 0x68 /* Input Selection */
>> +#define TIM_HWCFGR2 0x3EC /* hardware configuration 2 Reg (MP25) */
>> +#define TIM_HWCFGR1 0x3F0 /* hardware configuration 1 Reg (MP25) */
>> +#define TIM_IPIDR 0x3F8 /* IP identification Reg (MP25) */
>>
>> #define TIM_CR1_CEN BIT(0) /* Counter Enable */
>> #define TIM_CR1_DIR BIT(4) /* Counter Direction */
>> @@ -100,6 +103,9 @@
>> #define TIM_BDTR_BKF(x) (0xf << (16 + (x) * 4))
>> #define TIM_DCR_DBA GENMASK(4, 0) /* DMA base addr */
>> #define TIM_DCR_DBL GENMASK(12, 8) /* DMA burst len */
>> +#define TIM_HWCFGR1_NB_OF_CC GENMASK(3, 0) /* Capture/compare channels */
>> +#define TIM_HWCFGR1_NB_OF_DT GENMASK(7, 4) /* Complementary outputs & dead-time generators */
>> +#define TIM_HWCFGR2_CNT_WIDTH GENMASK(15, 8) /* Counter width */
>>
>> #define MAX_TIM_PSC 0xFFFF
>> #define MAX_TIM_ICPSC 0x3
>> @@ -113,6 +119,8 @@
>> #define TIM_BDTR_BKF_MASK 0xF
>> #define TIM_BDTR_BKF_SHIFT(x) (16 + (x) * 4)
>>
>> +#define STM32MP25_TIM_IPIDR 0x00120002
>> +
>> enum stm32_timers_dmas {
>> STM32_TIMERS_DMA_CH1,
>> STM32_TIMERS_DMA_CH2,
>> @@ -151,6 +159,7 @@ struct stm32_timers_dma {
>>
>> struct stm32_timers {
>> struct clk *clk;
>> + u32 ipidr;
>> struct regmap *regmap;
>> u32 max_arr;
>> struct stm32_timers_dma dma; /* Only to be used by the parent */
>> --
>> 2.25.1
>>
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 3/9] iio: trigger: stm32-timer: add support for stm32mp25
2024-12-18 9:01 [PATCH 0/9] Add STM32MP25 timers support: MFD, PWM, IIO and counter drivers Fabrice Gasnier
2024-12-18 9:01 ` [PATCH 1/9] dt-bindings: mfd: stm32-timers: add support for stm32mp25 Fabrice Gasnier
2024-12-18 9:01 ` [PATCH 2/9] " Fabrice Gasnier
@ 2024-12-18 9:01 ` Fabrice Gasnier
2024-12-19 15:10 ` Jonathan Cameron
2024-12-18 9:01 ` [PATCH 4/9] counter: stm32-timer-cnt: " Fabrice Gasnier
` (5 subsequent siblings)
8 siblings, 1 reply; 16+ messages in thread
From: Fabrice Gasnier @ 2024-12-18 9:01 UTC (permalink / raw)
To: lee, robh, krzk+dt, conor+dt, alexandre.torgue, wbg, jic23,
ukleinek
Cc: catalin.marinas, will, devicetree, linux-stm32, linux-arm-kernel,
linux-kernel, linux-iio, linux-pwm, olivier.moysan
Add support for STM32MP25 SoC. Use newly introduced compatible to handle
this new HW variant. Add TIM20 trigger definitions that can be used by
the stm32 analog-to-digital converter. Use compatible data to identify
it.
As the counter framework is now superseding the deprecated IIO counter
interface (IIO_COUNT), don't support it. Only register IIO trigger
devices for ADC usage. So, make the valids_table a cfg option.
Signed-off-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
---
drivers/iio/trigger/stm32-timer-trigger.c | 21 +++++++++++++++++--
include/linux/iio/timer/stm32-timer-trigger.h | 6 ++++++
2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/trigger/stm32-timer-trigger.c b/drivers/iio/trigger/stm32-timer-trigger.c
index bb60b2d7b2ec..8aaf3abf044e 100644
--- a/drivers/iio/trigger/stm32-timer-trigger.c
+++ b/drivers/iio/trigger/stm32-timer-trigger.c
@@ -38,6 +38,9 @@ static const void *triggers_table[][MAX_TRIGGERS] = {
{ TIM15_TRGO,},
{ TIM16_OC1,},
{ TIM17_OC1,},
+ { }, /* timer 18 */
+ { }, /* timer 19 */
+ { TIM20_TRGO, TIM20_TRGO2, TIM20_OC1, TIM20_OC2, TIM20_OC3, },
};
/* List the triggers accepted by each timer */
@@ -781,7 +784,7 @@ static int stm32_timer_trigger_probe(struct platform_device *pdev)
return -EINVAL;
/* Create an IIO device only if we have triggers to be validated */
- if (*cfg->valids_table[index])
+ if (cfg->valids_table && *cfg->valids_table[index])
priv = stm32_setup_counter_device(dev);
else
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
@@ -794,7 +797,8 @@ static int stm32_timer_trigger_probe(struct platform_device *pdev)
priv->clk = ddata->clk;
priv->max_arr = ddata->max_arr;
priv->triggers = triggers_table[index];
- priv->valids = cfg->valids_table[index];
+ if (cfg->valids_table && *cfg->valids_table[index])
+ priv->valids = cfg->valids_table[index];
stm32_timer_detect_trgo2(priv);
mutex_init(&priv->lock);
@@ -886,6 +890,16 @@ static const struct stm32_timer_trigger_cfg stm32h7_timer_trg_cfg = {
.num_valids_table = ARRAY_SIZE(stm32h7_valids_table),
};
+static const struct stm32_timer_trigger_cfg stm32mp25_timer_trg_cfg = {
+ /*
+ * valids_table not used: counter framework is now superseding the deprecated IIO
+ * counter interface (IIO_COUNT), so don't support it. num_valids_table is only
+ * kept here to register the IIO HW triggers. valids_table should be moved at some
+ * point to the stm32-timer-cnt driver instead.
+ */
+ .num_valids_table = ARRAY_SIZE(triggers_table),
+};
+
static const struct of_device_id stm32_trig_of_match[] = {
{
.compatible = "st,stm32-timer-trigger",
@@ -893,6 +907,9 @@ static const struct of_device_id stm32_trig_of_match[] = {
}, {
.compatible = "st,stm32h7-timer-trigger",
.data = (void *)&stm32h7_timer_trg_cfg,
+ }, {
+ .compatible = "st,stm32mp25-timer-trigger",
+ .data = (void *)&stm32mp25_timer_trg_cfg,
},
{ /* end node */ },
};
diff --git a/include/linux/iio/timer/stm32-timer-trigger.h b/include/linux/iio/timer/stm32-timer-trigger.h
index 37572e4dc73a..1ee237b56183 100644
--- a/include/linux/iio/timer/stm32-timer-trigger.h
+++ b/include/linux/iio/timer/stm32-timer-trigger.h
@@ -72,6 +72,12 @@
#define TIM17_OC1 "tim17_oc1"
+#define TIM20_OC1 "tim20_oc1"
+#define TIM20_OC2 "tim20_oc2"
+#define TIM20_OC3 "tim20_oc3"
+#define TIM20_TRGO "tim20_trgo"
+#define TIM20_TRGO2 "tim20_trgo2"
+
#if IS_REACHABLE(CONFIG_IIO_STM32_TIMER_TRIGGER)
bool is_stm32_timer_trigger(struct iio_trigger *trig);
#else
--
2.25.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 3/9] iio: trigger: stm32-timer: add support for stm32mp25
2024-12-18 9:01 ` [PATCH 3/9] iio: trigger: stm32-timer: " Fabrice Gasnier
@ 2024-12-19 15:10 ` Jonathan Cameron
0 siblings, 0 replies; 16+ messages in thread
From: Jonathan Cameron @ 2024-12-19 15:10 UTC (permalink / raw)
To: Fabrice Gasnier
Cc: lee, robh, krzk+dt, conor+dt, alexandre.torgue, wbg, ukleinek,
catalin.marinas, will, devicetree, linux-stm32, linux-arm-kernel,
linux-kernel, linux-iio, linux-pwm, olivier.moysan
On Wed, 18 Dec 2024 10:01:47 +0100
Fabrice Gasnier <fabrice.gasnier@foss.st.com> wrote:
> Add support for STM32MP25 SoC. Use newly introduced compatible to handle
> this new HW variant. Add TIM20 trigger definitions that can be used by
> the stm32 analog-to-digital converter. Use compatible data to identify
> it.
> As the counter framework is now superseding the deprecated IIO counter
> interface (IIO_COUNT), don't support it. Only register IIO trigger
> devices for ADC usage. So, make the valids_table a cfg option.
>
> Signed-off-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Looks good to me. Looks like I can just pick this up for IIO?
Or is thOre a dependency I'm missing?
Just in case it goes another route.
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Jonathan
> ---
> drivers/iio/trigger/stm32-timer-trigger.c | 21 +++++++++++++++++--
> include/linux/iio/timer/stm32-timer-trigger.h | 6 ++++++
> 2 files changed, 25 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/trigger/stm32-timer-trigger.c b/drivers/iio/trigger/stm32-timer-trigger.c
> index bb60b2d7b2ec..8aaf3abf044e 100644
> --- a/drivers/iio/trigger/stm32-timer-trigger.c
> +++ b/drivers/iio/trigger/stm32-timer-trigger.c
> @@ -38,6 +38,9 @@ static const void *triggers_table[][MAX_TRIGGERS] = {
> { TIM15_TRGO,},
> { TIM16_OC1,},
> { TIM17_OC1,},
> + { }, /* timer 18 */
> + { }, /* timer 19 */
> + { TIM20_TRGO, TIM20_TRGO2, TIM20_OC1, TIM20_OC2, TIM20_OC3, },
> };
>
> /* List the triggers accepted by each timer */
> @@ -781,7 +784,7 @@ static int stm32_timer_trigger_probe(struct platform_device *pdev)
> return -EINVAL;
>
> /* Create an IIO device only if we have triggers to be validated */
> - if (*cfg->valids_table[index])
> + if (cfg->valids_table && *cfg->valids_table[index])
> priv = stm32_setup_counter_device(dev);
> else
> priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> @@ -794,7 +797,8 @@ static int stm32_timer_trigger_probe(struct platform_device *pdev)
> priv->clk = ddata->clk;
> priv->max_arr = ddata->max_arr;
> priv->triggers = triggers_table[index];
> - priv->valids = cfg->valids_table[index];
> + if (cfg->valids_table && *cfg->valids_table[index])
> + priv->valids = cfg->valids_table[index];
> stm32_timer_detect_trgo2(priv);
> mutex_init(&priv->lock);
>
> @@ -886,6 +890,16 @@ static const struct stm32_timer_trigger_cfg stm32h7_timer_trg_cfg = {
> .num_valids_table = ARRAY_SIZE(stm32h7_valids_table),
> };
>
> +static const struct stm32_timer_trigger_cfg stm32mp25_timer_trg_cfg = {
> + /*
> + * valids_table not used: counter framework is now superseding the deprecated IIO
> + * counter interface (IIO_COUNT), so don't support it. num_valids_table is only
> + * kept here to register the IIO HW triggers. valids_table should be moved at some
> + * point to the stm32-timer-cnt driver instead.
> + */
> + .num_valids_table = ARRAY_SIZE(triggers_table),
> +};
> +
> static const struct of_device_id stm32_trig_of_match[] = {
> {
> .compatible = "st,stm32-timer-trigger",
> @@ -893,6 +907,9 @@ static const struct of_device_id stm32_trig_of_match[] = {
> }, {
> .compatible = "st,stm32h7-timer-trigger",
> .data = (void *)&stm32h7_timer_trg_cfg,
> + }, {
> + .compatible = "st,stm32mp25-timer-trigger",
> + .data = (void *)&stm32mp25_timer_trg_cfg,
> },
> { /* end node */ },
> };
> diff --git a/include/linux/iio/timer/stm32-timer-trigger.h b/include/linux/iio/timer/stm32-timer-trigger.h
> index 37572e4dc73a..1ee237b56183 100644
> --- a/include/linux/iio/timer/stm32-timer-trigger.h
> +++ b/include/linux/iio/timer/stm32-timer-trigger.h
> @@ -72,6 +72,12 @@
>
> #define TIM17_OC1 "tim17_oc1"
>
> +#define TIM20_OC1 "tim20_oc1"
> +#define TIM20_OC2 "tim20_oc2"
> +#define TIM20_OC3 "tim20_oc3"
> +#define TIM20_TRGO "tim20_trgo"
> +#define TIM20_TRGO2 "tim20_trgo2"
> +
> #if IS_REACHABLE(CONFIG_IIO_STM32_TIMER_TRIGGER)
> bool is_stm32_timer_trigger(struct iio_trigger *trig);
> #else
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 4/9] counter: stm32-timer-cnt: add support for stm32mp25
2024-12-18 9:01 [PATCH 0/9] Add STM32MP25 timers support: MFD, PWM, IIO and counter drivers Fabrice Gasnier
` (2 preceding siblings ...)
2024-12-18 9:01 ` [PATCH 3/9] iio: trigger: stm32-timer: " Fabrice Gasnier
@ 2024-12-18 9:01 ` Fabrice Gasnier
2024-12-19 4:35 ` William Breathitt Gray
2024-12-18 9:01 ` [PATCH 5/9] pwm: stm32: " Fabrice Gasnier
` (4 subsequent siblings)
8 siblings, 1 reply; 16+ messages in thread
From: Fabrice Gasnier @ 2024-12-18 9:01 UTC (permalink / raw)
To: lee, robh, krzk+dt, conor+dt, alexandre.torgue, wbg, jic23,
ukleinek
Cc: catalin.marinas, will, devicetree, linux-stm32, linux-arm-kernel,
linux-kernel, linux-iio, linux-pwm, olivier.moysan
Add support for STM32MP25 SoC. There are new counter modes that may be
implemented in later. Still, use newly introduced compatible to handle
this new HW variant and avoid being blocked with existing compatible
in SoC dtsi file. Modes supported currently still remains compatible.
New timer 20 has encoder capability, add it to the list.
Signed-off-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
---
drivers/counter/stm32-timer-cnt.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/counter/stm32-timer-cnt.c b/drivers/counter/stm32-timer-cnt.c
index e75b69476a00..3d3384cbea87 100644
--- a/drivers/counter/stm32-timer-cnt.c
+++ b/drivers/counter/stm32-timer-cnt.c
@@ -669,12 +669,14 @@ static void stm32_timer_cnt_detect_channels(struct device *dev,
dev_dbg(dev, "has %d cc channels\n", priv->nchannels);
}
-/* encoder supported on TIM1 TIM2 TIM3 TIM4 TIM5 TIM8 */
-#define STM32_TIM_ENCODER_SUPPORTED (BIT(0) | BIT(1) | BIT(2) | BIT(3) | BIT(4) | BIT(7))
+/* encoder supported on TIM1 TIM2 TIM3 TIM4 TIM5 TIM8 TIM20 */
+#define STM32_TIM_ENCODER_SUPPORTED (BIT(0) | BIT(1) | BIT(2) | BIT(3) | BIT(4) | BIT(7) | \
+ BIT(19))
static const char * const stm32_timer_trigger_compat[] = {
"st,stm32-timer-trigger",
"st,stm32h7-timer-trigger",
+ "st,stm32mp25-timer-trigger",
};
static int stm32_timer_cnt_probe_encoder(struct device *dev,
@@ -846,6 +848,7 @@ static SIMPLE_DEV_PM_OPS(stm32_timer_cnt_pm_ops, stm32_timer_cnt_suspend,
static const struct of_device_id stm32_timer_cnt_of_match[] = {
{ .compatible = "st,stm32-timer-counter", },
+ { .compatible = "st,stm32mp25-timer-counter", },
{},
};
MODULE_DEVICE_TABLE(of, stm32_timer_cnt_of_match);
--
2.25.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 4/9] counter: stm32-timer-cnt: add support for stm32mp25
2024-12-18 9:01 ` [PATCH 4/9] counter: stm32-timer-cnt: " Fabrice Gasnier
@ 2024-12-19 4:35 ` William Breathitt Gray
0 siblings, 0 replies; 16+ messages in thread
From: William Breathitt Gray @ 2024-12-19 4:35 UTC (permalink / raw)
To: Fabrice Gasnier
Cc: lee, robh, krzk+dt, conor+dt, alexandre.torgue, jic23, ukleinek,
catalin.marinas, will, devicetree, linux-stm32, linux-arm-kernel,
linux-kernel, linux-iio, linux-pwm, olivier.moysan
[-- Attachment #1: Type: text/plain, Size: 540 bytes --]
On Wed, Dec 18, 2024 at 10:01:48AM +0100, Fabrice Gasnier wrote:
> Add support for STM32MP25 SoC. There are new counter modes that may be
> implemented in later. Still, use newly introduced compatible to handle
> this new HW variant and avoid being blocked with existing compatible
> in SoC dtsi file. Modes supported currently still remains compatible.
> New timer 20 has encoder capability, add it to the list.
>
> Signed-off-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Acked-by: William Breathitt Gray <wbg@kernel.org>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 5/9] pwm: stm32: add support for stm32mp25
2024-12-18 9:01 [PATCH 0/9] Add STM32MP25 timers support: MFD, PWM, IIO and counter drivers Fabrice Gasnier
` (3 preceding siblings ...)
2024-12-18 9:01 ` [PATCH 4/9] counter: stm32-timer-cnt: " Fabrice Gasnier
@ 2024-12-18 9:01 ` Fabrice Gasnier
2024-12-18 10:05 ` Uwe Kleine-König
2024-12-18 9:01 ` [PATCH 6/9] arm64: defconfig: enable STM32 timers drivers Fabrice Gasnier
` (3 subsequent siblings)
8 siblings, 1 reply; 16+ messages in thread
From: Fabrice Gasnier @ 2024-12-18 9:01 UTC (permalink / raw)
To: lee, robh, krzk+dt, conor+dt, alexandre.torgue, wbg, jic23,
ukleinek
Cc: catalin.marinas, will, devicetree, linux-stm32, linux-arm-kernel,
linux-kernel, linux-iio, linux-pwm, olivier.moysan
Add support for STM32MP25 SoC. Use newly introduced compatible to handle
new features along with registers and bits diversity.
The MFD part of the driver fills in ipidr, so it is used to check the
hardware configuration register, when available to gather the number
of PWM channels and complementary outputs.
Signed-off-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
---
drivers/pwm/pwm-stm32.c | 39 +++++++++++++++++++++++++++++++++++----
1 file changed, 35 insertions(+), 4 deletions(-)
diff --git a/drivers/pwm/pwm-stm32.c b/drivers/pwm/pwm-stm32.c
index 17e591f61efb..99383e09920e 100644
--- a/drivers/pwm/pwm-stm32.c
+++ b/drivers/pwm/pwm-stm32.c
@@ -19,6 +19,7 @@
#define CCMR_CHANNEL_SHIFT 8
#define CCMR_CHANNEL_MASK 0xFF
#define MAX_BREAKINPUT 2
+#define MAX_PWM_OUTPUT 4
struct stm32_breakinput {
u32 index;
@@ -775,10 +776,19 @@ static int stm32_pwm_probe_breakinputs(struct stm32_pwm *priv,
return stm32_pwm_apply_breakinputs(priv);
}
-static void stm32_pwm_detect_complementary(struct stm32_pwm *priv)
+static void stm32_pwm_detect_complementary(struct stm32_pwm *priv, struct stm32_timers *ddata)
{
u32 ccer;
+ if (ddata->ipidr) {
+ u32 val;
+
+ /* Simply read from HWCFGR the number of complementary outputs (MP25). */
+ regmap_read(priv->regmap, TIM_HWCFGR1, &val);
+ priv->have_complementary_output = !!FIELD_GET(TIM_HWCFGR1_NB_OF_DT, val);
+ return;
+ }
+
/*
* If complementary bit doesn't exist writing 1 will have no
* effect so we can detect it.
@@ -790,11 +800,31 @@ static void stm32_pwm_detect_complementary(struct stm32_pwm *priv)
priv->have_complementary_output = (ccer != 0);
}
-static unsigned int stm32_pwm_detect_channels(struct regmap *regmap,
+static unsigned int stm32_pwm_detect_channels(struct stm32_timers *ddata,
unsigned int *num_enabled)
{
+ struct regmap *regmap = ddata->regmap;
u32 ccer, ccer_backup;
+ if (ddata->ipidr) {
+ unsigned int npwm = 0;
+ u32 val;
+
+ /* Simply deduce from HWCFGR the number of outputs (MP25). */
+ regmap_read(regmap, TIM_HWCFGR1, &val);
+
+ /*
+ * Timers may have more capture/compare channels than the
+ * actual number of PWM channel outputs (e.g. TIM_CH[1..4]).
+ */
+ npwm = FIELD_GET(TIM_HWCFGR1_NB_OF_CC, val);
+
+ regmap_read(regmap, TIM_CCER, &ccer);
+ *num_enabled = hweight32(ccer & TIM_CCER_CCXE);
+
+ return npwm < MAX_PWM_OUTPUT ? npwm : MAX_PWM_OUTPUT;
+ }
+
/*
* If channels enable bits don't exist writing 1 will have no
* effect so we can detect and count them.
@@ -820,7 +850,7 @@ static int stm32_pwm_probe(struct platform_device *pdev)
unsigned int i;
int ret;
- npwm = stm32_pwm_detect_channels(ddata->regmap, &num_enabled);
+ npwm = stm32_pwm_detect_channels(ddata, &num_enabled);
chip = devm_pwmchip_alloc(dev, npwm, sizeof(*priv));
if (IS_ERR(chip))
@@ -841,7 +871,7 @@ static int stm32_pwm_probe(struct platform_device *pdev)
return dev_err_probe(dev, ret,
"Failed to configure breakinputs\n");
- stm32_pwm_detect_complementary(priv);
+ stm32_pwm_detect_complementary(priv, ddata);
ret = devm_clk_rate_exclusive_get(dev, priv->clk);
if (ret)
@@ -911,6 +941,7 @@ static DEFINE_SIMPLE_DEV_PM_OPS(stm32_pwm_pm_ops, stm32_pwm_suspend, stm32_pwm_r
static const struct of_device_id stm32_pwm_of_match[] = {
{ .compatible = "st,stm32-pwm", },
+ { .compatible = "st,stm32mp25-pwm", },
{ /* end node */ },
};
MODULE_DEVICE_TABLE(of, stm32_pwm_of_match);
--
2.25.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 5/9] pwm: stm32: add support for stm32mp25
2024-12-18 9:01 ` [PATCH 5/9] pwm: stm32: " Fabrice Gasnier
@ 2024-12-18 10:05 ` Uwe Kleine-König
0 siblings, 0 replies; 16+ messages in thread
From: Uwe Kleine-König @ 2024-12-18 10:05 UTC (permalink / raw)
To: Fabrice Gasnier
Cc: lee, robh, krzk+dt, conor+dt, alexandre.torgue, wbg, jic23,
catalin.marinas, will, devicetree, linux-stm32, linux-arm-kernel,
linux-kernel, linux-iio, linux-pwm, olivier.moysan
[-- Attachment #1: Type: text/plain, Size: 1826 bytes --]
On Wed, Dec 18, 2024 at 10:01:49AM +0100, Fabrice Gasnier wrote:
> diff --git a/drivers/pwm/pwm-stm32.c b/drivers/pwm/pwm-stm32.c
> index 17e591f61efb..99383e09920e 100644
> --- a/drivers/pwm/pwm-stm32.c
> +++ b/drivers/pwm/pwm-stm32.c
> @@ -19,6 +19,7 @@
> #define CCMR_CHANNEL_SHIFT 8
> #define CCMR_CHANNEL_MASK 0xFF
> #define MAX_BREAKINPUT 2
> +#define MAX_PWM_OUTPUT 4
I would prefer a less generic name. Something like STM32_PWM_MAX_OUTPUT.
> struct stm32_breakinput {
> u32 index;
> [...]
> @@ -790,11 +800,31 @@ static void stm32_pwm_detect_complementary(struct stm32_pwm *priv)
> priv->have_complementary_output = (ccer != 0);
> }
>
> -static unsigned int stm32_pwm_detect_channels(struct regmap *regmap,
> +static unsigned int stm32_pwm_detect_channels(struct stm32_timers *ddata,
> unsigned int *num_enabled)
> {
> + struct regmap *regmap = ddata->regmap;
> u32 ccer, ccer_backup;
>
> + if (ddata->ipidr) {
> + unsigned int npwm = 0;
No need to initialize npwm.
> + u32 val;
> +
> + /* Simply deduce from HWCFGR the number of outputs (MP25). */
> + regmap_read(regmap, TIM_HWCFGR1, &val);
> +
> + /*
> + * Timers may have more capture/compare channels than the
> + * actual number of PWM channel outputs (e.g. TIM_CH[1..4]).
> + */
> + npwm = FIELD_GET(TIM_HWCFGR1_NB_OF_CC, val);
> +
> + regmap_read(regmap, TIM_CCER, &ccer);
> + *num_enabled = hweight32(ccer & TIM_CCER_CCXE);
So the part that determines *num_enabled is the same for both variants.
Maybe it's possible to share the code for that?
> + return npwm < MAX_PWM_OUTPUT ? npwm : MAX_PWM_OUTPUT;
> + }
> +
> /*
> * If channels enable bits don't exist writing 1 will have no
> * effect so we can detect and count them.
Best regards
Uwe
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 6/9] arm64: defconfig: enable STM32 timers drivers
2024-12-18 9:01 [PATCH 0/9] Add STM32MP25 timers support: MFD, PWM, IIO and counter drivers Fabrice Gasnier
` (4 preceding siblings ...)
2024-12-18 9:01 ` [PATCH 5/9] pwm: stm32: " Fabrice Gasnier
@ 2024-12-18 9:01 ` Fabrice Gasnier
2024-12-18 9:01 ` [PATCH 7/9] arm64: dts: st: add timer nodes on stm32mp251 Fabrice Gasnier
` (2 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Fabrice Gasnier @ 2024-12-18 9:01 UTC (permalink / raw)
To: lee, robh, krzk+dt, conor+dt, alexandre.torgue, wbg, jic23,
ukleinek
Cc: catalin.marinas, will, devicetree, linux-stm32, linux-arm-kernel,
linux-kernel, linux-iio, linux-pwm, olivier.moysan
Enable the STM32 timer drivers: MFD, counter, PWM and trigger as module.
These drivers can be used on STM32MP25.
Signed-off-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
---
arch/arm64/configs/defconfig | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index c62831e61586..d6aabdc103d7 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -764,6 +764,7 @@ CONFIG_MFD_TI_LP873X=m
CONFIG_MFD_TPS65219=y
CONFIG_MFD_TPS6594_I2C=m
CONFIG_MFD_ROHM_BD718XX=y
+CONFIG_MFD_STM32_TIMERS=m
CONFIG_MFD_WCD934X=m
CONFIG_MFD_KHADAS_MCU=m
CONFIG_REGULATOR_FIXED_VOLTAGE=y
@@ -1499,6 +1500,7 @@ CONFIG_IIO_CROS_EC_LIGHT_PROX=m
CONFIG_SENSORS_ISL29018=m
CONFIG_VCNL4000=m
CONFIG_IIO_ST_MAGN_3AXIS=m
+CONFIG_IIO_STM32_TIMER_TRIGGER=m
CONFIG_IIO_CROS_EC_BARO=m
CONFIG_MPL3115=m
CONFIG_PWM=y
@@ -1516,6 +1518,7 @@ CONFIG_PWM_ROCKCHIP=y
CONFIG_PWM_RZ_MTU3=m
CONFIG_PWM_SAMSUNG=y
CONFIG_PWM_SL28CPLD=m
+CONFIG_PWM_STM32=m
CONFIG_PWM_SUN4I=m
CONFIG_PWM_TEGRA=m
CONFIG_PWM_TIECAP=m
@@ -1650,6 +1653,7 @@ CONFIG_INTERCONNECT_QCOM_SM8650=y
CONFIG_INTERCONNECT_QCOM_X1E80100=y
CONFIG_COUNTER=m
CONFIG_RZ_MTU3_CNT=m
+CONFIG_STM32_TIMER_CNT=m
CONFIG_HTE=y
CONFIG_HTE_TEGRA194=y
CONFIG_HTE_TEGRA194_TEST=m
--
2.25.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 7/9] arm64: dts: st: add timer nodes on stm32mp251
2024-12-18 9:01 [PATCH 0/9] Add STM32MP25 timers support: MFD, PWM, IIO and counter drivers Fabrice Gasnier
` (5 preceding siblings ...)
2024-12-18 9:01 ` [PATCH 6/9] arm64: defconfig: enable STM32 timers drivers Fabrice Gasnier
@ 2024-12-18 9:01 ` Fabrice Gasnier
2024-12-18 9:01 ` [PATCH 8/9] arm64: dts: st: add timer pins for stm32mp257f-ev1 Fabrice Gasnier
2024-12-18 9:01 ` [PATCH 9/9] arm64: dts: st: add timer nodes on stm32mp257f-ev1 Fabrice Gasnier
8 siblings, 0 replies; 16+ messages in thread
From: Fabrice Gasnier @ 2024-12-18 9:01 UTC (permalink / raw)
To: lee, robh, krzk+dt, conor+dt, alexandre.torgue, wbg, jic23,
ukleinek
Cc: catalin.marinas, will, devicetree, linux-stm32, linux-arm-kernel,
linux-kernel, linux-iio, linux-pwm, olivier.moysan
Add timers support on STM32MP25 SoC. Use dedicated compatible to handle
new features and instances introduced with this SoC. STM32MP25 SoC has
various timer flavours, each group has its own specific feature list:
- Advanced-control timers (TIM1/TIM8/TIM20)
- General-purpose timers (TIM2/TIM3/TIM4/TIM5)
- Basic timers (TIM6/TIM7)
- General-purpose timers (TIM10/TIM11/TIM12/TIM13/TIM14)
- General purpose timers (TIM15/TIM16/TIM17)
Signed-off-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
---
arch/arm64/boot/dts/st/stm32mp251.dtsi | 524 +++++++++++++++++++++++++
1 file changed, 524 insertions(+)
diff --git a/arch/arm64/boot/dts/st/stm32mp251.dtsi b/arch/arm64/boot/dts/st/stm32mp251.dtsi
index 6fe12e3bd7dd..220fb1a3da71 100644
--- a/arch/arm64/boot/dts/st/stm32mp251.dtsi
+++ b/arch/arm64/boot/dts/st/stm32mp251.dtsi
@@ -237,6 +237,273 @@ rifsc: bus@42080000 {
#access-controller-cells = <1>;
ranges;
+ timers2: timer@40000000 {
+ compatible = "st,stm32mp25-timers";
+ reg = <0x40000000 0x400>;
+ interrupts = <GIC_SPI 105 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-names = "global";
+ clocks = <&rcc CK_KER_TIM2>;
+ clock-names = "int";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ access-controllers = <&rifsc 1>;
+ power-domains = <&CLUSTER_PD>;
+ status = "disabled";
+
+ counter {
+ compatible = "st,stm32mp25-timer-counter";
+ status = "disabled";
+ };
+
+ pwm {
+ compatible = "st,stm32mp25-pwm";
+ #pwm-cells = <3>;
+ status = "disabled";
+ };
+
+ timer@1 {
+ compatible = "st,stm32mp25-timer-trigger";
+ reg = <1>;
+ status = "disabled";
+ };
+ };
+
+ timers3: timer@40010000 {
+ compatible = "st,stm32mp25-timers";
+ reg = <0x40010000 0x400>;
+ interrupts = <GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-names = "global";
+ clocks = <&rcc CK_KER_TIM3>;
+ clock-names = "int";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ access-controllers = <&rifsc 2>;
+ power-domains = <&CLUSTER_PD>;
+ status = "disabled";
+
+ counter {
+ compatible = "st,stm32mp25-timer-counter";
+ status = "disabled";
+ };
+
+ pwm {
+ compatible = "st,stm32mp25-pwm";
+ #pwm-cells = <3>;
+ status = "disabled";
+ };
+
+ timer@2 {
+ compatible = "st,stm32mp25-timer-trigger";
+ reg = <2>;
+ status = "disabled";
+ };
+ };
+
+ timers4: timer@40020000 {
+ compatible = "st,stm32mp25-timers";
+ reg = <0x40020000 0x400>;
+ interrupts = <GIC_SPI 107 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-names = "global";
+ clocks = <&rcc CK_KER_TIM4>;
+ clock-names = "int";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ access-controllers = <&rifsc 3>;
+ power-domains = <&CLUSTER_PD>;
+ status = "disabled";
+
+ counter {
+ compatible = "st,stm32mp25-timer-counter";
+ status = "disabled";
+ };
+
+ pwm {
+ compatible = "st,stm32mp25-pwm";
+ #pwm-cells = <3>;
+ status = "disabled";
+ };
+
+ timer@3 {
+ compatible = "st,stm32mp25-timer-trigger";
+ reg = <3>;
+ status = "disabled";
+ };
+ };
+
+ timers5: timer@40030000 {
+ compatible = "st,stm32mp25-timers";
+ reg = <0x40030000 0x400>;
+ interrupts = <GIC_SPI 124 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-names = "global";
+ clocks = <&rcc CK_KER_TIM5>;
+ clock-names = "int";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ access-controllers = <&rifsc 4>;
+ power-domains = <&CLUSTER_PD>;
+ status = "disabled";
+
+ counter {
+ compatible = "st,stm32mp25-timer-counter";
+ status = "disabled";
+ };
+
+ pwm {
+ compatible = "st,stm32mp25-pwm";
+ #pwm-cells = <3>;
+ status = "disabled";
+ };
+
+ timer@4 {
+ compatible = "st,stm32mp25-timer-trigger";
+ reg = <4>;
+ status = "disabled";
+ };
+ };
+
+ timers6: timer@40040000 {
+ compatible = "st,stm32mp25-timers";
+ reg = <0x40040000 0x400>;
+ interrupts = <GIC_SPI 128 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-names = "global";
+ clocks = <&rcc CK_KER_TIM6>;
+ clock-names = "int";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ access-controllers = <&rifsc 5>;
+ power-domains = <&CLUSTER_PD>;
+ status = "disabled";
+
+ counter {
+ compatible = "st,stm32mp25-timer-counter";
+ status = "disabled";
+ };
+
+ timer@5 {
+ compatible = "st,stm32mp25-timer-trigger";
+ reg = <5>;
+ status = "disabled";
+ };
+ };
+
+ timers7: timer@40050000 {
+ compatible = "st,stm32mp25-timers";
+ reg = <0x40050000 0x400>;
+ interrupts = <GIC_SPI 129 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-names = "global";
+ clocks = <&rcc CK_KER_TIM7>;
+ clock-names = "int";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ access-controllers = <&rifsc 6>;
+ power-domains = <&CLUSTER_PD>;
+ status = "disabled";
+
+ counter {
+ compatible = "st,stm32mp25-timer-counter";
+ status = "disabled";
+ };
+
+ timer@6 {
+ compatible = "st,stm32mp25-timer-trigger";
+ reg = <6>;
+ status = "disabled";
+ };
+ };
+
+ timers12: timer@40060000 {
+ compatible = "st,stm32mp25-timers";
+ reg = <0x40060000 0x400>;
+ interrupts = <GIC_SPI 196 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-names = "global";
+ clocks = <&rcc CK_KER_TIM12>;
+ clock-names = "int";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ access-controllers = <&rifsc 10>;
+ power-domains = <&CLUSTER_PD>;
+ status = "disabled";
+
+ counter {
+ compatible = "st,stm32mp25-timer-counter";
+ status = "disabled";
+ };
+
+ pwm {
+ compatible = "st,stm32mp25-pwm";
+ #pwm-cells = <3>;
+ status = "disabled";
+ };
+
+ timer@11 {
+ compatible = "st,stm32mp25-timer-trigger";
+ reg = <11>;
+ status = "disabled";
+ };
+ };
+
+ timers13: timer@40070000 {
+ compatible = "st,stm32mp25-timers";
+ reg = <0x40070000 0x400>;
+ interrupts = <GIC_SPI 203 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-names = "global";
+ clocks = <&rcc CK_KER_TIM13>;
+ clock-names = "int";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ access-controllers = <&rifsc 11>;
+ power-domains = <&CLUSTER_PD>;
+ status = "disabled";
+
+ counter {
+ compatible = "st,stm32mp25-timer-counter";
+ status = "disabled";
+ };
+
+ pwm {
+ compatible = "st,stm32mp25-pwm";
+ #pwm-cells = <3>;
+ status = "disabled";
+ };
+
+ timer@12 {
+ compatible = "st,stm32mp25-timer-trigger";
+ reg = <12>;
+ status = "disabled";
+ };
+ };
+
+ timers14: timer@40080000 {
+ compatible = "st,stm32mp25-timers";
+ reg = <0x40080000 0x400>;
+ interrupts = <GIC_SPI 204 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-names = "global";
+ clocks = <&rcc CK_KER_TIM14>;
+ clock-names = "int";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ access-controllers = <&rifsc 12>;
+ power-domains = <&CLUSTER_PD>;
+ status = "disabled";
+
+ counter {
+ compatible = "st,stm32mp25-timer-counter";
+ status = "disabled";
+ };
+
+ pwm {
+ compatible = "st,stm32mp25-pwm";
+ #pwm-cells = <3>;
+ status = "disabled";
+ };
+
+ timer@13 {
+ compatible = "st,stm32mp25-timer-trigger";
+ reg = <13>;
+ status = "disabled";
+ };
+ };
+
spi2: spi@400b0000 {
#address-cells = <1>;
#size-cells = <0>;
@@ -427,6 +694,136 @@ i2c7: i2c@40180000 {
status = "disabled";
};
+ timers10: timer@401c0000 {
+ compatible = "st,stm32mp25-timers";
+ reg = <0x401c0000 0x400>;
+ interrupts = <GIC_SPI 205 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-names = "global";
+ clocks = <&rcc CK_KER_TIM10>;
+ clock-names = "int";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ access-controllers = <&rifsc 8>;
+ power-domains = <&CLUSTER_PD>;
+ status = "disabled";
+
+ counter {
+ compatible = "st,stm32mp25-timer-counter";
+ status = "disabled";
+ };
+
+ pwm {
+ compatible = "st,stm32mp25-pwm";
+ #pwm-cells = <3>;
+ status = "disabled";
+ };
+
+ timer@9 {
+ compatible = "st,stm32mp25-timer-trigger";
+ reg = <9>;
+ status = "disabled";
+ };
+ };
+
+ timers11: timer@401d0000 {
+ compatible = "st,stm32mp25-timers";
+ reg = <0x401d0000 0x400>;
+ interrupts = <GIC_SPI 225 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-names = "global";
+ clocks = <&rcc CK_KER_TIM11>;
+ clock-names = "int";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ access-controllers = <&rifsc 9>;
+ power-domains = <&CLUSTER_PD>;
+ status = "disabled";
+
+ counter {
+ compatible = "st,stm32mp25-timer-counter";
+ status = "disabled";
+ };
+
+ pwm {
+ compatible = "st,stm32mp25-pwm";
+ #pwm-cells = <3>;
+ status = "disabled";
+ };
+
+ timer@10 {
+ compatible = "st,stm32mp25-timer-trigger";
+ reg = <10>;
+ status = "disabled";
+ };
+ };
+
+ timers1: timer@40200000 {
+ compatible = "st,stm32mp25-timers";
+ reg = <0x40200000 0x400>;
+ interrupts = <GIC_SPI 97 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 98 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 99 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 100 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-names = "brk", "up", "trg-com", "cc";
+ clocks = <&rcc CK_KER_TIM1>;
+ clock-names = "int";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ access-controllers = <&rifsc 0>;
+ power-domains = <&CLUSTER_PD>;
+ status = "disabled";
+
+ counter {
+ compatible = "st,stm32mp25-timer-counter";
+ status = "disabled";
+ };
+
+ pwm {
+ compatible = "st,stm32mp25-pwm";
+ #pwm-cells = <3>;
+ status = "disabled";
+ };
+
+ timer@0 {
+ compatible = "st,stm32mp25-timer-trigger";
+ reg = <0>;
+ status = "disabled";
+ };
+ };
+
+ timers8: timer@40210000 {
+ compatible = "st,stm32mp25-timers";
+ reg = <0x40210000 0x400>;
+ interrupts = <GIC_SPI 118 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 119 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 120 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 121 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-names = "brk", "up", "trg-com", "cc";
+ clocks = <&rcc CK_KER_TIM8>;
+ clock-names = "int";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ access-controllers = <&rifsc 7>;
+ power-domains = <&CLUSTER_PD>;
+ status = "disabled";
+
+ counter {
+ compatible = "st,stm32mp25-timer-counter";
+ status = "disabled";
+ };
+
+ pwm {
+ compatible = "st,stm32mp25-pwm";
+ #pwm-cells = <3>;
+ status = "disabled";
+ };
+
+ timer@7 {
+ compatible = "st,stm32mp25-timer-trigger";
+ reg = <7>;
+ status = "disabled";
+ };
+ };
+
usart6: serial@40220000 {
compatible = "st,stm32h7-uart";
reg = <0x40220000 0x400>;
@@ -469,6 +866,99 @@ spi4: spi@40240000 {
status = "disabled";
};
+ timers15: timer@40250000 {
+ compatible = "st,stm32mp25-timers";
+ reg = <0x40250000 0x400>;
+ interrupts = <GIC_SPI 193 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-names = "global";
+ clocks = <&rcc CK_KER_TIM15>;
+ clock-names = "int";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ access-controllers = <&rifsc 13>;
+ power-domains = <&CLUSTER_PD>;
+ status = "disabled";
+
+ counter {
+ compatible = "st,stm32mp25-timer-counter";
+ status = "disabled";
+ };
+
+ pwm {
+ compatible = "st,stm32mp25-pwm";
+ #pwm-cells = <3>;
+ status = "disabled";
+ };
+
+ timer@14 {
+ compatible = "st,stm32mp25-timer-trigger";
+ reg = <14>;
+ status = "disabled";
+ };
+ };
+
+ timers16: timer@40260000 {
+ compatible = "st,stm32mp25-timers";
+ reg = <0x40260000 0x400>;
+ interrupts = <GIC_SPI 194 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-names = "global";
+ clocks = <&rcc CK_KER_TIM16>;
+ clock-names = "int";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ access-controllers = <&rifsc 14>;
+ power-domains = <&CLUSTER_PD>;
+ status = "disabled";
+
+ counter {
+ compatible = "st,stm32mp25-timer-counter";
+ status = "disabled";
+ };
+
+ pwm {
+ compatible = "st,stm32mp25-pwm";
+ #pwm-cells = <3>;
+ status = "disabled";
+ };
+
+ timer@15 {
+ compatible = "st,stm32mp25-timer-trigger";
+ reg = <15>;
+ status = "disabled";
+ };
+ };
+
+ timers17: timer@40270000 {
+ compatible = "st,stm32mp25-timers";
+ reg = <0x40270000 0x400>;
+ interrupts = <GIC_SPI 195 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-names = "global";
+ clocks = <&rcc CK_KER_TIM17>;
+ clock-names = "int";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ access-controllers = <&rifsc 15>;
+ power-domains = <&CLUSTER_PD>;
+ status = "disabled";
+
+ counter {
+ compatible = "st,stm32mp25-timer-counter";
+ status = "disabled";
+ };
+
+ pwm {
+ compatible = "st,stm32mp25-pwm";
+ #pwm-cells = <3>;
+ status = "disabled";
+ };
+
+ timer@16 {
+ compatible = "st,stm32mp25-timer-trigger";
+ reg = <16>;
+ status = "disabled";
+ };
+ };
+
spi5: spi@40280000 {
#address-cells = <1>;
#size-cells = <0>;
@@ -496,6 +986,40 @@ uart9: serial@402c0000 {
status = "disabled";
};
+ timers20: timer@40320000 {
+ compatible = "st,stm32mp25-timers";
+ reg = <0x40320000 0x400>;
+ interrupts = <GIC_SPI 101 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 102 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 104 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-names = "brk", "up", "trg-com", "cc";
+ clocks = <&rcc CK_KER_TIM20>;
+ clock-names = "int";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ access-controllers = <&rifsc 16>;
+ power-domains = <&CLUSTER_PD>;
+ status = "disabled";
+
+ counter {
+ compatible = "st,stm32mp25-timer-counter";
+ status = "disabled";
+ };
+
+ pwm {
+ compatible = "st,stm32mp25-pwm";
+ #pwm-cells = <3>;
+ status = "disabled";
+ };
+
+ timer@19 {
+ compatible = "st,stm32mp25-timer-trigger";
+ reg = <19>;
+ status = "disabled";
+ };
+ };
+
usart1: serial@40330000 {
compatible = "st,stm32h7-uart";
reg = <0x40330000 0x400>;
--
2.25.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 8/9] arm64: dts: st: add timer pins for stm32mp257f-ev1
2024-12-18 9:01 [PATCH 0/9] Add STM32MP25 timers support: MFD, PWM, IIO and counter drivers Fabrice Gasnier
` (6 preceding siblings ...)
2024-12-18 9:01 ` [PATCH 7/9] arm64: dts: st: add timer nodes on stm32mp251 Fabrice Gasnier
@ 2024-12-18 9:01 ` Fabrice Gasnier
2024-12-18 9:01 ` [PATCH 9/9] arm64: dts: st: add timer nodes on stm32mp257f-ev1 Fabrice Gasnier
8 siblings, 0 replies; 16+ messages in thread
From: Fabrice Gasnier @ 2024-12-18 9:01 UTC (permalink / raw)
To: lee, robh, krzk+dt, conor+dt, alexandre.torgue, wbg, jic23,
ukleinek
Cc: catalin.marinas, will, devicetree, linux-stm32, linux-arm-kernel,
linux-kernel, linux-iio, linux-pwm, olivier.moysan
Add timer pins available on stm32mp257f-ev1, configured for PWM:
- timer3 CH2 is available on mikroBUS connector
- timer8 CH1, timer8 CH4, timer10 CH1 and timer12 CH2 are available
on EXPANSION connector
Arbitrary define all these pins to be used as PWM (output) channels,
except for timer10 CH1, to be used as counter input.
Signed-off-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
---
arch/arm64/boot/dts/st/stm32mp25-pinctrl.dtsi | 61 +++++++++++++++++++
1 file changed, 61 insertions(+)
diff --git a/arch/arm64/boot/dts/st/stm32mp25-pinctrl.dtsi b/arch/arm64/boot/dts/st/stm32mp25-pinctrl.dtsi
index 8fdd5f020425..bb9dc82d3dd5 100644
--- a/arch/arm64/boot/dts/st/stm32mp25-pinctrl.dtsi
+++ b/arch/arm64/boot/dts/st/stm32mp25-pinctrl.dtsi
@@ -82,6 +82,53 @@ pins {
};
};
+ pwm3_pins_a: pwm3-0 {
+ pins {
+ pinmux = <STM32_PINMUX('B', 15, AF7)>; /* TIM3_CH2 */
+ bias-pull-down;
+ drive-push-pull;
+ slew-rate = <0>;
+ };
+ };
+
+ pwm3_sleep_pins_a: pwm3-sleep-0 {
+ pins {
+ pinmux = <STM32_PINMUX('B', 15, ANALOG)>; /* TIM3_CH2 */
+ };
+ };
+
+ pwm8_pins_a: pwm8-0 {
+ pins {
+ pinmux = <STM32_PINMUX('J', 5, AF8)>, /* TIM8_CH1 */
+ <STM32_PINMUX('J', 4, AF8)>; /* TIM8_CH4 */
+ bias-pull-down;
+ drive-push-pull;
+ slew-rate = <0>;
+ };
+ };
+
+ pwm8_sleep_pins_a: pwm8-sleep-0 {
+ pins {
+ pinmux = <STM32_PINMUX('J', 5, ANALOG)>, /* TIM8_CH1 */
+ <STM32_PINMUX('J', 4, ANALOG)>; /* TIM8_CH4 */
+ };
+ };
+
+ pwm12_pins_a: pwm12-0 {
+ pins {
+ pinmux = <STM32_PINMUX('B', 11, AF9)>; /* TIM12_CH2 */
+ bias-pull-down;
+ drive-push-pull;
+ slew-rate = <0>;
+ };
+ };
+
+ pwm12_sleep_pins_a: pwm12-sleep-0 {
+ pins {
+ pinmux = <STM32_PINMUX('B', 11, ANALOG)>; /* TIM12_CH2 */
+ };
+ };
+
sdmmc1_b4_pins_a: sdmmc1-b4-0 {
pins1 {
pinmux = <STM32_PINMUX('E', 4, AF10)>, /* SDMMC1_D0 */
@@ -158,6 +205,20 @@ pins1 {
};
};
+ tim10_counter_pins_a: tim10-counter-0 {
+ pins {
+ pinmux = <STM32_PINMUX('B', 9, AF9)>; /* TIM10_CH1 */
+ bias-disable;
+ };
+ };
+
+ tim10_counter_sleep_pins_a: tim10-counter-sleep-0 {
+ pins {
+ pinmux = <STM32_PINMUX('B', 9, ANALOG)>; /* TIM10_CH1 */
+ bias-disable;
+ };
+ };
+
usart2_pins_a: usart2-0 {
pins1 {
pinmux = <STM32_PINMUX('A', 4, AF6)>; /* USART2_TX */
--
2.25.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 9/9] arm64: dts: st: add timer nodes on stm32mp257f-ev1
2024-12-18 9:01 [PATCH 0/9] Add STM32MP25 timers support: MFD, PWM, IIO and counter drivers Fabrice Gasnier
` (7 preceding siblings ...)
2024-12-18 9:01 ` [PATCH 8/9] arm64: dts: st: add timer pins for stm32mp257f-ev1 Fabrice Gasnier
@ 2024-12-18 9:01 ` Fabrice Gasnier
8 siblings, 0 replies; 16+ messages in thread
From: Fabrice Gasnier @ 2024-12-18 9:01 UTC (permalink / raw)
To: lee, robh, krzk+dt, conor+dt, alexandre.torgue, wbg, jic23,
ukleinek
Cc: catalin.marinas, will, devicetree, linux-stm32, linux-arm-kernel,
linux-kernel, linux-iio, linux-pwm, olivier.moysan
Configure timer nodes on stm32mp257f-ev1:
- Timer3 CH2 is available on mikroBUS connector for PWM
- timer8 CH1, timer8 CH4, timer10 CH1 and timer12 CH2 are available
on EXPANSION connector.
Timers are kept disabled by default, so the pins can be used for any
other purpose (and the timers can be assigned to any of the processors).
Arbitrary choice is to use all these timers as PWM (or counter on
internal clock signal), except for timer10 that is configured with
CH1 as an input (for capture).
Signed-off-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
---
arch/arm64/boot/dts/st/stm32mp257f-ev1.dts | 58 ++++++++++++++++++++++
1 file changed, 58 insertions(+)
diff --git a/arch/arm64/boot/dts/st/stm32mp257f-ev1.dts b/arch/arm64/boot/dts/st/stm32mp257f-ev1.dts
index 6f393b082789..6601ca411006 100644
--- a/arch/arm64/boot/dts/st/stm32mp257f-ev1.dts
+++ b/arch/arm64/boot/dts/st/stm32mp257f-ev1.dts
@@ -156,6 +156,64 @@ &spi8 {
status = "disabled";
};
+&timers3 {
+ status = "disabled";
+ counter {
+ status = "okay";
+ };
+ pwm {
+ pinctrl-0 = <&pwm3_pins_a>;
+ pinctrl-1 = <&pwm3_sleep_pins_a>;
+ pinctrl-names = "default", "sleep";
+ status = "okay";
+ };
+ timer@2 {
+ status = "okay";
+ };
+};
+
+&timers8 {
+ status = "disabled";
+ counter {
+ status = "okay";
+ };
+ pwm {
+ pinctrl-0 = <&pwm8_pins_a>;
+ pinctrl-1 = <&pwm8_sleep_pins_a>;
+ pinctrl-names = "default", "sleep";
+ status = "okay";
+ };
+ timer@7 {
+ status = "okay";
+ };
+};
+
+&timers10 {
+ status = "disabled";
+ counter {
+ pinctrl-0 = <&tim10_counter_pins_a>;
+ pinctrl-1 = <&tim10_counter_sleep_pins_a>;
+ pinctrl-names = "default", "sleep";
+ status = "okay";
+ };
+};
+
+&timers12 {
+ status = "disabled";
+ counter {
+ status = "okay";
+ };
+ pwm {
+ pinctrl-0 = <&pwm12_pins_a>;
+ pinctrl-1 = <&pwm12_sleep_pins_a>;
+ pinctrl-names = "default", "sleep";
+ status = "okay";
+ };
+ timer@11 {
+ status = "okay";
+ };
+};
+
&usart2 {
pinctrl-names = "default", "idle", "sleep";
pinctrl-0 = <&usart2_pins_a>;
--
2.25.1
^ permalink raw reply related [flat|nested] 16+ messages in thread