linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] reset: Add devm_reset_control_array_get_exclusive_released()
@ 2025-04-11 12:41 Patrice Chotard
  2025-04-11 12:41 ` [PATCH v2 1/2] " Patrice Chotard
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Patrice Chotard @ 2025-04-11 12:41 UTC (permalink / raw)
  To: Philipp Zabel, Mark Brown, Maxime Coquelin, Alexandre Torgue
  Cc: linux-kernel, linux-spi, linux-stm32, linux-arm-kernel,
	Patrice Chotard

Add the released variant of devm_reset_control_array_get_exclusive().
Needed by spi-smt32-ospi driver as same reset line is also used also
by stm32-omm driver.

Signed-off-by: Patrice Chotard <patrice.chotard@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/

---
Patrice Chotard (2):
      reset: Add devm_reset_control_array_get_exclusive_released()
      spi: stm32-ospi: Make usage of reset_control_acquire/release() API

 drivers/spi/spi-stm32-ospi.c | 15 +++++++++------
 include/linux/reset.h        |  6 ++++++
 2 files changed, 15 insertions(+), 6 deletions(-)
---
base-commit: 7a978d8fcf57b283cb8c88dd4c9431502bd36ea8
change-id: 20250411-b4-upstream_ospi_reset_update-596ce245ada1

Best regards,
-- 
Patrice Chotard <patrice.chotard@foss.st.com>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 1/2] reset: Add devm_reset_control_array_get_exclusive_released()
  2025-04-11 12:41 [PATCH v2 0/2] reset: Add devm_reset_control_array_get_exclusive_released() Patrice Chotard
@ 2025-04-11 12:41 ` Patrice Chotard
  2025-05-05 13:28   ` Philipp Zabel
  2025-04-11 12:41 ` [PATCH v2 2/2] spi: stm32-ospi: Make usage of reset_control_acquire/release() API Patrice Chotard
  2025-06-09 19:33 ` [PATCH v2 0/2] reset: Add devm_reset_control_array_get_exclusive_released() Mark Brown
  2 siblings, 1 reply; 7+ messages in thread
From: Patrice Chotard @ 2025-04-11 12:41 UTC (permalink / raw)
  To: Philipp Zabel, Mark Brown, Maxime Coquelin, Alexandre Torgue
  Cc: linux-kernel, linux-spi, linux-stm32, linux-arm-kernel,
	Patrice Chotard

Add the released variant of devm_reset_control_array_get_exclusive().
Needed by spi-smt32-ospi driver as same reset line is ulso used by
stm32-omm driver.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 include/linux/reset.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/linux/reset.h b/include/linux/reset.h
index 2986ced69a026947c8aafa89cdddf1e4088caef7..840d75d172f6239540bd12ab701103b7f02a624b 100644
--- a/include/linux/reset.h
+++ b/include/linux/reset.h
@@ -1004,6 +1004,12 @@ devm_reset_control_array_get_exclusive(struct device *dev)
 	return devm_reset_control_array_get(dev, RESET_CONTROL_EXCLUSIVE);
 }
 
+static inline struct reset_control *
+devm_reset_control_array_get_exclusive_released(struct device *dev)
+{
+	return devm_reset_control_array_get(dev, RESET_CONTROL_EXCLUSIVE_RELEASED);
+}
+
 static inline struct reset_control *
 devm_reset_control_array_get_shared(struct device *dev)
 {

-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 2/2] spi: stm32-ospi: Make usage of reset_control_acquire/release() API
  2025-04-11 12:41 [PATCH v2 0/2] reset: Add devm_reset_control_array_get_exclusive_released() Patrice Chotard
  2025-04-11 12:41 ` [PATCH v2 1/2] " Patrice Chotard
@ 2025-04-11 12:41 ` Patrice Chotard
  2025-05-05 13:12   ` Philipp Zabel
  2025-06-09 19:33 ` [PATCH v2 0/2] reset: Add devm_reset_control_array_get_exclusive_released() Mark Brown
  2 siblings, 1 reply; 7+ messages in thread
From: Patrice Chotard @ 2025-04-11 12:41 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>
---
 drivers/spi/spi-stm32-ospi.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/spi/spi-stm32-ospi.c b/drivers/spi/spi-stm32-ospi.c
index d002b9c16714684e4e4623f9255a7f2660c46fd1..ef840f377459891b559be6d6c0435408fb58a1e9 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_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,14 @@ 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);
+	reset_control_release(ospi->rstc);
 
 	ret = spi_register_controller(ctrl);
 	if (ret) {

-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 2/2] spi: stm32-ospi: Make usage of reset_control_acquire/release() API
  2025-04-11 12:41 ` [PATCH v2 2/2] spi: stm32-ospi: Make usage of reset_control_acquire/release() API Patrice Chotard
@ 2025-05-05 13:12   ` Philipp Zabel
  2025-05-07 16:04     ` Patrice CHOTARD
  0 siblings, 1 reply; 7+ messages in thread
From: Philipp Zabel @ 2025-05-05 13:12 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 Fr, 2025-04-11 at 14:41 +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>
> ---
>  drivers/spi/spi-stm32-ospi.c | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/spi/spi-stm32-ospi.c b/drivers/spi/spi-stm32-ospi.c
> index d002b9c16714684e4e4623f9255a7f2660c46fd1..ef840f377459891b559be6d6c0435408fb58a1e9 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_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,14 @@ 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);
> +	reset_control_release(ospi->rstc);

Could you keep the reset control (mostly) acquired from probe() to
remove()? The reset control would have to be released/acquired in OSPI
suspend/resume so that OMM can temporarily acquire control during OMM
resume.

regards
Philipp

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/2] reset: Add devm_reset_control_array_get_exclusive_released()
  2025-04-11 12:41 ` [PATCH v2 1/2] " Patrice Chotard
@ 2025-05-05 13:28   ` Philipp Zabel
  0 siblings, 0 replies; 7+ messages in thread
From: Philipp Zabel @ 2025-05-05 13:28 UTC (permalink / raw)
  To: Patrice Chotard, Mark Brown, Maxime Coquelin, Alexandre Torgue
  Cc: linux-kernel, linux-spi, linux-stm32, linux-arm-kernel

On Fr, 2025-04-11 at 14:41 +0200, Patrice Chotard wrote:
> Add the released variant of devm_reset_control_array_get_exclusive().
> Needed by spi-smt32-ospi driver as same reset line is ulso used by
> stm32-omm driver.
> 
> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>

Applied patch 1 to reset/next, thanks!

[1/2] reset: Add devm_reset_control_array_get_exclusive_released()
      https://git.pengutronix.de/cgit/pza/linux/commit/?id=6b3754009f87

regards
Philipp

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 2/2] spi: stm32-ospi: Make usage of reset_control_acquire/release() API
  2025-05-05 13:12   ` Philipp Zabel
@ 2025-05-07 16:04     ` Patrice CHOTARD
  0 siblings, 0 replies; 7+ 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



On 5/5/25 15:12, Philipp Zabel wrote:
> Hi Patrice,
> 
> On Fr, 2025-04-11 at 14:41 +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>
>> ---
>>  drivers/spi/spi-stm32-ospi.c | 15 +++++++++------
>>  1 file changed, 9 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/spi/spi-stm32-ospi.c b/drivers/spi/spi-stm32-ospi.c
>> index d002b9c16714684e4e4623f9255a7f2660c46fd1..ef840f377459891b559be6d6c0435408fb58a1e9 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_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,14 @@ 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);
>> +	reset_control_release(ospi->rstc);
> 
> Could you keep the reset control (mostly) acquired from probe() to
> remove()? The reset control would have to be released/acquired in OSPI
> suspend/resume so that OMM can temporarily acquire control during OMM
> resume.

Ok

Thanks
Patrice

> 
> regards
> Philipp

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 0/2] reset: Add devm_reset_control_array_get_exclusive_released()
  2025-04-11 12:41 [PATCH v2 0/2] reset: Add devm_reset_control_array_get_exclusive_released() Patrice Chotard
  2025-04-11 12:41 ` [PATCH v2 1/2] " Patrice Chotard
  2025-04-11 12:41 ` [PATCH v2 2/2] spi: stm32-ospi: Make usage of reset_control_acquire/release() API Patrice Chotard
@ 2025-06-09 19:33 ` Mark Brown
  2 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2025-06-09 19:33 UTC (permalink / raw)
  To: Philipp Zabel, Maxime Coquelin, Alexandre Torgue, Patrice Chotard
  Cc: linux-kernel, linux-spi, linux-stm32, linux-arm-kernel

On Fri, 11 Apr 2025 14:41:09 +0200, Patrice Chotard wrote:
> Add the released variant of devm_reset_control_array_get_exclusive().
> Needed by spi-smt32-ospi driver as same reset line is also used also
> by stm32-omm driver.
> 
> Signed-off-by: Patrice Chotard <patrice.chotard@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/
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/2] reset: Add devm_reset_control_array_get_exclusive_released()
      (no commit info)
[2/2] spi: stm32-ospi: Make usage of reset_control_acquire/release() API
      commit: cf2c3eceb757e3f28e6f1034f9bc178e1535f5cc

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-06-09 19:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-11 12:41 [PATCH v2 0/2] reset: Add devm_reset_control_array_get_exclusive_released() Patrice Chotard
2025-04-11 12:41 ` [PATCH v2 1/2] " Patrice Chotard
2025-05-05 13:28   ` Philipp Zabel
2025-04-11 12:41 ` [PATCH v2 2/2] spi: stm32-ospi: Make usage of reset_control_acquire/release() API Patrice Chotard
2025-05-05 13:12   ` Philipp Zabel
2025-05-07 16:04     ` Patrice CHOTARD
2025-06-09 19:33 ` [PATCH v2 0/2] reset: Add devm_reset_control_array_get_exclusive_released() Mark Brown

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).