Nicholas Sudsgaard has uploaded this change for review.

View Change

southbridge/intel: Use azalia_audio_init() instead of duplicating code

Change-Id: Ie174ba29c115e3a3419362602d3e3175c9a03708
Signed-off-by: Nicholas Sudsgaard <devel+coreboot@nsudsgaard.com>
---
M src/southbridge/intel/i82801gx/azalia.c
M src/southbridge/intel/i82801ix/azalia.c
M src/southbridge/intel/i82801jx/azalia.c
3 files changed, 3 insertions(+), 128 deletions(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/04/83504/1
diff --git a/src/southbridge/intel/i82801gx/azalia.c b/src/southbridge/intel/i82801gx/azalia.c
index 31827e6..8df159e 100644
--- a/src/southbridge/intel/i82801gx/azalia.c
+++ b/src/southbridge/intel/i82801gx/azalia.c
@@ -12,36 +12,8 @@
#include "chip.h"
#include "i82801gx.h"

-static int codec_detect(u8 *base)
-{
- u32 reg32;
-
- if (azalia_enter_reset(base) < 0)
- goto no_codec;
-
- if (azalia_exit_reset(base) < 0)
- goto no_codec;
-
- /* Read in Codec location (BAR + 0xe)[2..0] */
- reg32 = read32(base + HDA_STATESTS_REG);
- reg32 &= 0x0f;
- if (!reg32)
- goto no_codec;
-
- return reg32;
-
-no_codec:
- /* Codec not found, put HDA back in reset */
- azalia_enter_reset(base);
- printk(BIOS_DEBUG, "Azalia: No codec!\n");
- return 0;
-}
-
static void azalia_init(struct device *dev)
{
- u8 *base;
- struct resource *res;
- u32 codec_mask;
u8 reg8;

// ESD
@@ -83,20 +55,7 @@
// Docking not supported
pci_and_config8(dev, 0x4d, (u8)~(1 << 7)); // Docking Status

- res = probe_resource(dev, PCI_BASE_ADDRESS_0);
- if (!res)
- return;
-
- // NOTE this will break as soon as the Azalia gets a bar above 4G.
- // Is there anything we can do about it?
- base = res2mmio(res, 0, 0);
- printk(BIOS_DEBUG, "Azalia: base = %08x\n", (u32)(uintptr_t)base);
- codec_mask = codec_detect(base);
-
- if (codec_mask) {
- printk(BIOS_DEBUG, "Azalia: codec_mask = %02x\n", codec_mask);
- azalia_codecs_init(base, codec_mask);
- }
+ azalia_audio_init(dev);
}

static struct device_operations azalia_ops = {
diff --git a/src/southbridge/intel/i82801ix/azalia.c b/src/southbridge/intel/i82801ix/azalia.c
index fdc9514..e939318 100644
--- a/src/southbridge/intel/i82801ix/azalia.c
+++ b/src/southbridge/intel/i82801ix/azalia.c
@@ -10,37 +10,8 @@
#include "chip.h"
#include "i82801ix.h"

-static int codec_detect(u8 *base)
-{
- u32 reg32;
-
- if (azalia_enter_reset(base) < 0)
- goto no_codec;
-
- if (azalia_exit_reset(base) < 0)
- goto no_codec;
-
- /* Read in Codec location (BAR + 0xe)[2..0] */
- reg32 = read32(base + HDA_STATESTS_REG);
- reg32 &= 0x0f;
- if (!reg32)
- goto no_codec;
-
- return reg32;
-
-no_codec:
- /* Codec not found, put HDA back in reset */
- azalia_enter_reset(base);
- printk(BIOS_DEBUG, "Azalia: No codec!\n");
- return 0;
-}
-
static void azalia_init(struct device *dev)
{
- u8 *base;
- struct resource *res;
- u32 codec_mask;
-
// ESD
pci_update_config32(dev, 0x134, ~0x00ff0000, 2 << 16);

@@ -65,20 +36,7 @@
/* Lock some R/WO bits by writing their current value. */
pci_update_config32(dev, 0x74, ~0, 0);

- res = probe_resource(dev, PCI_BASE_ADDRESS_0);
- if (!res)
- return;
-
- // NOTE this will break as soon as the Azalia gets a bar above 4G.
- // Is there anything we can do about it?
- base = res2mmio(res, 0, 0);
- printk(BIOS_DEBUG, "Azalia: base = %p\n", base);
- codec_mask = codec_detect(base);
-
- if (codec_mask) {
- printk(BIOS_DEBUG, "Azalia: codec_mask = %02x\n", codec_mask);
- azalia_codecs_init(base, codec_mask);
- }
+ azalia_audio_init(dev);
}

static struct device_operations azalia_ops = {
diff --git a/src/southbridge/intel/i82801jx/azalia.c b/src/southbridge/intel/i82801jx/azalia.c
index fa0209a..6271de7 100644
--- a/src/southbridge/intel/i82801jx/azalia.c
+++ b/src/southbridge/intel/i82801jx/azalia.c
@@ -10,37 +10,8 @@
#include "chip.h"
#include "i82801jx.h"

-static int codec_detect(u8 *base)
-{
- u32 reg32;
-
- if (azalia_enter_reset(base) < 0)
- goto no_codec;
-
- if (azalia_exit_reset(base) < 0)
- goto no_codec;
-
- /* Read in Codec location (BAR + 0xe)[2..0] */
- reg32 = read32(base + HDA_STATESTS_REG);
- reg32 &= 0x0f;
- if (!reg32)
- goto no_codec;
-
- return reg32;
-
-no_codec:
- /* Codec not found, put HDA back in reset */
- azalia_enter_reset(base);
- printk(BIOS_DEBUG, "Azalia: No codec!\n");
- return 0;
-}
-
static void azalia_init(struct device *dev)
{
- u8 *base;
- struct resource *res;
- u32 codec_mask;
-
// ESD
pci_update_config32(dev, 0x134, ~0x00ff0000, 2 << 16);

@@ -65,20 +36,7 @@
/* Lock some R/WO bits by writing their current value. */
pci_update_config32(dev, 0x74, ~0, 0);

- res = probe_resource(dev, PCI_BASE_ADDRESS_0);
- if (!res)
- return;
-
- // NOTE this will break as soon as the Azalia gets a bar above 4G.
- // Is there anything we can do about it?
- base = res2mmio(res, 0, 0);
- printk(BIOS_DEBUG, "Azalia: base = %p\n", base);
- codec_mask = codec_detect(base);
-
- if (codec_mask) {
- printk(BIOS_DEBUG, "Azalia: codec_mask = %02x\n", codec_mask);
- azalia_codecs_init(base, codec_mask);
- }
+ azalia_audio_init(dev);
}

static struct device_operations azalia_ops = {

To view, visit change 83504. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: coreboot
Gerrit-Branch: main
Gerrit-Change-Id: Ie174ba29c115e3a3419362602d3e3175c9a03708
Gerrit-Change-Number: 83504
Gerrit-PatchSet: 1
Gerrit-Owner: Nicholas Sudsgaard <devel+coreboot@nsudsgaard.com>