From ecf202b8e4ac085f8b09b942a48e7f745fdac0d6 Mon Sep 17 00:00:00 2001 From: Nico Huber Date: Sat, 20 Jul 2024 12:54:03 +0200 Subject: [PATCH] device/azalia: Add missing 521us delay after RESET# de-assertion The spec[1] says a codec is allowed to take up to 521us before sig- naling an initialization request. Our original SB600 implementation had a 1ms delay here since commit 4505948faec7 ("Use the correct device for switching on HDA.") Most codecs are a lot faster, which is probably why nobody noticed the missing delay. For instance, the Realtek ALC272 datasheet spe- cifies a 1 frame (1/48kHz) maximum[2]. It doesn't hurt, though, to be correct here. We have a lot longer delays around. [1] High Definition Audio Specification 1.0a: "4.3 Codec Discovery" [2] ALC272 datasheet: "9.2.1. Link Reset and Initialization Timing" TEST= Verbs were loaded correctly on off-tree HP ProBook 450 G3. Change-Id: Ifd3357758fb3678e60b4c6edcfbdb60b3bda9746 Signed-off-by: Nico Huber Signed-off-by: Nicholas Sudsgaard Reviewed-on: https://review.coreboot.org/c/coreboot/+/89651 Tested-by: build bot (Jenkins) Reviewed-by: Alicja Michalska --- src/device/azalia_device.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/device/azalia_device.c b/src/device/azalia_device.c index 82c6fdca41..937ca89f55 100644 --- a/src/device/azalia_device.c +++ b/src/device/azalia_device.c @@ -40,7 +40,13 @@ enum cb_err azalia_enter_reset(u8 *base) enum cb_err azalia_exit_reset(u8 *base) { /* Set bit 0 to 1 to exit reset state (BAR + 0x8)[0] */ - return azalia_set_bits(base + HDA_GCTL_REG, HDA_GCTL_CRST, HDA_GCTL_CRST); + if (azalia_set_bits(base + HDA_GCTL_REG, HDA_GCTL_CRST, HDA_GCTL_CRST) != CB_SUCCESS) + return CB_ERR; + + /* Codecs have up to 25 frames (at 48kHz) to signal an + initialization request (HDA Spec 1.0a "4.3 Codec Discovery"). */ + udelay(521); + return CB_SUCCESS; } static u16 codec_detect(u8 *base)