summaryrefslogtreecommitdiffstats
path: root/src/southbridge
diff options
context:
space:
mode:
authorAngel Pons <th3fanbus@gmail.com>2021-11-10 17:35:19 +0100
committerPaul Fagerburg <pfagerburg@chromium.org>2021-11-11 22:44:06 +0000
commitb7a6a1e4ac2bca3632a8dc00406d3bb77db2073c (patch)
treef144fcd1d45e8443eaab3814ecd021979cc3da57 /src/southbridge
parent992c8603f0d67887d36dd52ae3dbe690ed3f9104 (diff)
downloadcoreboot-b7a6a1e4ac2bca3632a8dc00406d3bb77db2073c.tar.gz
coreboot-b7a6a1e4ac2bca3632a8dc00406d3bb77db2073c.tar.bz2
coreboot-b7a6a1e4ac2bca3632a8dc00406d3bb77db2073c.zip
sb/intel/bd82x6x: Use `azalia_codecs_init()`
Use the functionally-equivalent common Azalia code to get rid of redundant code. Change-Id: I982c1725d5affe95a20aa6713a246cd6b1ad270c Signed-off-by: Angel Pons <th3fanbus@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/59114 Reviewed-by: Arthur Heymans <arthur@aheymans.xyz> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/southbridge')
-rw-r--r--src/southbridge/intel/bd82x6x/Kconfig3
-rw-r--r--src/southbridge/intel/bd82x6x/azalia.c97
2 files changed, 4 insertions, 96 deletions
diff --git a/src/southbridge/intel/bd82x6x/Kconfig b/src/southbridge/intel/bd82x6x/Kconfig
index c9e86625d297..ee8a5ccc5641 100644
--- a/src/southbridge/intel/bd82x6x/Kconfig
+++ b/src/southbridge/intel/bd82x6x/Kconfig
@@ -37,6 +37,9 @@ config SOUTH_BRIDGE_OPTIONS
select SOUTHBRIDGE_INTEL_COMMON_WATCHDOG
select SOUTHBRIDGE_INTEL_COMMON_USB_DEBUG
+config AZALIA_MAX_CODECS
+ default 4
+
config EHCI_BAR
hex
default 0xfef00000
diff --git a/src/southbridge/intel/bd82x6x/azalia.c b/src/southbridge/intel/bd82x6x/azalia.c
index 974a390c3896..ae9b82176ef5 100644
--- a/src/southbridge/intel/bd82x6x/azalia.c
+++ b/src/southbridge/intel/bd82x6x/azalia.c
@@ -37,101 +37,6 @@ no_codec:
return 0;
}
-/*
- * Wait 50usec for the codec to indicate it is ready.
- * No response would imply that the codec is non-operative.
- */
-
-static int wait_for_ready(u8 *base)
-{
- /* Use a 1msec timeout */
- int timeout = 1000;
-
- while (timeout--) {
- u32 reg32 = read32(base + HDA_ICII_REG);
- if (!(reg32 & HDA_ICII_BUSY))
- return 0;
- udelay(1);
- }
-
- return -1;
-}
-
-/*
- * Wait 50usec for the codec to indicate that it accepted the previous command.
- * No response would imply that the code is non-operative.
- */
-
-static int wait_for_valid(u8 *base)
-{
- u32 reg32;
- /* Use a 1msec timeout */
- int timeout = 1000;
-
- /* Send the verb to the codec */
- reg32 = read32(base + HDA_ICII_REG);
- reg32 |= HDA_ICII_BUSY | HDA_ICII_VALID;
- write32(base + HDA_ICII_REG, reg32);
-
- while (timeout--) {
- reg32 = read32(base + HDA_ICII_REG);
- if ((reg32 & (HDA_ICII_VALID | HDA_ICII_BUSY)) == HDA_ICII_VALID)
- return 0;
- udelay(1);
- }
-
- return -1;
-}
-
-static void codec_init(struct device *dev, u8 *base, int addr)
-{
- u32 reg32;
- const u32 *verb;
- u32 verb_size;
-
- printk(BIOS_DEBUG, "Azalia: Initializing codec #%d\n", addr);
-
- /* 1 */
- if (wait_for_ready(base) < 0) {
- printk(BIOS_DEBUG, " codec not ready.\n");
- return;
- }
-
- reg32 = (addr << 28) | 0x000f0000;
- write32(base + HDA_IC_REG, reg32);
-
- if (wait_for_valid(base) < 0) {
- printk(BIOS_DEBUG, " codec not valid.\n");
- return;
- }
-
- /* 2 */
- reg32 = read32(base + HDA_IR_REG);
- printk(BIOS_DEBUG, "Azalia: codec viddid: %08x\n", reg32);
- verb_size = azalia_find_verb(cim_verb_data, cim_verb_data_size, reg32, &verb);
-
- if (!verb_size) {
- printk(BIOS_DEBUG, "Azalia: No verb!\n");
- return;
- }
- printk(BIOS_DEBUG, "Azalia: verb_size: %d\n", verb_size);
-
- /* 3 */
- azalia_program_verb_table(base, verb, verb_size);
- printk(BIOS_DEBUG, "Azalia: verb loaded.\n");
-}
-
-static void codecs_init(struct device *dev, u8 *base, u32 codec_mask)
-{
- int i;
- for (i = 3; i >= 0; i--) {
- if (codec_mask & (1 << i))
- codec_init(dev, base, i);
- }
-
- azalia_program_verb_table(base, pc_beep_verbs, pc_beep_verbs_size);
-}
-
static void azalia_init(struct device *dev)
{
u8 *base;
@@ -205,7 +110,7 @@ static void azalia_init(struct device *dev)
if (codec_mask) {
printk(BIOS_DEBUG, "Azalia: codec_mask = %02x\n", codec_mask);
- codecs_init(dev, base, codec_mask);
+ azalia_codecs_init(dev, base, codec_mask);
}
/* Enable dynamic clock gating */