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

Merge tag 'intel-pinctrl-v6.12-1' of git://git.kernel.org/pub/scm/linux/kernel/git/pinctrl/intel into devel

intel-pinctrl for v6.12-1

* Enable High Impedance pin configuration support for Intel pin control
* Miscellaneous small improvements here and there

The following is an automated git shortlog grouped by driver:

baytrail:
- Drop duplicate return statement

intel:
- Constify struct intel_pinctrl parameter
- Inline intel_gpio_community_irq_handler()
- Introduce for_each_intel_gpio_group() helper et al.
- Constify intel_get_community() returned object
- Implement high impedance support
- Add __intel_gpio_get_direction() helper
- Refactor __intel_gpio_set_direction() to be more useful
- Move debounce validation out of the lock
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

+190 -148
+3 -4
drivers/pinctrl/intel/pinctrl-baytrail.c
··· 560 560 static void __iomem *byt_gpio_reg(struct intel_pinctrl *vg, unsigned int offset, 561 561 int reg) 562 562 { 563 - struct intel_community *comm = intel_get_community(vg, offset); 563 + const struct intel_community *comm; 564 564 u32 reg_offset; 565 565 566 + comm = intel_get_community(vg, offset); 566 567 if (!comm) 567 568 return NULL; 568 569 ··· 1542 1541 } 1543 1542 1544 1543 ret = devm_gpiochip_add_data(vg->dev, gc, vg); 1545 - if (ret) { 1544 + if (ret) 1546 1545 dev_err(vg->dev, "failed adding byt-gpio chip\n"); 1547 - return ret; 1548 - } 1549 1546 1550 1547 return ret; 1551 1548 }
+184 -142
drivers/pinctrl/intel/pinctrl-intel.c
··· 70 70 #define PADCFG0_PMODE_SHIFT 10 71 71 #define PADCFG0_PMODE_MASK GENMASK(13, 10) 72 72 #define PADCFG0_PMODE_GPIO 0 73 + #define PADCFG0_GPIODIS_SHIFT 8 74 + #define PADCFG0_GPIODIS_MASK GENMASK(9, 8) 75 + #define PADCFG0_GPIODIS_NONE 0 76 + #define PADCFG0_GPIODIS_OUTPUT 1 77 + #define PADCFG0_GPIODIS_INPUT 2 78 + #define PADCFG0_GPIODIS_FULL 3 73 79 #define PADCFG0_GPIORXDIS BIT(9) 74 80 #define PADCFG0_GPIOTXDIS BIT(8) 75 81 #define PADCFG0_GPIORXSTATE BIT(1) ··· 114 108 #define pin_to_padno(c, p) ((p) - (c)->pin_base) 115 109 #define padgroup_offset(g, p) ((p) - (g)->base) 116 110 117 - struct intel_community *intel_get_community(struct intel_pinctrl *pctrl, unsigned int pin) 118 - { 119 - struct intel_community *community; 120 - int i; 111 + #define for_each_intel_pin_community(pctrl, community) \ 112 + for (unsigned int __ci = 0; \ 113 + __ci < pctrl->ncommunities && (community = &pctrl->communities[__ci]); \ 114 + __ci++) \ 121 115 122 - for (i = 0; i < pctrl->ncommunities; i++) { 123 - community = &pctrl->communities[i]; 116 + #define for_each_intel_community_pad_group(community, grp) \ 117 + for (unsigned int __gi = 0; \ 118 + __gi < community->ngpps && (grp = &community->gpps[__gi]); \ 119 + __gi++) \ 120 + 121 + #define for_each_intel_pad_group(pctrl, community, grp) \ 122 + for_each_intel_pin_community(pctrl, community) \ 123 + for_each_intel_community_pad_group(community, grp) 124 + 125 + #define for_each_intel_gpio_group(pctrl, community, grp) \ 126 + for_each_intel_pad_group(pctrl, community, grp) \ 127 + if (grp->gpio_base == INTEL_GPIO_BASE_NOMAP) {} else 128 + 129 + const struct intel_community *intel_get_community(const struct intel_pinctrl *pctrl, 130 + unsigned int pin) 131 + { 132 + const struct intel_community *community; 133 + 134 + for_each_intel_pin_community(pctrl, community) { 124 135 if (pin >= community->pin_base && 125 136 pin < community->pin_base + community->npins) 126 137 return community; ··· 152 129 intel_community_get_padgroup(const struct intel_community *community, 153 130 unsigned int pin) 154 131 { 155 - int i; 132 + const struct intel_padgroup *padgrp; 156 133 157 - for (i = 0; i < community->ngpps; i++) { 158 - const struct intel_padgroup *padgrp = &community->gpps[i]; 159 - 134 + for_each_intel_community_pad_group(community, padgrp) { 160 135 if (pin >= padgrp->base && pin < padgrp->base + padgrp->size) 161 136 return padgrp; 162 137 } ··· 182 161 return community->pad_regs + reg + padno * nregs * 4; 183 162 } 184 163 185 - static bool intel_pad_owned_by_host(struct intel_pinctrl *pctrl, unsigned int pin) 164 + static bool intel_pad_owned_by_host(const struct intel_pinctrl *pctrl, unsigned int pin) 186 165 { 187 166 const struct intel_community *community; 188 167 const struct intel_padgroup *padgrp; ··· 207 186 return !(readl(padown) & PADOWN_MASK(gpp_offset)); 208 187 } 209 188 210 - static bool intel_pad_acpi_mode(struct intel_pinctrl *pctrl, unsigned int pin) 189 + static bool intel_pad_acpi_mode(const struct intel_pinctrl *pctrl, unsigned int pin) 211 190 { 212 191 const struct intel_community *community; 213 192 const struct intel_padgroup *padgrp; ··· 233 212 234 213 /** 235 214 * enum - Locking variants of the pad configuration 236 - * 237 215 * @PAD_UNLOCKED: pad is fully controlled by the configuration registers 238 216 * @PAD_LOCKED: pad configuration registers, except TX state, are locked 239 217 * @PAD_LOCKED_TX: pad configuration TX state is locked ··· 249 229 PAD_LOCKED_FULL = PAD_LOCKED | PAD_LOCKED_TX, 250 230 }; 251 231 252 - static int intel_pad_locked(struct intel_pinctrl *pctrl, unsigned int pin) 232 + static int intel_pad_locked(const struct intel_pinctrl *pctrl, unsigned int pin) 253 233 { 254 - struct intel_community *community; 234 + const struct intel_community *community; 255 235 const struct intel_padgroup *padgrp; 256 236 unsigned int offset, gpp_offset; 257 237 u32 value; ··· 287 267 return ret; 288 268 } 289 269 290 - static bool intel_pad_is_unlocked(struct intel_pinctrl *pctrl, unsigned int pin) 270 + static bool intel_pad_is_unlocked(const struct intel_pinctrl *pctrl, unsigned int pin) 291 271 { 292 272 return (intel_pad_locked(pctrl, pin) & PAD_LOCKED) == PAD_UNLOCKED; 293 273 } 294 274 295 - static bool intel_pad_usable(struct intel_pinctrl *pctrl, unsigned int pin) 275 + static bool intel_pad_usable(const struct intel_pinctrl *pctrl, unsigned int pin) 296 276 { 297 277 return intel_pad_owned_by_host(pctrl, pin) && intel_pad_is_unlocked(pctrl, pin); 298 278 } 299 279 300 280 int intel_get_groups_count(struct pinctrl_dev *pctldev) 301 281 { 302 - struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 282 + const struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 303 283 304 284 return pctrl->soc->ngroups; 305 285 } ··· 307 287 308 288 const char *intel_get_group_name(struct pinctrl_dev *pctldev, unsigned int group) 309 289 { 310 - struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 290 + const struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 311 291 312 292 return pctrl->soc->groups[group].grp.name; 313 293 } ··· 316 296 int intel_get_group_pins(struct pinctrl_dev *pctldev, unsigned int group, 317 297 const unsigned int **pins, unsigned int *npins) 318 298 { 319 - struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 299 + const struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 320 300 321 301 *pins = pctrl->soc->groups[group].grp.pins; 322 302 *npins = pctrl->soc->groups[group].grp.npins; ··· 384 364 385 365 int intel_get_functions_count(struct pinctrl_dev *pctldev) 386 366 { 387 - struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 367 + const struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 388 368 389 369 return pctrl->soc->nfunctions; 390 370 } ··· 392 372 393 373 const char *intel_get_function_name(struct pinctrl_dev *pctldev, unsigned int function) 394 374 { 395 - struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 375 + const struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 396 376 397 377 return pctrl->soc->functions[function].func.name; 398 378 } ··· 401 381 int intel_get_function_groups(struct pinctrl_dev *pctldev, unsigned int function, 402 382 const char * const **groups, unsigned int * const ngroups) 403 383 { 404 - struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 384 + const struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 405 385 406 386 *groups = pctrl->soc->functions[function].func.groups; 407 387 *ngroups = pctrl->soc->functions[function].func.ngroups; ··· 449 429 return 0; 450 430 } 451 431 452 - static void __intel_gpio_set_direction(void __iomem *padcfg0, bool input) 453 - { 454 - u32 value; 432 + /** 433 + * enum - Possible pad physical connections 434 + * @PAD_CONNECT_NONE: pad is fully disconnected 435 + * @PAD_CONNECT_INPUT: pad is in input only mode 436 + * @PAD_CONNECT_OUTPUT: pad is in output only mode 437 + * @PAD_CONNECT_FULL: pad is fully connected 438 + */ 439 + enum { 440 + PAD_CONNECT_NONE = 0, 441 + PAD_CONNECT_INPUT = 1, 442 + PAD_CONNECT_OUTPUT = 2, 443 + PAD_CONNECT_FULL = PAD_CONNECT_INPUT | PAD_CONNECT_OUTPUT, 444 + }; 455 445 456 - value = readl(padcfg0); 457 - if (input) { 446 + static int __intel_gpio_get_direction(u32 value) 447 + { 448 + switch ((value & PADCFG0_GPIODIS_MASK) >> PADCFG0_GPIODIS_SHIFT) { 449 + case PADCFG0_GPIODIS_FULL: 450 + return PAD_CONNECT_NONE; 451 + case PADCFG0_GPIODIS_OUTPUT: 452 + return PAD_CONNECT_INPUT; 453 + case PADCFG0_GPIODIS_INPUT: 454 + return PAD_CONNECT_OUTPUT; 455 + case PADCFG0_GPIODIS_NONE: 456 + return PAD_CONNECT_FULL; 457 + default: 458 + return -ENOTSUPP; 459 + }; 460 + } 461 + 462 + static u32 __intel_gpio_set_direction(u32 value, bool input, bool output) 463 + { 464 + if (input) 458 465 value &= ~PADCFG0_GPIORXDIS; 459 - value |= PADCFG0_GPIOTXDIS; 460 - } else { 461 - value &= ~PADCFG0_GPIOTXDIS; 466 + else 462 467 value |= PADCFG0_GPIORXDIS; 463 - } 464 - writel(value, padcfg0); 468 + 469 + if (output) 470 + value &= ~PADCFG0_GPIOTXDIS; 471 + else 472 + value |= PADCFG0_GPIOTXDIS; 473 + 474 + return value; 465 475 } 466 476 467 477 static int __intel_gpio_get_gpio_mode(u32 value) ··· 515 465 value |= PADCFG0_PMODE_GPIO; 516 466 517 467 /* Disable TX buffer and enable RX (this will be input) */ 518 - value &= ~PADCFG0_GPIORXDIS; 519 - value |= PADCFG0_GPIOTXDIS; 468 + value = __intel_gpio_set_direction(value, true, false); 520 469 521 470 /* Disable SCI/SMI/NMI generation */ 522 471 value &= ~(PADCFG0_GPIROUTIOXAPIC | PADCFG0_GPIROUTSCI); ··· 561 512 { 562 513 struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 563 514 void __iomem *padcfg0; 515 + u32 value; 564 516 565 517 padcfg0 = intel_get_padcfg(pctrl, pin, PADCFG0); 566 518 567 519 guard(raw_spinlock_irqsave)(&pctrl->lock); 568 520 569 - __intel_gpio_set_direction(padcfg0, input); 521 + value = readl(padcfg0); 522 + if (input) 523 + value = __intel_gpio_set_direction(value, true, false); 524 + else 525 + value = __intel_gpio_set_direction(value, false, true); 526 + writel(value, padcfg0); 570 527 571 528 return 0; 572 529 } ··· 667 612 return 0; 668 613 } 669 614 615 + static int intel_config_get_high_impedance(struct intel_pinctrl *pctrl, unsigned int pin, 616 + enum pin_config_param param, u32 *arg) 617 + { 618 + void __iomem *padcfg0; 619 + u32 value; 620 + 621 + padcfg0 = intel_get_padcfg(pctrl, pin, PADCFG0); 622 + 623 + scoped_guard(raw_spinlock_irqsave, &pctrl->lock) 624 + value = readl(padcfg0); 625 + 626 + if (__intel_gpio_get_direction(value) != PAD_CONNECT_NONE) 627 + return -EINVAL; 628 + 629 + return 0; 630 + } 631 + 670 632 static int intel_config_get_debounce(struct intel_pinctrl *pctrl, unsigned int pin, 671 633 enum pin_config_param param, u32 *arg) 672 634 { ··· 723 651 case PIN_CONFIG_BIAS_PULL_UP: 724 652 case PIN_CONFIG_BIAS_PULL_DOWN: 725 653 ret = intel_config_get_pull(pctrl, pin, param, &arg); 654 + if (ret) 655 + return ret; 656 + break; 657 + 658 + case PIN_CONFIG_BIAS_HIGH_IMPEDANCE: 659 + ret = intel_config_get_high_impedance(pctrl, pin, param, &arg); 726 660 if (ret) 727 661 return ret; 728 662 break; ··· 831 753 return 0; 832 754 } 833 755 756 + static void intel_gpio_set_high_impedance(struct intel_pinctrl *pctrl, unsigned int pin) 757 + { 758 + void __iomem *padcfg0; 759 + u32 value; 760 + 761 + padcfg0 = intel_get_padcfg(pctrl, pin, PADCFG0); 762 + 763 + guard(raw_spinlock_irqsave)(&pctrl->lock); 764 + 765 + value = readl(padcfg0); 766 + value = __intel_gpio_set_direction(value, false, false); 767 + writel(value, padcfg0); 768 + } 769 + 834 770 static int intel_config_set_debounce(struct intel_pinctrl *pctrl, 835 771 unsigned int pin, unsigned int debounce) 836 772 { 837 773 void __iomem *padcfg0, *padcfg2; 838 774 u32 value0, value2; 775 + unsigned long v; 776 + 777 + if (debounce) { 778 + v = order_base_2(debounce * NSEC_PER_USEC / DEBOUNCE_PERIOD_NSEC); 779 + if (v < 3 || v > 15) 780 + return -EINVAL; 781 + } else { 782 + v = 0; 783 + } 839 784 840 785 padcfg2 = intel_get_padcfg(pctrl, pin, PADCFG2); 841 786 if (!padcfg2) ··· 871 770 value0 = readl(padcfg0); 872 771 value2 = readl(padcfg2); 873 772 874 - /* Disable glitch filter and debouncer */ 875 - value0 &= ~PADCFG0_PREGFRXSEL; 876 - value2 &= ~(PADCFG2_DEBEN | PADCFG2_DEBOUNCE_MASK); 877 - 878 - if (debounce) { 879 - unsigned long v; 880 - 881 - v = order_base_2(debounce * NSEC_PER_USEC / DEBOUNCE_PERIOD_NSEC); 882 - if (v < 3 || v > 15) 883 - return -EINVAL; 884 - 773 + value2 = (value2 & ~PADCFG2_DEBOUNCE_MASK) | (v << PADCFG2_DEBOUNCE_SHIFT); 774 + if (v) { 885 775 /* Enable glitch filter and debouncer */ 886 776 value0 |= PADCFG0_PREGFRXSEL; 887 - value2 |= v << PADCFG2_DEBOUNCE_SHIFT; 888 777 value2 |= PADCFG2_DEBEN; 778 + } else { 779 + /* Disable glitch filter and debouncer */ 780 + value0 &= ~PADCFG0_PREGFRXSEL; 781 + value2 &= ~PADCFG2_DEBEN; 889 782 } 890 783 891 784 writel(value0, padcfg0); ··· 905 810 ret = intel_config_set_pull(pctrl, pin, configs[i]); 906 811 if (ret) 907 812 return ret; 813 + break; 814 + 815 + case PIN_CONFIG_BIAS_HIGH_IMPEDANCE: 816 + intel_gpio_set_high_impedance(pctrl, pin); 908 817 break; 909 818 910 819 case PIN_CONFIG_INPUT_DEBOUNCE: ··· 953 854 * Return: a pin number and pointers to the community and pad group, which 954 855 * the pin belongs to, or negative error code if translation can't be done. 955 856 */ 956 - static int intel_gpio_to_pin(struct intel_pinctrl *pctrl, unsigned int offset, 857 + static int intel_gpio_to_pin(const struct intel_pinctrl *pctrl, unsigned int offset, 957 858 const struct intel_community **community, 958 859 const struct intel_padgroup **padgrp) 959 860 { 960 - int i; 861 + const struct intel_community *comm; 862 + const struct intel_padgroup *grp; 961 863 962 - for (i = 0; i < pctrl->ncommunities; i++) { 963 - const struct intel_community *comm = &pctrl->communities[i]; 964 - int j; 864 + for_each_intel_gpio_group(pctrl, comm, grp) { 865 + if (offset >= grp->gpio_base && offset < grp->gpio_base + grp->size) { 866 + if (community) 867 + *community = comm; 868 + if (padgrp) 869 + *padgrp = grp; 965 870 966 - for (j = 0; j < comm->ngpps; j++) { 967 - const struct intel_padgroup *pgrp = &comm->gpps[j]; 968 - 969 - if (pgrp->gpio_base == INTEL_GPIO_BASE_NOMAP) 970 - continue; 971 - 972 - if (offset >= pgrp->gpio_base && 973 - offset < pgrp->gpio_base + pgrp->size) { 974 - int pin; 975 - 976 - pin = pgrp->base + offset - pgrp->gpio_base; 977 - if (community) 978 - *community = comm; 979 - if (padgrp) 980 - *padgrp = pgrp; 981 - 982 - return pin; 983 - } 871 + return grp->base + offset - grp->gpio_base; 984 872 } 985 873 } 986 874 ··· 983 897 * 984 898 * Return: a GPIO offset, or negative error code if translation can't be done. 985 899 */ 986 - static int intel_pin_to_gpio(struct intel_pinctrl *pctrl, int pin) 900 + static int intel_pin_to_gpio(const struct intel_pinctrl *pctrl, int pin) 987 901 { 988 902 const struct intel_community *community; 989 903 const struct intel_padgroup *padgrp; ··· 1015 929 return -EINVAL; 1016 930 1017 931 padcfg0 = readl(reg); 1018 - if (!(padcfg0 & PADCFG0_GPIOTXDIS)) 932 + if (__intel_gpio_get_direction(padcfg0) & PAD_CONNECT_OUTPUT) 1019 933 return !!(padcfg0 & PADCFG0_GPIOTXSTATE); 1020 934 1021 935 return !!(padcfg0 & PADCFG0_GPIORXSTATE); ··· 1068 982 if (padcfg0 & PADCFG0_PMODE_MASK) 1069 983 return -EINVAL; 1070 984 1071 - if (padcfg0 & PADCFG0_GPIOTXDIS) 1072 - return GPIO_LINE_DIRECTION_IN; 985 + if (__intel_gpio_get_direction(padcfg0) & PAD_CONNECT_OUTPUT) 986 + return GPIO_LINE_DIRECTION_OUT; 1073 987 1074 - return GPIO_LINE_DIRECTION_OUT; 988 + return GPIO_LINE_DIRECTION_IN; 1075 989 } 1076 990 1077 991 static int intel_gpio_direction_input(struct gpio_chip *chip, unsigned int offset) ··· 1257 1171 GPIOCHIP_IRQ_RESOURCE_HELPERS, 1258 1172 }; 1259 1173 1260 - static int intel_gpio_community_irq_handler(struct intel_pinctrl *pctrl, 1261 - const struct intel_community *community) 1174 + static irqreturn_t intel_gpio_irq(int irq, void *data) 1262 1175 { 1263 - struct gpio_chip *gc = &pctrl->chip; 1264 - unsigned int gpp; 1176 + const struct intel_community *community; 1177 + const struct intel_padgroup *padgrp; 1178 + struct intel_pinctrl *pctrl = data; 1265 1179 int ret = 0; 1266 1180 1267 - for (gpp = 0; gpp < community->ngpps; gpp++) { 1268 - const struct intel_padgroup *padgrp = &community->gpps[gpp]; 1181 + /* Need to check all communities for pending interrupts */ 1182 + for_each_intel_pad_group(pctrl, community, padgrp) { 1183 + struct gpio_chip *gc = &pctrl->chip; 1269 1184 unsigned long pending, enabled; 1270 1185 unsigned int gpp, gpp_offset; 1271 1186 void __iomem *reg, *is; ··· 1290 1203 ret += pending ? 1 : 0; 1291 1204 } 1292 1205 1293 - return ret; 1294 - } 1295 - 1296 - static irqreturn_t intel_gpio_irq(int irq, void *data) 1297 - { 1298 - const struct intel_community *community; 1299 - struct intel_pinctrl *pctrl = data; 1300 - unsigned int i; 1301 - int ret = 0; 1302 - 1303 - /* Need to check all communities for pending interrupts */ 1304 - for (i = 0; i < pctrl->ncommunities; i++) { 1305 - community = &pctrl->communities[i]; 1306 - ret += intel_gpio_community_irq_handler(pctrl, community); 1307 - } 1308 - 1309 1206 return IRQ_RETVAL(ret); 1310 1207 } 1311 1208 1312 1209 static void intel_gpio_irq_init(struct intel_pinctrl *pctrl) 1313 1210 { 1314 - int i; 1211 + const struct intel_community *community; 1315 1212 1316 - for (i = 0; i < pctrl->ncommunities; i++) { 1317 - const struct intel_community *community; 1213 + for_each_intel_pin_community(pctrl, community) { 1318 1214 void __iomem *reg, *is; 1319 1215 unsigned int gpp; 1320 - 1321 - community = &pctrl->communities[i]; 1322 1216 1323 1217 for (gpp = 0; gpp < community->ngpps; gpp++) { 1324 1218 reg = community->regs + community->ie_offset + gpp * 4; ··· 1325 1257 return 0; 1326 1258 } 1327 1259 1328 - static int intel_gpio_add_community_ranges(struct intel_pinctrl *pctrl, 1329 - const struct intel_community *community) 1330 - { 1331 - int ret = 0, i; 1332 - 1333 - for (i = 0; i < community->ngpps; i++) { 1334 - const struct intel_padgroup *gpp = &community->gpps[i]; 1335 - 1336 - if (gpp->gpio_base == INTEL_GPIO_BASE_NOMAP) 1337 - continue; 1338 - 1339 - ret = gpiochip_add_pin_range(&pctrl->chip, dev_name(pctrl->dev), 1340 - gpp->gpio_base, gpp->base, 1341 - gpp->size); 1342 - if (ret) 1343 - return ret; 1344 - } 1345 - 1346 - return ret; 1347 - } 1348 - 1349 1260 static int intel_gpio_add_pin_ranges(struct gpio_chip *gc) 1350 1261 { 1351 1262 struct intel_pinctrl *pctrl = gpiochip_get_data(gc); 1352 - int ret, i; 1263 + const struct intel_community *community; 1264 + const struct intel_padgroup *grp; 1265 + int ret; 1353 1266 1354 - for (i = 0; i < pctrl->ncommunities; i++) { 1355 - struct intel_community *community = &pctrl->communities[i]; 1356 - 1357 - ret = intel_gpio_add_community_ranges(pctrl, community); 1267 + for_each_intel_gpio_group(pctrl, community, grp) { 1268 + ret = gpiochip_add_pin_range(&pctrl->chip, dev_name(pctrl->dev), 1269 + grp->gpio_base, grp->base, 1270 + grp->size); 1358 1271 if (ret) { 1359 1272 dev_err(pctrl->dev, "failed to add GPIO pin range\n"); 1360 1273 return ret; ··· 1348 1299 static unsigned int intel_gpio_ngpio(const struct intel_pinctrl *pctrl) 1349 1300 { 1350 1301 const struct intel_community *community; 1302 + const struct intel_padgroup *grp; 1351 1303 unsigned int ngpio = 0; 1352 - int i, j; 1353 1304 1354 - for (i = 0; i < pctrl->ncommunities; i++) { 1355 - community = &pctrl->communities[i]; 1356 - for (j = 0; j < community->ngpps; j++) { 1357 - const struct intel_padgroup *gpp = &community->gpps[j]; 1358 - 1359 - if (gpp->gpio_base == INTEL_GPIO_BASE_NOMAP) 1360 - continue; 1361 - 1362 - if (gpp->gpio_base + gpp->size > ngpio) 1363 - ngpio = gpp->gpio_base + gpp->size; 1364 - } 1305 + for_each_intel_gpio_group(pctrl, community, grp) { 1306 + if (grp->gpio_base + grp->size > ngpio) 1307 + ngpio = grp->gpio_base + grp->size; 1365 1308 } 1366 1309 1367 1310 return ngpio; ··· 1723 1682 1724 1683 static bool __intel_gpio_is_direct_irq(u32 value) 1725 1684 { 1726 - return (value & PADCFG0_GPIROUTIOXAPIC) && (value & PADCFG0_GPIOTXDIS) && 1685 + return (value & PADCFG0_GPIROUTIOXAPIC) && 1686 + (__intel_gpio_get_direction(value) == PAD_CONNECT_INPUT) && 1727 1687 (__intel_gpio_get_gpio_mode(value) == PADCFG0_PMODE_GPIO); 1728 1688 } 1729 1689
+2 -1
drivers/pinctrl/intel/pinctrl-intel.h
··· 264 264 265 265 extern const struct dev_pm_ops intel_pinctrl_pm_ops; 266 266 267 - struct intel_community *intel_get_community(struct intel_pinctrl *pctrl, unsigned int pin); 267 + const struct intel_community *intel_get_community(const struct intel_pinctrl *pctrl, 268 + unsigned int pin); 268 269 269 270 int intel_get_groups_count(struct pinctrl_dev *pctldev); 270 271 const char *intel_get_group_name(struct pinctrl_dev *pctldev, unsigned int group);
+1 -1
drivers/pinctrl/intel/pinctrl-lynxpoint.c
··· 211 211 int reg) 212 212 { 213 213 struct intel_pinctrl *lg = gpiochip_get_data(chip); 214 - struct intel_community *comm; 214 + const struct intel_community *comm; 215 215 int reg_offset; 216 216 217 217 comm = intel_get_community(lg, offset);