mb/purism/librem_cnl: Enable Librem 14 jack detect with fixed EC

Use verbs enabling jack detect if the EC firmware has been updated
with fixed jack detection.

Test: Build Librem 14 and boot with latest EC, test headset jack
detection.

Change-Id: I57a27b1d51e4f6c7c712bcb2823d21692b9c5ce6
Signed-off-by: Jonathon Hall <jonathon.hall@puri.sm>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/74364
Reviewed-by: Paul Menzel <paulepanter@mailbox.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
This commit is contained in:
Jonathon Hall 2023-03-03 10:28:15 -05:00 committed by Felix Held
parent a41c825068
commit 9fb599bd9b
1 changed files with 29 additions and 2 deletions

View File

@ -1,6 +1,8 @@
/* SPDX-License-Identifier: GPL-2.0-only */ /* SPDX-License-Identifier: GPL-2.0-only */
#include <device/azalia_device.h> #include <device/azalia_device.h>
#include <ec/purism/librem-ec/librem_ec.h>
#include <console/console.h>
const u32 cim_verb_data[] = { const u32 cim_verb_data[] = {
0x10ec0256, /* Codec Vendor/Device ID: Realtek ALC256 */ 0x10ec0256, /* Codec Vendor/Device ID: Realtek ALC256 */
@ -14,12 +16,12 @@ const u32 cim_verb_data[] = {
AZALIA_PIN_CFG(0, 0x13, 0x411111f0), /* NC */ AZALIA_PIN_CFG(0, 0x13, 0x411111f0), /* NC */
AZALIA_PIN_CFG(0, 0x14, 0x90170110), /* Internal speakers */ AZALIA_PIN_CFG(0, 0x14, 0x90170110), /* Internal speakers */
AZALIA_PIN_CFG(0, 0x18, 0x411111f0), /* NC */ AZALIA_PIN_CFG(0, 0x18, 0x411111f0), /* NC */
AZALIA_PIN_CFG(0, 0x19, 0x04a11130), /* Jack analog mic */ AZALIA_PIN_CFG(0, 0x19, 0x02a11030), /* Jack analog mic */
AZALIA_PIN_CFG(0, 0x1a, 0x411111f0), /* NC */ AZALIA_PIN_CFG(0, 0x1a, 0x411111f0), /* NC */
AZALIA_PIN_CFG(0, 0x1b, 0x411111f0), /* NC */ AZALIA_PIN_CFG(0, 0x1b, 0x411111f0), /* NC */
AZALIA_PIN_CFG(0, 0x1d, 0x411111f0), /* NC */ AZALIA_PIN_CFG(0, 0x1d, 0x411111f0), /* NC */
AZALIA_PIN_CFG(0, 0x1e, 0x411111f0), /* NC */ AZALIA_PIN_CFG(0, 0x1e, 0x411111f0), /* NC */
AZALIA_PIN_CFG(0, 0x21, 0x04211120), /* Jack analog out */ AZALIA_PIN_CFG(0, 0x21, 0x02211020), /* Jack analog out */
/* Hidden SW reset */ /* Hidden SW reset */
0x0205001a, 0x0205001a,
@ -58,3 +60,28 @@ const u32 cim_verb_data[] = {
const u32 pc_beep_verbs[] = {}; const u32 pc_beep_verbs[] = {};
AZALIA_ARRAY_SIZES; AZALIA_ARRAY_SIZES;
/* Older verbs with no jack detect - needed if an older Librem EC is in use that
lacks jack detect. Headphones can be selected manually. */
static const u32 no_jack_detect_verbs[] = {
AZALIA_PIN_CFG(0, 0x19, 0x04a11130), /* Jack analog mic */
AZALIA_PIN_CFG(0, 0x21, 0x04211120), /* Jack analog out */
};
void mainboard_azalia_program_runtime_verbs(u8 *base, u32 viddid)
{
if (viddid == 0x10ec0256) {
/* Now that the codec is configured, we can check if the EC has
jack detect. */
if (librem_ec_has_jack_detect()) {
printk(BIOS_INFO, "EC jack detect enabled\n");
} else {
printk(BIOS_WARNING, "EC firmware lacks jack detect, applying workaround.\n");
printk(BIOS_WARNING, "Update to Librem-EC 1.13 or later for jack detect.\n");
/* The EC firmware lacks jack detect. Program the
older workaround verbs with no jack detect. */
azalia_program_verb_table(base, no_jack_detect_verbs,
ARRAY_SIZE(no_jack_detect_verbs));
}
}
}