Merge tag 'pinctrl-v4.14-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl

Pull pin control fixes from Linus Walleij:
"This slew of fixes for pin control was noticed and patched up early,
so to get the annoyance out of the way for -rc1 it would make sense to
send them already.

- Fix a build include in the Uniphier driver to keep pace with
ongoing refactorings.

- Fix a slew of minor semantic and syntactic issues as well as
stricting up Kconfig for the new Spreadtrum driver.

- Fix the GPIO interrupt set-up on the Marvell 37xx Armada as fallout
for dynamically allocating irq descriptors from the core. (Also
tagged for stable.)

- Fix AMD register suspend/resume state spool/unspooling so that
wakeup works as it should. (Also tagged for stable.)"

* tag 'pinctrl-v4.14-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl:
pinctrl/amd: save pin registers over suspend/resume
pinctrl: armada-37xx: Fix gpio interrupt setup
pinctrl: sprd: fix off by one bugs
pinctrl: sprd: check for allocation failure
pinctrl: sprd: Restrict PINCTRL_SPRD to ARCH_SPRD or COMPILE_TEST
pinctrl: sprd: fix build errors and dependencies
pinctrl: sprd: make three local functions static
pinctrl: uniphier: include <linux/build_bug.h> instead of <linux/bug.h>

+120 -34
+22 -19
drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
··· 550 spin_lock_irqsave(&info->irq_lock, flags); 551 val = readl(info->base + reg); 552 if (on) 553 - val |= d->mask; 554 else 555 - val &= ~d->mask; 556 writel(val, info->base + reg); 557 spin_unlock_irqrestore(&info->irq_lock, flags); 558 ··· 571 val = readl(info->base + reg); 572 switch (type) { 573 case IRQ_TYPE_EDGE_RISING: 574 - val &= ~d->mask; 575 break; 576 case IRQ_TYPE_EDGE_FALLING: 577 - val |= d->mask; 578 break; 579 default: 580 spin_unlock_irqrestore(&info->irq_lock, flags); ··· 624 chained_irq_exit(chip, desc); 625 } 626 627 static int armada_37xx_irqchip_register(struct platform_device *pdev, 628 struct armada_37xx_pinctrl *info) 629 { 630 struct device_node *np = info->dev->of_node; 631 - int nrirqs = info->data->nr_pins; 632 struct gpio_chip *gc = &info->gpio_chip; 633 struct irq_chip *irqchip = &info->irq_chip; 634 struct resource res; ··· 682 irqchip->irq_unmask = armada_37xx_irq_unmask; 683 irqchip->irq_set_wake = armada_37xx_irq_set_wake; 684 irqchip->irq_set_type = armada_37xx_irq_set_type; 685 irqchip->name = info->data->name; 686 - 687 ret = gpiochip_irqchip_add(gc, irqchip, 0, 688 handle_edge_irq, IRQ_TYPE_NONE); 689 if (ret) { ··· 696 * controller. But we do not take advantage of this and use 697 * the chained irq with all of them. 698 */ 699 - for (i = 0; i < nrirqs; i++) { 700 - struct irq_data *d = irq_get_irq_data(gc->irq_base + i); 701 - 702 - /* 703 - * The mask field is a "precomputed bitmask for 704 - * accessing the chip registers" which was introduced 705 - * for the generic irqchip framework. As we don't use 706 - * this framework, we can reuse this field for our own 707 - * usage. 708 - */ 709 - d->mask = BIT(i % GPIO_PER_REG); 710 - } 711 - 712 for (i = 0; i < nr_irq_parent; i++) { 713 int irq = irq_of_parse_and_map(np, i); 714
··· 550 spin_lock_irqsave(&info->irq_lock, flags); 551 val = readl(info->base + reg); 552 if (on) 553 + val |= (BIT(d->hwirq % GPIO_PER_REG)); 554 else 555 + val &= ~(BIT(d->hwirq % GPIO_PER_REG)); 556 writel(val, info->base + reg); 557 spin_unlock_irqrestore(&info->irq_lock, flags); 558 ··· 571 val = readl(info->base + reg); 572 switch (type) { 573 case IRQ_TYPE_EDGE_RISING: 574 + val &= ~(BIT(d->hwirq % GPIO_PER_REG)); 575 break; 576 case IRQ_TYPE_EDGE_FALLING: 577 + val |= (BIT(d->hwirq % GPIO_PER_REG)); 578 break; 579 default: 580 spin_unlock_irqrestore(&info->irq_lock, flags); ··· 624 chained_irq_exit(chip, desc); 625 } 626 627 + static unsigned int armada_37xx_irq_startup(struct irq_data *d) 628 + { 629 + struct gpio_chip *chip = irq_data_get_irq_chip_data(d); 630 + int irq = d->hwirq - chip->irq_base; 631 + /* 632 + * The mask field is a "precomputed bitmask for accessing the 633 + * chip registers" which was introduced for the generic 634 + * irqchip framework. As we don't use this framework, we can 635 + * reuse this field for our own usage. 636 + */ 637 + d->mask = BIT(irq % GPIO_PER_REG); 638 + 639 + armada_37xx_irq_unmask(d); 640 + 641 + return 0; 642 + } 643 + 644 static int armada_37xx_irqchip_register(struct platform_device *pdev, 645 struct armada_37xx_pinctrl *info) 646 { 647 struct device_node *np = info->dev->of_node; 648 struct gpio_chip *gc = &info->gpio_chip; 649 struct irq_chip *irqchip = &info->irq_chip; 650 struct resource res; ··· 666 irqchip->irq_unmask = armada_37xx_irq_unmask; 667 irqchip->irq_set_wake = armada_37xx_irq_set_wake; 668 irqchip->irq_set_type = armada_37xx_irq_set_type; 669 + irqchip->irq_startup = armada_37xx_irq_startup; 670 irqchip->name = info->data->name; 671 ret = gpiochip_irqchip_add(gc, irqchip, 0, 672 handle_edge_irq, IRQ_TYPE_NONE); 673 if (ret) { ··· 680 * controller. But we do not take advantage of this and use 681 * the chained irq with all of them. 682 */ 683 for (i = 0; i < nr_irq_parent; i++) { 684 int irq = irq_of_parse_and_map(np, i); 685
+75
drivers/pinctrl/pinctrl-amd.c
··· 36 #include <linux/pinctrl/pinconf.h> 37 #include <linux/pinctrl/pinconf-generic.h> 38 39 #include "pinctrl-utils.h" 40 #include "pinctrl-amd.h" 41 ··· 726 .pin_config_group_set = amd_pinconf_group_set, 727 }; 728 729 static struct pinctrl_desc amd_pinctrl_desc = { 730 .pins = kerncz_pins, 731 .npins = ARRAY_SIZE(kerncz_pins), ··· 827 dev_err(&pdev->dev, "Failed to get gpio IRQ: %d\n", irq_base); 828 return irq_base; 829 } 830 831 gpio_dev->pdev = pdev; 832 gpio_dev->gc.direction_input = amd_gpio_direction_input; ··· 925 .driver = { 926 .name = "amd_gpio", 927 .acpi_match_table = ACPI_PTR(amd_gpio_acpi_match), 928 }, 929 .probe = amd_gpio_probe, 930 .remove = amd_gpio_remove,
··· 36 #include <linux/pinctrl/pinconf.h> 37 #include <linux/pinctrl/pinconf-generic.h> 38 39 + #include "core.h" 40 #include "pinctrl-utils.h" 41 #include "pinctrl-amd.h" 42 ··· 725 .pin_config_group_set = amd_pinconf_group_set, 726 }; 727 728 + #ifdef CONFIG_PM_SLEEP 729 + static bool amd_gpio_should_save(struct amd_gpio *gpio_dev, unsigned int pin) 730 + { 731 + const struct pin_desc *pd = pin_desc_get(gpio_dev->pctrl, pin); 732 + 733 + if (!pd) 734 + return false; 735 + 736 + /* 737 + * Only restore the pin if it is actually in use by the kernel (or 738 + * by userspace). 739 + */ 740 + if (pd->mux_owner || pd->gpio_owner || 741 + gpiochip_line_is_irq(&gpio_dev->gc, pin)) 742 + return true; 743 + 744 + return false; 745 + } 746 + 747 + int amd_gpio_suspend(struct device *dev) 748 + { 749 + struct platform_device *pdev = to_platform_device(dev); 750 + struct amd_gpio *gpio_dev = platform_get_drvdata(pdev); 751 + struct pinctrl_desc *desc = gpio_dev->pctrl->desc; 752 + int i; 753 + 754 + for (i = 0; i < desc->npins; i++) { 755 + int pin = desc->pins[i].number; 756 + 757 + if (!amd_gpio_should_save(gpio_dev, pin)) 758 + continue; 759 + 760 + gpio_dev->saved_regs[i] = readl(gpio_dev->base + pin*4); 761 + } 762 + 763 + return 0; 764 + } 765 + 766 + int amd_gpio_resume(struct device *dev) 767 + { 768 + struct platform_device *pdev = to_platform_device(dev); 769 + struct amd_gpio *gpio_dev = platform_get_drvdata(pdev); 770 + struct pinctrl_desc *desc = gpio_dev->pctrl->desc; 771 + int i; 772 + 773 + for (i = 0; i < desc->npins; i++) { 774 + int pin = desc->pins[i].number; 775 + 776 + if (!amd_gpio_should_save(gpio_dev, pin)) 777 + continue; 778 + 779 + writel(gpio_dev->saved_regs[i], gpio_dev->base + pin*4); 780 + } 781 + 782 + return 0; 783 + } 784 + 785 + static const struct dev_pm_ops amd_gpio_pm_ops = { 786 + SET_LATE_SYSTEM_SLEEP_PM_OPS(amd_gpio_suspend, 787 + amd_gpio_resume) 788 + }; 789 + #endif 790 + 791 static struct pinctrl_desc amd_pinctrl_desc = { 792 .pins = kerncz_pins, 793 .npins = ARRAY_SIZE(kerncz_pins), ··· 763 dev_err(&pdev->dev, "Failed to get gpio IRQ: %d\n", irq_base); 764 return irq_base; 765 } 766 + 767 + #ifdef CONFIG_PM_SLEEP 768 + gpio_dev->saved_regs = devm_kcalloc(&pdev->dev, amd_pinctrl_desc.npins, 769 + sizeof(*gpio_dev->saved_regs), 770 + GFP_KERNEL); 771 + if (!gpio_dev->saved_regs) 772 + return -ENOMEM; 773 + #endif 774 775 gpio_dev->pdev = pdev; 776 gpio_dev->gc.direction_input = amd_gpio_direction_input; ··· 853 .driver = { 854 .name = "amd_gpio", 855 .acpi_match_table = ACPI_PTR(amd_gpio_acpi_match), 856 + #ifdef CONFIG_PM_SLEEP 857 + .pm = &amd_gpio_pm_ops, 858 + #endif 859 }, 860 .probe = amd_gpio_probe, 861 .remove = amd_gpio_remove,
+1
drivers/pinctrl/pinctrl-amd.h
··· 97 unsigned int hwbank_num; 98 struct resource *res; 99 struct platform_device *pdev; 100 }; 101 102 /* KERNCZ configuration*/
··· 97 unsigned int hwbank_num; 98 struct resource *res; 99 struct platform_device *pdev; 100 + u32 *saved_regs; 101 }; 102 103 /* KERNCZ configuration*/
+3
drivers/pinctrl/sprd/Kconfig
··· 4 5 config PINCTRL_SPRD 6 bool "Spreadtrum pinctrl driver" 7 select PINMUX 8 select PINCONF 9 select GENERIC_PINCONF ··· 15 16 config PINCTRL_SPRD_SC9860 17 bool "Spreadtrum SC9860 pinctrl driver" 18 help 19 Say Y here to enable Spreadtrum SC9860 pinctrl driver
··· 4 5 config PINCTRL_SPRD 6 bool "Spreadtrum pinctrl driver" 7 + depends on OF 8 + depends on ARCH_SPRD || COMPILE_TEST 9 select PINMUX 10 select PINCONF 11 select GENERIC_PINCONF ··· 13 14 config PINCTRL_SPRD_SC9860 15 bool "Spreadtrum SC9860 pinctrl driver" 16 + depends on PINCTRL_SPRD 17 help 18 Say Y here to enable Spreadtrum SC9860 pinctrl driver
+18 -14
drivers/pinctrl/sprd/pinctrl-sprd.c
··· 353 .dt_free_map = pinctrl_utils_free_map, 354 }; 355 356 - int sprd_pmx_get_function_count(struct pinctrl_dev *pctldev) 357 { 358 return PIN_FUNC_MAX; 359 } 360 361 - const char *sprd_pmx_get_function_name(struct pinctrl_dev *pctldev, 362 - unsigned int selector) 363 { 364 switch (selector) { 365 case PIN_FUNC_1: ··· 375 } 376 } 377 378 - int sprd_pmx_get_function_groups(struct pinctrl_dev *pctldev, 379 - unsigned int selector, 380 - const char * const **groups, 381 - unsigned int * const num_groups) 382 { 383 struct sprd_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev); 384 struct sprd_pinctrl_soc_info *info = pctl->info; ··· 400 unsigned long reg; 401 unsigned int val = 0; 402 403 - if (group_selector > info->ngroups) 404 return -EINVAL; 405 406 switch (func_selector) { ··· 734 struct sprd_pin_group *grp; 735 unsigned int pin_id; 736 737 - if (selector > info->ngroups) 738 return -EINVAL; 739 740 grp = &info->groups[selector]; ··· 753 struct sprd_pin_group *grp; 754 int ret, i; 755 756 - if (selector > info->ngroups) 757 return -EINVAL; 758 759 grp = &info->groups[selector]; ··· 813 const char *name; 814 int i, ret; 815 816 - if (selector > info->ngroups) 817 return; 818 819 grp = &info->groups[selector]; ··· 1100 1101 void sprd_pinctrl_shutdown(struct platform_device *pdev) 1102 { 1103 - struct pinctrl *pinctl = devm_pinctrl_get(&pdev->dev); 1104 struct pinctrl_state *state; 1105 1106 state = pinctrl_lookup_state(pinctl, "shutdown"); 1107 - if (!IS_ERR(state)) 1108 - pinctrl_select_state(pinctl, state); 1109 } 1110 1111 MODULE_DESCRIPTION("SPREADTRUM Pin Controller Driver");
··· 353 .dt_free_map = pinctrl_utils_free_map, 354 }; 355 356 + static int sprd_pmx_get_function_count(struct pinctrl_dev *pctldev) 357 { 358 return PIN_FUNC_MAX; 359 } 360 361 + static const char *sprd_pmx_get_function_name(struct pinctrl_dev *pctldev, 362 + unsigned int selector) 363 { 364 switch (selector) { 365 case PIN_FUNC_1: ··· 375 } 376 } 377 378 + static int sprd_pmx_get_function_groups(struct pinctrl_dev *pctldev, 379 + unsigned int selector, 380 + const char * const **groups, 381 + unsigned int * const num_groups) 382 { 383 struct sprd_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev); 384 struct sprd_pinctrl_soc_info *info = pctl->info; ··· 400 unsigned long reg; 401 unsigned int val = 0; 402 403 + if (group_selector >= info->ngroups) 404 return -EINVAL; 405 406 switch (func_selector) { ··· 734 struct sprd_pin_group *grp; 735 unsigned int pin_id; 736 737 + if (selector >= info->ngroups) 738 return -EINVAL; 739 740 grp = &info->groups[selector]; ··· 753 struct sprd_pin_group *grp; 754 int ret, i; 755 756 + if (selector >= info->ngroups) 757 return -EINVAL; 758 759 grp = &info->groups[selector]; ··· 813 const char *name; 814 int i, ret; 815 816 + if (selector >= info->ngroups) 817 return; 818 819 grp = &info->groups[selector]; ··· 1100 1101 void sprd_pinctrl_shutdown(struct platform_device *pdev) 1102 { 1103 + struct pinctrl *pinctl; 1104 struct pinctrl_state *state; 1105 1106 + pinctl = devm_pinctrl_get(&pdev->dev); 1107 + if (IS_ERR(pinctl)) 1108 + return; 1109 state = pinctrl_lookup_state(pinctl, "shutdown"); 1110 + if (IS_ERR(state)) 1111 + return; 1112 + pinctrl_select_state(pinctl, state); 1113 } 1114 1115 MODULE_DESCRIPTION("SPREADTRUM Pin Controller Driver");
+1 -1
drivers/pinctrl/uniphier/pinctrl-uniphier.h
··· 17 #define __PINCTRL_UNIPHIER_H__ 18 19 #include <linux/bitops.h> 20 - #include <linux/bug.h> 21 #include <linux/kernel.h> 22 #include <linux/types.h> 23
··· 17 #define __PINCTRL_UNIPHIER_H__ 18 19 #include <linux/bitops.h> 20 + #include <linux/build_bug.h> 21 #include <linux/kernel.h> 22 #include <linux/types.h> 23