summaryrefslogtreecommitdiff
path: root/board/woomax/board.h
blob: 20bbb8417a0811a60358a68fb8a89cf7e6828f33 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
/* Copyright 2020 The ChromiumOS Authors
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

/* Trembyle board configuration */

#ifndef __CROS_EC_BOARD_H
#define __CROS_EC_BOARD_H

#define VARIANT_ZORK_TREMBYLE

#include <stdbool.h>
#include "baseboard.h"

#undef CONFIG_USB_PORT_POWER_SMART_PORT_COUNT
#define CONFIG_USB_PORT_POWER_SMART_PORT_COUNT 1
#define CONFIG_USBC_RETIMER_PI3DPX1207

/* Motion sensing drivers */
#define CONFIG_ACCELGYRO_BMI160
#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
	TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
#define CONFIG_ACCELGYRO_ICM426XX
#define CONFIG_ACCELGYRO_ICM426XX_INT_EVENT \
	TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
#define CONFIG_ACCEL_KX022
#define CONFIG_CMD_ACCELS
#define CONFIG_CMD_ACCEL_INFO
#define CONFIG_TABLET_MODE
#define CONFIG_LID_ANGLE
#define CONFIG_LID_ANGLE_UPDATE
#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL
#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL
#define CONFIG_GMR_TABLET_MODE

/* Keyboard */
#define CONFIG_KEYBOARD_VIVALDI
#define CONFIG_KEYBOARD_REFRESH_ROW3
#define CONFIG_KEYBOARD_KEYPAD

/*
 * Woomax's battery takes several seconds to come back out of its disconnect
 * state (~4 seconds on the unit I have, so give it a little more for margin).
 */
#undef CONFIG_POWER_BUTTON_INIT_TIMEOUT
#define CONFIG_POWER_BUTTON_INIT_TIMEOUT 5

/* Thermal */
#define CONFIG_CUSTOM_FAN_CONTROL

/* GPIO mapping from board specific name to EC common name. */
#define CONFIG_BATTERY_PRESENT_GPIO GPIO_EC_BATT_PRES_ODL
#define CONFIG_SCI_GPIO GPIO_EC_FCH_SCI_ODL
#define GPIO_AC_PRESENT GPIO_ACOK_OD
#define GPIO_CPU_PROCHOT GPIO_PROCHOT_ODL
#define GPIO_EC_INT_L GPIO_EC_AP_INT_ODL
#define GPIO_ENABLE_BACKLIGHT_L GPIO_EC_EDP_BL_DISABLE
#define GPIO_ENTERING_RW GPIO_EC_ENTERING_RW
#define GPIO_KBD_KSO2 GPIO_EC_KSO_02_INV
#define GPIO_PCH_PWRBTN_L GPIO_EC_FCH_PWR_BTN_L
#define GPIO_PCH_RSMRST_L GPIO_EC_FCH_RSMRST_L
#define GPIO_PCH_SLP_S3_L GPIO_SLP_S3_L
#define GPIO_PCH_SLP_S5_L GPIO_SLP_S5_L
#define GPIO_PCH_SYS_PWROK GPIO_EC_FCH_PWROK
#define GPIO_PCH_WAKE_L GPIO_EC_FCH_WAKE_L
#define GPIO_POWER_BUTTON_L GPIO_EC_PWR_BTN_ODL
#define GPIO_S0_PGOOD GPIO_S0_PWROK_OD
#define GPIO_S5_PGOOD GPIO_EC_PWROK_OD
#define GPIO_SYS_RESET_L GPIO_EC_SYS_RST_L
#define GPIO_VOLUME_DOWN_L GPIO_VOLDN_BTN_ODL
#define GPIO_VOLUME_UP_L GPIO_VOLUP_BTN_ODL
#define GPIO_WP_L GPIO_EC_WP_L
#define GPIO_PACKET_MODE_EN GPIO_EC_H1_PACKET_MODE

#ifndef __ASSEMBLER__

enum adc_channel { ADC_TEMP_SENSOR_CHARGER, ADC_TEMP_SENSOR_SOC, ADC_CH_COUNT };

enum battery_type {
	BATTERY_C536,
	BATTERY_TYPE_COUNT,
};

enum mft_channel {
	MFT_CH_0 = 0,
	/* Number of MFT channels */
	MFT_CH_COUNT,
};

enum pwm_channel { PWM_CH_KBLIGHT = 0, PWM_CH_FAN, PWM_CH_COUNT };

enum temp_sensor_id {
	TEMP_SENSOR_CHARGER = 0,
	TEMP_SENSOR_SOC,
	TEMP_SENSOR_CPU,
	TEMP_SENSOR_COUNT
};

enum usba_port { USBA_PORT_A0 = 0, USBA_PORT_COUNT };

/*****************************************************************************
 * CBI EC FW Configuration
 */

/**
 * WOOMAX_MB_USBAC
 *	USB-A0  Speed: 10 Gbps
 *		Retimer: PS8811
 *	USB-C0  Speed: 10 Gbps
 *		Retimer: PI3DPX1207
 *		TCPC: NCT3807
 *		PPC: AOZ1380
 *		IOEX: TCPC
 */
enum ec_cfg_usb_mb_type {
	WOOMAX_MB_USBAC = 0,
};

/**
 * WOOMAX_DB_T_OPT1_USBAC_HMDI
 *	USB-C1  Speed: 10 Gbps
 *		Retimer: PS8818
 *		TCPC: NCT3807
 *		PPC: NX20P3483
 *		IOEX: TCPC
 *	HDMI    Exists: yes
 *		Retimer: PI3HDX1204
 *		MST Hub: none
 *
 * WOOMAX_DB_T_OPT3_USBAC_HDMI_MSTHUB
 *	USB-C1  Speed: 10 Gbps
 *		Retimer: PS8802
 *		TCPC: NCT3807
 *		PPC: NX20P3483
 *		IOEX: TCPC
 *	HDMI    Exists: yes
 *		Retimer: none
 *		MST Hub: RTD2141B
 */
enum ec_cfg_usb_db_type {
	WOOMAX_DB_T_OPT1_USBAC_HMDI = 0,
	WOOMAX_DB_T_OPT3_USBAC_HDMI_MSTHUB = 1,
};

#include "cbi_ec_fw_config.h"

#define HAS_USBC1_RETIMER_PS8802 (BIT(WOOMAX_DB_T_OPT3_USBAC_HDMI_MSTHUB))

static inline bool ec_config_has_usbc1_retimer_ps8802(void)
{
	return !!(BIT(ec_config_get_usb_db()) & HAS_USBC1_RETIMER_PS8802);
}

#define HAS_USBC1_RETIMER_PS8818 (BIT(WOOMAX_DB_T_OPT1_USBAC_HMDI))

static inline bool ec_config_has_usbc1_retimer_ps8818(void)
{
	return !!(BIT(ec_config_get_usb_db()) & HAS_USBC1_RETIMER_PS8818);
}

#define HAS_HDMI_RETIMER_PI3HDX1204 (BIT(WOOMAX_DB_T_OPT1_USBAC_HMDI))

static inline bool ec_config_has_hdmi_retimer_pi3hdx1204(void)
{
	return !!(BIT(ec_config_get_usb_db()) & HAS_HDMI_RETIMER_PI3HDX1204);
}

#define HAS_MST_HUB_RTD2141B (BIT(WOOMAX_DB_T_OPT3_USBAC_HDMI_MSTHUB))

static inline bool ec_config_has_mst_hub_rtd2141b(void)
{
	return !!(BIT(ec_config_get_usb_db()) & HAS_MST_HUB_RTD2141B);
}

/**
 * @warning Callers must use gpio_or_ioex_set_level to handle the return result
 * since either type of signal can be returned.
 *
 * USB-C0 always uses USB_C0_HPD (= DP3_HPD).
 * USB-C1 OPT1 DB uses DP2_HPD.
 * USB-C1 OPT3 DB uses DP1_HPD via RTD2141B MST hub to drive AP
 *    HPD, EC drives MST hub HPD input from USB-PD messages.
 *
 * @return GPIO (gpio_signal) or IOEX (ioex_signal)
 */
int board_usbc_port_to_hpd_gpio_or_ioex(int port);
#define PORT_TO_HPD(port) board_usbc_port_to_hpd_gpio_or_ioex(port)

extern const struct usb_mux_chain usbc0_pi3dpx1207_usb_retimer;
extern const struct usb_mux usbc1_ps8818;
extern struct usb_mux usbc1_ps8802;
extern struct usb_mux usbc1_amd_fp5_usb_mux;
void hdmi_hpd_interrupt(enum gpio_signal signal);
void motion_interrupt(enum gpio_signal signal);

#endif /* !__ASSEMBLER__ */

#endif /* __CROS_EC_BOARD_H */