diff options
Diffstat (limited to 'common/case_closed_debug.c')
-rw-r--r-- | common/case_closed_debug.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/common/case_closed_debug.c b/common/case_closed_debug.c new file mode 100644 index 0000000000..08e5e8411d --- /dev/null +++ b/common/case_closed_debug.c @@ -0,0 +1,39 @@ +/* Copyright (c) 2014 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. + * + * Case Closed Debug common implementation + */ + +#include "case_closed_debug.h" + +#include "common.h" +#include "usb_api.h" + +#if !defined(CONFIG_USB_INHIBIT_INIT) +#error "CONFIG_USB_INHIBIT_INIT must be defined to use Case Closed Debugging" +#endif + +#if !defined(CONFIG_USB) +#error "CONFIG_USB must be defined to use Case Closed Debugging" +#endif + +static enum ccd_mode current_mode = CCD_MODE_DISABLED; + +void ccd_set_mode(enum ccd_mode new_mode) +{ + if (new_mode == current_mode) + return; + + if (current_mode != CCD_MODE_DISABLED) { + usb_release(); + ccd_board_disconnect(); + } + + current_mode = new_mode; + + if (new_mode != CCD_MODE_DISABLED) { + ccd_board_connect(); + usb_init(); + } +} |