mb/ocp/tiogapass: Fix GPIOs
[coreboot2.git] / src / mainboard / prodrive / hermes / hda_verb.c
blobd1ad64f570c66d26ce8267475ea5990fb86e8e86
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, AZALIA_PIN_CFG_NC(0)), /* SPDIF-OUT2 - disabled */
16 AZALIA_PIN_CFG(0, 0x12, AZALIA_PIN_CFG_NC(0)), /* Digital MIC - disabled */
17 AZALIA_PIN_CFG(0, 0x14, 0x01014430), /* Port D - rear line out */
18 AZALIA_PIN_CFG(0, 0x16, AZALIA_PIN_CFG_NC(0)), /* Port G - disabled */
19 AZALIA_PIN_CFG(0, 0x17, AZALIA_PIN_CFG_NC(0)), /* Port H - disabled */
20 AZALIA_PIN_CFG(0, 0x18, 0x01a19c50), /* Port B - rear mic in */
21 AZALIA_PIN_CFG(0, 0x1c, AZALIA_PIN_CFG_NC(0)), /* 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, AZALIA_PIN_CFG_NC(0)), /* Port E - disabled */
73 AZALIA_PIN_CFG(0, 0x15, AZALIA_PIN_CFG_NC(0)), /* 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 0; /* Disabled (Hi-Z) */
99 case 1:
100 return 1; /* 50% of LDO out */
101 case 2:
102 return 4; /* 80% of LDO out */
103 case 3:
104 return 5; /* 100% of LDO out */
105 case 4:
106 return 2; /* 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, 0x411110f0 | port_b_vref_cfg << 8),
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);