soc/intel: Remove blank lines before '}' and after '{'
[coreboot2.git] / src / mainboard / prodrive / hermes / hda_verb.c
blobcab4fd344b1315ed618b4d5bface91f80a78bf2d
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <device/azalia_device.h>
4 #include <types.h>
6 #include "eeprom.h"
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),
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 */
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 */
33 * VerbTable: CFL Display Audio Codec
34 * Revision ID = 0xff
35 * Codec Vendor: 0x8086280b
37 0x8086280b,
38 0xffffffff,
39 5, /* Number of 4 dword sets */
41 AZALIA_SUBVENDOR(2, 0x80860101),
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
49 0x20878101,
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,
60 /* Dummy entries */
61 0x20878100,
62 0x20878100,
65 const u32 pc_beep_verbs[0] = {};
67 AZALIA_ARRAY_SIZES;
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 */
76 static u32 get_port_c_vref_cfg(uint8_t blue_rear_vref)
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;
93 static u32 get_port_b_vref_cfg(uint8_t pink_rear_vref)
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 */
110 static u32 get_front_panel_cfg(uint8_t front_panel_audio)
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;
123 static u32 get_front_mic_cfg(uint8_t front_panel_audio)
125 return front_panel_audio == 2 ? AZALIA_PIN_CFG_NC(0) : 0x02a19c20;
128 static void mainboard_r0x_configure_alc888(u8 *base, u32 viddid)
130 /* Overwrite settings made by baseboard */
131 azalia_program_verb_table(base, r04_verb_data, ARRAY_SIZE(r04_verb_data));
133 const struct eeprom_board_settings *const board_cfg = get_board_settings();
135 const u32 front_panel_cfg = get_front_panel_cfg(board_cfg->front_panel_audio);
137 const u32 front_mic_cfg = get_front_mic_cfg(board_cfg->front_panel_audio);
139 const u32 port_b_vref_cfg = get_port_b_vref_cfg(board_cfg->pink_rear_vref);
141 const u32 verbs[] = {
143 * Write port B Vref settings to unused non-volatile NID 0x12 instead of
144 * NID 0x18, the actual port B NID. Because per-port Vref settings don't
145 * persist after codec resets, a custom Realtek driver (ab)uses NID 0x12
146 * to restore port B Vref after resetting the codec.
148 AZALIA_PIN_CFG(0, 0x12, port_b_vref_cfg),
149 AZALIA_PIN_CFG(0, 0x19, front_mic_cfg),
150 AZALIA_PIN_CFG(0, 0x1b, front_panel_cfg),
151 0x0205000d, /* Pin 37 vrefo hidden register - used as port C vref */
152 get_port_c_vref_cfg(board_cfg->blue_rear_vref),
154 azalia_program_verb_table(base, verbs, ARRAY_SIZE(verbs));
157 void mainboard_azalia_program_runtime_verbs(u8 *base, u32 viddid)
159 if (viddid == 0x10ec0888) {
160 u8 hsi = get_bmc_hsi();
162 if (hsi >= 3) /* R04 and newer */
163 mainboard_r0x_configure_alc888(base, viddid);