Alexandru Gagniuc (mr.nuke.me(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/13314
-gerrit
commit 0c00e57d0a9b37214cec1c52a25b82b32cdec427
Author: Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com>
Date: Thu Oct 22 09:28:13 2015 -0700
soc/apollolake/cache_as_ram: Fix initial stack pointer calculation
We want the initial stack pointer to point within the region allocated
for stack, and not above it. This means we need to place it four
bytes below the end address, so the first push does not write above
the allocated stack region.
Change-Id: I288b3c0f04b9e3be742012124ecac7825874cb7f
Signed-off-by: Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com>
---
src/soc/intel/apollolake/bootblock/cache_as_ram.S | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/soc/intel/apollolake/bootblock/cache_as_ram.S b/src/soc/intel/apollolake/bootblock/cache_as_ram.S
index 6ecfa86..e496087 100644
--- a/src/soc/intel/apollolake/bootblock/cache_as_ram.S
+++ b/src/soc/intel/apollolake/bootblock/cache_as_ram.S
@@ -124,7 +124,7 @@ car_init_done:
/* Setup bootblock stack */
mov esp, CONFIG_DCACHE_RAM_BASE
- add esp, CONFIG_DCACHE_RAM_BOOTBLOCK_STACK_SIZE
+ add esp, CONFIG_DCACHE_RAM_BOOTBLOCK_STACK_SIZE - 4
/* Make sure CAR region is executable */
mov ecx, 0x120
Alexandru Gagniuc (mr.nuke.me(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/13309
-gerrit
commit dda0f21bf1e0687dc16a07e2d99c5e78852fa6dc
Author: Andrey Petrov <andrey.petrov(a)intel.com>
Date: Wed Oct 14 11:16:30 2015 -0700
soc/apollolake: Add support for memory-mapped boot media
On Apollo Lake SPI flash is memory mapped. The mapping is
different to previous platforms. Only "BIOS" region is mapped
in contrast to whole flash.
Change-Id: Ib57e01310c1a2b91e027abcbd6ac2c5cad9fddf3
Signed-off-by: Andrey Petrov <andrey.petrov(a)intel.com>
---
src/arch/x86/Makefile.inc | 3 ++
src/soc/intel/apollolake/Makefile.inc | 1 +
src/soc/intel/apollolake/mmap_boot.c | 63 +++++++++++++++++++++++++++++++++++
3 files changed, 67 insertions(+)
diff --git a/src/arch/x86/Makefile.inc b/src/arch/x86/Makefile.inc
index 86290ab..bd9e348 100644
--- a/src/arch/x86/Makefile.inc
+++ b/src/arch/x86/Makefile.inc
@@ -144,6 +144,9 @@ ifeq ($(CONFIG_SSE),y)
bootblock_romccflags := -mcpu=k7 -msse -O2 -D__PRE_RAM__ -D__BOOTBLOCK__
endif
+bootblock-y += memset.c
+bootblock-y += memcpy.c
+
# This is a hack in case there are no per chipset linker files.
$(objgenerated)/empty: build-dirs
touch $@
diff --git a/src/soc/intel/apollolake/Makefile.inc b/src/soc/intel/apollolake/Makefile.inc
index 9d3897f..0af3f36 100644
--- a/src/soc/intel/apollolake/Makefile.inc
+++ b/src/soc/intel/apollolake/Makefile.inc
@@ -13,6 +13,7 @@ bootblock-y += gpio.c
bootblock-y += bootblock/cache_as_ram.S
bootblock-y += bootblock/early_chipset_config.S
bootblock-y += uart_early.c
+bootblock-y += mmap_boot.c
romstage-y += cpu.c
romstage-y += gpio.c
diff --git a/src/soc/intel/apollolake/mmap_boot.c b/src/soc/intel/apollolake/mmap_boot.c
new file mode 100644
index 0000000..7e9080b
--- /dev/null
+++ b/src/soc/intel/apollolake/mmap_boot.c
@@ -0,0 +1,63 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2015 Intel Corp.
+ * (Written by Andrey Petrov <andrey.petrov(a)intel.com> for Intel Corp.)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <boot_device.h>
+#include <console/console.h>
+#include <cbfs.h>
+#include <endian.h>
+#include <stdlib.h>
+#include <commonlib/region.h>
+#include <fmap.h>
+
+/*
+ * If Apollo Lake is configured to boot from SPI flash "BIOS" region
+ * (as defined in descriptor) is mapped below 4GiB. Form a pointer for
+ * the base.
+ */
+#define ROM_BASE ((void *)(uintptr_t)(0x100000000ULL - CONFIG_IFD_BIOS_SIZE))
+
+static const struct mem_region_device boot_dev = {
+ .base = (void *) ROM_BASE,
+ /* typically not whole flash is memory mapped */
+ .rdev = REGION_DEV_INIT(&mem_rdev_ops, CONFIG_IFD_BIOS_START,
+ CONFIG_IFD_BIOS_SIZE)
+};
+
+const struct region_device *boot_device_ro(void)
+{
+ return &boot_dev.rdev;
+}
+
+static int iafw_boot_region_properties(struct cbfs_props *props)
+{
+ struct region regn;
+
+ /* use fmap to locate CBFS area */
+ if (fmap_locate_area("COREBOOT", ®n))
+ return 1;
+
+ props->offset = regn.offset;
+ props->size = regn.size;
+
+ printk(BIOS_DEBUG, "CBFS @ %zx size %zx\n", props->offset, props->size);
+
+ return 0;
+}
+
+/*
+ * Named cbfs_master_header_locator so that it overrides the default, but
+ * incompatible locator in cbfs.c
+ */
+const struct cbfs_locator cbfs_master_header_locator = {
+ .name = "IAFW Locator",
+ .locate = iafw_boot_region_properties,
+};
Alexandru Gagniuc (mr.nuke.me(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/13311
-gerrit
commit 1eff21041805fc146aa59fff95c850906d250027
Author: Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com>
Date: Fri Oct 9 17:34:46 2015 -0700
soc/apollolake: Disable watchdog timer after console initialization
Change-Id: I0680d3866cece70e3ea03b5c1b22769149fc2278
Signed-off-by: Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com>
---
src/soc/intel/apollolake/bootblock/bootblock_car.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/src/soc/intel/apollolake/bootblock/bootblock_car.c b/src/soc/intel/apollolake/bootblock/bootblock_car.c
index 3a0110e..e9cbb09 100644
--- a/src/soc/intel/apollolake/bootblock/bootblock_car.c
+++ b/src/soc/intel/apollolake/bootblock/bootblock_car.c
@@ -12,9 +12,26 @@
#include <arch/io.h>
#include <console/console.h>
+#include <device/pci.h>
#include <soc/bootblock.h>
#include <soc/uart.h>
+static void disable_watchdog(void)
+{
+ uint32_t reg;
+ device_t dev = PCI_DEV(0, 0xd, 1);
+
+ /* Open up an IO window */
+ pci_write_config16(dev, PCI_BASE_ADDRESS_4, 0x400);
+ pci_write_config32(dev, PCI_COMMAND,
+ PCI_COMMAND_MASTER | PCI_COMMAND_IO);
+
+ /* We don't have documentation for this bit, but it prevents reboots */
+ reg = inl(0x400 + 0x68);
+ reg |= 1 << 11;
+ outl(reg, 0x400 + 0x68);
+}
+
void bootblock_car_main(void)
{
/* Quick post code to show we made it to C code */
@@ -25,6 +42,9 @@ void bootblock_car_main(void)
console_init();
}
+ /* Wait until after we have console to disable this */
+ disable_watchdog();
+
/* Don't return, so we see the above post code */
while (1)
;
Alexandru Gagniuc (mr.nuke.me(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/13320
-gerrit
commit d4b781264bcc3aea79f30a5f8d9d5095830f5e5e
Author: Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com>
Date: Tue Oct 27 10:31:26 2015 -0700
soc/apollolake: Override default mmap_boot.c for all stages
The Apollolake-specific mmap_boot.c implementation was only compiled
for the bootblock. This worked because the generic one was never
included in the bootblock, so we didn't get duplicate symbol.
However, the default mmap_boot won't work on this SOC, so we need to
override it for all stages where it is used.
Change-Id: If633349e0700437d8adfe6af9da045e80c9f02c5
Signed-off-by: Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com>
---
src/soc/intel/apollolake/Kconfig | 4 ++++
src/soc/intel/apollolake/Makefile.inc | 4 +++-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/soc/intel/apollolake/Kconfig b/src/soc/intel/apollolake/Kconfig
index e5b0649..4b181ea 100644
--- a/src/soc/intel/apollolake/Kconfig
+++ b/src/soc/intel/apollolake/Kconfig
@@ -36,6 +36,10 @@ config CPU_SPECIFIC_OPTIONS
select UDELAY_TSC
select TSC_CONSTANT_RATE
+config X86_TOP4G_BOOTMEDIA_MAP
+ bool
+ default n
+
config MMCONF_BASE_ADDRESS
hex "PCI MMIO Base Address"
default 0xe0000000
diff --git a/src/soc/intel/apollolake/Makefile.inc b/src/soc/intel/apollolake/Makefile.inc
index 0af3f36..4b0b31d 100644
--- a/src/soc/intel/apollolake/Makefile.inc
+++ b/src/soc/intel/apollolake/Makefile.inc
@@ -12,15 +12,17 @@ bootblock-y += cpu.c
bootblock-y += gpio.c
bootblock-y += bootblock/cache_as_ram.S
bootblock-y += bootblock/early_chipset_config.S
-bootblock-y += uart_early.c
bootblock-y += mmap_boot.c
+bootblock-y += uart_early.c
romstage-y += cpu.c
romstage-y += gpio.c
+romstage-y += mmap_boot.c
romstage-y += uart_early.c
ramstage-y += cpu.c
ramstage-y += gpio.c
+ramstage-y += mmap_boot.c
ramstage-y += uart.c
romstage-y += placeholders.c
Martin Roth (martinroth(a)google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/13426
-gerrit
commit 0d78a56555361e158fec0e8237eb05a3a88a0e2e
Author: Martin Roth <martinroth(a)google.com>
Date: Mon Jan 25 14:01:55 2016 -0700
payloads/coreinfo: Add defaultbuild target
Add a single target to do the full coreinfo build using default Kconfig
values for both coreinfo and libpayload.
Change-Id: Id622fb2df480e826f6d868dbe01385d76587be26
Signed-off-by: Martin Roth <martinroth(a)google.com>
---
payloads/coreinfo/Makefile | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/payloads/coreinfo/Makefile b/payloads/coreinfo/Makefile
index 6f7ce51..a3a02c2 100644
--- a/payloads/coreinfo/Makefile
+++ b/payloads/coreinfo/Makefile
@@ -106,6 +106,10 @@ else
real-all: config
endif
+defaultbuild:
+ $(MAKE) olddefconfig
+ $(MAKE) all
+
ifneq ($(strip $(HAVE_LIBPAYLOAD)),)
libpayload:
printf "Found Libpayload $(LIBPAYLOAD_DIR).\n"
Alexandru Gagniuc (mr.nuke.me(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/13308
-gerrit
commit ed5a73c3665e7c2c9e50119de0b8d2cfbc24ce8a
Author: Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com>
Date: Wed Oct 7 12:59:31 2015 -0700
soc/apollolake: Add UART and debug console support
The UART uses a standard 8250 32-bit register map, and some config
registers in the same memory window. Set it up for console.
Change-Id: I866ff67d121826594b634cd00b6ef693b1d64512
Signed-off-by: Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com>
---
src/soc/intel/apollolake/Kconfig | 7 ++
src/soc/intel/apollolake/Makefile.inc | 3 +
src/soc/intel/apollolake/bootblock/bootblock_car.c | 8 +++
src/soc/intel/apollolake/include/soc/uart.h | 28 ++++++++
src/soc/intel/apollolake/uart.c | 28 ++++++++
src/soc/intel/apollolake/uart_early.c | 78 ++++++++++++++++++++++
6 files changed, 152 insertions(+)
diff --git a/src/soc/intel/apollolake/Kconfig b/src/soc/intel/apollolake/Kconfig
index 825a40f..e5b0649 100644
--- a/src/soc/intel/apollolake/Kconfig
+++ b/src/soc/intel/apollolake/Kconfig
@@ -20,6 +20,8 @@ config CPU_SPECIFIC_OPTIONS
# Misc options
select C_ENVIRONMENT_BOOTBLOCK
select COLLECT_TIMESTAMPS
+ select DRIVERS_UART_8250MEM_32
+ select NO_UART_ON_SUPERIO # 8250 IO conflicts with 8250 MEM_32
select HAVE_INTEL_FIRMWARE
select MMCONF_SUPPORT
select MMCONF_SUPPORT_DEFAULT
@@ -42,6 +44,11 @@ config IOSF_BASE_ADDRESS
hex "MMIO Base Address of sideband bus"
default 0xd0000000
+config CONSOLE_UART_BASE_ADDRESS
+ depends on CONSOLE_SERIAL
+ hex "MMIO base address for UART"
+ default 0xde000000
+
config DCACHE_RAM_BASE
hex "Base address of cache-as-RAM"
default 0xfef00000
diff --git a/src/soc/intel/apollolake/Makefile.inc b/src/soc/intel/apollolake/Makefile.inc
index 9d33fe5..9d3897f 100644
--- a/src/soc/intel/apollolake/Makefile.inc
+++ b/src/soc/intel/apollolake/Makefile.inc
@@ -12,12 +12,15 @@ bootblock-y += cpu.c
bootblock-y += gpio.c
bootblock-y += bootblock/cache_as_ram.S
bootblock-y += bootblock/early_chipset_config.S
+bootblock-y += uart_early.c
romstage-y += cpu.c
romstage-y += gpio.c
+romstage-y += uart_early.c
ramstage-y += cpu.c
ramstage-y += gpio.c
+ramstage-y += uart.c
romstage-y += placeholders.c
smm-y += placeholders.c
diff --git a/src/soc/intel/apollolake/bootblock/bootblock_car.c b/src/soc/intel/apollolake/bootblock/bootblock_car.c
index 4be0815..3a0110e 100644
--- a/src/soc/intel/apollolake/bootblock/bootblock_car.c
+++ b/src/soc/intel/apollolake/bootblock/bootblock_car.c
@@ -11,12 +11,20 @@
*/
#include <arch/io.h>
+#include <console/console.h>
#include <soc/bootblock.h>
+#include <soc/uart.h>
void bootblock_car_main(void)
{
/* Quick post code to show we made it to C code */
outb(0x30, 0x80);
+
+ if (IS_ENABLED(CONFIG_BOOTBLOCK_CONSOLE)) {
+ lpss_console_uart_init();
+ console_init();
+ }
+
/* Don't return, so we see the above post code */
while (1)
;
diff --git a/src/soc/intel/apollolake/include/soc/uart.h b/src/soc/intel/apollolake/include/soc/uart.h
new file mode 100644
index 0000000..fd535fb
--- /dev/null
+++ b/src/soc/intel/apollolake/include/soc/uart.h
@@ -0,0 +1,28 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2015 Intel Corp.
+ * (Written by Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com> for Intel Corp.)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef _SOC_APOLLOLAKE_UART_H_
+#define _SOC_APOLLOLAKE_UART_H_
+
+/* Clock is 100MHz * (M / N).*/
+#define UART_CLK 0x200
+# define UART_CLK_UPDATE (1 << 31)
+# define UART_CLK_DIV_N(n) (((n) & 0x7fff) << 16)
+# define UART_CLK_DIV_M(m) (((m) & 0x7fff) << 1)
+# define UART_CLK_EN (1 << 0)
+#define UART_RESET 0x204
+# define UART_RESET_DMA_EN (1 << 2)
+# define UART_RESET_UART_EN (3 << 0)
+
+void lpss_console_uart_init(void);
+
+#endif /* _SOC_APOLLOLAKE_UART_H_ */
diff --git a/src/soc/intel/apollolake/uart.c b/src/soc/intel/apollolake/uart.c
new file mode 100644
index 0000000..00bc45f
--- /dev/null
+++ b/src/soc/intel/apollolake/uart.c
@@ -0,0 +1,28 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2015 Intel Corp.
+ * (Written by Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com> for Intel Corp.)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <console/uart.h>
+
+/*
+ * TODO: We need a mechanism to return the new BAR once the resource allocator
+ * gives us a new location.
+ */
+uintptr_t uart_platform_base(int idx)
+{
+ return (CONFIG_CONSOLE_UART_BASE_ADDRESS);
+}
+
+unsigned int uart_platform_refclk(void)
+{
+ /* That's within 0.5% of the actual value we've set earlier */
+ return 115200 * 16;
+}
diff --git a/src/soc/intel/apollolake/uart_early.c b/src/soc/intel/apollolake/uart_early.c
new file mode 100644
index 0000000..bc02776
--- /dev/null
+++ b/src/soc/intel/apollolake/uart_early.c
@@ -0,0 +1,78 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2015 Intel Corp.
+ * (Written by Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com> for Intel Corp.)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <console/uart.h>
+#include <device/pci.h>
+#include <soc/gpio.h>
+#include <soc/uart.h>
+
+static const struct pad_config uart_tx_pad_configs[] = {
+ {
+ .community = GPIO_NORTH,
+ .pad = 39,
+ .config = {PAD_CFG0_DEFAULT_FUNC(1), PAD_CFG1_DEFAULT_NATIVE},
+ }, {
+ .community = GPIO_NORTH,
+ .pad = 42,
+ .config = {PAD_CFG0_DEFAULT_FUNC(1), PAD_CFG1_DEFAULT_NATIVE},
+ }, {
+ .community = GPIO_NORTH,
+ .pad = 47,
+ .config = {PAD_CFG0_DEFAULT_FUNC(1), PAD_CFG1_DEFAULT_NATIVE},
+ },
+};
+
+static void lpss_uart_write(uint16_t reg, uint32_t val)
+{
+ uintptr_t base = CONFIG_CONSOLE_UART_BASE_ADDRESS | reg;
+ write32((void *)base, val);
+}
+
+void lpss_console_uart_init(void)
+{
+ uint32_t clk_sel;
+ device_t uart = PCI_DEV(0, 0x18, CONFIG_UART_FOR_CONSOLE & 3);
+
+ if(CONFIG_UART_FOR_CONSOLE > 2)
+ return;
+
+ gpio_configure_pad(&uart_tx_pad_configs[CONFIG_UART_FOR_CONSOLE]);
+
+ /* 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);
+
+ /* 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_DMA_EN | UART_RESET_UART_EN);
+
+ /* 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);
+
+}
+
+uintptr_t uart_platform_base(int idx)
+{
+ return (CONFIG_CONSOLE_UART_BASE_ADDRESS);
+}
+
+unsigned int uart_platform_refclk(void)
+{
+ /* That's within 0.5% of the actual value we've set earlier */
+ return 115200 * 16;
+}
Alexandru Gagniuc (mr.nuke.me(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/13308
-gerrit
commit 7c7f66072299718c7335bbc8e9f000eacc1e8bbe
Author: Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com>
Date: Wed Oct 7 12:59:31 2015 -0700
soc/apollolake: Add UART and debug console support
The UART uses a standard 8250 32-bit register map, and some config
registers in the same memory window. Set it up for console.
Change-Id: I866ff67d121826594b634cd00b6ef693b1d64512
Signed-off-by: Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com>
---
src/soc/intel/apollolake/Kconfig | 7 ++
src/soc/intel/apollolake/Makefile.inc | 3 +
src/soc/intel/apollolake/bootblock/bootblock_car.c | 8 +++
src/soc/intel/apollolake/include/soc/uart.h | 28 ++++++++
src/soc/intel/apollolake/uart.c | 22 ++++++
src/soc/intel/apollolake/uart_early.c | 78 ++++++++++++++++++++++
6 files changed, 146 insertions(+)
diff --git a/src/soc/intel/apollolake/Kconfig b/src/soc/intel/apollolake/Kconfig
index 825a40f..e5b0649 100644
--- a/src/soc/intel/apollolake/Kconfig
+++ b/src/soc/intel/apollolake/Kconfig
@@ -20,6 +20,8 @@ config CPU_SPECIFIC_OPTIONS
# Misc options
select C_ENVIRONMENT_BOOTBLOCK
select COLLECT_TIMESTAMPS
+ select DRIVERS_UART_8250MEM_32
+ select NO_UART_ON_SUPERIO # 8250 IO conflicts with 8250 MEM_32
select HAVE_INTEL_FIRMWARE
select MMCONF_SUPPORT
select MMCONF_SUPPORT_DEFAULT
@@ -42,6 +44,11 @@ config IOSF_BASE_ADDRESS
hex "MMIO Base Address of sideband bus"
default 0xd0000000
+config CONSOLE_UART_BASE_ADDRESS
+ depends on CONSOLE_SERIAL
+ hex "MMIO base address for UART"
+ default 0xde000000
+
config DCACHE_RAM_BASE
hex "Base address of cache-as-RAM"
default 0xfef00000
diff --git a/src/soc/intel/apollolake/Makefile.inc b/src/soc/intel/apollolake/Makefile.inc
index 9d33fe5..9d3897f 100644
--- a/src/soc/intel/apollolake/Makefile.inc
+++ b/src/soc/intel/apollolake/Makefile.inc
@@ -12,12 +12,15 @@ bootblock-y += cpu.c
bootblock-y += gpio.c
bootblock-y += bootblock/cache_as_ram.S
bootblock-y += bootblock/early_chipset_config.S
+bootblock-y += uart_early.c
romstage-y += cpu.c
romstage-y += gpio.c
+romstage-y += uart_early.c
ramstage-y += cpu.c
ramstage-y += gpio.c
+ramstage-y += uart.c
romstage-y += placeholders.c
smm-y += placeholders.c
diff --git a/src/soc/intel/apollolake/bootblock/bootblock_car.c b/src/soc/intel/apollolake/bootblock/bootblock_car.c
index 4be0815..3a0110e 100644
--- a/src/soc/intel/apollolake/bootblock/bootblock_car.c
+++ b/src/soc/intel/apollolake/bootblock/bootblock_car.c
@@ -11,12 +11,20 @@
*/
#include <arch/io.h>
+#include <console/console.h>
#include <soc/bootblock.h>
+#include <soc/uart.h>
void bootblock_car_main(void)
{
/* Quick post code to show we made it to C code */
outb(0x30, 0x80);
+
+ if (IS_ENABLED(CONFIG_BOOTBLOCK_CONSOLE)) {
+ lpss_console_uart_init();
+ console_init();
+ }
+
/* Don't return, so we see the above post code */
while (1)
;
diff --git a/src/soc/intel/apollolake/include/soc/uart.h b/src/soc/intel/apollolake/include/soc/uart.h
new file mode 100644
index 0000000..fd535fb
--- /dev/null
+++ b/src/soc/intel/apollolake/include/soc/uart.h
@@ -0,0 +1,28 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2015 Intel Corp.
+ * (Written by Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com> for Intel Corp.)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef _SOC_APOLLOLAKE_UART_H_
+#define _SOC_APOLLOLAKE_UART_H_
+
+/* Clock is 100MHz * (M / N).*/
+#define UART_CLK 0x200
+# define UART_CLK_UPDATE (1 << 31)
+# define UART_CLK_DIV_N(n) (((n) & 0x7fff) << 16)
+# define UART_CLK_DIV_M(m) (((m) & 0x7fff) << 1)
+# define UART_CLK_EN (1 << 0)
+#define UART_RESET 0x204
+# define UART_RESET_DMA_EN (1 << 2)
+# define UART_RESET_UART_EN (3 << 0)
+
+void lpss_console_uart_init(void);
+
+#endif /* _SOC_APOLLOLAKE_UART_H_ */
diff --git a/src/soc/intel/apollolake/uart.c b/src/soc/intel/apollolake/uart.c
new file mode 100644
index 0000000..9663130
--- /dev/null
+++ b/src/soc/intel/apollolake/uart.c
@@ -0,0 +1,22 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2015 Intel Corp.
+ * (Written by Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com> for Intel Corp.)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <console/uart.h>
+
+/*
+ * TODO: We need a mechanism to return the new BAR once the resource allocator
+ * gives us a new location.
+ */
+uintptr_t uart_platform_base(int idx)
+{
+ return (CONFIG_CONSOLE_UART_BASE_ADDRESS);
+}
diff --git a/src/soc/intel/apollolake/uart_early.c b/src/soc/intel/apollolake/uart_early.c
new file mode 100644
index 0000000..bc02776
--- /dev/null
+++ b/src/soc/intel/apollolake/uart_early.c
@@ -0,0 +1,78 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2015 Intel Corp.
+ * (Written by Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com> for Intel Corp.)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <console/uart.h>
+#include <device/pci.h>
+#include <soc/gpio.h>
+#include <soc/uart.h>
+
+static const struct pad_config uart_tx_pad_configs[] = {
+ {
+ .community = GPIO_NORTH,
+ .pad = 39,
+ .config = {PAD_CFG0_DEFAULT_FUNC(1), PAD_CFG1_DEFAULT_NATIVE},
+ }, {
+ .community = GPIO_NORTH,
+ .pad = 42,
+ .config = {PAD_CFG0_DEFAULT_FUNC(1), PAD_CFG1_DEFAULT_NATIVE},
+ }, {
+ .community = GPIO_NORTH,
+ .pad = 47,
+ .config = {PAD_CFG0_DEFAULT_FUNC(1), PAD_CFG1_DEFAULT_NATIVE},
+ },
+};
+
+static void lpss_uart_write(uint16_t reg, uint32_t val)
+{
+ uintptr_t base = CONFIG_CONSOLE_UART_BASE_ADDRESS | reg;
+ write32((void *)base, val);
+}
+
+void lpss_console_uart_init(void)
+{
+ uint32_t clk_sel;
+ device_t uart = PCI_DEV(0, 0x18, CONFIG_UART_FOR_CONSOLE & 3);
+
+ if(CONFIG_UART_FOR_CONSOLE > 2)
+ return;
+
+ gpio_configure_pad(&uart_tx_pad_configs[CONFIG_UART_FOR_CONSOLE]);
+
+ /* 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);
+
+ /* 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_DMA_EN | UART_RESET_UART_EN);
+
+ /* 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);
+
+}
+
+uintptr_t uart_platform_base(int idx)
+{
+ return (CONFIG_CONSOLE_UART_BASE_ADDRESS);
+}
+
+unsigned int uart_platform_refclk(void)
+{
+ /* That's within 0.5% of the actual value we've set earlier */
+ return 115200 * 16;
+}
Alexandru Gagniuc (mr.nuke.me(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/12870
-gerrit
commit c4173406518eaf68bf8544d7863672b795fad754
Author: Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com>
Date: Tue Oct 6 16:35:39 2015 -0700
OBSOLETED BY https://review.coreboot.org/13069
src/arch/x86: Link the compiler runtime library in the bootblock
At least on GCC __udivdi3 and __umoddi3 are needed by the console
code. They are provided by the compiler runtime library.
Change-Id: I78bbea425c33d7eebaf829d58d763b7a1c6e997c
Signed-off-by: Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com>
---
src/arch/x86/Makefile.inc | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/arch/x86/Makefile.inc b/src/arch/x86/Makefile.inc
index 86290ab..75767cb 100644
--- a/src/arch/x86/Makefile.inc
+++ b/src/arch/x86/Makefile.inc
@@ -163,8 +163,12 @@ $(objgenerated)/bootblock.inc: $(src)/arch/x86/$(subst ",,$(CONFIG_BOOTBLOCK_SOU
# $(obj)/arch/x86/bootblock.bootblock.ld is part of $(bootblock-objs)
$(objcbfs)/bootblock.debug: $$(bootblock-objs)
@printf " LINK $(subst $(obj)/,,$(@))\n"
- $(LD_bootblock) $(LDFLAGS_bootblock) -o $@ -L$(obj) \
- $(filter-out %.ld,$(bootblock-objs)) \
+ $(LD_bootblock) $(LDFLAGS_bootblock) -static \
+ -o $@ $(COMPILER_RT_FLAGS_bootblock) -L$(obj) \
+ -whole-archive --start-group \
+ $(filter %.o,$(bootblock-objs)) \
+ --no-whole-archive $(COMPILER_RT_bootblock) \
+ --end-group \
-T $(obj)/arch/x86/bootblock.bootblock.ld
endif # C_ENVIRONMENT_BOOTBLOCK