From: "Chew, Kean Ho" <[email protected]> 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 <[email protected]> Signed-off-by: Chew, Chiau Ee <[email protected]> Signed-off-by: Sreeju Selvaraj <[email protected]> --- 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 -- _______________________________________________ linux-yocto mailing list [email protected] https://lists.yoctoproject.org/listinfo/linux-yocto
