From 29922a540922550b80ba76a821c85eae328899cc Mon Sep 17 00:00:00 2001 From: Marc Jones Date: Thu, 28 Sep 2017 22:37:07 -0600 Subject: soc/amd/stoneyridge: Wait for UART to be ready The Stoney Ridge UART and AMBA devices must be powered and report power and clock OK prior to using the coreboot serial console. The code used to have a delay to wait for the power and clock, but didn't check the OK bits. This caused long delays on a reboot, as each byte would time out until the console was reset again at romstage. This change also removes the UART reset. The device has just been powered and is in reset already. Testing indicates the reset isn't needed. BUG=b:65853981 TEST=Boot to Chrome OS, run the reboot command, verify that the long delay is gone. Change-Id: I410700df5df255d20b8e5d192c72241dd44cf676 Signed-off-by: Marc Jones Reviewed-on: https://review.coreboot.org/21731 Reviewed-by: Aaron Durbin Tested-by: build bot (Jenkins) --- src/soc/amd/stoneyridge/early_setup.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/soc/amd/stoneyridge/early_setup.c b/src/soc/amd/stoneyridge/early_setup.c index 5166a7f5e8..e5f123a151 100644 --- a/src/soc/amd/stoneyridge/early_setup.c +++ b/src/soc/amd/stoneyridge/early_setup.c @@ -23,31 +23,47 @@ #include #include #include -#include #include #include +/* vendor includes */ +#include +#include +#include + void configure_stoneyridge_uart(void) { - u8 byte; + u8 byte, byte2; + /* Power on the UART and AMBA devices */ byte = read8((void *)ACPI_MMIO_BASE + AOAC_BASE + FCH_AOAC_REG56 + CONFIG_UART_FOR_CONSOLE * 2); - byte |= 1 << 3; + byte |= AOAC_PWR_ON_DEV; write8((void *)ACPI_MMIO_BASE + AOAC_BASE + FCH_AOAC_REG56 + CONFIG_UART_FOR_CONSOLE * 2, byte); + byte = read8((void *)ACPI_MMIO_BASE + AOAC_BASE + FCH_AOAC_REG62); - byte |= 1 << 3; + byte |= AOAC_PWR_ON_DEV; write8((void *)ACPI_MMIO_BASE + AOAC_BASE + FCH_AOAC_REG62, byte); + + /* Set the GPIO mux to UART */ write8((void *)FCH_IOMUXx89_UART0_RTS_L_EGPIO137, 0); write8((void *)FCH_IOMUXx8A_UART0_TXD_EGPIO138, 0); write8((void *)FCH_IOMUXx8E_UART1_RTS_L_EGPIO142, 0); write8((void *)FCH_IOMUXx8F_UART1_TXD_EGPIO143, 0); - udelay(2000); - /* reset UART */ - write8((void *)APU_UART0_BASE + (0x2000 * CONFIG_UART_FOR_CONSOLE) - + 0x88, 0x01); + /* Wait for the UART and AMBA devices to indicate power and clock OK */ + do { + udelay(100); + byte = read8((void *)ACPI_MMIO_BASE + AOAC_BASE + FCH_AOAC_REG57 + + CONFIG_UART_FOR_CONSOLE * 2); + byte &= (A0AC_PWR_RST_STATE | AOAC_RST_CLK_OK_STATE); + byte2 = read8((void *)ACPI_MMIO_BASE + AOAC_BASE + + FCH_AOAC_REG63); + byte2 &= (A0AC_PWR_RST_STATE | AOAC_RST_CLK_OK_STATE); + } while (!((byte == (A0AC_PWR_RST_STATE | AOAC_RST_CLK_OK_STATE)) && + (byte2 == (A0AC_PWR_RST_STATE | AOAC_RST_CLK_OK_STATE)))); + } void sb_pci_port80(void) -- cgit v1.2.3