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 <jeremy.compostella@intel.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/87955
Reviewed-by: Subrata Banik <subratabanik@google.com>
Reviewed-by: Wonkyu Kim <wonkyu.kim@intel.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Kapil Porwal <kapilporwal@google.com>
This commit is contained in:
Jeremy Compostella 2025-06-04 12:05:35 -07:00 committed by Subrata Banik
commit 619699648f
3 changed files with 8 additions and 31 deletions

View file

@ -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);
}

View file

@ -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

View file

@ -1,10 +1,8 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <console/console.h>
#include <device/device.h>
#include <device/pci_def.h>
#include <intelblocks/p2sb.h>
#include <soc/iomap.h>
#include <types.h>
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,
};