platform/x86:intel/pmc: Move arch specific action to init function
authorXi Pardee <xi.pardee@linux.intel.com>
Wed, 12 Feb 2025 01:05:56 +0000 (17:05 -0800)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Thu, 13 Feb 2025 12:49:03 +0000 (14:49 +0200)
Move arch specific action from core.c to the init() function of spt.c.

Signed-off-by: Xi Pardee <xi.pardee@linux.intel.com>
Link: https://lore.kernel.org/r/20250212010621.1003663-1-xi.pardee@linux.intel.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
drivers/platform/x86/intel/pmc/core.c
drivers/platform/x86/intel/pmc/spt.c

index 1b85800ec10f340b483e23e1da0fb84ef97759ad..28e0c09dd599a251616cc0f56e847f46801c6320 100644 (file)
@@ -1418,11 +1418,6 @@ static const struct x86_cpu_id intel_pmc_core_ids[] = {
 
 MODULE_DEVICE_TABLE(x86cpu, intel_pmc_core_ids);
 
-static const struct pci_device_id pmc_pci_ids[] = {
-       { PCI_VDEVICE(INTEL, SPT_PMC_PCI_DEVICE_ID) },
-       { }
-};
-
 /*
  * This quirk can be used on those platforms where
  * the platform BIOS enforces 24Mhz crystal to shutdown
@@ -1533,14 +1528,6 @@ static int pmc_core_probe(struct platform_device *pdev)
        if (!pmcdev->pkgc_res_cnt)
                return -ENOMEM;
 
-       /*
-        * Coffee Lake has CPU ID of Kaby Lake and Cannon Lake PCH. So here
-        * Sunrisepoint PCH regmap can't be used. Use Cannon Lake PCH regmap
-        * in this case.
-        */
-       if (pmc_dev_info == &spt_pmc_dev && !pci_dev_present(pmc_pci_ids))
-               pmc_dev_info = &cnp_pmc_dev;
-
        mutex_init(&pmcdev->lock);
 
        if (pmc_dev_info->init)
index 956b2ec1c7510d771bb5f9b195dd8bfef0bec442..440594acac6cf81b47cc972e9202226fdeb297da 100644 (file)
@@ -8,6 +8,8 @@
  *
  */
 
+#include <linux/pci.h>
+
 #include "core.h"
 
 const struct pmc_bit_map spt_pll_map[] = {
@@ -134,6 +136,25 @@ const struct pmc_reg_map spt_reg_map = {
        .pm_vric1_offset = SPT_PMC_VRIC1_OFFSET,
 };
 
+static const struct pci_device_id spt_pmc_pci_id[] = {
+       { PCI_VDEVICE(INTEL, SPT_PMC_PCI_DEVICE_ID) },
+       { }
+};
+
+static int spt_core_init(struct pmc_dev *pmcdev, struct pmc_dev_info *pmc_dev_info)
+{
+       /*
+        * Coffee Lake has CPU ID of Kaby Lake and Cannon Lake PCH. So here
+        * Sunrisepoint PCH regmap can't be used. Use Cannon Lake PCH regmap
+        * in this case.
+        */
+       if (!pci_dev_present(spt_pmc_pci_id))
+               return generic_core_init(pmcdev, &cnp_pmc_dev);
+
+       return generic_core_init(pmcdev, pmc_dev_info);
+}
+
 struct pmc_dev_info spt_pmc_dev = {
        .map = &spt_reg_map,
+       .init = spt_core_init,
 };