aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/gpio-ich.c2
-rw-r--r--drivers/gpio/gpio-stmpe.c15
-rw-r--r--drivers/gpio/gpio-tegra.c21
-rw-r--r--drivers/gpio/gpiolib-of.c5
4 files changed, 33 insertions, 10 deletions
diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
index f9dbd503fc40..de3c317bd3e2 100644
--- a/drivers/gpio/gpio-ich.c
+++ b/drivers/gpio/gpio-ich.c
@@ -214,7 +214,7 @@ static int ichx_gpio_request(struct gpio_chip *chip, unsigned nr)
214 * If it can't be trusted, assume that the pin can be used as a GPIO. 214 * If it can't be trusted, assume that the pin can be used as a GPIO.
215 */ 215 */
216 if (ichx_priv.desc->use_sel_ignore[nr / 32] & (1 << (nr & 0x1f))) 216 if (ichx_priv.desc->use_sel_ignore[nr / 32] & (1 << (nr & 0x1f)))
217 return 1; 217 return 0;
218 218
219 return ichx_read_bit(GPIO_USE_SEL, nr) ? 0 : -ENODEV; 219 return ichx_read_bit(GPIO_USE_SEL, nr) ? 0 : -ENODEV;
220} 220}
diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c
index 770476a9da87..3ce5bc38ac31 100644
--- a/drivers/gpio/gpio-stmpe.c
+++ b/drivers/gpio/gpio-stmpe.c
@@ -307,11 +307,15 @@ static const struct irq_domain_ops stmpe_gpio_irq_simple_ops = {
307 .xlate = irq_domain_xlate_twocell, 307 .xlate = irq_domain_xlate_twocell,
308}; 308};
309 309
310static int stmpe_gpio_irq_init(struct stmpe_gpio *stmpe_gpio) 310static int stmpe_gpio_irq_init(struct stmpe_gpio *stmpe_gpio,
311 struct device_node *np)
311{ 312{
312 int base = stmpe_gpio->irq_base; 313 int base = 0;
313 314
314 stmpe_gpio->domain = irq_domain_add_simple(NULL, 315 if (!np)
316 base = stmpe_gpio->irq_base;
317
318 stmpe_gpio->domain = irq_domain_add_simple(np,
315 stmpe_gpio->chip.ngpio, base, 319 stmpe_gpio->chip.ngpio, base,
316 &stmpe_gpio_irq_simple_ops, stmpe_gpio); 320 &stmpe_gpio_irq_simple_ops, stmpe_gpio);
317 if (!stmpe_gpio->domain) { 321 if (!stmpe_gpio->domain) {
@@ -346,6 +350,9 @@ static int stmpe_gpio_probe(struct platform_device *pdev)
346 stmpe_gpio->chip = template_chip; 350 stmpe_gpio->chip = template_chip;
347 stmpe_gpio->chip.ngpio = stmpe->num_gpios; 351 stmpe_gpio->chip.ngpio = stmpe->num_gpios;
348 stmpe_gpio->chip.dev = &pdev->dev; 352 stmpe_gpio->chip.dev = &pdev->dev;
353#ifdef CONFIG_OF
354 stmpe_gpio->chip.of_node = np;
355#endif
349 stmpe_gpio->chip.base = pdata ? pdata->gpio_base : -1; 356 stmpe_gpio->chip.base = pdata ? pdata->gpio_base : -1;
350 357
351 if (pdata) 358 if (pdata)
@@ -366,7 +373,7 @@ static int stmpe_gpio_probe(struct platform_device *pdev)
366 goto out_free; 373 goto out_free;
367 374
368 if (irq >= 0) { 375 if (irq >= 0) {
369 ret = stmpe_gpio_irq_init(stmpe_gpio); 376 ret = stmpe_gpio_irq_init(stmpe_gpio, np);
370 if (ret) 377 if (ret)
371 goto out_disable; 378 goto out_disable;
372 379
diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c
index 8e2155548888..dde0656ea951 100644
--- a/drivers/gpio/gpio-tegra.c
+++ b/drivers/gpio/gpio-tegra.c
@@ -71,6 +71,7 @@ struct tegra_gpio_bank {
71 u32 oe[4]; 71 u32 oe[4];
72 u32 int_enb[4]; 72 u32 int_enb[4];
73 u32 int_lvl[4]; 73 u32 int_lvl[4];
74 u32 wake_enb[4];
74#endif 75#endif
75}; 76};
76 77
@@ -332,15 +333,31 @@ static int tegra_gpio_suspend(struct device *dev)
332 bank->oe[p] = tegra_gpio_readl(GPIO_OE(gpio)); 333 bank->oe[p] = tegra_gpio_readl(GPIO_OE(gpio));
333 bank->int_enb[p] = tegra_gpio_readl(GPIO_INT_ENB(gpio)); 334 bank->int_enb[p] = tegra_gpio_readl(GPIO_INT_ENB(gpio));
334 bank->int_lvl[p] = tegra_gpio_readl(GPIO_INT_LVL(gpio)); 335 bank->int_lvl[p] = tegra_gpio_readl(GPIO_INT_LVL(gpio));
336
337 /* Enable gpio irq for wake up source */
338 tegra_gpio_writel(bank->wake_enb[p],
339 GPIO_INT_ENB(gpio));
335 } 340 }
336 } 341 }
337 local_irq_restore(flags); 342 local_irq_restore(flags);
338 return 0; 343 return 0;
339} 344}
340 345
341static int tegra_gpio_wake_enable(struct irq_data *d, unsigned int enable) 346static int tegra_gpio_irq_set_wake(struct irq_data *d, unsigned int enable)
342{ 347{
343 struct tegra_gpio_bank *bank = irq_data_get_irq_chip_data(d); 348 struct tegra_gpio_bank *bank = irq_data_get_irq_chip_data(d);
349 int gpio = d->hwirq;
350 u32 port, bit, mask;
351
352 port = GPIO_PORT(gpio);
353 bit = GPIO_BIT(gpio);
354 mask = BIT(bit);
355
356 if (enable)
357 bank->wake_enb[port] |= mask;
358 else
359 bank->wake_enb[port] &= ~mask;
360
344 return irq_set_irq_wake(bank->irq, enable); 361 return irq_set_irq_wake(bank->irq, enable);
345} 362}
346#endif 363#endif
@@ -352,7 +369,7 @@ static struct irq_chip tegra_gpio_irq_chip = {
352 .irq_unmask = tegra_gpio_irq_unmask, 369 .irq_unmask = tegra_gpio_irq_unmask,
353 .irq_set_type = tegra_gpio_irq_set_type, 370 .irq_set_type = tegra_gpio_irq_set_type,
354#ifdef CONFIG_PM_SLEEP 371#ifdef CONFIG_PM_SLEEP
355 .irq_set_wake = tegra_gpio_wake_enable, 372 .irq_set_wake = tegra_gpio_irq_set_wake,
356#endif 373#endif
357}; 374};
358 375
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index a71a54a3e3f7..5150df6cba08 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -193,7 +193,7 @@ static void of_gpiochip_add_pin_range(struct gpio_chip *chip)
193 if (!np) 193 if (!np)
194 return; 194 return;
195 195
196 do { 196 for (;; index++) {
197 ret = of_parse_phandle_with_args(np, "gpio-ranges", 197 ret = of_parse_phandle_with_args(np, "gpio-ranges",
198 "#gpio-range-cells", index, &pinspec); 198 "#gpio-range-cells", index, &pinspec);
199 if (ret) 199 if (ret)
@@ -222,8 +222,7 @@ static void of_gpiochip_add_pin_range(struct gpio_chip *chip)
222 222
223 if (ret) 223 if (ret)
224 break; 224 break;
225 225 }
226 } while (index++);
227} 226}
228 227
229#else 228#else