@@ -1,3 +1,2 @@
obj-${CONFIG_THUNDERBOLT} := thunderbolt.o
-thunderbolt-objs := nhi.o ctl.o tb.o switch.o cap.o path.o tunnel_pci.o eeprom.o
-
+thunderbolt-objs := nhi.o ctl.o tb.o switch.o cap.o path.o tunnel_pci.o eeprom.o power.o
@@ -7,7 +7,6 @@
* Copyright (c) 2014 Andreas Noever <andreas.noever@gmail.com>
*/
-#include <linux/pm_runtime.h>
#include <linux/slab.h>
#include <linux/errno.h>
#include <linux/pci.h>
@@ -17,6 +16,7 @@
#include "nhi.h"
#include "nhi_regs.h"
+#include "power.h"
#include "tb.h"
#define RING_TYPE(ring) ((ring)->is_tx ? "TX ring" : "RX ring")
@@ -493,22 +493,6 @@ static irqreturn_t nhi_msi(int irq, void *data)
return IRQ_HANDLED;
}
-static int nhi_suspend_noirq(struct device *dev)
-{
- struct pci_dev *pdev = to_pci_dev(dev);
- struct tb *tb = pci_get_drvdata(pdev);
- thunderbolt_suspend(tb);
- return 0;
-}
-
-static int nhi_resume_noirq(struct device *dev)
-{
- struct pci_dev *pdev = to_pci_dev(dev);
- struct tb *tb = pci_get_drvdata(pdev);
- thunderbolt_resume(tb);
- return 0;
-}
-
static void nhi_shutdown(struct tb_nhi *nhi)
{
int i;
@@ -615,21 +599,6 @@ static void nhi_remove(struct pci_dev *pdev)
nhi_shutdown(nhi);
}
-/*
- * The tunneled pci bridges are siblings of us. Use resume_noirq to reenable
- * the tunnels asap. A corresponding pci quirk blocks the downstream bridges
- * resume_noirq until we are done.
- */
-static const struct dev_pm_ops nhi_pm_ops = {
- .suspend_noirq = nhi_suspend_noirq,
- .resume_noirq = nhi_resume_noirq,
- .freeze_noirq = nhi_suspend_noirq, /*
- * we just disable hotplug, the
- * pci-tunnels stay alive.
- */
- .restore_noirq = nhi_resume_noirq,
-};
-
static struct pci_device_id nhi_ids[] = {
/*
* We have to specify class, the TB bridges use the same device and
new file mode 100644
@@ -0,0 +1,41 @@
+/*
+ * Thunderbolt Cactus Ridge driver - power management
+ *
+ * Copyright (c) 2014 Andreas Noever <andreas.noever@gmail.com>
+ */
+
+#include <linux/pci.h>
+#include <linux/pm_runtime.h>
+
+#include "tb.h"
+
+static int nhi_suspend_noirq(struct device *dev)
+{
+ struct pci_dev *pdev = to_pci_dev(dev);
+ struct tb *tb = pci_get_drvdata(pdev);
+ thunderbolt_suspend(tb);
+ return 0;
+}
+
+static int nhi_resume_noirq(struct device *dev)
+{
+ struct pci_dev *pdev = to_pci_dev(dev);
+ struct tb *tb = pci_get_drvdata(pdev);
+ thunderbolt_resume(tb);
+ return 0;
+}
+
+/*
+ * The tunneled pci bridges are siblings of us. Use resume_noirq to reenable
+ * the tunnels asap. A corresponding pci quirk blocks the downstream bridges
+ * resume_noirq until we are done.
+ */
+const struct dev_pm_ops nhi_pm_ops = {
+ .suspend_noirq = nhi_suspend_noirq,
+ .resume_noirq = nhi_resume_noirq,
+ .freeze_noirq = nhi_suspend_noirq, /*
+ * we just disable hotplug, the
+ * pci-tunnels stay alive.
+ */
+ .restore_noirq = nhi_resume_noirq,
+};
new file mode 100644
@@ -0,0 +1,14 @@
+/*
+ * Thunderbolt Cactus Ridge driver - power management
+ *
+ * Copyright (c) 2014 Andreas Noever <andreas.noever@gmail.com>
+ */
+
+#ifndef POWER_H
+#define POWER_H
+
+#include <linux/pm_runtime.h>
+
+extern const struct dev_pm_ops nhi_pm_ops;
+
+#endif
No code changes. Cc: Andreas Noever <andreas.noever@gmail.com> Signed-off-by: Lukas Wunner <lukas@wunner.de> --- drivers/thunderbolt/Makefile | 3 +-- drivers/thunderbolt/nhi.c | 33 +-------------------------------- drivers/thunderbolt/power.c | 41 +++++++++++++++++++++++++++++++++++++++++ drivers/thunderbolt/power.h | 14 ++++++++++++++ 4 files changed, 57 insertions(+), 34 deletions(-) create mode 100644 drivers/thunderbolt/power.c create mode 100644 drivers/thunderbolt/power.h