soc/intel/cannonlake: Switch PMC to use device callbacks
Now that the PMC device is marked as hidden in devicetrees, the device callbacks can be used instead of BOOT_STATE_INIT_ENTRY callbacks. Note that this moves PMC initialization from BS_DEV_INIT_CHIPS to BS_DEV_ENUMERATE, which aligns with other Intel SoCs. Signed-off-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Change-Id: If292728ad975ba803fed6abea879f6f634470a11 Reviewed-on: https://review.coreboot.org/c/coreboot/+/56009 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Furquan Shaikh <furquan@google.com>
This commit is contained in:
@ -195,6 +195,9 @@ static void soc_enable(struct device *dev)
|
|||||||
dev->ops = &cpu_bus_ops;
|
dev->ops = &cpu_bus_ops;
|
||||||
else if (dev->path.type == DEVICE_PATH_GPIO)
|
else if (dev->path.type == DEVICE_PATH_GPIO)
|
||||||
block_gpio_enable(dev);
|
block_gpio_enable(dev);
|
||||||
|
else if (dev->path.type == DEVICE_PATH_PCI &&
|
||||||
|
dev->path.pci.devfn == PCH_DEVFN_PMC)
|
||||||
|
dev->ops = &pmc_ops;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct chip_operations soc_intel_cannonlake_ops = {
|
struct chip_operations soc_intel_cannonlake_ops = {
|
||||||
|
@ -3,6 +3,10 @@
|
|||||||
#ifndef _SOC_CANNONLAKE_PMC_H_
|
#ifndef _SOC_CANNONLAKE_PMC_H_
|
||||||
#define _SOC_CANNONLAKE_PMC_H_
|
#define _SOC_CANNONLAKE_PMC_H_
|
||||||
|
|
||||||
|
#include <device/device.h>
|
||||||
|
|
||||||
|
extern struct device_operations pmc_ops;
|
||||||
|
|
||||||
/* PCI Configuration Space (D31:F2): PMC */
|
/* PCI Configuration Space (D31:F2): PMC */
|
||||||
#define PWRMBASE 0x10
|
#define PWRMBASE 0x10
|
||||||
#define ABASE 0x20
|
#define ABASE 0x20
|
||||||
|
@ -49,21 +49,4 @@ void lpc_soc_init(struct device *dev)
|
|||||||
i8259_configure_irq_trigger(9, 1);
|
i8259_configure_irq_trigger(9, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fill up LPC IO resource structure inside SoC directory */
|
|
||||||
void pch_lpc_soc_fill_io_resources(struct device *dev)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* PMC pci device gets hidden from PCI bus due to Silicon
|
|
||||||
* policy hence bind ACPI BASE aka ABASE (offset 0x20) with
|
|
||||||
* LPC IO resources to ensure that ABASE falls under PCI reserved
|
|
||||||
* IO memory range.
|
|
||||||
*
|
|
||||||
* Note: Don't add any more resource with same offset 0x20
|
|
||||||
* under this device space.
|
|
||||||
*/
|
|
||||||
pch_lpc_add_new_resource(dev, PCI_BASE_ADDRESS_4,
|
|
||||||
ACPI_BASE_ADDRESS, ACPI_BASE_SIZE, IORESOURCE_IO |
|
|
||||||
IORESOURCE_ASSIGNED | IORESOURCE_FIXED);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -68,7 +68,22 @@ static void config_deep_sx(uint32_t deepsx_config)
|
|||||||
write32(pmcbase + DSX_CFG, reg);
|
write32(pmcbase + DSX_CFG, reg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pmc_init(void *unused)
|
static void soc_pmc_read_resources(struct device *dev)
|
||||||
|
{
|
||||||
|
struct resource *res;
|
||||||
|
|
||||||
|
/* Add the fixed MMIO resource */
|
||||||
|
mmio_resource(dev, 0, PCH_PWRM_BASE_ADDRESS / KiB, PCH_PWRM_BASE_SIZE / KiB);
|
||||||
|
|
||||||
|
/* Add the fixed I/O resource */
|
||||||
|
res = new_resource(dev, 1);
|
||||||
|
res->base = (resource_t)ACPI_BASE_ADDRESS;
|
||||||
|
res->size = (resource_t)ACPI_BASE_SIZE;
|
||||||
|
res->limit = res->base + res->size - 1;
|
||||||
|
res->flags = IORESOURCE_IO | IORESOURCE_ASSIGNED | IORESOURCE_FIXED;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void pmc_init(struct device *dev)
|
||||||
{
|
{
|
||||||
const config_t *config = config_of_soc();
|
const config_t *config = config_of_soc();
|
||||||
|
|
||||||
@ -82,16 +97,7 @@ static void pmc_init(void *unused)
|
|||||||
config_deep_sx(config->deep_sx_config);
|
config_deep_sx(config->deep_sx_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
static void soc_acpi_mode_init(struct device *dev)
|
||||||
* Initialize PMC controller.
|
|
||||||
*
|
|
||||||
* PMC controller gets hidden from PCI bus during FSP-Silicon init call.
|
|
||||||
* Hence PCI enumeration can't be used to initialize bus device and
|
|
||||||
* allocate resources.
|
|
||||||
*/
|
|
||||||
BOOT_STATE_INIT_ENTRY(BS_DEV_INIT_CHIPS, BS_ON_EXIT, pmc_init, NULL);
|
|
||||||
|
|
||||||
static void soc_acpi_mode_init(void *unused)
|
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* PMC initialization happens earlier for this SoC because FSP-Silicon
|
* PMC initialization happens earlier for this SoC because FSP-Silicon
|
||||||
@ -106,11 +112,17 @@ static void soc_acpi_mode_init(void *unused)
|
|||||||
* taking different actions based on disabling of ACPI (e.g. flushing of
|
* taking different actions based on disabling of ACPI (e.g. flushing of
|
||||||
* all EC hostevent bits).
|
* all EC hostevent bits).
|
||||||
*
|
*
|
||||||
* P.S.: This cannot be done as part of pmc_soc_init as PMC device is
|
* Because the device is set as `hidden` in the devicetree, enumeration
|
||||||
* hidden and hence the PMC driver never gets enumerated and so init is
|
* is skipped, but the device callbacks are still called as if it were
|
||||||
* not called for it.
|
* found.
|
||||||
*/
|
*/
|
||||||
pmc_set_acpi_mode();
|
pmc_set_acpi_mode();
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOT_STATE_INIT_ENTRY(BS_DEV_INIT, BS_ON_EXIT, soc_acpi_mode_init, NULL);
|
struct device_operations pmc_ops = {
|
||||||
|
.read_resources = soc_pmc_read_resources,
|
||||||
|
.set_resources = noop_set_resources,
|
||||||
|
.init = soc_acpi_mode_init,
|
||||||
|
.enable = pmc_init,
|
||||||
|
.scan_bus = scan_static_bus,
|
||||||
|
};
|
||||||
|
@ -27,17 +27,6 @@ void soc_add_fixed_mmio_resources(struct device *dev, int *index)
|
|||||||
{ EPBAR, EP_BASE_ADDRESS, EP_BASE_SIZE, "EPBAR" },
|
{ EPBAR, EP_BASE_ADDRESS, EP_BASE_SIZE, "EPBAR" },
|
||||||
{ REGBAR, REG_BASE_ADDRESS, REG_BASE_SIZE, "REGBAR" },
|
{ REGBAR, REG_BASE_ADDRESS, REG_BASE_SIZE, "REGBAR" },
|
||||||
{ EDRAMBAR, EDRAM_BASE_ADDRESS, EDRAM_BASE_SIZE, "EDRAMBAR" },
|
{ EDRAMBAR, EDRAM_BASE_ADDRESS, EDRAM_BASE_SIZE, "EDRAMBAR" },
|
||||||
/*
|
|
||||||
* PMC pci device gets hidden from PCI bus due to Silicon
|
|
||||||
* policy hence binding PMCBAR aka PWRMBASE (offset 0x10) with
|
|
||||||
* SA resources to ensure that PMCBAR falls under PCI reserved
|
|
||||||
* memory range.
|
|
||||||
*
|
|
||||||
* Note: Don't add any more resource with same offset 0x10
|
|
||||||
* under this device space.
|
|
||||||
*/
|
|
||||||
{ PCI_BASE_ADDRESS_0, PCH_PWRM_BASE_ADDRESS, PCH_PWRM_BASE_SIZE,
|
|
||||||
"PMCBAR" },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
sa_add_fixed_mmio_resources(dev, index, soc_fixed_resources,
|
sa_add_fixed_mmio_resources(dev, index, soc_fixed_resources,
|
||||||
|
Reference in New Issue
Block a user