From 5d31dfa8df50dc6020a145f7c5123d93538167cc Mon Sep 17 00:00:00 2001 From: Angel Pons Date: Thu, 18 Mar 2021 16:00:14 +0100 Subject: [PATCH] device/azalia_device.c: Introduce AZALIA_MAX_CODECS Add the AZALIA_MAX_CODECS Kconfig option and use it. Change-Id: Ibb10c2f2992257bc261e6cb35f11cc4b2d956054 Signed-off-by: Angel Pons Reviewed-on: https://review.coreboot.org/c/coreboot/+/51640 Tested-by: build bot (Jenkins) Reviewed-by: Nico Huber Reviewed-by: Patrick Rudolph --- src/device/Kconfig | 8 ++++++++ src/device/azalia_device.c | 7 ++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/device/Kconfig b/src/device/Kconfig index 8dc9ecdff9..1bfc34a982 100644 --- a/src/device/Kconfig +++ b/src/device/Kconfig @@ -519,6 +519,14 @@ config AZALIA_PLUGIN_SUPPORT bool default n +config AZALIA_MAX_CODECS + int + depends on AZALIA_PLUGIN_SUPPORT + default 3 + range 1 15 + help + The maximum number of codecs supported on a single HD Audio controller. + config PCIEXP_PLUGIN_SUPPORT bool default y diff --git a/src/device/azalia_device.c b/src/device/azalia_device.c index 1048804add..ad0858affa 100644 --- a/src/device/azalia_device.c +++ b/src/device/azalia_device.c @@ -50,6 +50,7 @@ int azalia_exit_reset(u8 *base) static u16 codec_detect(u8 *base) { struct stopwatch sw; + const u16 codec_mask = (1 << CONFIG_AZALIA_MAX_CODECS) - 1; u16 reg16; if (azalia_exit_reset(base) < 0) @@ -57,7 +58,7 @@ static u16 codec_detect(u8 *base) /* clear STATESTS bits (BAR + 0xe)[2:0] */ reg16 = read16(base + HDA_STATESTS_REG); - reg16 |= 7; + reg16 |= codec_mask; write16(base + HDA_STATESTS_REG, reg16); /* Wait for readback of register to @@ -82,7 +83,7 @@ static u16 codec_detect(u8 *base) /* Read in Codec location (BAR + 0xe)[2..0] */ reg16 = read16(base + HDA_STATESTS_REG); - reg16 &= 0x0f; + reg16 &= codec_mask; if (!reg16) goto no_codec; @@ -265,7 +266,7 @@ static void codecs_init(struct device *dev, u8 *base, u16 codec_mask) { int i; - for (i = 2; i >= 0; i--) { + for (i = CONFIG_AZALIA_MAX_CODECS - 1; i >= 0; i--) { if (codec_mask & (1 << i)) codec_init(dev, base, i); }