From c5dd305dffe25c6fa85e7201a4be19a835601f38 Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Wed, 27 Apr 2016 22:08:02 -0700 Subject: [PATCH] Cr50: Move board-specific rdd stuff out of chip/g/ Poking GPIOs is something that belongs in board/ not chip/ BUG=none BRANCH=none TEST=make buildall; test on Kevin Change-Id: I798053c3760415ed787800d37eb81c765b826399 Signed-off-by: Bill Richardson Reviewed-on: https://chromium-review.googlesource.com/341065 Reviewed-by: Mary Ruthven --- board/cr50/rdd.c | 13 +++++++------ chip/g/rdd.c | 9 +++------ chip/g/usb.c | 2 +- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/board/cr50/rdd.c b/board/cr50/rdd.c index 66f6c8c313..ed30094bf3 100644 --- a/board/cr50/rdd.c +++ b/board/cr50/rdd.c @@ -4,6 +4,7 @@ */ #include "console.h" +#include "gpio.h" #include "rdd.h" #include "registers.h" #include "usb_api.h" @@ -22,11 +23,11 @@ static void usart_tx_disconnect(void) void rdd_attached(void) { + /* Indicate case-closed debug mode (active low) */ + gpio_set_level(GPIO_CCD_MODE_L, 0); + /* Select the CCD PHY */ usb_select_phy(USB_SEL_PHY1); - - /* Connect to selected phy */ - usb_init(); } void rdd_detached(void) @@ -34,11 +35,11 @@ void rdd_detached(void) /* Disconnect from AP and EC UART TX */ usart_tx_disconnect(); + /* Done with case-closed debug mode */ + gpio_set_level(GPIO_CCD_MODE_L, 1); + /* Select the AP PHY */ usb_select_phy(USB_SEL_PHY0); - - /* Connect to selected phy */ - usb_init(); } static int command_uart(int argc, char **argv) diff --git a/chip/g/rdd.c b/chip/g/rdd.c index 59a27ee475..129299f91b 100644 --- a/chip/g/rdd.c +++ b/chip/g/rdd.c @@ -5,7 +5,6 @@ #include "clock.h" #include "console.h" -#include "gpio.h" #include "hooks.h" #include "rdd.h" #include "registers.h" @@ -49,11 +48,9 @@ void rdd_init(void) debug_detect = GREAD(RDD, PROG_DEBUG_STATE_MAP); - /* If cable is attached, detect when it is disconnected */ - if (debug_cable_is_attached()) { - GWRITE(RDD, PROG_DEBUG_STATE_MAP, ~debug_detect); - rdd_attached(); - } + /* Invoke the interrupt handler manually so that the board-specific + * callbacks can process the initial state. */ + rdd_interrupt(); /* Enable RDD interrupts */ task_enable_irq(GC_IRQNUM_RDD0_INTR_DEBUG_STATE_DETECTED_INT); diff --git a/chip/g/usb.c b/chip/g/usb.c index 4501aa6496..b5e036d60b 100644 --- a/chip/g/usb.c +++ b/chip/g/usb.c @@ -320,6 +320,7 @@ void usb_select_phy(uint32_t phy) which_phy = phy; GR_USB_GGPIO = GGPIO_WRITE(USB_CUSTOM_CFG_REG, (USB_PHY_ACTIVE | which_phy)); + CPRINTS("USB PHY %c", which_phy == USB_SEL_PHY0 ? 'A' : 'B'); } uint32_t usb_get_phy(void) @@ -1244,7 +1245,6 @@ void usb_init(void) /* Select the correct PHY */ usb_select_phy(which_phy); - gpio_set_level(GPIO_CCD_MODE_L, !(which_phy == USB_SEL_PHY1)); /* Full-Speed Serial PHY */ GR_USB_GUSBCFG = GUSBCFG_PHYSEL_FS | GUSBCFG_FSINTF_6PIN