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 <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/51640
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
This commit is contained in:
Angel Pons 2021-03-18 16:00:14 +01:00 committed by Patrick Georgi
parent 6da78660d0
commit 5d31dfa8df
2 changed files with 12 additions and 3 deletions

View File

@ -519,6 +519,14 @@ config AZALIA_PLUGIN_SUPPORT
bool bool
default n 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 config PCIEXP_PLUGIN_SUPPORT
bool bool
default y default y

View File

@ -50,6 +50,7 @@ int azalia_exit_reset(u8 *base)
static u16 codec_detect(u8 *base) static u16 codec_detect(u8 *base)
{ {
struct stopwatch sw; struct stopwatch sw;
const u16 codec_mask = (1 << CONFIG_AZALIA_MAX_CODECS) - 1;
u16 reg16; u16 reg16;
if (azalia_exit_reset(base) < 0) if (azalia_exit_reset(base) < 0)
@ -57,7 +58,7 @@ static u16 codec_detect(u8 *base)
/* clear STATESTS bits (BAR + 0xe)[2:0] */ /* clear STATESTS bits (BAR + 0xe)[2:0] */
reg16 = read16(base + HDA_STATESTS_REG); reg16 = read16(base + HDA_STATESTS_REG);
reg16 |= 7; reg16 |= codec_mask;
write16(base + HDA_STATESTS_REG, reg16); write16(base + HDA_STATESTS_REG, reg16);
/* Wait for readback of register to /* Wait for readback of register to
@ -82,7 +83,7 @@ static u16 codec_detect(u8 *base)
/* Read in Codec location (BAR + 0xe)[2..0] */ /* Read in Codec location (BAR + 0xe)[2..0] */
reg16 = read16(base + HDA_STATESTS_REG); reg16 = read16(base + HDA_STATESTS_REG);
reg16 &= 0x0f; reg16 &= codec_mask;
if (!reg16) if (!reg16)
goto no_codec; goto no_codec;
@ -265,7 +266,7 @@ static void codecs_init(struct device *dev, u8 *base, u16 codec_mask)
{ {
int i; int i;
for (i = 2; i >= 0; i--) { for (i = CONFIG_AZALIA_MAX_CODECS - 1; i >= 0; i--) {
if (codec_mask & (1 << i)) if (codec_mask & (1 << i))
codec_init(dev, base, i); codec_init(dev, base, i);
} }