Kevin Chang has uploaded this change for review.

View Change

grunt/treeya: add Realtek ALC5682 codec support

ALC5682 i2c address: 0x1A

BUG=b:185972050
BRANCH=master
TEST=emerge-grunt coreboot

Signed-off-by: Kevin Chang <kevin.chang@lcfc.corp-partner.google.com>
Change-Id: I49c673fd944b2c2a79c4283eee941a16596ba7fa
---
M src/mainboard/google/kahlee/variants/treeya/Makefile.inc
A src/mainboard/google/kahlee/variants/treeya/audio.c
M src/mainboard/google/kahlee/variants/treeya/devicetree.cb
A src/mainboard/google/kahlee/variants/treeya/include/variant/sku.h
4 files changed, 98 insertions(+), 0 deletions(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/00/56100/1
diff --git a/src/mainboard/google/kahlee/variants/treeya/Makefile.inc b/src/mainboard/google/kahlee/variants/treeya/Makefile.inc
index 21b0276..525e76c 100644
--- a/src/mainboard/google/kahlee/variants/treeya/Makefile.inc
+++ b/src/mainboard/google/kahlee/variants/treeya/Makefile.inc
@@ -1,3 +1,5 @@
# SPDX-License-Identifier: GPL-2.0-only

subdirs-y += ./spd
+
+ramstage-y += audio.c
diff --git a/src/mainboard/google/kahlee/variants/treeya/audio.c b/src/mainboard/google/kahlee/variants/treeya/audio.c
new file mode 100644
index 0000000..e40ad57
--- /dev/null
+++ b/src/mainboard/google/kahlee/variants/treeya/audio.c
@@ -0,0 +1,60 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#include <ec/google/chromeec/ec.h>
+#include <baseboard/variants.h>
+#include <variant/sku.h>
+#include <string.h>
+#include <drivers/i2c/hid/chip.h>
+
+extern struct chip_operations drivers_i2c_generic_ops;
+extern struct chip_operations drivers_i2c_da7219_ops;
+
+void variant_devtree_update(void)
+{
+ uint32_t sku = google_chromeec_get_sku_id();
+ struct device *mmio_dev = NULL, *child = NULL;
+ struct device *alc_dev = NULL, *da7219_dev = NULL;
+
+ while (1) {
+ mmio_dev = dev_find_path(mmio_dev, DEVICE_PATH_MMIO);
+ if (mmio_dev == NULL)
+ break;
+ if (mmio_dev->path.mmio.addr == 0xfedc2000)
+ break;
+ }
+
+ if (mmio_dev == NULL)
+ return;
+
+ while ((child = dev_bus_each_child(mmio_dev->link_list, child)) != NULL) {
+ if (child->path.type != DEVICE_PATH_I2C)
+ continue;
+ if (child->path.i2c.device != 0x1a)
+ continue;
+ if (child->chip_ops == &drivers_i2c_generic_ops) {
+ struct drivers_i2c_generic_config *config = child->chip_info;
+ if (!strcmp(config->hid, "10EC5682"))
+ alc_dev = child;
+ } else if (child->chip_ops == &drivers_i2c_da7219_ops) {
+ da7219_dev = child;
+ }
+ }
+
+ switch (sku) {
+ default:
+ /* da7219 only */
+ if (da7219_dev)
+ da7219_dev->enabled = 1;
+ if (alc_dev)
+ alc_dev->enabled = 0;
+ break;
+ case SKU_TREEYA_ALC5682_AE:
+ case SKU_TREEYA_ALC5682_AF:
+ /* alc5682 only */
+ if (da7219_dev)
+ da7219_dev->enabled = 0;
+ if (alc_dev)
+ alc_dev->enabled = 1;
+ break;
+ }
+}
diff --git a/src/mainboard/google/kahlee/variants/treeya/devicetree.cb b/src/mainboard/google/kahlee/variants/treeya/devicetree.cb
index 183e3dd..0050d80 100644
--- a/src/mainboard/google/kahlee/variants/treeya/devicetree.cb
+++ b/src/mainboard/google/kahlee/variants/treeya/devicetree.cb
@@ -110,6 +110,21 @@
register "mclk_name" = ""oscout1""
device i2c 1a on end
end
+ chip drivers/i2c/generic
+ register "hid" = ""10EC5682""
+ register "name" = ""RT58""
+ register "uid" = "1"
+ register "desc" = ""Realtek RT5682""
+ register "irq_gpio" = "ACPI_GPIO_IRQ_EDGE_BOTH(GPIO_14)"
+ register "property_count" = "2"
+ register "property_list[0].type" = "ACPI_DP_TYPE_INTEGER"
+ register "property_list[0].name" = ""realtek,jd-src""
+ register "property_list[0].integer" = "1"
+ register "property_list[1].type" = "ACPI_DP_TYPE_STRING"
+ register "property_list[1].name" = ""realtek,mclk-name""
+ register "property_list[1].string" = ""oscout1""
+ device i2c 1a on end
+ end
chip drivers/generic/max98357a
register "hid" = ""MX98357A""
register "sdmode_gpio" = "ACPI_GPIO_OUTPUT_ACTIVE_HIGH(GPIO_119)"
diff --git a/src/mainboard/google/kahlee/variants/treeya/include/variant/sku.h b/src/mainboard/google/kahlee/variants/treeya/include/variant/sku.h
new file mode 100644
index 0000000..fd4fe34
--- /dev/null
+++ b/src/mainboard/google/kahlee/variants/treeya/include/variant/sku.h
@@ -0,0 +1,21 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2017 Google Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+/* SKU ID enumeration */
+enum treeya_sku {
+ SKU_UNKNOWN = -1,
+ SKU_TREEYA_ALC5682_AE = 174,
+ SKU_TREEYA_ALC5682_AF = 175,
+};

To view, visit change 56100. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I49c673fd944b2c2a79c4283eee941a16596ba7fa
Gerrit-Change-Number: 56100
Gerrit-PatchSet: 1
Gerrit-Owner: Kevin Chang <kevin.chang@lcfc.corp-partner.google.com>
Gerrit-MessageType: newchange