coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
mainboard.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
4 #include <baseboard/variants.h>
5 #include <variant/sku.h>
6 #include <string.h>
7 #include <drivers/i2c/hid/chip.h>
8 
11 
13 {
15  struct device *mmio_dev = NULL, *child = NULL;
16  struct device *alc_dev = NULL, *da7219_dev = NULL;
17 
18  while (1) {
19  mmio_dev = dev_find_path(mmio_dev, DEVICE_PATH_MMIO);
20  if (mmio_dev == NULL)
21  break;
22  if (mmio_dev->path.mmio.addr == 0xfedc2000)
23  break;
24  }
25 
26  if (mmio_dev == NULL)
27  return;
28 
29  while ((child = dev_bus_each_child(mmio_dev->link_list, child)) != NULL) {
30  if (child->path.type != DEVICE_PATH_I2C)
31  continue;
32  if (child->path.i2c.device != 0x1a)
33  continue;
34  if (child->chip_ops == &drivers_i2c_generic_ops) {
35  struct drivers_i2c_generic_config *config = child->chip_info;
36  if (!strcmp(config->hid, "10EC5682"))
37  alc_dev = child;
38  } else if (child->chip_ops == &drivers_i2c_da7219_ops) {
39  da7219_dev = child;
40  }
41  }
42 
43  switch (sku) {
44  default:
45  /* da7219 only */
46  if (da7219_dev)
47  da7219_dev->enabled = 1;
48  if (alc_dev)
49  alc_dev->enabled = 0;
50  break;
55  /* alc5682 only */
56  if (da7219_dev)
57  da7219_dev->enabled = 0;
58  if (alc_dev)
59  alc_dev->enabled = 1;
60  break;
61  }
62 }
DEVTREE_CONST struct device * dev_find_path(DEVTREE_CONST struct device *prev_match, enum device_path_type path_type)
Given a Device Path Type, find the device structure.
Definition: device_const.c:53
DEVTREE_CONST struct device * dev_bus_each_child(const struct bus *parent, DEVTREE_CONST struct device *prev_child)
Given a device and previous match iterate through all the children.
Definition: device_const.c:353
uint32_t google_chromeec_get_sku_id(void)
Definition: ec.c:934
void __weak variant_devtree_update(void)
Definition: mainboard.c:86
struct chip_operations drivers_i2c_da7219_ops
Definition: da7219.c:112
struct chip_operations drivers_i2c_generic_ops
Definition: generic.c:217
enum project_sku sku
Definition: mainboard.c:51
@ SKU_BARLA_ALC5682_44
Definition: sku.h:11
@ SKU_BARLA_ALC5682_45
Definition: sku.h:12
@ SKU_BARLA_ALC5682_47
Definition: sku.h:14
@ SKU_BARLA_ALC5682_46
Definition: sku.h:13
enum board_config config
Definition: memory.c:448
@ DEVICE_PATH_I2C
Definition: path.h:11
@ DEVICE_PATH_MMIO
Definition: path.h:21
#define NULL
Definition: stddef.h:19
unsigned int uint32_t
Definition: stdint.h:14
int strcmp(const char *s1, const char *s2)
Definition: string.c:103
struct mmio_path mmio
Definition: path.h:128
Definition: device.h:107
struct device_path path
Definition: device.h:115
DEVTREE_CONST struct bus * link_list
Definition: device.h:139
unsigned int enabled
Definition: device.h:122
uintptr_t addr
Definition: path.h:106