mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-10 17:41:54 +00:00
update case closed debugging partial mode policy
When a debug accessory is connected to the type-C port while the write protection is enabled, put the case closed debugging in "partial" mode rather than "full". Update the "partial" mode to provide read-only access to the AP and EC consoles. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=smaug BUG=chrome-os-partner:44700 TEST=check the EC console input/output over USB is still working with SuzyQ on a write-protected system, verify that the console input is disabled. Change-Id: I5baa03d6e738d06437c45469f46b286e76a755a4 Reviewed-on: https://chromium-review.googlesource.com/297141 Commit-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Anton Staaf <robotboy@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org>
This commit is contained in:
committed by
chrome-bot
parent
15fcbc9596
commit
96093145cb
@@ -30,6 +30,7 @@
|
||||
#include "queue_policies.h"
|
||||
#include "registers.h"
|
||||
#include "spi.h"
|
||||
#include "system.h"
|
||||
#include "task.h"
|
||||
#include "usb.h"
|
||||
#include "usb_charge.h"
|
||||
@@ -144,6 +145,9 @@ static void board_init(void)
|
||||
queue_init(&ap_usart_to_usb);
|
||||
queue_init(&ap_usb_to_usart);
|
||||
usart_init(&ap_usart);
|
||||
/* Disable UART input when the Write Protect is enabled */
|
||||
if (system_is_locked())
|
||||
ap_usb.state->rx_disabled = 1;
|
||||
|
||||
/*
|
||||
* Enable CC lines after all GPIO have been initialized. Note, it is
|
||||
|
||||
@@ -255,7 +255,8 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload,
|
||||
#endif /* CONFIG_USB_PD_LOGGING */
|
||||
#ifdef CONFIG_CASE_CLOSED_DEBUG
|
||||
case VDO_CMD_CCD_EN:
|
||||
ccd_set_mode(CCD_MODE_ENABLED);
|
||||
ccd_set_mode(system_is_locked() ? CCD_MODE_PARTIAL
|
||||
: CCD_MODE_ENABLED);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ static int last_tx_ok = 1;
|
||||
|
||||
static int is_reset;
|
||||
static int is_enabled = 1;
|
||||
static int is_readonly;
|
||||
|
||||
/* USB-Serial descriptors */
|
||||
const struct usb_interface_descriptor USB_IFACE_DESC(USB_IFACE_CONSOLE) =
|
||||
@@ -76,7 +77,7 @@ static void con_ep_tx(void)
|
||||
static void con_ep_rx(void)
|
||||
{
|
||||
int i;
|
||||
int rx_size = USB_MAX_PACKET_SIZE
|
||||
int rx_size = is_readonly ? 0 : USB_MAX_PACKET_SIZE
|
||||
- (ep_out_desc.flags & DOEPDMA_RXBYTES_MASK);
|
||||
|
||||
for (i = 0; i < rx_size; i++) {
|
||||
@@ -94,7 +95,8 @@ static void con_ep_rx(void)
|
||||
GR_USB_DOEPINT(USB_EP_CONSOLE) = 0xffffffff;
|
||||
|
||||
/* wake-up the console task */
|
||||
console_has_input();
|
||||
if (!is_readonly)
|
||||
console_has_input();
|
||||
}
|
||||
|
||||
static void ep_reset(void)
|
||||
@@ -254,7 +256,8 @@ int usb_vprintf(const char *format, va_list args)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void usb_console_enable(int enabled)
|
||||
void usb_console_enable(int enabled, int readonly)
|
||||
{
|
||||
is_enabled = enabled;
|
||||
is_readonly = readonly;
|
||||
}
|
||||
|
||||
@@ -56,6 +56,11 @@ static int rx_valid(struct usb_stream_config const *config)
|
||||
return (STM32_USB_EP(config->endpoint) & EP_RX_MASK) == EP_RX_VALID;
|
||||
}
|
||||
|
||||
static int rx_disabled(struct usb_stream_config const *config)
|
||||
{
|
||||
return config->state->rx_disabled;
|
||||
}
|
||||
|
||||
static void usb_read(struct producer const *producer, size_t count)
|
||||
{
|
||||
struct usb_stream_config const *config =
|
||||
@@ -95,7 +100,7 @@ void usb_stream_deferred(struct usb_stream_config const *config)
|
||||
if (!tx_valid(config) && tx_write(config))
|
||||
STM32_TOGGLE_EP(config->endpoint, EP_TX_MASK, EP_TX_VALID, 0);
|
||||
|
||||
if (!rx_valid(config) && rx_read(config))
|
||||
if (!rx_valid(config) && !rx_disabled(config) && rx_read(config))
|
||||
STM32_TOGGLE_EP(config->endpoint, EP_RX_MASK, EP_RX_VALID, 0);
|
||||
}
|
||||
|
||||
@@ -136,5 +141,5 @@ void usb_stream_reset(struct usb_stream_config const *config)
|
||||
STM32_USB_EP(i) = ((i << 0) | /* Endpoint Addr*/
|
||||
(2 << 4) | /* TX NAK */
|
||||
(0 << 9) | /* Bulk EP */
|
||||
(3 << 12)); /* RX VALID */
|
||||
(rx_disabled(config) ? EP_RX_NAK : EP_RX_VALID));
|
||||
}
|
||||
|
||||
@@ -31,6 +31,10 @@ struct usb_stream_state {
|
||||
* restart USB reception by marking the RX buffer as VALID.
|
||||
*/
|
||||
int rx_waiting;
|
||||
/*
|
||||
* Flag indicating that the incoming data on the USB link are discarded.
|
||||
*/
|
||||
int rx_disabled;
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
@@ -29,6 +29,7 @@ static int last_tx_ok = 1;
|
||||
|
||||
static int is_reset;
|
||||
static int is_enabled = 1;
|
||||
static int is_readonly;
|
||||
|
||||
/* USB-Serial descriptors */
|
||||
const struct usb_interface_descriptor USB_IFACE_DESC(USB_IFACE_CONSOLE) = {
|
||||
@@ -100,7 +101,8 @@ static void ep_reset(void)
|
||||
STM32_USB_EP(USB_EP_CONSOLE) = (USB_EP_CONSOLE | /* Endpoint Addr */
|
||||
(2 << 4) | /* TX NAK */
|
||||
(0 << 9) | /* Bulk EP */
|
||||
(3 << 12)); /* RX VALID */
|
||||
(is_readonly ? EP_RX_NAK
|
||||
: EP_RX_VALID));
|
||||
|
||||
is_reset = 1;
|
||||
}
|
||||
@@ -248,7 +250,8 @@ int usb_vprintf(const char *format, va_list args)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void usb_console_enable(int enabled)
|
||||
void usb_console_enable(int enabled, int readonly)
|
||||
{
|
||||
is_enabled = enabled;
|
||||
is_readonly = readonly;
|
||||
}
|
||||
|
||||
@@ -41,10 +41,11 @@ void ccd_set_mode(enum ccd_mode new_mode)
|
||||
current_mode = new_mode;
|
||||
|
||||
/*
|
||||
* Only enable forwarding the local console over USB if we are now in
|
||||
* the fully enabled mode.
|
||||
* The forwarding of the local console over USB is read-only
|
||||
* if we are not in the fully enabled mode.
|
||||
*/
|
||||
usb_console_enable(new_mode == CCD_MODE_ENABLED);
|
||||
usb_console_enable(new_mode != CCD_MODE_DISABLED,
|
||||
new_mode != CCD_MODE_ENABLED);
|
||||
|
||||
#if defined(CONFIG_USB_SPI)
|
||||
usb_spi_enable(&ccd_usb_spi, new_mode == CCD_MODE_ENABLED);
|
||||
|
||||
@@ -1590,7 +1590,9 @@ void pd_task(void)
|
||||
|
||||
#ifdef CONFIG_CASE_CLOSED_DEBUG
|
||||
if (new_cc_state == PD_CC_DEBUG_ACC) {
|
||||
ccd_set_mode(CCD_MODE_ENABLED);
|
||||
ccd_set_mode(system_is_locked() ?
|
||||
CCD_MODE_PARTIAL :
|
||||
CCD_MODE_ENABLED);
|
||||
typec_set_input_current_limit(
|
||||
port, 3000, TYPE_C_VOLTAGE);
|
||||
charge_manager_update_dualrole(
|
||||
|
||||
@@ -50,7 +50,7 @@ int usb_getc(void);
|
||||
* is not accessible until the USB peripheral is also initialized, which can
|
||||
* be delayed.
|
||||
*/
|
||||
void usb_console_enable(int enabled);
|
||||
void usb_console_enable(int enabled, int readonly);
|
||||
|
||||
#define usb_va_start va_start
|
||||
#define usb_va_end va_end
|
||||
|
||||
Reference in New Issue
Block a user