Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'gpio-updates-for-v5.9-part1' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux into devel

gpio updates for v5.9

- use kobj_to_dev() in sysfs interface
- kerneldoc and documentation fixes
- relax the interrupt flags in gpio-mpc8xxx
- support new model in gpio-pca953x
- remove a redundant check from gpio-max732x
- support a new platform in gpio-zynq (+ some minor fixes)
- don't depend on GPIOLIB when already inside the "if GPIOLIB" in Kconfig
- support PM ops for suspend in gpio-omap
- minor tweaks in gpiolib

+106 -15
+1
Documentation/devicetree/bindings/gpio/gpio-pca953x.txt
··· 19 19 nxp,pca9698 20 20 nxp,pcal6416 21 21 nxp,pcal6524 22 + nxp,pcal9535 22 23 nxp,pcal9555a 23 24 maxim,max7310 24 25 maxim,max7312
+3 -1
Documentation/devicetree/bindings/gpio/gpio-zynq.txt
··· 6 6 - First cell is the GPIO line number 7 7 - Second cell is used to specify optional 8 8 parameters (unused) 9 - - compatible : Should be "xlnx,zynq-gpio-1.0" or "xlnx,zynqmp-gpio-1.0" 9 + - compatible : Should be "xlnx,zynq-gpio-1.0" or 10 + "xlnx,zynqmp-gpio-1.0" or "xlnx,versal-gpio-1.0 11 + or "xlnx,pmc-gpio-1.0 10 12 - clocks : Clock specifier (see clock bindings for details) 11 13 - gpio-controller : Marks the device node as a GPIO controller. 12 14 - interrupts : Interrupt specifier (see interrupt bindings for
+2 -2
drivers/gpio/Kconfig
··· 410 410 411 411 config GPIO_OCTEON 412 412 tristate "Cavium OCTEON GPIO" 413 - depends on GPIOLIB && CAVIUM_OCTEON_SOC 413 + depends on CAVIUM_OCTEON_SOC 414 414 default y 415 415 help 416 416 Say yes here to support the on-chip GPIO lines on the OCTEON ··· 1117 1117 1118 1118 config HTC_EGPIO 1119 1119 bool "HTC EGPIO support" 1120 - depends on GPIOLIB && ARM 1120 + depends on ARM 1121 1121 help 1122 1122 This driver supports the CPLD egpio chip present on 1123 1123 several HTC phones. It provides basic support for input
+1 -1
drivers/gpio/TODO
··· 5 5 GPIO descriptors 6 6 7 7 Starting with commit 79a9becda894 the GPIO subsystem embarked on a journey 8 - to move away from the global GPIO numberspace and toward a decriptor-based 8 + to move away from the global GPIO numberspace and toward a descriptor-based 9 9 approach. This means that GPIO consumers, drivers and machine descriptions 10 10 ideally have no use or idea of the global GPIO numberspace that has/was 11 11 used in the inception of the GPIO subsystem.
+1 -1
drivers/gpio/gpio-mpc8xxx.c
··· 417 417 418 418 ret = devm_request_irq(&pdev->dev, mpc8xxx_gc->irqn, 419 419 mpc8xxx_gpio_irq_cascade, 420 - IRQF_NO_THREAD | IRQF_SHARED, "gpio-cascade", 420 + IRQF_SHARED, "gpio-cascade", 421 421 mpc8xxx_gc); 422 422 if (ret) { 423 423 dev_err(&pdev->dev, "%s: failed to devm_request_irq(%d), ret = %d\n",
+26
drivers/gpio/gpio-omap.c
··· 60 60 struct clk *dbck; 61 61 struct notifier_block nb; 62 62 unsigned int is_suspended:1; 63 + unsigned int needs_resume:1; 63 64 u32 mod_usage; 64 65 u32 irq_usage; 65 66 u32 dbck_enable_mask; ··· 1505 1504 return 0; 1506 1505 } 1507 1506 1507 + static int omap_gpio_suspend(struct device *dev) 1508 + { 1509 + struct gpio_bank *bank = dev_get_drvdata(dev); 1510 + 1511 + if (bank->is_suspended) 1512 + return 0; 1513 + 1514 + bank->needs_resume = 1; 1515 + 1516 + return omap_gpio_runtime_suspend(dev); 1517 + } 1518 + 1519 + static int omap_gpio_resume(struct device *dev) 1520 + { 1521 + struct gpio_bank *bank = dev_get_drvdata(dev); 1522 + 1523 + if (!bank->needs_resume) 1524 + return 0; 1525 + 1526 + bank->needs_resume = 0; 1527 + 1528 + return omap_gpio_runtime_resume(dev); 1529 + } 1530 + 1508 1531 static const struct dev_pm_ops gpio_pm_ops = { 1509 1532 SET_RUNTIME_PM_OPS(omap_gpio_runtime_suspend, omap_gpio_runtime_resume, 1510 1533 NULL) 1534 + SET_LATE_SYSTEM_SLEEP_PM_OPS(omap_gpio_suspend, omap_gpio_resume) 1511 1535 }; 1512 1536 1513 1537 static struct platform_driver omap_gpio_driver = {
+2
drivers/gpio/gpio-pca953x.c
··· 89 89 90 90 { "pcal6416", 16 | PCA953X_TYPE | PCA_LATCH_INT, }, 91 91 { "pcal6524", 24 | PCA953X_TYPE | PCA_LATCH_INT, }, 92 + { "pcal9535", 16 | PCA953X_TYPE | PCA_LATCH_INT, }, 92 93 { "pcal9555a", 16 | PCA953X_TYPE | PCA_LATCH_INT, }, 93 94 94 95 { "max7310", 8 | PCA953X_TYPE, }, ··· 1146 1145 1147 1146 { .compatible = "nxp,pcal6416", .data = OF_953X(16, PCA_LATCH_INT), }, 1148 1147 { .compatible = "nxp,pcal6524", .data = OF_953X(24, PCA_LATCH_INT), }, 1148 + { .compatible = "nxp,pcal9535", .data = OF_953X(16, PCA_LATCH_INT), }, 1149 1149 { .compatible = "nxp,pcal9555a", .data = OF_953X(16, PCA_LATCH_INT), }, 1150 1150 1151 1151 { .compatible = "maxim,max7310", .data = OF_953X( 8, 0), },
+64 -2
drivers/gpio/gpio-zynq.c
··· 10 10 #include <linux/gpio/driver.h> 11 11 #include <linux/init.h> 12 12 #include <linux/interrupt.h> 13 + #include <linux/spinlock.h> 13 14 #include <linux/io.h> 14 15 #include <linux/module.h> 15 16 #include <linux/platform_device.h> ··· 22 21 /* Maximum banks */ 23 22 #define ZYNQ_GPIO_MAX_BANK 4 24 23 #define ZYNQMP_GPIO_MAX_BANK 6 24 + #define VERSAL_GPIO_MAX_BANK 4 25 + #define PMC_GPIO_MAX_BANK 5 26 + #define VERSAL_UNUSED_BANKS 2 25 27 26 28 #define ZYNQ_GPIO_BANK0_NGPIO 32 27 29 #define ZYNQ_GPIO_BANK1_NGPIO 22 ··· 99 95 /* set to differentiate zynq from zynqmp, 0=zynqmp, 1=zynq */ 100 96 #define ZYNQ_GPIO_QUIRK_IS_ZYNQ BIT(0) 101 97 #define GPIO_QUIRK_DATA_RO_BUG BIT(1) 98 + #define GPIO_QUIRK_VERSAL BIT(2) 102 99 103 100 struct gpio_regs { 104 101 u32 datamsw[ZYNQMP_GPIO_MAX_BANK]; ··· 121 116 * @irq: interrupt for the GPIO device 122 117 * @p_data: pointer to platform data 123 118 * @context: context registers 119 + * @dirlock: lock used for direction in/out synchronization 124 120 */ 125 121 struct zynq_gpio { 126 122 struct gpio_chip chip; ··· 130 124 int irq; 131 125 const struct zynq_platform_data *p_data; 132 126 struct gpio_regs context; 127 + spinlock_t dirlock; /* lock */ 133 128 }; 134 129 135 130 /** ··· 203 196 gpio->p_data->bank_min[bank]; 204 197 return; 205 198 } 199 + if (gpio->p_data->quirks & GPIO_QUIRK_VERSAL) 200 + bank = bank + VERSAL_UNUSED_BANKS; 206 201 } 207 202 208 203 /* default */ ··· 306 297 { 307 298 u32 reg; 308 299 unsigned int bank_num, bank_pin_num; 300 + unsigned long flags; 309 301 struct zynq_gpio *gpio = gpiochip_get_data(chip); 310 302 311 303 zynq_gpio_get_bank_pin(pin, &bank_num, &bank_pin_num, gpio); ··· 320 310 return -EINVAL; 321 311 322 312 /* clear the bit in direction mode reg to set the pin as input */ 313 + spin_lock_irqsave(&gpio->dirlock, flags); 323 314 reg = readl_relaxed(gpio->base_addr + ZYNQ_GPIO_DIRM_OFFSET(bank_num)); 324 315 reg &= ~BIT(bank_pin_num); 325 316 writel_relaxed(reg, gpio->base_addr + ZYNQ_GPIO_DIRM_OFFSET(bank_num)); 317 + spin_unlock_irqrestore(&gpio->dirlock, flags); 326 318 327 319 return 0; 328 320 } ··· 346 334 { 347 335 u32 reg; 348 336 unsigned int bank_num, bank_pin_num; 337 + unsigned long flags; 349 338 struct zynq_gpio *gpio = gpiochip_get_data(chip); 350 339 351 340 zynq_gpio_get_bank_pin(pin, &bank_num, &bank_pin_num, gpio); 352 341 353 342 /* set the GPIO pin as output */ 343 + spin_lock_irqsave(&gpio->dirlock, flags); 354 344 reg = readl_relaxed(gpio->base_addr + ZYNQ_GPIO_DIRM_OFFSET(bank_num)); 355 345 reg |= BIT(bank_pin_num); 356 346 writel_relaxed(reg, gpio->base_addr + ZYNQ_GPIO_DIRM_OFFSET(bank_num)); ··· 361 347 reg = readl_relaxed(gpio->base_addr + ZYNQ_GPIO_OUTEN_OFFSET(bank_num)); 362 348 reg |= BIT(bank_pin_num); 363 349 writel_relaxed(reg, gpio->base_addr + ZYNQ_GPIO_OUTEN_OFFSET(bank_num)); 350 + spin_unlock_irqrestore(&gpio->dirlock, flags); 364 351 365 352 /* set the state of the pin */ 366 353 zynq_gpio_set_value(chip, pin, state); ··· 662 647 int_enb = readl_relaxed(gpio->base_addr + 663 648 ZYNQ_GPIO_INTMASK_OFFSET(bank_num)); 664 649 zynq_gpio_handle_bank_irq(gpio, bank_num, int_sts & ~int_enb); 650 + if (gpio->p_data->quirks & GPIO_QUIRK_VERSAL) 651 + bank_num = bank_num + VERSAL_UNUSED_BANKS; 665 652 } 666 653 667 654 chained_irq_exit(irqchip, desc); ··· 693 676 gpio->context.int_any[bank_num] = 694 677 readl_relaxed(gpio->base_addr + 695 678 ZYNQ_GPIO_INTANY_OFFSET(bank_num)); 679 + if (gpio->p_data->quirks & GPIO_QUIRK_VERSAL) 680 + bank_num = bank_num + VERSAL_UNUSED_BANKS; 696 681 } 697 682 } 698 683 ··· 726 707 writel_relaxed(~(gpio->context.int_en[bank_num]), 727 708 gpio->base_addr + 728 709 ZYNQ_GPIO_INTEN_OFFSET(bank_num)); 710 + if (gpio->p_data->quirks & GPIO_QUIRK_VERSAL) 711 + bank_num = bank_num + VERSAL_UNUSED_BANKS; 729 712 } 730 713 } 731 714 ··· 735 714 { 736 715 struct zynq_gpio *gpio = dev_get_drvdata(dev); 737 716 struct irq_data *data = irq_get_irq_data(gpio->irq); 717 + 718 + if (!device_may_wakeup(dev)) 719 + disable_irq(gpio->irq); 738 720 739 721 if (!irqd_is_wakeup_set(data)) { 740 722 zynq_gpio_save_context(gpio); ··· 752 728 struct zynq_gpio *gpio = dev_get_drvdata(dev); 753 729 struct irq_data *data = irq_get_irq_data(gpio->irq); 754 730 int ret; 731 + 732 + if (!device_may_wakeup(dev)) 733 + enable_irq(gpio->irq); 755 734 756 735 if (!irqd_is_wakeup_set(data)) { 757 736 ret = pm_runtime_force_resume(dev); ··· 805 778 zynq_gpio_runtime_resume, NULL) 806 779 }; 807 780 781 + static const struct zynq_platform_data versal_gpio_def = { 782 + .label = "versal_gpio", 783 + .quirks = GPIO_QUIRK_VERSAL, 784 + .ngpio = 58, 785 + .max_bank = VERSAL_GPIO_MAX_BANK, 786 + .bank_min[0] = 0, 787 + .bank_max[0] = 25, /* 0 to 25 are connected to MIOs (26 pins) */ 788 + .bank_min[3] = 26, 789 + .bank_max[3] = 57, /* Bank 3 is connected to FMIOs (32 pins) */ 790 + }; 791 + 792 + static const struct zynq_platform_data pmc_gpio_def = { 793 + .label = "pmc_gpio", 794 + .ngpio = 116, 795 + .max_bank = PMC_GPIO_MAX_BANK, 796 + .bank_min[0] = 0, 797 + .bank_max[0] = 25, /* 0 to 25 are connected to MIOs (26 pins) */ 798 + .bank_min[1] = 26, 799 + .bank_max[1] = 51, /* Bank 1 are connected to MIOs (26 pins) */ 800 + .bank_min[3] = 52, 801 + .bank_max[3] = 83, /* Bank 3 is connected to EMIOs (32 pins) */ 802 + .bank_min[4] = 84, 803 + .bank_max[4] = 115, /* Bank 4 is connected to EMIOs (32 pins) */ 804 + }; 805 + 808 806 static const struct zynq_platform_data zynqmp_gpio_def = { 809 807 .label = "zynqmp_gpio", 810 808 .quirks = GPIO_QUIRK_DATA_RO_BUG, ··· 867 815 static const struct of_device_id zynq_gpio_of_match[] = { 868 816 { .compatible = "xlnx,zynq-gpio-1.0", .data = &zynq_gpio_def }, 869 817 { .compatible = "xlnx,zynqmp-gpio-1.0", .data = &zynqmp_gpio_def }, 818 + { .compatible = "xlnx,versal-gpio-1.0", .data = &versal_gpio_def }, 819 + { .compatible = "xlnx,pmc-gpio-1.0", .data = &pmc_gpio_def }, 870 820 { /* end of table */ } 871 821 }; 872 822 MODULE_DEVICE_TABLE(of, zynq_gpio_of_match); ··· 930 876 /* Retrieve GPIO clock */ 931 877 gpio->clk = devm_clk_get(&pdev->dev, NULL); 932 878 if (IS_ERR(gpio->clk)) { 933 - dev_err(&pdev->dev, "input clock not found.\n"); 879 + if (PTR_ERR(gpio->clk) != -EPROBE_DEFER) 880 + dev_err(&pdev->dev, "input clock not found.\n"); 934 881 return PTR_ERR(gpio->clk); 935 882 } 936 883 ret = clk_prepare_enable(gpio->clk); ··· 940 885 return ret; 941 886 } 942 887 888 + spin_lock_init(&gpio->dirlock); 889 + 943 890 pm_runtime_set_active(&pdev->dev); 944 891 pm_runtime_enable(&pdev->dev); 945 892 ret = pm_runtime_get_sync(&pdev->dev); ··· 949 892 goto err_pm_dis; 950 893 951 894 /* disable interrupts for all banks */ 952 - for (bank_num = 0; bank_num < gpio->p_data->max_bank; bank_num++) 895 + for (bank_num = 0; bank_num < gpio->p_data->max_bank; bank_num++) { 953 896 writel_relaxed(ZYNQ_GPIO_IXR_DISABLE_ALL, gpio->base_addr + 954 897 ZYNQ_GPIO_INTDIS_OFFSET(bank_num)); 898 + if (gpio->p_data->quirks & GPIO_QUIRK_VERSAL) 899 + bank_num = bank_num + VERSAL_UNUSED_BANKS; 900 + } 955 901 956 902 /* Set up the GPIO irqchip */ 957 903 girq = &chip->irq; ··· 979 919 goto err_pm_put; 980 920 } 981 921 922 + irq_set_status_flags(gpio->irq, IRQ_DISABLE_UNLAZY); 923 + device_init_wakeup(&pdev->dev, 1); 982 924 pm_runtime_put(&pdev->dev); 983 925 984 926 return 0;
+1 -1
drivers/gpio/gpiolib-sysfs.c
··· 365 365 static umode_t gpio_is_visible(struct kobject *kobj, struct attribute *attr, 366 366 int n) 367 367 { 368 - struct device *dev = container_of(kobj, struct device, kobj); 368 + struct device *dev = kobj_to_dev(kobj); 369 369 struct gpiod_data *data = dev_get_drvdata(dev); 370 370 struct gpio_desc *desc = data->desc; 371 371 umode_t mode = attr->mode;
+4 -6
drivers/gpio/gpiolib.c
··· 2594 2594 bitmap_xor(value_bitmap, value_bitmap, 2595 2595 array_info->invert_mask, array_size); 2596 2596 2597 - if (bitmap_full(array_info->get_mask, array_size)) 2598 - return 0; 2599 - 2600 2597 i = find_first_zero_bit(array_info->get_mask, array_size); 2598 + if (i == array_size) 2599 + return 0; 2601 2600 } else { 2602 2601 array_info = NULL; 2603 2602 } ··· 2877 2878 gpio_chip_set_multiple(array_info->chip, array_info->set_mask, 2878 2879 value_bitmap); 2879 2880 2880 - if (bitmap_full(array_info->set_mask, array_size)) 2881 - return 0; 2882 - 2883 2881 i = find_first_zero_bit(array_info->set_mask, array_size); 2882 + if (i == array_size) 2883 + return 0; 2884 2884 } else { 2885 2885 array_info = NULL; 2886 2886 }
+1 -1
include/linux/gpio/driver.h
··· 497 497 498 498 /** 499 499 * gpiochip_add_data() - register a gpio_chip 500 - * @chip: the chip to register, with chip->base initialized 500 + * @gc: the chip to register, with chip->base initialized 501 501 * @data: driver-private data associated with this chip 502 502 * 503 503 * Context: potentially before irqs will work