coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
hda_verb.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <console/console.h>
4 #include <device/azalia_device.h>
5 #include <device/mmio.h>
6 
7 #include "hda_verb.h"
8 
10 {
11  u8 reg8;
12 
13  /* Set Bit 0 to 1 to exit reset state (BAR + 0x8)[0] */
14  if (azalia_exit_reset(base) < 0)
15  goto no_codec;
16 
17  /* Write back the value once reset bit is set. */
19 
20  /*
21  * Clear the "State Change Status Register" STATESTS bits
22  * for each of the "SDIN Stat Change Status Flag"
23  */
25 
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;
29 
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;
33 
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;
39 
40  return reg8;
41 
42 no_codec:
43  /* Codec not found, put HDA back in reset */
45  printk(BIOS_DEBUG, "HDA: No codec!\n");
46  return 0;
47 }
static void write8(void *addr, uint8_t val)
Definition: mmio.h:30
static uint16_t read16(const void *addr)
Definition: mmio.h:17
static uint8_t read8(const void *addr)
Definition: mmio.h:12
static void write16(void *addr, uint16_t val)
Definition: mmio.h:35
int azalia_enter_reset(u8 *base)
Definition: azalia_device.c:38
int azalia_exit_reset(u8 *base)
Definition: azalia_device.c:44
#define HDA_STATESTS_REG
Definition: azalia_device.h:14
#define HDA_GCAP_REG
Definition: azalia_device.h:11
#define printk(level,...)
Definition: stdlib.h:16
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
uintptr_t base
Definition: uart.c:17
int hda_codec_detect(u8 *base)
Definition: hda_verb.c:10
uint8_t u8
Definition: stdint.h:45