diff options
-rw-r--r-- | board/atlas/board.c | 2 | ||||
-rw-r--r-- | board/atlas/board.h | 2 | ||||
-rw-r--r-- | board/atlas/gpio.inc | 19 | ||||
-rw-r--r-- | board/atlas/usb_pd_policy.c | 49 |
4 files changed, 23 insertions, 49 deletions
diff --git a/board/atlas/board.c b/board/atlas/board.c index b0f4e01384..2ffd4540c7 100644 --- a/board/atlas/board.c +++ b/board/atlas/board.c @@ -97,6 +97,8 @@ const struct pwm_t pwm_channels[] = { [PWM_CH_KBLIGHT] = { 3, 0, 10000 }, [PWM_CH_LED1] = { 0, PWM_CONFIG_DSLEEP, 100 }, [PWM_CH_LED2] = { 2, PWM_CONFIG_DSLEEP, 100 }, + [PWM_CH_LED3] = { 6, PWM_CONFIG_DSLEEP, 100 }, + [PWM_CH_LED4] = { 1, PWM_CONFIG_DSLEEP, 100 }, }; BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT); diff --git a/board/atlas/board.h b/board/atlas/board.h index 40ab0e63f6..2a3ee997f8 100644 --- a/board/atlas/board.h +++ b/board/atlas/board.h @@ -197,6 +197,8 @@ enum pwm_channel { PWM_CH_KBLIGHT, PWM_CH_LED1, PWM_CH_LED2, + PWM_CH_LED3, + PWM_CH_LED4, PWM_CH_COUNT }; diff --git a/board/atlas/gpio.inc b/board/atlas/gpio.inc index ac0627222e..817692873b 100644 --- a/board/atlas/gpio.inc +++ b/board/atlas/gpio.inc @@ -26,19 +26,19 @@ GPIO_INT(LID_OPEN, PIN(D, 2), GPIO_INT_BOTH, lid_interrupt) GPIO_INT(ACCELGYRO3_INT_L, PIN(4, 1), GPIO_INT_FALLING, bmi160_interrupt) /* SoC section */ -GPIO(RSMRST_L, PIN(C, 2), GPIO_OUT_LOW) /* SOC Resume Reset */ +GPIO(RSMRST_L, PIN(3, 7), GPIO_OUT_LOW) /* SOC Resume Reset */ GPIO(EC_PCH_PWR_BTN_ODL, PIN(C, 1), GPIO_ODR_HIGH) /* Power button to SOC */ GPIO(EC_PCH_RTCRST, PIN(7, 6), GPIO_OUT_LOW) /* RTC Reset (broken) */ GPIO(EC_PCH_WAKE_L, PIN(7, 4), GPIO_ODR_HIGH) /* PCH wake */ GPIO(EC_PROCHOT_ODL, PIN(3, 4), GPIO_INPUT) /* SOC PROCHOT# */ GPIO(SYS_RESET_L, PIN(0, 2), GPIO_ODR_HIGH) /* SOC reset */ -GPIO(USB_C0_DP_HPD, PIN(C, 5), GPIO_OUT_LOW) /* C0 Hotplug */ -GPIO(USB_C1_DP_HPD, PIN(C, 6), GPIO_OUT_LOW) /* C1 Hotplug */ +GPIO(USB_C0_DP_HPD, PIN(C, 5), GPIO_INPUT) /* C0 Hotplug Detect */ +GPIO(USB_C1_DP_HPD, PIN(C, 6), GPIO_INPUT) /* C1 Hotplug Detect */ /* power seq section */ GPIO(EC_PCH_ACPRESENT, PIN(7, 3), GPIO_ODR_LOW) /* ACOK to SOC */ /* note: SLP_SUS_L_PMIC is an input in the schematics */ -GPIO(SLP_SUS_L_PMIC, PIN(B, 7), GPIO_OUT_LOW) /* SOC SLP_SUS# */ +GPIO(SLP_SUS_L_PMIC, PIN(E, 4), GPIO_OUT_LOW) /* SOC SLP_SUS# */ GPIO(SLP_S4_L, PIN(A, 3), GPIO_INPUT) /* SOC SLP_S4# */ GPIO(SLP_S3_L, PIN(A, 6), GPIO_INPUT) /* SOC SLP_S3# */ GPIO(ROP_INT_L, PIN(D, 5), GPIO_INPUT | GPIO_PULL_UP) /* PMIC IRQ (Unused) */ @@ -50,6 +50,10 @@ GPIO(EN_USB_C0_3A, PIN(6, 2), GPIO_OUT_LOW) /* 1.5/3.0 C0 current limit selec GPIO(EN_USB_C1_5V_OUT, PIN(7, 0), GPIO_OUT_LOW) /* C1 5V Enable */ GPIO(EN_USB_C1_CHARGE_L, PIN(0, 4), GPIO_OUT_LOW) /* alt fn */ GPIO(EN_USB_C1_3A, PIN(8, 3), GPIO_OUT_LOW) /* alt fn 1.5/3.0 C1 current limit selection */ + +GPIO(USB2_VBUSSENSE, PIN(A, 2), GPIO_OUT_LOW) /* USB OTG ID */ +GPIO(USB2_ID, PIN(A, 0), GPIO_OUT_LOW) /* USB OTG VBUS Sense */ + GPIO(USB_PD_RST_L, PIN(F, 1), GPIO_OUT_LOW) /* C0,C1 PD Reset */ /* misc section */ @@ -81,7 +85,6 @@ GPIO(EC_I2C4_BATTERY_SDA, PIN(F, 2), GPIO_INPUT) /* alt fn I2C4_SDA */ /* Not connected */ GPIO(NC_GPIO32, PIN(3, 2), GPIO_INPUT | GPIO_PULL_UP) GPIO(NC_GPIO35, PIN(3, 5), GPIO_INPUT | GPIO_PULL_UP) -GPIO(NC_GPIO37, PIN(3, 7), GPIO_INPUT | GPIO_PULL_UP) GPIO(NC_GPIO40, PIN(4, 0), GPIO_INPUT | GPIO_PULL_UP) GPIO(NC_GPIO44, PIN(4, 4), GPIO_INPUT | GPIO_PULL_UP) GPIO(NC_GPIO45, PIN(4, 5), GPIO_INPUT | GPIO_PULL_UP) @@ -93,8 +96,6 @@ GPIO(NC_GPIO63, PIN(6, 3), GPIO_INPUT | GPIO_PULL_UP) GPIO(NC_GPIO66, PIN(6, 6), GPIO_INPUT | GPIO_PULL_UP) GPIO(NC_GPIO82, PIN(8, 2), GPIO_INPUT | GPIO_PULL_UP) GPIO(NC_GPIO95, PIN(9, 5), GPIO_INPUT | GPIO_PULL_UP) -GPIO(NC_GPIOA0, PIN(A, 0), GPIO_INPUT | GPIO_PULL_UP) -GPIO(NC_GPIOA2, PIN(A, 2), GPIO_INPUT | GPIO_PULL_UP) GPIO(NC_GPIOB1, PIN(B, 1), GPIO_INPUT | GPIO_PULL_UP) GPIO(NC_GPIOB2, PIN(B, 2), GPIO_INPUT | GPIO_PULL_UP) GPIO(NC_GPIOB3, PIN(B, 3), GPIO_INPUT | GPIO_PULL_UP) @@ -103,7 +104,6 @@ GPIO(NC_GPIOC7, PIN(C, 7), GPIO_INPUT | GPIO_PULL_UP) GPIO(NC_GPIOD6, PIN(D, 6), GPIO_INPUT | GPIO_PULL_UP) GPIO(NC_GPIOD7, PIN(D, 7), GPIO_INPUT | GPIO_PULL_UP) GPIO(NC_GPIOE0, PIN(E, 0), GPIO_INPUT | GPIO_PULL_UP) -GPIO(NC_GPIOE4, PIN(E, 4), GPIO_INPUT | GPIO_PULL_UP) /* WoV is unused */ GPIO(NC_GPIO94, PIN(9, 4), GPIO_INPUT | GPIO_PULL_UP) @@ -120,7 +120,8 @@ ALTERNATE(PIN_MASK(D, 0x04), 0, MODULE_GPIO, 0) /* GPIOD2 */ /* PWM channels */ ALTERNATE(PIN_MASK(8, 0x01), 0, MODULE_PWM, 0) /* GPIO80 PWM3 KBD_BL_PWM */ -ALTERNATE(PIN_MASK(C, 0x08), 0, MODULE_PWM, 0) /* GPIOC3 PWM0 CHARGE_LED1 */ +ALTERNATE(PIN_MASK(B, 0x80), 0, MODULE_PWM, 0) /* GPIOB7 PWM5 CHARGE_LED6 */ +ALTERNATE(PIN_MASK(C, 0x0c), 0, MODULE_PWM, 0) /* GPIOC3,2 PWM0,1 CHARGE_LED1,4 */ ALTERNATE(PIN_MASK(C, 0x10), 0, MODULE_PWM, 0) /* GPIOC4 PWM2 CHARGE_LED2 */ /* I2C alternate functions */ diff --git a/board/atlas/usb_pd_policy.c b/board/atlas/usb_pd_policy.c index 322bd4bb23..a8e98ee5e1 100644 --- a/board/atlas/usb_pd_policy.c +++ b/board/atlas/usb_pd_policy.c @@ -168,7 +168,14 @@ int pd_check_vconn_swap(int port) void pd_execute_data_swap(int port, int data_role) { - /* Do nothing */ + /* Only port 0 supports device mode. */ + if (port != 0) + return; + + gpio_set_level(GPIO_USB2_ID, + (data_role == PD_ROLE_UFP) ? 1 : 0); + gpio_set_level(GPIO_USB2_VBUSSENSE, + (data_role == PD_ROLE_UFP) ? 1 : 0); } void pd_check_pr_role(int port, int pr_role, int flags) @@ -332,14 +339,6 @@ static int svdm_dp_config(int port, uint32_t *payload) return 2; }; -/* - * timestamp of the next possible toggle to ensure the 2-ms spacing - * between IRQ_HPD. - */ -static uint64_t hpd_deadline[CONFIG_USB_PD_PORT_COUNT]; - -#define PORT_TO_HPD(port) ((port) ? GPIO_USB_C1_DP_HPD : GPIO_USB_C0_DP_HPD) - static void svdm_dp_post_config(int port) { const struct usb_mux *mux = &usb_muxes[port]; @@ -348,23 +347,15 @@ static void svdm_dp_post_config(int port) if (!(dp_flags[port] & DP_FLAGS_HPD_HI_PENDING)) return; - gpio_set_level(PORT_TO_HPD(port), 1); - - /* set the minimum time delay (2ms) for the next HPD IRQ */ - hpd_deadline[port] = get_time().val + HPD_USTREAM_DEBOUNCE_LVL; - mux->hpd_update(port, 1, 0); } static int svdm_dp_attention(int port, uint32_t *payload) { - int cur_lvl; int lvl = PD_VDO_DPSTS_HPD_LVL(payload[1]); int irq = PD_VDO_DPSTS_HPD_IRQ(payload[1]); - enum gpio_signal hpd = PORT_TO_HPD(port); const struct usb_mux *mux = &usb_muxes[port]; - cur_lvl = gpio_get_level(hpd); dp_status[port] = payload[1]; /* Its initial DP status message prior to config */ @@ -373,29 +364,8 @@ static int svdm_dp_attention(int port, uint32_t *payload) dp_flags[port] |= DP_FLAGS_HPD_HI_PENDING; return 1; } - - if (irq & cur_lvl) { - uint64_t now = get_time().val; - /* wait for the minimum spacing between IRQ_HPD if needed */ - if (now < hpd_deadline[port]) - usleep(hpd_deadline[port] - now); - - /* generate IRQ_HPD pulse */ - gpio_set_level(hpd, 0); - usleep(HPD_DSTREAM_DEBOUNCE_IRQ); - gpio_set_level(hpd, 1); - - /* set the minimum time delay (2ms) for the next HPD IRQ */ - hpd_deadline[port] = get_time().val + HPD_USTREAM_DEBOUNCE_LVL; - } else if (irq & !cur_lvl) { - CPRINTF("ERR:HPD:IRQ&LOW\n"); - return 0; /* nak */ - } else { - gpio_set_level(hpd, lvl); - /* set the minimum time delay (2ms) for the next HPD IRQ */ - hpd_deadline[port] = get_time().val + HPD_USTREAM_DEBOUNCE_LVL; - } mux->hpd_update(port, lvl, irq); + /* ack */ return 1; } @@ -405,7 +375,6 @@ static void svdm_exit_dp_mode(int port) const struct usb_mux *mux = &usb_muxes[port]; svdm_safe_dp_mode(port); - gpio_set_level(PORT_TO_HPD(port), 0); mux->hpd_update(port, 0, 0); } |