mb/google/octopus/var/bobba: Update GPIO config for bobba bid >= 1
[coreboot.git] / src / mainboard / google / octopus / variants / bobba / variant.c
blob1ead5e230ce3e3f34dbe185c4483d0b65c424d26
1 /*
2 * This file is part of the coreboot project.
4 * Copyright 2018 Google LLC.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
16 #include <arch/acpi_device.h>
17 #include <baseboard/variants.h>
18 #include <boardid.h>
19 #include <device/device.h>
20 #include <drivers/i2c/generic/chip.h>
21 #include <drivers/i2c/hid/chip.h>
22 #include <soc/gpio.h>
23 #include <soc/pci_devs.h>
24 #include <string.h>
26 extern struct chip_operations drivers_i2c_generic_ops;
27 extern struct chip_operations drivers_i2c_hid_ops;
29 void variant_update_devtree(struct device *dev)
31 uint32_t bid;
32 struct device *touchscreen_i2c_host;
33 struct device *child;
34 const struct bus *children_bus;
35 static const struct acpi_gpio new_enable_gpio =
36 ACPI_GPIO_OUTPUT_ACTIVE_HIGH(GPIO_146);
38 bid = board_id();
40 /* Nothing to update. */
41 if (bid == UNDEFINED_STRAPPING_ID || bid < 1)
42 return;
44 touchscreen_i2c_host = dev_find_slot(0, PCH_DEVFN_I2C7);
46 if (touchscreen_i2c_host == NULL)
47 return;
49 children_bus = touchscreen_i2c_host->link_list;
50 child = NULL;
52 /* Find all children on bus to update touchscreen enable gpio. */
53 while ((child = dev_bus_each_child(children_bus, child)) != NULL) {
54 struct drivers_i2c_generic_config *cfg;
56 /* No configration to change. */
57 if (child->chip_info == NULL)
58 continue;
60 if (child->chip_ops == &drivers_i2c_generic_ops)
61 cfg = child->chip_info;
62 else if (child->chip_ops == &drivers_i2c_hid_ops) {
63 struct drivers_i2c_hid_config *hid_cfg;
64 hid_cfg = child->chip_info;
65 cfg = &hid_cfg->generic;
66 } else
67 continue;
69 /* Update the enable gpio. */
70 memcpy(&cfg->enable_gpio, &new_enable_gpio,
71 sizeof(new_enable_gpio));