summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/vendorcode/google/chromeos/Kconfig9
-rw-r--r--src/vendorcode/google/chromeos/Makefile.inc1
-rw-r--r--src/vendorcode/google/chromeos/chromeos.h11
-rw-r--r--src/vendorcode/google/chromeos/dsm_calib.c52
4 files changed, 73 insertions, 0 deletions
diff --git a/src/vendorcode/google/chromeos/Kconfig b/src/vendorcode/google/chromeos/Kconfig
index 2ff7ec70b8..cdb4305fdd 100644
--- a/src/vendorcode/google/chromeos/Kconfig
+++ b/src/vendorcode/google/chromeos/Kconfig
@@ -95,5 +95,14 @@ config CHROMEOS_USE_EC_WATCHDOG_FLAG
help
Use the AP watchdog flag stored in EC.
+config CHROMEOS_DSM_CALIB
+ bool
+ default n
+ help
+ On some boards, there are calibrated parameters for Dynamic Speaker Management(DSM)
+ stored in VPD. Enable this config to read and parse these VPD values and write them
+ to ACPI DSD table in device driver. These parameters will be applied by kernel driver
+ through device property at boot.
+
endif # CHROMEOS
endmenu
diff --git a/src/vendorcode/google/chromeos/Makefile.inc b/src/vendorcode/google/chromeos/Makefile.inc
index 000d056509..05acdeec9a 100644
--- a/src/vendorcode/google/chromeos/Makefile.inc
+++ b/src/vendorcode/google/chromeos/Makefile.inc
@@ -21,6 +21,7 @@ ramstage-y += vpd_mac.c vpd_serialno.c vpd_calibration.c
ramstage-$(CONFIG_CHROMEOS_DISABLE_PLATFORM_HIERARCHY_ON_RESUME) += tpm2.c
ramstage-$(CONFIG_HAVE_REGULATORY_DOMAIN) += wrdd.c
ramstage-$(CONFIG_USE_SAR) += sar.c
+ramstage-$(CONFIG_CHROMEOS_DSM_CALIB) += dsm_calib.c
ramstage-$(CONFIG_TPM_CR50) += cr50_enable_update.c
ifeq ($(CONFIG_ARCH_MIPS),)
bootblock-y += watchdog.c
diff --git a/src/vendorcode/google/chromeos/chromeos.h b/src/vendorcode/google/chromeos/chromeos.h
index e5420ac099..a40c4c9a88 100644
--- a/src/vendorcode/google/chromeos/chromeos.h
+++ b/src/vendorcode/google/chromeos/chromeos.h
@@ -23,6 +23,7 @@
#include <rules.h>
#include <security/vboot/misc.h>
#include <security/vboot/vboot_common.h>
+#include <types.h>
#if CONFIG(CHROMEOS)
/* functions implemented in watchdog.c */
@@ -58,6 +59,16 @@ static inline void chromeos_reserve_ram_oops(struct device *dev, int idx) {}
void cbmem_add_vpd_calibration_data(void);
+/**
+ * get_dsm_calibration_from_key - Gets value related to DSM calibration from VPD
+ * @key: The key in RO_VPD. The valid prefix is "dsm_calib_". The valid keys are
+ * documented in https://chromeos.google.com/partner/dlm/docs/factory/vpd.html.
+ * @value: Output value. The value read from VPD parsed into uint64_t integer.
+ *
+ * Returns CB_SUCCESS on success or CB_ERR on failure.
+ */
+enum cb_err get_dsm_calibration_from_key(const char *key, uint64_t *value);
+
/*
* Create the OIPG package containing the Chrome OS gpios described by
* the chromeos_gpio array.
diff --git a/src/vendorcode/google/chromeos/dsm_calib.c b/src/vendorcode/google/chromeos/dsm_calib.c
new file mode 100644
index 0000000000..d3b14cb03c
--- /dev/null
+++ b/src/vendorcode/google/chromeos/dsm_calib.c
@@ -0,0 +1,52 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2019 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.
+ */
+
+#include <console/console.h>
+#include <drivers/vpd/vpd.h>
+#include <stdint.h>
+#include <string.h>
+#include <types.h>
+#include <vendorcode/google/chromeos/chromeos.h>
+
+#define DSM_BUF_LEN 128
+#define DSM_PREFIX "dsm_calib_"
+
+enum cb_err get_dsm_calibration_from_key(const char *key, uint64_t *value)
+{
+ static char buf[DSM_BUF_LEN];
+ char *ret;
+ long value_from_vpd;
+
+ if (strncmp(key, DSM_PREFIX, strlen(DSM_PREFIX))) {
+ printk(BIOS_ERR, "got invalid dsm_calib key: %s\n", key);
+ return CB_ERR;
+ }
+
+ ret = vpd_gets(key, buf, DSM_BUF_LEN, VPD_RO);
+ if (!ret) {
+ printk(BIOS_ERR, "failed to find key in VPD: %s\n", key);
+ return CB_ERR;
+ }
+
+ value_from_vpd = atol(buf);
+ if (value_from_vpd <= 0) {
+ printk(BIOS_ERR, "got invalid dsm_calib from VPD: %ld\n", value_from_vpd);
+ return CB_ERR;
+ }
+
+ *value = value_from_vpd;
+
+ return CB_SUCCESS;
+}