* [PATCH v3] spi: stm32-ospi: Make usage of reset_control_acquire/release() API
@ 2025-05-07 16:04 Patrice Chotard
2025-05-08 9:16 ` Philipp Zabel
0 siblings, 1 reply; 3+ messages in thread
From: Patrice Chotard @ 2025-05-07 16:04 UTC (permalink / raw)
To: Philipp Zabel, Mark Brown, Maxime Coquelin, Alexandre Torgue
Cc: linux-kernel, linux-spi, linux-stm32, linux-arm-kernel,
Patrice Chotard
As ospi reset is consumed by both OMM and OSPI drivers, use the reset
acquire/release mechanism which ensure exclusive reset usage.
This avoid to call reset_control_get/put() in OMM driver each time
we need to reset OSPI children and guarantee the reset line stays
deasserted.
Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
---
Changes in v3:
- Remove previous patch 1/2 as already merged.
- Keep the reset control acquired from probe() to remove().
- Link to v2: https://lore.kernel.org/r/20250411-b4-upstream_ospi_reset_update-v2-0-4de7f5dd2a91@foss.st.com
Changes in v2:
- Rebased on spi/for-next (7a978d8fcf57).
- Remove useless check on reset.
- Add error handling on reset_control_acquire().
- Link to v1: https://lore.kernel.org/all/20250410-b4-upstream_ospi_reset_update-v1-0-74126a8ceb9c@foss.st.com/
---
drivers/spi/spi-stm32-ospi.c | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/drivers/spi/spi-stm32-ospi.c b/drivers/spi/spi-stm32-ospi.c
index 668022098b1eac3628f0677e6d786e5a267346be..b2597b52beb1133155e0d6f601b0632ad4b8e8f5 100644
--- a/drivers/spi/spi-stm32-ospi.c
+++ b/drivers/spi/spi-stm32-ospi.c
@@ -804,7 +804,7 @@ static int stm32_ospi_get_resources(struct platform_device *pdev)
return ret;
}
- ospi->rstc = devm_reset_control_array_get_optional_exclusive(dev);
+ ospi->rstc = devm_reset_control_array_get_exclusive_released(dev);
if (IS_ERR(ospi->rstc))
return dev_err_probe(dev, PTR_ERR(ospi->rstc),
"Can't get reset\n");
@@ -936,11 +936,13 @@ static int stm32_ospi_probe(struct platform_device *pdev)
if (ret < 0)
goto err_pm_enable;
- if (ospi->rstc) {
- reset_control_assert(ospi->rstc);
- udelay(2);
- reset_control_deassert(ospi->rstc);
- }
+ ret = reset_control_acquire(ospi->rstc);
+ if (ret)
+ return dev_err_probe(dev, ret, "Can not acquire reset %d\n", ret);
+
+ reset_control_assert(ospi->rstc);
+ udelay(2);
+ reset_control_deassert(ospi->rstc);
ret = spi_register_controller(ctrl);
if (ret) {
@@ -983,6 +985,8 @@ static void stm32_ospi_remove(struct platform_device *pdev)
if (ospi->dma_chrx)
dma_release_channel(ospi->dma_chrx);
+ reset_control_release(ospi->rstc);
+
pm_runtime_put_sync_suspend(ospi->dev);
pm_runtime_force_suspend(ospi->dev);
}
@@ -993,6 +997,8 @@ static int __maybe_unused stm32_ospi_suspend(struct device *dev)
pinctrl_pm_select_sleep_state(dev);
+ reset_control_release(ospi->rstc);
+
return pm_runtime_force_suspend(ospi->dev);
}
@@ -1012,6 +1018,12 @@ static int __maybe_unused stm32_ospi_resume(struct device *dev)
if (ret < 0)
return ret;
+ ret = reset_control_acquire(ospi->rstc);
+ if (ret) {
+ dev_err(dev, "Can not acquire reset\n");
+ return ret;
+ }
+
writel_relaxed(ospi->cr_reg, regs_base + OSPI_CR);
writel_relaxed(ospi->dcr_reg, regs_base + OSPI_DCR1);
pm_runtime_mark_last_busy(ospi->dev);
---
base-commit: 1c64de886b8893c0158097edd6ba08d527a2c97a
change-id: 20250411-b4-upstream_ospi_reset_update-596ce245ada1
Best regards,
--
Patrice Chotard <patrice.chotard@foss.st.com>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v3] spi: stm32-ospi: Make usage of reset_control_acquire/release() API
2025-05-07 16:04 [PATCH v3] spi: stm32-ospi: Make usage of reset_control_acquire/release() API Patrice Chotard
@ 2025-05-08 9:16 ` Philipp Zabel
2025-05-12 6:58 ` Patrice CHOTARD
0 siblings, 1 reply; 3+ messages in thread
From: Philipp Zabel @ 2025-05-08 9:16 UTC (permalink / raw)
To: Patrice Chotard, Mark Brown, Maxime Coquelin, Alexandre Torgue
Cc: linux-kernel, linux-spi, linux-stm32, linux-arm-kernel
Hi Patrice,
On Mi, 2025-05-07 at 18:04 +0200, Patrice Chotard wrote:
> As ospi reset is consumed by both OMM and OSPI drivers, use the reset
> acquire/release mechanism which ensure exclusive reset usage.
>
> This avoid to call reset_control_get/put() in OMM driver each time
> we need to reset OSPI children and guarantee the reset line stays
> deasserted.
>
> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
> ---
> Changes in v3:
> - Remove previous patch 1/2 as already merged.
> - Keep the reset control acquired from probe() to remove().
> - Link to v2: https://lore.kernel.org/r/20250411-b4-upstream_ospi_reset_update-v2-0-4de7f5dd2a91@foss.st.com
>
> Changes in v2:
> - Rebased on spi/for-next (7a978d8fcf57).
> - Remove useless check on reset.
> - Add error handling on reset_control_acquire().
> - Link to v1: https://lore.kernel.org/all/20250410-b4-upstream_ospi_reset_update-v1-0-74126a8ceb9c@foss.st.com/
> ---
> drivers/spi/spi-stm32-ospi.c | 24 ++++++++++++++++++------
> 1 file changed, 18 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/spi/spi-stm32-ospi.c b/drivers/spi/spi-stm32-ospi.c
> index 668022098b1eac3628f0677e6d786e5a267346be..b2597b52beb1133155e0d6f601b0632ad4b8e8f5 100644
> --- a/drivers/spi/spi-stm32-ospi.c
> +++ b/drivers/spi/spi-stm32-ospi.c
> @@ -804,7 +804,7 @@ static int stm32_ospi_get_resources(struct platform_device *pdev)
> return ret;
> }
>
> - ospi->rstc = devm_reset_control_array_get_optional_exclusive(dev);
> + ospi->rstc = devm_reset_control_array_get_exclusive_released(dev);
> if (IS_ERR(ospi->rstc))
> return dev_err_probe(dev, PTR_ERR(ospi->rstc),
> "Can't get reset\n");
> @@ -936,11 +936,13 @@ static int stm32_ospi_probe(struct platform_device *pdev)
> if (ret < 0)
> goto err_pm_enable;
>
> - if (ospi->rstc) {
> - reset_control_assert(ospi->rstc);
> - udelay(2);
> - reset_control_deassert(ospi->rstc);
> - }
> + ret = reset_control_acquire(ospi->rstc);
> + if (ret)
> + return dev_err_probe(dev, ret, "Can not acquire reset %d\n", ret);
> +
> + reset_control_assert(ospi->rstc);
> + udelay(2);
> + reset_control_deassert(ospi->rstc);
>
> ret = spi_register_controller(ctrl);
> if (ret) {
> @@ -983,6 +985,8 @@ static void stm32_ospi_remove(struct platform_device *pdev)
> if (ospi->dma_chrx)
> dma_release_channel(ospi->dma_chrx);
>
> + reset_control_release(ospi->rstc);
> +
> pm_runtime_put_sync_suspend(ospi->dev);
> pm_runtime_force_suspend(ospi->dev);
> }
> @@ -993,6 +997,8 @@ static int __maybe_unused stm32_ospi_suspend(struct device *dev)
>
> pinctrl_pm_select_sleep_state(dev);
>
> + reset_control_release(ospi->rstc);
It would be nice to point out in a comment that OMM will temporarily
take over control during resume. But either way,
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
regards
Philipp
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3] spi: stm32-ospi: Make usage of reset_control_acquire/release() API
2025-05-08 9:16 ` Philipp Zabel
@ 2025-05-12 6:58 ` Patrice CHOTARD
0 siblings, 0 replies; 3+ messages in thread
From: Patrice CHOTARD @ 2025-05-12 6:58 UTC (permalink / raw)
To: Philipp Zabel, Mark Brown, Maxime Coquelin, Alexandre Torgue
Cc: linux-kernel, linux-spi, linux-stm32, linux-arm-kernel
On 5/8/25 11:16, Philipp Zabel wrote:
> Hi Patrice,
>
> On Mi, 2025-05-07 at 18:04 +0200, Patrice Chotard wrote:
>> As ospi reset is consumed by both OMM and OSPI drivers, use the reset
>> acquire/release mechanism which ensure exclusive reset usage.
>>
>> This avoid to call reset_control_get/put() in OMM driver each time
>> we need to reset OSPI children and guarantee the reset line stays
>> deasserted.
>>
>> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
>> ---
>> Changes in v3:
>> - Remove previous patch 1/2 as already merged.
>> - Keep the reset control acquired from probe() to remove().
>> - Link to v2: https://lore.kernel.org/r/20250411-b4-upstream_ospi_reset_update-v2-0-4de7f5dd2a91@foss.st.com
>>
>> Changes in v2:
>> - Rebased on spi/for-next (7a978d8fcf57).
>> - Remove useless check on reset.
>> - Add error handling on reset_control_acquire().
>> - Link to v1: https://lore.kernel.org/all/20250410-b4-upstream_ospi_reset_update-v1-0-74126a8ceb9c@foss.st.com/
>> ---
>> drivers/spi/spi-stm32-ospi.c | 24 ++++++++++++++++++------
>> 1 file changed, 18 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/spi/spi-stm32-ospi.c b/drivers/spi/spi-stm32-ospi.c
>> index 668022098b1eac3628f0677e6d786e5a267346be..b2597b52beb1133155e0d6f601b0632ad4b8e8f5 100644
>> --- a/drivers/spi/spi-stm32-ospi.c
>> +++ b/drivers/spi/spi-stm32-ospi.c
>> @@ -804,7 +804,7 @@ static int stm32_ospi_get_resources(struct platform_device *pdev)
>> return ret;
>> }
>>
>> - ospi->rstc = devm_reset_control_array_get_optional_exclusive(dev);
>> + ospi->rstc = devm_reset_control_array_get_exclusive_released(dev);
>> if (IS_ERR(ospi->rstc))
>> return dev_err_probe(dev, PTR_ERR(ospi->rstc),
>> "Can't get reset\n");
>> @@ -936,11 +936,13 @@ static int stm32_ospi_probe(struct platform_device *pdev)
>> if (ret < 0)
>> goto err_pm_enable;
>>
>> - if (ospi->rstc) {
>> - reset_control_assert(ospi->rstc);
>> - udelay(2);
>> - reset_control_deassert(ospi->rstc);
>> - }
>> + ret = reset_control_acquire(ospi->rstc);
>> + if (ret)
>> + return dev_err_probe(dev, ret, "Can not acquire reset %d\n", ret);
>> +
>> + reset_control_assert(ospi->rstc);
>> + udelay(2);
>> + reset_control_deassert(ospi->rstc);
>>
>> ret = spi_register_controller(ctrl);
>> if (ret) {
>> @@ -983,6 +985,8 @@ static void stm32_ospi_remove(struct platform_device *pdev)
>> if (ospi->dma_chrx)
>> dma_release_channel(ospi->dma_chrx);
>>
>> + reset_control_release(ospi->rstc);
>> +
>> pm_runtime_put_sync_suspend(ospi->dev);
>> pm_runtime_force_suspend(ospi->dev);
>> }
>> @@ -993,6 +997,8 @@ static int __maybe_unused stm32_ospi_suspend(struct device *dev)
>>
>> pinctrl_pm_select_sleep_state(dev);
>>
>> + reset_control_release(ospi->rstc);
>
> It would be nice to point out in a comment that OMM will temporarily
> take over control during resume. But either way,
>
Hi Philipp
Right, i will send a new version by adding this information.
Thanks
Patrice
> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
>
> regards
> Philipp
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-05-12 7:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-07 16:04 [PATCH v3] spi: stm32-ospi: Make usage of reset_control_acquire/release() API Patrice Chotard
2025-05-08 9:16 ` Philipp Zabel
2025-05-12 6:58 ` Patrice CHOTARD
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).