pinctrl: intel: Use helper to restore register values on ->resume()

We can restore only values that had been changed and do not spam kernel log
with unnecessary messages. Convert intel_gpio_update_pad_mode() to a helper
function that will be used across few callers.

Suggested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
This commit is contained in:
Andy Shevchenko 2019-10-22 13:00:04 +03:00
parent 764cfe3351
commit 942c5ea49f

View File

@ -1595,16 +1595,18 @@ intel_gpio_is_requested(struct gpio_chip *chip, int base, unsigned int size)
return requested; return requested;
} }
static u32 static bool intel_gpio_update_reg(void __iomem *reg, u32 mask, u32 value)
intel_gpio_update_pad_mode(void __iomem *hostown, u32 mask, u32 value)
{ {
u32 curr, updated; u32 curr, updated;
curr = readl(hostown); curr = readl(reg);
updated = (curr & ~mask) | (value & mask);
writel(updated, hostown);
return curr; updated = (curr & ~mask) | (value & mask);
if (curr == updated)
return false;
writel(updated, reg);
return true;
} }
static void intel_restore_hostown(struct intel_pinctrl *pctrl, unsigned int c, static void intel_restore_hostown(struct intel_pinctrl *pctrl, unsigned int c,
@ -1613,14 +1615,13 @@ static void intel_restore_hostown(struct intel_pinctrl *pctrl, unsigned int c,
const struct intel_community *community = &pctrl->communities[c]; const struct intel_community *community = &pctrl->communities[c];
const struct intel_padgroup *padgrp = &community->gpps[gpp]; const struct intel_padgroup *padgrp = &community->gpps[gpp];
struct device *dev = pctrl->dev; struct device *dev = pctrl->dev;
u32 requested, value; u32 requested;
if (padgrp->gpio_base < 0) if (padgrp->gpio_base < 0)
return; return;
requested = intel_gpio_is_requested(&pctrl->chip, padgrp->gpio_base, padgrp->size); requested = intel_gpio_is_requested(&pctrl->chip, padgrp->gpio_base, padgrp->size);
value = intel_gpio_update_pad_mode(base + gpp * 4, requested, saved); if (!intel_gpio_update_reg(base + gpp * 4, requested, saved))
if (!((value ^ saved) & requested))
return; return;
dev_dbg(dev, "restored hostown %u/%u %#08x\n", c, gpp, readl(base + gpp * 4)); dev_dbg(dev, "restored hostown %u/%u %#08x\n", c, gpp, readl(base + gpp * 4));
@ -1631,7 +1632,9 @@ static void intel_restore_intmask(struct intel_pinctrl *pctrl, unsigned int c,
{ {
struct device *dev = pctrl->dev; struct device *dev = pctrl->dev;
writel(saved, base + gpp * 4); if (!intel_gpio_update_reg(base + gpp * 4, ~0U, saved))
return;
dev_dbg(dev, "restored mask %u/%u %#08x\n", c, gpp, readl(base + gpp * 4)); dev_dbg(dev, "restored mask %u/%u %#08x\n", c, gpp, readl(base + gpp * 4));
} }
@ -1642,17 +1645,14 @@ static void intel_restore_padcfg(struct intel_pinctrl *pctrl, unsigned int pin,
unsigned int n = reg / sizeof(u32); unsigned int n = reg / sizeof(u32);
struct device *dev = pctrl->dev; struct device *dev = pctrl->dev;
void __iomem *padcfg; void __iomem *padcfg;
u32 value;
padcfg = intel_get_padcfg(pctrl, pin, reg); padcfg = intel_get_padcfg(pctrl, pin, reg);
if (!padcfg) if (!padcfg)
return; return;
value = readl(padcfg) & ~mask; if (!intel_gpio_update_reg(padcfg, ~mask, saved))
if (value == saved)
return; return;
writel(saved, padcfg);
dev_dbg(dev, "restored pin %u padcfg%u %#08x\n", pin, n, readl(padcfg)); dev_dbg(dev, "restored pin %u padcfg%u %#08x\n", pin, n, readl(padcfg));
} }