[linux-yocto] [PATCH 25/29] pinctrl-baytrail: add function mux checking in gpio pin request
rebecca.swee.fun.chang at intel.com
rebecca.swee.fun.chang at intel.com
Mon Apr 7 08:18:16 PDT 2014
From: "Chew, Kean Ho" <kean.ho.chew at intel.com>
The requested GPIO pin must has the function mux bits set
to GPIO function by BIOS in advance. Else, the gpio pin
request would fail. This is to ensure that we do not expose
any GPIO pins which shall be used for other purposes,
for eg: wakeup pin, I/O interfaces for LPSS, etc.
Signed-off-by: Chew, Kean Ho <kean.ho.chew at intel.com>
Signed-off-by: Chew, Chiau Ee <chiau.ee.chew at intel.com>
Signed-off-by: Sreeju Selvaraj <sreeju.armughanx.selvaraj at intel.com>
---
drivers/pinctrl/pinctrl-baytrail.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/drivers/pinctrl/pinctrl-baytrail.c b/drivers/pinctrl/pinctrl-baytrail.c
index 2832576..c0ef8e2 100644
--- a/drivers/pinctrl/pinctrl-baytrail.c
+++ b/drivers/pinctrl/pinctrl-baytrail.c
@@ -149,10 +149,27 @@ static void __iomem *byt_gpio_reg(struct gpio_chip *chip, unsigned offset,
static int byt_gpio_request(struct gpio_chip *chip, unsigned offset)
{
struct byt_gpio *vg = to_byt_gpio(chip);
+ void __iomem *reg = byt_gpio_reg(chip, offset, BYT_CONF0_REG);
+ u32 value;
+
+ value = readl(reg) & BYT_PIN_MUX;
+ if ((!strcmp(chip->label, "byt_gpio.2") ||
+ !strcmp(chip->label, "INT33B2:02")) &&
+ offset >= 11 && offset <= 21) {
+ if (value != 1)
+ goto not_gpio;
+ } else {
+ if (value)
+ goto not_gpio;
+ }
pm_runtime_get(&vg->pdev->dev);
return 0;
+
+not_gpio:
+ dev_err(&vg->pdev->dev, "GPIO %d is not a GPIO pin.\n", (int)offset);
+ return -EINVAL;
}
static void byt_gpio_free(struct gpio_chip *chip, unsigned offset)
--
1.7.10.4
More information about the linux-yocto
mailing list