Jianeng Ceng has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/81660?usp=email )
Change subject: [Test-only] ......................................................................
[Test-only]
Change-Id: I0e25863e720f247bc2813e40e29dcbb984973084 Signed-off-by: Jianeng Ceng cengjianeng@huaqin.corp-partner.google.com --- A src/drivers/generic/rt5645/Kconfig A src/drivers/generic/rt5645/Makefile.inc A src/drivers/generic/rt5645/chip.h A src/drivers/generic/rt5645/rt5645.c M src/mainboard/google/brya/Kconfig M src/mainboard/google/brya/variants/anraggar/overridetree.cb 6 files changed, 94 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/60/81660/1
diff --git a/src/drivers/generic/rt5645/Kconfig b/src/drivers/generic/rt5645/Kconfig new file mode 100644 index 0000000..a86d802 --- /dev/null +++ b/src/drivers/generic/rt5645/Kconfig @@ -0,0 +1,3 @@ +config DRIVERS_GENERIC_RT5645 + bool + depends on HAVE_ACPI_TABLES diff --git a/src/drivers/generic/rt5645/Makefile.inc b/src/drivers/generic/rt5645/Makefile.inc new file mode 100644 index 0000000..56f1601 --- /dev/null +++ b/src/drivers/generic/rt5645/Makefile.inc @@ -0,0 +1 @@ +ramstage-$(CONFIG_DRIVERS_GENERIC_RT5645) += rt5645.c diff --git a/src/drivers/generic/rt5645/chip.h b/src/drivers/generic/rt5645/chip.h new file mode 100644 index 0000000..fdbccf6 --- /dev/null +++ b/src/drivers/generic/rt5645/chip.h @@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <acpi/acpi_device.h> + +struct drivers_generic_rt5645_config { + const char *hid; /* ACPI _HID */ + struct acpi_gpio sleeve; /* sleeve power gate GPIO */ +}; diff --git a/src/drivers/generic/rt5645/rt5645.c b/src/drivers/generic/rt5645/rt5645.c new file mode 100644 index 0000000..697d4f0 --- /dev/null +++ b/src/drivers/generic/rt5645/rt5645.c @@ -0,0 +1,77 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <acpi/acpi_device.h> +#include <acpi/acpigen.h> +#include <console/console.h> +#include <device/device.h> +#include <device/path.h> +#include "chip.h" + +#define RT5645_ACPI_NAME "RT58" + +static void rt5645_fill_ssdt(const struct device *dev) +{ + struct drivers_generic_rt5645_config *config = dev->chip_info; + const char *path; + struct acpi_dp *dp; + + if (!config) + return; + + const char *scope = acpi_device_scope(dev); + const char *name = acpi_device_name(dev); + if (!scope || !name) + return; + + /* Device */ + acpigen_write_scope(scope); + acpigen_write_device(name); + + if (config->hid) + acpigen_write_name_string("_HID", config->hid); + else + acpigen_write_name_string("_HID", "10EC5650"); + acpigen_write_name_integer("_UID", 0); + acpigen_write_name_string("_DDN", dev->chip_ops->name); + acpigen_write_STA(acpi_device_status(dev)); + + /* Resources */ + acpigen_write_name("_CRS"); + acpigen_write_resourcetemplate_header(); + acpi_device_write_gpio(&config->sleeve); + acpigen_write_resourcetemplate_footer(); + + /* _DSD for devicetree properties */ + /* This points to the first pin in the first gpio entry in _CRS */ + path = acpi_device_path(dev); + dp = acpi_dp_new_table("_DSD"); + acpi_dp_add_gpio(dp, "cbj-sleeve-gpios", path, 0, 0, config->sleeve.active_low); + acpi_dp_write(dp); + + acpigen_pop_len(); /* Device */ + acpigen_pop_len(); /* Scope */ + + printk(BIOS_INFO, "%s: %s\n", path, dev->chip_ops->name); +} + +static const char *rt5645_acpi_name(const struct device *dev) +{ + return RT5645_ACPI_NAME; +} + +static struct device_operations rt5645_ops = { + .read_resources = noop_read_resources, + .set_resources = noop_set_resources, + .acpi_name = rt5645_acpi_name, + .acpi_fill_ssdt = rt5645_fill_ssdt, +}; + +static void rt5645_enable(struct device *dev) +{ + dev->ops = &rt5645_ops; +} + +struct chip_operations drivers_generic_rt5645_ops = { + CHIP_NAME("ASoC RT5645 Codec driver") + .enable_dev = rt5645_enable +}; diff --git a/src/mainboard/google/brya/Kconfig b/src/mainboard/google/brya/Kconfig index 160d12a..0c629d8 100644 --- a/src/mainboard/google/brya/Kconfig +++ b/src/mainboard/google/brya/Kconfig @@ -2,6 +2,7 @@
config BOARD_GOOGLE_BRYA_COMMON def_bool n + select DRIVERS_GENERIC_RT5645 select DRIVERS_GENERIC_ALC1015 select DRIVERS_GENERIC_GPIO_KEYS select DRIVERS_GENERIC_MAX98357A diff --git a/src/mainboard/google/brya/variants/anraggar/overridetree.cb b/src/mainboard/google/brya/variants/anraggar/overridetree.cb index c7942c1..4da0a04 100644 --- a/src/mainboard/google/brya/variants/anraggar/overridetree.cb +++ b/src/mainboard/google/brya/variants/anraggar/overridetree.cb @@ -359,6 +359,10 @@ register "property_list[0].integer" = "2" device i2c 1a on end end + chip drivers/generic/rt5645 + register "hid" = ""10EC5650"" + register "sleeve" = "ACPI_GPIO_OUTPUT_ACTIVE_LOW(GPP_A11)" + end end device ref i2c5 on chip drivers/i2c/hid