summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--board/cr50/ec_comm.c23
-rw-r--r--board/cr50/ec_comm.h6
-rw-r--r--board/cr50/rdd.c23
3 files changed, 48 insertions, 4 deletions
diff --git a/board/cr50/ec_comm.c b/board/cr50/ec_comm.c
index d9b01c92e2..c4a3603c82 100644
--- a/board/cr50/ec_comm.c
+++ b/board/cr50/ec_comm.c
@@ -73,3 +73,26 @@ int ec_comm_is_uart_in_packet_mode(int uart)
{
return uart == ec_comm_ctx.uart;
}
+
+void ec_comm_block(int block)
+{
+ static int is_blocked;
+
+ if (is_blocked == block)
+ return;
+
+ if (block) {
+ gpio_disable_interrupt(GPIO_EC_PACKET_MODE_EN);
+ gpio_disable_interrupt(GPIO_EC_PACKET_MODE_DIS);
+
+ if (ec_comm_is_uart_in_packet_mode(UART_EC))
+ ec_comm_packet_mode_dis(GPIO_EC_PACKET_MODE_DIS);
+ } else {
+ gpio_enable_interrupt(GPIO_EC_PACKET_MODE_EN);
+ gpio_enable_interrupt(GPIO_EC_PACKET_MODE_DIS);
+ }
+
+ is_blocked = block;
+
+ /* Note: ccd_update_state() should be called to change UART status. */
+}
diff --git a/board/cr50/ec_comm.h b/board/cr50/ec_comm.h
index 37732e69c2..9e84a715e1 100644
--- a/board/cr50/ec_comm.h
+++ b/board/cr50/ec_comm.h
@@ -24,6 +24,12 @@ int ec_comm_is_uart_in_packet_mode(int uart);
* 0 otherwise.
*/
int ec_comm_process_packet(uint8_t ch);
+/*
+ * Block or unblock EC-CR50 communication.
+ * @param block non-zero value blocks EC-CR50 communication.
+ * Zero value unblocks it.
+ */
+void ec_comm_block(int block);
/* Reset EC EFS context */
void ec_efs_reset(void);
/* Set EC-EFS boot_mode */
diff --git a/board/cr50/rdd.c b/board/cr50/rdd.c
index 2e5ccc7e81..228f076831 100644
--- a/board/cr50/rdd.c
+++ b/board/cr50/rdd.c
@@ -56,7 +56,13 @@ enum ccd_block_flags {
* uart while servo is connected, it could break the hardware and the
* ccd uart could become permanently unusable.
*/
- CCD_BLOCK_IGNORE_SERVO = BIT(3)
+ CCD_BLOCK_IGNORE_SERVO = BIT(3),
+
+ /*
+ * This will block EC-CR50-communication. CR50 should not enable EC
+ * UART.
+ */
+ CCD_BLOCK_EC_CR50_COMM = BIT(4)
};
/* Which UARTs are blocked by console command */
@@ -300,9 +306,11 @@ static void ccd_state_change_hook(void)
/*
* EC UART flags are cleared if ccd ext is not detected or if ccd block
* EC UART is enabled. EC-CR50 comm trumps both of those conditions.
- * Re-enable the EC UART flags if EC-CR50 comm is enabled.
+ * Re-enable the EC UART flags if EC-CR50 comm is enabled and
+ * CCD_BLOCK_EC_CR50_COMM must be off in ccd_block bitmap.
*/
- if (ec_comm_is_uart_in_packet_mode(UART_EC))
+ if (ec_comm_is_uart_in_packet_mode(UART_EC) &&
+ !(ccd_block & CCD_BLOCK_EC_CR50_COMM))
flags_want |= (CCD_ENABLE_UART_EC | CCD_ENABLE_UART_EC_TX);
/*
@@ -442,6 +450,8 @@ static void print_ccd_ports_blocked(void)
ccputs("\nWARNING: enabling UART while servo is connected may "
"damage hardware");
}
+ if (ccd_block & CCD_BLOCK_EC_CR50_COMM)
+ ccputs(" EC_CR50_COMM");
if (!ccd_block)
ccputs(" (none)");
ccputs("\n");
@@ -484,6 +494,8 @@ static int command_ccd_block(int argc, char **argv)
block_flag = CCD_BLOCK_SERVO_SHARED;
else if (!strcasecmp(argv[1], "IGNORE_SERVO"))
block_flag = CCD_BLOCK_IGNORE_SERVO;
+ else if (!strcasecmp(argv[1], "EC_CR50_COMM"))
+ block_flag = CCD_BLOCK_EC_CR50_COMM;
else
return EC_ERROR_PARAM1;
@@ -497,6 +509,8 @@ static int command_ccd_block(int argc, char **argv)
if (block_flag == CCD_BLOCK_IGNORE_SERVO)
servo_ignore(new_state);
+ else if (block_flag == CCD_BLOCK_EC_CR50_COMM)
+ ec_comm_block(new_state);
/* Update blocked state in deferred function */
ccd_update_state();
@@ -507,5 +521,6 @@ static int command_ccd_block(int argc, char **argv)
return EC_SUCCESS;
}
DECLARE_CONSOLE_COMMAND(ccdblock, command_ccd_block,
- "[<AP | EC | SERVO | IGNORE_SERVO> [BOOLEAN]]",
+ "[<AP | EC | SERVO | IGNORE_SERVO | EC_CR50_COMM>"
+ " [BOOLEAN]]",
"Force CCD ports disabled");