summaryrefslogtreecommitdiff
path: root/src/soc/amd/common/block/emmc/emmc.c
blob: 9242d715512c75a78aa4f57f1e940ee490d1489b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* SPDX-License-Identifier: GPL-2.0-only */

#include <acpi/acpigen.h>
#include <amdblocks/aoac.h>
#include <device/device.h>
#include <soc/aoac_defs.h>

static void emmc_read_resources(struct device *dev)
{
	mmio_range(dev, 0, dev->path.mmio.addr, 4 * KiB);
}

static void emmc_enable(struct device *dev)
{
	if (!dev->enabled && !CONFIG(SOC_AMD_COMMON_BLOCK_EMMC_SKIP_POWEROFF))
		power_off_aoac_device(FCH_AOAC_DEV_EMMC);
}

static const char *emmc_acpi_name(const struct device *dev)
{
	return "MMC0";
}

static void emmc_acpi_fill_ssdt(const struct device *dev)
{
	acpigen_write_scope(acpi_device_path(dev));
	acpigen_write_store_int_to_namestr(acpi_device_status(dev), "STAT");
	acpigen_pop_len(); /* Scope */
}

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,
	.acpi_name = emmc_acpi_name,
	.acpi_fill_ssdt = emmc_acpi_fill_ssdt,
};