Skip to content

Commit d76abd3

Browse files
committed
oot: boards: Add PTL board specfic files
1 parent f0347e8 commit d76abd3

15 files changed

+1231
-1
lines changed

boards/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ target_sources_ifdef(CONFIG_BOARD_MEC172X_MTL_S app
4848
${CMAKE_CURRENT_LIST_DIR}/microchip/mtl_s_mec172x.h
4949
)
5050

51+
target_sources_ifdef(CONFIG_BOARD_MEC172X_PTL_UH app
52+
PRIVATE
53+
${CMAKE_CURRENT_LIST_DIR}/microchip/ptl_uh_mec172x.c
54+
PUBLIC
55+
${CMAKE_CURRENT_LIST_DIR}/microchip/ptl_uh_mec172x.h
56+
)
57+
5158
target_include_directories(app
5259
PRIVATE
5360
${CMAKE_CURRENT_LIST_DIR}
@@ -56,4 +63,4 @@ target_include_directories(app
5663
${CMAKE_CURRENT_LIST_DIR}/microchip/mec172x_mecc
5764
)
5865

59-
endif()
66+
endif()

boards/board_config.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ extern uint8_t boot_mode_maf;
3030
#include "mtl_template_mec172xlj.h"
3131
#elif defined(CONFIG_BOARD_MEC172X_MTL_S)
3232
#include "mtl_s_mec172x.h"
33+
#elif defined(CONFIG_BOARD_MEC172X_PTL_UH)
34+
#include "ptl_uh_mec172x.h"
3335
#else
3436
#error "Platform not supported"
3537
#endif /* CONFIG_BOARD_MEC1501MODULAR_ASSY6885 */

boards/mec172x_ptl_uh.conf

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Zephyr-based EC FW
2+
3+
# EC FW features configuration
4+
# ----------------------------
5+
6+
# Enable PS2 device management but only keyboard due SoC port limitation
7+
CONFIG_PS2_KEYBOARD=y
8+
CONFIG_PS2_MOUSE=n
9+
10+
# EC FW keyscan configuration
11+
CONFIG_KSCAN_EC=y
12+
CONFIG_SOC_DEBUG_CONSENT_GPIO=y
13+
14+
#Use UART0 for the eSPI communication
15+
#-------------------------------------
16+
CONFIG_ESPI_PERIPHERAL_UART_SOC_MAPPING=0
17+
18+
# Support deprecated SMChost commands for backward compatibility
19+
CONFIG_DEPRECATED_SMCHOST_CMD=y
20+
21+
# Enable gigadevice sequence
22+
CONFIG_SAF_ENABLE_XIP=y
23+
24+
# Zephyr kernel/driver configuration required by EC FW
25+
# ----------------------------------------------------
26+
CONFIG_PS2=y
27+
CONFIG_ESPI_PERIPHERAL_8042_KBC=y
28+
29+
# IO expander support interrupt
30+
CONFIG_GPIO_PCA95XX_INTERRUPT=y
31+
32+
# Workaround to avoid overlap in SPI layout
33+
CONFIG_FLASH_SIZE=224
34+
35+
# Enable SAF
36+
CONFIG_ESPI_SAF=y

boards/microchip/ptl_uh_mec172x.c

Lines changed: 280 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,280 @@
1+
/*
2+
* Copyright (c) 2024 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <soc.h>
8+
#include <zephyr/drivers/gpio.h>
9+
#include "i2c_hub.h"
10+
#include <zephyr/logging/log.h>
11+
#include "gpio_ec.h"
12+
#include "espi_hub.h"
13+
#include "board.h"
14+
#include "board_config.h"
15+
#include "ptl_uh_mec172x.h"
16+
#include "vci.h"
17+
18+
LOG_MODULE_DECLARE(board, CONFIG_BOARD_LOG_LEVEL);
19+
20+
uint8_t platformskutype;
21+
uint8_t pd_i2c_addr_set;
22+
23+
/** @brief EC FW app owned gpios list.
24+
*
25+
* This list is not exhaustive, it do not include driver-owned pins,
26+
* the initialization is done as part of corresponding Zephyr pinmux driver.
27+
* BSP drivers are responsible to control gpios in soc power transitions and
28+
* system transitions.
29+
*
30+
* Note: Pins not assigned to any app function are identified with their
31+
* original pin number instead of signal
32+
*
33+
*/
34+
35+
/* APP-owned gpios */
36+
struct gpio_ec_config mecc172x_cfg[] = {
37+
{ HOME_BUTTON, GPIO_INPUT },
38+
{ EC_GPIO_002, GPIO_DISCONNECTED },
39+
{ PM_SLP_SUS, GPIO_DISCONNECTED },
40+
{ PM_PWRBTN, GPIO_OUTPUT_HIGH | GPIO_OPEN_DRAIN },
41+
{ RSMRST_PWRGD_G3SAF_P, GPIO_INPUT },
42+
{ RSMRST_PWRGD_MAF_P, GPIO_INPUT },
43+
{ CPU_C10_GATE, GPIO_INPUT },
44+
{ DNX_FORCE_RELOAD_EC, GPIO_DISCONNECTED },
45+
{ EC_GPIO_015, GPIO_DISCONNECTED },
46+
47+
/* Not used */
48+
{ SLP_S0_PLT_EC_N, GPIO_DISCONNECTED },
49+
50+
{ ALL_SYS_PWRGD, GPIO_INPUT },
51+
{ FAN_PWR_DISABLE_N, GPIO_OUTPUT_HIGH },
52+
{ ESPI_RESET_MAF, GPIO_INPUT },
53+
{ PCA9555_1_R_INT_N, GPIO_INPUT },
54+
{ EC_GPIO_063, GPIO_DISCONNECTED },
55+
{ EC_GPIO_067, GPIO_DISCONNECTED },
56+
57+
{ PCH_PWROK, GPIO_OUTPUT_LOW | GPIO_OPEN_DRAIN },
58+
{ PWRBTN_EC_IN_N, GPIO_INPUT | GPIO_INT_EDGE_BOTH },
59+
{ EC_GPIO_115, GPIO_DISCONNECTED },
60+
{ KBC_CAPS_LOCK, GPIO_OUTPUT_LOW },
61+
{ TYPEC_EC_SMBUS_ALERT_0_R, GPIO_INPUT | GPIO_INT_EDGE_FALLING },
62+
{ EC_PG3_EXIT, GPIO_OUTPUT_LOW },
63+
64+
{ KBD_BKLT_CTRL, GPIO_OUTPUT_LOW },
65+
{ PM_BAT_STATUS_LED1, GPIO_OUTPUT_LOW },
66+
{ PM_BAT_STATUS_LED2, GPIO_OUTPUT_LOW },
67+
{ KBC_NUM_LOCK, GPIO_OUTPUT_LOW },
68+
{ BC_ACOK, GPIO_INPUT },
69+
{ BATT_ID_N, GPIO_INPUT },
70+
{ PM_BATLOW, GPIO_OUTPUT_LOW | GPIO_OPEN_DRAIN },
71+
72+
{ PROCHOT, GPIO_OUTPUT_HIGH | GPIO_OPEN_DRAIN },
73+
{ RETIMER_FORCE_PWR_BTP_EC_R, GPIO_DISCONNECTED},
74+
{ EC_SLATEMODE_HALLOUT_SNSR_R, GPIO_INPUT | GPIO_INT_EDGE_BOTH },
75+
{ PM_DS3, GPIO_OUTPUT_LOW },
76+
{ EC_GPIO_240, GPIO_DISCONNECTED },
77+
{ EC_PWRBTN_LED, GPIO_OUTPUT_LOW },
78+
{ VOL_UP, GPIO_INPUT | GPIO_INT_EDGE_BOTH },
79+
{ STD_ADP_PRSNT, GPIO_INPUT },
80+
{ TOP_SWAP_OVERRIDE_GPIO, GPIO_OUTPUT },
81+
{ EC_GPIO_245, GPIO_DISCONNECTED },
82+
{ VOL_DOWN, GPIO_INPUT | GPIO_INT_EDGE_BOTH },
83+
{ STD_ADPT_CNTRL_GPIO, GPIO_OUTPUT_LOW },
84+
{ CATERR_LED_DRV, GPIO_DISCONNECTED},
85+
86+
/* Not used */
87+
{ SLP_S0_PLT_EC_N, GPIO_DISCONNECTED },
88+
89+
};
90+
91+
/* Any IO expanders pins should be defined here */
92+
struct gpio_ec_config expander_cfg[] = {
93+
#ifdef CONFIG_GPIO_PCA95XX
94+
{ SPD_PRSNT, GPIO_INPUT },
95+
{ VIRTUAL_BAT, GPIO_INPUT },
96+
{ VIRTUAL_DOCK, GPIO_INPUT },
97+
{ TIMEOUT_DISABLE, GPIO_INPUT },
98+
{ SOC_VR_CNTRL, GPIO_INPUT },
99+
{ EC_M_2_SSD_PLN, GPIO_OUTPUT_HIGH },
100+
{ THERM_STRAP, GPIO_INPUT },
101+
{ KBC_SCROLL_LOCK, GPIO_OUTPUT_LOW },
102+
{ CS_INDICATE_LED, GPIO_OUTPUT_LOW },
103+
{ C10_GATE_LED, GPIO_OUTPUT_LOW },
104+
#endif
105+
};
106+
107+
struct gpio_ec_config mecc172x_cfg_sus[] = {
108+
};
109+
110+
struct gpio_ec_config mecc172x_cfg_res[] = {
111+
};
112+
113+
#ifdef CONFIG_THERMAL_MANAGEMENT
114+
/**
115+
* @brief Fan device table.
116+
*
117+
* This table lists the supported fan devices for board. By default, each
118+
* board is assigned one fan for CPU.
119+
*/
120+
static struct fan_dev fan_tbl[] = {
121+
/* PWM_CH_## TACH_CH_## */
122+
{ PWM_CH_08, TACH_CH_00 }, /* CPU Fan */
123+
};
124+
125+
void board_fan_dev_tbl_init(uint8_t *pmax_fan, struct fan_dev **pfan_tbl)
126+
{
127+
*pfan_tbl = fan_tbl;
128+
*pmax_fan = ARRAY_SIZE(fan_tbl);
129+
}
130+
131+
void board_therm_sensor_list_init(uint8_t therm_sensors[])
132+
{
133+
switch (platformskutype) {
134+
case PLATFORM_PTL_UH_SKUs:
135+
therm_sensors[ACPI_THRM_SEN_2] = ADC_CH_07;
136+
therm_sensors[ACPI_THRM_SEN_3] = ADC_CH_04;
137+
therm_sensors[ACPI_THRM_SEN_4] = ADC_CH_05;
138+
therm_sensors[ACPI_THRM_SEN_5] = ADC_CH_06;
139+
break;
140+
default:
141+
break;
142+
}
143+
}
144+
#endif
145+
146+
void board_config_io_buffer(void)
147+
{
148+
int ret;
149+
150+
/* PS2 requires additional configuration not possible in pinmux */
151+
ret = gpio_interrupt_configure_pin(PS2_KB_DATA, GPIO_INT_EDGE_FALLING);
152+
if (ret) {
153+
LOG_ERR("Failed to enable PS2 KB interrupt");
154+
}
155+
}
156+
157+
void update_platform_sku_type(void)
158+
{
159+
switch (get_board_id()) {
160+
/* PTL UH Board ID List */
161+
case BRD_ID_PTL_UH_LP5x_T3_ERB:
162+
case BRD_ID_PTL_UH_LP5x_T3_RVP1:
163+
case BRD_ID_PTL_UH_LP5x_T4_RVP3:
164+
platformskutype = PLATFORM_PTL_UH_SKUs;
165+
pd_i2c_addr_set = PTL_UH_I2C_SET1;
166+
break;
167+
case BRD_ID_PTL_UH_LP5x_CAMM_DTBT_RVP2:
168+
case BRD_ID_PTL_UH_DDR5_T3_RVP4:
169+
platformskutype = PLATFORM_PTL_UH_SKUs;
170+
pd_i2c_addr_set = PTL_UH_I2C_SET2;
171+
break;
172+
default:
173+
platformskutype = PLATFORM_PTL_UH_SKUs;
174+
pd_i2c_addr_set = PTL_UH_I2C_SET1;
175+
break;
176+
}
177+
}
178+
179+
int board_init(void)
180+
{
181+
int ret;
182+
183+
LOG_WRN("%s", __func__);
184+
bgpo_disable();
185+
186+
ret = gpio_init();
187+
if (ret) {
188+
LOG_ERR("Failed to initialize gpio devs: %d", ret);
189+
return ret;
190+
}
191+
192+
LOG_WRN("%s about to initialize i2c0", __func__);
193+
ret = i2c_hub_config(I2C_0);
194+
if (ret) {
195+
return ret;
196+
}
197+
198+
LOG_WRN("%s about to initialize i2c1", __func__);
199+
ret = i2c_hub_config(I2C_1);
200+
if (ret) {
201+
return ret;
202+
}
203+
204+
LOG_WRN("%s about to read board id", __func__);
205+
ret = read_board_id();
206+
if (ret) {
207+
LOG_ERR("Failed to fetch brd id: %d", ret);
208+
return ret;
209+
}
210+
211+
LOG_WRN("%s about to update sku", __func__);
212+
update_platform_sku_type();
213+
214+
LOG_WRN("%s about to configure expander", __func__);
215+
ret = gpio_configure_array(expander_cfg, ARRAY_SIZE(expander_cfg));
216+
if (ret) {
217+
LOG_ERR("%s: %d", __func__, ret);
218+
return ret;
219+
}
220+
221+
/* In PTL UH G3_SAF HW strap is not in the expander_cfg
222+
* MEC172x has by default GPIO input disabled.
223+
* Need to configure strap prior to decide boot mode
224+
*/
225+
gpio_configure_pin(G3_SAF_DETECT, GPIO_INPUT);
226+
227+
detect_boot_mode();
228+
229+
ret = gpio_configure_array(mecc172x_cfg, ARRAY_SIZE(mecc172x_cfg));
230+
if (ret) {
231+
LOG_ERR("%s: %d", __func__, ret);
232+
return ret;
233+
}
234+
235+
236+
/* In MAF, boot ROM already made this pin output and high, so we must
237+
* keep it like that during the boot phase in order to avoid espi reset
238+
*/
239+
if (espihub_boot_mode() == FLASH_BOOT_MODE_MAF) {
240+
gpio_force_configure_pin(PM_RSMRST_MAF_P, GPIO_OUTPUT_HIGH);
241+
/* LPM optimizations */
242+
gpio_force_configure_pin(G3_SAF_DETECT, GPIO_DISCONNECTED);
243+
gpio_force_configure_pin(PM_RSMRST_G3SAF_P, GPIO_DISCONNECTED);
244+
} else {
245+
gpio_configure_pin(RSMRST_PWRGD_G3SAF_P, GPIO_INPUT);
246+
gpio_configure_pin(PM_RSMRST_G3SAF_P, GPIO_OUTPUT_LOW);
247+
}
248+
249+
board_config_io_buffer();
250+
251+
return 0;
252+
}
253+
254+
int board_suspend(void)
255+
{
256+
int ret;
257+
258+
ret = gpio_configure_array(mecc172x_cfg_sus,
259+
ARRAY_SIZE(mecc172x_cfg_sus));
260+
if (ret) {
261+
LOG_ERR("%s: %d", __func__, ret);
262+
return ret;
263+
}
264+
265+
return 0;
266+
}
267+
268+
int board_resume(void)
269+
{
270+
int ret;
271+
272+
ret = gpio_configure_array(mecc172x_cfg_res,
273+
ARRAY_SIZE(mecc172x_cfg_res));
274+
if (ret) {
275+
LOG_ERR("%s: %d", __func__, ret);
276+
return ret;
277+
}
278+
279+
return 0;
280+
}

0 commit comments

Comments
 (0)