summaryrefslogtreecommitdiff
path: root/src/device
diff options
context:
space:
mode:
authorAngel Pons <th3fanbus@gmail.com>2021-03-18 16:00:14 +0100
committerPatrick Georgi <pgeorgi@google.com>2021-03-24 07:55:03 +0000
commit5d31dfa8df50dc6020a145f7c5123d93538167cc (patch)
tree740e5a54b25ef229a8263df681dcca22cae6050f /src/device
parent6da78660d055e7fdd7af07e824433921b500437b (diff)
downloadcoreboot-5d31dfa8df50dc6020a145f7c5123d93538167cc.tar.xz
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>
Diffstat (limited to 'src/device')
-rw-r--r--src/device/Kconfig8
-rw-r--r--src/device/azalia_device.c7
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);
}