From 65d73cc4573a23b4d98e3156cc1c4d0a1b09cb96 Mon Sep 17 00:00:00 2001 From: Felix Held Date: Thu, 13 Oct 2022 20:58:47 +0200 Subject: soc/amd: factor out common eMMC code Signed-off-by: Felix Held Change-Id: If5447f9272183f83bc422520ada93d3cfd96551e Reviewed-on: https://review.coreboot.org/c/coreboot/+/68415 Tested-by: build bot (Jenkins) Reviewed-by: Martin Roth --- src/soc/amd/cezanne/Kconfig | 1 + src/soc/amd/cezanne/Makefile.inc | 1 - src/soc/amd/cezanne/chipset.cb | 2 +- src/soc/amd/cezanne/emmc.c | 23 ----------------------- src/soc/amd/common/block/emmc/Kconfig | 4 ++++ src/soc/amd/common/block/emmc/Makefile.inc | 1 + src/soc/amd/common/block/emmc/emmc.c | 23 +++++++++++++++++++++++ src/soc/amd/mendocino/Kconfig | 1 + src/soc/amd/mendocino/Makefile.inc | 1 - src/soc/amd/mendocino/chipset_mendocino.cb | 2 +- src/soc/amd/mendocino/chipset_rembrandt.cb | 2 +- src/soc/amd/mendocino/emmc.c | 23 ----------------------- src/soc/amd/morgana/Kconfig | 1 + src/soc/amd/morgana/Makefile.inc | 1 - src/soc/amd/morgana/chipset.cb | 2 +- src/soc/amd/morgana/emmc.c | 23 ----------------------- 16 files changed, 35 insertions(+), 76 deletions(-) delete mode 100644 src/soc/amd/cezanne/emmc.c create mode 100644 src/soc/amd/common/block/emmc/Kconfig create mode 100644 src/soc/amd/common/block/emmc/Makefile.inc create mode 100644 src/soc/amd/common/block/emmc/emmc.c delete mode 100644 src/soc/amd/mendocino/emmc.c delete mode 100644 src/soc/amd/morgana/emmc.c (limited to 'src') diff --git a/src/soc/amd/cezanne/Kconfig b/src/soc/amd/cezanne/Kconfig index 35b9215586..b8209f83a9 100644 --- a/src/soc/amd/cezanne/Kconfig +++ b/src/soc/amd/cezanne/Kconfig @@ -46,6 +46,7 @@ config SOC_SPECIFIC_OPTIONS select SOC_AMD_COMMON_BLOCK_APOB select SOC_AMD_COMMON_BLOCK_BANKED_GPIOS select SOC_AMD_COMMON_BLOCK_DATA_FABRIC + select SOC_AMD_COMMON_BLOCK_EMMC select SOC_AMD_COMMON_BLOCK_GRAPHICS select SOC_AMD_COMMON_BLOCK_HAS_ESPI select SOC_AMD_COMMON_BLOCK_I2C diff --git a/src/soc/amd/cezanne/Makefile.inc b/src/soc/amd/cezanne/Makefile.inc index 95ab4edb4b..dc97c1ff4d 100644 --- a/src/soc/amd/cezanne/Makefile.inc +++ b/src/soc/amd/cezanne/Makefile.inc @@ -33,7 +33,6 @@ 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/chipset.cb b/src/soc/amd/cezanne/chipset.cb index a9bc2568a1..e717fd47c5 100644 --- a/src/soc/amd/cezanne/chipset.cb +++ b/src/soc/amd/cezanne/chipset.cb @@ -113,5 +113,5 @@ chip soc/amd/cezanne device mmio 0xfedc5000 alias i2c_3 off ops soc_amd_i2c_mmio_ops end device mmio 0xfedc9000 alias uart_0 off ops cezanne_uart_mmio_ops end device mmio 0xfedca000 alias uart_1 off ops cezanne_uart_mmio_ops end - device mmio 0xfedd5000 alias emmc off ops cezanne_emmc_mmio_ops end + device mmio 0xfedd5000 alias emmc off ops amd_emmc_mmio_ops end end diff --git a/src/soc/amd/cezanne/emmc.c b/src/soc/amd/cezanne/emmc.c deleted file mode 100644 index a699b20f51..0000000000 --- a/src/soc/amd/cezanne/emmc.c +++ /dev/null @@ -1,23 +0,0 @@ -/* 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, -}; diff --git a/src/soc/amd/common/block/emmc/Kconfig b/src/soc/amd/common/block/emmc/Kconfig new file mode 100644 index 0000000000..96bbada13b --- /dev/null +++ b/src/soc/amd/common/block/emmc/Kconfig @@ -0,0 +1,4 @@ +config SOC_AMD_COMMON_BLOCK_EMMC + bool + help + Select this option to use AMD common EMMC driver support. diff --git a/src/soc/amd/common/block/emmc/Makefile.inc b/src/soc/amd/common/block/emmc/Makefile.inc new file mode 100644 index 0000000000..ed68ab238d --- /dev/null +++ b/src/soc/amd/common/block/emmc/Makefile.inc @@ -0,0 +1 @@ +ramstage-$(CONFIG_SOC_AMD_COMMON_BLOCK_EMMC) += emmc.c diff --git a/src/soc/amd/common/block/emmc/emmc.c b/src/soc/amd/common/block/emmc/emmc.c new file mode 100644 index 0000000000..ee612e4110 --- /dev/null +++ b/src/soc/amd/common/block/emmc/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 amd_emmc_mmio_ops = { + .read_resources = emmc_read_resources, + .set_resources = noop_set_resources, + .scan_bus = scan_static_bus, + .enable = emmc_enable, +}; diff --git a/src/soc/amd/mendocino/Kconfig b/src/soc/amd/mendocino/Kconfig index 9608e41ec4..d31b29dd43 100644 --- a/src/soc/amd/mendocino/Kconfig +++ b/src/soc/amd/mendocino/Kconfig @@ -61,6 +61,7 @@ config SOC_SPECIFIC_OPTIONS select SOC_AMD_COMMON_BLOCK_APOB_HASH select SOC_AMD_COMMON_BLOCK_BANKED_GPIOS # TODO: Check if this is still correct select SOC_AMD_COMMON_BLOCK_DATA_FABRIC + select SOC_AMD_COMMON_BLOCK_EMMC select SOC_AMD_COMMON_BLOCK_ESPI_EXTENDED_DECODE_RANGES select SOC_AMD_COMMON_BLOCK_GRAPHICS # TODO: Check if this is still correct select SOC_AMD_COMMON_BLOCK_HAS_ESPI diff --git a/src/soc/amd/mendocino/Makefile.inc b/src/soc/amd/mendocino/Makefile.inc index 2952d18c4e..9549426694 100644 --- a/src/soc/amd/mendocino/Makefile.inc +++ b/src/soc/amd/mendocino/Makefile.inc @@ -36,7 +36,6 @@ 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/mendocino/chipset_mendocino.cb b/src/soc/amd/mendocino/chipset_mendocino.cb index 2a8d1877ff..5692d64563 100644 --- a/src/soc/amd/mendocino/chipset_mendocino.cb +++ b/src/soc/amd/mendocino/chipset_mendocino.cb @@ -93,5 +93,5 @@ chip soc/amd/mendocino device mmio 0xfedce000 alias uart_2 off ops mendocino_uart_mmio_ops end device mmio 0xfedcf000 alias uart_3 off ops mendocino_uart_mmio_ops end device mmio 0xfedd1000 alias uart_4 off ops mendocino_uart_mmio_ops end - device mmio 0xfedd5000 alias emmc off ops mendocino_emmc_mmio_ops end + device mmio 0xfedd5000 alias emmc off ops amd_emmc_mmio_ops end end diff --git a/src/soc/amd/mendocino/chipset_rembrandt.cb b/src/soc/amd/mendocino/chipset_rembrandt.cb index 2a8d1877ff..5692d64563 100644 --- a/src/soc/amd/mendocino/chipset_rembrandt.cb +++ b/src/soc/amd/mendocino/chipset_rembrandt.cb @@ -93,5 +93,5 @@ chip soc/amd/mendocino device mmio 0xfedce000 alias uart_2 off ops mendocino_uart_mmio_ops end device mmio 0xfedcf000 alias uart_3 off ops mendocino_uart_mmio_ops end device mmio 0xfedd1000 alias uart_4 off ops mendocino_uart_mmio_ops end - device mmio 0xfedd5000 alias emmc off ops mendocino_emmc_mmio_ops end + device mmio 0xfedd5000 alias emmc off ops amd_emmc_mmio_ops end end diff --git a/src/soc/amd/mendocino/emmc.c b/src/soc/amd/mendocino/emmc.c deleted file mode 100644 index ae01a1486b..0000000000 --- a/src/soc/amd/mendocino/emmc.c +++ /dev/null @@ -1,23 +0,0 @@ -/* 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 mendocino_emmc_mmio_ops = { - .read_resources = emmc_read_resources, - .set_resources = noop_set_resources, - .scan_bus = scan_static_bus, - .enable = emmc_enable, -}; diff --git a/src/soc/amd/morgana/Kconfig b/src/soc/amd/morgana/Kconfig index 8c7d87c4d2..f150d51175 100644 --- a/src/soc/amd/morgana/Kconfig +++ b/src/soc/amd/morgana/Kconfig @@ -51,6 +51,7 @@ config SOC_SPECIFIC_OPTIONS select SOC_AMD_COMMON_BLOCK_APOB_HASH select SOC_AMD_COMMON_BLOCK_BANKED_GPIOS select SOC_AMD_COMMON_BLOCK_DATA_FABRIC + select SOC_AMD_COMMON_BLOCK_EMMC select SOC_AMD_COMMON_BLOCK_ESPI_EXTENDED_DECODE_RANGES select SOC_AMD_COMMON_BLOCK_GRAPHICS select SOC_AMD_COMMON_BLOCK_HAS_ESPI diff --git a/src/soc/amd/morgana/Makefile.inc b/src/soc/amd/morgana/Makefile.inc index e99fa27088..6c80d237ba 100644 --- a/src/soc/amd/morgana/Makefile.inc +++ b/src/soc/amd/morgana/Makefile.inc @@ -37,7 +37,6 @@ 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/morgana/chipset.cb b/src/soc/amd/morgana/chipset.cb index 8510981f4d..e710ffb2ff 100644 --- a/src/soc/amd/morgana/chipset.cb +++ b/src/soc/amd/morgana/chipset.cb @@ -95,5 +95,5 @@ chip soc/amd/morgana device mmio 0xfedce000 alias uart_2 off ops morgana_uart_mmio_ops end device mmio 0xfedcf000 alias uart_3 off ops morgana_uart_mmio_ops end device mmio 0xfedd1000 alias uart_4 off ops morgana_uart_mmio_ops end - device mmio 0xfedd5000 alias emmc off ops morgana_emmc_mmio_ops end + device mmio 0xfedd5000 alias emmc off ops amd_emmc_mmio_ops end end diff --git a/src/soc/amd/morgana/emmc.c b/src/soc/amd/morgana/emmc.c deleted file mode 100644 index 4b43536ac0..0000000000 --- a/src/soc/amd/morgana/emmc.c +++ /dev/null @@ -1,23 +0,0 @@ -/* 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 morgana_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