2020-10-28 06:19:11

by Charles Keepax

[permalink] [raw]
Subject: [PATCH RESEND 1/2] mfd: madera: Add reset as part of resume

The DCVDD supply does not always power down when the CODEC enters
suspend, for example shared regulators or always-on regulators. In
these cases if a register is written back to the default value whilst
the CODEC is in suspend that register will retain the previous value.
As DCVDD never powered down, the register retains its old value and
as the cache sync only synchronises registers that differ from the
default the new value is never written out.

Ensure the registers are in the expected state after suspend by always
resetting the CODEC on resume. This also has the benefit of being
recommended by the datasheet for DCVDD supplies that take longer than
2mS to rise.

Signed-off-by: Charles Keepax <[email protected]>
---
drivers/mfd/madera-core.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/mfd/madera-core.c b/drivers/mfd/madera-core.c
index 4ed6ad8ce0020..a9c6f0833f327 100644
--- a/drivers/mfd/madera-core.c
+++ b/drivers/mfd/madera-core.c
@@ -291,6 +291,8 @@ static int __maybe_unused madera_runtime_resume(struct device *dev)

dev_dbg(dev, "Leaving sleep mode\n");

+ madera_enable_hard_reset(madera);
+
ret = regulator_enable(madera->dcvdd);
if (ret) {
dev_err(dev, "Failed to enable DCVDD: %d\n", ret);
@@ -300,7 +302,19 @@ static int __maybe_unused madera_runtime_resume(struct device *dev)
regcache_cache_only(madera->regmap, false);
regcache_cache_only(madera->regmap_32bit, false);

- usleep_range(MADERA_RESET_MIN_US, MADERA_RESET_MAX_US);
+ madera_disable_hard_reset(madera);
+
+ if (!madera->pdata.reset) {
+ ret = madera_wait_for_boot(madera);
+ if (ret)
+ goto err;
+
+ ret = madera_soft_reset(madera);
+ if (ret) {
+ dev_err(dev, "Failed to reset: %d\n", ret);
+ goto err;
+ }
+ }

ret = madera_wait_for_boot(madera);
if (ret)
--
2.11.0


2020-10-28 06:19:27

by Charles Keepax

[permalink] [raw]
Subject: [PATCH RESEND 2/2] mfd: madera: Add special errata reset handling for cs47l15

An errata exists for cs47l15 where the reset must be handled
differently and removed before DCVDD is applied. A soft reset is used
for situations where a reset is required to reset state. This does
however, make this part unsuitable for DCVDD supplies with a rise time
greater than 2mS.

Signed-off-by: Charles Keepax <[email protected]>
---
drivers/mfd/madera-core.c | 25 ++++++++++++++++++++-----
include/linux/mfd/madera/core.h | 1 +
2 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/drivers/mfd/madera-core.c b/drivers/mfd/madera-core.c
index a9c6f0833f327..a2abc0094def7 100644
--- a/drivers/mfd/madera-core.c
+++ b/drivers/mfd/madera-core.c
@@ -38,6 +38,9 @@
#define MADERA_RESET_MIN_US 2000
#define MADERA_RESET_MAX_US 3000

+#define ERRATA_DCVDD_MIN_US 10000
+#define ERRATA_DCVDD_MAX_US 15000
+
static const char * const madera_core_supplies[] = {
"AVDD",
"DBVDD1",
@@ -291,7 +294,8 @@ static int __maybe_unused madera_runtime_resume(struct device *dev)

dev_dbg(dev, "Leaving sleep mode\n");

- madera_enable_hard_reset(madera);
+ if (!madera->reset_errata)
+ madera_enable_hard_reset(madera);

ret = regulator_enable(madera->dcvdd);
if (ret) {
@@ -302,9 +306,12 @@ static int __maybe_unused madera_runtime_resume(struct device *dev)
regcache_cache_only(madera->regmap, false);
regcache_cache_only(madera->regmap_32bit, false);

- madera_disable_hard_reset(madera);
+ if (madera->reset_errata)
+ usleep_range(ERRATA_DCVDD_MIN_US, ERRATA_DCVDD_MAX_US);
+ else
+ madera_disable_hard_reset(madera);

- if (!madera->pdata.reset) {
+ if (!madera->pdata.reset || madera->reset_errata) {
ret = madera_wait_for_boot(madera);
if (ret)
goto err;
@@ -503,6 +510,8 @@ int madera_dev_init(struct madera *madera)
*/
switch (madera->type) {
case CS47L15:
+ madera->reset_errata = true;
+ break;
case CS47L35:
case CS47L90:
case CS47L91:
@@ -553,13 +562,19 @@ int madera_dev_init(struct madera *madera)
goto err_dcvdd;
}

+ if (madera->reset_errata)
+ madera_disable_hard_reset(madera);
+
ret = regulator_enable(madera->dcvdd);
if (ret) {
dev_err(dev, "Failed to enable DCVDD: %d\n", ret);
goto err_enable;
}

- madera_disable_hard_reset(madera);
+ if (madera->reset_errata)
+ usleep_range(ERRATA_DCVDD_MIN_US, ERRATA_DCVDD_MAX_US);
+ else
+ madera_disable_hard_reset(madera);

regcache_cache_only(madera->regmap, false);
regcache_cache_only(madera->regmap_32bit, false);
@@ -667,7 +682,7 @@ int madera_dev_init(struct madera *madera)
* It looks like a device we support. If we don't have a hard reset
* we can now attempt a soft reset.
*/
- if (!madera->pdata.reset) {
+ if (!madera->pdata.reset || madera->reset_errata) {
ret = madera_soft_reset(madera);
if (ret)
goto err_reset;
diff --git a/include/linux/mfd/madera/core.h b/include/linux/mfd/madera/core.h
index ad2c138105d4b..03a8a788424a2 100644
--- a/include/linux/mfd/madera/core.h
+++ b/include/linux/mfd/madera/core.h
@@ -186,6 +186,7 @@ struct madera {
struct regulator_bulk_data core_supplies[MADERA_MAX_CORE_SUPPLIES];
struct regulator *dcvdd;
bool internal_dcvdd;
+ bool reset_errata;

struct madera_pdata pdata;

--
2.11.0

2020-11-04 15:42:00

by Lee Jones

[permalink] [raw]
Subject: Re: [PATCH RESEND 1/2] mfd: madera: Add reset as part of resume

On Tue, 27 Oct 2020, Charles Keepax wrote:

> The DCVDD supply does not always power down when the CODEC enters
> suspend, for example shared regulators or always-on regulators. In
> these cases if a register is written back to the default value whilst
> the CODEC is in suspend that register will retain the previous value.
> As DCVDD never powered down, the register retains its old value and
> as the cache sync only synchronises registers that differ from the
> default the new value is never written out.
>
> Ensure the registers are in the expected state after suspend by always
> resetting the CODEC on resume. This also has the benefit of being
> recommended by the datasheet for DCVDD supplies that take longer than
> 2mS to rise.
>
> Signed-off-by: Charles Keepax <[email protected]>
> ---
> drivers/mfd/madera-core.c | 16 +++++++++++++++-
> 1 file changed, 15 insertions(+), 1 deletion(-)

Applied, thanks.

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

2020-11-04 15:46:41

by Lee Jones

[permalink] [raw]
Subject: Re: [PATCH RESEND 2/2] mfd: madera: Add special errata reset handling for cs47l15

On Tue, 27 Oct 2020, Charles Keepax wrote:

> An errata exists for cs47l15 where the reset must be handled
> differently and removed before DCVDD is applied. A soft reset is used
> for situations where a reset is required to reset state. This does
> however, make this part unsuitable for DCVDD supplies with a rise time
> greater than 2mS.
>
> Signed-off-by: Charles Keepax <[email protected]>
> ---
> drivers/mfd/madera-core.c | 25 ++++++++++++++++++++-----
> include/linux/mfd/madera/core.h | 1 +
> 2 files changed, 21 insertions(+), 5 deletions(-)

Applied, thanks.

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