aboutsummaryrefslogtreecommitdiff
path: root/drivers/pinctrl
diff options
context:
space:
mode:
authorAndy Shevchenko2019-11-25 19:27:34 +0200
committerAndy Shevchenko2019-12-13 16:48:48 +0200
commit21a06495d0e757b8a52774ce62e9cfdf07838971 (patch)
tree9c102e0a12df776cf975c6a09acf707d02084c5d /drivers/pinctrl
parentc35f463a966221f3d6c6bc48fbea27a8d68aafc3 (diff)
pinctrl: lynxpoint: Extract lp_gpio_acpi_use() for future use
We may need this function for other features in the pin control driver. Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Diffstat (limited to 'drivers/pinctrl')
-rw-r--r--drivers/pinctrl/intel/pinctrl-lynxpoint.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/drivers/pinctrl/intel/pinctrl-lynxpoint.c b/drivers/pinctrl/intel/pinctrl-lynxpoint.c
index 3c8241ed8bc2..d40360728140 100644
--- a/drivers/pinctrl/intel/pinctrl-lynxpoint.c
+++ b/drivers/pinctrl/intel/pinctrl-lynxpoint.c
@@ -98,18 +98,28 @@ static void __iomem *lp_gpio_reg(struct gpio_chip *chip, unsigned int offset,
return lg->regs + reg + reg_offset;
}
+static bool lp_gpio_acpi_use(struct lp_gpio *lg, unsigned int pin)
+{
+ void __iomem *acpi_use;
+
+ acpi_use = lp_gpio_reg(&lg->chip, pin, LP_ACPI_OWNED);
+ if (!acpi_use)
+ return true;
+
+ return !(ioread32(acpi_use) & BIT(pin % 32));
+}
+
static int lp_gpio_request(struct gpio_chip *chip, unsigned int offset)
{
struct lp_gpio *lg = gpiochip_get_data(chip);
void __iomem *reg = lp_gpio_reg(chip, offset, LP_CONFIG1);
void __iomem *conf2 = lp_gpio_reg(chip, offset, LP_CONFIG2);
- void __iomem *acpi_use = lp_gpio_reg(chip, offset, LP_ACPI_OWNED);
u32 value;
pm_runtime_get(lg->dev); /* should we put if failed */
/* Fail if BIOS reserved pin for ACPI use */
- if (!(ioread32(acpi_use) & BIT(offset % 32))) {
+ if (lp_gpio_acpi_use(lg, offset)) {
dev_err(lg->dev, "gpio %d reserved for ACPI\n", offset);
return -EBUSY;
}