soc/intel/pantherlake: Remove soc_info.[hc] interface
[coreboot2.git] / src / southbridge / intel / lynxpoint / hda_verb.c
blobe79b5d1b20448b6662acb1ebb36f3e7780f2ae31
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <console/console.h>
4 #include <device/azalia_device.h>
5 #include <device/mmio.h>
6 #include <types.h>
8 #include "hda_verb.h"
10 int hda_codec_detect(u8 *base)
12 u8 reg8;
14 /* Set Bit 0 to 1 to exit reset state (BAR + 0x8)[0] */
15 if (azalia_exit_reset(base) != CB_SUCCESS)
16 goto no_codec;
18 /* Write back the value once reset bit is set. */
19 write16(base + HDA_GCAP_REG, read16(base + HDA_GCAP_REG));
22 * Clear the "State Change Status Register" STATESTS bits
23 * for each of the "SDIN Stat Change Status Flag"
25 write8(base + HDA_STATESTS_REG, 0xf);
27 /* Turn off the link and poll RESET# bit until it reads back as 0 */
28 if (azalia_enter_reset(base) != CB_SUCCESS)
29 goto no_codec;
31 /* Turn on the link and poll RESET# bit until it reads back as 1 */
32 if (azalia_exit_reset(base) != CB_SUCCESS)
33 goto no_codec;
35 /* Read in Codec location (BAR + 0xe)[2..0] */
36 reg8 = read8(base + HDA_STATESTS_REG);
37 reg8 &= 0x0f;
38 if (!reg8)
39 goto no_codec;
41 return reg8;
43 no_codec:
44 /* Codec not found, put HDA back in reset */
45 azalia_enter_reset(base);
46 printk(BIOS_DEBUG, "HDA: No codec!\n");
47 return 0;