From 9fb599bd9b4c73e573842a2a874964034034484e Mon Sep 17 00:00:00 2001 From: Jonathon Hall Date: Fri, 3 Mar 2023 10:28:15 -0500 Subject: 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 Reviewed-on: https://review.coreboot.org/c/coreboot/+/74364 Reviewed-by: Paul Menzel Tested-by: build bot (Jenkins) Reviewed-by: Angel Pons --- .../librem_cnl/variants/librem_14/hda_verb.c | 31 ++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mainboard/purism/librem_cnl/variants/librem_14/hda_verb.c b/src/mainboard/purism/librem_cnl/variants/librem_14/hda_verb.c index 1256c1721b..4e2fc2d128 100644 --- a/src/mainboard/purism/librem_cnl/variants/librem_14/hda_verb.c +++ b/src/mainboard/purism/librem_cnl/variants/librem_14/hda_verb.c @@ -1,6 +1,8 @@ /* SPDX-License-Identifier: GPL-2.0-only */ #include +#include +#include const u32 cim_verb_data[] = { 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, 0x14, 0x90170110), /* Internal speakers */ 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, 0x1b, 0x411111f0), /* NC */ AZALIA_PIN_CFG(0, 0x1d, 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 */ 0x0205001a, @@ -58,3 +60,28 @@ const u32 cim_verb_data[] = { const u32 pc_beep_verbs[] = {}; 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)); + } + } +} -- cgit v1.2.3