Skip to contentSkip to conversation

x86: Patches to enable running U-Boot from coreboot

PATCH New Simon Glass 4 participants 33 messages Oct 10, 2012 – Nov 26, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover x86: Patches to enable running U-Boot from coreboot

This series carries on from Gabe Black's work to upstream support for running U-Boot from coreboot.

Aditional follow-on patches are also required, depending on feedback here.

Changes in v2:
- Put CONFIG_NO_RESET_CODE into Makefile instead of source files
- Add new patch to remove coreboot start16 code.

Gabe Black (4):
x86: Allow excluding reset vector code from u-boot
x86: Add some missing includes.
x86: coreboot: Tell u-boot about PCI bus 0 when initializing
x86: coreboot: Implement recursively scanning PCI busses

Simon Glass (4):
x86: Change board baud_rate to ulong
x86: Add initial memory barrier macros
x86: coreboot: Enable LPC TPM and CONFIG_NO_RESET_CODE
x86: Remove coreboot start16 code

Stefan Reinauer (1):
x86: coreboot: Move non-board specific files to coreboot arch
directory

Vadim Bendebury (1):
x86: coreboot: Modify u-boot code to allow building coreboot payload

 Makefile                                           |    7 +++-
 arch/x86/cpu/Makefile                              |    5 ++-
 arch/x86/cpu/coreboot/Makefile                     |    2 +
 .../x86/cpu}/coreboot/coreboot.c                   |    0
 .../coreboot_pci.c => arch/x86/cpu/coreboot/pci.c  |   35 ++++++++++++++++++
 arch/x86/cpu/u-boot.lds                            |    3 ++
 arch/x86/include/asm/global_data.h                 |    2 +
 arch/x86/include/asm/io.h                          |    8 ++++
 arch/x86/include/asm/pci.h                         |    2 +-
 arch/x86/include/asm/u-boot.h                      |    5 ++-
 board/chromebook-x86/coreboot/Makefile             |    2 -
 board/chromebook-x86/coreboot/config.mk            |   37 ++++++++++++++++++++
 board/chromebook-x86/coreboot/coreboot_start16.S   |   13 -------
 common/cmd_bdinfo.c                                |    2 +-
 include/configs/coreboot.h                         |    6 +++-
 15 files changed, 107 insertions(+), 22 deletions(-)
 rename {board/chromebook-x86 => arch/x86/cpu}/coreboot/coreboot.c (100%)
 rename board/chromebook-x86/coreboot/coreboot_pci.c => arch/x86/cpu/coreboot/pci.c (51%)
 create mode 100644 board/chromebook-x86/coreboot/config.mk
Signature · 1 line
1.7.7.3
#1 lore raw

PATCH v2 1/10 x86: Change board baud_rate to ulong

This is a ulong for some architectures and just unsigned for others. Change x86 to be consistent.

---

 arch/x86/include/asm/u-boot.h |    2 +-
 common/cmd_bdinfo.c           |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/u-boot.h +1 -1
index da667c5..0671b8d 100644
@@ -48,7 +48,7 @@ typedef struct bd_info {
 	unsigned short	bi_ethspeed;	/* Ethernet speed in Mbps */
 	unsigned long	bi_intfreq;	/* Internal Freq, in MHz */
 	unsigned long	bi_busfreq;	/* Bus Freq, in MHz */
-	unsigned int	bi_baudrate;	/* Console Baudrate */
+	unsigned long	bi_baudrate;	/* Console Baudrate */
 	unsigned long   bi_boot_params;	/* where this board expects params */
 	struct				/* RAM configuration */
 	{
common/cmd_bdinfo.c +1 -1
index 23bd8a5..9bc0ebc 100644
@@ -439,7 +439,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	printf("ip_addr     = %s\n", getenv("ipaddr"));
 	print_mhz("ethspeed",	    bd->bi_ethspeed);
 #endif
-	printf("baudrate    = %d bps\n", bd->bi_baudrate);
+	printf("baudrate    = %ld bps\n", bd->bi_baudrate);
 
 	return 0;
 }
Signature · 1 line
1.7.7.3
#2 lore raw

PATCH v2 1/10 x86: Change board baud_rate to ulong

Hi Simon,

Quoted 37 lines · Simon Glass

This is a ulong for some architectures and just unsigned for others. Change x86 to be consistent.

---

 arch/x86/include/asm/u-boot.h |    2 +-
 common/cmd_bdinfo.c           |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/u-boot.h +1 -1
index da667c5..0671b8d 100644
@@ -48,7 +48,7 @@ typedef struct bd_info {
        unsigned short  bi_ethspeed;    /* Ethernet speed in Mbps */
        unsigned long   bi_intfreq;     /* Internal Freq, in MHz */
        unsigned long   bi_busfreq;     /* Bus Freq, in MHz */
-       unsigned int    bi_baudrate;    /* Console Baudrate */
+       unsigned long   bi_baudrate;    /* Console Baudrate */
        unsigned long   bi_boot_params; /* where this board expects params */
        struct                          /* RAM configuration */
        {
common/cmd_bdinfo.c +1 -2
index 23bd8a5..9bc0ebc 100644
@@ -439,7 +439,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
        printf("ip_addr     = %s\n", getenv("ipaddr"));
        print_mhz("ethspeed",       bd->bi_ethspeed);
 #endif
-       printf("baudrate    = %d bps\n", bd->bi_baudrate);
+       printf("baudrate    = %ld bps\n", bd->bi_baudrate);
 
        return 0;
 }
--
Quoted 2 lines

1.7.7.3

#3 lore raw

PATCH v2 1/10 x86: Change board baud_rate to ulong

In reply to Simon Glass

Hi Simon,

Let's do it by the book this time :)

Quoted 37 lines · Simon Glass

This is a ulong for some architectures and just unsigned for others. Change x86 to be consistent.

---

 arch/x86/include/asm/u-boot.h |    2 +-
 common/cmd_bdinfo.c           |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/u-boot.h +1 -1
index da667c5..0671b8d 100644
@@ -48,7 +48,7 @@ typedef struct bd_info {
        unsigned short  bi_ethspeed;    /* Ethernet speed in Mbps */
        unsigned long   bi_intfreq;     /* Internal Freq, in MHz */
        unsigned long   bi_busfreq;     /* Bus Freq, in MHz */
-       unsigned int    bi_baudrate;    /* Console Baudrate */
+       unsigned long   bi_baudrate;    /* Console Baudrate */
        unsigned long   bi_boot_params; /* where this board expects params */
        struct                          /* RAM configuration */
        {
common/cmd_bdinfo.c +1 -2
index 23bd8a5..9bc0ebc 100644
@@ -439,7 +439,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
        printf("ip_addr     = %s\n", getenv("ipaddr"));
        print_mhz("ethspeed",       bd->bi_ethspeed);
 #endif
-       printf("baudrate    = %d bps\n", bd->bi_baudrate);
+       printf("baudrate    = %ld bps\n", bd->bi_baudrate);
 
        return 0;
 }
--
Quoted 2 lines

1.7.7.3

#4 lore raw

PATCH v2 1/10 x86: Change board baud_rate to ulong

In reply to Simon Glass

Dear Simon Glass,

Quoted 2 lines · In message <[email protected]> you wrote:

This is a ulong for some architectures and just unsigned for others. Change x86 to be consistent.

Given the limited range for this variable it makes no sense to use a long for this. Please fix this the other way round, i. e. change the architectures that use a long.

Thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Always try to do things in chronological order; it's  less  confusing
that way.
#5 lore raw

PATCH v2 1/10 x86: Change board baud_rate to ulong

Hi Wolfgang,

Quoted 10 lines · Wolfgang Denk

Dear Simon Glass,

Quoted 2 lines · In message <[email protected]> you wrote:

This is a ulong for some architectures and just unsigned for others. Change x86 to be consistent.

Given the limited range for this variable it makes no sense to use a long for this. Please fix this the other way round, i. e. change the architectures that use a long.

Will unsigned hold 115200?

Regards,

Graeme

#6 lore raw

PATCH v2 1/10 x86: Change board baud_rate to ulong

In reply to Wolfgang Denk

Hi Wolfgang,

Quoted 9 lines · Wolfgang Denk

Dear Simon Glass,

Quoted 2 lines · In message <[email protected]> you wrote:

This is a ulong for some architectures and just unsigned for others. Change x86 to be consistent.

Given the limited range for this variable it makes no sense to use a long for this. Please fix this the other way round, i. e. change the architectures that use a long.

OK I will send out a series that changes them to unsigned long.

This sort of thing relates to the unified board init series I was working on earlier it the year, since then all archs can use the same structures for generic fields like baud rate. I hope to get back to that one day.

Regards,
Simon

Quoted 13 lines

Thanks.

Best regards,

Wolfgang Denk

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Always try to do things in chronological order; it's less confusing that way.

#7 lore raw

PATCH v2 1/10 x86: Change board baud_rate to ulong

Hi Simon,

Quoted 6 lines · Simon Glass

Hi Wolfgang,

Quoted 3 lines · Wolfgang Denk

Dear Simon Glass,

In message <[email protected]> you wrote:

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

This is a ulong for some architectures and just unsigned for others. Change x86 to be consistent.

Given the limited range for this variable it makes no sense to use a long for this. Please fix this the other way round, i. e. change the architectures that use a long.

OK I will send out a series that changes them to unsigned long.

Should we just change them all to u32 to be clear on the value range?

Regards,

Graeme

#8 lore raw

PATCH v2 1/10 x86: Change board baud_rate to ulong

Hi,

Quoted 12 lines · Graeme Russ

Hi Simon,

Quoted 9 lines · Simon Glass

Hi Wolfgang,

Quoted 6 lines · Wolfgang Denk

Dear Simon Glass,

Quoted 2 lines · In message <[email protected]> you wrote:

This is a ulong for some architectures and just unsigned for others. Change x86 to be consistent.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Given the limited range for this variable it makes no sense to use a long for this. Please fix this the other way round, i. e. change the architectures that use a long.

OK I will send out a series that changes them to unsigned long.

Should we just change them all to u32 to be clear on the value range?

Sorry, I meant unsigned int.

Are there architectures in U-Boot which use a 16-bit int?

Regards,
Simon

Quoted 4 lines

Regards,

Graeme

#9 lore raw

PATCH v2 1/10 x86: Change board baud_rate to ulong

Hi Simon,

Quoted 19 lines · Simon Glass

Hi,

Quoted 16 lines · Graeme Russ

Hi Simon,

Quoted 13 lines · Simon Glass

Hi Wolfgang,

Quoted 9 lines · Wolfgang Denk

Dear Simon Glass,

Quoted 2 lines · In message <[email protected]> you wrote:

This is a ulong for some architectures and just unsigned for others. Change x86 to be consistent.

Given the limited range for this variable it makes no sense to use a long for this. Please fix this the other way round, i. e. change the architectures that use a long.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

OK I will send out a series that changes them to unsigned long.

Should we just change them all to u32 to be clear on the value range?

Sorry, I meant unsigned int.

Are there architectures in U-Boot which use a 16-bit int?

The C standard does not guarantee unsigned int will be at least 32-bits. It is possible (although I have not checked it) that compiling 'real-mode' x86 code can produce 16-bit ints (not that we do that in U-Boot)

using u32 will always guarantee a 32-bit unsigned value - better to be safe than sorry

Regards,

Graeme

#10 lore raw

PATCH v2 1/10 x86: Change board baud_rate to ulong

Hi Graham,

Quoted 30 lines · Graeme Russ

Hi Simon,

Quoted 19 lines · Simon Glass

Hi,

Quoted 16 lines · Graeme Russ

Hi Simon,

Quoted 13 lines · Simon Glass

Hi Wolfgang,

Quoted 9 lines · Wolfgang Denk

Dear Simon Glass,

Quoted 2 lines · In message <[email protected]> you wrote:

This is a ulong for some architectures and just unsigned for others. Change x86 to be consistent.

Given the limited range for this variable it makes no sense to use a long for this. Please fix this the other way round, i. e. change the architectures that use a long.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

OK I will send out a series that changes them to unsigned long.

Should we just change them all to u32 to be clear on the value range?

Sorry, I meant unsigned int.

Are there architectures in U-Boot which use a 16-bit int?

Quoted 8 lines

The C standard does not guarantee unsigned int will be at least 32-bits. It is possible (although I have not checked it) that compiling 'real-mode' x86 code can produce 16-bit ints (not that we do that in U-Boot)

using u32 will always guarantee a 32-bit unsigned value - better to be safe than sorry

That's fine, but what about all the other fields? Does the same apply here? It seems that everything uses 'unsigned int' for u32:

arch/nds32/include/asm/types.h:47:typedef unsigned int u32; arch/avr32/include/asm/types.h:65:typedef unsigned int u32; arch/arm/include/asm/types.h:37:typedef unsigned int u32; arch/sandbox/include/asm/types.h:59:typedef unsigned int u32; arch/blackfin/include/asm/types.h:70:typedef unsigned int u32; arch/openrisc/include/asm/types.h:64:typedef unsigned int u32; arch/mips/include/asm/types.h:62:typedef unsigned int u32; arch/x86/include/asm/types.h:37:typedef unsigned int u32; arch/nios2/include/asm/types.h:45:typedef unsigned int u32; arch/sh/include/asm/types.h:46:typedef unsigned int u32; arch/microblaze/include/asm/types.h:45:typedef unsigned int u32; arch/powerpc/include/asm/types.h:37:typedef unsigned int u32; arch/m68k/include/asm/types.h:37:typedef unsigned int u32; arch/sparc/include/asm/types.h:58:typedef unsigned int u32;

I wonder then if we need to decide which to use (int or long). I presume 'long' was used to cope with 16-bit machines, but we don't actually have any (which is presumably Wolfgang's point). If we don't have any, then 'int' is safe. I'm just a bit unsure about changing a single field in these two structures to u32, when all the others are unsigned long/short.

For example:

typedef struct bd_info {
int bi_baudrate; /* serial console baudrate */
ulong bi_arch_number; /* unique id for this board */
ulong bi_boot_params; /* where this board expects params */
unsigned long bi_arm_freq; /* arm frequency */
unsigned long bi_dsp_freq; /* dsp core frequency */
unsigned long bi_ddr_freq; /* ddr frequency */
struct /* RAM configuration */
{
ulong start;
ulong size;
} bi_dram[CONFIG_NR_DRAM_BANKS];
} bd_t;

typedef	struct	global_data {
	bd_t		*bd;
	unsigned long	flags;
	unsigned long	baudrate;
	unsigned long	have_console;	/* serial_init() was called */

#ifdef CONFIG_PRE_CONSOLE_BUFFER
unsigned long precon_buf_idx; /* Pre-Console buffer index */
#endif
unsigned long env_addr; /* Address of Environment struct */
unsigned long env_valid; /* Checksum of Environment valid? */
unsigned long fb_base; /* base address of frame buffer */

#ifdef CONFIG_FSL_ESDHC
	unsigned long	sdhc_clk;
#endif
#ifdef CONFIG_AT91FAMILY
	/* "static data" needed by at91's clock.c */
	unsigned long	cpu_clk_rate_hz;
	unsigned long	main_clk_rate_hz;
	unsigned long	mck_rate_hz;
	unsigned long	plla_rate_hz;
	unsigned long	pllb_rate_hz;
	unsigned long	at91_pllb_usb_init;
#endif
#ifdef CONFIG_ARM
	/* "static data" needed by most of timer.c on ARM platforms */
	unsigned long	timer_rate_hz;
	unsigned long	tbl;
	unsigned long	tbu;
	unsigned long long	timer_reset_value;
	unsigned long	lastinc;

Guidance appreciated!

....

Quoted 3 lines

Regards,

Graeme

Regards,
Simon

#11 lore raw

PATCH v2 2/10 x86: Add initial memory barrier macros

In reply to Simon Glass

These are available on other architectures, so add them on x86.

---

 arch/x86/include/asm/io.h |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
arch/x86/include/asm/io.h +8 -0
index 9b757d4..b12bdd8 100644
@@ -234,4 +234,12 @@ static inline phys_addr_t virt_to_phys(void * vaddr)
 	return (phys_addr_t)(vaddr);
 }
 
+/*
+ * TODO: The kernel offers some more advanced versions of barriers, it might
+ * have some advantages to use them instead of the simple one here.
+ */
+#define dmb()		__asm__ __volatile__ ("" : : : "memory")
+#define __iormb()	dmb()
+#define __iowmb()	dmb()
+
 #endif
Signature · 1 line
1.7.7.3
#12 lore raw

PATCH v2 2/10 x86: Add initial memory barrier macros

Hi Simon,

Quoted 26 lines · Simon Glass

These are available on other architectures, so add them on x86.

---

 arch/x86/include/asm/io.h |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
arch/x86/include/asm/io.h +8 -1
index 9b757d4..b12bdd8 100644
@@ -234,4 +234,12 @@ static inline phys_addr_t virt_to_phys(void * vaddr)
        return (phys_addr_t)(vaddr);
 }
 
+/*
+ * TODO: The kernel offers some more advanced versions of barriers, it might
+ * have some advantages to use them instead of the simple one here.
+ */
+#define dmb()          __asm__ __volatile__ ("" : : : "memory")
+#define __iormb()      dmb()
+#define __iowmb()      dmb()
+
 #endif
--
Quoted 2 lines

1.7.7.3

#13 lore raw

PATCH v2 3/10 x86: Allow excluding reset vector code from u-boot

In reply to Simon Glass

From: Gabe Black <[email protected]>

When running from coreboot we don't want this code.

This version works by ifdef-ing out all of the code that would go into those sections and all the code that refers to it. The sections are then empty, and the linker will either leave them empty for the loader to ignore or remove them entirely.

---
Changes in v2:
- Put CONFIG_NO_RESET_CODE into Makefile instead of source files

 Makefile                |    7 +++++--
 arch/x86/cpu/Makefile   |    5 ++++-
 arch/x86/cpu/u-boot.lds |    3 +++
 3 files changed, 12 insertions(+), 3 deletions(-)
Makefile +5 -2
index 34d9075..6c2f357 100644
@@ -212,9 +212,12 @@ endif
 # U-Boot objects....order is important (i.e. start must be first)
 
 OBJS  = $(CPUDIR)/start.o
+OBJS  = $(CPUDIR)/start.o
 ifeq ($(CPU),x86)
-OBJS += $(CPUDIR)/start16.o
-OBJS += $(CPUDIR)/resetvec.o
+	ifneq ($(CONFIG_NO_RESET_CODE),y)
+		OBJS += $(CPUDIR)/start16.o
+		OBJS += $(CPUDIR)/resetvec.o
+	endif
 endif
 ifeq ($(CPU),ppc4xx)
 OBJS += $(CPUDIR)/resetvec.o
arch/x86/cpu/Makefile +4 -1
index 7f1fc18..1eb70a7 100644
@@ -28,7 +28,10 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(CPU).o
 
-START	= start.o start16.o resetvec.o
+START	= start.o
+ifneq ($(CONFIG_NO_RESET_CODE),y)
+START	+= resetvec.o start16.o
+endif
 COBJS	= interrupts.o cpu.o
 
 SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
arch/x86/cpu/u-boot.lds +3 -0
index fe28030..2a90a01 100644
@@ -85,6 +85,8 @@ SECTIONS
 	__bios_start = LOADADDR(.bios);
 	__bios_size = SIZEOF(.bios);
 
+#ifndef CONFIG_NO_RESET_CODE
+
 	/*
 	 * The following expressions place the 16-bit Real-Mode code and
 	 * Reset Vector at the end of the Flash ROM
@@ -94,4 +96,5 @@ SECTIONS
 
 	. = RESET_VEC_LOC;
 	.resetvec : AT (CONFIG_SYS_TEXT_BASE + (CONFIG_SYS_MONITOR_LEN - RESET_SEG_SIZE + RESET_VEC_LOC)) { KEEP(*(.resetvec)); }
+#endif
 }
Signature · 1 line
1.7.7.3
#14 lore raw

PATCH v2 3/10 x86: Allow excluding reset vector code from u-boot

Hi Simon,

Quoted 75 lines · Simon Glass

From: Gabe Black <[email protected]>

When running from coreboot we don't want this code.

This version works by ifdef-ing out all of the code that would go into those sections and all the code that refers to it. The sections are then empty, and the linker will either leave them empty for the loader to ignore or remove them entirely.

---
Changes in v2:
- Put CONFIG_NO_RESET_CODE into Makefile instead of source files

 Makefile                |    7 +++++--
 arch/x86/cpu/Makefile   |    5 ++++-
 arch/x86/cpu/u-boot.lds |    3 +++
 3 files changed, 12 insertions(+), 3 deletions(-)
Makefile +5 -2
index 34d9075..6c2f357 100644
@@ -212,9 +212,12 @@ endif
 # U-Boot objects....order is important (i.e. start must be first)
 
 OBJS  = $(CPUDIR)/start.o
+OBJS  = $(CPUDIR)/start.o
 ifeq ($(CPU),x86)
-OBJS += $(CPUDIR)/start16.o
-OBJS += $(CPUDIR)/resetvec.o
+       ifneq ($(CONFIG_NO_RESET_CODE),y)
+               OBJS += $(CPUDIR)/start16.o
+               OBJS += $(CPUDIR)/resetvec.o
+       endif
 endif
 ifeq ($(CPU),ppc4xx)
 OBJS += $(CPUDIR)/resetvec.o
arch/x86/cpu/Makefile +4 -1
index 7f1fc18..1eb70a7 100644
@@ -28,7 +28,10 @@ include $(TOPDIR)/config.mk
 
 LIB    = $(obj)lib$(CPU).o
 
-START  = start.o start16.o resetvec.o
+START  = start.o
+ifneq ($(CONFIG_NO_RESET_CODE),y)
+START  += resetvec.o start16.o
+endif
 COBJS  = interrupts.o cpu.o
 
 SRCS   := $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
arch/x86/cpu/u-boot.lds +3 -1
index fe28030..2a90a01 100644
@@ -85,6 +85,8 @@ SECTIONS
        __bios_start = LOADADDR(.bios);
        __bios_size = SIZEOF(.bios);
 
+#ifndef CONFIG_NO_RESET_CODE
+
        /*
         * The following expressions place the 16-bit Real-Mode code and
         * Reset Vector at the end of the Flash ROM
@@ -94,4 +96,5 @@ SECTIONS
 
        . = RESET_VEC_LOC;
        .resetvec : AT (CONFIG_SYS_TEXT_BASE + (CONFIG_SYS_MONITOR_LEN - RESET_SEG_SIZE + RESET_VEC_LOC)) { KEEP(*(.resetvec)); }
+#endif
 }
--
Quoted 2 lines

1.7.7.3

#15 lore raw

PATCH v2 3/10 x86: Allow excluding reset vector code from u-boot

In reply to Simon Glass

Dear Simon Glass,

Quoted 9 lines · In message <[email protected]> you wrote:

From: Gabe Black <[email protected]>

When running from coreboot we don't want this code.

This version works by ifdef-ing out all of the code that would go into those sections and all the code that refers to it. The sections are then empty, and the linker will either leave them empty for the loader to ignore or remove them entirely.

Quoted 5 lines

---
Changes in v2:
- Put CONFIG_NO_RESET_CODE into Makefile instead of source files

What exactly is CONFIG_NO_RESET_CODE ?

There is no documentation anywhere for such a config option as is mandatory when introducing it, nor is there any comment why it would be needed, nor are there any users for it.

Quoted 11 lines
 Makefile                |    7 +++++--
 arch/x86/cpu/Makefile   |    5 ++++-
 arch/x86/cpu/u-boot.lds |    3 +++
 3 files changed, 12 insertions(+), 3 deletions(-)
Makefile +0 -0
index 34d9075..6c2f357 100644
@@ -212,9 +212,12 @@ endif
 # U-Boot objects....order is important (i.e. start must be first)

Makefile endif · line 220

Quoted 10 lines
Makefile +5 -2
 
 OBJS  = $(CPUDIR)/start.o
+OBJS  = $(CPUDIR)/start.o
 ifeq ($(CPU),x86)
-OBJS += $(CPUDIR)/start16.o
-OBJS += $(CPUDIR)/resetvec.o
+	ifneq ($(CONFIG_NO_RESET_CODE),y)
+		OBJS += $(CPUDIR)/start16.o
+		OBJS += $(CPUDIR)/resetvec.o
+	endif

NAK. Bad indentation, and please do without 'if's or the like.

arch/x86/cpu/Makefile include $(TOPDIR)/config.mk · line 34

Quoted 11 lines
arch/x86/cpu/Makefile +4 -1
@@ -28,7 +28,10 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(CPU).o
 
-START	= start.o start16.o resetvec.o
+START	= start.o
+ifneq ($(CONFIG_NO_RESET_CODE),y)
+START	+= resetvec.o start16.o
+endif

Ditto.

arch/x86/cpu/u-boot.lds SECTIONS · line 88

Quoted 7 lines
arch/x86/cpu/u-boot.lds +1 -0
@@ -85,6 +85,8 @@ SECTIONS
 	__bios_start = LOADADDR(.bios);
 	__bios_size = SIZEOF(.bios);
 
+#ifndef CONFIG_NO_RESET_CODE

Undocumented.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
If I can have honesty, it's easier to overlook mistakes.
	-- Kirk, "Space Seed", stardate 3141.9
#16 lore raw

PATCH v2 3/10 x86: Allow excluding reset vector code from u-boot

Hi Wolfgang,

Quoted 18 lines · Wolfgang Denk

Dear Simon Glass,

Quoted 9 lines · In message <[email protected]> you wrote:

From: Gabe Black <[email protected]>

When running from coreboot we don't want this code.

This version works by ifdef-ing out all of the code that would go into those sections and all the code that refers to it. The sections are then empty, and the linker will either leave them empty for the loader to ignore or remove them entirely.

Quoted 5 lines

---
Changes in v2:
- Put CONFIG_NO_RESET_CODE into Makefile instead of source files

Quoted 6 lines

What exactly is CONFIG_NO_RESET_CODE ?

There is no documentation anywhere for such a config option as is mandatory when introducing it, nor is there any comment why it would be needed, nor are there any users for it.

Based on your comments I will come up with another way of doing this and send a new patch.

Quoted 52 lines
Quoted 12 lines
 Makefile                |    7 +++++--
 arch/x86/cpu/Makefile   |    5 ++++-
 arch/x86/cpu/u-boot.lds |    3 +++
 3 files changed, 12 insertions(+), 3 deletions(-)
Makefile +0 -0
index 34d9075..6c2f357 100644
@@ -212,9 +212,12 @@ endif
 # U-Boot objects....order is important (i.e. start must be first)

Makefile endif · line 220

Quoted 10 lines
Makefile +5 -2
 
 OBJS  = $(CPUDIR)/start.o
+OBJS  = $(CPUDIR)/start.o
 ifeq ($(CPU),x86)
-OBJS += $(CPUDIR)/start16.o
-OBJS += $(CPUDIR)/resetvec.o
+     ifneq ($(CONFIG_NO_RESET_CODE),y)
+             OBJS += $(CPUDIR)/start16.o
+             OBJS += $(CPUDIR)/resetvec.o
+     endif

NAK. Bad indentation, and please do without 'if's or the like.

arch/x86/cpu/Makefile include $(TOPDIR)/config.mk · line 34

Quoted 11 lines
arch/x86/cpu/Makefile +4 -1
@@ -28,7 +28,10 @@ include $(TOPDIR)/config.mk
 
 LIB  = $(obj)lib$(CPU).o
 
-START        = start.o start16.o resetvec.o
+START        = start.o
+ifneq ($(CONFIG_NO_RESET_CODE),y)
+START        += resetvec.o start16.o
+endif

Ditto.

arch/x86/cpu/u-boot.lds SECTIONS · line 88

Quoted 7 lines
arch/x86/cpu/u-boot.lds +1 -0
@@ -85,6 +85,8 @@ SECTIONS
      __bios_start = LOADADDR(.bios);
      __bios_size = SIZEOF(.bios);
 
+#ifndef CONFIG_NO_RESET_CODE

Undocumented.

Best regards,

Quoted 8 lines

Wolfgang Denk

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de If I can have honesty, it's easier to overlook mistakes.

        -- Kirk, "Space Seed", stardate 3141.9

Regards,
Simon

#17 lore raw

PATCH v2 4/10 x86: Add some missing includes.

In reply to Simon Glass

From: Gabe Black <[email protected]>

I suspect these includes were usually available because something else included them earlier or because they were brought in transitively.

---

 arch/x86/include/asm/global_data.h |    2 ++
 arch/x86/include/asm/u-boot.h      |    3 +++
 2 files changed, 5 insertions(+), 0 deletions(-)
arch/x86/include/asm/global_data.h +2 -0
index 6d29c0b..3c79508 100644
@@ -33,6 +33,8 @@
 
 #ifndef __ASSEMBLY__
 
+#include <asm/u-boot.h>
+
 typedef	struct global_data {
 	/* NOTE: gd_addr MUST be first member of struct global_data! */
 	unsigned long	gd_addr;	/* Location of Global Data */
arch/x86/include/asm/u-boot.h +3 -0
index 0671b8d..e2ba845 100644
@@ -36,6 +36,9 @@
 #ifndef _U_BOOT_H_
 #define _U_BOOT_H_	1
 
+#include <config.h>
+#include <compiler.h>
+
 typedef struct bd_info {
 	unsigned long	bi_memstart;	/* start of DRAM memory */
 	phys_size_t	bi_memsize;	/* size	 of DRAM memory in bytes */
Signature · 1 line
1.7.7.3
#18 lore raw

PATCH v2 4/10 x86: Add some missing includes.

Hi Simon,

Quoted 41 lines · Simon Glass

From: Gabe Black <[email protected]>

I suspect these includes were usually available because something else included them earlier or because they were brought in transitively.

---

 arch/x86/include/asm/global_data.h |    2 ++
 arch/x86/include/asm/u-boot.h      |    3 +++
 2 files changed, 5 insertions(+), 0 deletions(-)
arch/x86/include/asm/global_data.h +2 -0
index 6d29c0b..3c79508 100644
@@ -33,6 +33,8 @@
 
 #ifndef __ASSEMBLY__
 
+#include <asm/u-boot.h>
+
 typedef        struct global_data {
        /* NOTE: gd_addr MUST be first member of struct global_data! */
        unsigned long   gd_addr;        /* Location of Global Data */
arch/x86/include/asm/u-boot.h +3 -1
index 0671b8d..e2ba845 100644
@@ -36,6 +36,9 @@
 #ifndef _U_BOOT_H_
 #define _U_BOOT_H_     1
 
+#include <config.h>
+#include <compiler.h>
+
 typedef struct bd_info {
        unsigned long   bi_memstart;    /* start of DRAM memory */
        phys_size_t     bi_memsize;     /* size  of DRAM memory in bytes */
--
Quoted 2 lines

1.7.7.3

#19 lore raw

PATCH v2 5/10 x86: coreboot: Move non-board specific files to coreboot arch directory

In reply to Simon Glass

From: Stefan Reinauer <[email protected]>

coreboot.c and coreboot_pci.c don't contain board specific but only coreboot specific code. Hence move it to the coreboot directory in arch/x86/cpu (which should probably be moved out of cpu/ in another commit)

---

 arch/x86/cpu/coreboot/Makefile                     |    2 ++
 .../x86/cpu}/coreboot/coreboot.c                   |    0
 .../coreboot_pci.c => arch/x86/cpu/coreboot/pci.c  |    0
 board/chromebook-x86/coreboot/Makefile             |    2 --
 4 files changed, 2 insertions(+), 2 deletions(-)
 rename {board/chromebook-x86 => arch/x86/cpu}/coreboot/coreboot.c (100%)
 rename board/chromebook-x86/coreboot/coreboot_pci.c => arch/x86/cpu/coreboot/pci.c (100%)
arch/x86/cpu/coreboot/Makefile +2 -0
index 13f5f8a..fbf5a00 100644
@@ -33,10 +33,12 @@ include $(TOPDIR)/config.mk
 
 LIB	:= $(obj)lib$(SOC).o
 
+COBJS-$(CONFIG_SYS_COREBOOT) += coreboot.o
 COBJS-$(CONFIG_SYS_COREBOOT) += tables.o
 COBJS-$(CONFIG_SYS_COREBOOT) += ipchecksum.o
 COBJS-$(CONFIG_SYS_COREBOOT) += sdram.o
 COBJS-$(CONFIG_SYS_COREBOOT) += sysinfo.o
+COBJS-$(CONFIG_PCI) += pci.o
 
 SOBJS-$(CONFIG_SYS_COREBOOT) += coreboot_car.o
 
arch/x86/cpu/coreboot/coreboot.c renamed from board/chromebook-x86/coreboot/coreboot.c +0 -0
similarity index 100%
rename from board/chromebook-x86/coreboot/coreboot.c
rename to arch/x86/cpu/coreboot/coreboot.c
arch/x86/cpu/coreboot/pci.c renamed from board/chromebook-x86/coreboot/coreboot_pci.c +0 -0
similarity index 100%
rename from board/chromebook-x86/coreboot/coreboot_pci.c
rename to arch/x86/cpu/coreboot/pci.c
board/chromebook-x86/coreboot/Makefile +0 -2
index cfcc0df..2bddf04 100644
@@ -32,8 +32,6 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(BOARD).o
 
-COBJS-y	+= coreboot.o
-COBJS-$(CONFIG_PCI) += coreboot_pci.o
 SOBJS-y	+= coreboot_start16.o
 SOBJS-y	+= coreboot_start.o
 
Signature · 1 line
1.7.7.3
#20 lore raw

PATCH v2 5/10 x86: coreboot: Move non-board specific files to coreboot arch directory

Hi Simon,

Quoted 58 lines · Simon Glass

From: Stefan Reinauer <[email protected]>

coreboot.c and coreboot_pci.c don't contain board specific but only coreboot specific code. Hence move it to the coreboot directory in arch/x86/cpu (which should probably be moved out of cpu/ in another commit)

---

 arch/x86/cpu/coreboot/Makefile                     |    2 ++
 .../x86/cpu}/coreboot/coreboot.c                   |    0
 .../coreboot_pci.c => arch/x86/cpu/coreboot/pci.c  |    0
 board/chromebook-x86/coreboot/Makefile             |    2 --
 4 files changed, 2 insertions(+), 2 deletions(-)
 rename {board/chromebook-x86 => arch/x86/cpu}/coreboot/coreboot.c (100%)
 rename board/chromebook-x86/coreboot/coreboot_pci.c => arch/x86/cpu/coreboot/pci.c (100%)
arch/x86/cpu/coreboot/Makefile +2 -0
index 13f5f8a..fbf5a00 100644
@@ -33,10 +33,12 @@ include $(TOPDIR)/config.mk
 
 LIB    := $(obj)lib$(SOC).o
 
+COBJS-$(CONFIG_SYS_COREBOOT) += coreboot.o
 COBJS-$(CONFIG_SYS_COREBOOT) += tables.o
 COBJS-$(CONFIG_SYS_COREBOOT) += ipchecksum.o
 COBJS-$(CONFIG_SYS_COREBOOT) += sdram.o
 COBJS-$(CONFIG_SYS_COREBOOT) += sysinfo.o
+COBJS-$(CONFIG_PCI) += pci.o
 
 SOBJS-$(CONFIG_SYS_COREBOOT) += coreboot_car.o
 
arch/x86/cpu/coreboot/coreboot.c renamed from board/chromebook-x86/coreboot/coreboot.c +0 -0
similarity index 100%
rename from board/chromebook-x86/coreboot/coreboot.c
rename to arch/x86/cpu/coreboot/coreboot.c
arch/x86/cpu/coreboot/pci.c renamed from board/chromebook-x86/coreboot/coreboot_pci.c +0 -0
similarity index 100%
rename from board/chromebook-x86/coreboot/coreboot_pci.c
rename to arch/x86/cpu/coreboot/pci.c
board/chromebook-x86/coreboot/Makefile +0 -3
index cfcc0df..2bddf04 100644
@@ -32,8 +32,6 @@ include $(TOPDIR)/config.mk
 
 LIB    = $(obj)lib$(BOARD).o
 
-COBJS-y        += coreboot.o
-COBJS-$(CONFIG_PCI) += coreboot_pci.o
 SOBJS-y        += coreboot_start16.o
 SOBJS-y        += coreboot_start.o
 
--
Quoted 2 lines

1.7.7.3

#21 lore raw

PATCH v2 6/10 x86: coreboot: Tell u-boot about PCI bus 0 when initializing

In reply to Simon Glass

From: Gabe Black <[email protected]>

U-boot needs a host controller or "hose" to interact with the PCI busses behind them. This change installs a host controller during initialization of the coreboot "board" which implements some of X86's basic PCI semantics. This relies on some existing generic code, but also duplicates a little bit of code from the sc520 implementation. Ideally we'd eliminate that duplication at some point.

It looks like in order to scan buses beyond bus 0, we'll need to tell u-boot's generic PCI configuration code what to do if it encounters a bridge, specifically to scan the bus on the other side of it.

---

 arch/x86/cpu/coreboot/pci.c |   15 +++++++++++++++
 arch/x86/include/asm/pci.h  |    2 +-
 2 files changed, 16 insertions(+), 1 deletions(-)
arch/x86/cpu/coreboot/pci.c +15 -0
index 732ca3c..0ddc975 100644
@@ -25,6 +25,21 @@
  * MA 02111-1307 USA
  */
 
+#include <common.h>
+#include <pci.h>
+#include <asm/pci.h>
+
+static struct pci_controller coreboot_hose;
+
 void pci_init_board(void)
 {
+	coreboot_hose.first_busno = 0;
+	coreboot_hose.last_busno = 0xff;
+	coreboot_hose.region_count = 0;
+
+	pci_setup_type1(&coreboot_hose);
+
+	pci_register_hose(&coreboot_hose);
+
+	coreboot_hose.last_busno = pci_hose_scan(&coreboot_hose);
 }
arch/x86/include/asm/pci.h +1 -1
index 37cc7e3..6d68ab6 100644
@@ -24,7 +24,7 @@
  */
 
 #ifndef _PCI_I386_H_
-#define _PCI_I386_H_	1
+#define _PCI_I386_H_
 
 #define DEFINE_PCI_DEVICE_TABLE(_table) \
 	const struct pci_device_id _table[]
Signature · 1 line
1.7.7.3
#22 lore raw

PATCH v2 6/10 x86: coreboot: Tell u-boot about PCI bus 0 when initializing

Hi Simon,

Quoted 61 lines · Simon Glass

From: Gabe Black <[email protected]>

U-boot needs a host controller or "hose" to interact with the PCI busses behind them. This change installs a host controller during initialization of the coreboot "board" which implements some of X86's basic PCI semantics. This relies on some existing generic code, but also duplicates a little bit of code from the sc520 implementation. Ideally we'd eliminate that duplication at some point.

It looks like in order to scan buses beyond bus 0, we'll need to tell u-boot's generic PCI configuration code what to do if it encounters a bridge, specifically to scan the bus on the other side of it.

---

 arch/x86/cpu/coreboot/pci.c |   15 +++++++++++++++
 arch/x86/include/asm/pci.h  |    2 +-
 2 files changed, 16 insertions(+), 1 deletions(-)
arch/x86/cpu/coreboot/pci.c +15 -0
index 732ca3c..0ddc975 100644
@@ -25,6 +25,21 @@
  * MA 02111-1307 USA
  */
 
+#include <common.h>
+#include <pci.h>
+#include <asm/pci.h>
+
+static struct pci_controller coreboot_hose;
+
 void pci_init_board(void)
 {
+       coreboot_hose.first_busno = 0;
+       coreboot_hose.last_busno = 0xff;
+       coreboot_hose.region_count = 0;
+
+       pci_setup_type1(&coreboot_hose);
+
+       pci_register_hose(&coreboot_hose);
+
+       coreboot_hose.last_busno = pci_hose_scan(&coreboot_hose);
 }
arch/x86/include/asm/pci.h +1 -2
index 37cc7e3..6d68ab6 100644
@@ -24,7 +24,7 @@
  */
 
 #ifndef _PCI_I386_H_
-#define _PCI_I386_H_   1
+#define _PCI_I386_H_
 
 #define DEFINE_PCI_DEVICE_TABLE(_table) \
        const struct pci_device_id _table[]
--
Quoted 2 lines

1.7.7.3

#23 lore raw

PATCH v2 7/10 x86: coreboot: Modify u-boot code to allow building coreboot payload

In reply to Simon Glass

From: Vadim Bendebury <[email protected]>

This prevents the preprocessor from complaining when processing variadic macros

---

 board/chromebook-x86/coreboot/config.mk |   37 +++++++++++++++++++++++++++++++
 1 files changed, 37 insertions(+), 0 deletions(-)
 create mode 100644 board/chromebook-x86/coreboot/config.mk
board/chromebook-x86/coreboot/config.mk new file +37 -0
new file mode 100644
index 0000000..f720851
@@ -0,0 +1,37 @@
+#
+# 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.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# 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.
+#
+
+HOSTCFLAGS_autoconf.mk.dep = -Wno-variadic-macros
Signature · 1 line
1.7.7.3
#24 lore raw

PATCH v2 7/10 x86: coreboot: Modify u-boot code to allow building coreboot payload

Hi Simon,

Quoted 57 lines · Simon Glass

From: Vadim Bendebury <[email protected]>

This prevents the preprocessor from complaining when processing variadic macros

---

 board/chromebook-x86/coreboot/config.mk |   37 +++++++++++++++++++++++++++++++
 1 files changed, 37 insertions(+), 0 deletions(-)
 create mode 100644 board/chromebook-x86/coreboot/config.mk
board/chromebook-x86/coreboot/config.mk new file +37 -1
new file mode 100644
index 0000000..f720851
@@ -0,0 +1,37 @@
+#
+# 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.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# 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.
+#
+
+HOSTCFLAGS_autoconf.mk.dep = -Wno-variadic-macros
--
Quoted 2 lines

1.7.7.3

#25 lore raw

PATCH v2 8/10 x86: coreboot: Implement recursively scanning PCI busses

In reply to Simon Glass

From: Gabe Black <[email protected]>

A hook is installed to configure PCI bus bridges as they encountered by u-boot. The hook extracts the secondary bus number from the bridge's config space and then recursively scans that bus.

On Coreboot, the PCI bus address space has identity mapping with the physical address space, so declare it as such to ensure that the "pci_map_bar" function used by some PCI drivers is behaving properly. This fixes the EHCI PCI driver initialization on Stumpy.

This was tested as follows:

Ran the PCI command on Alex, saw devices on bus 0, the OXPCIe 952 on bus 1, and empty busses 2 through 5. This matches the bridges reported on bus 0 and the PCI configuration output from coreboot.

---

 arch/x86/cpu/coreboot/pci.c |   26 +++++++++++++++++++++++---
 1 files changed, 23 insertions(+), 3 deletions(-)
arch/x86/cpu/coreboot/pci.c +23 -3
index 0ddc975..8f94167 100644
@@ -31,15 +31,35 @@
 
 static struct pci_controller coreboot_hose;
 
+static void config_pci_bridge(struct pci_controller *hose, pci_dev_t dev,
+			      struct pci_config_table *table)
+{
+	u8 secondary;
+	hose->read_byte(hose, dev, PCI_SECONDARY_BUS, &secondary);
+	hose->last_busno = max(hose->last_busno, secondary);
+	pci_hose_scan_bus(hose, secondary);
+}
+
+static struct pci_config_table pci_coreboot_config_table[] = {
+	/* vendor, device, class, bus, dev, func */
+	{ PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_BRIDGE_PCI,
+		PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, &config_pci_bridge },
+	{}
+};
+
 void pci_init_board(void)
 {
+	coreboot_hose.config_table = pci_coreboot_config_table;
 	coreboot_hose.first_busno = 0;
-	coreboot_hose.last_busno = 0xff;
-	coreboot_hose.region_count = 0;
+	coreboot_hose.last_busno = 0;
+
+	pci_set_region(coreboot_hose.regions + 0, 0x0, 0x0, 0xffffffff,
+		PCI_REGION_MEM);
+	coreboot_hose.region_count = 1;
 
 	pci_setup_type1(&coreboot_hose);
 
 	pci_register_hose(&coreboot_hose);
 
-	coreboot_hose.last_busno = pci_hose_scan(&coreboot_hose);
+	pci_hose_scan(&coreboot_hose);
 }
Signature · 1 line
1.7.7.3
#26 lore raw

PATCH v2 8/10 x86: coreboot: Implement recursively scanning PCI busses

Hi Simon,

Quoted 70 lines · Simon Glass

From: Gabe Black <[email protected]>

A hook is installed to configure PCI bus bridges as they encountered by u-boot. The hook extracts the secondary bus number from the bridge's config space and then recursively scans that bus.

On Coreboot, the PCI bus address space has identity mapping with the physical address space, so declare it as such to ensure that the "pci_map_bar" function used by some PCI drivers is behaving properly. This fixes the EHCI PCI driver initialization on Stumpy.

This was tested as follows:

Ran the PCI command on Alex, saw devices on bus 0, the OXPCIe 952 on bus 1, and empty busses 2 through 5. This matches the bridges reported on bus 0 and the PCI configuration output from coreboot.

---

 arch/x86/cpu/coreboot/pci.c |   26 +++++++++++++++++++++++---
 1 files changed, 23 insertions(+), 3 deletions(-)
arch/x86/cpu/coreboot/pci.c +23 -4
index 0ddc975..8f94167 100644
@@ -31,15 +31,35 @@
 
 static struct pci_controller coreboot_hose;
 
+static void config_pci_bridge(struct pci_controller *hose, pci_dev_t dev,
+                             struct pci_config_table *table)
+{
+       u8 secondary;
+       hose->read_byte(hose, dev, PCI_SECONDARY_BUS, &secondary);
+       hose->last_busno = max(hose->last_busno, secondary);
+       pci_hose_scan_bus(hose, secondary);
+}
+
+static struct pci_config_table pci_coreboot_config_table[] = {
+       /* vendor, device, class, bus, dev, func */
+       { PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_BRIDGE_PCI,
+               PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, &config_pci_bridge },
+       {}
+};
+
 void pci_init_board(void)
 {
+       coreboot_hose.config_table = pci_coreboot_config_table;
        coreboot_hose.first_busno = 0;
-       coreboot_hose.last_busno = 0xff;
-       coreboot_hose.region_count = 0;
+       coreboot_hose.last_busno = 0;
+
+       pci_set_region(coreboot_hose.regions + 0, 0x0, 0x0, 0xffffffff,
+               PCI_REGION_MEM);
+       coreboot_hose.region_count = 1;
 
        pci_setup_type1(&coreboot_hose);
 
        pci_register_hose(&coreboot_hose);
 
-       coreboot_hose.last_busno = pci_hose_scan(&coreboot_hose);
+       pci_hose_scan(&coreboot_hose);
 }
--
Quoted 2 lines

1.7.7.3

#27 lore raw

PATCH v2 9/10 x86: coreboot: Enable LPC TPM and CONFIG_NO_RESET_CODE

In reply to Simon Glass

Coreboot boards have an LPC TPM connected, so enable this. We also need to skip the reset code.

---

 include/configs/coreboot.h |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
include/configs/coreboot.h +5 -1
index 2c65d74..75db176 100644
@@ -37,7 +37,7 @@
 #define CONFIG_SYS_COREBOOT
 #undef CONFIG_SHOW_BOOT_PROGRESS
 #define CONFIG_LAST_STAGE_INIT
-
+#define CONFIG_NO_RESET_CODE
 
 /*-----------------------------------------------------------------------
  * Watchdog Configuration
@@ -45,6 +45,10 @@
 #undef CONFIG_WATCHDOG
 #undef CONFIG_HW_WATCHDOG
 
+/* Generic TPM interfaced through LPC bus */
+#define CONFIG_GENERIC_LPC_TPM
+#define CONFIG_TPM_TIS_BASE_ADDRESS        0xfed40000
+
 /*-----------------------------------------------------------------------
  * Real Time Clock Configuration
  */
Signature · 1 line
1.7.7.3
#28 lore raw

PATCH v2 9/10 x86: coreboot: Enable LPC TPM and CONFIG_NO_RESET_CODE

Hi Simon,

Quoted 34 lines · Simon Glass

Coreboot boards have an LPC TPM connected, so enable this. We also need to skip the reset code.

---

 include/configs/coreboot.h |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
include/configs/coreboot.h +5 -2
index 2c65d74..75db176 100644
@@ -37,7 +37,7 @@
 #define CONFIG_SYS_COREBOOT
 #undef CONFIG_SHOW_BOOT_PROGRESS
 #define CONFIG_LAST_STAGE_INIT
-
+#define CONFIG_NO_RESET_CODE
 
 /*-----------------------------------------------------------------------
  * Watchdog Configuration
@@ -45,6 +45,10 @@
 #undef CONFIG_WATCHDOG
 #undef CONFIG_HW_WATCHDOG
 
+/* Generic TPM interfaced through LPC bus */
+#define CONFIG_GENERIC_LPC_TPM
+#define CONFIG_TPM_TIS_BASE_ADDRESS        0xfed40000
+
 /*-----------------------------------------------------------------------
  * Real Time Clock Configuration
  */
--
Quoted 2 lines

1.7.7.3

#29 lore raw

PATCH v2 9/10 x86: coreboot: Enable LPC TPM and CONFIG_NO_RESET_CODE

Dear Graeme Russ,

Quoted 43 lines

Hi Simon,

Quoted 40 lines · Simon Glass

Coreboot boards have an LPC TPM connected, so enable this. We also need to skip the reset code.

---

 include/configs/coreboot.h |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
include/configs/coreboot.h +1 -1
index 2c65d74..75db176 100644
@@ -37,7 +37,7 @@
 
 #define CONFIG_SYS_COREBOOT
 #undef CONFIG_SHOW_BOOT_PROGRESS
 #define CONFIG_LAST_STAGE_INIT
 
-
+#define CONFIG_NO_RESET_CODE
 

/*---------------------------------------------------------------------- -

* Watchdog Configuration

include/configs/coreboot.h +4 -0
@@ -45,6 +45,10 @@
 
 #undef CONFIG_WATCHDOG
 #undef CONFIG_HW_WATCHDOG
 
+/* Generic TPM interfaced through LPC bus */
+#define CONFIG_GENERIC_LPC_TPM
+#define CONFIG_TPM_TIS_BASE_ADDRESS        0xfed40000
+
 
 /*----------------------------------------------------------------------

-

Quoted 7 lines
Quoted 5 lines

* Real Time Clock Configuration
*/

--
1.7.7.3

Well, spliting it into two patches -- since each hunk does something else -- won't hurt. But I think it doesn't matter.

Best regards,
Marek Vasut

#30 lore raw

PATCH v2 9/10 x86: coreboot: Enable LPC TPM and CONFIG_NO_RESET_CODE

Hi Marek,

Quoted 48 lines · Marek Vasut

Dear Graeme Russ,

Quoted 46 lines

Hi Simon,

Quoted 43 lines · Simon Glass

Coreboot boards have an LPC TPM connected, so enable this. We also need to skip the reset code.

---

 include/configs/coreboot.h |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
include/configs/coreboot.h +1 -1
index 2c65d74..75db176 100644
@@ -37,7 +37,7 @@
 
 #define CONFIG_SYS_COREBOOT
 #undef CONFIG_SHOW_BOOT_PROGRESS
 #define CONFIG_LAST_STAGE_INIT
 
-
+#define CONFIG_NO_RESET_CODE
 

/*---------------------------------------------------------------------- -

* Watchdog Configuration

include/configs/coreboot.h +4 -0
@@ -45,6 +45,10 @@
 
 #undef CONFIG_WATCHDOG
 #undef CONFIG_HW_WATCHDOG
 
+/* Generic TPM interfaced through LPC bus */
+#define CONFIG_GENERIC_LPC_TPM
+#define CONFIG_TPM_TIS_BASE_ADDRESS        0xfed40000
+
 
 /*----------------------------------------------------------------------

-

* Real Time Clock Configuration
*/

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

--
1.7.7.3

Well, spliting it into two patches -- since each hunk does something else -- won't hurt. But I think it doesn't matter.

It's board level config - I see no reason to atomise it. If it was global / arch / SoC / CPU level then I would to help maintain bisectability.

Regards,

Graeme

#31 lore raw

PATCH v2 10/10 x86: Remove coreboot start16 code

In reply to Simon Glass

Now that coreboot doesn't need the start16 code, remove it.

---
Changes in v2:
- Add new patch to remove coreboot start16 code.

 board/chromebook-x86/coreboot/coreboot_start16.S |   13 -------------
 1 files changed, 0 insertions(+), 13 deletions(-)
board/chromebook-x86/coreboot/coreboot_start16.S +0 -13
index 9ad06df..6b3d92d 100644
@@ -22,19 +22,6 @@
  * MA 02111-1307 USA
  */
 
-/*
- * 16bit initialization code.
- * This code have to map the area of the boot flash
- * that is used by U-boot to its final destination.
- */
-
-.text
-.section .start16, "ax"
-.code16
-.globl board_init16
-board_init16:
-	jmp	board_init16_ret
-
 .section .bios, "ax"
 .code16
 .globl realmode_reset
Signature · 1 line
1.7.7.3
#32 lore raw

PATCH v2 10/10 x86: Remove coreboot start16 code

Hi Simon,

Quoted 35 lines · Simon Glass

Now that coreboot doesn't need the start16 code, remove it.

---
Changes in v2:
- Add new patch to remove coreboot start16 code.

 board/chromebook-x86/coreboot/coreboot_start16.S |   13 -------------
 1 files changed, 0 insertions(+), 13 deletions(-)
board/chromebook-x86/coreboot/coreboot_start16.S +0 -14
index 9ad06df..6b3d92d 100644
@@ -22,19 +22,6 @@
  * MA 02111-1307 USA
  */
 
-/*
- * 16bit initialization code.
- * This code have to map the area of the boot flash
- * that is used by U-boot to its final destination.
- */
-
-.text
-.section .start16, "ax"
-.code16
-.globl board_init16
-board_init16:
-       jmp     board_init16_ret
-
 .section .bios, "ax"
 .code16
 .globl realmode_reset
--
Quoted 2 lines

1.7.7.3