Skip to contentSkip to conversation

platform/x86:intel/pmc: Move arch specific action to init function

PATCH In review Xi Pardee 2 participants 2 messages Feb 12, 2025 – Feb 13, 2025

Subsystems (2)
lore
Share & tools
lore

Xi Pardee

author maintainer
#0 lore raw

PATCH v2 1/1 platform/x86:intel/pmc: Move arch specific action to init function

Move arch specific action from core.c to the init() function of spt.c.

---
v2->v1:
- Change the name of pmc_pci_ids to spt_pmc_pci_id

 drivers/platform/x86/intel/pmc/core.c | 13 -------------
 drivers/platform/x86/intel/pmc/spt.c  | 21 +++++++++++++++++++++
 2 files changed, 21 insertions(+), 13 deletions(-)
drivers/platform/x86/intel/pmc/core.c +0 -13
index d819478fea29a..bd90d38e62e94 100644
@@ -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)
drivers/platform/x86/intel/pmc/spt.c +21 -0
index 956b2ec1c7510..440594acac6cf 100644
@@ -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,
 };
Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 3 lines · Xi Pardee

Move arch specific action from core.c to the init() function of spt.c.

Thank you for your contribution, it has been applied to my local review-ilpo-next branch. Note it will show up in the public platform-drivers-x86/review-ilpo-next branch only once I've pushed my local branch there, which might take a while.

The list of commits applied:
[1/1] platform/x86:intel/pmc: Move arch specific action to init function

      commit: d026feb03bdcde33e22a75777d59ed9d8725bcdd

--
i.