mb/google/brya: Create rull variant
[coreboot2.git] / src / mainboard / google / kahlee / variants / careena / mainboard.c
blobc54b5303a5f182ccec397e1d8c6790ea02457c3d
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <ec/google/chromeec/ec.h>
4 #include <baseboard/variants.h>
5 #include <variant/sku.h>
6 #include <string.h>
7 #include <drivers/i2c/hid/chip.h>
9 extern struct chip_operations drivers_i2c_generic_ops;
10 extern struct chip_operations drivers_i2c_da7219_ops;
12 void variant_devtree_update(void)
14 uint32_t sku = google_chromeec_get_sku_id();
15 struct device *mmio_dev = NULL, *child = NULL;
16 struct device *alc_dev = NULL, *da7219_dev = NULL;
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;
26 if (mmio_dev == NULL)
27 return;
29 while ((child = dev_bus_each_child(mmio_dev->downstream, 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;
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;
51 case SKU_BARLA_ALC5682_44:
52 case SKU_BARLA_ALC5682_45:
53 case SKU_BARLA_ALC5682_46:
54 case SKU_BARLA_ALC5682_47:
55 /* alc5682 only */
56 if (da7219_dev)
57 da7219_dev->enabled = 0;
58 if (alc_dev)
59 alc_dev->enabled = 1;
60 break;