From bd15ece78af605bca9fc092baa094c87d5b8244b Mon Sep 17 00:00:00 2001 From: Arthur Heymans Date: Tue, 4 Oct 2022 14:53:56 +0200 Subject: soc/amd/*: Move emmc disabling to device ops This allows for reduced use of chip_operations in the followup patch and allows the allocator to skip over the used mmio. Change-Id: I4052438185e7861792733b96a1298201c73fc3ff Signed-off-by: Arthur Heymans Signed-off-by: Felix Held Reviewed-on: https://review.coreboot.org/c/coreboot/+/68113 Tested-by: build bot (Jenkins) Reviewed-by: Martin Roth Reviewed-by: Fred Reitberger --- src/soc/amd/cezanne/Makefile.inc | 1 + src/soc/amd/cezanne/chip.c | 7 +++---- src/soc/amd/cezanne/emmc.c | 23 +++++++++++++++++++++++ 3 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 src/soc/amd/cezanne/emmc.c (limited to 'src/soc/amd/cezanne') diff --git a/src/soc/amd/cezanne/Makefile.inc b/src/soc/amd/cezanne/Makefile.inc index dc97c1ff4d..95ab4edb4b 100644 --- a/src/soc/amd/cezanne/Makefile.inc +++ b/src/soc/amd/cezanne/Makefile.inc @@ -33,6 +33,7 @@ ramstage-y += agesa_acpi.c ramstage-y += chip.c ramstage-y += cpu.c ramstage-y += data_fabric.c +ramstage-y += emmc.c ramstage-y += fch.c ramstage-y += fsp_s_params.c ramstage-y += gpio.c diff --git a/src/soc/amd/cezanne/chip.c b/src/soc/amd/cezanne/chip.c index f184cb543b..86aaf6ced2 100644 --- a/src/soc/amd/cezanne/chip.c +++ b/src/soc/amd/cezanne/chip.c @@ -1,12 +1,10 @@ /* SPDX-License-Identifier: GPL-2.0-only */ -#include #include #include #include #include #include -#include #include #include #include @@ -18,6 +16,8 @@ extern struct device_operations soc_amd_i2c_mmio_ops; /* Supplied by uart.c */ extern struct device_operations cezanne_uart_mmio_ops; +/* Supplied by emmc.c */ +extern struct device_operations cezanne_emmc_mmio_ops; struct device_operations cpu_bus_ops = { .read_resources = noop_read_resources, @@ -60,8 +60,7 @@ static void set_mmio_dev_ops(struct device *dev) dev->ops = &cezanne_uart_mmio_ops; break; case APU_EMMC_BASE: - if (!dev->enabled) - power_off_aoac_device(FCH_AOAC_DEV_EMMC); + dev->ops = &cezanne_emmc_mmio_ops; break; } } diff --git a/src/soc/amd/cezanne/emmc.c b/src/soc/amd/cezanne/emmc.c new file mode 100644 index 0000000000..a699b20f51 --- /dev/null +++ b/src/soc/amd/cezanne/emmc.c @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include +#include +#include + +static void emmc_read_resources(struct device *dev) +{ + mmio_resource_kb(dev, 0, dev->path.mmio.addr / KiB, 4); +} + +static void emmc_enable(struct device *dev) +{ + if (!dev->enabled) + power_off_aoac_device(FCH_AOAC_DEV_EMMC); +} + +struct device_operations cezanne_emmc_mmio_ops = { + .read_resources = emmc_read_resources, + .set_resources = noop_set_resources, + .scan_bus = scan_static_bus, + .enable = emmc_enable, +}; -- cgit v1.2.3