Elyes Haouas has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/83214?usp=email )
Change subject: treewide/azalia: Make codec_detect() common and use it ......................................................................
treewide/azalia: Make codec_detect() common and use it
Change-Id: Ib7be3c0b1a90a766c5bb0f950c4dbac31a87c20f Signed-off-by: Elyes Haouas ehaouas@noos.fr --- M src/device/azalia_device.c M src/include/device/azalia_device.h M src/northbridge/intel/haswell/minihd.c M src/soc/intel/baytrail/hda.c M src/soc/intel/broadwell/minihd.c M src/soc/intel/broadwell/pch/hda.c M src/soc/intel/common/hda_verb.c M src/soc/intel/common/hda_verb.h M src/southbridge/intel/lynxpoint/azalia.c D src/southbridge/intel/lynxpoint/hda_verb.c D src/southbridge/intel/lynxpoint/hda_verb.h 11 files changed, 7 insertions(+), 108 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/14/83214/1
diff --git a/src/device/azalia_device.c b/src/device/azalia_device.c index 8051f2e..3841c58 100644 --- a/src/device/azalia_device.c +++ b/src/device/azalia_device.c @@ -48,7 +48,7 @@ return azalia_set_bits(base + HDA_GCTL_REG, HDA_GCTL_CRST, HDA_GCTL_CRST); }
-static u16 codec_detect(u8 *base) +u16 codec_detect(u8 *base) { struct stopwatch sw; u16 reg16; diff --git a/src/include/device/azalia_device.h b/src/include/device/azalia_device.h index 59e7ea2..3018df0 100644 --- a/src/include/device/azalia_device.h +++ b/src/include/device/azalia_device.h @@ -20,6 +20,7 @@
#define AZALIA_MAX_CODECS 15
+u16 codec_detect(u8 *base); int azalia_set_bits(void *port, u32 mask, u32 val); int azalia_enter_reset(u8 *base); int azalia_exit_reset(u8 *base); diff --git a/src/northbridge/intel/haswell/minihd.c b/src/northbridge/intel/haswell/minihd.c index 6abc6c1..4e6fb6c 100644 --- a/src/northbridge/intel/haswell/minihd.c +++ b/src/northbridge/intel/haswell/minihd.c @@ -7,7 +7,6 @@ #include <device/pci_ids.h> #include <device/pci_ops.h> #include <device/mmio.h> -#include <southbridge/intel/lynxpoint/hda_verb.h>
static const u32 minihd_verb_table[] = { /* coreboot specific header */ @@ -74,7 +73,7 @@ write32(base + 0x1010, reg32);
/* Init the codec and write the verb table */ - codec_mask = hda_codec_detect(base); + codec_mask = codec_detect(base);
if (codec_mask) { for (i = 3; i >= 0; i--) { diff --git a/src/soc/intel/baytrail/hda.c b/src/soc/intel/baytrail/hda.c index 46fbce1..d006408 100644 --- a/src/soc/intel/baytrail/hda.c +++ b/src/soc/intel/baytrail/hda.c @@ -68,7 +68,7 @@ return;
base = res2mmio(res, 0, 0); - codec_mask = hda_codec_detect(base); + codec_mask = codec_detect(base);
printk(BIOS_DEBUG, "codec mask = %x\n", codec_mask); if (!codec_mask) diff --git a/src/soc/intel/broadwell/minihd.c b/src/soc/intel/broadwell/minihd.c index ee63501..ccca636 100644 --- a/src/soc/intel/broadwell/minihd.c +++ b/src/soc/intel/broadwell/minihd.c @@ -8,7 +8,6 @@ #include <device/pci_ops.h> #include <device/mmio.h> #include <soc/igd.h> -#include <southbridge/intel/lynxpoint/hda_verb.h>
static const u32 minihd_verb_table[] = { /* coreboot specific header */ @@ -75,7 +74,7 @@ write32(base + 0x1010, reg32);
/* Init the codec and write the verb table */ - codec_mask = hda_codec_detect(base); + codec_mask = codec_detect(base);
if (codec_mask) { for (i = 3; i >= 0; i--) { diff --git a/src/soc/intel/broadwell/pch/hda.c b/src/soc/intel/broadwell/pch/hda.c index ad3d8e9..77acc0b 100644 --- a/src/soc/intel/broadwell/pch/hda.c +++ b/src/soc/intel/broadwell/pch/hda.c @@ -9,7 +9,6 @@ #include <device/mmio.h> #include <soc/pch.h> #include <soc/rcba.h> -#include <southbridge/intel/lynxpoint/hda_verb.h>
static void hda_pch_init(struct device *dev, u8 *base) { @@ -76,7 +75,7 @@
hda_pch_init(dev, base);
- codec_mask = hda_codec_detect(base); + codec_mask = codec_detect(base);
if (codec_mask) { printk(BIOS_DEBUG, "HDA: codec_mask = %02x\n", codec_mask); diff --git a/src/soc/intel/common/hda_verb.c b/src/soc/intel/common/hda_verb.c index dceb031..5a7b582 100644 --- a/src/soc/intel/common/hda_verb.c +++ b/src/soc/intel/common/hda_verb.c @@ -8,46 +8,6 @@
#include "hda_verb.h"
-int hda_codec_detect(u8 *base) -{ - u8 reg8; - - /* Set Bit 0 to 1 to exit reset state (BAR + 0x8)[0] */ - if (azalia_exit_reset(base) < 0) - goto no_codec; - - /* Write back the value once reset bit is set. */ - write16(base + HDA_GCAP_REG, read16(base + HDA_GCAP_REG)); - - /* - * Clear the "State Change Status Register" STATESTS bits - * for each of the "SDIN Stat Change Status Flag" - */ - write8(base + HDA_STATESTS_REG, 0xf); - - /* Turn off the link and poll RESET# bit until it reads back as 0 */ - if (azalia_enter_reset(base) < 0) - goto no_codec; - - /* Turn on the link and poll RESET# bit until it reads back as 1 */ - if (azalia_exit_reset(base) < 0) - goto no_codec; - - /* Read in Codec location (BAR + 0xe)[2..0] */ - reg8 = read8(base + HDA_STATESTS_REG); - reg8 &= 0x0f; - if (!reg8) - goto no_codec; - - return reg8; - -no_codec: - /* Codec not found, put HDA back in reset */ - azalia_enter_reset(base); - printk(BIOS_DEBUG, "HDA: No codec!\n"); - return 0; -} - /* * Wait 50usec for the codec to indicate it is ready. * No response would imply that the codec is non-operative. diff --git a/src/soc/intel/common/hda_verb.h b/src/soc/intel/common/hda_verb.h index ddd5774..53ca3ff 100644 --- a/src/soc/intel/common/hda_verb.h +++ b/src/soc/intel/common/hda_verb.h @@ -5,7 +5,6 @@
#include <stdint.h>
-int hda_codec_detect(u8 *base); int hda_codec_write(u8 *base, u32 size, const u32 *data); int hda_codec_init(u8 *base, int addr, int verb_size, const u32 *verb_data);
diff --git a/src/southbridge/intel/lynxpoint/azalia.c b/src/southbridge/intel/lynxpoint/azalia.c index 34f0753..0c85ea5 100644 --- a/src/southbridge/intel/lynxpoint/azalia.c +++ b/src/southbridge/intel/lynxpoint/azalia.c @@ -9,7 +9,6 @@ #include <device/azalia_device.h>
#include "pch.h" -#include "hda_verb.h"
static void azalia_pch_init(struct device *dev, u8 *base) { @@ -97,7 +96,7 @@
azalia_pch_init(dev, base);
- codec_mask = hda_codec_detect(base); + codec_mask = codec_detect(base);
if (codec_mask) { printk(BIOS_DEBUG, "Azalia: codec_mask = %02x\n", codec_mask); diff --git a/src/southbridge/intel/lynxpoint/hda_verb.c b/src/southbridge/intel/lynxpoint/hda_verb.c deleted file mode 100644 index 7e9f4d2..0000000 --- a/src/southbridge/intel/lynxpoint/hda_verb.c +++ /dev/null @@ -1,47 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ - -#include <console/console.h> -#include <device/azalia_device.h> -#include <device/mmio.h> - -#include "hda_verb.h" - -int hda_codec_detect(u8 *base) -{ - u8 reg8; - - /* Set Bit 0 to 1 to exit reset state (BAR + 0x8)[0] */ - if (azalia_exit_reset(base) < 0) - goto no_codec; - - /* Write back the value once reset bit is set. */ - write16(base + HDA_GCAP_REG, read16(base + HDA_GCAP_REG)); - - /* - * Clear the "State Change Status Register" STATESTS bits - * for each of the "SDIN Stat Change Status Flag" - */ - write8(base + HDA_STATESTS_REG, 0xf); - - /* Turn off the link and poll RESET# bit until it reads back as 0 */ - if (azalia_enter_reset(base) < 0) - goto no_codec; - - /* Turn on the link and poll RESET# bit until it reads back as 1 */ - if (azalia_exit_reset(base) < 0) - goto no_codec; - - /* Read in Codec location (BAR + 0xe)[2..0] */ - reg8 = read8(base + HDA_STATESTS_REG); - reg8 &= 0x0f; - if (!reg8) - goto no_codec; - - return reg8; - -no_codec: - /* Codec not found, put HDA back in reset */ - azalia_enter_reset(base); - printk(BIOS_DEBUG, "HDA: No codec!\n"); - return 0; -} diff --git a/src/southbridge/intel/lynxpoint/hda_verb.h b/src/southbridge/intel/lynxpoint/hda_verb.h deleted file mode 100644 index 1d6ef39..0000000 --- a/src/southbridge/intel/lynxpoint/hda_verb.h +++ /dev/null @@ -1,10 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ - -#ifndef LYNXPOINT_HDA_VERB_H -#define LYNXPOINT_HDA_VERB_H - -#include <stdint.h> - -int hda_codec_detect(u8 *base); - -#endif