summaryrefslogtreecommitdiffstats
path: root/src/mainboard/google/geralt/chromeos.c
blob: 10fc9d314fccc4f44d6217021dba688bcae276f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* SPDX-License-Identifier: GPL-2.0-only */

#include <bootmode.h>
#include <boot/coreboot_tables.h>
#include <gpio.h>
#include <security/tpm/tis.h>

#include "gpio.h"
#include "panel.h"

void setup_chromeos_gpios(void)
{
	/* Set up open-drain pins */
	gpio_input(GPIO_EC_AP_INT_ODL);
	gpio_input(GPIO_GSC_AP_INT_ODL);
	gpio_input(GPIO_AP_WP_ODL);

	/* Set up GPOs */
	gpio_output(GPIO_AP_EC_WARM_RST_REQ, 0);
	gpio_output(GPIO_EN_SPKR, 0);
	gpio_output(GPIO_RST_SPKR_L, 0);
	gpio_output(GPIO_XHCI_INIT_DONE, 0);
}

void fill_lb_gpios(struct lb_gpios *gpios)
{
	struct lb_gpio chromeos_gpios[] = {
		{GPIO_EC_AP_INT_ODL.id, ACTIVE_LOW, -1, "EC interrupt"},
		{GPIO_GSC_AP_INT_ODL.id, ACTIVE_HIGH, -1, "TPM interrupt"},
		{GPIO_EN_SPKR.id, ACTIVE_HIGH, -1, "speaker enable"},
		{GPIO_XHCI_INIT_DONE.id, ACTIVE_HIGH, -1, "XHCI init done"},
	};
	lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios));

	fill_lp_backlight_gpios(gpios);

	if (CONFIG(SDCARD_INIT)) {
		struct lb_gpio sd_card_gpios[] = {
			{GPIO_SD_CD_ODL.id, ACTIVE_LOW, -1, "SD card detect"},
		};
		lb_add_gpios(gpios, sd_card_gpios, ARRAY_SIZE(sd_card_gpios));
	}

	if (CONFIG(USE_MAX98390)) {
		struct lb_gpio max98390_gpios[] = {
			{GPIO_RST_SPKR_L.id, ACTIVE_LOW, -1, "speaker reset"},
		};
		lb_add_gpios(gpios, max98390_gpios, ARRAY_SIZE(max98390_gpios));
	}
}

int tis_plat_irq_status(void)
{
	return gpio_eint_poll(GPIO_GSC_AP_INT_ODL);
}