diff options
Diffstat (limited to 'chip/g')
-rw-r--r-- | chip/g/rdd.c | 36 | ||||
-rw-r--r-- | chip/g/rdd.h | 14 |
2 files changed, 29 insertions, 21 deletions
diff --git a/chip/g/rdd.c b/chip/g/rdd.c index 63df750484..59a27ee475 100644 --- a/chip/g/rdd.c +++ b/chip/g/rdd.c @@ -7,16 +7,14 @@ #include "console.h" #include "gpio.h" #include "hooks.h" +#include "rdd.h" #include "registers.h" #include "task.h" #include "usb_api.h" -#define CCD_PHY USB_SEL_PHY1 -#define AP_PHY USB_SEL_PHY0 +static uint16_t debug_detect; -uint16_t ccd_detect; - -static int debug_cable_is_detected(void) +int debug_cable_is_attached(void) { uint8_t cc1 = GREAD_FIELD(RDD, INPUT_PIN_VALUES, CC1); uint8_t cc2 = GREAD_FIELD(RDD, INPUT_PIN_VALUES, CC2); @@ -26,25 +24,18 @@ static int debug_cable_is_detected(void) void rdd_interrupt(void) { - if (debug_cable_is_detected()) { + if (debug_cable_is_attached()) { ccprintf("Debug Accessory connected\n"); /* Detect when debug cable is disconnected */ - GWRITE(RDD, PROG_DEBUG_STATE_MAP, ~ccd_detect); - - /* Select the CCD PHY */ - usb_select_phy(CCD_PHY); + GWRITE(RDD, PROG_DEBUG_STATE_MAP, ~debug_detect); + rdd_attached(); } else { ccprintf("Debug Accessory disconnected\n"); /* Detect when debug cable is connected */ - GWRITE(RDD, PROG_DEBUG_STATE_MAP, ccd_detect); - - /* Select the AP PHY */ - usb_select_phy(AP_PHY); + GWRITE(RDD, PROG_DEBUG_STATE_MAP, debug_detect); + rdd_detached(); } - /* Connect to selected phy */ - usb_init(); - /* Clear interrupt */ GWRITE_FIELD(RDD, INT_STATE, INTR_DEBUG_STATE_DETECTED, 1); } @@ -56,10 +47,13 @@ void rdd_init(void) clock_enable_module(MODULE_RDD, 1); GWRITE(RDD, POWER_DOWN_B, 1); - ccd_detect = GREAD(RDD, PROG_DEBUG_STATE_MAP); - /* Detect cable disconnect if CCD is enabled */ - if (usb_get_phy() == CCD_PHY) - GWRITE(RDD, PROG_DEBUG_STATE_MAP, ~ccd_detect); + 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(); + } /* Enable RDD interrupts */ task_enable_irq(GC_IRQNUM_RDD0_INTR_DEBUG_STATE_DETECTED_INT); diff --git a/chip/g/rdd.h b/chip/g/rdd.h new file mode 100644 index 0000000000..53dd687a16 --- /dev/null +++ b/chip/g/rdd.h @@ -0,0 +1,14 @@ +/* Copyright 2016 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef __CROS_RDD_H +#define __CROS_RDD_H + +/* Detach from debug cable */ +void rdd_detached(void); + +/* Attach to debug cable */ +void rdd_attached(void); +#endif /* __CROS_RDD_H */ |