Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1284271

[PATCH v3 4/9] ACPI / LPSS: power on when probe() and otherwise when remove()

From Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Newsgroups linux.kernel
Subject [PATCH v3 4/9] ACPI / LPSS: power on when probe() and otherwise when remove()
Date 2015-12-04 23:00 +0100
Message-ID <qC6yu-8fV-31@gated-at.bofh.it> (permalink)
References <qC6oO-8cc-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


When LPSS drivers are compiled as a module, which is usually the case, the
second probe of that driver may fail because the driver is written in an
assumption that device is powered on. That is not the case for all drivers.
Moreover we would like not drain power in vain.

Implement ->activate() and ->dismiss() callbacks in the ACPI LPSS custom power
domain.

-------- 8< -------- 8< -------- 8< -------- 8< -------- 8< --------

Case 1: The I2C probe() repeat.

/sys/bus/platform/devices/808622C1:00 \_SB_.PCI0.I2C1 [D3hot]
/sys/bus/platform/devices/808622C1:01 \_SB_.PCI0.I2C2 [D3hot]
/sys/bus/platform/devices/808622C1:02 \_SB_.PCI0.I2C3 [D3hot]
/sys/bus/platform/devices/808622C1:03 \_SB_.PCI0.I2C4 [D3hot]
/sys/bus/platform/devices/808622C1:05 \_SB_.PCI0.I2C6 [D3hot]
/sys/bus/platform/devices/808622C1:06 \_SB_.PCI0.I2C7 [D3hot]

% modprobe i2c-designware-platform
    i2c_designware 808622C1:00: Unknown Synopsys component type: 0xffffffff
    i2c_designware 808622C1:01: Unknown Synopsys component type: 0xffffffff
    i2c_designware 808622C1:02: Unknown Synopsys component type: 0xffffffff
    i2c_designware 808622C1:03: Unknown Synopsys component type: 0xffffffff
    i2c_designware 808622C1:05: Unknown Synopsys component type: 0xffffffff
    i2c_designware 808622C1:06: Unknown Synopsys component type: 0xffffffff

Case 2: The power drain in case of SDHCI.

/sys/bus/platform/devices/80860F14:00 \_SB_.PCI0.SDHA [D3hot]
/sys/bus/platform/devices/80860F14:01 \_SB_.PCI0.SDHC [D3hot]

% modprobe -r sdhci-acpi
    mmc0: card 0001 removed

/sys/bus/platform/devices/80860F14:00 \_SB_.PCI0.SDHA [D0]
/sys/bus/platform/devices/80860F14:01 \_SB_.PCI0.SDHC [D0]

-------- 8< -------- 8< -------- 8< -------- 8< -------- 8< --------

Patch fixes above problems.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/acpi/acpi_lpss.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
index 6263939..c5f12f3 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -596,6 +596,34 @@ static void acpi_lpss_restore_ctx(struct device *dev,
 	}
 }
 
+static int acpi_lpss_activate(struct device *dev)
+{
+	struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev));
+	int ret;
+
+	ret = acpi_dev_runtime_resume(dev);
+	if (ret)
+		return ret;
+
+	acpi_lpss_d3_to_d0_delay(pdata);
+
+	/*
+	 * This is called only on ->probe() stage where a device is either in
+	 * known state defined by BIOS or most likely powered off. Due to this
+	 * we have to deassert reset line to be sure that ->probe() will
+	 * recognize the device.
+	 */
+	if (pdata->dev_desc->flags & LPSS_SAVE_CTX)
+		lpss_deassert_reset(pdata);
+
+	return 0;
+}
+
+static void acpi_lpss_dismiss(struct device *dev)
+{
+	acpi_dev_runtime_suspend(dev);
+}
+
 #ifdef CONFIG_PM_SLEEP
 static int acpi_lpss_suspend_late(struct device *dev)
 {
@@ -660,6 +688,10 @@ static int acpi_lpss_runtime_resume(struct device *dev)
 #endif /* CONFIG_PM */
 
 static struct dev_pm_domain acpi_lpss_pm_domain = {
+#ifdef CONFIG_PM
+	.activate = acpi_lpss_activate,
+	.dismiss = acpi_lpss_dismiss,
+#endif
 	.ops = {
 #ifdef CONFIG_PM
 #ifdef CONFIG_PM_SLEEP
-- 
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v3 0/9] ACPI / LPSS: fix system hangup on BYT/BSW/CHT Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2015-12-04 23:00 +0100
  [PATCH v3 6/9] ACPI / LPSS: override power state for LPSS DMA device Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2015-12-04 23:00 +0100
  [PATCH v3 4/9] ACPI / LPSS: power on when probe() and otherwise when remove() Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2015-12-04 23:00 +0100
  [PATCH v3 7/9] dmaengine: dw: platform: power on device on shutdown Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2015-12-04 23:00 +0100
    Re: [PATCH v3 7/9] dmaengine: dw: platform: power on device on  shutdown Vinod Koul <vinod.koul@intel.com> - 2015-12-08 18:30 +0100
  Re: [PATCH v3 0/9] ACPI / LPSS: fix system hangup on BYT/BSW/CHT "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2015-12-04 23:40 +0100
    Re: [PATCH v3 0/9] ACPI / LPSS: fix system hangup on BYT/BSW/CHT Andy Shevchenko <andy.shevchenko@gmail.com> - 2015-12-05 00:20 +0100
      Re: [PATCH v3 0/9] ACPI / LPSS: fix system hangup on BYT/BSW/CHT "Rafael J. Wysocki" <rafael@kernel.org> - 2015-12-05 01:10 +0100
        Re: [PATCH v3 0/9] ACPI / LPSS: fix system hangup on BYT/BSW/CHT Jacob Pan <jacob.jun.pan@linux.intel.com> - 2015-12-08 05:40 +0100

csiph-web