diff --git a/board/cr50/board.c b/board/cr50/board.c index 008e9372b0..fec01fc506 100644 --- a/board/cr50/board.c +++ b/board/cr50/board.c @@ -522,7 +522,7 @@ void board_update_device_state(enum device_type device) } } -static void detect_slave_config(void) +void system_init_board_properties(void) { uint32_t properties; @@ -542,6 +542,12 @@ static void detect_slave_config(void) properties |= BOARD_SLAVE_CONFIG_I2C; /* One PHY is connected to the AP */ properties |= BOARD_USB_AP; + /* + * TODO(crosbug.com/p/56540): enable UART0 RX on Reef. + * Early reef boards dont have the necessary pullups on + * UART0RX so disable it until that is fixed. + */ + properties |= BOARD_DISABLE_UART0_RX; } /* @@ -559,8 +565,6 @@ static void detect_slave_config(void) /* Save this configuration setting */ board_properties = properties; } -/* Need this hook to run before the default hook level */ -DECLARE_HOOK(HOOK_INIT, detect_slave_config, HOOK_PRIO_DEFAULT - 1); uint32_t system_board_properties_callback(void) { diff --git a/board/cr50/gpio.inc b/board/cr50/gpio.inc index 8ff1da7b83..235a21b116 100644 --- a/board/cr50/gpio.inc +++ b/board/cr50/gpio.inc @@ -81,15 +81,7 @@ PINMUX(GPIO(STRAP0), A1, DIO_INPUT) /* UARTs */ PINMUX(FUNC(UART0_TX), A0, DIO_OUTPUT) /* Cr50 console */ -/* PINMUX(FUNC(UART0_RX), A13, DIO_INPUT | DIO_WAKE_LOW) */ -/* - * TODO(crosbug.com/p/56540): Enable UART0_RX when possible. - * At the moment, UART0_RX should only be used for debugging purposes. - * If there is no external pull up on DIOA13, Cr50 can get continual UART0_RX - * interrupts and will constantly reboot. Not all boards have that pullup. - * UART0_RX = DIOA13 - */ - +PINMUX(FUNC(UART0_RX), A13, DIO_INPUT | DIO_WAKE_FALLING) /* * UART1_TX and UART2_TX are configured in usart.c. They are not set as outputs * here in order to avoid interfering with servo. They can be controlled using diff --git a/chip/g/system.c b/chip/g/system.c index 075068e7ba..323c258ea8 100644 --- a/chip/g/system.c +++ b/chip/g/system.c @@ -81,6 +81,10 @@ void system_pre_init(void) * no effect. */ GREG32(GLOBALSEC, FLASH_REGION0_CTRL_CFG_EN) = 0; + +#ifdef BOARD_CR50 + system_init_board_properties(); +#endif } void system_reset(int flags) diff --git a/chip/g/uartn.c b/chip/g/uartn.c index dc95f1fbf0..c534705eb3 100644 --- a/chip/g/uartn.c +++ b/chip/g/uartn.c @@ -119,13 +119,12 @@ void uartn_enable(int uart) GR_UART_CTRL(uart) = 0x01; /* TODO(crosbug.com/p/56540): Remove this when UART0_RX works everywhere */ -#ifdef GC_UART0_RX_DISABLE - if (!uart) +#if defined(BOARD_CR50) && !defined(SECTION_IS_RO) + if (!uart && (system_get_board_properties() & BOARD_DISABLE_UART0_RX)) return; #endif - /* Enable UART RX if it is connected to an external pad */ - if (DIO_SEL_REG(GC_PINMUX_UART0_RX_SEL_OFFSET + (uart * 16))) - GR_UART_CTRL(uart) |= 0x02; + + GR_UART_CTRL(uart) |= 0x02; } /* Disable TX, RX, HW flow control, and loopback */ diff --git a/include/system.h b/include/system.h index 4b558cade8..d8d10950ce 100644 --- a/include/system.h +++ b/include/system.h @@ -467,6 +467,7 @@ int system_process_retry_counter(void); #define BOARD_SLAVE_CONFIG_I2C (1 << 1) /* Slave I2C interface */ #define BOARD_USB_AP (1 << 2) /* One of the PHYs is */ /* connected to the AP */ +#define BOARD_DISABLE_UART0_RX (1 << 3) /* Disable UART0 RX */ /** * Get board properites * @@ -475,6 +476,9 @@ int system_process_retry_counter(void); */ uint32_t system_get_board_properties(void); +/* Board specific function used to initialize the system board properties. */ +void system_init_board_properties(void); + /** * API for board specific version of system_get_board_properties *