soc/intel/xeon_sp: Allow OS to control LTR and AER
[coreboot2.git] / src / mainboard / google / octopus / variants / phaser / gpio.c
blob72ad7239fe5d087fabf1636d08b907549dacb29b
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <baseboard/gpio.h>
4 #include <baseboard/variants.h>
5 #include <boardid.h>
6 #include <gpio.h>
7 #include <ec/google/chromeec/ec.h>
9 #define SKU_UNKNOWN 0xFFFFFFFF
11 static const struct pad_config default_override_table[] = {
12 PAD_NC(GPIO_52, UP_20K),
13 PAD_NC(GPIO_53, UP_20K),
14 PAD_NC(GPIO_67, UP_20K),
15 PAD_NC(GPIO_117, UP_20K),
16 PAD_CFG_GPI_APIC_IOS(GPIO_137, NONE, DEEP, LEVEL, INVERT, HIZCRx1,
17 DISPUPD),
18 PAD_NC(GPIO_143, UP_20K),
20 /* EN_PP3300_TOUCHSCREEN */
21 PAD_CFG_GPO_IOSSTATE_IOSTERM(GPIO_146, 1, DEEP, NONE, Tx0RxDCRx0, DISPUPD),
22 /* GPIO_105 -- TOUCHSCREEN_RST */
23 PAD_CFG_GPO_IOSSTATE_IOSTERM(GPIO_105, 0, DEEP, NONE, Tx1RxDCRx0, DISPUPD),
24 /* GPIO_140 -- PEN_RESET */
25 PAD_CFG_GPO_IOSSTATE_IOSTERM(GPIO_140, 0, DEEP, NONE, Tx1RxDCRx0, DISPUPD),
27 PAD_NC(GPIO_161, DN_20K),
29 PAD_NC(GPIO_213, DN_20K),
30 PAD_NC(GPIO_214, DN_20K),
33 static const struct pad_config sku1_default_override_table[] = {
34 /* disable I2C7 SCL and SDA */
35 PAD_NC(GPIO_114, UP_20K), /* LPSS_I2C7_SDA */
36 PAD_NC(GPIO_115, UP_20K), /* LPSS_I2C7_SCL */
38 PAD_NC(GPIO_52, UP_20K),
39 PAD_NC(GPIO_53, UP_20K),
40 PAD_NC(GPIO_67, UP_20K),
41 PAD_NC(GPIO_117, UP_20K),
42 PAD_CFG_GPI_APIC_IOS(GPIO_137, NONE, DEEP, LEVEL, INVERT, HIZCRx1,
43 DISPUPD),
44 PAD_NC(GPIO_143, UP_20K),
46 /* EN_PP3300_TOUCHSCREEN */
47 PAD_CFG_GPO_IOSSTATE_IOSTERM(GPIO_146, 0, DEEP, NONE, Tx0RxDCRx0,
48 DISPUPD),
50 PAD_NC(GPIO_161, DN_20K),
52 /* EN_PP3300_WLAN_L */
53 PAD_CFG_GPO_IOSSTATE_IOSTERM(GPIO_178, 0, DEEP, NONE, Tx0RxDCRx0,
54 DISPUPD),
56 PAD_NC(GPIO_213, DN_20K),
57 PAD_NC(GPIO_214, DN_20K),
60 bool no_touchscreen_sku(uint32_t sku_id)
62 if ((sku_id == 1) || (sku_id == 6))
63 return true;
64 else
65 return false;
68 const struct pad_config *variant_override_gpio_table(size_t *num)
70 const struct pad_config *c;
71 uint32_t sku_id = SKU_UNKNOWN;
73 google_chromeec_cbi_get_sku_id(&sku_id);
74 if (no_touchscreen_sku(sku_id)) {
75 c = sku1_default_override_table;
76 *num = ARRAY_SIZE(sku1_default_override_table);
77 } else {
78 c = default_override_table;
79 *num = ARRAY_SIZE(default_override_table);
82 return c;
86 /* Touchscreen GPIOs needed to be set in romstage. */
87 static const struct pad_config romstage_touch_gpio_table[] = {
88 /* Enable touchscreen, hold in reset */
89 /* EN_PP3300_TOUCHSCREEN */
90 PAD_CFG_GPO_IOSSTATE_IOSTERM(GPIO_146, 1, DEEP, NONE, Tx0RxDCRx0, DISPUPD),
91 /* GPIO_105 -- TOUCHSCREEN_RST */
92 PAD_CFG_GPO_IOSSTATE_IOSTERM(GPIO_105, 1, DEEP, NONE, Tx1RxDCRx0, DISPUPD),
93 /* GPIO_140 -- PEN_RESET */
94 PAD_CFG_GPO_IOSSTATE_IOSTERM(GPIO_140, 1, DEEP, NONE, Tx1RxDCRx0, DISPUPD),
97 const struct pad_config *variant_romstage_gpio_table(size_t *num)
99 const struct pad_config *c;
100 uint32_t sku_id = SKU_UNKNOWN;
102 google_chromeec_cbi_get_sku_id(&sku_id);
103 if (no_touchscreen_sku(sku_id)) {
104 c = NULL;
105 *num = 0;
106 } else {
107 c = romstage_touch_gpio_table;
108 *num = ARRAY_SIZE(romstage_touch_gpio_table);
111 return c;