From 2b7dbf80c981b7892d4a2077e0ccfe9775e1db1f Mon Sep 17 00:00:00 2001 From: Nicholas Sudsgaard Date: Thu, 7 Aug 2025 09:18:32 +0900 Subject: [PATCH] mb/apple: Replace verb tables with reworked implementation Some boards did not provide the chip name for the audio codecs in the comments, and therefore we made the following assumptions based off the vendor ID: macbookair4_2: - 0x10134206 -> Cirrus Logic CS4206[1] It should be noted that some factors (e.g. revision) can cause the chip name to differ even with the same vendor ID. This is especially common for Realtek audio codecs. The Kconfigs were reverted using the following command: find src/mainboard/apple -name 'Kconfig' | xargs git checkout main It should be noted that we do not modifiy the verb tables in any case, as it would break the regression test script mentioned in the TEST section below. For an overall rationale for this rework, see CB:88656. References: [1] Linux kernel: sound/hda/codecs/cirrus/cs420x.c:770 TEST= All boards passed regression test (CB:88763) Change-Id: I1fcfa0e5e1af27dc5b0dc77bf471a7636b361cbe Signed-off-by: Nicholas Sudsgaard Reviewed-on: https://review.coreboot.org/c/coreboot/+/88660 Tested-by: build bot (Jenkins) Reviewed-by: Matt DeVillier Reviewed-by: Angel Pons --- src/mainboard/apple/macbook21/Kconfig | 1 - src/mainboard/apple/macbook21/hda_verb.c | 28 ++++++++++++------ src/mainboard/apple/macbookair4_2/Kconfig | 1 - src/mainboard/apple/macbookair4_2/hda_verb.c | 30 +++++++++++++++----- 4 files changed, 43 insertions(+), 17 deletions(-) diff --git a/src/mainboard/apple/macbook21/Kconfig b/src/mainboard/apple/macbook21/Kconfig index b8880120db..330d8efae2 100644 --- a/src/mainboard/apple/macbook21/Kconfig +++ b/src/mainboard/apple/macbook21/Kconfig @@ -4,7 +4,6 @@ if BOARD_APPLE_MACBOOK11 || BOARD_APPLE_MACBOOK21 || BOARD_APPLE_IMAC52 config BOARD_SPECIFIC_OPTIONS def_bool y - select AZALIA_USE_LEGACY_VERB_TABLE select SYSTEM_TYPE_LAPTOP select CPU_INTEL_SOCKET_M select NORTHBRIDGE_INTEL_I945 diff --git a/src/mainboard/apple/macbook21/hda_verb.c b/src/mainboard/apple/macbook21/hda_verb.c index 9146b3fdfc..d06fc0170f 100644 --- a/src/mainboard/apple/macbook21/hda_verb.c +++ b/src/mainboard/apple/macbook21/hda_verb.c @@ -2,11 +2,10 @@ #include -const u32 cim_verb_data[] = { - 0x83847680, /* Codec Vendor / Device ID: SigmaTel STAC9221 A1 */ #if CONFIG(BOARD_APPLE_MACBOOK11) || CONFIG(BOARD_APPLE_MACBOOK21) - 0x106b2200, /* Subsystem ID */ - 11, /* Number of 4 dword sets */ +static const u32 sigmatel_stac9221_a1_subsystem_id = 0x106b2200; + +static const u32 sigmatel_stac9221_a1_verbs[] = { AZALIA_SUBVENDOR(0, 0x106b2200), AZALIA_PIN_CFG(0, 0x0a, 0x0321e21f), AZALIA_PIN_CFG(0, 0x0b, 0x03a1e02e), @@ -18,9 +17,11 @@ const u32 cim_verb_data[] = { AZALIA_PIN_CFG(0, 0x11, 0x13c5e240), AZALIA_PIN_CFG(0, 0x15, 0x400000fc), AZALIA_PIN_CFG(0, 0x1b, 0x400000fb), +}; #else /* CONFIG_BOARD_APPLE_IMAC52 */ - 0x106b0f00, /* Subsystem ID */ - 11, /* Number of 4 dword sets */ +static const u32 sigmatel_stac9221_a1_subsystem_id = 0x106b0f00; + +static const u32 sigmatel_stac9221_a1_verbs[] = { AZALIA_SUBVENDOR(0, 0x106b0f00), AZALIA_PIN_CFG(0, 0x0a, 0x012be032), AZALIA_PIN_CFG(0, 0x0b, 0x90afe111), @@ -32,10 +33,21 @@ const u32 cim_verb_data[] = { AZALIA_PIN_CFG(0, 0x11, 0x11cbc022), AZALIA_PIN_CFG(0, 0x15, 0x4080e10f), AZALIA_PIN_CFG(0, 0x1b, 0x4080e10f), -#endif - }; +#endif const u32 pc_beep_verbs[0] = {}; +struct azalia_codec mainboard_azalia_codecs[] = { + { + .name = "Sigmatel STAC9221 A1", + .vendor_id = 0x83847680, + .subsystem_id = sigmatel_stac9221_a1_subsystem_id, + .address = 0, + .verbs = sigmatel_stac9221_a1_verbs, + .verb_count = ARRAY_SIZE(sigmatel_stac9221_a1_verbs), + }, + { /* terminator */ } +}; + AZALIA_ARRAY_SIZES; diff --git a/src/mainboard/apple/macbookair4_2/Kconfig b/src/mainboard/apple/macbookair4_2/Kconfig index f340761bb1..39b14a2487 100644 --- a/src/mainboard/apple/macbookair4_2/Kconfig +++ b/src/mainboard/apple/macbookair4_2/Kconfig @@ -4,7 +4,6 @@ if BOARD_APPLE_MACBOOKAIR4_2 config BOARD_SPECIFIC_OPTIONS def_bool y - select AZALIA_USE_LEGACY_VERB_TABLE select BOARD_ROMSIZE_KB_8192 select EC_ACPI select HAVE_ACPI_RESUME diff --git a/src/mainboard/apple/macbookair4_2/hda_verb.c b/src/mainboard/apple/macbookair4_2/hda_verb.c index d2acefbaa7..d855862f49 100644 --- a/src/mainboard/apple/macbookair4_2/hda_verb.c +++ b/src/mainboard/apple/macbookair4_2/hda_verb.c @@ -2,10 +2,7 @@ #include -const u32 cim_verb_data[] = { - 0x10134206, /* Codec Vendor / Device ID: Cirrus */ - 0x106b5b00, /* Subsystem ID */ - 11, /* Number of 4 dword sets */ +static const u32 cirrus_logic_cs4206_verbs[] = { AZALIA_SUBVENDOR(0, 0x106b5b00), AZALIA_PIN_CFG(0, 0x09, 0x012b4030), AZALIA_PIN_CFG(0, 0x0a, 0x400000f0), @@ -17,10 +14,9 @@ const u32 cim_verb_data[] = { AZALIA_PIN_CFG(0, 0x10, 0x400000f0), AZALIA_PIN_CFG(0, 0x12, 0x400000f0), AZALIA_PIN_CFG(0, 0x15, 0x400000f0), +}; - 0x80862805, /* Codec Vendor / Device ID: Intel */ - 0x80860101, /* Subsystem ID */ - 4, /* Number of 4 dword sets */ +static const u32 intel_display_audio_verbs[] = { AZALIA_SUBVENDOR(3, 0x80860101), AZALIA_PIN_CFG(3, 0x05, 0x18560010), AZALIA_PIN_CFG(3, 0x06, 0x18560010), @@ -29,4 +25,24 @@ const u32 cim_verb_data[] = { const u32 pc_beep_verbs[0] = {}; +struct azalia_codec mainboard_azalia_codecs[] = { + { + .name = "Cirrus Logic CS4206", + .vendor_id = 0x10134206, + .subsystem_id = 0x106b5b00, + .address = 0, + .verbs = cirrus_logic_cs4206_verbs, + .verb_count = ARRAY_SIZE(cirrus_logic_cs4206_verbs), + }, + { + .name = "Intel Display Audio (HDMI/DP)", + .vendor_id = 0x80862805, + .subsystem_id = 0x80860101, + .address = 3, + .verbs = intel_display_audio_verbs, + .verb_count = ARRAY_SIZE(intel_display_audio_verbs), + }, + { /* terminator */ } +}; + AZALIA_ARRAY_SIZES;