coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
cbi_ssfc.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #include <baseboard/cbi_ssfc.h>
4 #include <console/console.h>
6 
7 static int get_ssfc(uint32_t *val)
8 {
9  static uint32_t known_value;
10  static enum {
11  SSFC_NOT_READ,
12  SSFC_AVAILABLE,
13  } ssfc_state = SSFC_NOT_READ;
14 
15  if (ssfc_state == SSFC_AVAILABLE) {
16  *val = known_value;
17  return 0;
18  }
19 
20  /*
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.
24  */
25  if (google_chromeec_cbi_get_ssfc(&known_value) != 0) {
26  printk(BIOS_DEBUG, "SSFC not set in CBI\n");
27  return -1;
28  }
29 
30  ssfc_state = SSFC_AVAILABLE;
31  *val = known_value;
32  printk(BIOS_INFO, "SSFC 0x%x.\n", known_value);
33 
34  return 0;
35 }
36 
37 static unsigned int extract_field(uint32_t mask, int shift)
38 {
39  uint32_t ssfc;
40 
41  /* On errors nothing is assumed to be set. */
42  if (get_ssfc(&ssfc))
43  return 0;
44 
45  return (ssfc >> shift) & mask;
46 }
47 
49 {
50  /*
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.
54  */
55  if (CONFIG(BOARD_GOOGLE_AMPTON))
57 
59 }
60 
62 {
63  uint32_t codec = extract_field(
65 
66  if (codec != SSFC_AUDIO_CODEC_DEFAULT)
67  return codec;
68 
70 }
static enum ssfc_audio_codec ssfc_get_default_audio_codec(void)
Definition: cbi_ssfc.c:48
static int get_ssfc(uint32_t *val)
Definition: cbi_ssfc.c:7
static unsigned int extract_field(uint32_t mask, int shift)
Definition: cbi_ssfc.c:37
enum ssfc_audio_codec ssfc_get_audio_codec(void)
Definition: cbi_ssfc.c:61
#define SSFC_AUDIO_CODEC_OFFSET
Definition: cbi_ssfc.h:35
ssfc_audio_codec
Definition: cbi_ssfc.h:28
@ SSFC_AUDIO_CODEC_DEFAULT
Definition: cbi_ssfc.h:29
@ SSFC_AUDIO_CODEC_DA7219
Definition: cbi_ssfc.h:30
@ SSFC_AUDIO_CODEC_RT5682
Definition: cbi_ssfc.h:31
#define SSFC_AUDIO_CODEC_MASK
Definition: cbi_ssfc.h:36
#define printk(level,...)
Definition: stdlib.h:16
@ CONFIG
Definition: dsi_common.h:201
int google_chromeec_cbi_get_ssfc(uint32_t *ssfc)
Definition: ec.c:875
#define BIOS_INFO
BIOS_INFO - Expected events.
Definition: loglevel.h:113
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
static const int mask[4]
Definition: gpio.c:308
unsigned int uint32_t
Definition: stdint.h:14
u8 val
Definition: sys.c:300