soc/intel/xeon_sp: Allow OS to control LTR and AER
[coreboot2.git] / src / mainboard / google / octopus / variants / baseboard / cbi_ssfc.c
blob589f92e139b384cc3caacf3aefc5dcbcc5c43574
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 #include <baseboard/cbi_ssfc.h>
4 #include <console/console.h>
5 #include <ec/google/chromeec/ec.h>
7 static int get_ssfc(uint32_t *val)
9 static uint32_t known_value;
10 static enum {
11 SSFC_NOT_READ,
12 SSFC_AVAILABLE,
13 } ssfc_state = SSFC_NOT_READ;
15 if (ssfc_state == SSFC_AVAILABLE) {
16 *val = known_value;
17 return 0;
21 * If SSFC field is not in the CBI then the value of SSFC will be 0 for
22 * further processing later since 0 of each bits group means default
23 * component in a variant. For more detail, please refer to cbi_ssfc.h.
25 if (google_chromeec_cbi_get_ssfc(&known_value) != 0) {
26 printk(BIOS_DEBUG, "SSFC not set in CBI\n");
27 return -1;
30 ssfc_state = SSFC_AVAILABLE;
31 *val = known_value;
32 printk(BIOS_INFO, "SSFC 0x%x.\n", known_value);
34 return 0;
37 static unsigned int extract_field(uint32_t mask, int shift)
39 uint32_t ssfc;
41 /* On errors nothing is assumed to be set. */
42 if (get_ssfc(&ssfc))
43 return 0;
45 return (ssfc >> shift) & mask;
48 static enum ssfc_audio_codec ssfc_get_default_audio_codec(void)
51 * Octopus has two reference boards; yorp is with DA7219 and bip is with
52 * RT5682. Currently only AMPTON derived from bip so only it uses
53 * RT5682 as the default source in the first MP devices.
55 if (CONFIG(BOARD_GOOGLE_AMPTON))
56 return SSFC_AUDIO_CODEC_RT5682;
58 return SSFC_AUDIO_CODEC_DA7219;
61 enum ssfc_audio_codec ssfc_get_audio_codec(void)
63 uint32_t codec = extract_field(
64 SSFC_AUDIO_CODEC_MASK, SSFC_AUDIO_CODEC_OFFSET);
66 if (codec != SSFC_AUDIO_CODEC_DEFAULT)
67 return codec;
69 return ssfc_get_default_audio_codec();