diff options
Diffstat (limited to 'drivers/gpio')
-rw-r--r-- | drivers/gpio/devres.c | 2 | ||||
-rw-r--r-- | drivers/gpio/gpio-bt8xx.c | 3 | ||||
-rw-r--r-- | drivers/gpio/gpio-lynxpoint.c | 18 | ||||
-rw-r--r-- | drivers/gpio/gpio-zynq.c | 36 | ||||
-rw-r--r-- | drivers/gpio/gpiolib-acpi.c | 5 | ||||
-rw-r--r-- | drivers/gpio/gpiolib-of.c | 4 | ||||
-rw-r--r-- | drivers/gpio/gpiolib.c | 4 |
7 files changed, 54 insertions, 18 deletions
diff --git a/drivers/gpio/devres.c b/drivers/gpio/devres.c index 41b2f40578d5..954b9f6b0ef8 100644 --- a/drivers/gpio/devres.c +++ b/drivers/gpio/devres.c | |||
@@ -90,7 +90,7 @@ struct gpio_desc *__must_check __devm_gpiod_get_index(struct device *dev, | |||
90 | struct gpio_desc **dr; | 90 | struct gpio_desc **dr; |
91 | struct gpio_desc *desc; | 91 | struct gpio_desc *desc; |
92 | 92 | ||
93 | dr = devres_alloc(devm_gpiod_release, sizeof(struct gpiod_desc *), | 93 | dr = devres_alloc(devm_gpiod_release, sizeof(struct gpio_desc *), |
94 | GFP_KERNEL); | 94 | GFP_KERNEL); |
95 | if (!dr) | 95 | if (!dr) |
96 | return ERR_PTR(-ENOMEM); | 96 | return ERR_PTR(-ENOMEM); |
diff --git a/drivers/gpio/gpio-bt8xx.c b/drivers/gpio/gpio-bt8xx.c index 6557147d9331..7e4c43c18960 100644 --- a/drivers/gpio/gpio-bt8xx.c +++ b/drivers/gpio/gpio-bt8xx.c | |||
@@ -241,9 +241,6 @@ static void bt8xxgpio_remove(struct pci_dev *pdev) | |||
241 | bgwrite(~0x0, BT848_INT_STAT); | 241 | bgwrite(~0x0, BT848_INT_STAT); |
242 | bgwrite(0x0, BT848_GPIO_OUT_EN); | 242 | bgwrite(0x0, BT848_GPIO_OUT_EN); |
243 | 243 | ||
244 | iounmap(bg->mmio); | ||
245 | release_mem_region(pci_resource_start(pdev, 0), | ||
246 | pci_resource_len(pdev, 0)); | ||
247 | pci_disable_device(pdev); | 244 | pci_disable_device(pdev); |
248 | } | 245 | } |
249 | 246 | ||
diff --git a/drivers/gpio/gpio-lynxpoint.c b/drivers/gpio/gpio-lynxpoint.c index ff9eb911b5e4..fa945ec9ccff 100644 --- a/drivers/gpio/gpio-lynxpoint.c +++ b/drivers/gpio/gpio-lynxpoint.c | |||
@@ -407,9 +407,27 @@ static int lp_gpio_runtime_resume(struct device *dev) | |||
407 | return 0; | 407 | return 0; |
408 | } | 408 | } |
409 | 409 | ||
410 | static int lp_gpio_resume(struct device *dev) | ||
411 | { | ||
412 | struct platform_device *pdev = to_platform_device(dev); | ||
413 | struct lp_gpio *lg = platform_get_drvdata(pdev); | ||
414 | unsigned long reg; | ||
415 | int i; | ||
416 | |||
417 | /* on some hardware suspend clears input sensing, re-enable it here */ | ||
418 | for (i = 0; i < lg->chip.ngpio; i++) { | ||
419 | if (gpiochip_is_requested(&lg->chip, i) != NULL) { | ||
420 | reg = lp_gpio_reg(&lg->chip, i, LP_CONFIG2); | ||
421 | outl(inl(reg) & ~GPINDIS_BIT, reg); | ||
422 | } | ||
423 | } | ||
424 | return 0; | ||
425 | } | ||
426 | |||
410 | static const struct dev_pm_ops lp_gpio_pm_ops = { | 427 | static const struct dev_pm_ops lp_gpio_pm_ops = { |
411 | .runtime_suspend = lp_gpio_runtime_suspend, | 428 | .runtime_suspend = lp_gpio_runtime_suspend, |
412 | .runtime_resume = lp_gpio_runtime_resume, | 429 | .runtime_resume = lp_gpio_runtime_resume, |
430 | .resume = lp_gpio_resume, | ||
413 | }; | 431 | }; |
414 | 432 | ||
415 | static const struct acpi_device_id lynxpoint_gpio_acpi_match[] = { | 433 | static const struct acpi_device_id lynxpoint_gpio_acpi_match[] = { |
diff --git a/drivers/gpio/gpio-zynq.c b/drivers/gpio/gpio-zynq.c index c3145f91fda3..31ad5df5dbc9 100644 --- a/drivers/gpio/gpio-zynq.c +++ b/drivers/gpio/gpio-zynq.c | |||
@@ -95,6 +95,9 @@ struct zynq_gpio { | |||
95 | struct clk *clk; | 95 | struct clk *clk; |
96 | }; | 96 | }; |
97 | 97 | ||
98 | static struct irq_chip zynq_gpio_level_irqchip; | ||
99 | static struct irq_chip zynq_gpio_edge_irqchip; | ||
100 | |||
98 | /** | 101 | /** |
99 | * zynq_gpio_get_bank_pin - Get the bank number and pin number within that bank | 102 | * zynq_gpio_get_bank_pin - Get the bank number and pin number within that bank |
100 | * for a given pin in the GPIO device | 103 | * for a given pin in the GPIO device |
@@ -410,6 +413,15 @@ static int zynq_gpio_set_irq_type(struct irq_data *irq_data, unsigned int type) | |||
410 | gpio->base_addr + ZYNQ_GPIO_INTPOL_OFFSET(bank_num)); | 413 | gpio->base_addr + ZYNQ_GPIO_INTPOL_OFFSET(bank_num)); |
411 | writel_relaxed(int_any, | 414 | writel_relaxed(int_any, |
412 | gpio->base_addr + ZYNQ_GPIO_INTANY_OFFSET(bank_num)); | 415 | gpio->base_addr + ZYNQ_GPIO_INTANY_OFFSET(bank_num)); |
416 | |||
417 | if (type & IRQ_TYPE_LEVEL_MASK) { | ||
418 | __irq_set_chip_handler_name_locked(irq_data->irq, | ||
419 | &zynq_gpio_level_irqchip, handle_fasteoi_irq, NULL); | ||
420 | } else { | ||
421 | __irq_set_chip_handler_name_locked(irq_data->irq, | ||
422 | &zynq_gpio_edge_irqchip, handle_level_irq, NULL); | ||
423 | } | ||
424 | |||
413 | return 0; | 425 | return 0; |
414 | } | 426 | } |
415 | 427 | ||
@@ -424,9 +436,21 @@ static int zynq_gpio_set_wake(struct irq_data *data, unsigned int on) | |||
424 | } | 436 | } |
425 | 437 | ||
426 | /* irq chip descriptor */ | 438 | /* irq chip descriptor */ |
427 | static struct irq_chip zynq_gpio_irqchip = { | 439 | static struct irq_chip zynq_gpio_level_irqchip = { |
428 | .name = DRIVER_NAME, | 440 | .name = DRIVER_NAME, |
429 | .irq_enable = zynq_gpio_irq_enable, | 441 | .irq_enable = zynq_gpio_irq_enable, |
442 | .irq_eoi = zynq_gpio_irq_ack, | ||
443 | .irq_mask = zynq_gpio_irq_mask, | ||
444 | .irq_unmask = zynq_gpio_irq_unmask, | ||
445 | .irq_set_type = zynq_gpio_set_irq_type, | ||
446 | .irq_set_wake = zynq_gpio_set_wake, | ||
447 | .flags = IRQCHIP_EOI_THREADED | IRQCHIP_EOI_IF_HANDLED, | ||
448 | }; | ||
449 | |||
450 | static struct irq_chip zynq_gpio_edge_irqchip = { | ||
451 | .name = DRIVER_NAME, | ||
452 | .irq_enable = zynq_gpio_irq_enable, | ||
453 | .irq_ack = zynq_gpio_irq_ack, | ||
430 | .irq_mask = zynq_gpio_irq_mask, | 454 | .irq_mask = zynq_gpio_irq_mask, |
431 | .irq_unmask = zynq_gpio_irq_unmask, | 455 | .irq_unmask = zynq_gpio_irq_unmask, |
432 | .irq_set_type = zynq_gpio_set_irq_type, | 456 | .irq_set_type = zynq_gpio_set_irq_type, |
@@ -469,10 +493,6 @@ static void zynq_gpio_irqhandler(unsigned int irq, struct irq_desc *desc) | |||
469 | offset); | 493 | offset); |
470 | generic_handle_irq(gpio_irq); | 494 | generic_handle_irq(gpio_irq); |
471 | } | 495 | } |
472 | |||
473 | /* clear IRQ in HW */ | ||
474 | writel_relaxed(int_sts, gpio->base_addr + | ||
475 | ZYNQ_GPIO_INTSTS_OFFSET(bank_num)); | ||
476 | } | 496 | } |
477 | } | 497 | } |
478 | 498 | ||
@@ -610,14 +630,14 @@ static int zynq_gpio_probe(struct platform_device *pdev) | |||
610 | writel_relaxed(ZYNQ_GPIO_IXR_DISABLE_ALL, gpio->base_addr + | 630 | writel_relaxed(ZYNQ_GPIO_IXR_DISABLE_ALL, gpio->base_addr + |
611 | ZYNQ_GPIO_INTDIS_OFFSET(bank_num)); | 631 | ZYNQ_GPIO_INTDIS_OFFSET(bank_num)); |
612 | 632 | ||
613 | ret = gpiochip_irqchip_add(chip, &zynq_gpio_irqchip, 0, | 633 | ret = gpiochip_irqchip_add(chip, &zynq_gpio_edge_irqchip, 0, |
614 | handle_simple_irq, IRQ_TYPE_NONE); | 634 | handle_level_irq, IRQ_TYPE_NONE); |
615 | if (ret) { | 635 | if (ret) { |
616 | dev_err(&pdev->dev, "Failed to add irq chip\n"); | 636 | dev_err(&pdev->dev, "Failed to add irq chip\n"); |
617 | goto err_rm_gpiochip; | 637 | goto err_rm_gpiochip; |
618 | } | 638 | } |
619 | 639 | ||
620 | gpiochip_set_chained_irqchip(chip, &zynq_gpio_irqchip, irq, | 640 | gpiochip_set_chained_irqchip(chip, &zynq_gpio_edge_irqchip, irq, |
621 | zynq_gpio_irqhandler); | 641 | zynq_gpio_irqhandler); |
622 | 642 | ||
623 | pm_runtime_set_active(&pdev->dev); | 643 | pm_runtime_set_active(&pdev->dev); |
diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index d62eaaa75397..687476fb39e3 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c | |||
@@ -377,8 +377,10 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address, | |||
377 | struct gpio_chip *chip = achip->chip; | 377 | struct gpio_chip *chip = achip->chip; |
378 | struct acpi_resource_gpio *agpio; | 378 | struct acpi_resource_gpio *agpio; |
379 | struct acpi_resource *ares; | 379 | struct acpi_resource *ares; |
380 | int pin_index = (int)address; | ||
380 | acpi_status status; | 381 | acpi_status status; |
381 | bool pull_up; | 382 | bool pull_up; |
383 | int length; | ||
382 | int i; | 384 | int i; |
383 | 385 | ||
384 | status = acpi_buffer_to_resource(achip->conn_info.connection, | 386 | status = acpi_buffer_to_resource(achip->conn_info.connection, |
@@ -400,7 +402,8 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address, | |||
400 | return AE_BAD_PARAMETER; | 402 | return AE_BAD_PARAMETER; |
401 | } | 403 | } |
402 | 404 | ||
403 | for (i = 0; i < agpio->pin_table_length; i++) { | 405 | length = min(agpio->pin_table_length, (u16)(pin_index + bits)); |
406 | for (i = pin_index; i < length; ++i) { | ||
404 | unsigned pin = agpio->pin_table[i]; | 407 | unsigned pin = agpio->pin_table[i]; |
405 | struct acpi_gpio_connection *conn; | 408 | struct acpi_gpio_connection *conn; |
406 | struct gpio_desc *desc; | 409 | struct gpio_desc *desc; |
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 7cfdc2278905..604dbe60bdee 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c | |||
@@ -307,7 +307,5 @@ void of_gpiochip_add(struct gpio_chip *chip) | |||
307 | void of_gpiochip_remove(struct gpio_chip *chip) | 307 | void of_gpiochip_remove(struct gpio_chip *chip) |
308 | { | 308 | { |
309 | gpiochip_remove_pin_ranges(chip); | 309 | gpiochip_remove_pin_ranges(chip); |
310 | 310 | of_node_put(chip->of_node); | |
311 | if (chip->of_node) | ||
312 | of_node_put(chip->of_node); | ||
313 | } | 311 | } |
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 15cc0bb65dda..c68d037de656 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c | |||
@@ -413,12 +413,12 @@ void gpiochip_set_chained_irqchip(struct gpio_chip *gpiochip, | |||
413 | return; | 413 | return; |
414 | } | 414 | } |
415 | 415 | ||
416 | irq_set_chained_handler(parent_irq, parent_handler); | ||
417 | /* | 416 | /* |
418 | * The parent irqchip is already using the chip_data for this | 417 | * The parent irqchip is already using the chip_data for this |
419 | * irqchip, so our callbacks simply use the handler_data. | 418 | * irqchip, so our callbacks simply use the handler_data. |
420 | */ | 419 | */ |
421 | irq_set_handler_data(parent_irq, gpiochip); | 420 | irq_set_handler_data(parent_irq, gpiochip); |
421 | irq_set_chained_handler(parent_irq, parent_handler); | ||
422 | } | 422 | } |
423 | EXPORT_SYMBOL_GPL(gpiochip_set_chained_irqchip); | 423 | EXPORT_SYMBOL_GPL(gpiochip_set_chained_irqchip); |
424 | 424 | ||
@@ -1674,7 +1674,7 @@ struct gpio_desc *__must_check __gpiod_get_index(struct device *dev, | |||
1674 | set_bit(FLAG_OPEN_SOURCE, &desc->flags); | 1674 | set_bit(FLAG_OPEN_SOURCE, &desc->flags); |
1675 | 1675 | ||
1676 | /* No particular flag request, return here... */ | 1676 | /* No particular flag request, return here... */ |
1677 | if (flags & GPIOD_FLAGS_BIT_DIR_SET) | 1677 | if (!(flags & GPIOD_FLAGS_BIT_DIR_SET)) |
1678 | return desc; | 1678 | return desc; |
1679 | 1679 | ||
1680 | /* Process flags */ | 1680 | /* Process flags */ |