diff options
author | Kevin K Wong <kevin.k.wong@intel.com> | 2016-04-15 12:45:19 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-05-24 15:46:01 -0700 |
commit | f4e617e11866c4ce353d42f8c83331017fbf7eb2 (patch) | |
tree | 7e0aa61ac26078a91cc8da8e946270c2452d4e6e | |
parent | f63124791dfe3f166ef99ae0e4ae477b1176abcc (diff) | |
download | chrome-ec-f4e617e11866c4ce353d42f8c83331017fbf7eb2.tar.gz |
amenia: enable tcpc support for amenia 1.2
added Analogix AXN7428 and ParadeTech PS8751
note: hdp support is wip
BUG=none
BRANCH=none
TEST=make buildall
Change-Id: I4ff1a2ad03da8e625e869482102d6c3a1ca2aa50
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/341535
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
-rw-r--r-- | board/amenia/board.c | 30 | ||||
-rw-r--r-- | board/amenia/board.h | 8 | ||||
-rw-r--r-- | board/amenia/usb_pd_policy.c | 79 |
3 files changed, 28 insertions, 89 deletions
diff --git a/board/amenia/board.c b/board/amenia/board.c index a64ab089fd..402ae5519c 100644 --- a/board/amenia/board.c +++ b/board/amenia/board.c @@ -18,6 +18,7 @@ #include "driver/accel_kx022.h" #include "driver/accelgyro_bmi160.h" #include "driver/charger/bd99955.h" +#include "driver/tcpm/anx74xx.h" #include "driver/tcpm/tcpci.h" #include "driver/temp_sensor/g78x.h" #include "extpower.h" @@ -45,8 +46,8 @@ #include "usb_pd_tcpm.h" #include "util.h" -#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args) -#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ## args) +#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ## args) +#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ## args) #if 1 /* TODO: CHARGER / BC1.2 */ static void update_vbus_supplier(int port, int vbus_level) @@ -89,7 +90,6 @@ uint16_t tcpc_get_alert_status(void) { uint16_t status = 0; -#if 0 /* TODO: TCPC */ if (gpio_get_level(GPIO_USB_C0_PD_INT)) if (gpio_get_level(GPIO_USB_C0_RST_L)) status |= PD_STATUS_TCPC_ALERT_0; @@ -97,19 +97,24 @@ uint16_t tcpc_get_alert_status(void) if (!gpio_get_level(GPIO_USB_C1_PD_INT_L)) if (gpio_get_level(GPIO_USB_C1_RST_L)) status |= PD_STATUS_TCPC_ALERT_1; -#endif return status; } static void tcpc_alert_event(enum gpio_signal signal) { -#if 0 /* TODO: TCPC */ + if ((signal == GPIO_USB_C0_PD_INT) && + (!gpio_get_level(GPIO_USB_C0_RST_L))) + return; + + if ((signal == GPIO_USB_C1_PD_INT_L) && + (!gpio_get_level(GPIO_USB_C1_RST_L))) + return; + #ifdef HAS_TASK_PDCMD /* Exchange status with PD MCU to determine interrupt cause */ host_command_pd_send_status(0); #endif -#endif } void vbus0_evt(enum gpio_signal signal) @@ -134,6 +139,10 @@ void vbus1_evt(enum gpio_signal signal) task_wake(TASK_ID_PD_C1); } +void board_set_tcpc_power_mode(int port, int normal_mode) +{ +} + /* * enable_input_devices() is called by the tablet_mode ISR, but changes the * state of GPIOs, so its definition must reside after including gpio_list. @@ -185,7 +194,7 @@ const struct i2c_port_t i2c_ports[] = { const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { - {I2C_PORT_TCPC0, TCPC0_I2C_ADDR, &tcpci_tcpm_drv}, + {I2C_PORT_TCPC0, TCPC0_I2C_ADDR, &anx74xx_tcpm_drv}, {I2C_PORT_TCPC1, TCPC1_I2C_ADDR, &tcpci_tcpm_drv}, }; @@ -201,10 +210,10 @@ const int hibernate_wake_pins_used = ARRAY_SIZE(hibernate_wake_pins); struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { { .port_addr = 0, - .driver = &tcpci_tcpm_usb_mux_driver, + .driver = &anx74xx_tcpm_usb_mux_driver, }, { - .port_addr = 0, + .port_addr = 1, .driver = &tcpci_tcpm_usb_mux_driver, } }; @@ -244,7 +253,6 @@ void board_tcpc_init(void) if (!system_jumped_to_this_image()) board_reset_pd_mcu(); -#if 0 /* TODO: TCPC */ /* Enable TCPC0 interrupt */ gpio_enable_interrupt(GPIO_USB_C0_PD_INT); gpio_enable_interrupt(GPIO_USB_C0_VBUS_WAKE_L); @@ -252,7 +260,6 @@ void board_tcpc_init(void) /* Enable TCPC1 interrupt */ gpio_enable_interrupt(GPIO_USB_C1_PD_INT_L); gpio_enable_interrupt(GPIO_USB_C1_VBUS_WAKE_L); -#endif } DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C+1); @@ -413,7 +420,6 @@ void board_hibernate_late(void) /* Turn off LEDs in hibernate */ {GPIO_BAT_LED_BLUE, GPIO_INPUT | GPIO_PULL_UP}, {GPIO_BAT_LED_AMBER, GPIO_INPUT | GPIO_PULL_UP}, - /* * In hibernate, this pin connected to GND. Set it to output * low to eliminate the current caused by internal pull-up. diff --git a/board/amenia/board.h b/board/amenia/board.h index 4d4b76bcd3..368e7b0b2e 100644 --- a/board/amenia/board.h +++ b/board/amenia/board.h @@ -78,9 +78,11 @@ #define CONFIG_USB_PD_LOGGING #define CONFIG_USB_PD_LOG_SIZE 512 #define CONFIG_USB_PD_PORT_COUNT 2 +#define CONFIG_USB_PD_TCPM_ANX74XX +#define TCPC0_I2C_ADDR 0x50 +#define ANX74XX_INT_ACTIVE_POLARITY ANX74XX_REG_IRQ_POL_HIGH #define CONFIG_USB_PD_TCPM_TCPCI -#define TCPC0_I2C_ADDR CONFIG_TCPC_I2C_BASE_ADDR -#define TCPC1_I2C_ADDR (CONFIG_TCPC_I2C_BASE_ADDR + 2) +#define TCPC1_I2C_ADDR 0x16 #define CONFIG_USB_PD_TCPM_MUX #define CONFIG_USB_PD_TRY_SRC #define CONFIG_USB_PORT_POWER_SMART @@ -215,6 +217,8 @@ enum sensor_id { /* Reset PD MCU */ void board_reset_pd_mcu(void); +void board_set_tcpc_power_mode(int port, int normal_mode); + #endif /* !__ASSEMBLER__ */ #endif /* __CROS_EC_BOARD_H */ diff --git a/board/amenia/usb_pd_policy.c b/board/amenia/usb_pd_policy.c index f4fce34590..e2355d93d2 100644 --- a/board/amenia/usb_pd_policy.c +++ b/board/amenia/usb_pd_policy.c @@ -228,16 +228,12 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, #ifdef CONFIG_USB_PD_ALT_MODE_DFP static int dp_flags[CONFIG_USB_PD_PORT_COUNT]; -/* DP Status VDM as returned by UFP */ -static uint32_t dp_status[CONFIG_USB_PD_PORT_COUNT]; static void svdm_safe_dp_mode(int port) { /* make DP interface safe until configure */ dp_flags[port] = 0; - dp_status[port] = 0; - usb_mux_set(port, TYPEC_MUX_NONE, - USB_SWITCH_CONNECT, pd_get_polarity(port)); + /* board_set_usb_mux(port, TYPEC_MUX_NONE, pd_get_polarity(port)); */ } static int svdm_enter_dp_mode(int port, uint32_t mode_caps) @@ -271,87 +267,24 @@ static int svdm_dp_status(int port, uint32_t *payload) static int svdm_dp_config(int port, uint32_t *payload) { int opos = pd_alt_mode(port, USB_SID_DISPLAYPORT); - int mf_pref = PD_VDO_DPSTS_MF_PREF(dp_status[port]); - int pin_mode = pd_dfp_dp_get_pin_mode(port, dp_status[port]); - - if (!pin_mode) - return 0; - - usb_mux_set(port, mf_pref ? TYPEC_MUX_DOCK : TYPEC_MUX_DP, - USB_SWITCH_CONNECT, pd_get_polarity(port)); - + /* board_set_usb_mux(port, TYPEC_MUX_DP, pd_get_polarity(port)); */ payload[0] = VDO(USB_SID_DISPLAYPORT, 1, CMD_DP_CONFIG | VDO_OPOS(opos)); - payload[1] = VDO_DP_CFG(pin_mode, /* pin mode */ + payload[1] = VDO_DP_CFG(MODE_DP_PIN_E, /* pin mode */ 1, /* DPv1.3 signaling */ 2); /* UFP connected */ return 2; }; -#define PORT_TO_HPD(port) ((port) ? GPIO_USB_C1_DP_HPD : GPIO_USB_C0_DP_HPD) static void svdm_dp_post_config(int port) { dp_flags[port] |= DP_FLAGS_DP_ON; if (!(dp_flags[port] & DP_FLAGS_HPD_HI_PENDING)) return; - -/* TODO: TCPC HPD */ -#if 0 - gpio_set_level(PORT_TO_HPD(port), 1); -#endif } -/* TODO: TCPC HPD */ -#if 0 -static void hpd0_irq_deferred(void) -{ - gpio_set_level(GPIO_USB_C0_DP_HPD, 1); -} - -static void hpd1_irq_deferred(void) -{ - gpio_set_level(GPIO_USB_C1_DP_HPD, 1); -} - -DECLARE_DEFERRED(hpd0_irq_deferred); -DECLARE_DEFERRED(hpd1_irq_deferred); -#define PORT_TO_HPD_IRQ_DEFERRED(port) ((port) ? \ - &hpd1_irq_deferred_data : \ - &hpd0_irq_deferred_data) -#endif - static int svdm_dp_attention(int port, uint32_t *payload) { -/* TODO: TCPC HPD */ -#if 0 - 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); - - cur_lvl = gpio_get_level(hpd); - - dp_status[port] = payload[1]; - - /* Its initial DP status message prior to config */ - if (!(dp_flags[port] & DP_FLAGS_DP_ON)) { - if (lvl) - dp_flags[port] |= DP_FLAGS_HPD_HI_PENDING; - return 1; - } - - if (irq & cur_lvl) { - gpio_set_level(hpd, 0); - hook_call_deferred(PORT_TO_HPD_IRQ_DEFERRED(port), - HPD_DSTREAM_DEBOUNCE_IRQ); - } else if (irq & !cur_lvl) { - CPRINTF("ERR:HPD:IRQ&LOW\n"); - return 0; /* nak */ - } else { - gpio_set_level(hpd, lvl); - } -#endif - /* ack */ return 1; } @@ -359,11 +292,7 @@ static int svdm_dp_attention(int port, uint32_t *payload) static void svdm_exit_dp_mode(int port) { svdm_safe_dp_mode(port); - -/* TODO: TCPC HPD */ -#if 0 - gpio_set_level(PORT_TO_HPD(port), 0); -#endif + /* gpio_set_level(PORT_TO_HPD(port), 0); */ } static int svdm_enter_gfu_mode(int port, uint32_t mode_caps) |