TEST mfld pmu: differentiate MRST and MFLD pmu_pci_set_power_state
authorLen Brown <len.brown@intel.com>
Fri, 12 Aug 2011 21:44:30 +0000 (22:44 +0100)
committermgross <mark.gross@intel.com>
Wed, 9 Nov 2011 20:37:17 +0000 (12:37 -0800)
It is currently possible to build both MRST and MFLD into the kernel.
So we need to avoid a name conflict,
and bind the right version of pmu_pci_set_power_state().

Signed-off-by: Len Brown <len.brown@intel.com>
arch/x86/include/asm/mrst.h
arch/x86/platform/mfld/pmu.c
arch/x86/platform/mrst/pmu.c
drivers/pci/mid_pci.c

index 18ba6d2..4eb329b 100644 (file)
@@ -79,7 +79,8 @@ extern void intel_scu_devices_destroy(void);
 
 extern void mrst_rtc_init(void);
 
-extern int pmu_pci_set_power_state(struct pci_dev *pdev, pci_power_t state);
+extern int mrst_pmu_pci_set_power_state(struct pci_dev *pdev, pci_power_t state);
+extern int mfld_pmu_pci_set_power_state(struct pci_dev *pdev, pci_power_t state);
 
 #ifdef CONFIG_X86_MRST
 extern int mrst_pmu_s0i3_entry(void);
index 0e84973..a05ef2c 100755 (executable)
@@ -322,7 +322,7 @@ static spinlock_t nc_ready_lock;
  * Locking strategy::
  *
  * Two semaphores are used to lock the global variables used in
- * the code. The entry points in pmu driver are pmu_pci_set_power_state()
+ * the code. The entry points in pmu driver are mfld_pmu_pci_set_power_state()
  * and PMU interrupt handler contexts, so here is the flow of how
  * the semaphores are used.
  *
@@ -1604,11 +1604,11 @@ unlock:
 EXPORT_SYMBOL(pmu_nc_set_power_state);
 
 /**
- * pmu_pci_set_power_state - Callback function is used by all the PCI devices
+ * mfld_pmu_pci_set_power_state - Callback function is used by all the PCI devices
  *                     for a platform  specific device power on/shutdown.
  *
  */
-int __ref pmu_pci_set_power_state(struct pci_dev *pdev, pci_power_t state)
+int __ref mfld_pmu_pci_set_power_state(struct pci_dev *pdev, pci_power_t state)
 {
        int i;
        u32 pm_cmd_val;
@@ -1625,6 +1625,12 @@ int __ref pmu_pci_set_power_state(struct pci_dev *pdev, pci_power_t state)
 
        /* Try to acquire the scu_ready_sem, if not
         * get blocked, until pmu_sc_irq() releases */
+
+if (in_interrupt()) {
+       dev_err(&pmu_dev->dev, "mfld_pmu_pci_set_power_state() called from interrupt context!\n");
+       return -1;
+}
+
        down_scu_timed(&scu_ready_sem);
        interactive_cmd_sent = 1;
 
index c0ac06d..03fba44 100644 (file)
@@ -372,11 +372,11 @@ static u16 pmu_min_lss_pci_req(u16 *ids, u16 pci_state)
 }
 
 /**
- * pmu_pci_set_power_state - Callback function is used by all the PCI devices
+ * mrst_pmu_pci_set_power_state - Callback function is used by all the PCI devices
  *                     for a platform  specific device power on/shutdown.
  */
 
-int pmu_pci_set_power_state(struct pci_dev *pdev, pci_power_t pci_state)
+int mrst_pmu_pci_set_power_state(struct pci_dev *pdev, pci_power_t pci_state)
 {
        u32 old_sss, new_sss;
        int status = 0;
index 4b68bd3..9db203c 100644 (file)
@@ -49,7 +49,6 @@ static int mid_pci_run_wake(struct pci_dev *dev, bool enable)
 
 static struct pci_platform_pm_ops mid_pci_platform_pm = {
        .is_manageable = mid_pci_power_manageable,
-       .set_state = pmu_pci_set_power_state,
        .choose_state = mid_pci_choose_state,
        .can_wakeup = mid_pci_can_wakeup,
        .sleep_wake = mid_pci_sleep_wake,
@@ -62,12 +61,30 @@ static struct pci_platform_pm_ops mid_pci_platform_pm = {
  */
 static int __init mid_pci_init(void)
 {
-       int ret = 0;
-
        pr_info("mid_pci_init is called\n");
 
-       pci_set_platform_pm(&mid_pci_platform_pm);
+       if (!boot_cpu_data.x86 == 6)
+               return 0;
+
+       /*
+        * n.b. this model check does not uniquely identify the platform,
+        * and additional checks are necessary inside the pmu driver
+        */
+       switch(boot_cpu_data.x86_model) {
+#ifdef CONFIG_X86_MRST
+       case 0x26:
+               mid_pci_platform_pm.set_state = mrst_pmu_pci_set_power_state;
+               pci_set_platform_pm(&mid_pci_platform_pm);
+               break;
+#endif
+#ifdef CONFIG_X86_MDFLD
+       case 0x27:
+               mid_pci_platform_pm.set_state = mfld_pmu_pci_set_power_state;
+               pci_set_platform_pm(&mid_pci_platform_pm);
+               break;
+#endif
+       }
 
-       return ret;
+       return 0;
 }
 arch_initcall(mid_pci_init);