aboutsummaryrefslogtreecommitdiff
path: root/src/soc/amd/common
diff options
context:
space:
mode:
authorFelix Held <felix-coreboot@felixheld.de>2022-10-13 20:58:47 +0200
committerFelix Held <felix-coreboot@felixheld.de>2022-10-14 20:18:29 +0000
commit65d73cc4573a23b4d98e3156cc1c4d0a1b09cb96 (patch)
treef8567513da4a2532131b94a574b35be89cf42349 /src/soc/amd/common
parent5e2f1b1e646da2e2333252f1f798dff419df0309 (diff)
soc/amd: factor out common eMMC code
Signed-off-by: Felix Held <felix-coreboot@felixheld.de> Change-Id: If5447f9272183f83bc422520ada93d3cfd96551e Reviewed-on: https://review.coreboot.org/c/coreboot/+/68415 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Martin Roth <martin.roth@amd.corp-partner.google.com>
Diffstat (limited to 'src/soc/amd/common')
-rw-r--r--src/soc/amd/common/block/emmc/Kconfig4
-rw-r--r--src/soc/amd/common/block/emmc/Makefile.inc1
-rw-r--r--src/soc/amd/common/block/emmc/emmc.c23
3 files changed, 28 insertions, 0 deletions
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 <amdblocks/aoac.h>
+#include <device/device.h>
+#include <soc/aoac_defs.h>
+
+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,
+};