From 619699648fd47e4bc0146c94be2650e9e05f5fec Mon Sep 17 00:00:00 2001 From: Jeremy Compostella Date: Wed, 4 Jun 2025 12:05:35 -0700 Subject: [PATCH] soc/intel/pantherlake: Simplify P2SB and P2SB2 device operations This commit refactors the Pantherlake SOC code by leveraging existing P2SB device operations, thereby removing redundant definitions. The change eliminates unnecessary device operation structures (pcd_p2sb_ops and pcd_p2sb_2_ops) and replaces them with references to already defined operations (p2sb_ops and p2sb2_ops). This is similar to how it is handled in the Alder Lake codebase. BUG=b:422284273 TEST=Boot on Fatcat with and without this commit, compare the logs, and verify that the I/O memory resources for P2SB and P2SB2 devices are accounted for and are identical. Change-Id: I9304b6aa16f07fdc7d927cc2e27879db549ac774 Signed-off-by: Jeremy Compostella Reviewed-on: https://review.coreboot.org/c/coreboot/+/87955 Reviewed-by: Subrata Banik Reviewed-by: Wonkyu Kim Tested-by: build bot (Jenkins) Reviewed-by: Kapil Porwal --- src/soc/intel/pantherlake/chip.c | 7 +++-- src/soc/intel/pantherlake/include/soc/p2sb.h | 4 +-- src/soc/intel/pantherlake/p2sb.c | 28 +------------------- 3 files changed, 8 insertions(+), 31 deletions(-) diff --git a/src/soc/intel/pantherlake/chip.c b/src/soc/intel/pantherlake/chip.c index 24c6fc33ee..8005240475 100644 --- a/src/soc/intel/pantherlake/chip.c +++ b/src/soc/intel/pantherlake/chip.c @@ -247,6 +247,9 @@ static struct device_operations cpu_bus_ops = { static void soc_enable(struct device *dev) { + struct device_operations *soc_p2sb_ops = (struct device_operations *)&p2sb_ops; + struct device_operations *soc_p2sb2_ops = (struct device_operations *)&p2sb2_ops; + /* * Set the operations if it is a special bus type or a hidden PCI * device. @@ -260,10 +263,10 @@ static void soc_enable(struct device *dev) dev->ops = &pmc_ops; else if (dev->path.type == DEVICE_PATH_PCI && dev->path.pci.devfn == PCI_DEVFN_P2SB) - dev->ops = &pcd_p2sb_ops; + dev->ops = soc_p2sb_ops; else if (dev->path.type == DEVICE_PATH_PCI && dev->path.pci.devfn == PCI_DEVFN_P2SB2) - dev->ops = &pcd_p2sb_2_ops; + dev->ops = soc_p2sb2_ops; else if (dev->path.type == DEVICE_PATH_GPIO) block_gpio_enable(dev); } diff --git a/src/soc/intel/pantherlake/include/soc/p2sb.h b/src/soc/intel/pantherlake/include/soc/p2sb.h index 9bf7e2d4b8..36ffd2957b 100644 --- a/src/soc/intel/pantherlake/include/soc/p2sb.h +++ b/src/soc/intel/pantherlake/include/soc/p2sb.h @@ -8,7 +8,7 @@ #define PCH_P2SB_EPMASK0 0x220 -extern struct device_operations pcd_p2sb_ops; -extern struct device_operations pcd_p2sb_2_ops; +extern const struct device_operations p2sb_ops; +extern const struct device_operations p2sb2_ops; #endif diff --git a/src/soc/intel/pantherlake/p2sb.c b/src/soc/intel/pantherlake/p2sb.c index 6915463937..3b86bb07e8 100644 --- a/src/soc/intel/pantherlake/p2sb.c +++ b/src/soc/intel/pantherlake/p2sb.c @@ -1,10 +1,8 @@ /* SPDX-License-Identifier: GPL-2.0-only */ #include -#include -#include #include -#include +#include void p2sb_soc_get_sb_mask(uint32_t *ep_mask, size_t count) { @@ -31,27 +29,3 @@ void p2sb_soc_get_sb_mask(uint32_t *ep_mask, size_t count) ep_mask[P2SB_EP_MASK_7_REG] = mask; } - -static void p2sb2_read_resources(struct device *dev) -{ - /* Add the fixed MMIO resource for P2SB#2 */ - mmio_range(dev, PCI_BASE_ADDRESS_0, P2SB2_BAR, P2SB2_SIZE); -} - -static void p2sb_read_resources(struct device *dev) -{ - /* Add the fixed MMIO resource for P2SB#1 */ - mmio_range(dev, PCI_BASE_ADDRESS_0, P2SB_BAR, P2SB_SIZE); -} - -struct device_operations pcd_p2sb_2_ops = { - .read_resources = p2sb2_read_resources, - .set_resources = noop_set_resources, - .scan_bus = scan_static_bus, -}; - -struct device_operations pcd_p2sb_ops = { - .read_resources = p2sb_read_resources, - .set_resources = noop_set_resources, - .scan_bus = scan_static_bus, -};