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

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'intel-pinctrl-v5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/pinctrl/intel into devel

intel-pinctrl for v5.4

A collection of improvements and fixes for Intel pinctrl drivers
including:

- Converting drivers to use new devm_platform_ioremap_resource()
helper function.

- Make Interrupt Status (IS) register configurable.

- Allow locked pins to be requested and used as long as they are not
modified.

- Fix intel_pinctrl_should_save() to translate pin number to GPIO
number where needed. This fixes Asus X571GT touchpad
unresponsiveness issue after suspend/resume cycle.

+156 -119
+23 -44
drivers/pinctrl/intel/pinctrl-baytrail.c
··· 98 98 u32 val; 99 99 }; 100 100 101 - struct byt_community { 102 - unsigned int pin_base; 103 - size_t npins; 104 - const unsigned int *pad_map; 105 - void __iomem *reg_base; 106 - }; 107 - 108 101 #define COMMUNITY(p, n, map) \ 109 102 { \ 110 103 .pin_base = (p), \ ··· 105 112 .pad_map = (map),\ 106 113 } 107 114 108 - struct byt_pinctrl_soc_data { 109 - const char *uid; 110 - const struct pinctrl_pin_desc *pins; 111 - size_t npins; 112 - const struct intel_pingroup *groups; 113 - size_t ngroups; 114 - const struct intel_function *functions; 115 - size_t nfunctions; 116 - const struct byt_community *communities; 117 - size_t ncommunities; 118 - }; 119 - 120 115 struct byt_gpio { 121 116 struct gpio_chip chip; 122 117 struct platform_device *pdev; 123 118 struct pinctrl_dev *pctl_dev; 124 119 struct pinctrl_desc pctl_desc; 125 120 raw_spinlock_t lock; 126 - const struct byt_pinctrl_soc_data *soc_data; 127 - struct byt_community *communities_copy; 121 + const struct intel_pinctrl_soc_data *soc_data; 122 + struct intel_community *communities_copy; 128 123 struct byt_gpio_pin_context *saved_context; 129 124 }; 130 125 ··· 364 383 FUNCTION("gpio", byt_score_gpio_groups), 365 384 }; 366 385 367 - static const struct byt_community byt_score_communities[] = { 386 + static const struct intel_community byt_score_communities[] = { 368 387 COMMUNITY(0, BYT_NGPIO_SCORE, byt_score_pins_map), 369 388 }; 370 389 371 - static const struct byt_pinctrl_soc_data byt_score_soc_data = { 390 + static const struct intel_pinctrl_soc_data byt_score_soc_data = { 372 391 .uid = BYT_SCORE_ACPI_UID, 373 392 .pins = byt_score_pins, 374 393 .npins = ARRAY_SIZE(byt_score_pins), ··· 477 496 FUNCTION("gpio", byt_sus_gpio_groups), 478 497 }; 479 498 480 - static const struct byt_community byt_sus_communities[] = { 499 + static const struct intel_community byt_sus_communities[] = { 481 500 COMMUNITY(0, BYT_NGPIO_SUS, byt_sus_pins_map), 482 501 }; 483 502 484 - static const struct byt_pinctrl_soc_data byt_sus_soc_data = { 503 + static const struct intel_pinctrl_soc_data byt_sus_soc_data = { 485 504 .uid = BYT_SUS_ACPI_UID, 486 505 .pins = byt_sus_pins, 487 506 .npins = ARRAY_SIZE(byt_sus_pins), ··· 530 549 3, 6, 10, 13, 2, 5, 9, 7, 531 550 }; 532 551 533 - static const struct byt_community byt_ncore_communities[] = { 552 + static const struct intel_community byt_ncore_communities[] = { 534 553 COMMUNITY(0, BYT_NGPIO_NCORE, byt_ncore_pins_map), 535 554 }; 536 555 537 - static const struct byt_pinctrl_soc_data byt_ncore_soc_data = { 556 + static const struct intel_pinctrl_soc_data byt_ncore_soc_data = { 538 557 .uid = BYT_NCORE_ACPI_UID, 539 558 .pins = byt_ncore_pins, 540 559 .npins = ARRAY_SIZE(byt_ncore_pins), ··· 542 561 .ncommunities = ARRAY_SIZE(byt_ncore_communities), 543 562 }; 544 563 545 - static const struct byt_pinctrl_soc_data *byt_soc_data[] = { 564 + static const struct intel_pinctrl_soc_data *byt_soc_data[] = { 546 565 &byt_score_soc_data, 547 566 &byt_sus_soc_data, 548 567 &byt_ncore_soc_data, 549 568 NULL 550 569 }; 551 570 552 - static struct byt_community *byt_get_community(struct byt_gpio *vg, 553 - unsigned int pin) 571 + static struct intel_community *byt_get_community(struct byt_gpio *vg, 572 + unsigned int pin) 554 573 { 555 - struct byt_community *comm; 574 + struct intel_community *comm; 556 575 int i; 557 576 558 577 for (i = 0; i < vg->soc_data->ncommunities; i++) { ··· 567 586 static void __iomem *byt_gpio_reg(struct byt_gpio *vg, unsigned int offset, 568 587 int reg) 569 588 { 570 - struct byt_community *comm = byt_get_community(vg, offset); 589 + struct intel_community *comm = byt_get_community(vg, offset); 571 590 u32 reg_offset; 572 591 573 592 if (!comm) ··· 586 605 break; 587 606 } 588 607 589 - return comm->reg_base + reg_offset + reg; 608 + return comm->pad_regs + reg_offset + reg; 590 609 } 591 610 592 611 static int byt_get_groups_count(struct pinctrl_dev *pctldev) ··· 1192 1211 u32 conf0, val; 1193 1212 1194 1213 for (i = 0; i < vg->soc_data->npins; i++) { 1195 - const struct byt_community *comm; 1214 + const struct intel_community *comm; 1196 1215 const char *pull_str = NULL; 1197 1216 const char *pull = NULL; 1198 1217 void __iomem *reg; ··· 1547 1566 } 1548 1567 1549 1568 static int byt_set_soc_data(struct byt_gpio *vg, 1550 - const struct byt_pinctrl_soc_data *soc_data) 1569 + const struct intel_pinctrl_soc_data *soc_data) 1551 1570 { 1552 1571 int i; 1553 1572 ··· 1560 1579 return -ENOMEM; 1561 1580 1562 1581 for (i = 0; i < soc_data->ncommunities; i++) { 1563 - struct byt_community *comm = vg->communities_copy + i; 1564 - struct resource *mem_rc; 1582 + struct intel_community *comm = vg->communities_copy + i; 1565 1583 1566 1584 *comm = vg->soc_data->communities[i]; 1567 1585 1568 - mem_rc = platform_get_resource(vg->pdev, IORESOURCE_MEM, 0); 1569 - comm->reg_base = devm_ioremap_resource(&vg->pdev->dev, mem_rc); 1570 - if (IS_ERR(comm->reg_base)) 1571 - return PTR_ERR(comm->reg_base); 1586 + comm->pad_regs = devm_platform_ioremap_resource(vg->pdev, 0); 1587 + if (IS_ERR(comm->pad_regs)) 1588 + return PTR_ERR(comm->pad_regs); 1572 1589 } 1573 1590 1574 1591 return 0; ··· 1580 1601 1581 1602 static int byt_pinctrl_probe(struct platform_device *pdev) 1582 1603 { 1583 - const struct byt_pinctrl_soc_data *soc_data = NULL; 1584 - const struct byt_pinctrl_soc_data **soc_table; 1604 + const struct intel_pinctrl_soc_data *soc_data = NULL; 1605 + const struct intel_pinctrl_soc_data **soc_table; 1585 1606 struct acpi_device *acpi_dev; 1586 1607 struct byt_gpio *vg; 1587 1608 int i, ret; ··· 1590 1611 if (!acpi_dev) 1591 1612 return -ENODEV; 1592 1613 1593 - soc_table = (const struct byt_pinctrl_soc_data **)device_get_match_data(&pdev->dev); 1614 + soc_table = (const struct intel_pinctrl_soc_data **)device_get_match_data(&pdev->dev); 1594 1615 1595 1616 for (i = 0; soc_table[i]; i++) { 1596 1617 if (!strcmp(acpi_dev->pnp.unique_id, soc_table[i]->uid)) {
+3 -1
drivers/pinctrl/intel/pinctrl-broxton.c
··· 15 15 #include "pinctrl-intel.h" 16 16 17 17 #define BXT_PAD_OWN 0x020 18 - #define BXT_HOSTSW_OWN 0x080 19 18 #define BXT_PADCFGLOCK 0x060 19 + #define BXT_HOSTSW_OWN 0x080 20 + #define BXT_GPI_IS 0x100 20 21 #define BXT_GPI_IE 0x110 21 22 22 23 #define BXT_COMMUNITY(s, e) \ ··· 25 24 .padown_offset = BXT_PAD_OWN, \ 26 25 .padcfglock_offset = BXT_PADCFGLOCK, \ 27 26 .hostown_offset = BXT_HOSTSW_OWN, \ 27 + .is_offset = BXT_GPI_IS, \ 28 28 .ie_offset = BXT_GPI_IE, \ 29 29 .gpp_size = 32, \ 30 30 .pin_base = (s), \
+2
drivers/pinctrl/intel/pinctrl-cannonlake.c
··· 19 19 #define CNL_PADCFGLOCK 0x080 20 20 #define CNL_LP_HOSTSW_OWN 0x0b0 21 21 #define CNL_H_HOSTSW_OWN 0x0c0 22 + #define CNL_GPI_IS 0x100 22 23 #define CNL_GPI_IE 0x120 23 24 24 25 #define CNL_GPP(r, s, e, g) \ ··· 38 37 .padown_offset = CNL_PAD_OWN, \ 39 38 .padcfglock_offset = CNL_PADCFGLOCK, \ 40 39 .hostown_offset = (o), \ 40 + .is_offset = CNL_GPI_IS, \ 41 41 .ie_offset = CNL_GPI_IE, \ 42 42 .pin_base = (s), \ 43 43 .npins = ((e) - (s) + 1), \
+2 -6
drivers/pinctrl/intel/pinctrl-cherryview.c
··· 1667 1667 { 1668 1668 struct chv_pinctrl *pctrl; 1669 1669 struct acpi_device *adev; 1670 - struct resource *res; 1671 1670 acpi_status status; 1672 1671 int ret, irq, i; 1673 1672 ··· 1696 1697 return -ENOMEM; 1697 1698 #endif 1698 1699 1699 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1700 - pctrl->regs = devm_ioremap_resource(&pdev->dev, res); 1700 + pctrl->regs = devm_platform_ioremap_resource(pdev, 0); 1701 1701 if (IS_ERR(pctrl->regs)) 1702 1702 return PTR_ERR(pctrl->regs); 1703 1703 1704 1704 irq = platform_get_irq(pdev, 0); 1705 - if (irq < 0) { 1706 - dev_err(&pdev->dev, "failed to get interrupt number\n"); 1705 + if (irq < 0) 1707 1706 return irq; 1708 - } 1709 1707 1710 1708 pctrl->pctldesc = chv_pinctrl_desc; 1711 1709 pctrl->pctldesc.name = dev_name(&pdev->dev);
+28 -25
drivers/pinctrl/intel/pinctrl-denverton.c
··· 15 15 #include "pinctrl-intel.h" 16 16 17 17 #define DNV_PAD_OWN 0x020 18 - #define DNV_HOSTSW_OWN 0x0C0 19 18 #define DNV_PADCFGLOCK 0x090 19 + #define DNV_HOSTSW_OWN 0x0C0 20 + #define DNV_GPI_IS 0x100 20 21 #define DNV_GPI_IE 0x120 21 22 22 23 #define DNV_GPP(n, s, e) \ ··· 33 32 .padown_offset = DNV_PAD_OWN, \ 34 33 .padcfglock_offset = DNV_PADCFGLOCK, \ 35 34 .hostown_offset = DNV_HOSTSW_OWN, \ 35 + .is_offset = DNV_GPI_IS, \ 36 36 .ie_offset = DNV_GPI_IE, \ 37 37 .pin_base = (s), \ 38 38 .npins = ((e) - (s) + 1), \ ··· 41 39 .ngpps = ARRAY_SIZE(g), \ 42 40 } 43 41 42 + /* Denverton */ 44 43 static const struct pinctrl_pin_desc dnv_pins[] = { 45 44 /* North ALL */ 46 45 PINCTRL_PIN(0, "GBE0_SDP0"), ··· 62 59 PINCTRL_PIN(15, "NCSI_CLK_IN"), 63 60 PINCTRL_PIN(16, "NCSI_RXD1"), 64 61 PINCTRL_PIN(17, "NCSI_CRS_DV"), 65 - PINCTRL_PIN(18, "NCSI_ARB_IN"), 62 + PINCTRL_PIN(18, "IDSLDO_VID_TICKLE"), 66 63 PINCTRL_PIN(19, "NCSI_TX_EN"), 67 64 PINCTRL_PIN(20, "NCSI_TXD0"), 68 65 PINCTRL_PIN(21, "NCSI_TXD1"), ··· 71 68 PINCTRL_PIN(24, "GBE0_LED1"), 72 69 PINCTRL_PIN(25, "GBE1_LED0"), 73 70 PINCTRL_PIN(26, "GBE1_LED1"), 74 - PINCTRL_PIN(27, "GPIO_0"), 71 + PINCTRL_PIN(27, "SPARE_0"), 75 72 PINCTRL_PIN(28, "PCIE_CLKREQ0_N"), 76 73 PINCTRL_PIN(29, "PCIE_CLKREQ1_N"), 77 74 PINCTRL_PIN(30, "PCIE_CLKREQ2_N"), 78 75 PINCTRL_PIN(31, "PCIE_CLKREQ3_N"), 79 76 PINCTRL_PIN(32, "PCIE_CLKREQ4_N"), 80 - PINCTRL_PIN(33, "GPIO_1"), 81 - PINCTRL_PIN(34, "GPIO_2"), 77 + PINCTRL_PIN(33, "GBE_MDC"), 78 + PINCTRL_PIN(34, "GBE_MDIO"), 82 79 PINCTRL_PIN(35, "SVID_ALERT_N"), 83 80 PINCTRL_PIN(36, "SVID_DATA"), 84 81 PINCTRL_PIN(37, "SVID_CLK"), ··· 105 102 PINCTRL_PIN(57, "DFX_PORT14"), 106 103 PINCTRL_PIN(58, "DFX_PORT15"), 107 104 /* South GPP0 */ 108 - PINCTRL_PIN(59, "GPIO_12"), 109 - PINCTRL_PIN(60, "SMB5_GBE_ALRT_N"), 105 + PINCTRL_PIN(59, "SPI_TPM_CS_N"), 106 + PINCTRL_PIN(60, "UART2_CTS"), 110 107 PINCTRL_PIN(61, "PCIE_CLKREQ5_N"), 111 108 PINCTRL_PIN(62, "PCIE_CLKREQ6_N"), 112 109 PINCTRL_PIN(63, "PCIE_CLKREQ7_N"), 113 110 PINCTRL_PIN(64, "UART0_RXD"), 114 111 PINCTRL_PIN(65, "UART0_TXD"), 115 - PINCTRL_PIN(66, "SMB5_GBE_CLK"), 116 - PINCTRL_PIN(67, "SMB5_GBE_DATA"), 112 + PINCTRL_PIN(66, "CPU_RESET_N"), 113 + PINCTRL_PIN(67, "NMI"), 117 114 PINCTRL_PIN(68, "ERROR2_N"), 118 115 PINCTRL_PIN(69, "ERROR1_N"), 119 116 PINCTRL_PIN(70, "ERROR0_N"), ··· 132 129 PINCTRL_PIN(83, "USB_OC0_N"), 133 130 PINCTRL_PIN(84, "FLEX_CLK_SE0"), 134 131 PINCTRL_PIN(85, "FLEX_CLK_SE1"), 135 - PINCTRL_PIN(86, "GPIO_4"), 136 - PINCTRL_PIN(87, "GPIO_5"), 137 - PINCTRL_PIN(88, "GPIO_6"), 138 - PINCTRL_PIN(89, "GPIO_7"), 132 + PINCTRL_PIN(86, "SPARE_4"), 133 + PINCTRL_PIN(87, "SMB3_IE0_CLK"), 134 + PINCTRL_PIN(88, "SMB3_IE0_DATA"), 135 + PINCTRL_PIN(89, "SMB3_IE0_ALRT_N"), 139 136 PINCTRL_PIN(90, "SATA0_LED_N"), 140 137 PINCTRL_PIN(91, "SATA1_LED_N"), 141 138 PINCTRL_PIN(92, "SATA_PDETECT0"), 142 139 PINCTRL_PIN(93, "SATA_PDETECT1"), 143 - PINCTRL_PIN(94, "SATA0_SDOUT"), 144 - PINCTRL_PIN(95, "SATA1_SDOUT"), 140 + PINCTRL_PIN(94, "UART1_RTS"), 141 + PINCTRL_PIN(95, "UART1_CTS"), 145 142 PINCTRL_PIN(96, "UART1_RXD"), 146 143 PINCTRL_PIN(97, "UART1_TXD"), 147 - PINCTRL_PIN(98, "GPIO_8"), 148 - PINCTRL_PIN(99, "GPIO_9"), 144 + PINCTRL_PIN(98, "SPARE_8"), 145 + PINCTRL_PIN(99, "SPARE_9"), 149 146 PINCTRL_PIN(100, "TCK"), 150 147 PINCTRL_PIN(101, "TRST_N"), 151 148 PINCTRL_PIN(102, "TMS"), ··· 153 150 PINCTRL_PIN(104, "TDO"), 154 151 PINCTRL_PIN(105, "CX_PRDY_N"), 155 152 PINCTRL_PIN(106, "CX_PREQ_N"), 156 - PINCTRL_PIN(107, "CTBTRIGINOUT"), 157 - PINCTRL_PIN(108, "CTBTRIGOUT"), 158 - PINCTRL_PIN(109, "DFX_SPARE2"), 159 - PINCTRL_PIN(110, "DFX_SPARE3"), 160 - PINCTRL_PIN(111, "DFX_SPARE4"), 153 + PINCTRL_PIN(107, "TAP1_TCK"), 154 + PINCTRL_PIN(108, "TAP1_TRST_N"), 155 + PINCTRL_PIN(109, "TAP1_TMS"), 156 + PINCTRL_PIN(110, "TAP1_TDI"), 157 + PINCTRL_PIN(111, "TAP1_TDO"), 161 158 /* South GPP1 */ 162 159 PINCTRL_PIN(112, "SUSPWRDNACK"), 163 160 PINCTRL_PIN(113, "PMU_SUSCLK"), ··· 186 183 PINCTRL_PIN(136, "ESPI_CLK"), 187 184 PINCTRL_PIN(137, "ESPI_RST_N"), 188 185 PINCTRL_PIN(138, "ESPI_ALRT0_N"), 189 - PINCTRL_PIN(139, "GPIO_10"), 190 - PINCTRL_PIN(140, "GPIO_11"), 186 + PINCTRL_PIN(139, "ESPI_CS1_N"), 187 + PINCTRL_PIN(140, "ESPI_ALRT1_N"), 191 188 PINCTRL_PIN(141, "ESPI_CLK_LOOPBK"), 192 189 PINCTRL_PIN(142, "EMMC_CMD"), 193 190 PINCTRL_PIN(143, "EMMC_STROBE"), ··· 200 197 PINCTRL_PIN(150, "EMMC_D5"), 201 198 PINCTRL_PIN(151, "EMMC_D6"), 202 199 PINCTRL_PIN(152, "EMMC_D7"), 203 - PINCTRL_PIN(153, "GPIO_3"), 200 + PINCTRL_PIN(153, "SPARE_3"), 204 201 }; 205 202 206 203 static const unsigned int dnv_uart0_pins[] = { 60, 61, 64, 65 };
+2
drivers/pinctrl/intel/pinctrl-geminilake.c
··· 17 17 #define GLK_PAD_OWN 0x020 18 18 #define GLK_PADCFGLOCK 0x080 19 19 #define GLK_HOSTSW_OWN 0x0b0 20 + #define GLK_GPI_IS 0x100 20 21 #define GLK_GPI_IE 0x110 21 22 22 23 #define GLK_COMMUNITY(s, e) \ ··· 25 24 .padown_offset = GLK_PAD_OWN, \ 26 25 .padcfglock_offset = GLK_PADCFGLOCK, \ 27 26 .hostown_offset = GLK_HOSTSW_OWN, \ 27 + .is_offset = GLK_GPI_IS, \ 28 28 .ie_offset = GLK_GPI_IE, \ 29 29 .gpp_size = 32, \ 30 30 .pin_base = (s), \
+2
drivers/pinctrl/intel/pinctrl-icelake.c
··· 18 18 #define ICL_PAD_OWN 0x020 19 19 #define ICL_PADCFGLOCK 0x080 20 20 #define ICL_HOSTSW_OWN 0x0b0 21 + #define ICL_GPI_IS 0x100 21 22 #define ICL_GPI_IE 0x110 22 23 23 24 #define ICL_GPP(r, s, e, g) \ ··· 37 36 .padown_offset = ICL_PAD_OWN, \ 38 37 .padcfglock_offset = ICL_PADCFGLOCK, \ 39 38 .hostown_offset = ICL_HOSTSW_OWN, \ 39 + .is_offset = ICL_GPI_IS, \ 40 40 .ie_offset = ICL_GPI_IE, \ 41 41 .pin_base = (s), \ 42 42 .npins = ((e) - (s) + 1), \
+84 -36
drivers/pinctrl/intel/pinctrl-intel.c
··· 8 8 */ 9 9 10 10 #include <linux/acpi.h> 11 - #include <linux/module.h> 12 11 #include <linux/interrupt.h> 13 12 #include <linux/gpio/driver.h> 14 13 #include <linux/log2.h> 14 + #include <linux/module.h> 15 15 #include <linux/platform_device.h> 16 16 #include <linux/property.h> 17 + #include <linux/time.h> 17 18 18 19 #include <linux/pinctrl/pinctrl.h> 19 20 #include <linux/pinctrl/pinmux.h> ··· 30 29 #define REVID_MASK GENMASK(31, 16) 31 30 32 31 #define PADBAR 0x00c 33 - #define GPI_IS 0x100 34 32 35 33 #define PADOWN_BITS 4 36 34 #define PADOWN_SHIFT(p) ((p) % 8 * PADOWN_BITS) ··· 71 71 #define PADCFG2_DEBOUNCE_SHIFT 1 72 72 #define PADCFG2_DEBOUNCE_MASK GENMASK(4, 1) 73 73 74 - #define DEBOUNCE_PERIOD 31250 /* ns */ 74 + #define DEBOUNCE_PERIOD_NSEC 31250 75 75 76 76 struct intel_pad_context { 77 77 u32 padcfg0; ··· 165 165 padno = pin_to_padno(community, pin); 166 166 nregs = (community->features & PINCTRL_FEATURE_DEBOUNCE) ? 4 : 2; 167 167 168 - if (reg == PADCFG2 && !(community->features & PINCTRL_FEATURE_DEBOUNCE)) 168 + if (reg >= nregs * 4) 169 169 return NULL; 170 170 171 171 return community->pad_regs + reg + padno * nregs * 4; ··· 220 220 return !(readl(hostown) & BIT(gpp_offset)); 221 221 } 222 222 223 - static bool intel_pad_locked(struct intel_pinctrl *pctrl, unsigned int pin) 223 + /** 224 + * enum - Locking variants of the pad configuration 225 + * 226 + * @PAD_UNLOCKED: pad is fully controlled by the configuration registers 227 + * @PAD_LOCKED: pad configuration registers, except TX state, are locked 228 + * @PAD_LOCKED_TX: pad configuration TX state is locked 229 + * @PAD_LOCKED_FULL: pad configuration registers are locked completely 230 + * 231 + * Locking is considered as read-only mode for corresponding registers and 232 + * their respective fields. That said, TX state bit is locked separately from 233 + * the main locking scheme. 234 + */ 235 + enum { 236 + PAD_UNLOCKED = 0, 237 + PAD_LOCKED = 1, 238 + PAD_LOCKED_TX = 2, 239 + PAD_LOCKED_FULL = PAD_LOCKED | PAD_LOCKED_TX, 240 + }; 241 + 242 + static int intel_pad_locked(struct intel_pinctrl *pctrl, unsigned int pin) 224 243 { 225 244 struct intel_community *community; 226 245 const struct intel_padgroup *padgrp; 227 246 unsigned int offset, gpp_offset; 228 247 u32 value; 248 + int ret = PAD_UNLOCKED; 229 249 230 250 community = intel_get_community(pctrl, pin); 231 251 if (!community) 232 - return true; 252 + return PAD_LOCKED_FULL; 233 253 if (!community->padcfglock_offset) 234 - return false; 254 + return PAD_UNLOCKED; 235 255 236 256 padgrp = intel_community_get_padgroup(community, pin); 237 257 if (!padgrp) 238 - return true; 258 + return PAD_LOCKED_FULL; 239 259 240 260 gpp_offset = padgroup_offset(padgrp, pin); 241 261 242 262 /* 243 263 * If PADCFGLOCK and PADCFGLOCKTX bits are both clear for this pad, 244 264 * the pad is considered unlocked. Any other case means that it is 245 - * either fully or partially locked and we don't touch it. 265 + * either fully or partially locked. 246 266 */ 247 - offset = community->padcfglock_offset + padgrp->reg_num * 8; 267 + offset = community->padcfglock_offset + 0 + padgrp->reg_num * 8; 248 268 value = readl(community->regs + offset); 249 269 if (value & BIT(gpp_offset)) 250 - return true; 270 + ret |= PAD_LOCKED; 251 271 252 272 offset = community->padcfglock_offset + 4 + padgrp->reg_num * 8; 253 273 value = readl(community->regs + offset); 254 274 if (value & BIT(gpp_offset)) 255 - return true; 275 + ret |= PAD_LOCKED_TX; 256 276 257 - return false; 277 + return ret; 278 + } 279 + 280 + static bool intel_pad_is_unlocked(struct intel_pinctrl *pctrl, unsigned int pin) 281 + { 282 + return (intel_pad_locked(pctrl, pin) & PAD_LOCKED) == PAD_UNLOCKED; 258 283 } 259 284 260 285 static bool intel_pad_usable(struct intel_pinctrl *pctrl, unsigned int pin) 261 286 { 262 - return intel_pad_owned_by_host(pctrl, pin) && 263 - !intel_pad_locked(pctrl, pin); 287 + return intel_pad_owned_by_host(pctrl, pin) && intel_pad_is_unlocked(pctrl, pin); 264 288 } 265 289 266 290 static int intel_get_groups_count(struct pinctrl_dev *pctldev) ··· 318 294 struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 319 295 void __iomem *padcfg; 320 296 u32 cfg0, cfg1, mode; 321 - bool locked, acpi; 297 + int locked; 298 + bool acpi; 322 299 323 300 if (!intel_pad_owned_by_host(pctrl, pin)) { 324 301 seq_puts(s, "not available"); ··· 347 322 348 323 if (locked || acpi) { 349 324 seq_puts(s, " ["); 350 - if (locked) { 325 + if (locked) 351 326 seq_puts(s, "LOCKED"); 352 - if (acpi) 353 - seq_puts(s, ", "); 354 - } 327 + if ((locked & PAD_LOCKED_FULL) == PAD_LOCKED_TX) 328 + seq_puts(s, " tx"); 329 + else if ((locked & PAD_LOCKED_FULL) == PAD_LOCKED_FULL) 330 + seq_puts(s, " full"); 331 + 332 + if (locked && acpi) 333 + seq_puts(s, ", "); 334 + 355 335 if (acpi) 356 336 seq_puts(s, "ACPI"); 357 337 seq_puts(s, "]"); ··· 478 448 479 449 raw_spin_lock_irqsave(&pctrl->lock, flags); 480 450 481 - if (!intel_pad_usable(pctrl, pin)) { 451 + if (!intel_pad_owned_by_host(pctrl, pin)) { 482 452 raw_spin_unlock_irqrestore(&pctrl->lock, flags); 483 453 return -EBUSY; 454 + } 455 + 456 + if (!intel_pad_is_unlocked(pctrl, pin)) { 457 + raw_spin_unlock_irqrestore(&pctrl->lock, flags); 458 + return 0; 484 459 } 485 460 486 461 padcfg0 = intel_get_padcfg(pctrl, pin, PADCFG0); ··· 601 566 return -EINVAL; 602 567 603 568 v = (v & PADCFG2_DEBOUNCE_MASK) >> PADCFG2_DEBOUNCE_SHIFT; 604 - arg = BIT(v) * DEBOUNCE_PERIOD / 1000; 569 + arg = BIT(v) * DEBOUNCE_PERIOD_NSEC / NSEC_PER_USEC; 605 570 606 571 break; 607 572 } ··· 718 683 if (debounce) { 719 684 unsigned long v; 720 685 721 - v = order_base_2(debounce * 1000 / DEBOUNCE_PERIOD); 686 + v = order_base_2(debounce * NSEC_PER_USEC / DEBOUNCE_PERIOD_NSEC); 722 687 if (v < 3 || v > 15) { 723 688 ret = -EINVAL; 724 689 goto exit_unlock; ··· 829 794 } 830 795 831 796 return -EINVAL; 797 + } 798 + 799 + /** 800 + * intel_pin_to_gpio() - Translate from pin number to GPIO offset 801 + * @pctrl: Pinctrl structure 802 + * @pin: pin number 803 + * 804 + * Translate the pin number of pinctrl to GPIO offset 805 + */ 806 + static int intel_pin_to_gpio(struct intel_pinctrl *pctrl, int pin) 807 + { 808 + const struct intel_community *community; 809 + const struct intel_padgroup *padgrp; 810 + 811 + community = intel_get_community(pctrl, pin); 812 + if (!community) 813 + return -EINVAL; 814 + 815 + padgrp = intel_community_get_padgroup(community, pin); 816 + if (!padgrp) 817 + return -EINVAL; 818 + 819 + return pin - padgrp->base + padgrp->gpio_base; 832 820 } 833 821 834 822 static int intel_gpio_get(struct gpio_chip *chip, unsigned int offset) ··· 1371 1313 1372 1314 for (i = 0; i < pctrl->ncommunities; i++) { 1373 1315 struct intel_community *community = &pctrl->communities[i]; 1374 - struct resource *res; 1375 1316 void __iomem *regs; 1376 1317 u32 padbar; 1377 1318 1378 1319 *community = pctrl->soc->communities[i]; 1379 1320 1380 - res = platform_get_resource(pdev, IORESOURCE_MEM, 1381 - community->barno); 1382 - regs = devm_ioremap_resource(&pdev->dev, res); 1321 + regs = devm_platform_ioremap_resource(pdev, community->barno); 1383 1322 if (IS_ERR(regs)) 1384 1323 return PTR_ERR(regs); 1385 1324 ··· 1400 1345 community->regs = regs; 1401 1346 community->pad_regs = regs + padbar; 1402 1347 1403 - if (!community->is_offset) 1404 - community->is_offset = GPI_IS; 1405 - 1406 1348 ret = intel_pinctrl_add_padgroups(pctrl, community); 1407 1349 if (ret) 1408 1350 return ret; 1409 1351 } 1410 1352 1411 1353 irq = platform_get_irq(pdev, 0); 1412 - if (irq < 0) { 1413 - dev_err(&pdev->dev, "failed to get interrupt number\n"); 1354 + if (irq < 0) 1414 1355 return irq; 1415 - } 1416 1356 1417 1357 ret = intel_pinctrl_pm_init(pctrl); 1418 1358 if (ret) ··· 1471 1421 table = (const struct intel_pinctrl_soc_data **)id->driver_data; 1472 1422 data = table[pdev->id]; 1473 1423 } 1474 - if (!data) 1475 - return -ENODEV; 1476 1424 1477 1425 return intel_pinctrl_probe(pdev, data); 1478 1426 } ··· 1491 1443 * them alone. 1492 1444 */ 1493 1445 if (pd->mux_owner || pd->gpio_owner || 1494 - gpiochip_line_is_irq(&pctrl->chip, pin)) 1446 + gpiochip_line_is_irq(&pctrl->chip, intel_pin_to_gpio(pctrl, pin))) 1495 1447 return true; 1496 1448 1497 1449 return false;
+5 -4
drivers/pinctrl/intel/pinctrl-intel.h
··· 75 75 * @hostown_offset: Register offset of HOSTSW_OWN from @regs. If %0 then it 76 76 * is assumed that the host owns the pin (rather than 77 77 * ACPI). 78 - * @is_offset: Register offset of GPI_IS from @regs. If %0 then uses the 79 - * default (%0x100). 78 + * @is_offset: Register offset of GPI_IS from @regs. 80 79 * @ie_offset: Register offset of GPI_IE from @regs. 80 + * @features: Additional features supported by the hardware 81 81 * @pin_base: Starting pin of pins in this community 82 82 * @gpp_size: Maximum number of pads in each group, such as PADCFGLOCK, 83 83 * HOSTSW_OWN, GPI_IS, GPI_IE, etc. Used when @gpps is %NULL. ··· 85 85 * minimum. Use %0 if the number of registers can be 86 86 * determined by the size of the group. 87 87 * @npins: Number of pins in this community 88 - * @features: Additional features supported by the hardware 89 88 * @gpps: Pad groups if the controller has variable size pad groups 90 89 * @ngpps: Number of pad groups in this community 90 + * @pad_map: Optional non-linear mapping of the pads 91 91 * @regs: Community specific common registers (reserved for core driver) 92 92 * @pad_regs: Community specific pad registers (reserved for core driver) 93 93 * ··· 104 104 unsigned int hostown_offset; 105 105 unsigned int is_offset; 106 106 unsigned int ie_offset; 107 + unsigned int features; 107 108 unsigned int pin_base; 108 109 unsigned int gpp_size; 109 110 unsigned int gpp_num_padown_regs; 110 111 size_t npins; 111 - unsigned int features; 112 112 const struct intel_padgroup *gpps; 113 113 size_t ngpps; 114 + const unsigned int *pad_map; 114 115 /* Reserved for the core driver */ 115 116 void __iomem *regs; 116 117 void __iomem *pad_regs;
+2
drivers/pinctrl/intel/pinctrl-lewisburg.c
··· 17 17 #define LBG_PAD_OWN 0x020 18 18 #define LBG_PADCFGLOCK 0x060 19 19 #define LBG_HOSTSW_OWN 0x080 20 + #define LBG_GPI_IS 0x100 20 21 #define LBG_GPI_IE 0x110 21 22 22 23 #define LBG_COMMUNITY(b, s, e) \ ··· 26 25 .padown_offset = LBG_PAD_OWN, \ 27 26 .padcfglock_offset = LBG_PADCFGLOCK, \ 28 27 .hostown_offset = LBG_HOSTSW_OWN, \ 28 + .is_offset = LBG_GPI_IS, \ 29 29 .ie_offset = LBG_GPI_IE, \ 30 30 .gpp_size = 24, \ 31 31 .pin_base = (s), \
+1 -3
drivers/pinctrl/intel/pinctrl-merrifield.c
··· 885 885 { 886 886 struct mrfld_family *families; 887 887 struct mrfld_pinctrl *mp; 888 - struct resource *mem; 889 888 void __iomem *regs; 890 889 size_t nfamilies; 891 890 unsigned int i; ··· 896 897 mp->dev = &pdev->dev; 897 898 raw_spin_lock_init(&mp->lock); 898 899 899 - mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 900 - regs = devm_ioremap_resource(&pdev->dev, mem); 900 + regs = devm_platform_ioremap_resource(pdev, 0); 901 901 if (IS_ERR(regs)) 902 902 return PTR_ERR(regs); 903 903
+2
drivers/pinctrl/intel/pinctrl-sunrisepoint.c
··· 18 18 #define SPT_PAD_OWN 0x020 19 19 #define SPT_PADCFGLOCK 0x0a0 20 20 #define SPT_HOSTSW_OWN 0x0d0 21 + #define SPT_GPI_IS 0x100 21 22 #define SPT_GPI_IE 0x120 22 23 23 24 #define SPT_COMMUNITY(b, s, e) \ ··· 27 26 .padown_offset = SPT_PAD_OWN, \ 28 27 .padcfglock_offset = SPT_PADCFGLOCK, \ 29 28 .hostown_offset = SPT_HOSTSW_OWN, \ 29 + .is_offset = SPT_GPI_IS, \ 30 30 .ie_offset = SPT_GPI_IE, \ 31 31 .gpp_size = 24, \ 32 32 .gpp_num_padown_regs = 4, \