1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <baseboard/gpio.h>
4 #include <baseboard/variants.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
,
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
,
44 PAD_NC(GPIO_143
, UP_20K
),
46 /* EN_PP3300_TOUCHSCREEN */
47 PAD_CFG_GPO_IOSSTATE_IOSTERM(GPIO_146
, 0, DEEP
, NONE
, Tx0RxDCRx0
,
50 PAD_NC(GPIO_161
, DN_20K
),
52 /* EN_PP3300_WLAN_L */
53 PAD_CFG_GPO_IOSSTATE_IOSTERM(GPIO_178
, 0, DEEP
, NONE
, Tx0RxDCRx0
,
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))
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
);
78 c
= default_override_table
;
79 *num
= ARRAY_SIZE(default_override_table
);
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
)) {
107 c
= romstage_touch_gpio_table
;
108 *num
= ARRAY_SIZE(romstage_touch_gpio_table
);