util/sconfig: Remove unused ioapic and irq keywords
[coreboot.git] / src / southbridge / intel / lynxpoint / hda_verb.c
blob7e9f4d2c4828e08fc1df4a3c27b9b7ab1e8843b5
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <console/console.h>
4 #include <device/azalia_device.h>
5 #include <device/mmio.h>
7 #include "hda_verb.h"
9 int hda_codec_detect(u8 *base)
11 u8 reg8;
13 /* Set Bit 0 to 1 to exit reset state (BAR + 0x8)[0] */
14 if (azalia_exit_reset(base) < 0)
15 goto no_codec;
17 /* Write back the value once reset bit is set. */
18 write16(base + HDA_GCAP_REG, read16(base + HDA_GCAP_REG));
21 * Clear the "State Change Status Register" STATESTS bits
22 * for each of the "SDIN Stat Change Status Flag"
24 write8(base + HDA_STATESTS_REG, 0xf);
26 /* Turn off the link and poll RESET# bit until it reads back as 0 */
27 if (azalia_enter_reset(base) < 0)
28 goto no_codec;
30 /* Turn on the link and poll RESET# bit until it reads back as 1 */
31 if (azalia_exit_reset(base) < 0)
32 goto no_codec;
34 /* Read in Codec location (BAR + 0xe)[2..0] */
35 reg8 = read8(base + HDA_STATESTS_REG);
36 reg8 &= 0x0f;
37 if (!reg8)
38 goto no_codec;
40 return reg8;
42 no_codec:
43 /* Codec not found, put HDA back in reset */
44 azalia_enter_reset(base);
45 printk(BIOS_DEBUG, "HDA: No codec!\n");
46 return 0;