mfd: madera: Add reset as part of resume
Subsystems (2)
Charles Keepax
maintainerPATCH 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.
--- drivers/mfd/madera-core.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
drivers/mfd/madera-core.c +15 -1
@@ -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)
Signature · 1 line
2.11.0
Charles Keepax
maintainerPATCH 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.
--- drivers/mfd/madera-core.c | 25 ++++++++++++++++++++----- include/linux/mfd/madera/core.h | 1 + 2 files changed, 21 insertions(+), 5 deletions(-)
drivers/mfd/madera-core.c +20 -5
@@ -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;
include/linux/mfd/madera/core.h +1 -0
@@ -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;
Signature · 1 line
2.11.0
Lee Jones
AppliedRe: [PATCH RESEND 2/2] mfd: madera: Add special errata reset handling for cs47l15
Quoted 11 lines · Charles Keepax
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.
Signature · 4 lines
Lee Jones [李琼斯] Senior Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
Lee Jones
AppliedQuoted 13 lines · Charles Keepax
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.
Quoted 4 lines
Signed-off-by Charles Keepax <[email protected]>--- drivers/mfd/madera-core.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
Applied, thanks.
Signature · 4 lines
Lee Jones [李琼斯] Senior Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog