linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] STMFX power related fixes
@ 2020-04-22  9:08 Amelie Delaunay
  2020-04-22  9:08 ` [PATCH 1/3] mfd: stmfx: reset chip on resume as supply was disabled Amelie Delaunay
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Amelie Delaunay @ 2020-04-22  9:08 UTC (permalink / raw)
  To: Lee Jones, Maxime Coquelin, Alexandre Torgue
  Cc: linux-stm32, linux-arm-kernel, linux-kernel, Amelie Delaunay

With suspend/resume tests on STM32MP157C-EV1 board, on which STMFX is used by
several devices, some errors could occurred: -6 when trying to restore STMFX
registers, spurious interrupts after disabling supply...
This patchset fixes all these issues and cleans IRQ init error path.

Amelie Delaunay (3):
  mfd: stmfx: reset chip on resume as supply was disabled
  mfd: stmfx: fix stmfx_irq_init error path
  mfd: stmfx: disable irq in suspend to avoid spurious interrupt

 drivers/mfd/stmfx.c       | 22 ++++++++++++++++++++--
 include/linux/mfd/stmfx.h |  1 +
 2 files changed, 21 insertions(+), 2 deletions(-)

-- 
2.17.1


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

* [PATCH 1/3] mfd: stmfx: reset chip on resume as supply was disabled
  2020-04-22  9:08 [PATCH 0/3] STMFX power related fixes Amelie Delaunay
@ 2020-04-22  9:08 ` Amelie Delaunay
  2020-05-26  7:57   ` Lee Jones
  2020-04-22  9:08 ` [PATCH 2/3] mfd: stmfx: fix stmfx_irq_init error path Amelie Delaunay
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Amelie Delaunay @ 2020-04-22  9:08 UTC (permalink / raw)
  To: Lee Jones, Maxime Coquelin, Alexandre Torgue
  Cc: linux-stm32, linux-arm-kernel, linux-kernel, Amelie Delaunay

STMFX supply is disabled during suspend. To avoid a too early access to
the STMFX firmware on resume, reset the chip and wait for its firmware to
be loaded.

Fixes: 06252ade9156 ("mfd: Add ST Multi-Function eXpander (STMFX) core driver")
Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com>
---
 drivers/mfd/stmfx.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/mfd/stmfx.c b/drivers/mfd/stmfx.c
index 857991cb3cbb..fde6541e347c 100644
--- a/drivers/mfd/stmfx.c
+++ b/drivers/mfd/stmfx.c
@@ -501,6 +501,13 @@ static int stmfx_resume(struct device *dev)
 		}
 	}
 
+	/* Reset STMFX - supply has been stopped during suspend */
+	ret = stmfx_chip_reset(stmfx);
+	if (ret) {
+		dev_err(stmfx->dev, "Failed to reset chip: %d\n", ret);
+		return ret;
+	}
+
 	ret = regmap_raw_write(stmfx->map, STMFX_REG_SYS_CTRL,
 			       &stmfx->bkp_sysctrl, sizeof(stmfx->bkp_sysctrl));
 	if (ret)
-- 
2.17.1


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

* [PATCH 2/3] mfd: stmfx: fix stmfx_irq_init error path
  2020-04-22  9:08 [PATCH 0/3] STMFX power related fixes Amelie Delaunay
  2020-04-22  9:08 ` [PATCH 1/3] mfd: stmfx: reset chip on resume as supply was disabled Amelie Delaunay
@ 2020-04-22  9:08 ` Amelie Delaunay
  2020-05-26  7:58   ` Lee Jones
  2020-04-22  9:08 ` [PATCH 3/3] mfd: stmfx: disable irq in suspend to avoid spurious interrupt Amelie Delaunay
  2020-05-25 12:02 ` [PATCH 0/3] STMFX power related fixes Amelie DELAUNAY
  3 siblings, 1 reply; 9+ messages in thread
From: Amelie Delaunay @ 2020-04-22  9:08 UTC (permalink / raw)
  To: Lee Jones, Maxime Coquelin, Alexandre Torgue
  Cc: linux-stm32, linux-arm-kernel, linux-kernel, Amelie Delaunay

In case the interrupt signal can't be configured, irq domain needs to be
removed.

Fixes: 06252ade9156 ("mfd: Add ST Multi-Function eXpander (STMFX) core driver")
Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com>
---
 drivers/mfd/stmfx.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/stmfx.c b/drivers/mfd/stmfx.c
index fde6541e347c..1977fe95f876 100644
--- a/drivers/mfd/stmfx.c
+++ b/drivers/mfd/stmfx.c
@@ -287,14 +287,19 @@ static int stmfx_irq_init(struct i2c_client *client)
 
 	ret = regmap_write(stmfx->map, STMFX_REG_IRQ_OUT_PIN, irqoutpin);
 	if (ret)
-		return ret;
+		goto irq_exit;
 
 	ret = devm_request_threaded_irq(stmfx->dev, client->irq,
 					NULL, stmfx_irq_handler,
 					irqtrigger | IRQF_ONESHOT,
 					"stmfx", stmfx);
 	if (ret)
-		stmfx_irq_exit(client);
+		goto irq_exit;
+
+	return 0;
+
+irq_exit:
+	stmfx_irq_exit(client);
 
 	return ret;
 }
-- 
2.17.1


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

* [PATCH 3/3] mfd: stmfx: disable irq in suspend to avoid spurious interrupt
  2020-04-22  9:08 [PATCH 0/3] STMFX power related fixes Amelie Delaunay
  2020-04-22  9:08 ` [PATCH 1/3] mfd: stmfx: reset chip on resume as supply was disabled Amelie Delaunay
  2020-04-22  9:08 ` [PATCH 2/3] mfd: stmfx: fix stmfx_irq_init error path Amelie Delaunay
@ 2020-04-22  9:08 ` Amelie Delaunay
  2020-05-26  7:59   ` Lee Jones
  2020-05-25 12:02 ` [PATCH 0/3] STMFX power related fixes Amelie DELAUNAY
  3 siblings, 1 reply; 9+ messages in thread
From: Amelie Delaunay @ 2020-04-22  9:08 UTC (permalink / raw)
  To: Lee Jones, Maxime Coquelin, Alexandre Torgue
  Cc: linux-stm32, linux-arm-kernel, linux-kernel, Amelie Delaunay

When STMFX supply is stopped, spurious interrupt can occur. To avoid that,
disable the interrupt in suspend before disabling the regulator and
re-enable it at the end of resume.

Fixes: 06252ade9156 ("mfd: Add ST Multi-Function eXpander (STMFX) core driver")
Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com>
---
 drivers/mfd/stmfx.c       | 6 ++++++
 include/linux/mfd/stmfx.h | 1 +
 2 files changed, 7 insertions(+)

diff --git a/drivers/mfd/stmfx.c b/drivers/mfd/stmfx.c
index 1977fe95f876..711979afd90a 100644
--- a/drivers/mfd/stmfx.c
+++ b/drivers/mfd/stmfx.c
@@ -296,6 +296,8 @@ static int stmfx_irq_init(struct i2c_client *client)
 	if (ret)
 		goto irq_exit;
 
+	stmfx->irq = client->irq;
+
 	return 0;
 
 irq_exit:
@@ -486,6 +488,8 @@ static int stmfx_suspend(struct device *dev)
 	if (ret)
 		return ret;
 
+	disable_irq(stmfx->irq);
+
 	if (stmfx->vdd)
 		return regulator_disable(stmfx->vdd);
 
@@ -529,6 +533,8 @@ static int stmfx_resume(struct device *dev)
 	if (ret)
 		return ret;
 
+	enable_irq(stmfx->irq);
+
 	return 0;
 }
 #endif
diff --git a/include/linux/mfd/stmfx.h b/include/linux/mfd/stmfx.h
index 3c67983678ec..744dce63946e 100644
--- a/include/linux/mfd/stmfx.h
+++ b/include/linux/mfd/stmfx.h
@@ -109,6 +109,7 @@ struct stmfx {
 	struct device *dev;
 	struct regmap *map;
 	struct regulator *vdd;
+	int irq;
 	struct irq_domain *irq_domain;
 	struct mutex lock; /* IRQ bus lock */
 	u8 irq_src;
-- 
2.17.1


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

* Re: [PATCH 0/3] STMFX power related fixes
  2020-04-22  9:08 [PATCH 0/3] STMFX power related fixes Amelie Delaunay
                   ` (2 preceding siblings ...)
  2020-04-22  9:08 ` [PATCH 3/3] mfd: stmfx: disable irq in suspend to avoid spurious interrupt Amelie Delaunay
@ 2020-05-25 12:02 ` Amelie DELAUNAY
  2020-05-26  7:27   ` Lee Jones
  3 siblings, 1 reply; 9+ messages in thread
From: Amelie DELAUNAY @ 2020-05-25 12:02 UTC (permalink / raw)
  To: Lee Jones, Maxime Coquelin, Alexandre Torgue
  Cc: linux-stm32, linux-arm-kernel, linux-kernel

Hi,

Gentle reminder regarding this series sent one month ago.

Regards,
Amelie

On 4/22/20 11:08 AM, Amelie Delaunay wrote:
> With suspend/resume tests on STM32MP157C-EV1 board, on which STMFX is used by
> several devices, some errors could occurred: -6 when trying to restore STMFX
> registers, spurious interrupts after disabling supply...
> This patchset fixes all these issues and cleans IRQ init error path.
> 
> Amelie Delaunay (3):
>    mfd: stmfx: reset chip on resume as supply was disabled
>    mfd: stmfx: fix stmfx_irq_init error path
>    mfd: stmfx: disable irq in suspend to avoid spurious interrupt
> 
>   drivers/mfd/stmfx.c       | 22 ++++++++++++++++++++--
>   include/linux/mfd/stmfx.h |  1 +
>   2 files changed, 21 insertions(+), 2 deletions(-)
> 

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

* Re: [PATCH 0/3] STMFX power related fixes
  2020-05-25 12:02 ` [PATCH 0/3] STMFX power related fixes Amelie DELAUNAY
@ 2020-05-26  7:27   ` Lee Jones
  0 siblings, 0 replies; 9+ messages in thread
From: Lee Jones @ 2020-05-26  7:27 UTC (permalink / raw)
  To: Amelie DELAUNAY
  Cc: Maxime Coquelin, Alexandre Torgue, linux-stm32, linux-arm-kernel,
	linux-kernel

On Mon, 25 May 2020, Amelie DELAUNAY wrote:

> Hi,
> 
> Gentle reminder regarding this series sent one month ago.

Apologies Amelie, this fell through the gaps.

If this happens in the future just submit a [RESEND].

I'll take a look at this, this time however.

> On 4/22/20 11:08 AM, Amelie Delaunay wrote:
> > With suspend/resume tests on STM32MP157C-EV1 board, on which STMFX is used by
> > several devices, some errors could occurred: -6 when trying to restore STMFX
> > registers, spurious interrupts after disabling supply...
> > This patchset fixes all these issues and cleans IRQ init error path.
> > 
> > Amelie Delaunay (3):
> >    mfd: stmfx: reset chip on resume as supply was disabled
> >    mfd: stmfx: fix stmfx_irq_init error path
> >    mfd: stmfx: disable irq in suspend to avoid spurious interrupt
> > 
> >   drivers/mfd/stmfx.c       | 22 ++++++++++++++++++++--
> >   include/linux/mfd/stmfx.h |  1 +
> >   2 files changed, 21 insertions(+), 2 deletions(-)
> > 

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH 1/3] mfd: stmfx: reset chip on resume as supply was disabled
  2020-04-22  9:08 ` [PATCH 1/3] mfd: stmfx: reset chip on resume as supply was disabled Amelie Delaunay
@ 2020-05-26  7:57   ` Lee Jones
  0 siblings, 0 replies; 9+ messages in thread
From: Lee Jones @ 2020-05-26  7:57 UTC (permalink / raw)
  To: Amelie Delaunay
  Cc: Maxime Coquelin, Alexandre Torgue, linux-stm32, linux-arm-kernel,
	linux-kernel

On Wed, 22 Apr 2020, Amelie Delaunay wrote:

> STMFX supply is disabled during suspend. To avoid a too early access to
> the STMFX firmware on resume, reset the chip and wait for its firmware to
> be loaded.
> 
> Fixes: 06252ade9156 ("mfd: Add ST Multi-Function eXpander (STMFX) core driver")
> Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com>
> ---
>  drivers/mfd/stmfx.c | 7 +++++++
>  1 file changed, 7 insertions(+)

Applied, thanks.

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH 2/3] mfd: stmfx: fix stmfx_irq_init error path
  2020-04-22  9:08 ` [PATCH 2/3] mfd: stmfx: fix stmfx_irq_init error path Amelie Delaunay
@ 2020-05-26  7:58   ` Lee Jones
  0 siblings, 0 replies; 9+ messages in thread
From: Lee Jones @ 2020-05-26  7:58 UTC (permalink / raw)
  To: Amelie Delaunay
  Cc: Maxime Coquelin, Alexandre Torgue, linux-stm32, linux-arm-kernel,
	linux-kernel

On Wed, 22 Apr 2020, Amelie Delaunay wrote:

> In case the interrupt signal can't be configured, IRQ domain needs to be
> removed.
> 
> Fixes: 06252ade9156 ("mfd: Add ST Multi-Function eXpander (STMFX) core driver")
> Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com>
> ---
>  drivers/mfd/stmfx.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)

Applied, thanks.

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH 3/3] mfd: stmfx: disable irq in suspend to avoid spurious interrupt
  2020-04-22  9:08 ` [PATCH 3/3] mfd: stmfx: disable irq in suspend to avoid spurious interrupt Amelie Delaunay
@ 2020-05-26  7:59   ` Lee Jones
  0 siblings, 0 replies; 9+ messages in thread
From: Lee Jones @ 2020-05-26  7:59 UTC (permalink / raw)
  To: Amelie Delaunay
  Cc: Maxime Coquelin, Alexandre Torgue, linux-stm32, linux-arm-kernel,
	linux-kernel

On Wed, 22 Apr 2020, Amelie Delaunay wrote:

> When STMFX supply is stopped, spurious interrupt can occur. To avoid that,
> disable the interrupt in suspend before disabling the regulator and
> re-enable it at the end of resume.
> 
> Fixes: 06252ade9156 ("mfd: Add ST Multi-Function eXpander (STMFX) core driver")
> Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com>
> ---
>  drivers/mfd/stmfx.c       | 6 ++++++
>  include/linux/mfd/stmfx.h | 1 +
>  2 files changed, 7 insertions(+)

Applied, thanks.

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

end of thread, other threads:[~2020-05-26  7:59 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-22  9:08 [PATCH 0/3] STMFX power related fixes Amelie Delaunay
2020-04-22  9:08 ` [PATCH 1/3] mfd: stmfx: reset chip on resume as supply was disabled Amelie Delaunay
2020-05-26  7:57   ` Lee Jones
2020-04-22  9:08 ` [PATCH 2/3] mfd: stmfx: fix stmfx_irq_init error path Amelie Delaunay
2020-05-26  7:58   ` Lee Jones
2020-04-22  9:08 ` [PATCH 3/3] mfd: stmfx: disable irq in suspend to avoid spurious interrupt Amelie Delaunay
2020-05-26  7:59   ` Lee Jones
2020-05-25 12:02 ` [PATCH 0/3] STMFX power related fixes Amelie DELAUNAY
2020-05-26  7:27   ` Lee Jones

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