Skip to contentSkip to conversation

mfd: wm8994: Use regcache_sync_region() to sync GPIO registers on suspend

PATCH Applied Mark Brown 2 participants 4 messages Jun 29, 2012 – Jul 8, 2012

Subsystems (2)
lore
Share & tools
lore

Mark Brown

author
#0 lore raw

PATCH 1/2 mfd: wm8994: Use regcache_sync_region() to sync GPIO registers on suspend

Now we have regcache sync region we can use it to do a more efficient sync of the pin configuration after we reset the device during suspend.

---
 drivers/mfd/wm8994-core.c |   13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/mfd/wm8994-core.c +4 -9
index f75cdcc..53293c7 100644
@@ -196,7 +196,6 @@ static int wm8994_suspend(struct device *dev)
 {
 	struct wm8994 *wm8994 = dev_get_drvdata(dev);
 	int ret;
-	int gpio_regs[WM8994_NUM_GPIO_REGS];
 
 	/* Don't actually go through with the suspend if the CODEC is
 	 * still active (eg, for audio passthrough from CP. */
@@ -278,27 +277,23 @@ static int wm8994_suspend(struct device *dev)
 				WM8994_LDO1ENA_PD | WM8994_LDO2ENA_PD,
 				WM8994_LDO1ENA_PD | WM8994_LDO2ENA_PD);
 
-	/* Save GPIO registers before reset */
-	regmap_bulk_read(wm8994->regmap, WM8994_GPIO_1, gpio_regs,
-			 WM8994_NUM_GPIO_REGS);
-
 	/* Explicitly put the device into reset in case regulators
 	 * don't get disabled in order to ensure consistent restart.
 	 */
 	wm8994_reg_write(wm8994, WM8994_SOFTWARE_RESET,
 			 wm8994_reg_read(wm8994, WM8994_SOFTWARE_RESET));
 
+	regcache_mark_dirty(wm8994->regmap);
+
 	/* Restore GPIO registers to prevent problems with mismatched
 	 * pin configurations.
 	 */
-	ret = regmap_bulk_write(wm8994->regmap, WM8994_GPIO_1, gpio_regs,
-				WM8994_NUM_GPIO_REGS);
+	ret = regcache_sync_region(wm8994->regmap, WM8994_GPIO_1,
+				   WM8994_GPIO_11);
 	if (ret != 0)
 		dev_err(dev, "Failed to restore GPIO registers: %d\n", ret);
 
 	regcache_cache_only(wm8994->regmap, true);
-	regcache_mark_dirty(wm8994->regmap);
-
 	wm8994->suspended = true;
 
 	ret = regulator_bulk_disable(wm8994->num_supplies,
Signature · 1 line
1.7.10
author
#1 lore raw

PATCH 2/2 mfd: wm8994: Also restore GPIO IRQ masks after reset

This ensures that if we are using a GPIO as a wake source it continues to function while we're suspended.

---
 drivers/mfd/wm8994-core.c |    7 +++++++
 1 file changed, 7 insertions(+)
drivers/mfd/wm8994-core.c +7 -0
index 53293c7..eec74aa 100644
@@ -293,6 +293,13 @@ static int wm8994_suspend(struct device *dev)
 	if (ret != 0)
 		dev_err(dev, "Failed to restore GPIO registers: %d\n", ret);
 
+	/* In case one of the GPIOs is used as a wake input. */
+	ret = regcache_sync_region(wm8994->regmap,
+				   WM8994_INTERRUPT_STATUS_1_MASK,
+				   WM8994_INTERRUPT_STATUS_1_MASK);
+	if (ret != 0)
+		dev_err(dev, "Failed to restore interrupt mask: %d\n", ret);
+
 	regcache_cache_only(wm8994->regmap, true);
 	wm8994->suspended = true;
 
Signature · 1 line
1.7.10
Applied
#2 lore raw

Re: [PATCH 2/2] mfd: wm8994: Also restore GPIO IRQ masks after reset

Hi Mark,

Quoted 7 lines · Mark Brown

This ensures that if we are using a GPIO as a wake source it continues to function while we're suspended.

---
 drivers/mfd/wm8994-core.c |    7 +++++++
 1 file changed, 7 insertions(+)

Applied as well, thanks.

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/
Applied
#3 lore raw
In reply to Mark Brown

Hi Mark,

Quoted 7 lines · Mark Brown

Now we have regcache sync region we can use it to do a more efficient sync of the pin configuration after we reset the device during suspend.

---
 drivers/mfd/wm8994-core.c |   13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

Applied, thanks.

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/