Elyes Haouas has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/61853 )
Change subject: sb/intel/*/azalia.c: Make codec_detect(u8 *base) common and use it ......................................................................
sb/intel/*/azalia.c: Make codec_detect(u8 *base) common and use it
Change-Id: I349b35dbf4d5851af71703239781c196945c6cae Signed-off-by: Elyes Haouas ehaouas@noos.fr --- M src/device/azalia_device.c M src/include/device/azalia_device.h M src/southbridge/intel/bd82x6x/azalia.c M src/southbridge/intel/i82801gx/azalia.c M src/southbridge/intel/i82801ix/azalia.c M src/southbridge/intel/i82801jx/azalia.c M src/southbridge/intel/ibexpeak/azalia.c M src/southbridge/intel/lynxpoint/Kconfig 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, 4 insertions(+), 192 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/53/61853/1
diff --git a/src/device/azalia_device.c b/src/device/azalia_device.c index e61e1dc..f3942f7 100644 --- a/src/device/azalia_device.c +++ b/src/device/azalia_device.c @@ -47,7 +47,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; const u16 codec_mask = (1 << CONFIG_AZALIA_MAX_CODECS) - 1; diff --git a/src/include/device/azalia_device.h b/src/include/device/azalia_device.h index 1562e25..dec711c 100644 --- a/src/include/device/azalia_device.h +++ b/src/include/device/azalia_device.h @@ -18,6 +18,7 @@ #define HDA_ICII_BUSY (1 << 0) #define HDA_ICII_VALID (1 << 1)
+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/southbridge/intel/bd82x6x/azalia.c b/src/southbridge/intel/bd82x6x/azalia.c index 287f886..607b5b8 100644 --- a/src/southbridge/intel/bd82x6x/azalia.c +++ b/src/southbridge/intel/bd82x6x/azalia.c @@ -12,32 +12,6 @@ #include "chip.h" #include "pch.h"
-static u16 codec_detect(u8 *base) -{ - const u16 codec_mask = (1 << CONFIG_AZALIA_MAX_CODECS) - 1; - u16 reg16; - - 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)); - - /* Read in Codec location (BAR + 0xe)[2..0] */ - reg16 = read16(base + HDA_STATESTS_REG); - reg16 &= codec_mask; - if (!reg16) - goto no_codec; - - return reg16; - -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; diff --git a/src/southbridge/intel/i82801gx/azalia.c b/src/southbridge/intel/i82801gx/azalia.c index 6f6c31c..7921fdd 100644 --- a/src/southbridge/intel/i82801gx/azalia.c +++ b/src/southbridge/intel/i82801gx/azalia.c @@ -12,32 +12,6 @@ #include "chip.h" #include "i82801gx.h"
-static u16 codec_detect(u8 *base) -{ - const u16 codec_mask = (1 << CONFIG_AZALIA_MAX_CODECS) - 1; - u16 reg16; - - 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] */ - reg16 = read16(base + HDA_STATESTS_REG); - reg16 &= codec_mask; - if (!reg16) - goto no_codec; - - return reg16; - -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; diff --git a/src/southbridge/intel/i82801ix/azalia.c b/src/southbridge/intel/i82801ix/azalia.c index ec3706e..f6af83f 100644 --- a/src/southbridge/intel/i82801ix/azalia.c +++ b/src/southbridge/intel/i82801ix/azalia.c @@ -10,32 +10,6 @@ #include "chip.h" #include "i82801ix.h"
-static u16 codec_detect(u8 *base) -{ - const u16 codec_mask = (1 << CONFIG_AZALIA_MAX_CODECS) - 1; - u16 reg16; - - 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] */ - reg16 = read16(base + HDA_STATESTS_REG); - reg16 &= codec_mask; - if (!reg16) - goto no_codec; - - return reg16; - -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; diff --git a/src/southbridge/intel/i82801jx/azalia.c b/src/southbridge/intel/i82801jx/azalia.c index 8304bc4..7e9a9ed 100644 --- a/src/southbridge/intel/i82801jx/azalia.c +++ b/src/southbridge/intel/i82801jx/azalia.c @@ -10,32 +10,6 @@ #include "chip.h" #include "i82801jx.h"
-static u16 codec_detect(u8 *base) -{ - const u16 codec_mask = (1 << CONFIG_AZALIA_MAX_CODECS) - 1; - u16 reg16; - - 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] */ - reg16 = read16(base + HDA_STATESTS_REG); - reg16 &= codec_mask; - if (!reg16) - goto no_codec; - - return reg; - -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; diff --git a/src/southbridge/intel/ibexpeak/azalia.c b/src/southbridge/intel/ibexpeak/azalia.c index 96a7f1a..fd8a3dc 100644 --- a/src/southbridge/intel/ibexpeak/azalia.c +++ b/src/southbridge/intel/ibexpeak/azalia.c @@ -10,32 +10,6 @@ #include <device/azalia_device.h> #include "pch.h"
-static u16 codec_detect(u8 *base) -{ - const u16 codec_mask = (1 << CONFIG_AZALIA_MAX_CODECS) - 1; - u16 reg16; - - 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)); - - /* Read in Codec location (BAR + 0xe)[2..0] */ - reg16 = read16(base + HDA_STATESTS_REG); - reg16 &= codec_mask; - if (!reg16) - goto no_codec; - - return reg16; - -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; diff --git a/src/southbridge/intel/lynxpoint/Kconfig b/src/southbridge/intel/lynxpoint/Kconfig index b7c719b..c613f65 100644 --- a/src/southbridge/intel/lynxpoint/Kconfig +++ b/src/southbridge/intel/lynxpoint/Kconfig @@ -34,6 +34,7 @@ select HAVE_POWER_STATE_PREVIOUS_AFTER_FAILURE select SOUTHBRIDGE_INTEL_COMMON_WATCHDOG select SOUTHBRIDGE_INTEL_COMMON_USB_DEBUG + select AZALIA_LOCK_DOWN_R_WO_GCAP
config INTEL_LYNXPOINT_LP bool diff --git a/src/southbridge/intel/lynxpoint/azalia.c b/src/southbridge/intel/lynxpoint/azalia.c index 6f8c7a8..77b54d2 100644 --- a/src/southbridge/intel/lynxpoint/azalia.c +++ b/src/southbridge/intel/lynxpoint/azalia.c @@ -97,7 +97,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 48c8c74..0000000 --- a/src/southbridge/intel/lynxpoint/hda_verb.c +++ /dev/null @@ -1,50 +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" - -u16 hda_codec_detect(u8 *base) -{ - const u16 codec_mask = (1 << CONFIG_AZALIA_MAX_CODECS) - 1; - u16 reg16; - - /* 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" - */ - reg16 = read16(base + HDA_STATESTS_REG); - reg16 |= codec_mask; - write16(base + HDA_STATESTS_REG, reg16); - - /* 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] */ - reg16 = read16(base + HDA_STATESTS_REG); - reg16 &= codec_mask; - if (!reg16) - goto no_codec; - - return reg16; - -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 2eab550..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> - -u16 hda_codec_detect(u8 *base); - -#endif