coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
ramstage_common.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #include <acpi/acpi_device.h>
4 #include <baseboard/variants.h>
5 #include <console/console.h>
6 #include <device/device.h>
9 #include <drivers/i2c/hid/chip.h>
10 #include <drivers/usb/acpi/chip.h>
11 #include <ec/google/chromeec/ec.h>
12 #include <soc/gpio.h>
13 #include <soc/iomap.h>
14 #include <soc/pci_devs.h>
15 
18 
19 WEAK_DEV_PTR(xhci1_bt);
20 
21 static void update_hp_int_odl(void)
22 {
23  const struct device *rt5682_dev = DEV_PTR(audio_rt5682);
24  struct drivers_i2c_generic_config *cfg;
25  struct acpi_gpio *gpio;
26  struct soc_amd_picasso_config *soc_cfg;
27 
29  return;
30 
31  cfg = config_of(rt5682_dev);
32  gpio = &cfg->irq_gpio;
33  gpio->pins[0] = 62;
34 
35  /*
36  * When using CODEC_GPI for headphone jack interrupt, ACP_PME_EN and ACP_I2S_WAKE_EN
37  * need to be set to trigger I2S_WAKE event for headphone jack.
38  */
39  soc_cfg = config_of_soc();
42 }
43 
44 static void update_dmic_gpio(void)
45 {
46  const struct device *machine_dev = DEV_PTR(acp_machine);
48  struct acpi_gpio *gpio;
49 
51  return;
52 
53  cfg = config_of(machine_dev);
54  gpio = &cfg->dmic_select_gpio;
55 
56  if (CONFIG(BOARD_GOOGLE_BASEBOARD_TREMBYLE))
57  gpio->pins[0] = GPIO_13;
58  else
59  gpio->pins[0] = GPIO_6;
60 
61 }
62 
64 {
67 }
68 
69 /*
70  * Removes reset_gpio from usb device in device tree.
71  *
72  * debug_device_name is used for debug messaging only.
73  */
74 static void remove_usb_device_reset_gpio(const struct device *usb_dev)
75 {
76 
77  struct drivers_usb_acpi_config *usb_cfg;
78  /* config_of dies on failure, so a NULL check is not required */
79  usb_cfg = config_of(usb_dev);
80  usb_cfg->reset_gpio.pin_count = 0;
81 }
82 
83 /*
84  * The bluetooth device may be on XHCI0 or XHCI1 depending on SOC.
85  * There's no harm in removing reset_gpio from both here.
86  */
88 {
91 }
92 
94 {
95  if (CONFIG(BOARD_GOOGLE_BASEBOARD_DALBOZ) || variant_uses_v3_schematics())
96  return;
97 
99 }
100 
102 {
103  DEVTREE_CONST struct device *mmio_dev = DEV_PTR(i2c_2);
104  struct device *child = NULL;
105 
106  /*
107  * By default, devicetree/overridetree entries for touchscreen device are configured to
108  * match v3.6 of reference schematics. So, if the board is using v3.6+ schematics, no
109  * additional work is required here. For maintaining support for pre-v3.6 boards, rest
110  * of the code in this function finds all entries that correspond to touchscreen
111  * devices (identified by reset_gpio being set to GPIO_140) and updates them as per
112  * pre-v3.6 version of schematics:
113  * 1. reset_gpio is marked as active high.
114  */
116  return;
117 
118  while ((child = dev_bus_each_child(mmio_dev->link_list, child)) != NULL) {
119  struct drivers_i2c_generic_config *cfg;
120 
121  if (child->chip_ops == &drivers_i2c_generic_ops) {
122  cfg = config_of(child);
123  } else if (child->chip_ops == &drivers_i2c_hid_ops) {
124  struct drivers_i2c_hid_config *hid_cfg;
125  hid_cfg = config_of(child);
126  cfg = &hid_cfg->generic;
127  } else {
128  continue;
129  }
130 
131  /* If reset_gpio is set to GPIO_140, assume that this is touchscreen device. */
132  if (cfg->reset_gpio.pins[0] != GPIO_140)
133  continue;
134 
135  cfg->reset_gpio.active_low = 0;
136  cfg->enable_gpio.pin_count = 0;
137  cfg->enable_gpio.pins[0] = 0;
138  }
139 }
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
@ CONFIG
Definition: dsi_common.h:201
#define DEV_PTR(_alias)
Definition: device.h:403
static DEVTREE_CONST void * config_of(const struct device *dev)
Definition: device.h:382
#define config_of_soc()
Definition: device.h:394
WEAK_DEV_PTR(xhci1_bt)
static void remove_usb_device_reset_gpio(const struct device *usb_dev)
void variant_bluetooth_update(void)
void variant_touchscreen_update(void)
static void baseboard_trembyle_remove_bluetooth_reset_gpio(void)
void variant_audio_update(void)
struct chip_operations drivers_i2c_hid_ops
Definition: hid.c:92
static void update_hp_int_odl(void)
static void update_dmic_gpio(void)
struct chip_operations drivers_i2c_generic_ops
Definition: generic.c:217
#define GPIO_140
Definition: gpio.h:87
#define GPIO_6
Definition: gpio.h:27
#define GPIO_13
Definition: gpio.h:34
#define NULL
Definition: stddef.h:19
#define DEVTREE_CONST
Definition: stddef.h:30
u8 acp_pme_enable
Definition: acp.h:38
u8 acp_i2s_wake_enable
Definition: acp.h:36
int pin_count
Definition: acpi_device.h:165
bool active_low
Definition: acpi_device.h:190
uint16_t pins[ACPI_GPIO_MAX_PINS]
Definition: acpi_device.h:166
Definition: device.h:107
struct chip_operations * chip_ops
Definition: device.h:144
DEVTREE_CONST struct bus * link_list
Definition: device.h:139
struct acpi_gpio dmic_select_gpio
Definition: chip.h:19
struct acpi_gpio irq_gpio
Definition: chip.h:23
struct acpi_gpio enable_gpio
Definition: chip.h:51
struct acpi_gpio reset_gpio
Definition: chip.h:45
struct drivers_i2c_generic_config generic
Definition: chip.h:11
struct acpi_gpio reset_gpio
Definition: chip.h:51
Definition: pinmux.c:36
struct acp_config acp_config
Definition: chip.h:42
struct soc_amd_common_config common_config
Definition: chip.h:98
bool variant_uses_codec_gpi(void)
Definition: helpers.c:160
bool variant_uses_v3_schematics(void)
Definition: helpers.c:124
bool variant_uses_v3_6_schematics(void)
Definition: helpers.c:140