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

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

Pull pin control fixes from Linus Walleij:
"Some few pin control fixes for the v5.15 kernel cycle. The most
critical is the AMD fixes.

- Fix wakeup interrupts in the AMD driver affecting AMD laptops.

- Fix parent irqspec translation in the Qualcomm SPMI GPIO driver.

- Fix deferred probe handling in the Rockchip driver, this is a
stopgap solution while we look for something more elegant.

- Add PM suspend callbacks to the Qualcomm SC7280 driver.

- Some minor doc fix (should have come in earlier, sorry)"

* tag 'pinctrl-v5.15-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl:
pinctrl: qcom: sc7280: Add PM suspend callbacks
gpio/rockchip: fetch deferred output settings on probe
pinctrl/rockchip: add a queue for deferred pin output settings on probe
pinctrl: qcom: spmi-gpio: correct parent irqspec translation
pinctrl: amd: Handle wake-up interrupt
pinctrl: amd: Add irq field data
pinctrl: core: Remove duplicated word from devm_pinctrl_unregister()

+150 -9
+22
drivers/gpio/gpio-rockchip.c
··· 689 689 struct device_node *pctlnp = of_get_parent(np); 690 690 struct pinctrl_dev *pctldev = NULL; 691 691 struct rockchip_pin_bank *bank = NULL; 692 + struct rockchip_pin_output_deferred *cfg; 692 693 static int gpio; 693 694 int id, ret; 694 695 ··· 717 716 if (ret) 718 717 return ret; 719 718 719 + /* 720 + * Prevent clashes with a deferred output setting 721 + * being added right at this moment. 722 + */ 723 + mutex_lock(&bank->deferred_lock); 724 + 720 725 ret = rockchip_gpiolib_register(bank); 721 726 if (ret) { 722 727 clk_disable_unprepare(bank->clk); 728 + mutex_unlock(&bank->deferred_lock); 723 729 return ret; 724 730 } 731 + 732 + while (!list_empty(&bank->deferred_output)) { 733 + cfg = list_first_entry(&bank->deferred_output, 734 + struct rockchip_pin_output_deferred, head); 735 + list_del(&cfg->head); 736 + 737 + ret = rockchip_gpio_direction_output(&bank->gpio_chip, cfg->pin, cfg->arg); 738 + if (ret) 739 + dev_warn(dev, "setting output pin %u to %u failed\n", cfg->pin, cfg->arg); 740 + 741 + kfree(cfg); 742 + } 743 + 744 + mutex_unlock(&bank->deferred_lock); 725 745 726 746 platform_set_drvdata(pdev, bank); 727 747 dev_info(dev, "probed %pOF\n", np);
+1 -1
drivers/pinctrl/core.c
··· 2306 2306 2307 2307 /** 2308 2308 * devm_pinctrl_unregister() - Resource managed version of pinctrl_unregister(). 2309 - * @dev: device for which which resource was allocated 2309 + * @dev: device for which resource was allocated 2310 2310 * @pctldev: the pinctrl device to unregister. 2311 2311 */ 2312 2312 void devm_pinctrl_unregister(struct device *dev, struct pinctrl_dev *pctldev)
+14 -5
drivers/pinctrl/pinctrl-amd.c
··· 445 445 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 446 446 struct amd_gpio *gpio_dev = gpiochip_get_data(gc); 447 447 u32 wake_mask = BIT(WAKE_CNTRL_OFF_S0I3) | BIT(WAKE_CNTRL_OFF_S3); 448 + int err; 448 449 449 450 raw_spin_lock_irqsave(&gpio_dev->lock, flags); 450 451 pin_reg = readl(gpio_dev->base + (d->hwirq)*4); ··· 457 456 458 457 writel(pin_reg, gpio_dev->base + (d->hwirq)*4); 459 458 raw_spin_unlock_irqrestore(&gpio_dev->lock, flags); 459 + 460 + if (on) 461 + err = enable_irq_wake(gpio_dev->irq); 462 + else 463 + err = disable_irq_wake(gpio_dev->irq); 464 + 465 + if (err) 466 + dev_err(&gpio_dev->pdev->dev, "failed to %s wake-up interrupt\n", 467 + on ? "enable" : "disable"); 460 468 461 469 return 0; 462 470 } ··· 912 902 static int amd_gpio_probe(struct platform_device *pdev) 913 903 { 914 904 int ret = 0; 915 - int irq_base; 916 905 struct resource *res; 917 906 struct amd_gpio *gpio_dev; 918 907 struct gpio_irq_chip *girq; ··· 934 925 if (!gpio_dev->base) 935 926 return -ENOMEM; 936 927 937 - irq_base = platform_get_irq(pdev, 0); 938 - if (irq_base < 0) 939 - return irq_base; 928 + gpio_dev->irq = platform_get_irq(pdev, 0); 929 + if (gpio_dev->irq < 0) 930 + return gpio_dev->irq; 940 931 941 932 #ifdef CONFIG_PM_SLEEP 942 933 gpio_dev->saved_regs = devm_kcalloc(&pdev->dev, amd_pinctrl_desc.npins, ··· 996 987 goto out2; 997 988 } 998 989 999 - ret = devm_request_irq(&pdev->dev, irq_base, amd_gpio_irq_handler, 990 + ret = devm_request_irq(&pdev->dev, gpio_dev->irq, amd_gpio_irq_handler, 1000 991 IRQF_SHARED, KBUILD_MODNAME, gpio_dev); 1001 992 if (ret) 1002 993 goto out2;
+1
drivers/pinctrl/pinctrl-amd.h
··· 98 98 struct resource *res; 99 99 struct platform_device *pdev; 100 100 u32 *saved_regs; 101 + int irq; 101 102 }; 102 103 103 104 /* KERNCZ configuration*/
+67
drivers/pinctrl/pinctrl-rockchip.c
··· 2092 2092 return false; 2093 2093 } 2094 2094 2095 + static int rockchip_pinconf_defer_output(struct rockchip_pin_bank *bank, 2096 + unsigned int pin, u32 arg) 2097 + { 2098 + struct rockchip_pin_output_deferred *cfg; 2099 + 2100 + cfg = kzalloc(sizeof(*cfg), GFP_KERNEL); 2101 + if (!cfg) 2102 + return -ENOMEM; 2103 + 2104 + cfg->pin = pin; 2105 + cfg->arg = arg; 2106 + 2107 + list_add_tail(&cfg->head, &bank->deferred_output); 2108 + 2109 + return 0; 2110 + } 2111 + 2095 2112 /* set the pin config settings for a specified pin */ 2096 2113 static int rockchip_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin, 2097 2114 unsigned long *configs, unsigned num_configs) ··· 2152 2135 RK_FUNC_GPIO); 2153 2136 if (rc != RK_FUNC_GPIO) 2154 2137 return -EINVAL; 2138 + 2139 + /* 2140 + * Check for gpio driver not being probed yet. 2141 + * The lock makes sure that either gpio-probe has completed 2142 + * or the gpio driver hasn't probed yet. 2143 + */ 2144 + mutex_lock(&bank->deferred_lock); 2145 + if (!gpio || !gpio->direction_output) { 2146 + rc = rockchip_pinconf_defer_output(bank, pin - bank->pin_base, arg); 2147 + mutex_unlock(&bank->deferred_lock); 2148 + if (rc) 2149 + return rc; 2150 + 2151 + break; 2152 + } 2153 + mutex_unlock(&bank->deferred_lock); 2155 2154 2156 2155 rc = gpio->direction_output(gpio, pin - bank->pin_base, 2157 2156 arg); ··· 2236 2203 rc = rockchip_get_mux(bank, pin - bank->pin_base); 2237 2204 if (rc != RK_FUNC_GPIO) 2238 2205 return -EINVAL; 2206 + 2207 + if (!gpio || !gpio->get) { 2208 + arg = 0; 2209 + break; 2210 + } 2239 2211 2240 2212 rc = gpio->get(gpio, pin - bank->pin_base); 2241 2213 if (rc < 0) ··· 2488 2450 pin_bank->name, pin); 2489 2451 pdesc++; 2490 2452 } 2453 + 2454 + INIT_LIST_HEAD(&pin_bank->deferred_output); 2455 + mutex_init(&pin_bank->deferred_lock); 2491 2456 } 2492 2457 2493 2458 ret = rockchip_pinctrl_parse_dt(pdev, info); ··· 2752 2711 if (ret) { 2753 2712 dev_err(&pdev->dev, "failed to register gpio device\n"); 2754 2713 return ret; 2714 + } 2715 + 2716 + return 0; 2717 + } 2718 + 2719 + static int rockchip_pinctrl_remove(struct platform_device *pdev) 2720 + { 2721 + struct rockchip_pinctrl *info = platform_get_drvdata(pdev); 2722 + struct rockchip_pin_bank *bank; 2723 + struct rockchip_pin_output_deferred *cfg; 2724 + int i; 2725 + 2726 + of_platform_depopulate(&pdev->dev); 2727 + 2728 + for (i = 0; i < info->ctrl->nr_banks; i++) { 2729 + bank = &info->ctrl->pin_banks[i]; 2730 + 2731 + mutex_lock(&bank->deferred_lock); 2732 + while (!list_empty(&bank->deferred_output)) { 2733 + cfg = list_first_entry(&bank->deferred_output, 2734 + struct rockchip_pin_output_deferred, head); 2735 + list_del(&cfg->head); 2736 + kfree(cfg); 2737 + } 2738 + mutex_unlock(&bank->deferred_lock); 2755 2739 } 2756 2740 2757 2741 return 0; ··· 3241 3175 3242 3176 static struct platform_driver rockchip_pinctrl_driver = { 3243 3177 .probe = rockchip_pinctrl_probe, 3178 + .remove = rockchip_pinctrl_remove, 3244 3179 .driver = { 3245 3180 .name = "rockchip-pinctrl", 3246 3181 .pm = &rockchip_pinctrl_dev_pm_ops,
+10
drivers/pinctrl/pinctrl-rockchip.h
··· 141 141 * @toggle_edge_mode: bit mask to toggle (falling/rising) edge mode 142 142 * @recalced_mask: bit mask to indicate a need to recalulate the mask 143 143 * @route_mask: bits describing the routing pins of per bank 144 + * @deferred_output: gpio output settings to be done after gpio bank probed 145 + * @deferred_lock: mutex for the deferred_output shared btw gpio and pinctrl 144 146 */ 145 147 struct rockchip_pin_bank { 146 148 struct device *dev; ··· 171 169 u32 toggle_edge_mode; 172 170 u32 recalced_mask; 173 171 u32 route_mask; 172 + struct list_head deferred_output; 173 + struct mutex deferred_lock; 174 174 }; 175 175 176 176 /** ··· 245 241 unsigned int func; 246 242 unsigned long *configs; 247 243 unsigned int nconfigs; 244 + }; 245 + 246 + struct rockchip_pin_output_deferred { 247 + struct list_head head; 248 + unsigned int pin; 249 + u32 arg; 248 250 }; 249 251 250 252 /**
+1
drivers/pinctrl/qcom/pinctrl-sc7280.c
··· 1496 1496 static struct platform_driver sc7280_pinctrl_driver = { 1497 1497 .driver = { 1498 1498 .name = "sc7280-pinctrl", 1499 + .pm = &msm_pinctrl_dev_pm_ops, 1499 1500 .of_match_table = sc7280_pinctrl_of_match, 1500 1501 }, 1501 1502 .probe = sc7280_pinctrl_probe,
+34 -3
drivers/pinctrl/qcom/pinctrl-spmi-gpio.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-only 2 2 /* 3 - * Copyright (c) 2012-2014, The Linux Foundation. All rights reserved. 3 + * Copyright (c) 2012-2014, 2016-2021 The Linux Foundation. All rights reserved. 4 4 */ 5 5 6 6 #include <linux/gpio/driver.h> ··· 14 14 #include <linux/platform_device.h> 15 15 #include <linux/regmap.h> 16 16 #include <linux/slab.h> 17 + #include <linux/spmi.h> 17 18 #include <linux/types.h> 18 19 19 20 #include <dt-bindings/pinctrl/qcom,pmic-gpio.h> ··· 172 171 struct pinctrl_dev *ctrl; 173 172 struct gpio_chip chip; 174 173 struct irq_chip irq; 174 + u8 usid; 175 + u8 pid_base; 175 176 }; 176 177 177 178 static const struct pinconf_generic_params pmic_gpio_bindings[] = { ··· 952 949 unsigned int *parent_hwirq, 953 950 unsigned int *parent_type) 954 951 { 955 - *parent_hwirq = child_hwirq + 0xc0; 952 + struct pmic_gpio_state *state = gpiochip_get_data(chip); 953 + 954 + *parent_hwirq = child_hwirq + state->pid_base; 956 955 *parent_type = child_type; 957 956 958 957 return 0; 958 + } 959 + 960 + static void *pmic_gpio_populate_parent_fwspec(struct gpio_chip *chip, 961 + unsigned int parent_hwirq, 962 + unsigned int parent_type) 963 + { 964 + struct pmic_gpio_state *state = gpiochip_get_data(chip); 965 + struct irq_fwspec *fwspec; 966 + 967 + fwspec = kzalloc(sizeof(*fwspec), GFP_KERNEL); 968 + if (!fwspec) 969 + return NULL; 970 + 971 + fwspec->fwnode = chip->irq.parent_domain->fwnode; 972 + 973 + fwspec->param_count = 4; 974 + fwspec->param[0] = state->usid; 975 + fwspec->param[1] = parent_hwirq; 976 + /* param[2] must be left as 0 */ 977 + fwspec->param[3] = parent_type; 978 + 979 + return fwspec; 959 980 } 960 981 961 982 static int pmic_gpio_probe(struct platform_device *pdev) ··· 992 965 struct pmic_gpio_pad *pad, *pads; 993 966 struct pmic_gpio_state *state; 994 967 struct gpio_irq_chip *girq; 968 + const struct spmi_device *parent_spmi_dev; 995 969 int ret, npins, i; 996 970 u32 reg; 997 971 ··· 1012 984 1013 985 state->dev = &pdev->dev; 1014 986 state->map = dev_get_regmap(dev->parent, NULL); 987 + parent_spmi_dev = to_spmi_device(dev->parent); 988 + state->usid = parent_spmi_dev->usid; 989 + state->pid_base = reg >> 8; 1015 990 1016 991 pindesc = devm_kcalloc(dev, npins, sizeof(*pindesc), GFP_KERNEL); 1017 992 if (!pindesc) ··· 1090 1059 girq->fwnode = of_node_to_fwnode(state->dev->of_node); 1091 1060 girq->parent_domain = parent_domain; 1092 1061 girq->child_to_parent_hwirq = pmic_gpio_child_to_parent_hwirq; 1093 - girq->populate_parent_alloc_arg = gpiochip_populate_parent_fwspec_fourcell; 1062 + girq->populate_parent_alloc_arg = pmic_gpio_populate_parent_fwspec; 1094 1063 girq->child_offset_to_irq = pmic_gpio_child_offset_to_irq; 1095 1064 girq->child_irq_domain_ops.translate = pmic_gpio_domain_translate; 1096 1065