Commit dcdc3018 authored by Aaron Lu's avatar Aaron Lu Committed by Linus Walleij

gpio: crystalcove: support virtual GPIO

The virtual GPIO introduced in ACPI table of Baytrail-T based system is
used to solve a problem under Windows. We do not have such problems
under Linux so we do not actually need them. But we have to tell GPIO
library that the Crystal Cove GPIO chip has this many GPIO pins or the
common GPIO handler will refuse any access to those high number GPIO
pins, which will resulted in a failure evaluation of every ACPI control
method that is used to turn on/off power resource and/or report sensor
temperatures.
Signed-off-by: default avatarAaron Lu <aaron.lu@intel.com>
Reviewed-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
[changed vgpio number from 0x5e to 94]
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent e4742d57
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <linux/mfd/intel_soc_pmic.h> #include <linux/mfd/intel_soc_pmic.h>
#define CRYSTALCOVE_GPIO_NUM 16 #define CRYSTALCOVE_GPIO_NUM 16
#define CRYSTALCOVE_VGPIO_NUM 94
#define UPDATE_IRQ_TYPE BIT(0) #define UPDATE_IRQ_TYPE BIT(0)
#define UPDATE_IRQ_MASK BIT(1) #define UPDATE_IRQ_MASK BIT(1)
...@@ -130,6 +131,9 @@ static int crystalcove_gpio_dir_in(struct gpio_chip *chip, unsigned gpio) ...@@ -130,6 +131,9 @@ static int crystalcove_gpio_dir_in(struct gpio_chip *chip, unsigned gpio)
{ {
struct crystalcove_gpio *cg = to_cg(chip); struct crystalcove_gpio *cg = to_cg(chip);
if (gpio > CRYSTALCOVE_VGPIO_NUM)
return 0;
return regmap_write(cg->regmap, to_reg(gpio, CTRL_OUT), return regmap_write(cg->regmap, to_reg(gpio, CTRL_OUT),
CTLO_INPUT_SET); CTLO_INPUT_SET);
} }
...@@ -139,6 +143,9 @@ static int crystalcove_gpio_dir_out(struct gpio_chip *chip, unsigned gpio, ...@@ -139,6 +143,9 @@ static int crystalcove_gpio_dir_out(struct gpio_chip *chip, unsigned gpio,
{ {
struct crystalcove_gpio *cg = to_cg(chip); struct crystalcove_gpio *cg = to_cg(chip);
if (gpio > CRYSTALCOVE_VGPIO_NUM)
return 0;
return regmap_write(cg->regmap, to_reg(gpio, CTRL_OUT), return regmap_write(cg->regmap, to_reg(gpio, CTRL_OUT),
CTLO_OUTPUT_SET | value); CTLO_OUTPUT_SET | value);
} }
...@@ -149,6 +156,9 @@ static int crystalcove_gpio_get(struct gpio_chip *chip, unsigned gpio) ...@@ -149,6 +156,9 @@ static int crystalcove_gpio_get(struct gpio_chip *chip, unsigned gpio)
int ret; int ret;
unsigned int val; unsigned int val;
if (gpio > CRYSTALCOVE_VGPIO_NUM)
return 0;
ret = regmap_read(cg->regmap, to_reg(gpio, CTRL_IN), &val); ret = regmap_read(cg->regmap, to_reg(gpio, CTRL_IN), &val);
if (ret) if (ret)
return ret; return ret;
...@@ -161,6 +171,9 @@ static void crystalcove_gpio_set(struct gpio_chip *chip, ...@@ -161,6 +171,9 @@ static void crystalcove_gpio_set(struct gpio_chip *chip,
{ {
struct crystalcove_gpio *cg = to_cg(chip); struct crystalcove_gpio *cg = to_cg(chip);
if (gpio > CRYSTALCOVE_VGPIO_NUM)
return;
if (value) if (value)
regmap_update_bits(cg->regmap, to_reg(gpio, CTRL_OUT), 1, 1); regmap_update_bits(cg->regmap, to_reg(gpio, CTRL_OUT), 1, 1);
else else
...@@ -256,7 +269,7 @@ static irqreturn_t crystalcove_gpio_irq_handler(int irq, void *data) ...@@ -256,7 +269,7 @@ static irqreturn_t crystalcove_gpio_irq_handler(int irq, void *data)
pending = p0 | p1 << 8; pending = p0 | p1 << 8;
for (gpio = 0; gpio < cg->chip.ngpio; gpio++) { for (gpio = 0; gpio < CRYSTALCOVE_GPIO_NUM; gpio++) {
if (pending & BIT(gpio)) { if (pending & BIT(gpio)) {
virq = irq_find_mapping(cg->chip.irqdomain, gpio); virq = irq_find_mapping(cg->chip.irqdomain, gpio);
generic_handle_irq(virq); generic_handle_irq(virq);
...@@ -273,7 +286,7 @@ static void crystalcove_gpio_dbg_show(struct seq_file *s, ...@@ -273,7 +286,7 @@ static void crystalcove_gpio_dbg_show(struct seq_file *s,
int gpio, offset; int gpio, offset;
unsigned int ctlo, ctli, mirqs0, mirqsx, irq; unsigned int ctlo, ctli, mirqs0, mirqsx, irq;
for (gpio = 0; gpio < cg->chip.ngpio; gpio++) { for (gpio = 0; gpio < CRYSTALCOVE_GPIO_NUM; gpio++) {
regmap_read(cg->regmap, to_reg(gpio, CTRL_OUT), &ctlo); regmap_read(cg->regmap, to_reg(gpio, CTRL_OUT), &ctlo);
regmap_read(cg->regmap, to_reg(gpio, CTRL_IN), &ctli); regmap_read(cg->regmap, to_reg(gpio, CTRL_IN), &ctli);
regmap_read(cg->regmap, gpio < 8 ? MGPIO0IRQS0 : MGPIO1IRQS0, regmap_read(cg->regmap, gpio < 8 ? MGPIO0IRQS0 : MGPIO1IRQS0,
...@@ -320,7 +333,7 @@ static int crystalcove_gpio_probe(struct platform_device *pdev) ...@@ -320,7 +333,7 @@ static int crystalcove_gpio_probe(struct platform_device *pdev)
cg->chip.get = crystalcove_gpio_get; cg->chip.get = crystalcove_gpio_get;
cg->chip.set = crystalcove_gpio_set; cg->chip.set = crystalcove_gpio_set;
cg->chip.base = -1; cg->chip.base = -1;
cg->chip.ngpio = CRYSTALCOVE_GPIO_NUM; cg->chip.ngpio = CRYSTALCOVE_VGPIO_NUM;
cg->chip.can_sleep = true; cg->chip.can_sleep = true;
cg->chip.dev = dev; cg->chip.dev = dev;
cg->chip.dbg_show = crystalcove_gpio_dbg_show; cg->chip.dbg_show = crystalcove_gpio_dbg_show;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment