From 65db5f09a86f59fb4ab22f49beb2b2eebc98ee75 Mon Sep 17 00:00:00 2001 From: Chris Frantz Date: Wed, 11 Sep 2024 09:16:14 -0700 Subject: [PATCH] [rom, rom_ext] Enable pull-up on UART_RX Fixes: #24551 Signed-off-by: Chris Frantz (cherry picked from commit 6ca7587f727325e16ad42a380c4be437906ba1dd) --- sw/device/silicon_creator/lib/drivers/pinmux.c | 3 +++ .../silicon_creator/lib/drivers/pinmux_unittest.cc | 14 ++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/sw/device/silicon_creator/lib/drivers/pinmux.c b/sw/device/silicon_creator/lib/drivers/pinmux.c index ed5e11c4f82ec..7aaed1d5291e5 100644 --- a/sw/device/silicon_creator/lib/drivers/pinmux.c +++ b/sw/device/silicon_creator/lib/drivers/pinmux.c @@ -187,6 +187,9 @@ void pinmux_init(void) { configure_input(kInputSwStrap2); } + // Pull the UART_RX line high (idle state for UART). This prevents a + // floating UART_RX from incorrectly triggering serial break. + enable_pull(kInputUart0.pad, /*enable=*/true, /*up=*/true); configure_input(kInputUart0); configure_output(kOutputUart0); } diff --git a/sw/device/silicon_creator/lib/drivers/pinmux_unittest.cc b/sw/device/silicon_creator/lib/drivers/pinmux_unittest.cc index 0cfe5b6528e8b..076099ff01d2c 100644 --- a/sw/device/silicon_creator/lib/drivers/pinmux_unittest.cc +++ b/sw/device/silicon_creator/lib/drivers/pinmux_unittest.cc @@ -100,10 +100,13 @@ TEST_F(InitTest, WithBootstrap) { kTopEarlgreyPinmuxInselIoc1) EXPECT_ABS_WRITE32(RegInSel(kTopEarlgreyPinmuxPeripheralInGpioGpio24), kTopEarlgreyPinmuxInselIoc2) + + // UART configuration: RX line pulled up, RX is IOC3, TX is IOC4. + EXPECT_ABS_WRITE32(RegPadAttr(kTopEarlgreyMuxedPadsIoc3), + {{PINMUX_MIO_PAD_ATTR_0_PULL_EN_0_BIT, 1}, + {PINMUX_MIO_PAD_ATTR_0_PULL_SELECT_0_BIT, 1}}); EXPECT_ABS_WRITE32(RegInSel(kTopEarlgreyPinmuxPeripheralInUart0Rx), kTopEarlgreyPinmuxInselIoc3); - - // The outputs that will be configured. EXPECT_ABS_WRITE32(RegOutSel(kTopEarlgreyPinmuxMioOutIoc4), kTopEarlgreyPinmuxOutselUart0Tx); @@ -115,10 +118,13 @@ TEST_F(InitTest, WithoutBootstrap) { EXPECT_CALL(otp_, read32(OTP_CTRL_PARAM_OWNER_SW_CFG_ROM_BOOTSTRAP_DIS_OFFSET)) .WillOnce(Return(kHardenedBoolTrue)); + + // UART configuration: RX line pulled up, RX is IOC3, TX is IOC4. + EXPECT_ABS_WRITE32(RegPadAttr(kTopEarlgreyMuxedPadsIoc3), + {{PINMUX_MIO_PAD_ATTR_0_PULL_EN_0_BIT, 1}, + {PINMUX_MIO_PAD_ATTR_0_PULL_SELECT_0_BIT, 1}}); EXPECT_ABS_WRITE32(RegInSel(kTopEarlgreyPinmuxPeripheralInUart0Rx), kTopEarlgreyPinmuxInselIoc3); - - // The outputs that will be configured. EXPECT_ABS_WRITE32(RegOutSel(kTopEarlgreyPinmuxMioOutIoc4), kTopEarlgreyPinmuxOutselUart0Tx);