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
;
13 } ssfc_state
= SSFC_NOT_READ
;
15 if (ssfc_state
== SSFC_AVAILABLE
) {
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");
30 ssfc_state
= SSFC_AVAILABLE
;
32 printk(BIOS_INFO
, "SSFC 0x%x.\n", known_value
);
37 static unsigned int extract_field(uint32_t mask
, int shift
)
41 /* On errors nothing is assumed to be set. */
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
)
69 return ssfc_get_default_audio_codec();