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 <device/azalia_device.h>
4 #include <types.h>
5 
6 #include "eeprom.h"
7 
8 const u32 cim_verb_data[] = {
9  0x10ec0888, /* Codec Vendor / Device ID: Realtek ALC888 */
10  0x10ec0888, /* Subsystem ID */
11  15, /* Number of 4 dword sets */
12  AZALIA_SUBVENDOR(0, 0x1d336700),
13 
14  /* Pin widgets */
15  AZALIA_PIN_CFG(0, 0x11, 0x411111f0), /* SPDIF-OUT2 - disabled */
16  AZALIA_PIN_CFG(0, 0x12, 0x411111f0), /* digital MIC - disabled */
17  AZALIA_PIN_CFG(0, 0x14, 0x01014430), /* PORT D - rear line out */
18  AZALIA_PIN_CFG(0, 0x16, 0x411111f0), /* PORT G - disabled */
19  AZALIA_PIN_CFG(0, 0x17, 0x411111f0), /* PORT H - disabled */
20  AZALIA_PIN_CFG(0, 0x18, 0x01a19c50), /* PORT B - rear mic in */
21  AZALIA_PIN_CFG(0, 0x1c, 0x411111f0), /* CD audio - disabled */
22  AZALIA_PIN_CFG(0, 0x1d, 0x4004c601), /* BEEPIN */
23  AZALIA_PIN_CFG(0, 0x1e, 0x01452160), /* SPDIF-OUT */
24  AZALIA_PIN_CFG(0, 0x1f, 0x01c52170), /* SPDIF-IN */
25 
26  /* Config for R02 and older */
27  AZALIA_PIN_CFG(0, 0x19, 0x02214c40), /* port F - front hp out */
28  AZALIA_PIN_CFG(0, 0x1a, 0x901001f0), /* port C - internal speaker */
29  AZALIA_PIN_CFG(0, 0x1b, 0x01813c10), /* port E - rear line in/mic - Blue */
30  AZALIA_PIN_CFG(0, 0x15, 0x02a19c20), /* port A - audio hdr input */
31 
32  /*
33  * VerbTable: CFL Display Audio Codec
34  * Revision ID = 0xff
35  * Codec Vendor: 0x8086280b
36  */
37  0x8086280b,
38  0xffffffff,
39  5, /* Number of 4 dword sets */
40 
41  AZALIA_SUBVENDOR(2, 0x80860101),
42 
43  /*
44  * Display Audio Verb Table
45  * For GEN9, the Vendor Node ID is 08h
46  * Port to be exposed to the inbox driver in the vanilla mode
47  * PORT C - BIT[7:6] = 01b
48  */
49  0x20878101,
50 
51  /* Pin Widget 5 - PORT B - Configuration Default: 0x18560010 */
52  AZALIA_PIN_CFG(2, 0x05, 0x18560010),
53  /* Pin Widget 6 - PORT C - Configuration Default: 0x18560020 */
54  AZALIA_PIN_CFG(2, 0x06, 0x18560020),
55  /* Pin Widget 7 - PORT D - Configuration Default: 0x18560030 */
56  AZALIA_PIN_CFG(2, 0x07, 0x18560030),
57  /* Disable the third converter and third Pin (NID 08h) */
58  0x20878100,
59 
60  /* Dummy entries */
61  0x20878100,
62  0x20878100,
63 };
64 
65 const u32 pc_beep_verbs[0] = {};
66 
68 
69 static const u32 r04_verb_data[] = {
70  AZALIA_PIN_CFG(0, 0x19, 0x02a19c20), /* PORT F - front mic in */
71  AZALIA_PIN_CFG(0, 0x1a, 0x01813c51), /* PORT C - rear line in (mic support) */
72  AZALIA_PIN_CFG(0, 0x1b, 0x411111f0), /* PORT E - disabled */
73  AZALIA_PIN_CFG(0, 0x15, 0x411111f0), /* PORT A - disabled */
74 };
75 
76 static u32 get_port_c_vref_cfg(uint8_t blue_rear_vref)
77 {
78  switch (blue_rear_vref) {
79  default:
80  case 0:
81  return 0x02040000;
82  case 1:
83  return 0x02041000;
84  case 2:
85  return 0x02044000;
86  case 3:
87  return 0x02045000;
88  case 4:
89  return 0x02046000;
90  }
91 }
92 
93 static u32 get_port_b_vref_cfg(uint8_t pink_rear_vref)
94 {
95  switch (pink_rear_vref) {
96  default:
97  case 0:
98  return 0x411110f0; /* Disabled (Hi-Z) */
99  case 1:
100  return 0x411111f0; /* 50% of LDO out */
101  case 2:
102  return 0x411114f0; /* 80% of LDO out */
103  case 3:
104  return 0x411115f0; /* 100% of LDO out */
105  case 4:
106  return 0x411112f0; /* Ground */
107  }
108 }
109 
110 static u32 get_front_panel_cfg(uint8_t front_panel_audio)
111 {
112  switch (front_panel_audio) {
113  default:
114  case 0:
115  return AZALIA_PIN_CFG_NC(0);
116  case 1:
117  return 0x02214c40;
118  case 2:
119  return 0x0227ec40;
120  }
121 }
122 
123 static u32 get_front_mic_cfg(uint8_t front_panel_audio)
124 {
125  return front_panel_audio == 2 ? AZALIA_PIN_CFG_NC(0) : 0x02a19c20;
126 }
127 
129 {
130  /* Overwrite settings made by baseboard */
132 
133  const struct eeprom_board_settings *const board_cfg = get_board_settings();
134 
135  if (!board_cfg)
136  return;
137 
138  const u32 front_panel_cfg = get_front_panel_cfg(board_cfg->front_panel_audio);
139 
140  const u32 front_mic_cfg = get_front_mic_cfg(board_cfg->front_panel_audio);
141 
142  const u32 port_b_vref_cfg = get_port_b_vref_cfg(board_cfg->pink_rear_vref);
143 
144  const u32 verbs[] = {
145  /*
146  * Write port B Vref settings to unused non-volatile NID 0x12 instead of
147  * NID 0x18, the actual port B NID. Because per-port Vref settings don't
148  * persist after codec resets, a custom Realtek driver (ab)uses NID 0x12
149  * to restore port B Vref after resetting the codec.
150  */
151  AZALIA_PIN_CFG(0, 0x12, port_b_vref_cfg),
152  AZALIA_PIN_CFG(0, 0x19, front_mic_cfg),
153  AZALIA_PIN_CFG(0, 0x1b, front_panel_cfg),
154  0x0205000d, /* Pin 37 vrefo hidden register - used as port C vref */
155  get_port_c_vref_cfg(board_cfg->blue_rear_vref),
156  };
157  azalia_program_verb_table(base, verbs, ARRAY_SIZE(verbs));
158 }
159 
161 {
162  if (viddid == 0x10ec0888) {
163  u8 hsi = get_bmc_hsi();
164 
165  if (hsi >= 3) /* R04 and newer */
167  }
168 }
int azalia_program_verb_table(u8 *base, const u32 *verbs, u32 verb_size)
#define AZALIA_SUBVENDOR(codec, val)
#define AZALIA_PIN_CFG(codec, pin, val)
#define AZALIA_PIN_CFG_NC(n)
#define ARRAY_SIZE(a)
Definition: helpers.h:12
uint8_t get_bmc_hsi(void)
Definition: eeprom.c:91
struct eeprom_board_settings * get_board_settings(void)
Definition: eeprom.c:59
const u32 cim_verb_data[]
Definition: hda_verb.c:5
const u32 pc_beep_verbs[]
Definition: hda_verb.c:37
AZALIA_ARRAY_SIZES
Definition: hda_verb.c:39
static u32 get_port_c_vref_cfg(uint8_t blue_rear_vref)
Definition: hda_verb.c:76
void mainboard_azalia_program_runtime_verbs(u8 *base, u32 viddid)
Definition: hda_verb.c:160
static const u32 r04_verb_data[]
Definition: hda_verb.c:69
static u32 get_front_panel_cfg(uint8_t front_panel_audio)
Definition: hda_verb.c:110
static u32 get_front_mic_cfg(uint8_t front_panel_audio)
Definition: hda_verb.c:123
static u32 get_port_b_vref_cfg(uint8_t pink_rear_vref)
Definition: hda_verb.c:93
static void mainboard_r0x_configure_alc888(u8 *base, u32 viddid)
Definition: hda_verb.c:128
static const struct mb_cfg board_cfg
Definition: romstage.c:8
uintptr_t base
Definition: uart.c:17
uint32_t u32
Definition: stdint.h:51
uint8_t u8
Definition: stdint.h:45
unsigned char uint8_t
Definition: stdint.h:8