From 138b2a03bedb059f7a4064b4ff03d88083774302 Mon Sep 17 00:00:00 2001 From: Aamir Bohra Date: Thu, 6 Apr 2017 20:21:58 +0530 Subject: soc/intel/apollolake: Use LPSS common library Use lpss common library to program reset and clock register for lpss modules Change-Id: I75f9aebd60290fbf22684f8cc2ce8e8a4a4304b0 Signed-off-by: Aamir Bohra Reviewed-on: https://review.coreboot.org/19154 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin --- src/soc/intel/apollolake/uart_early.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'src/soc/intel/apollolake/uart_early.c') diff --git a/src/soc/intel/apollolake/uart_early.c b/src/soc/intel/apollolake/uart_early.c index 51aeedfeb6..0a32b715b0 100644 --- a/src/soc/intel/apollolake/uart_early.c +++ b/src/soc/intel/apollolake/uart_early.c @@ -17,16 +17,11 @@ #include #include +#include #include #include #include -static void lpss_uart_write(uint16_t reg, uint32_t val) -{ - uintptr_t base = CONFIG_CONSOLE_UART_BASE_ADDRESS | reg; - write32((void *)base, val); -} - static inline int invalid_uart_for_console(void) { /* There are actually only 2 UARTS, and they are named UART1 and @@ -38,28 +33,27 @@ static inline int invalid_uart_for_console(void) void lpss_console_uart_init(void) { - uint32_t clk_sel; + uintptr_t base = CONFIG_CONSOLE_UART_BASE_ADDRESS; device_t uart = _PCH_DEV(UART, CONFIG_UART_FOR_CONSOLE & 3); if (invalid_uart_for_console()) return; /* Enable BAR0 for the UART -- this is where the 8250 registers hide */ - pci_write_config32(uart, PCI_BASE_ADDRESS_0, - CONFIG_CONSOLE_UART_BASE_ADDRESS); + pci_write_config32(uart, PCI_BASE_ADDRESS_0, base); /* Enable memory access and bus master */ pci_write_config32(uart, PCI_COMMAND, PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER); /* Take UART out of reset */ - lpss_uart_write(UART_RESET, UART_RESET_UART_EN); + lpss_reset_release(base); - /* These values get us a 1.836 MHz clock (ideally we want 1.843 MHz) */ - clk_sel = UART_CLK_DIV_N(0x7fff) | UART_CLK_DIV_M(0x025a); - /* Set M and N divisor inputs and enable clock */ - lpss_uart_write(UART_CLK, clk_sel | UART_CLK_UPDATE); - lpss_uart_write(UART_CLK, clk_sel | UART_CLK_EN); + /* + * Set M and N divisor inputs and enable clock. These values + * get us a 1.836 MHz clock (ideally we want 1.843 MHz) + */ + lpss_clk_update(base, 0x025a, 0x7fff); } -- cgit v1.2.3