[U-Boot] [PATCH 0/12] Add additional x86 support for coreboot

This series contains patches to enable additional coreboot features including the frame buffer and device tree control.
Gabe Black (7): x86: Allow compiling out realmode/bios code x86: Add an fdt pointer to the global data structure x86: Add a minimal device tree for alex x86 x86: Add a default implementation for cleanup_before_linux() x86: Add a dummy implementation for timer_get_us x86: Initialize the device tree pointer to NULL in i386. x86: Include types.h explicitly in the i386 version of io.h
Simon Glass (2): x86: Remove coreboot start16 code x86: Define CONFIG_SYS_VSNPRINTF for coreboot
Stefan Reinauer (3): x86: video: Add coreboot framebuffer support x86: Fix typo in pcat_timer.c x86: Don't spam POST80 codes with slow IO functions
arch/x86/cpu/Makefile | 2 +- arch/x86/cpu/cpu.c | 6 ++ arch/x86/cpu/timer.c | 17 ++++ arch/x86/include/asm/global_data.h | 1 + arch/x86/include/asm/io.h | 4 +- arch/x86/include/asm/u-boot-x86.h | 1 + arch/x86/lib/Makefile | 9 ++- arch/x86/lib/pcat_timer.c | 2 +- arch/x86/lib/video.c | 2 + arch/x86/lib/zimage.c | 4 +- board/chromebook-x86/coreboot/Makefile | 1 - board/chromebook-x86/coreboot/coreboot_start16.S | 33 ------- board/chromebook-x86/dts/x86-alex.dts | 30 +++++++ drivers/video/Makefile | 1 + drivers/video/coreboot_fb.c | 102 ++++++++++++++++++++++ include/configs/coreboot.h | 1 + 16 files changed, 174 insertions(+), 42 deletions(-) create mode 100644 arch/x86/cpu/timer.c delete mode 100644 board/chromebook-x86/coreboot/coreboot_start16.S create mode 100644 board/chromebook-x86/dts/x86-alex.dts create mode 100644 drivers/video/coreboot_fb.c

From: Gabe Black gabeblack@chromium.org
We don't want this for coreboot, so provide a way of compiling it out.
Signed-off-by: Gabe Black gabeblack@chromium.org Signed-off-by: Stefan Reinauer reinauer@chromium.org Signed-off-by: Simon Glass sjg@chromium.org --- arch/x86/lib/Makefile | 9 ++++++--- arch/x86/lib/video.c | 2 ++ arch/x86/lib/zimage.c | 4 ++-- 3 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile index 51836da..1cb9155 100644 --- a/arch/x86/lib/Makefile +++ b/arch/x86/lib/Makefile @@ -25,11 +25,16 @@ include $(TOPDIR)/config.mk
LIB = $(obj)lib$(ARCH).o
+ifeq ($(CONFIG_SYS_X86_REALMODE),y) SOBJS-$(CONFIG_SYS_PC_BIOS) += bios.o SOBJS-$(CONFIG_SYS_PCI_BIOS) += bios_pci.o -SOBJS-$(CONFIG_SYS_X86_REALMODE) += realmode_switch.o +COBJS-y += realmode.o +SOBJS-y += realmode_switch.o
COBJS-$(CONFIG_SYS_PC_BIOS) += bios_setup.o +COBJS-$(CONFIG_VIDEO) += video_bios.o +endif + COBJS-y += board.o COBJS-y += bootm.o COBJS-y += cmd_boot.o @@ -41,11 +46,9 @@ COBJS-$(CONFIG_SYS_PCAT_INTERRUPTS) += pcat_interrupts.o COBJS-$(CONFIG_SYS_GENERIC_TIMER) += pcat_timer.o COBJS-$(CONFIG_PCI) += pci.o COBJS-$(CONFIG_PCI) += pci_type1.o -COBJS-$(CONFIG_SYS_X86_REALMODE) += realmode.o COBJS-y += relocate.o COBJS-y += string.o COBJS-$(CONFIG_SYS_X86_ISR_TIMER) += timer.o -COBJS-$(CONFIG_VIDEO) += video_bios.o COBJS-$(CONFIG_VIDEO) += video.o COBJS-$(CONFIG_CMD_ZBOOT) += zimage.o
diff --git a/arch/x86/lib/video.c b/arch/x86/lib/video.c index 3d6b24d..7d58ab0 100644 --- a/arch/x86/lib/video.c +++ b/arch/x86/lib/video.c @@ -222,8 +222,10 @@ int video_init(void)
int drv_video_init(void) { +#if defined CONFIG_SYS_X86_REALMODE if (video_bios_init()) return 1; +#endif
return video_init(); } diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c index 2214286..2bbf5a8 100644 --- a/arch/x86/lib/zimage.c +++ b/arch/x86/lib/zimage.c @@ -171,7 +171,7 @@ struct boot_params *load_zimage(char *image, unsigned long kernel_size, else *load_address = (void *)ZIMAGE_LOAD_ADDR;
-#if defined CONFIG_ZBOOT_32 +#if !defined CONFIG_SYS_X86_REALMODE || defined CONFIG_ZBOOT_32 printf("Building boot_params at 0x%8.8lx\n", (ulong)setup_base); memset(setup_base, 0, sizeof(*setup_base)); setup_base->hdr = params->hdr; @@ -283,7 +283,7 @@ void boot_zimage(void *setup_base, void *load_address) { printf("\nStarting kernel ...\n\n");
-#if defined CONFIG_ZBOOT_32 +#if !defined CONFIG_SYS_X86_REALMODE || defined CONFIG_ZBOOT_32 /* * Set %ebx, %ebp, and %edi to 0, %esi to point to the boot_params * structure, and then jump to the kernel. We assume that %cs is

This file is no longer needed for coreboot.
Signed-off-by: Simon Glass sjg@chromium.org --- board/chromebook-x86/coreboot/Makefile | 1 - board/chromebook-x86/coreboot/coreboot_start16.S | 33 ---------------------- 2 files changed, 0 insertions(+), 34 deletions(-) delete mode 100644 board/chromebook-x86/coreboot/coreboot_start16.S
diff --git a/board/chromebook-x86/coreboot/Makefile b/board/chromebook-x86/coreboot/Makefile index 2bddf04..886baf6 100644 --- a/board/chromebook-x86/coreboot/Makefile +++ b/board/chromebook-x86/coreboot/Makefile @@ -32,7 +32,6 @@ include $(TOPDIR)/config.mk
LIB = $(obj)lib$(BOARD).o
-SOBJS-y += coreboot_start16.o SOBJS-y += coreboot_start.o
SRCS := $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c) diff --git a/board/chromebook-x86/coreboot/coreboot_start16.S b/board/chromebook-x86/coreboot/coreboot_start16.S deleted file mode 100644 index 6b3d92d..0000000 --- a/board/chromebook-x86/coreboot/coreboot_start16.S +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2011 The Chromium OS Authors. - * (C) Copyright 2008 - * Graeme Russ, graeme.russ@gmail.com. - * - * See file CREDITS for list of people who contributed to this - * project. - * - * 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. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA - */ - -.section .bios, "ax" -.code16 -.globl realmode_reset -.hidden realmode_reset -.type realmode_reset, @function -realmode_reset: - -1: hlt - jmp 1

From: Stefan Reinauer reinauer@chromium.org
Add a basic driver for the coreboot framebuffer.
Signed-off-by: Stefan Reinauer reinauer@chromium.org Signed-off-by: Simon Glass sjg@chromium.org --- drivers/video/Makefile | 1 + drivers/video/coreboot_fb.c | 102 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+), 0 deletions(-) create mode 100644 drivers/video/coreboot_fb.c
diff --git a/drivers/video/Makefile b/drivers/video/Makefile index ebb6da8..cc3022a 100644 --- a/drivers/video/Makefile +++ b/drivers/video/Makefile @@ -39,6 +39,7 @@ COBJS-$(CONFIG_S6E8AX0) += s6e8ax0.o COBJS-$(CONFIG_S6E63D6) += s6e63d6.o COBJS-$(CONFIG_SED156X) += sed156x.o COBJS-$(CONFIG_VIDEO_AMBA) += amba.o +COBJS-$(CONFIG_VIDEO_COREBOOT) += coreboot_fb.o COBJS-$(CONFIG_VIDEO_CT69000) += ct69000.o videomodes.o COBJS-$(CONFIG_VIDEO_DA8XX) += da8xx-fb.o videomodes.o COBJS-$(CONFIG_VIDEO_MB862xx) += mb862xx.o videomodes.o diff --git a/drivers/video/coreboot_fb.c b/drivers/video/coreboot_fb.c new file mode 100644 index 0000000..a99188a --- /dev/null +++ b/drivers/video/coreboot_fb.c @@ -0,0 +1,102 @@ +/* + * coreboot Framebuffer driver. + * + * Copyright (C) 2011 The Chromium OS authors + * + * See file CREDITS for list of people who contributed to this + * project. + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include <common.h> +#include <asm/ic/coreboot/tables.h> +#include <asm/ic/coreboot/sysinfo.h> +#include <video_fb.h> +#include "videomodes.h" + +/* + * The Graphic Device + */ +GraphicDevice ctfb; + +static int parse_coreboot_table_fb(GraphicDevice *gd) +{ + struct cb_framebuffer *fb = lib_sysinfo.framebuffer; + + /* If there is no framebuffer structure, bail out and keep + * running on the serial console. + */ + if (!fb) + return 0; + + gd->winSizeX = fb->x_resolution; + gd->winSizeY = fb->y_resolution; + + gd->plnSizeX = fb->x_resolution; + gd->plnSizeY = fb->y_resolution; + + gd->gdfBytesPP = fb->bits_per_pixel / 8; + + switch (fb->bits_per_pixel) { + case 24: + gd->gdfIndex = GDF_32BIT_X888RGB; + break; + case 16: + gd->gdfIndex = GDF_16BIT_565RGB; + break; + default: + gd->gdfIndex = GDF__8BIT_INDEX; + break; + } + + gd->isaBase = CONFIG_SYS_ISA_IO_BASE_ADDRESS; + gd->pciBase = (unsigned int)fb->physical_address; + + gd->frameAdrs = (unsigned int)fb->physical_address; + gd->memSize = fb->bytes_per_line * fb->y_resolution; + + gd->vprBase = (unsigned int)fb->physical_address; + gd->cprBase = (unsigned int)fb->physical_address; + + return 1; +} + +void *video_hw_init(void) +{ + GraphicDevice *gd = &ctfb; + int bits_per_pixel; + + printf("Video: "); + + if (!parse_coreboot_table_fb(gd)) { + printf("No video mode configured in coreboot!\n"); + return NULL; + } + + bits_per_pixel = gd->gdfBytesPP * 8; + + /* fill in Graphic device struct */ + sprintf(gd->modeIdent, "%dx%dx%d", gd->winSizeX, gd->winSizeY, + bits_per_pixel); + printf("%s\n", gd->modeIdent); + + memset((void *)gd->pciBase, 0, + gd->winSizeX * gd->winSizeY * gd->gdfBytesPP); + + return (void *)gd; +} +

From: Gabe Black gabeblack@chromium.org
This change adds a pointer to the global data structure in x86 to point to the device tree. This mirrors an identical pointer in ARM.
Signed-off-by: Gabe Black gabeblack@chromium.org Signed-off-by: Simon Glass sjg@chromium.org --- arch/x86/include/asm/global_data.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/arch/x86/include/asm/global_data.h b/arch/x86/include/asm/global_data.h index 3c79508..d3b6031 100644 --- a/arch/x86/include/asm/global_data.h +++ b/arch/x86/include/asm/global_data.h @@ -57,6 +57,7 @@ typedef struct global_data { unsigned long new_gd_addr; /* New location of Global Data */ phys_size_t ram_size; /* RAM size */ unsigned long reset_status; /* reset status register at boot */ + const void *fdt_blob; /* Our device tree, NULL if none */ void **jt; /* jump table */ char env_buf[32]; /* buffer for getenv() before reloc. */ } gd_t;

From: Gabe Black gabeblack@chromium.org
The device tree now includes the necessary console configuration information.
Signed-off-by: Gabe Black gabeblack@chromium.org Signed-off-by: Vadim Bendebury vbendeb@chromium.org
Signed-off-by: Simon Glass sjg@chromium.org --- board/chromebook-x86/dts/x86-alex.dts | 30 ++++++++++++++++++++++++++++++ 1 files changed, 30 insertions(+), 0 deletions(-) create mode 100644 board/chromebook-x86/dts/x86-alex.dts
diff --git a/board/chromebook-x86/dts/x86-alex.dts b/board/chromebook-x86/dts/x86-alex.dts new file mode 100644 index 0000000..bd90d18 --- /dev/null +++ b/board/chromebook-x86/dts/x86-alex.dts @@ -0,0 +1,30 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + model = "Google Alex"; + compatible = "google,alex", "intel,atom-pineview"; + + config { + silent_console = <0>; + }; + + aliases { + console = "/serial@e0401000"; + }; + + serial@e0401000 { + compatible = "ns16550"; + reg = <0xe0401000 0x40>; + id = <1>; + reg-shift = <1>; + baudrate = <115200>; + clock-frequency = <4000000>; + multiplier = <1>; + status = "ok"; + }; + + chosen { }; + memory { device_type = "memory"; reg = <0 0>; }; +};

From: Gabe Black gabeblack@chromium.org
This function provides an opportunity for some last minute cleanup and reconfiguration before control is handed over to Linux. It's possible this may need to do something in the future, but for now it's left empty. It's set up as a weak symbol so it can be overridden if necessary on a case by case basis.
Signed-off-by: Gabe Black gabeblack@chromium.org Signed-off-by: Simon Glass sjg@chromium.org --- arch/x86/cpu/cpu.c | 5 +++++ arch/x86/include/asm/u-boot-x86.h | 1 + 2 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/arch/x86/cpu/cpu.c b/arch/x86/cpu/cpu.c index e9bb0d7..e8bfe6f 100644 --- a/arch/x86/cpu/cpu.c +++ b/arch/x86/cpu/cpu.c @@ -121,6 +121,11 @@ void setup_gdt(gd_t *id, u64 *gdt_addr) load_fs(X86_GDT_ENTRY_32BIT_FS); }
+int __weak x86_cleanup_before_linux(void) +{ + return 0; +} + int x86_cpu_init_f(void) { const u32 em_rst = ~X86_CR0_EM; diff --git a/arch/x86/include/asm/u-boot-x86.h b/arch/x86/include/asm/u-boot-x86.h index 878a1ee..a4a5ae0 100644 --- a/arch/x86/include/asm/u-boot-x86.h +++ b/arch/x86/include/asm/u-boot-x86.h @@ -40,6 +40,7 @@ int cpu_init_f(void); void init_gd(gd_t *id, u64 *gdt_addr); void setup_gdt(gd_t *id, u64 *gdt_addr); int init_cache(void); +int cleanup_before_linux(void);
/* cpu/.../timer.c */ void timer_isr(void *);

From: Gabe Black gabeblack@chromium.org
The microsecond timer is not currently implemented, but add a dummy implementation for now.
Signed-off-by: Gabe Black gabeblack@chromium.org Signed-off-by: Simon Glass sjg@chromium.org --- arch/x86/cpu/Makefile | 2 +- arch/x86/cpu/timer.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletions(-) create mode 100644 arch/x86/cpu/timer.c
diff --git a/arch/x86/cpu/Makefile b/arch/x86/cpu/Makefile index 1eb70a7..cc68098 100644 --- a/arch/x86/cpu/Makefile +++ b/arch/x86/cpu/Makefile @@ -32,7 +32,7 @@ START = start.o ifneq ($(CONFIG_NO_RESET_CODE),y) START += resetvec.o start16.o endif -COBJS = interrupts.o cpu.o +COBJS = interrupts.o cpu.o timer.o
SRCS := $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS)) diff --git a/arch/x86/cpu/timer.c b/arch/x86/cpu/timer.c new file mode 100644 index 0000000..149109d --- /dev/null +++ b/arch/x86/cpu/timer.c @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2011 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + */ + +#include <common.h> + +unsigned long timer_get_us(void) +{ + printf("timer_get_us used but not implemented.\n"); + return 0; +}

From: Gabe Black gabeblack@chromium.org
If the device tree pointer isn't set to anything, which could happen if the device tree isn't found, for instance, or simply never set up, the pointer could be set to something arbitrary. This change forces initializes it to NULL so that it's more obviously not set.
Signed-off-by: Gabe Black gabeblack@chromium.org Signed-off-by: Simon Glass sjg@chromium.org --- arch/x86/cpu/cpu.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/arch/x86/cpu/cpu.c b/arch/x86/cpu/cpu.c index e8bfe6f..8b6d4cf 100644 --- a/arch/x86/cpu/cpu.c +++ b/arch/x86/cpu/cpu.c @@ -93,6 +93,7 @@ static void load_gdt(const u64 *boot_gdt, u16 num_entries) void init_gd(gd_t *id, u64 *gdt_addr) { id->gd_addr = (ulong)id; + gd->fdt_blob = NULL; setup_gdt(id, gdt_addr); }

From: Gabe Black gabeblack@chromium.org
The i386 version of io.h depends on the phys_addr_t type which is defined in types.h. It wasn't including that explicitly, and was working presumably because the other files including it had already included types.h themselves directly or indirectly. This change fixes that.
Signed-off-by: Gabe Black gabeblack@chromium.org Signed-off-by: Simon Glass sjg@chromium.org --- arch/x86/include/asm/io.h | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h index b12bdd8..2214958 100644 --- a/arch/x86/include/asm/io.h +++ b/arch/x86/include/asm/io.h @@ -36,6 +36,8 @@
#define IO_SPACE_LIMIT 0xffff
+#include <asm/types.h> +
#ifdef __KERNEL__

From: Stefan Reinauer reinauer@chromium.org
Fix a small comment typo.
Signed-off-by: Stefan Reinauer reinauer@chromium.org Signed-off-by: Simon Glass sjg@chromium.org --- arch/x86/lib/pcat_timer.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/arch/x86/lib/pcat_timer.c b/arch/x86/lib/pcat_timer.c index 6b3db69..b0b6637 100644 --- a/arch/x86/lib/pcat_timer.c +++ b/arch/x86/lib/pcat_timer.c @@ -39,7 +39,7 @@ int timer_init(void) * Timer 0 is used to increment system_tick 1000 times/sec * Timer 1 was used for DRAM refresh in early PC's * Timer 2 is used to drive the speaker - * (to stasrt a beep: write 3 to port 0x61, + * (to start a beep: write 3 to port 0x61, * to stop it again: write 0) */ outb(PIT_CMD_CTR0 | PIT_CMD_BOTH | PIT_CMD_MODE2,

This option protects the printf() functions from overflow.
Signed-off-by: Simon Glass sjg@chromium.org --- include/configs/coreboot.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/include/configs/coreboot.h b/include/configs/coreboot.h index fe589f3..56bc699 100644 --- a/include/configs/coreboot.h +++ b/include/configs/coreboot.h @@ -38,6 +38,7 @@ #undef CONFIG_SHOW_BOOT_PROGRESS #define CONFIG_LAST_STAGE_INIT #define CONFIG_NO_RESET_CODE +#define CONFIG_SYS_VSNPRINTF
#define CONFIG_STD_DEVICES_SETTINGS "stdin=usbkbd,vga,serial\0" \ "stdout=vga,serial,cbmem\0" \

From: Stefan Reinauer reinauer@chromium.org
This patch prevents u-boot from "spamming" random progress codes on a port 80 "post card". The previous version of this patch just removed the delays in the "slow" IO functions, as they do not need to be slow, however, this patch is less intrusive.
It uses another unused port that is often used by BIOSes (and the Linux Kernel) for small delay timing purposes.
Signed-off-by: Stefan Reinauer reinauer@chromium.org Signed-off-by: Simon Glass sjg@chromium.org --- arch/x86/include/asm/io.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h index 2214958..84a638d 100644 --- a/arch/x86/include/asm/io.h +++ b/arch/x86/include/asm/io.h @@ -137,7 +137,7 @@ out: #ifdef SLOW_IO_BY_JUMPING #define __SLOW_DOWN_IO "\njmp 1f\n1:\tjmp 1f\n1:" #else -#define __SLOW_DOWN_IO "\noutb %%al,$0x80" +#define __SLOW_DOWN_IO "\noutb %%al,$0xed" #endif
#ifdef REALLY_SLOW_IO
participants (1)
-
Simon Glass