diff options
| -rw-r--r-- | drivers/pinctrl/intel/pinctrl-baytrail.c | 2 | ||||
| -rw-r--r-- | drivers/pinctrl/intel/pinctrl-cedarfork.c | 18 | ||||
| -rw-r--r-- | drivers/pinctrl/intel/pinctrl-intel.c | 66 | ||||
| -rw-r--r-- | drivers/pinctrl/intel/pinctrl-intel.h | 11 |
4 files changed, 78 insertions, 19 deletions
diff --git a/drivers/pinctrl/intel/pinctrl-baytrail.c b/drivers/pinctrl/intel/pinctrl-baytrail.c index 241384ead4ed..18d9ad504194 100644 --- a/drivers/pinctrl/intel/pinctrl-baytrail.c +++ b/drivers/pinctrl/intel/pinctrl-baytrail.c | |||
| @@ -1710,6 +1710,8 @@ static int byt_gpio_probe(struct byt_gpio *vg) | |||
| 1710 | #ifdef CONFIG_PM_SLEEP | 1710 | #ifdef CONFIG_PM_SLEEP |
| 1711 | vg->saved_context = devm_kcalloc(&vg->pdev->dev, gc->ngpio, | 1711 | vg->saved_context = devm_kcalloc(&vg->pdev->dev, gc->ngpio, |
| 1712 | sizeof(*vg->saved_context), GFP_KERNEL); | 1712 | sizeof(*vg->saved_context), GFP_KERNEL); |
| 1713 | if (!vg->saved_context) | ||
| 1714 | return -ENOMEM; | ||
| 1713 | #endif | 1715 | #endif |
| 1714 | ret = devm_gpiochip_add_data(&vg->pdev->dev, gc, vg); | 1716 | ret = devm_gpiochip_add_data(&vg->pdev->dev, gc, vg); |
| 1715 | if (ret) { | 1717 | if (ret) { |
diff --git a/drivers/pinctrl/intel/pinctrl-cedarfork.c b/drivers/pinctrl/intel/pinctrl-cedarfork.c index b7d632f1dbf6..aa6f9040d3d8 100644 --- a/drivers/pinctrl/intel/pinctrl-cedarfork.c +++ b/drivers/pinctrl/intel/pinctrl-cedarfork.c | |||
| @@ -91,13 +91,13 @@ static const struct pinctrl_pin_desc cdf_pins[] = { | |||
| 91 | PINCTRL_PIN(43, "MEMTRIP_N"), | 91 | PINCTRL_PIN(43, "MEMTRIP_N"), |
| 92 | PINCTRL_PIN(44, "UART0_RXD"), | 92 | PINCTRL_PIN(44, "UART0_RXD"), |
| 93 | PINCTRL_PIN(45, "UART0_TXD"), | 93 | PINCTRL_PIN(45, "UART0_TXD"), |
| 94 | PINCTRL_PIN(46, "UART1_RXD"), | 94 | PINCTRL_PIN(46, "GBE_UART_RXD"), |
| 95 | PINCTRL_PIN(47, "UART1_TXD"), | 95 | PINCTRL_PIN(47, "GBE_UART_TXD"), |
| 96 | /* WEST01 */ | 96 | /* WEST01 */ |
| 97 | PINCTRL_PIN(48, "GBE_GPIO13"), | 97 | PINCTRL_PIN(48, "GBE_GPIO13"), |
| 98 | PINCTRL_PIN(49, "AUX_PWR"), | 98 | PINCTRL_PIN(49, "AUX_PWR"), |
| 99 | PINCTRL_PIN(50, "CPU_GP_2"), | 99 | PINCTRL_PIN(50, "UART0_RTS"), |
| 100 | PINCTRL_PIN(51, "CPU_GP_3"), | 100 | PINCTRL_PIN(51, "UART0_CTS"), |
| 101 | PINCTRL_PIN(52, "FAN_PWM_0"), | 101 | PINCTRL_PIN(52, "FAN_PWM_0"), |
| 102 | PINCTRL_PIN(53, "FAN_PWM_1"), | 102 | PINCTRL_PIN(53, "FAN_PWM_1"), |
| 103 | PINCTRL_PIN(54, "FAN_PWM_2"), | 103 | PINCTRL_PIN(54, "FAN_PWM_2"), |
| @@ -201,8 +201,8 @@ static const struct pinctrl_pin_desc cdf_pins[] = { | |||
| 201 | /* WESTF */ | 201 | /* WESTF */ |
| 202 | PINCTRL_PIN(145, "NAC_RMII_CLK"), | 202 | PINCTRL_PIN(145, "NAC_RMII_CLK"), |
| 203 | PINCTRL_PIN(146, "NAC_RGMII_CLK"), | 203 | PINCTRL_PIN(146, "NAC_RGMII_CLK"), |
| 204 | PINCTRL_PIN(147, "NAC_SPARE0"), | 204 | PINCTRL_PIN(147, "NAC_GBE_SMB_CLK_TX_N2S"), |
| 205 | PINCTRL_PIN(148, "NAC_SPARE1"), | 205 | PINCTRL_PIN(148, "NAC_GBE_SMB_DATA_TX_N2S"), |
| 206 | PINCTRL_PIN(149, "NAC_SPARE2"), | 206 | PINCTRL_PIN(149, "NAC_SPARE2"), |
| 207 | PINCTRL_PIN(150, "NAC_INIT_SX_WAKE_N"), | 207 | PINCTRL_PIN(150, "NAC_INIT_SX_WAKE_N"), |
| 208 | PINCTRL_PIN(151, "NAC_GBE_GPIO0_S2N"), | 208 | PINCTRL_PIN(151, "NAC_GBE_GPIO0_S2N"), |
| @@ -219,8 +219,8 @@ static const struct pinctrl_pin_desc cdf_pins[] = { | |||
| 219 | PINCTRL_PIN(162, "NAC_NCSI_TXD1"), | 219 | PINCTRL_PIN(162, "NAC_NCSI_TXD1"), |
| 220 | PINCTRL_PIN(163, "NAC_NCSI_ARB_OUT"), | 220 | PINCTRL_PIN(163, "NAC_NCSI_ARB_OUT"), |
| 221 | PINCTRL_PIN(164, "NAC_NCSI_OE_N"), | 221 | PINCTRL_PIN(164, "NAC_NCSI_OE_N"), |
| 222 | PINCTRL_PIN(165, "NAC_GBE_SMB_CLK"), | 222 | PINCTRL_PIN(165, "NAC_GBE_SMB_CLK_RX_S2N"), |
| 223 | PINCTRL_PIN(166, "NAC_GBE_SMB_DATA"), | 223 | PINCTRL_PIN(166, "NAC_GBE_SMB_DATA_RX_S2N"), |
| 224 | PINCTRL_PIN(167, "NAC_GBE_SMB_ALRT_N"), | 224 | PINCTRL_PIN(167, "NAC_GBE_SMB_ALRT_N"), |
| 225 | /* EAST2 */ | 225 | /* EAST2 */ |
| 226 | PINCTRL_PIN(168, "USB_OC0_N"), | 226 | PINCTRL_PIN(168, "USB_OC0_N"), |
| @@ -232,7 +232,7 @@ static const struct pinctrl_pin_desc cdf_pins[] = { | |||
| 232 | PINCTRL_PIN(174, "GBE_GPIO5"), | 232 | PINCTRL_PIN(174, "GBE_GPIO5"), |
| 233 | PINCTRL_PIN(175, "GBE_GPIO6"), | 233 | PINCTRL_PIN(175, "GBE_GPIO6"), |
| 234 | PINCTRL_PIN(176, "GBE_GPIO7"), | 234 | PINCTRL_PIN(176, "GBE_GPIO7"), |
| 235 | PINCTRL_PIN(177, "GBE_GPIO8"), | 235 | PINCTRL_PIN(177, "SPI_TPM_CS_N"), |
| 236 | PINCTRL_PIN(178, "GBE_GPIO9"), | 236 | PINCTRL_PIN(178, "GBE_GPIO9"), |
| 237 | PINCTRL_PIN(179, "GBE_GPIO10"), | 237 | PINCTRL_PIN(179, "GBE_GPIO10"), |
| 238 | PINCTRL_PIN(180, "GBE_GPIO11"), | 238 | PINCTRL_PIN(180, "GBE_GPIO11"), |
diff --git a/drivers/pinctrl/intel/pinctrl-intel.c b/drivers/pinctrl/intel/pinctrl-intel.c index 3b1818184207..d7acbb79cdf7 100644 --- a/drivers/pinctrl/intel/pinctrl-intel.c +++ b/drivers/pinctrl/intel/pinctrl-intel.c | |||
| @@ -81,6 +81,7 @@ struct intel_pad_context { | |||
| 81 | 81 | ||
| 82 | struct intel_community_context { | 82 | struct intel_community_context { |
| 83 | u32 *intmask; | 83 | u32 *intmask; |
| 84 | u32 *hostown; | ||
| 84 | }; | 85 | }; |
| 85 | 86 | ||
| 86 | struct intel_pinctrl_context { | 87 | struct intel_pinctrl_context { |
| @@ -1284,7 +1285,7 @@ static int intel_pinctrl_pm_init(struct intel_pinctrl *pctrl) | |||
| 1284 | 1285 | ||
| 1285 | for (i = 0; i < pctrl->ncommunities; i++) { | 1286 | for (i = 0; i < pctrl->ncommunities; i++) { |
| 1286 | struct intel_community *community = &pctrl->communities[i]; | 1287 | struct intel_community *community = &pctrl->communities[i]; |
| 1287 | u32 *intmask; | 1288 | u32 *intmask, *hostown; |
| 1288 | 1289 | ||
| 1289 | intmask = devm_kcalloc(pctrl->dev, community->ngpps, | 1290 | intmask = devm_kcalloc(pctrl->dev, community->ngpps, |
| 1290 | sizeof(*intmask), GFP_KERNEL); | 1291 | sizeof(*intmask), GFP_KERNEL); |
| @@ -1292,6 +1293,13 @@ static int intel_pinctrl_pm_init(struct intel_pinctrl *pctrl) | |||
| 1292 | return -ENOMEM; | 1293 | return -ENOMEM; |
| 1293 | 1294 | ||
| 1294 | communities[i].intmask = intmask; | 1295 | communities[i].intmask = intmask; |
| 1296 | |||
| 1297 | hostown = devm_kcalloc(pctrl->dev, community->ngpps, | ||
| 1298 | sizeof(*hostown), GFP_KERNEL); | ||
| 1299 | if (!hostown) | ||
| 1300 | return -ENOMEM; | ||
| 1301 | |||
| 1302 | communities[i].hostown = hostown; | ||
| 1295 | } | 1303 | } |
| 1296 | 1304 | ||
| 1297 | pctrl->context.pads = pads; | 1305 | pctrl->context.pads = pads; |
| @@ -1466,7 +1474,7 @@ static bool intel_pinctrl_should_save(struct intel_pinctrl *pctrl, unsigned int | |||
| 1466 | return false; | 1474 | return false; |
| 1467 | } | 1475 | } |
| 1468 | 1476 | ||
| 1469 | int intel_pinctrl_suspend(struct device *dev) | 1477 | int intel_pinctrl_suspend_noirq(struct device *dev) |
| 1470 | { | 1478 | { |
| 1471 | struct intel_pinctrl *pctrl = dev_get_drvdata(dev); | 1479 | struct intel_pinctrl *pctrl = dev_get_drvdata(dev); |
| 1472 | struct intel_community_context *communities; | 1480 | struct intel_community_context *communities; |
| @@ -1501,11 +1509,15 @@ int intel_pinctrl_suspend(struct device *dev) | |||
| 1501 | base = community->regs + community->ie_offset; | 1509 | base = community->regs + community->ie_offset; |
| 1502 | for (gpp = 0; gpp < community->ngpps; gpp++) | 1510 | for (gpp = 0; gpp < community->ngpps; gpp++) |
| 1503 | communities[i].intmask[gpp] = readl(base + gpp * 4); | 1511 | communities[i].intmask[gpp] = readl(base + gpp * 4); |
| 1512 | |||
| 1513 | base = community->regs + community->hostown_offset; | ||
| 1514 | for (gpp = 0; gpp < community->ngpps; gpp++) | ||
| 1515 | communities[i].hostown[gpp] = readl(base + gpp * 4); | ||
| 1504 | } | 1516 | } |
| 1505 | 1517 | ||
| 1506 | return 0; | 1518 | return 0; |
| 1507 | } | 1519 | } |
| 1508 | EXPORT_SYMBOL_GPL(intel_pinctrl_suspend); | 1520 | EXPORT_SYMBOL_GPL(intel_pinctrl_suspend_noirq); |
| 1509 | 1521 | ||
| 1510 | static void intel_gpio_irq_init(struct intel_pinctrl *pctrl) | 1522 | static void intel_gpio_irq_init(struct intel_pinctrl *pctrl) |
| 1511 | { | 1523 | { |
| @@ -1527,7 +1539,32 @@ static void intel_gpio_irq_init(struct intel_pinctrl *pctrl) | |||
| 1527 | } | 1539 | } |
| 1528 | } | 1540 | } |
| 1529 | 1541 | ||
| 1530 | int intel_pinctrl_resume(struct device *dev) | 1542 | static u32 |
| 1543 | intel_gpio_is_requested(struct gpio_chip *chip, int base, unsigned int size) | ||
| 1544 | { | ||
| 1545 | u32 requested = 0; | ||
| 1546 | unsigned int i; | ||
| 1547 | |||
| 1548 | for (i = 0; i < size; i++) | ||
| 1549 | if (gpiochip_is_requested(chip, base + i)) | ||
| 1550 | requested |= BIT(i); | ||
| 1551 | |||
| 1552 | return requested; | ||
| 1553 | } | ||
| 1554 | |||
| 1555 | static u32 | ||
| 1556 | intel_gpio_update_pad_mode(void __iomem *hostown, u32 mask, u32 value) | ||
| 1557 | { | ||
| 1558 | u32 curr, updated; | ||
| 1559 | |||
| 1560 | curr = readl(hostown); | ||
| 1561 | updated = (curr & ~mask) | (value & mask); | ||
| 1562 | writel(updated, hostown); | ||
| 1563 | |||
| 1564 | return curr; | ||
| 1565 | } | ||
| 1566 | |||
| 1567 | int intel_pinctrl_resume_noirq(struct device *dev) | ||
| 1531 | { | 1568 | { |
| 1532 | struct intel_pinctrl *pctrl = dev_get_drvdata(dev); | 1569 | struct intel_pinctrl *pctrl = dev_get_drvdata(dev); |
| 1533 | const struct intel_community_context *communities; | 1570 | const struct intel_community_context *communities; |
| @@ -1585,11 +1622,30 @@ int intel_pinctrl_resume(struct device *dev) | |||
| 1585 | dev_dbg(dev, "restored mask %d/%u %#08x\n", i, gpp, | 1622 | dev_dbg(dev, "restored mask %d/%u %#08x\n", i, gpp, |
| 1586 | readl(base + gpp * 4)); | 1623 | readl(base + gpp * 4)); |
| 1587 | } | 1624 | } |
| 1625 | |||
| 1626 | base = community->regs + community->hostown_offset; | ||
| 1627 | for (gpp = 0; gpp < community->ngpps; gpp++) { | ||
| 1628 | const struct intel_padgroup *padgrp = &community->gpps[gpp]; | ||
| 1629 | u32 requested = 0, value = 0; | ||
| 1630 | u32 saved = communities[i].hostown[gpp]; | ||
| 1631 | |||
| 1632 | if (padgrp->gpio_base < 0) | ||
| 1633 | continue; | ||
| 1634 | |||
| 1635 | requested = intel_gpio_is_requested(&pctrl->chip, | ||
| 1636 | padgrp->gpio_base, padgrp->size); | ||
| 1637 | value = intel_gpio_update_pad_mode(base + gpp * 4, | ||
| 1638 | requested, saved); | ||
| 1639 | if ((value ^ saved) & requested) { | ||
| 1640 | dev_warn(dev, "restore hostown %d/%u %#8x->%#8x\n", | ||
| 1641 | i, gpp, value, saved); | ||
| 1642 | } | ||
| 1643 | } | ||
| 1588 | } | 1644 | } |
| 1589 | 1645 | ||
| 1590 | return 0; | 1646 | return 0; |
| 1591 | } | 1647 | } |
| 1592 | EXPORT_SYMBOL_GPL(intel_pinctrl_resume); | 1648 | EXPORT_SYMBOL_GPL(intel_pinctrl_resume_noirq); |
| 1593 | #endif | 1649 | #endif |
| 1594 | 1650 | ||
| 1595 | MODULE_AUTHOR("Mathias Nyman <mathias.nyman@linux.intel.com>"); | 1651 | MODULE_AUTHOR("Mathias Nyman <mathias.nyman@linux.intel.com>"); |
diff --git a/drivers/pinctrl/intel/pinctrl-intel.h b/drivers/pinctrl/intel/pinctrl-intel.h index b8a07d37d18f..a8e958f1dcf5 100644 --- a/drivers/pinctrl/intel/pinctrl-intel.h +++ b/drivers/pinctrl/intel/pinctrl-intel.h | |||
| @@ -177,13 +177,14 @@ int intel_pinctrl_probe_by_hid(struct platform_device *pdev); | |||
| 177 | int intel_pinctrl_probe_by_uid(struct platform_device *pdev); | 177 | int intel_pinctrl_probe_by_uid(struct platform_device *pdev); |
| 178 | 178 | ||
| 179 | #ifdef CONFIG_PM_SLEEP | 179 | #ifdef CONFIG_PM_SLEEP |
| 180 | int intel_pinctrl_suspend(struct device *dev); | 180 | int intel_pinctrl_suspend_noirq(struct device *dev); |
| 181 | int intel_pinctrl_resume(struct device *dev); | 181 | int intel_pinctrl_resume_noirq(struct device *dev); |
| 182 | #endif | 182 | #endif |
| 183 | 183 | ||
| 184 | #define INTEL_PINCTRL_PM_OPS(_name) \ | 184 | #define INTEL_PINCTRL_PM_OPS(_name) \ |
| 185 | const struct dev_pm_ops _name = { \ | 185 | const struct dev_pm_ops _name = { \ |
| 186 | SET_LATE_SYSTEM_SLEEP_PM_OPS(intel_pinctrl_suspend, intel_pinctrl_resume) \ | 186 | SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(intel_pinctrl_suspend_noirq, \ |
| 187 | intel_pinctrl_resume_noirq) \ | ||
| 187 | } | 188 | } |
| 188 | 189 | ||
| 189 | #endif /* PINCTRL_INTEL_H */ | 190 | #endif /* PINCTRL_INTEL_H */ |
