Skip to contentSkip to conversation

x86: Add support for running on bare hardware

PATCH Superseded Simon Glass 2 participants 95 messages Nov 6, 2014 – Nov 12, 2014

Subsystems (5)
x86 Kbuild Library code GPIO +1 more subsystems

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover x86: Add support for running on bare hardware

At present U-Boot's x86 support requires Coreboot to run first, starting up the CPU and then setting up SDRAM and video among other tasks. U-Boot then runs as a payload. Notably U-Boot does not handle the ACPI fun on x86 where the kernel can call back into the 'BIOS' to perform certain tasks.

This Coreboot + U-Boot method is used for link (Chromebook Pixel) and it works fairly well.

However this does not remove the need for all x86-specific init in U-Boot. For each generation of chipset we need to adjust U-Boot to make it work, albeit sometimes not a lot. In any case this work has not been done so the x86 port risks being stranded.

There are also a few disadvantages to using two separate boot loaders. When Coreboot decides not set to up the video card, it is not possible for U-Boot to go back and do this.

Building an image which has both boot loaders in itis a little tricky, particularly with the binary blobs that are required.

After some experimentation prompted by a discussion at ELCE, it was found that while x86 is somewhat different to most of the other architectures that U-Boot supports, it actually fits the model fairly well. There is nothing magic about getting the platform running. Also it turns out that x86 likes running before relocation with no DRAM, using global_data, relocating and then starting up the full U-Boot, all within the same image (Coreboot splits this into three programs which run one after the other). Perhaps this is because U-Boot was conceived before the more modern SoCs with SRAM, FAT file system code in the ROM, etc.

This series contains a basic port of U-Boot to a bare x86 environment. It would be targeted at some generally available board, such as the Minnowmax, except that it doesn't seem to be generally available, at least for me. So while that remains a goal, for now the port targets link. It is already supported in U-Boot and the platform is well understood.

The following are implemented in this series:
- ivybridge support with some peripherals enabled
- SDRAM init using a binary blob (Memory Reference Code)
- Use of Intel Management Engine via another binary blob
- microcode update from device tree
- ifttool for creating ROMs of the required format (u-boot.rom)
- GPIO

Notably missing are:
- PCI device support (USB, SATA)
- Video support
- MTRR setup (for performance)
- Real time clock
- Chrome OS EC
- Documentation
- Links to binary blobs

These will be addressed in a follow-up series. Things like ACPI and SMI will come later.

Unfortunately this series is quite long as it includes basic infrastructure needed on x86. But it is a solid step forward: with this series, link boots to a prompt.

This series is available at u-boot-x86/working

Simon Glass (39):
Move early malloc() to before arch_cpu_init()
fdt: Add a function to decode a variable-sized u32 array
dm: serial: Move current serial port pointer to global_data
dm: gpio: Add a function to read an ID from a list of GPIOs
x86: Add ifdtool for working with Intel Flash Descriptor ROM images
x86: config: Move common x86 configs to a common file
x86: Add processor functions for cpuid and stack pointer
x86: Remove REALMODE_BASE which is no longer used
x86: Remove board_init16() call which is not used
x86: Remove unused early_board_init() call
x86: Invalidate TLB as early as possible
x86: Tidy up global descriptor table setup
x86: Use the standard dram_init() function
x86: Use the standard arch_cpu_init() function
x86: Remove unnecessary find_fdt() function
x86: Fix up some missing prototypes
x86: Add chromebook_link board
x86: Save the BIST value on reset
x86: Build a .rom file which can be flashed to an x86 machine
x86: Emit post codes in startup code
x86: chromebook_link: Implement CAR support (cache as RAM)
x86: Move Coreboot PCI into common cpu area
x86: Refactor PCI to permit alternate init
x86: ivybridge: Enable PCI in early init
x86: pci: Allow configuration before relocation
x86: ivybridge: Add early LPC init so that serial works
x86: Tidy up coreboot header usage
x86: Add clr/setbits functions
x86: Add msr read/write functions that use a structure
x86: ivybridge: Perform initial CPU setup
x86: ivybridge: Check BIST value on boot
x86: ivybridge: Perform Intel microcode update on boot
RFC: x86: dts: Add microcode updates for ivybridge CPU
x86: ivybridge: Add early init for PCH devices
x86: ivybridge: Add support for early GPIO init
x86: chromebook_link: Enable GPIO support
x86: Make show_boot_progress() common
x86: ivybridge: Add LAPIC support
x86: ivybridge: Implement SDRAM init

 Makefile                                          |   32 +-
 arch/x86/Kconfig                                  |   54 ++
 arch/x86/config.mk                                |    1 -
 arch/x86/cpu/Makefile                             |    1 +
 arch/x86/cpu/coreboot/Makefile                    |    1 -
 arch/x86/cpu/coreboot/coreboot.c                  |   44 +-
 arch/x86/cpu/coreboot/ipchecksum.c                |    2 +-
 arch/x86/cpu/coreboot/pci.c                       |   49 -
 arch/x86/cpu/coreboot/sdram.c                     |   15 +-
 arch/x86/cpu/coreboot/tables.c                    |    6 +-
 arch/x86/cpu/cpu.c                                |   60 +-
 arch/x86/cpu/interrupts.c                         |    2 +-
 arch/x86/cpu/ivybridge/Kconfig                    |  157 ++++
 arch/x86/cpu/ivybridge/Makefile                   |   15 +
 arch/x86/cpu/ivybridge/car.S                      |  174 ++++
 arch/x86/cpu/ivybridge/cpu.c                      |  356 +++++++
 arch/x86/cpu/ivybridge/early_init.c               |  145 +++
 arch/x86/cpu/ivybridge/early_me.c                 |  191 ++++
 arch/x86/cpu/ivybridge/lpc.c                      |   48 +
 arch/x86/cpu/ivybridge/me_status.c                |  195 ++++
 arch/x86/cpu/ivybridge/microcode_intel.c          |  150 +++
 arch/x86/cpu/ivybridge/report_platform.c          |   98 ++
 arch/x86/cpu/ivybridge/sdram.c                    |  571 +++++++++++
 arch/x86/cpu/pci.c                                |  150 +++
 arch/x86/cpu/start.S                              |   66 +-
 arch/x86/cpu/start16.S                            |   18 +-
 arch/x86/dts/Makefile                             |    1 +
 arch/x86/dts/chromebook_link.dts                  |    1 +
 arch/x86/dts/link.dts                             |  127 ++-
 arch/x86/dts/m12206a7_00000028.dtsi               |  622 ++++++++++++
 arch/x86/dts/m12306a9_00000017.dtsi               |  750 +++++++++++++++
 arch/x86/include/asm/arch-coreboot/gpio.h         |    5 -
 arch/x86/include/asm/arch-ivybridge/gpio.h        |   10 +
 arch/x86/include/asm/arch-ivybridge/me.h          |  357 +++++++
 arch/x86/include/asm/arch-ivybridge/microcode.h   |   20 +
 arch/x86/include/asm/arch-ivybridge/model_206ax.h |   82 ++
 arch/x86/include/asm/arch-ivybridge/pch.h         |  356 +++++++
 arch/x86/include/asm/arch-ivybridge/pei_data.h    |  121 +++
 arch/x86/include/asm/arch-ivybridge/sandybridge.h |  109 +++
 arch/x86/include/asm/config.h                     |    1 +
 arch/x86/include/asm/global_data.h                |   24 +
 arch/x86/include/asm/gpio.h                       |  142 ++-
 arch/x86/include/asm/init_helpers.h               |    1 -
 arch/x86/include/asm/io.h                         |   49 +
 arch/x86/include/asm/lapic.h                      |   59 ++
 arch/x86/include/asm/lapic_def.h                  |  101 ++
 arch/x86/include/asm/msr.h                        |   19 +
 arch/x86/include/asm/mtrr.h                       |  121 +++
 arch/x86/include/asm/pci.h                        |   13 +
 arch/x86/include/asm/post.h                       |   50 +
 arch/x86/include/asm/processor.h                  |  135 +++
 arch/x86/include/asm/u-boot-x86.h                 |   19 +-
 arch/x86/lib/Makefile                             |    1 +
 arch/x86/lib/ramtest.c                            |   79 ++
 board/chromebook-x86/coreboot/Makefile            |    2 +-
 board/chromebook-x86/coreboot/coreboot_start.S    |   13 -
 board/google/chromebook_link/Kconfig              |   31 +
 board/google/chromebook_link/MAINTAINERS          |    6 +
 board/google/chromebook_link/Makefile             |   15 +
 board/google/chromebook_link/link.c               |  124 +++
 common/board_f.c                                  |   14 +-
 configs/chromebook_link_defconfig                 |   10 +
 doc/device-tree-bindings/misc/intel-lpc.txt       |   23 +
 drivers/gpio/gpio-uclass.c                        |   19 +
 drivers/gpio/intel_ich6_gpio.c                    |   79 +-
 drivers/serial/serial-uclass.c                    |   35 +-
 include/asm-generic/global_data.h                 |    1 +
 include/asm-generic/gpio.h                        |   11 +-
 include/configs/chromebook_link.h                 |   68 ++
 include/configs/coreboot.h                        |  289 +-----
 include/configs/x86-common.h                      |  272 ++++++
 include/fdtdec.h                                  |   18 +
 lib/asm-offsets.c                                 |    3 +
 lib/fdtdec.c                                      |   22 +
 tools/Makefile                                    |    2 +
 tools/ifdtool.c                                   | 1039 +++++++++++++++++++++
 tools/ifdtool.h                                   |   88 ++
 77 files changed, 7690 insertions(+), 470 deletions(-)
 delete mode 100644 arch/x86/cpu/coreboot/pci.c
 create mode 100644 arch/x86/cpu/ivybridge/Kconfig
 create mode 100644 arch/x86/cpu/ivybridge/Makefile
 create mode 100644 arch/x86/cpu/ivybridge/car.S
 create mode 100644 arch/x86/cpu/ivybridge/cpu.c
 create mode 100644 arch/x86/cpu/ivybridge/early_init.c
 create mode 100644 arch/x86/cpu/ivybridge/early_me.c
 create mode 100644 arch/x86/cpu/ivybridge/lpc.c
 create mode 100644 arch/x86/cpu/ivybridge/me_status.c
 create mode 100644 arch/x86/cpu/ivybridge/microcode_intel.c
 create mode 100644 arch/x86/cpu/ivybridge/report_platform.c
 create mode 100644 arch/x86/cpu/ivybridge/sdram.c
 create mode 100644 arch/x86/cpu/pci.c
 create mode 120000 arch/x86/dts/chromebook_link.dts
 create mode 100644 arch/x86/dts/m12206a7_00000028.dtsi
 create mode 100644 arch/x86/dts/m12306a9_00000017.dtsi
 create mode 100644 arch/x86/include/asm/arch-ivybridge/gpio.h
 create mode 100644 arch/x86/include/asm/arch-ivybridge/me.h
 create mode 100644 arch/x86/include/asm/arch-ivybridge/microcode.h
 create mode 100644 arch/x86/include/asm/arch-ivybridge/model_206ax.h
 create mode 100644 arch/x86/include/asm/arch-ivybridge/pch.h
 create mode 100644 arch/x86/include/asm/arch-ivybridge/pei_data.h
 create mode 100644 arch/x86/include/asm/arch-ivybridge/sandybridge.h
 create mode 100644 arch/x86/include/asm/lapic.h
 create mode 100644 arch/x86/include/asm/lapic_def.h
 create mode 100644 arch/x86/include/asm/mtrr.h
 create mode 100644 arch/x86/include/asm/post.h
 create mode 100644 arch/x86/lib/ramtest.c
 delete mode 100644 board/chromebook-x86/coreboot/coreboot_start.S
 create mode 100644 board/google/chromebook_link/Kconfig
 create mode 100644 board/google/chromebook_link/MAINTAINERS
 create mode 100644 board/google/chromebook_link/Makefile
 create mode 100644 board/google/chromebook_link/link.c
 create mode 100644 configs/chromebook_link_defconfig
 create mode 100644 doc/device-tree-bindings/misc/intel-lpc.txt
 create mode 100644 include/configs/chromebook_link.h
 create mode 100644 include/configs/x86-common.h
 create mode 100644 tools/ifdtool.c
 create mode 100644 tools/ifdtool.h
Signature · 1 line
2.1.0.rc2.206.gedb03e5
#1 lore raw

PATCH 1/39 Move early malloc() to before arch_cpu_init()

For some CPUs, having malloc() available very early is useful. There is no reason to delay this since early malloc is allocated before board_init_f() is called.

Move early malloc() init nearer to the start of the init sequence.

---

 common/board_f.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/board_f.c +1 -1
index b5bebc9..31f1d5c 100644
@@ -812,6 +812,7 @@ static init_fnc_t init_sequence_f[] = {
 	setup_mon_len,
 	setup_fdt,
 	trace_early_init,
+	initf_malloc,
 #if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)
 	/* TODO: can this go into arch_cpu_init()? */
 	probecpu,
@@ -827,7 +828,6 @@ static init_fnc_t init_sequence_f[] = {
 #ifdef CONFIG_OF_CONTROL
 	fdtdec_check_fdt,
 #endif
-	initf_malloc,
 	initf_dm,
 #if defined(CONFIG_BOARD_EARLY_INIT_F)
 	board_early_init_f,
Signature · 1 line
2.1.0.rc2.206.gedb03e5
#2 lore raw

PATCH 2/39 fdt: Add a function to decode a variable-sized u32 array

In reply to Simon Glass

Sometimes an array can be of variable size up to a maximum. Add a helper function to decode this.

---

 include/fdtdec.h | 16 ++++++++++++++++
 lib/fdtdec.c     | 20 ++++++++++++++++++++
 2 files changed, 36 insertions(+)
include/fdtdec.h +16 -0
index 4ae77be..6b40006 100644
@@ -445,6 +445,22 @@ int fdtdec_get_int_array(const void *blob, int node, const char *prop_name,
 		u32 *array, int count);
 
 /**
+ * Look up a property in a node and return its contents in an integer
+ * array of given length. The property must exist but may have less data that
+ * expected (4*count bytes). It may have more, but this will be ignored.
+ *
+ * @param blob		FDT blob
+ * @param node		node to examine
+ * @param prop_name	name of property to find
+ * @param array		array to fill with data
+ * @param count		number of array elements
+ * @return number of array elements if ok, or -FDT_ERR_NOTFOUND if the
+ *		property is not found
+ */
+int fdtdec_get_int_array_count(const void *blob, int node,
+			       const char *prop_name, u32 *array, int count);
+
+/**
  * Look up a property in a node and return a pointer to its contents as a
  * unsigned int array of given length. The property must have at least enough
  * data for the array ('count' cells). It may have more, but this will be
lib/fdtdec.c +20 -0
index 9714620..4aa227a 100644
@@ -485,6 +485,26 @@ int fdtdec_get_int_array(const void *blob, int node, const char *prop_name,
 	return err;
 }
 
+int fdtdec_get_int_array_count(const void *blob, int node,
+			       const char *prop_name, u32 *array, int count)
+{
+	const u32 *cell;
+	int len, elems;
+	int i;
+
+	debug("%s: %s\n", __func__, prop_name);
+	cell = fdt_getprop(blob, node, prop_name, &len);
+	if (!cell)
+		return -FDT_ERR_NOTFOUND;
+	elems = len / sizeof(u32);
+	if (count > elems)
+		count = elems;
+	for (i = 0; i < count; i++)
+		array[i] = fdt32_to_cpu(cell[i]);
+
+	return count;
+}
+
 const u32 *fdtdec_locate_array(const void *blob, int node,
 			       const char *prop_name, int count)
 {
Signature · 1 line
2.1.0.rc2.206.gedb03e5
#3 lore raw

PATCH 3/39 dm: serial: Move current serial port pointer to global_data

In reply to Simon Glass

In general we can't store things in the data section until we have inited SDRAM. Some platforms allow this (e.g. those with SPL) but some don't. Move the pointer to global_data so that it will work on all platforms.

Without this fix the serial port will not work prior to relocation with driver model on some platforms.

---

 drivers/serial/serial-uclass.c    | 35 +++++++++++++++++++----------------
 include/asm-generic/global_data.h |  1 +
 2 files changed, 20 insertions(+), 16 deletions(-)
drivers/serial/serial-uclass.c +19 -16
index 71f1a5c..0f019c8 100644
@@ -19,15 +19,14 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-/* The currently-selected console serial device */
-struct udevice *cur_dev __attribute__ ((section(".data")));
-
 #ifndef CONFIG_SYS_MALLOC_F_LEN
 #error "Serial is required before relocation - define CONFIG_SYS_MALLOC_F_LEN to make this work"
 #endif
 
 static void serial_find_console_or_panic(void)
 {
+	struct udevice *dev;
+
 #ifdef CONFIG_OF_CONTROL
 	int node;
 
@@ -35,18 +34,21 @@ static void serial_find_console_or_panic(void)
 	node = fdtdec_get_chosen_node(gd->fdt_blob, "stdout-path");
 	if (node < 0)
 		node = fdtdec_get_alias_node(gd->fdt_blob, "console");
-	if (!uclass_get_device_by_of_offset(UCLASS_SERIAL, node, &cur_dev))
+	if (!uclass_get_device_by_of_offset(UCLASS_SERIAL, node, &dev)) {
+		gd->cur_serial_dev = dev;
 		return;
+	}
 
 	/*
 	 * If the console is not marked to be bound before relocation, bind
 	 * it anyway.
 	 */
 	if (node > 0 &&
-	    !lists_bind_fdt(gd->dm_root, gd->fdt_blob, node, &cur_dev)) {
-		if (!device_probe(cur_dev))
+	    !lists_bind_fdt(gd->dm_root, gd->fdt_blob, node, &dev)) {
+		if (!device_probe(dev)) {
+			gd->cur_serial_dev = dev;
 			return;
-		cur_dev = NULL;
+		}
 	}
 #endif
 	/*
@@ -61,11 +63,12 @@ static void serial_find_console_or_panic(void)
 #else
 #define INDEX 0
 #endif
-	if (uclass_get_device_by_seq(UCLASS_SERIAL, INDEX, &cur_dev) &&
-	    uclass_get_device(UCLASS_SERIAL, INDEX, &cur_dev) &&
-	    (uclass_first_device(UCLASS_SERIAL, &cur_dev) || !cur_dev))
+	if (uclass_get_device_by_seq(UCLASS_SERIAL, INDEX, &dev) &&
+	    uclass_get_device(UCLASS_SERIAL, INDEX, &dev) &&
+	    (uclass_first_device(UCLASS_SERIAL, &dev) || !dev))
 		panic("No serial driver found");
 #undef INDEX
+	gd->cur_serial_dev = dev;
 }
 
 /* Called prior to relocation */
@@ -127,30 +130,30 @@ static int _serial_tstc(struct udevice *dev)
 
 void serial_putc(char ch)
 {
-	_serial_putc(cur_dev, ch);
+	_serial_putc(gd->cur_serial_dev, ch);
 }
 
 void serial_puts(const char *str)
 {
-	_serial_puts(cur_dev, str);
+	_serial_puts(gd->cur_serial_dev, str);
 }
 
 int serial_getc(void)
 {
-	return _serial_getc(cur_dev);
+	return _serial_getc(gd->cur_serial_dev);
 }
 
 int serial_tstc(void)
 {
-	return _serial_tstc(cur_dev);
+	return _serial_tstc(gd->cur_serial_dev);
 }
 
 void serial_setbrg(void)
 {
-	struct dm_serial_ops *ops = serial_get_ops(cur_dev);
+	struct dm_serial_ops *ops = serial_get_ops(gd->cur_serial_dev);
 
 	if (ops->setbrg)
-		ops->setbrg(cur_dev, gd->baudrate);
+		ops->setbrg(gd->cur_serial_dev, gd->baudrate);
 }
 
 void serial_stdio_init(void)
include/asm-generic/global_data.h +1 -0
index 74df210..f61acbc 100644
@@ -91,6 +91,7 @@ typedef struct global_data {
 	unsigned long malloc_limit;	/* limit address */
 	unsigned long malloc_ptr;	/* current address */
 #endif
+	struct udevice *cur_serial_dev;	/* current serial device */
 	struct arch_global_data arch;	/* architecture-specific data */
 } gd_t;
 #endif
Signature · 1 line
2.1.0.rc2.206.gedb03e5
#4 lore raw

PATCH 4/39 dm: gpio: Add a function to read an ID from a list of GPIOs

In reply to Simon Glass

For board IDs a common approach is to set aside several GPIOs for use in determining the board ID. This can provide information about board features and the revision.

Add a function that turns a list of GPIOs into an integer by assigning each GPIO to a single bit.

---

 drivers/gpio/gpio-uclass.c | 19 +++++++++++++++++++
 include/asm-generic/gpio.h | 11 ++++++++++-
 2 files changed, 29 insertions(+), 1 deletion(-)
drivers/gpio/gpio-uclass.c +19 -0
index 45e9a5a..255700a 100644
@@ -390,6 +390,25 @@ int gpio_get_status(struct udevice *dev, int offset, char *buf, int buffsize)
 	return 0;
 }
 
+/*
+ * get a number comprised of multiple GPIO values. gpio_num_array points to
+ * the array of gpio pin numbers to scan, terminated by -1.
+ */
+unsigned gpio_get_values_as_int(const int *gpio_num_array)
+{
+	int gpio;
+	unsigned bitmask = 1;
+	unsigned vector = 0;
+
+	while (bitmask &&
+	       ((gpio = *gpio_num_array++) != -1)) {
+		if (gpio_get_value(gpio))
+			vector |= bitmask;
+		bitmask <<= 1;
+	}
+	return vector;
+}
+
 /* We need to renumber the GPIOs when any driver is probed/removed */
 static int gpio_renumber(struct udevice *removed_dev)
 {
include/asm-generic/gpio.h +10 -1
index f81b51a..36a36c6 100644
@@ -257,6 +257,15 @@ const char *gpio_get_bank_info(struct udevice *dev, int *offset_count);
 int gpio_lookup_name(const char *name, struct udevice **devp,
 		     unsigned int *offsetp, unsigned int *gpiop);
 
-int name_to_gpio(const char *name);
+/**
+ * get_gpios() - Turn the values of a list of GPIOs into an integer
+ *
+ * This puts the value of the first GPIO into bit 0, the second into bit 1,
+ * etc. then returns the resulting integer.
+ *
+ * @gpio_list: List of GPIOs to collect
+ * @return resulting integer value
+ */
+unsigned gpio_get_values_as_int(const int *gpio_list);
 
 #endif	/* _ASM_GENERIC_GPIO_H_ */
Signature · 1 line
2.1.0.rc2.206.gedb03e5
#5 lore raw

PATCH 5/39 x86: Add ifdtool for working with Intel Flash Descriptor ROM images

In reply to Simon Glass

Newer Intel chips require a Management Engine which requires a particular format for the SPI flash that contains the boot loader. Add a tool that supports creating and modifying these ROM images.

This tool is from Chrome OS but has been cleaned up to use U-Boot style and to add comments. A few features have been added also.

---

 tools/Makefile  |    2 +
 tools/ifdtool.c | 1039 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/ifdtool.h |   88 +++++
 3 files changed, 1129 insertions(+)
 create mode 100644 tools/ifdtool.c
 create mode 100644 tools/ifdtool.h
tools/Makefile +2 -0
index 3b95964..55f25c0 100644
@@ -126,6 +126,8 @@ hostprogs-$(CONFIG_EXYNOS5250) += mkexynosspl
 hostprogs-$(CONFIG_EXYNOS5420) += mkexynosspl
 HOSTCFLAGS_mkexynosspl.o := -pedantic
 
+hostprogs-$(CONFIG_X86) += ifdtool
+
 hostprogs-$(CONFIG_MX23) += mxsboot
 hostprogs-$(CONFIG_MX28) += mxsboot
 HOSTCFLAGS_mxsboot.o := -pedantic
tools/ifdtool.c new file +1039 -0

1,039 lines not on this page · raw message

tools/ifdtool.h new file +88 -0

88 lines not on this page · raw message

Signature · 1 line
2.1.0.rc2.206.gedb03e5
#6 lore raw

PATCH 6/39 x86: config: Move common x86 configs to a common file

In reply to Simon Glass

Many of the x86 CONFIG options will be common across different boards. Move them to a common file.

---

 include/configs/coreboot.h   | 289 ++-----------------------------------------
 include/configs/x86-common.h | 272 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 285 insertions(+), 276 deletions(-)
 create mode 100644 include/configs/x86-common.h
include/configs/coreboot.h +13 -276
index fef267f..9ac5306 100644
@@ -6,7 +6,6 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
-#include <asm/ibmpc.h>
 /*
  * board/config.h - configuration options, board specific
  */
@@ -14,27 +13,15 @@
 #ifndef __CONFIG_H
 #define __CONFIG_H
 
-/*
- * High Level Configuration Options
- * (easy to change)
- */
-#define CONFIG_SYS_COREBOOT
-#define CONFIG_SHOW_BOOT_PROGRESS
-#define CONFIG_LAST_STAGE_INIT
-#define CONFIG_SYS_VSNPRINTF
-#define CONFIG_ZBOOT_32
-#define CONFIG_PHYSMEM
-#define CONFIG_SYS_EARLY_PCI_INIT
-#define CONFIG_DISPLAY_BOARDINFO_LATE
-#define CONFIG_DISPLAY_CPUINFO
+#include <configs/x86-common.h>
 
-#define CONFIG_DM
-#define CONFIG_CMD_DM
-#define CONFIG_DM_GPIO
-#define CONFIG_DM_SERIAL
+#define CONFIG_SYS_CAR_ADDR			0x19200000
+#define CONFIG_SYS_CAR_SIZE			(16 * 1024)
+#define CONFIG_SYS_MONITOR_LEN			(256 * 1024)
 
-#define CONFIG_LMB
-#define CONFIG_OF_LIBFDT
+#define CONFIG_TRACE_EARLY_SIZE		(8 << 20)
+#define CONFIG_TRACE_EARLY
+#define CONFIG_TRACE_EARLY_ADDR		0x01400000
 
 #define CONFIG_BOOTSTAGE
 #define CONFIG_BOOTSTAGE_REPORT
@@ -45,278 +32,28 @@
 #define CONFIG_BOOTSTAGE_STASH_SIZE	0x7fc
 #define CONFIG_BOOTSTAGE_USER_COUNT	60
 
-#define CONFIG_LZO
-#define CONFIG_FIT
-#undef CONFIG_ZLIB
-#undef CONFIG_GZIP
-#define CONFIG_SYS_BOOTM_LEN		(16 << 20)
-
-/*-----------------------------------------------------------------------
- * Watchdog Configuration
- */
-#undef CONFIG_WATCHDOG
-#undef CONFIG_HW_WATCHDOG
-
-/* SATA AHCI storage */
-
-#define CONFIG_SCSI_AHCI
-
-#ifdef CONFIG_SCSI_AHCI
-#define CONFIG_LIBATA
-#define CONFIG_SYS_64BIT_LBA
-#define CONFIG_SATA_INTEL		1
-#define CONFIG_SCSI_DEV_LIST		{PCI_VENDOR_ID_INTEL, \
-			PCI_DEVICE_ID_INTEL_NM10_AHCI},	      \
-	{PCI_VENDOR_ID_INTEL,		\
-			PCI_DEVICE_ID_INTEL_COUGARPOINT_AHCI_MOBILE}, \
-	{PCI_VENDOR_ID_INTEL, \
-			PCI_DEVICE_ID_INTEL_COUGARPOINT_AHCI_SERIES6}, \
-	{PCI_VENDOR_ID_INTEL,		\
-			PCI_DEVICE_ID_INTEL_PANTHERPOINT_AHCI_MOBILE}
-
-#define CONFIG_SYS_SCSI_MAX_SCSI_ID	2
-#define CONFIG_SYS_SCSI_MAX_LUN		1
-#define CONFIG_SYS_SCSI_MAX_DEVICE	(CONFIG_SYS_SCSI_MAX_SCSI_ID * \
-					 CONFIG_SYS_SCSI_MAX_LUN)
-#endif
-
-/* Generic TPM interfaced through LPC bus */
-#define CONFIG_TPM
-#define CONFIG_TPM_TIS_LPC
-#define CONFIG_TPM_TIS_BASE_ADDRESS        0xfed40000
-
-/*-----------------------------------------------------------------------
- * Real Time Clock Configuration
- */
-#define CONFIG_RTC_MC146818
-#define CONFIG_SYS_ISA_IO_BASE_ADDRESS	0
-#define CONFIG_SYS_ISA_IO      CONFIG_SYS_ISA_IO_BASE_ADDRESS
-
-/*-----------------------------------------------------------------------
- * Serial Configuration
+/*
+ * High Level Configuration Options
+ * (easy to change)
  */
-#define CONFIG_COREBOOT_SERIAL
-#define CONFIG_SYS_NS16550
-#define CONFIG_BAUDRATE			115200
-#define CONFIG_SYS_BAUDRATE_TABLE	{300, 600, 1200, 2400, 4800, \
-					 9600, 19200, 38400, 115200}
-#define CONFIG_SYS_NS16550_PORT_MAPPED
+#define CONFIG_SYS_COREBOOT
+#define CONFIG_LAST_STAGE_INIT
 
 #define CONFIG_STD_DEVICES_SETTINGS     "stdin=usbkbd,vga,serial\0" \
 					"stdout=vga,serial,cbmem\0" \
 					"stderr=vga,serial,cbmem\0"
 
-#define CONFIG_CONSOLE_MUX
-#define CONFIG_SYS_CONSOLE_IS_IN_ENV
-#define CONFIG_SYS_STDIO_DEREGISTER
 #define CONFIG_CBMEM_CONSOLE
 
-#define CONFIG_CMDLINE_EDITING
-#define CONFIG_COMMAND_HISTORY
-#define CONFIG_AUTO_COMPLETE
-#define CONFIG_SYS_HUSH_PARSER
-
-#define CONFIG_SUPPORT_VFAT
-/************************************************************
- * ATAPI support (experimental)
- ************************************************************/
-#define CONFIG_ATAPI
-
-/************************************************************
- * DISK Partition support
- ************************************************************/
-#define CONFIG_EFI_PARTITION
-#define CONFIG_DOS_PARTITION
-#define CONFIG_MAC_PARTITION
-#define CONFIG_ISO_PARTITION		/* Experimental */
-
-#define CONFIG_CMD_PART
-#define CONFIG_CMD_CBFS
-#define CONFIG_CMD_EXT4
-#define CONFIG_CMD_EXT4_WRITE
-#define CONFIG_PARTITION_UUIDS
-
-/*-----------------------------------------------------------------------
- * Video Configuration
- */
-#define CONFIG_VIDEO
 #define CONFIG_VIDEO_COREBOOT
-#define CONFIG_VIDEO_SW_CURSOR
-#define VIDEO_FB_16BPP_WORD_SWAP
-#define CONFIG_I8042_KBD
-#define CONFIG_CFB_CONSOLE
-#define CONFIG_SYS_CONSOLE_INFO_QUIET
 
-/* x86 GPIOs are accessed through a PCI device */
-#define CONFIG_INTEL_ICH6_GPIO
-
-/*-----------------------------------------------------------------------
- * Command line configuration.
- */
-#include <config_cmd_default.h>
+#define CONFIG_NR_DRAM_BANKS			4
 
 #define CONFIG_TRACE
 #define CONFIG_CMD_TRACE
 #define CONFIG_TRACE_BUFFER_SIZE	(16 << 20)
-#define CONFIG_TRACE_EARLY_SIZE		(8 << 20)
-#define CONFIG_TRACE_EARLY
-#define CONFIG_TRACE_EARLY_ADDR		0x01400000
-
-#define CONFIG_CMD_BDI
-#define CONFIG_CMD_BOOTD
-#define CONFIG_CMD_CONSOLE
-#define CONFIG_CMD_DATE
-#define CONFIG_CMD_ECHO
-#undef CONFIG_CMD_FLASH
-#define CONFIG_CMD_FPGA
-#define CONFIG_CMD_FPGA_LOADMK
-#define CONFIG_CMD_GPIO
-#define CONFIG_CMD_IMI
-#undef CONFIG_CMD_IMLS
-#define CONFIG_CMD_IO
-#define CONFIG_CMD_IRQ
-#define CONFIG_CMD_ITEST
-#define CONFIG_CMD_LOADB
-#define CONFIG_CMD_LOADS
-#define CONFIG_CMD_MEMORY
-#define CONFIG_CMD_MISC
-#define CONFIG_CMD_NET
-#undef CONFIG_CMD_NFS
-#define CONFIG_CMD_PCI
-#define CONFIG_CMD_PING
-#define CONFIG_CMD_RUN
-#define CONFIG_CMD_SAVEENV
-#define CONFIG_CMD_SETGETDCR
-#define CONFIG_CMD_SOURCE
-#define CONFIG_CMD_TIME
-#define CONFIG_CMD_GETTIME
-#define CONFIG_CMD_XIMG
-#define CONFIG_CMD_SCSI
-
-#define CONFIG_CMD_FAT
-#define CONFIG_CMD_EXT2
-
-#define CONFIG_CMD_ZBOOT
-#define CONFIG_CMD_ELF
 
 #define CONFIG_BOOTDELAY	2
-#define CONFIG_BOOTARGS		\
-	"root=/dev/sdb3 init=/sbin/init rootwait ro"
-#define CONFIG_BOOTCOMMAND	\
-	"ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000"
-
-
-#if defined(CONFIG_CMD_KGDB)
-#define CONFIG_KGDB_BAUDRATE			115200
-#endif
-
-/*
- * Miscellaneous configurable options
- */
-#define CONFIG_SYS_LONGHELP
-#define CONFIG_SYS_CBSIZE			512
-#define CONFIG_SYS_PBSIZE			(CONFIG_SYS_CBSIZE + \
-						 sizeof(CONFIG_SYS_PROMPT) + \
-						 16)
-#define CONFIG_SYS_MAXARGS			16
-#define CONFIG_SYS_BARGSIZE			CONFIG_SYS_CBSIZE
-
-#define CONFIG_SYS_MEMTEST_START		0x00100000
-#define CONFIG_SYS_MEMTEST_END			0x01000000
-#define CONFIG_SYS_LOAD_ADDR			0x20000000
-
-/*-----------------------------------------------------------------------
- * SDRAM Configuration
- */
-#define CONFIG_NR_DRAM_BANKS			4
-
-/* CONFIG_SYS_SDRAM_DRCTMCTL Overrides the following*/
-#undef CONFIG_SYS_SDRAM_PRECHARGE_DELAY
-#undef CONFIG_SYS_SDRAM_RAS_CAS_DELAY
-#undef CONFIG_SYS_SDRAM_CAS_LATENCY_2T
-#undef CONFIG_SYS_SDRAM_CAS_LATENCY_3T
-
-/*-----------------------------------------------------------------------
- * CPU Features
- */
-
-#define CONFIG_SYS_X86_TSC_TIMER
-#define CONFIG_SYS_PCAT_INTERRUPTS
-#define CONFIG_SYS_PCAT_TIMER
-#define CONFIG_SYS_NUM_IRQS			16
-
-/*-----------------------------------------------------------------------
- * Memory organization:
- * 32kB Stack
- * 16kB Cache-As-RAM @ 0x19200000
- * 256kB Monitor
- * (128kB + Environment Sector Size) malloc pool
- */
-#define CONFIG_SYS_STACK_SIZE			(32 * 1024)
-#define CONFIG_SYS_CAR_ADDR			0x19200000
-#define CONFIG_SYS_CAR_SIZE			(16 * 1024)
-#define CONFIG_SYS_MONITOR_BASE		CONFIG_SYS_TEXT_BASE
-#define CONFIG_SYS_MONITOR_LEN			(256 * 1024)
-#define CONFIG_SYS_MALLOC_LEN			(0x20000 + 128 * 1024)
-#define CONFIG_SYS_MALLOC_F_LEN			(1 << 10)
-
-/* allow to overwrite serial and ethaddr */
-#define CONFIG_ENV_OVERWRITE
-
-/*-----------------------------------------------------------------------
- * FLASH configuration
- */
-#define CONFIG_ICH_SPI
-#define CONFIG_SPI_FLASH
-#define CONFIG_SPI_FLASH_MACRONIX
-#define CONFIG_SPI_FLASH_WINBOND
-#define CONFIG_SPI_FLASH_GIGADEVICE
-#define CONFIG_SYS_NO_FLASH
-#define CONFIG_CMD_SF
-#define CONFIG_CMD_SF_TEST
-#define CONFIG_CMD_SPI
-#define CONFIG_SPI
-
-/*-----------------------------------------------------------------------
- * Environment configuration
- */
-#define CONFIG_ENV_IS_NOWHERE
-#define CONFIG_ENV_SIZE			0x01000
-
-/*-----------------------------------------------------------------------
- * PCI configuration
- */
-#define CONFIG_PCI
-
-#define CONFIG_CROS_EC
-#define CONFIG_CROS_EC_LPC
-#define CONFIG_CMD_CROS_EC
-#define CONFIG_ARCH_EARLY_INIT_R
-
-/*-----------------------------------------------------------------------
- * USB configuration
- */
-#define CONFIG_USB_EHCI
-#define CONFIG_USB_EHCI_PCI
-#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS     12
-#define CONFIG_USB_MAX_CONTROLLER_COUNT        2
-#define CONFIG_USB_STORAGE
-#define CONFIG_USB_KEYBOARD
-#define CONFIG_SYS_USB_EVENT_POLL
-
-#define CONFIG_USB_HOST_ETHER
-#define CONFIG_USB_ETHER_ASIX
-#define CONFIG_USB_ETHER_SMSC95XX
-#define CONFIG_TFTP_TSIZE
-#define CONFIG_CMD_DHCP
-#define CONFIG_BOOTP_BOOTFILESIZE
-#define CONFIG_BOOTP_BOOTPATH
-#define CONFIG_BOOTP_GATEWAY
-#define CONFIG_BOOTP_HOSTNAME
-
-#define CONFIG_CMD_USB
 
-#define CONFIG_EXTRA_ENV_SETTINGS \
-	CONFIG_STD_DEVICES_SETTINGS
 
 #endif	/* __CONFIG_H */
include/configs/x86-common.h new file +272 -0

272 lines not on this page · raw message

Signature · 1 line
2.1.0.rc2.206.gedb03e5
#7 lore raw

PATCH 6/39 x86: config: Move common x86 configs to a common file

Hi Simon,

Quoted 361 lines · Simon Glass

Many of the x86 CONFIG options will be common across different boards. Move them to a common file.

---

 include/configs/coreboot.h   | 289 ++-----------------------------------------
 include/configs/x86-common.h | 272 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 285 insertions(+), 276 deletions(-)
 create mode 100644 include/configs/x86-common.h
include/configs/coreboot.h +13 -276
index fef267f..9ac5306 100644
@@ -6,7 +6,6 @@
  * SPDX-License-Identifier:    GPL-2.0+
  */
 
-#include <asm/ibmpc.h>
 /*
  * board/config.h - configuration options, board specific
  */
@@ -14,27 +13,15 @@
 #ifndef __CONFIG_H
 #define __CONFIG_H
 
-/*
- * High Level Configuration Options
- * (easy to change)
- */
-#define CONFIG_SYS_COREBOOT
-#define CONFIG_SHOW_BOOT_PROGRESS
-#define CONFIG_LAST_STAGE_INIT
-#define CONFIG_SYS_VSNPRINTF
-#define CONFIG_ZBOOT_32
-#define CONFIG_PHYSMEM
-#define CONFIG_SYS_EARLY_PCI_INIT
-#define CONFIG_DISPLAY_BOARDINFO_LATE
-#define CONFIG_DISPLAY_CPUINFO
+#include <configs/x86-common.h>
 
-#define CONFIG_DM
-#define CONFIG_CMD_DM
-#define CONFIG_DM_GPIO
-#define CONFIG_DM_SERIAL
+#define CONFIG_SYS_CAR_ADDR                    0x19200000
+#define CONFIG_SYS_CAR_SIZE                    (16 * 1024)
+#define CONFIG_SYS_MONITOR_LEN                 (256 * 1024)
 
-#define CONFIG_LMB
-#define CONFIG_OF_LIBFDT
+#define CONFIG_TRACE_EARLY_SIZE                (8 << 20)
+#define CONFIG_TRACE_EARLY
+#define CONFIG_TRACE_EARLY_ADDR                0x01400000
 
 #define CONFIG_BOOTSTAGE
 #define CONFIG_BOOTSTAGE_REPORT
@@ -45,278 +32,28 @@
 #define CONFIG_BOOTSTAGE_STASH_SIZE    0x7fc
 #define CONFIG_BOOTSTAGE_USER_COUNT    60
 
-#define CONFIG_LZO
-#define CONFIG_FIT
-#undef CONFIG_ZLIB
-#undef CONFIG_GZIP
-#define CONFIG_SYS_BOOTM_LEN           (16 << 20)
-
-/*-----------------------------------------------------------------------
- * Watchdog Configuration
- */
-#undef CONFIG_WATCHDOG
-#undef CONFIG_HW_WATCHDOG
-
-/* SATA AHCI storage */
-
-#define CONFIG_SCSI_AHCI
-
-#ifdef CONFIG_SCSI_AHCI
-#define CONFIG_LIBATA
-#define CONFIG_SYS_64BIT_LBA
-#define CONFIG_SATA_INTEL              1
-#define CONFIG_SCSI_DEV_LIST           {PCI_VENDOR_ID_INTEL, \
-                       PCI_DEVICE_ID_INTEL_NM10_AHCI},       \
-       {PCI_VENDOR_ID_INTEL,           \
-                       PCI_DEVICE_ID_INTEL_COUGARPOINT_AHCI_MOBILE}, \
-       {PCI_VENDOR_ID_INTEL, \
-                       PCI_DEVICE_ID_INTEL_COUGARPOINT_AHCI_SERIES6}, \
-       {PCI_VENDOR_ID_INTEL,           \
-                       PCI_DEVICE_ID_INTEL_PANTHERPOINT_AHCI_MOBILE}
-
-#define CONFIG_SYS_SCSI_MAX_SCSI_ID    2
-#define CONFIG_SYS_SCSI_MAX_LUN                1
-#define CONFIG_SYS_SCSI_MAX_DEVICE     (CONFIG_SYS_SCSI_MAX_SCSI_ID * \
-                                        CONFIG_SYS_SCSI_MAX_LUN)
-#endif
-
-/* Generic TPM interfaced through LPC bus */
-#define CONFIG_TPM
-#define CONFIG_TPM_TIS_LPC
-#define CONFIG_TPM_TIS_BASE_ADDRESS        0xfed40000
-
-/*-----------------------------------------------------------------------
- * Real Time Clock Configuration
- */
-#define CONFIG_RTC_MC146818
-#define CONFIG_SYS_ISA_IO_BASE_ADDRESS 0
-#define CONFIG_SYS_ISA_IO      CONFIG_SYS_ISA_IO_BASE_ADDRESS
-
-/*-----------------------------------------------------------------------
- * Serial Configuration
+/*
+ * High Level Configuration Options
+ * (easy to change)
  */
-#define CONFIG_COREBOOT_SERIAL
-#define CONFIG_SYS_NS16550
-#define CONFIG_BAUDRATE                        115200
-#define CONFIG_SYS_BAUDRATE_TABLE      {300, 600, 1200, 2400, 4800, \
-                                        9600, 19200, 38400, 115200}
-#define CONFIG_SYS_NS16550_PORT_MAPPED
+#define CONFIG_SYS_COREBOOT
+#define CONFIG_LAST_STAGE_INIT
 
 #define CONFIG_STD_DEVICES_SETTINGS     "stdin=usbkbd,vga,serial\0" \
                                        "stdout=vga,serial,cbmem\0" \
                                        "stderr=vga,serial,cbmem\0"
 
-#define CONFIG_CONSOLE_MUX
-#define CONFIG_SYS_CONSOLE_IS_IN_ENV
-#define CONFIG_SYS_STDIO_DEREGISTER
 #define CONFIG_CBMEM_CONSOLE
 
-#define CONFIG_CMDLINE_EDITING
-#define CONFIG_COMMAND_HISTORY
-#define CONFIG_AUTO_COMPLETE
-#define CONFIG_SYS_HUSH_PARSER
-
-#define CONFIG_SUPPORT_VFAT
-/************************************************************
- * ATAPI support (experimental)
- ************************************************************/
-#define CONFIG_ATAPI
-
-/************************************************************
- * DISK Partition support
- ************************************************************/
-#define CONFIG_EFI_PARTITION
-#define CONFIG_DOS_PARTITION
-#define CONFIG_MAC_PARTITION
-#define CONFIG_ISO_PARTITION           /* Experimental */
-
-#define CONFIG_CMD_PART
-#define CONFIG_CMD_CBFS
-#define CONFIG_CMD_EXT4
-#define CONFIG_CMD_EXT4_WRITE
-#define CONFIG_PARTITION_UUIDS
-
-/*-----------------------------------------------------------------------
- * Video Configuration
- */
-#define CONFIG_VIDEO
 #define CONFIG_VIDEO_COREBOOT
-#define CONFIG_VIDEO_SW_CURSOR
-#define VIDEO_FB_16BPP_WORD_SWAP
-#define CONFIG_I8042_KBD
-#define CONFIG_CFB_CONSOLE
-#define CONFIG_SYS_CONSOLE_INFO_QUIET
 
-/* x86 GPIOs are accessed through a PCI device */
-#define CONFIG_INTEL_ICH6_GPIO
-
-/*-----------------------------------------------------------------------
- * Command line configuration.
- */
-#include <config_cmd_default.h>
+#define CONFIG_NR_DRAM_BANKS                   4
 
 #define CONFIG_TRACE
 #define CONFIG_CMD_TRACE
 #define CONFIG_TRACE_BUFFER_SIZE       (16 << 20)
-#define CONFIG_TRACE_EARLY_SIZE                (8 << 20)
-#define CONFIG_TRACE_EARLY
-#define CONFIG_TRACE_EARLY_ADDR                0x01400000
-
-#define CONFIG_CMD_BDI
-#define CONFIG_CMD_BOOTD
-#define CONFIG_CMD_CONSOLE
-#define CONFIG_CMD_DATE
-#define CONFIG_CMD_ECHO
-#undef CONFIG_CMD_FLASH
-#define CONFIG_CMD_FPGA
-#define CONFIG_CMD_FPGA_LOADMK
-#define CONFIG_CMD_GPIO
-#define CONFIG_CMD_IMI
-#undef CONFIG_CMD_IMLS
-#define CONFIG_CMD_IO
-#define CONFIG_CMD_IRQ
-#define CONFIG_CMD_ITEST
-#define CONFIG_CMD_LOADB
-#define CONFIG_CMD_LOADS
-#define CONFIG_CMD_MEMORY
-#define CONFIG_CMD_MISC
-#define CONFIG_CMD_NET
-#undef CONFIG_CMD_NFS
-#define CONFIG_CMD_PCI
-#define CONFIG_CMD_PING
-#define CONFIG_CMD_RUN
-#define CONFIG_CMD_SAVEENV
-#define CONFIG_CMD_SETGETDCR
-#define CONFIG_CMD_SOURCE
-#define CONFIG_CMD_TIME
-#define CONFIG_CMD_GETTIME
-#define CONFIG_CMD_XIMG
-#define CONFIG_CMD_SCSI
-
-#define CONFIG_CMD_FAT
-#define CONFIG_CMD_EXT2
-
-#define CONFIG_CMD_ZBOOT
-#define CONFIG_CMD_ELF
 
 #define CONFIG_BOOTDELAY       2
-#define CONFIG_BOOTARGS                \
-       "root=/dev/sdb3 init=/sbin/init rootwait ro"
-#define CONFIG_BOOTCOMMAND     \
-       "ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000"
-
-
-#if defined(CONFIG_CMD_KGDB)
-#define CONFIG_KGDB_BAUDRATE                   115200
-#endif
-
-/*
- * Miscellaneous configurable options
- */
-#define CONFIG_SYS_LONGHELP
-#define CONFIG_SYS_CBSIZE                      512
-#define CONFIG_SYS_PBSIZE                      (CONFIG_SYS_CBSIZE + \
-                                                sizeof(CONFIG_SYS_PROMPT) + \
-                                                16)
-#define CONFIG_SYS_MAXARGS                     16
-#define CONFIG_SYS_BARGSIZE                    CONFIG_SYS_CBSIZE
-
-#define CONFIG_SYS_MEMTEST_START               0x00100000
-#define CONFIG_SYS_MEMTEST_END                 0x01000000
-#define CONFIG_SYS_LOAD_ADDR                   0x20000000
-
-/*-----------------------------------------------------------------------
- * SDRAM Configuration
- */
-#define CONFIG_NR_DRAM_BANKS                   4
-
-/* CONFIG_SYS_SDRAM_DRCTMCTL Overrides the following*/
-#undef CONFIG_SYS_SDRAM_PRECHARGE_DELAY
-#undef CONFIG_SYS_SDRAM_RAS_CAS_DELAY
-#undef CONFIG_SYS_SDRAM_CAS_LATENCY_2T
-#undef CONFIG_SYS_SDRAM_CAS_LATENCY_3T
-
-/*-----------------------------------------------------------------------
- * CPU Features
- */
-
-#define CONFIG_SYS_X86_TSC_TIMER
-#define CONFIG_SYS_PCAT_INTERRUPTS
-#define CONFIG_SYS_PCAT_TIMER
-#define CONFIG_SYS_NUM_IRQS                    16
-
-/*-----------------------------------------------------------------------
- * Memory organization:
- * 32kB Stack
- * 16kB Cache-As-RAM @ 0x19200000
- * 256kB Monitor
- * (128kB + Environment Sector Size) malloc pool
- */
-#define CONFIG_SYS_STACK_SIZE                  (32 * 1024)
-#define CONFIG_SYS_CAR_ADDR                    0x19200000
-#define CONFIG_SYS_CAR_SIZE                    (16 * 1024)
-#define CONFIG_SYS_MONITOR_BASE                CONFIG_SYS_TEXT_BASE
-#define CONFIG_SYS_MONITOR_LEN                 (256 * 1024)
-#define CONFIG_SYS_MALLOC_LEN                  (0x20000 + 128 * 1024)
-#define CONFIG_SYS_MALLOC_F_LEN                        (1 << 10)
-
-/* allow to overwrite serial and ethaddr */
-#define CONFIG_ENV_OVERWRITE
-
-/*-----------------------------------------------------------------------
- * FLASH configuration
- */
-#define CONFIG_ICH_SPI
-#define CONFIG_SPI_FLASH
-#define CONFIG_SPI_FLASH_MACRONIX
-#define CONFIG_SPI_FLASH_WINBOND
-#define CONFIG_SPI_FLASH_GIGADEVICE
-#define CONFIG_SYS_NO_FLASH
-#define CONFIG_CMD_SF
-#define CONFIG_CMD_SF_TEST
-#define CONFIG_CMD_SPI
-#define CONFIG_SPI
-
-/*-----------------------------------------------------------------------
- * Environment configuration
- */
-#define CONFIG_ENV_IS_NOWHERE
-#define CONFIG_ENV_SIZE                        0x01000
-
-/*-----------------------------------------------------------------------
- * PCI configuration
- */
-#define CONFIG_PCI
-
-#define CONFIG_CROS_EC
-#define CONFIG_CROS_EC_LPC
-#define CONFIG_CMD_CROS_EC
-#define CONFIG_ARCH_EARLY_INIT_R
-
-/*-----------------------------------------------------------------------
- * USB configuration
- */
-#define CONFIG_USB_EHCI
-#define CONFIG_USB_EHCI_PCI
-#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS     12
-#define CONFIG_USB_MAX_CONTROLLER_COUNT        2
-#define CONFIG_USB_STORAGE
-#define CONFIG_USB_KEYBOARD
-#define CONFIG_SYS_USB_EVENT_POLL
-
-#define CONFIG_USB_HOST_ETHER
-#define CONFIG_USB_ETHER_ASIX
-#define CONFIG_USB_ETHER_SMSC95XX
-#define CONFIG_TFTP_TSIZE
-#define CONFIG_CMD_DHCP
-#define CONFIG_BOOTP_BOOTFILESIZE
-#define CONFIG_BOOTP_BOOTPATH
-#define CONFIG_BOOTP_GATEWAY
-#define CONFIG_BOOTP_HOSTNAME
-
-#define CONFIG_CMD_USB
 
-#define CONFIG_EXTRA_ENV_SETTINGS \
-       CONFIG_STD_DEVICES_SETTINGS
 
 #endif /* __CONFIG_H */
include/configs/x86-common.h new file +12 -0
new file mode 100644
index 0000000..33ff04f
@@ -0,0 +1,272 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ * (C) Copyright 2008
+ * Graeme Russ, graeme.russ at gmail.com.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <asm/ibmpc.h>
+
+#ifndef __CONFIG_X86_COMMON_H
+#define __CONFIG_X86_COMMON_H

include/configs/x86-common.h line 22

Quoted 10 lines
include/configs/x86-common.h new file +10 -0
+
+/*
+ * High Level Configuration Options
+ * (easy to change)
+ */
+#define CONFIG_SHOW_BOOT_PROGRESS
+#define CONFIG_SYS_VSNPRINTF
+#define CONFIG_ZBOOT_32
+#define CONFIG_PHYSMEM
+#define CONFIG_SYS_EARLY_PCI_INIT

CONFIG_SYS_EARLY_PCI_INIT is probably chipset specific?

include/configs/x86-common.h line 29

Quoted 7 lines
include/configs/x86-common.h new file +7 -0
+#define CONFIG_DISPLAY_BOARDINFO_LATE
+#define CONFIG_DISPLAY_CPUINFO
+
+#define CONFIG_DM
+#define CONFIG_CMD_DM
+#define CONFIG_DM_GPIO
+#define CONFIG_DM_SERIAL

One question not related to the patch, is coreboot able to load U-Boot with embedded/separate device tree blob?

Quoted 4 lines
include/configs/x86-common.h new file +4 -0
+#define CONFIG_LMB
+#define CONFIG_OF_LIBFDT
+
+#define CONFIG_LZO

include/configs/x86-common.h line 44

Quoted 10 lines
include/configs/x86-common.h new file +10 -0
+#define CONFIG_FIT
+#undef CONFIG_ZLIB
+#undef CONFIG_GZIP
+#define CONFIG_SYS_BOOTM_LEN           (16 << 20)
+
+/*-----------------------------------------------------------------------
+ * Watchdog Configuration
+ */
+#undef CONFIG_WATCHDOG
+#undef CONFIG_HW_WATCHDOG

Since these two are undefs, can they be removed?

Quoted 5 lines
include/configs/x86-common.h new file +5 -0
+/* SATA AHCI storage */
+
+#define CONFIG_SCSI_AHCI
+#define CONFIG_SATA_INTEL
+#ifdef CONFIG_SCSI_AHCI

include/configs/x86-common.h line 60

Quoted 10 lines
include/configs/x86-common.h new file +10 -0
+#define CONFIG_LIBATA
+#define CONFIG_SYS_64BIT_LBA
+#define CONFIG_SCSI_DEV_LIST           {PCI_VENDOR_ID_INTEL, \
+                       PCI_DEVICE_ID_INTEL_NM10_AHCI},       \
+       {PCI_VENDOR_ID_INTEL,           \
+                       PCI_DEVICE_ID_INTEL_COUGARPOINT_AHCI_MOBILE}, \
+       {PCI_VENDOR_ID_INTEL, \
+                       PCI_DEVICE_ID_INTEL_COUGARPOINT_AHCI_SERIES6}, \
+       {PCI_VENDOR_ID_INTEL,           \
+                       PCI_DEVICE_ID_INTEL_PANTHERPOINT_AHCI_MOBILE}

CONFIG_SCSI_DEV_LIST is chipset specific, should be put into <board>.h I think.

Quoted 12 lines
include/configs/x86-common.h new file +12 -0
+#define CONFIG_SYS_SCSI_MAX_SCSI_ID    2
+#define CONFIG_SYS_SCSI_MAX_LUN                1
+#define CONFIG_SYS_SCSI_MAX_DEVICE     (CONFIG_SYS_SCSI_MAX_SCSI_ID * \
+                                        CONFIG_SYS_SCSI_MAX_LUN)
+#endif
+
+/* Generic TPM interfaced through LPC bus */
+#define CONFIG_TPM
+#define CONFIG_TPM_TIS_LPC
+#define CONFIG_TPM_TIS_BASE_ADDRESS        0xfed40000
+
+/*-----------------------------------------------------------------------

include/configs/x86-common.h line 83

Quoted 10 lines
include/configs/x86-common.h new file +10 -0
+ * Real Time Clock Configuration
+ */
+#define CONFIG_RTC_MC146818
+#define CONFIG_SYS_ISA_IO_BASE_ADDRESS 0
+#define CONFIG_SYS_ISA_IO      CONFIG_SYS_ISA_IO_BASE_ADDRESS
+
+/*-----------------------------------------------------------------------
+ * Serial Configuration
+ */
+#define CONFIG_COREBOOT_SERIAL

Coreboot stuff should be board specific.

Quoted 130 lines
include/configs/x86-common.h new file +130 -0
+#define CONFIG_SYS_NS16550
+#define CONFIG_BAUDRATE                        115200
+#define CONFIG_SYS_BAUDRATE_TABLE      {300, 600, 1200, 2400, 4800, \
+                                        9600, 19200, 38400, 115200}
+#define CONFIG_SYS_NS16550_PORT_MAPPED
+
+#define CONFIG_CONSOLE_MUX
+#define CONFIG_SYS_CONSOLE_IS_IN_ENV
+#define CONFIG_SYS_STDIO_DEREGISTER
+
+#define CONFIG_CMDLINE_EDITING
+#define CONFIG_COMMAND_HISTORY
+#define CONFIG_AUTO_COMPLETE
+#define CONFIG_SYS_HUSH_PARSER
+
+#define CONFIG_SUPPORT_VFAT
+/************************************************************
+ * ATAPI support (experimental)
+ ************************************************************/
+#define CONFIG_ATAPI
+
+/************************************************************
+ * DISK Partition support
+ ************************************************************/
+#define CONFIG_EFI_PARTITION
+#define CONFIG_DOS_PARTITION
+#define CONFIG_MAC_PARTITION
+#define CONFIG_ISO_PARTITION           /* Experimental */
+
+#define CONFIG_CMD_PART
+#define CONFIG_CMD_CBFS
+#define CONFIG_CMD_EXT4
+#define CONFIG_CMD_EXT4_WRITE
+#define CONFIG_PARTITION_UUIDS
+
+#define CONFIG_SYS_CONSOLE_INFO_QUIET
+
+/* x86 GPIOs are accessed through a PCI device */
+#define CONFIG_INTEL_ICH6_GPIO
+
+/*-----------------------------------------------------------------------
+ * Command line configuration.
+ */
+#include <config_cmd_default.h>
+
+#define CONFIG_CMD_BDI
+#define CONFIG_CMD_BOOTD
+#define CONFIG_CMD_CONSOLE
+#define CONFIG_CMD_DATE
+#define CONFIG_CMD_ECHO
+#undef CONFIG_CMD_FLASH
+#define CONFIG_CMD_FPGA
+#define CONFIG_CMD_FPGA_LOADMK
+#define CONFIG_CMD_GPIO
+#define CONFIG_CMD_IMI
+#undef CONFIG_CMD_IMLS
+#define CONFIG_CMD_IO
+#define CONFIG_CMD_IRQ
+#define CONFIG_CMD_ITEST
+#define CONFIG_CMD_LOADB
+#define CONFIG_CMD_LOADS
+#define CONFIG_CMD_MEMORY
+#define CONFIG_CMD_MISC
+#define CONFIG_CMD_NET
+#undef CONFIG_CMD_NFS
+#define CONFIG_CMD_PCI
+#define CONFIG_CMD_PING
+#define CONFIG_CMD_RUN
+#define CONFIG_CMD_SAVEENV
+#define CONFIG_CMD_SETGETDCR
+#define CONFIG_CMD_SOURCE
+#define CONFIG_CMD_TIME
+#define CONFIG_CMD_GETTIME
+#define CONFIG_CMD_XIMG
+#define CONFIG_CMD_SCSI
+
+#define CONFIG_CMD_FAT
+#define CONFIG_CMD_EXT2
+
+#define CONFIG_CMD_ZBOOT
+#define CONFIG_CMD_ELF
+
+#define CONFIG_BOOTARGS                \
+       "root=/dev/sdb3 init=/sbin/init rootwait ro"
+#define CONFIG_BOOTCOMMAND     \
+       "ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000"
+
+#if defined(CONFIG_CMD_KGDB)
+#define CONFIG_KGDB_BAUDRATE                   115200
+#endif
+
+/*
+ * Miscellaneous configurable options
+ */
+#define CONFIG_SYS_LONGHELP
+#define CONFIG_SYS_CBSIZE                      512
+#define CONFIG_SYS_PBSIZE                      (CONFIG_SYS_CBSIZE + \
+                                                sizeof(CONFIG_SYS_PROMPT) + \
+                                                16)
+#define CONFIG_SYS_MAXARGS                     16
+#define CONFIG_SYS_BARGSIZE                    CONFIG_SYS_CBSIZE
+
+#define CONFIG_SYS_MEMTEST_START               0x00100000
+#define CONFIG_SYS_MEMTEST_END                 0x01000000
+#define CONFIG_SYS_LOAD_ADDR                   0x20000000
+
+/*-----------------------------------------------------------------------
+ * Video Configuration
+ */
+#define CONFIG_VIDEO
+#define CONFIG_VIDEO_SW_CURSOR
+#define VIDEO_FB_16BPP_WORD_SWAP
+#define CONFIG_I8042_KBD
+#define CONFIG_CFB_CONSOLE
+
+/*-----------------------------------------------------------------------
+ * CPU Features
+ */
+
+#define CONFIG_SYS_X86_TSC_TIMER
+#define CONFIG_SYS_PCAT_INTERRUPTS
+#define CONFIG_SYS_PCAT_TIMER
+#define CONFIG_SYS_NUM_IRQS                    16
+
+#define CONFIG_SYS_STACK_SIZE                  (32 * 1024)
+#define CONFIG_SYS_MONITOR_BASE                CONFIG_SYS_TEXT_BASE
+#define CONFIG_SYS_MALLOC_LEN                  0x200000
+#define CONFIG_SYS_MALLOC_F_LEN                        (1 << 10)
+
+/* allow to overwrite serial and ethaddr */

include/configs/x86-common.h line 223

Quoted 10 lines
include/configs/x86-common.h new file +10 -0
+#define CONFIG_ENV_OVERWRITE
+
+/*-----------------------------------------------------------------------
+ * FLASH configuration
+ */
+#define CONFIG_ICH_SPI
+#define CONFIG_SPI_FLASH
+#define CONFIG_SPI_FLASH_MACRONIX
+#define CONFIG_SPI_FLASH_WINBOND
+#define CONFIG_SPI_FLASH_GIGADEVICE

Should we include all the avaliable SPI flash here?

Quoted 10 lines
include/configs/x86-common.h new file +10 -0
+#define CONFIG_SYS_NO_FLASH
+#define CONFIG_CMD_SF
+#define CONFIG_CMD_SF_TEST
+#define CONFIG_CMD_SPI
+#define CONFIG_SPI
+
+/*-----------------------------------------------------------------------
+ * Environment configuration
+ */
+#define CONFIG_ENV_IS_NOWHERE

include/configs/x86-common.h line 243

Quoted 10 lines
include/configs/x86-common.h new file +10 -0
+#define CONFIG_ENV_SIZE                        0x01000
+
+/*-----------------------------------------------------------------------
+ * PCI configuration
+ */
+#define CONFIG_PCI
+
+#define CONFIG_CROS_EC
+#define CONFIG_CROS_EC_LPC
+#define CONFIG_CMD_CROS_EC

The CROS_XXX should be board specific?

Quoted 20 lines
include/configs/x86-common.h new file +20 -0
+#define CONFIG_ARCH_EARLY_INIT_R
+
+/*-----------------------------------------------------------------------
+ * USB configuration
+ */
+#define CONFIG_USB_EHCI
+#define CONFIG_USB_EHCI_PCI
+#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS     12
+#define CONFIG_USB_MAX_CONTROLLER_COUNT        2
+#define CONFIG_USB_STORAGE
+#define CONFIG_USB_KEYBOARD
+#define CONFIG_SYS_USB_EVENT_POLL
+
+#define CONFIG_USB_HOST_ETHER
+#define CONFIG_USB_ETHER_ASIX
+#define CONFIG_USB_ETHER_SMSC95XX
+#define CONFIG_TFTP_TSIZE
+#define CONFIG_CMD_DHCP
+#define CONFIG_BOOTP_BOOTFILESIZE
+#define CONFIG_BOOTP_BOOTPATH

include/configs/x86-common.h

Quoted 10 lines
include/configs/x86-common.h new file +9 -1
+#define CONFIG_BOOTP_GATEWAY
+#define CONFIG_BOOTP_HOSTNAME
+
+#define CONFIG_CMD_USB
+
+#define CONFIG_EXTRA_ENV_SETTINGS \
+       CONFIG_STD_DEVICES_SETTINGS
+
+#endif /* __CONFIG_H */
--

Regards,
Bin

#8 lore raw

PATCH 6/39 x86: config: Move common x86 configs to a common file

Hi Bin,

Quoted 377 lines · Bin Meng

Hi Simon,

Quoted 361 lines · Simon Glass

Many of the x86 CONFIG options will be common across different boards. Move them to a common file.

---

 include/configs/coreboot.h   | 289 ++-----------------------------------------
 include/configs/x86-common.h | 272 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 285 insertions(+), 276 deletions(-)
 create mode 100644 include/configs/x86-common.h
include/configs/coreboot.h +13 -276
index fef267f..9ac5306 100644
@@ -6,7 +6,6 @@
  * SPDX-License-Identifier:    GPL-2.0+
  */
 
-#include <asm/ibmpc.h>
 /*
  * board/config.h - configuration options, board specific
  */
@@ -14,27 +13,15 @@
 #ifndef __CONFIG_H
 #define __CONFIG_H
 
-/*
- * High Level Configuration Options
- * (easy to change)
- */
-#define CONFIG_SYS_COREBOOT
-#define CONFIG_SHOW_BOOT_PROGRESS
-#define CONFIG_LAST_STAGE_INIT
-#define CONFIG_SYS_VSNPRINTF
-#define CONFIG_ZBOOT_32
-#define CONFIG_PHYSMEM
-#define CONFIG_SYS_EARLY_PCI_INIT
-#define CONFIG_DISPLAY_BOARDINFO_LATE
-#define CONFIG_DISPLAY_CPUINFO
+#include <configs/x86-common.h>
 
-#define CONFIG_DM
-#define CONFIG_CMD_DM
-#define CONFIG_DM_GPIO
-#define CONFIG_DM_SERIAL
+#define CONFIG_SYS_CAR_ADDR                    0x19200000
+#define CONFIG_SYS_CAR_SIZE                    (16 * 1024)
+#define CONFIG_SYS_MONITOR_LEN                 (256 * 1024)
 
-#define CONFIG_LMB
-#define CONFIG_OF_LIBFDT
+#define CONFIG_TRACE_EARLY_SIZE                (8 << 20)
+#define CONFIG_TRACE_EARLY
+#define CONFIG_TRACE_EARLY_ADDR                0x01400000
 
 #define CONFIG_BOOTSTAGE
 #define CONFIG_BOOTSTAGE_REPORT
@@ -45,278 +32,28 @@
 #define CONFIG_BOOTSTAGE_STASH_SIZE    0x7fc
 #define CONFIG_BOOTSTAGE_USER_COUNT    60
 
-#define CONFIG_LZO
-#define CONFIG_FIT
-#undef CONFIG_ZLIB
-#undef CONFIG_GZIP
-#define CONFIG_SYS_BOOTM_LEN           (16 << 20)
-
-/*-----------------------------------------------------------------------
- * Watchdog Configuration
- */
-#undef CONFIG_WATCHDOG
-#undef CONFIG_HW_WATCHDOG
-
-/* SATA AHCI storage */
-
-#define CONFIG_SCSI_AHCI
-
-#ifdef CONFIG_SCSI_AHCI
-#define CONFIG_LIBATA
-#define CONFIG_SYS_64BIT_LBA
-#define CONFIG_SATA_INTEL              1
-#define CONFIG_SCSI_DEV_LIST           {PCI_VENDOR_ID_INTEL, \
-                       PCI_DEVICE_ID_INTEL_NM10_AHCI},       \
-       {PCI_VENDOR_ID_INTEL,           \
-                       PCI_DEVICE_ID_INTEL_COUGARPOINT_AHCI_MOBILE}, \
-       {PCI_VENDOR_ID_INTEL, \
-                       PCI_DEVICE_ID_INTEL_COUGARPOINT_AHCI_SERIES6}, \
-       {PCI_VENDOR_ID_INTEL,           \
-                       PCI_DEVICE_ID_INTEL_PANTHERPOINT_AHCI_MOBILE}
-
-#define CONFIG_SYS_SCSI_MAX_SCSI_ID    2
-#define CONFIG_SYS_SCSI_MAX_LUN                1
-#define CONFIG_SYS_SCSI_MAX_DEVICE     (CONFIG_SYS_SCSI_MAX_SCSI_ID * \
-                                        CONFIG_SYS_SCSI_MAX_LUN)
-#endif
-
-/* Generic TPM interfaced through LPC bus */
-#define CONFIG_TPM
-#define CONFIG_TPM_TIS_LPC
-#define CONFIG_TPM_TIS_BASE_ADDRESS        0xfed40000
-
-/*-----------------------------------------------------------------------
- * Real Time Clock Configuration
- */
-#define CONFIG_RTC_MC146818
-#define CONFIG_SYS_ISA_IO_BASE_ADDRESS 0
-#define CONFIG_SYS_ISA_IO      CONFIG_SYS_ISA_IO_BASE_ADDRESS
-
-/*-----------------------------------------------------------------------
- * Serial Configuration
+/*
+ * High Level Configuration Options
+ * (easy to change)
  */
-#define CONFIG_COREBOOT_SERIAL
-#define CONFIG_SYS_NS16550
-#define CONFIG_BAUDRATE                        115200
-#define CONFIG_SYS_BAUDRATE_TABLE      {300, 600, 1200, 2400, 4800, \
-                                        9600, 19200, 38400, 115200}
-#define CONFIG_SYS_NS16550_PORT_MAPPED
+#define CONFIG_SYS_COREBOOT
+#define CONFIG_LAST_STAGE_INIT
 
 #define CONFIG_STD_DEVICES_SETTINGS     "stdin=usbkbd,vga,serial\0" \
                                        "stdout=vga,serial,cbmem\0" \
                                        "stderr=vga,serial,cbmem\0"
 
-#define CONFIG_CONSOLE_MUX
-#define CONFIG_SYS_CONSOLE_IS_IN_ENV
-#define CONFIG_SYS_STDIO_DEREGISTER
 #define CONFIG_CBMEM_CONSOLE
 
-#define CONFIG_CMDLINE_EDITING
-#define CONFIG_COMMAND_HISTORY
-#define CONFIG_AUTO_COMPLETE
-#define CONFIG_SYS_HUSH_PARSER
-
-#define CONFIG_SUPPORT_VFAT
-/************************************************************
- * ATAPI support (experimental)
- ************************************************************/
-#define CONFIG_ATAPI
-
-/************************************************************
- * DISK Partition support
- ************************************************************/
-#define CONFIG_EFI_PARTITION
-#define CONFIG_DOS_PARTITION
-#define CONFIG_MAC_PARTITION
-#define CONFIG_ISO_PARTITION           /* Experimental */
-
-#define CONFIG_CMD_PART
-#define CONFIG_CMD_CBFS
-#define CONFIG_CMD_EXT4
-#define CONFIG_CMD_EXT4_WRITE
-#define CONFIG_PARTITION_UUIDS
-
-/*-----------------------------------------------------------------------
- * Video Configuration
- */
-#define CONFIG_VIDEO
 #define CONFIG_VIDEO_COREBOOT
-#define CONFIG_VIDEO_SW_CURSOR
-#define VIDEO_FB_16BPP_WORD_SWAP
-#define CONFIG_I8042_KBD
-#define CONFIG_CFB_CONSOLE
-#define CONFIG_SYS_CONSOLE_INFO_QUIET
 
-/* x86 GPIOs are accessed through a PCI device */
-#define CONFIG_INTEL_ICH6_GPIO
-
-/*-----------------------------------------------------------------------
- * Command line configuration.
- */
-#include <config_cmd_default.h>
+#define CONFIG_NR_DRAM_BANKS                   4
 
 #define CONFIG_TRACE
 #define CONFIG_CMD_TRACE
 #define CONFIG_TRACE_BUFFER_SIZE       (16 << 20)
-#define CONFIG_TRACE_EARLY_SIZE                (8 << 20)
-#define CONFIG_TRACE_EARLY
-#define CONFIG_TRACE_EARLY_ADDR                0x01400000
-
-#define CONFIG_CMD_BDI
-#define CONFIG_CMD_BOOTD
-#define CONFIG_CMD_CONSOLE
-#define CONFIG_CMD_DATE
-#define CONFIG_CMD_ECHO
-#undef CONFIG_CMD_FLASH
-#define CONFIG_CMD_FPGA
-#define CONFIG_CMD_FPGA_LOADMK
-#define CONFIG_CMD_GPIO
-#define CONFIG_CMD_IMI
-#undef CONFIG_CMD_IMLS
-#define CONFIG_CMD_IO
-#define CONFIG_CMD_IRQ
-#define CONFIG_CMD_ITEST
-#define CONFIG_CMD_LOADB
-#define CONFIG_CMD_LOADS
-#define CONFIG_CMD_MEMORY
-#define CONFIG_CMD_MISC
-#define CONFIG_CMD_NET
-#undef CONFIG_CMD_NFS
-#define CONFIG_CMD_PCI
-#define CONFIG_CMD_PING
-#define CONFIG_CMD_RUN
-#define CONFIG_CMD_SAVEENV
-#define CONFIG_CMD_SETGETDCR
-#define CONFIG_CMD_SOURCE
-#define CONFIG_CMD_TIME
-#define CONFIG_CMD_GETTIME
-#define CONFIG_CMD_XIMG
-#define CONFIG_CMD_SCSI
-
-#define CONFIG_CMD_FAT
-#define CONFIG_CMD_EXT2
-
-#define CONFIG_CMD_ZBOOT
-#define CONFIG_CMD_ELF
 
 #define CONFIG_BOOTDELAY       2
-#define CONFIG_BOOTARGS                \
-       "root=/dev/sdb3 init=/sbin/init rootwait ro"
-#define CONFIG_BOOTCOMMAND     \
-       "ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000"
-
-
-#if defined(CONFIG_CMD_KGDB)
-#define CONFIG_KGDB_BAUDRATE                   115200
-#endif
-
-/*
- * Miscellaneous configurable options
- */
-#define CONFIG_SYS_LONGHELP
-#define CONFIG_SYS_CBSIZE                      512
-#define CONFIG_SYS_PBSIZE                      (CONFIG_SYS_CBSIZE + \
-                                                sizeof(CONFIG_SYS_PROMPT) + \
-                                                16)
-#define CONFIG_SYS_MAXARGS                     16
-#define CONFIG_SYS_BARGSIZE                    CONFIG_SYS_CBSIZE
-
-#define CONFIG_SYS_MEMTEST_START               0x00100000
-#define CONFIG_SYS_MEMTEST_END                 0x01000000
-#define CONFIG_SYS_LOAD_ADDR                   0x20000000
-
-/*-----------------------------------------------------------------------
- * SDRAM Configuration
- */
-#define CONFIG_NR_DRAM_BANKS                   4
-
-/* CONFIG_SYS_SDRAM_DRCTMCTL Overrides the following*/
-#undef CONFIG_SYS_SDRAM_PRECHARGE_DELAY
-#undef CONFIG_SYS_SDRAM_RAS_CAS_DELAY
-#undef CONFIG_SYS_SDRAM_CAS_LATENCY_2T
-#undef CONFIG_SYS_SDRAM_CAS_LATENCY_3T
-
-/*-----------------------------------------------------------------------
- * CPU Features
- */
-
-#define CONFIG_SYS_X86_TSC_TIMER
-#define CONFIG_SYS_PCAT_INTERRUPTS
-#define CONFIG_SYS_PCAT_TIMER
-#define CONFIG_SYS_NUM_IRQS                    16
-
-/*-----------------------------------------------------------------------
- * Memory organization:
- * 32kB Stack
- * 16kB Cache-As-RAM @ 0x19200000
- * 256kB Monitor
- * (128kB + Environment Sector Size) malloc pool
- */
-#define CONFIG_SYS_STACK_SIZE                  (32 * 1024)
-#define CONFIG_SYS_CAR_ADDR                    0x19200000
-#define CONFIG_SYS_CAR_SIZE                    (16 * 1024)
-#define CONFIG_SYS_MONITOR_BASE                CONFIG_SYS_TEXT_BASE
-#define CONFIG_SYS_MONITOR_LEN                 (256 * 1024)
-#define CONFIG_SYS_MALLOC_LEN                  (0x20000 + 128 * 1024)
-#define CONFIG_SYS_MALLOC_F_LEN                        (1 << 10)
-
-/* allow to overwrite serial and ethaddr */
-#define CONFIG_ENV_OVERWRITE
-
-/*-----------------------------------------------------------------------
- * FLASH configuration
- */
-#define CONFIG_ICH_SPI
-#define CONFIG_SPI_FLASH
-#define CONFIG_SPI_FLASH_MACRONIX
-#define CONFIG_SPI_FLASH_WINBOND
-#define CONFIG_SPI_FLASH_GIGADEVICE
-#define CONFIG_SYS_NO_FLASH
-#define CONFIG_CMD_SF
-#define CONFIG_CMD_SF_TEST
-#define CONFIG_CMD_SPI
-#define CONFIG_SPI
-
-/*-----------------------------------------------------------------------
- * Environment configuration
- */
-#define CONFIG_ENV_IS_NOWHERE
-#define CONFIG_ENV_SIZE                        0x01000
-
-/*-----------------------------------------------------------------------
- * PCI configuration
- */
-#define CONFIG_PCI
-
-#define CONFIG_CROS_EC
-#define CONFIG_CROS_EC_LPC
-#define CONFIG_CMD_CROS_EC
-#define CONFIG_ARCH_EARLY_INIT_R
-
-/*-----------------------------------------------------------------------
- * USB configuration
- */
-#define CONFIG_USB_EHCI
-#define CONFIG_USB_EHCI_PCI
-#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS     12
-#define CONFIG_USB_MAX_CONTROLLER_COUNT        2
-#define CONFIG_USB_STORAGE
-#define CONFIG_USB_KEYBOARD
-#define CONFIG_SYS_USB_EVENT_POLL
-
-#define CONFIG_USB_HOST_ETHER
-#define CONFIG_USB_ETHER_ASIX
-#define CONFIG_USB_ETHER_SMSC95XX
-#define CONFIG_TFTP_TSIZE
-#define CONFIG_CMD_DHCP
-#define CONFIG_BOOTP_BOOTFILESIZE
-#define CONFIG_BOOTP_BOOTPATH
-#define CONFIG_BOOTP_GATEWAY
-#define CONFIG_BOOTP_HOSTNAME
-
-#define CONFIG_CMD_USB
 
-#define CONFIG_EXTRA_ENV_SETTINGS \
-       CONFIG_STD_DEVICES_SETTINGS
 
 #endif /* __CONFIG_H */
include/configs/x86-common.h new file +12 -0
new file mode 100644
index 0000000..33ff04f
@@ -0,0 +1,272 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ * (C) Copyright 2008
+ * Graeme Russ, graeme.russ at gmail.com.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <asm/ibmpc.h>
+
+#ifndef __CONFIG_X86_COMMON_H
+#define __CONFIG_X86_COMMON_H

include/configs/x86-common.h line 22

Quoted 10 lines
include/configs/x86-common.h new file +10 -0
+
+/*
+ * High Level Configuration Options
+ * (easy to change)
+ */
+#define CONFIG_SHOW_BOOT_PROGRESS
+#define CONFIG_SYS_VSNPRINTF
+#define CONFIG_ZBOOT_32
+#define CONFIG_PHYSMEM
+#define CONFIG_SYS_EARLY_PCI_INIT

CONFIG_SYS_EARLY_PCI_INIT is probably chipset specific?

Quoted 10 lines

include/configs/x86-common.h line 29

Quoted 7 lines
include/configs/x86-common.h new file +7 -0
+#define CONFIG_DISPLAY_BOARDINFO_LATE
+#define CONFIG_DISPLAY_CPUINFO
+
+#define CONFIG_DM
+#define CONFIG_CMD_DM
+#define CONFIG_DM_GPIO
+#define CONFIG_DM_SERIAL

One question not related to the patch, is coreboot able to load U-Boot with embedded/separate device tree blob?

Yes. In the embedded case, U-Boot will just used the embedded FDT. In the separate case, your put u-boot-dtb.bin in as the Coreboot payload.

Quoted 17 lines
Quoted 5 lines
include/configs/x86-common.h new file +4 -0
+#define CONFIG_LMB
+#define CONFIG_OF_LIBFDT
+
+#define CONFIG_LZO

include/configs/x86-common.h line 44

Quoted 10 lines
include/configs/x86-common.h new file +10 -0
+#define CONFIG_FIT
+#undef CONFIG_ZLIB
+#undef CONFIG_GZIP
+#define CONFIG_SYS_BOOTM_LEN           (16 << 20)
+
+/*-----------------------------------------------------------------------
+ * Watchdog Configuration
+ */
+#undef CONFIG_WATCHDOG
+#undef CONFIG_HW_WATCHDOG

Since these two are undefs, can they be removed?

OK

Quoted 10 lines
Quoted 10 lines
include/configs/x86-common.h new file +9 -0
+/* SATA AHCI storage */
+
+#define CONFIG_SCSI_AHCI
+#define CONFIG_SATA_INTEL
+#ifdef CONFIG_SCSI_AHCI
+#define CONFIG_LIBATA
+#define CONFIG_SYS_64BIT_LBA
+#define CONFIG_SCSI_DEV_LIST           {PCI_VENDOR_ID_INTEL, \
+                       PCI_DEVICE_ID_INTEL_NM10_AHCI},       \
Quoted 8 lines

include/configs/x86-common.h line 60

Quoted 6 lines
include/configs/x86-common.h new file +6 -0
+       {PCI_VENDOR_ID_INTEL,           \
+                       PCI_DEVICE_ID_INTEL_COUGARPOINT_AHCI_MOBILE}, \
+       {PCI_VENDOR_ID_INTEL, \
+                       PCI_DEVICE_ID_INTEL_COUGARPOINT_AHCI_SERIES6}, \
+       {PCI_VENDOR_ID_INTEL,           \
+                       PCI_DEVICE_ID_INTEL_PANTHERPOINT_AHCI_MOBILE}

CONFIG_SCSI_DEV_LIST is chipset specific, should be put into <board>.h I think.

Fair enough. Hoping to drop this one day with driver model.

Quoted 17 lines
Quoted 17 lines
include/configs/x86-common.h new file +16 -0
+#define CONFIG_SYS_SCSI_MAX_SCSI_ID    2
+#define CONFIG_SYS_SCSI_MAX_LUN                1
+#define CONFIG_SYS_SCSI_MAX_DEVICE     (CONFIG_SYS_SCSI_MAX_SCSI_ID * \
+                                        CONFIG_SYS_SCSI_MAX_LUN)
+#endif
+
+/* Generic TPM interfaced through LPC bus */
+#define CONFIG_TPM
+#define CONFIG_TPM_TIS_LPC
+#define CONFIG_TPM_TIS_BASE_ADDRESS        0xfed40000
+
+/*-----------------------------------------------------------------------
+ * Real Time Clock Configuration
+ */
+#define CONFIG_RTC_MC146818
+#define CONFIG_SYS_ISA_IO_BASE_ADDRESS 0
Quoted 8 lines

include/configs/x86-common.h line 83

Quoted 6 lines
include/configs/x86-common.h new file +6 -0
+#define CONFIG_SYS_ISA_IO      CONFIG_SYS_ISA_IO_BASE_ADDRESS
+
+/*-----------------------------------------------------------------------
+ * Serial Configuration
+ */
+#define CONFIG_COREBOOT_SERIAL

Coreboot stuff should be board specific.

OK

Quoted 135 lines
Quoted 135 lines
include/configs/x86-common.h new file +134 -0
+#define CONFIG_SYS_NS16550
+#define CONFIG_BAUDRATE                        115200
+#define CONFIG_SYS_BAUDRATE_TABLE      {300, 600, 1200, 2400, 4800, \
+                                        9600, 19200, 38400, 115200}
+#define CONFIG_SYS_NS16550_PORT_MAPPED
+
+#define CONFIG_CONSOLE_MUX
+#define CONFIG_SYS_CONSOLE_IS_IN_ENV
+#define CONFIG_SYS_STDIO_DEREGISTER
+
+#define CONFIG_CMDLINE_EDITING
+#define CONFIG_COMMAND_HISTORY
+#define CONFIG_AUTO_COMPLETE
+#define CONFIG_SYS_HUSH_PARSER
+
+#define CONFIG_SUPPORT_VFAT
+/************************************************************
+ * ATAPI support (experimental)
+ ************************************************************/
+#define CONFIG_ATAPI
+
+/************************************************************
+ * DISK Partition support
+ ************************************************************/
+#define CONFIG_EFI_PARTITION
+#define CONFIG_DOS_PARTITION
+#define CONFIG_MAC_PARTITION
+#define CONFIG_ISO_PARTITION           /* Experimental */
+
+#define CONFIG_CMD_PART
+#define CONFIG_CMD_CBFS
+#define CONFIG_CMD_EXT4
+#define CONFIG_CMD_EXT4_WRITE
+#define CONFIG_PARTITION_UUIDS
+
+#define CONFIG_SYS_CONSOLE_INFO_QUIET
+
+/* x86 GPIOs are accessed through a PCI device */
+#define CONFIG_INTEL_ICH6_GPIO
+
+/*-----------------------------------------------------------------------
+ * Command line configuration.
+ */
+#include <config_cmd_default.h>
+
+#define CONFIG_CMD_BDI
+#define CONFIG_CMD_BOOTD
+#define CONFIG_CMD_CONSOLE
+#define CONFIG_CMD_DATE
+#define CONFIG_CMD_ECHO
+#undef CONFIG_CMD_FLASH
+#define CONFIG_CMD_FPGA
+#define CONFIG_CMD_FPGA_LOADMK
+#define CONFIG_CMD_GPIO
+#define CONFIG_CMD_IMI
+#undef CONFIG_CMD_IMLS
+#define CONFIG_CMD_IO
+#define CONFIG_CMD_IRQ
+#define CONFIG_CMD_ITEST
+#define CONFIG_CMD_LOADB
+#define CONFIG_CMD_LOADS
+#define CONFIG_CMD_MEMORY
+#define CONFIG_CMD_MISC
+#define CONFIG_CMD_NET
+#undef CONFIG_CMD_NFS
+#define CONFIG_CMD_PCI
+#define CONFIG_CMD_PING
+#define CONFIG_CMD_RUN
+#define CONFIG_CMD_SAVEENV
+#define CONFIG_CMD_SETGETDCR
+#define CONFIG_CMD_SOURCE
+#define CONFIG_CMD_TIME
+#define CONFIG_CMD_GETTIME
+#define CONFIG_CMD_XIMG
+#define CONFIG_CMD_SCSI
+
+#define CONFIG_CMD_FAT
+#define CONFIG_CMD_EXT2
+
+#define CONFIG_CMD_ZBOOT
+#define CONFIG_CMD_ELF
+
+#define CONFIG_BOOTARGS                \
+       "root=/dev/sdb3 init=/sbin/init rootwait ro"
+#define CONFIG_BOOTCOMMAND     \
+       "ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000"
+
+#if defined(CONFIG_CMD_KGDB)
+#define CONFIG_KGDB_BAUDRATE                   115200
+#endif
+
+/*
+ * Miscellaneous configurable options
+ */
+#define CONFIG_SYS_LONGHELP
+#define CONFIG_SYS_CBSIZE                      512
+#define CONFIG_SYS_PBSIZE                      (CONFIG_SYS_CBSIZE + \
+                                                sizeof(CONFIG_SYS_PROMPT) + \
+                                                16)
+#define CONFIG_SYS_MAXARGS                     16
+#define CONFIG_SYS_BARGSIZE                    CONFIG_SYS_CBSIZE
+
+#define CONFIG_SYS_MEMTEST_START               0x00100000
+#define CONFIG_SYS_MEMTEST_END                 0x01000000
+#define CONFIG_SYS_LOAD_ADDR                   0x20000000
+
+/*-----------------------------------------------------------------------
+ * Video Configuration
+ */
+#define CONFIG_VIDEO
+#define CONFIG_VIDEO_SW_CURSOR
+#define VIDEO_FB_16BPP_WORD_SWAP
+#define CONFIG_I8042_KBD
+#define CONFIG_CFB_CONSOLE
+
+/*-----------------------------------------------------------------------
+ * CPU Features
+ */
+
+#define CONFIG_SYS_X86_TSC_TIMER
+#define CONFIG_SYS_PCAT_INTERRUPTS
+#define CONFIG_SYS_PCAT_TIMER
+#define CONFIG_SYS_NUM_IRQS                    16
+
+#define CONFIG_SYS_STACK_SIZE                  (32 * 1024)
+#define CONFIG_SYS_MONITOR_BASE                CONFIG_SYS_TEXT_BASE
+#define CONFIG_SYS_MALLOC_LEN                  0x200000
+#define CONFIG_SYS_MALLOC_F_LEN                        (1 << 10)
+
+/* allow to overwrite serial and ethaddr */
+#define CONFIG_ENV_OVERWRITE
+
+/*-----------------------------------------------------------------------
+ * FLASH configuration
Quoted 8 lines

include/configs/x86-common.h line 223

Quoted 6 lines
include/configs/x86-common.h new file +6 -0
+ */
+#define CONFIG_ICH_SPI
+#define CONFIG_SPI_FLASH
+#define CONFIG_SPI_FLASH_MACRONIX
+#define CONFIG_SPI_FLASH_WINBOND
+#define CONFIG_SPI_FLASH_GIGADEVICE

Should we include all the avaliable SPI flash here?

We can add more as platforms need it.

Quoted 15 lines
Quoted 15 lines
include/configs/x86-common.h new file +14 -0
+#define CONFIG_SYS_NO_FLASH
+#define CONFIG_CMD_SF
+#define CONFIG_CMD_SF_TEST
+#define CONFIG_CMD_SPI
+#define CONFIG_SPI
+
+/*-----------------------------------------------------------------------
+ * Environment configuration
+ */
+#define CONFIG_ENV_IS_NOWHERE
+#define CONFIG_ENV_SIZE                        0x01000
+
+/*-----------------------------------------------------------------------
+ * PCI configuration
Quoted 8 lines

include/configs/x86-common.h line 243

Quoted 6 lines
include/configs/x86-common.h new file +6 -0
+ */
+#define CONFIG_PCI
+
+#define CONFIG_CROS_EC
+#define CONFIG_CROS_EC_LPC
+#define CONFIG_CMD_CROS_EC

The CROS_XXX should be board specific?

OK. I may end up with a Chrome OS-specific common file.

Quoted 22 lines
Quoted 22 lines
include/configs/x86-common.h new file +21 -0
+#define CONFIG_ARCH_EARLY_INIT_R
+
+/*-----------------------------------------------------------------------
+ * USB configuration
+ */
+#define CONFIG_USB_EHCI
+#define CONFIG_USB_EHCI_PCI
+#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS     12
+#define CONFIG_USB_MAX_CONTROLLER_COUNT        2
+#define CONFIG_USB_STORAGE
+#define CONFIG_USB_KEYBOARD
+#define CONFIG_SYS_USB_EVENT_POLL
+
+#define CONFIG_USB_HOST_ETHER
+#define CONFIG_USB_ETHER_ASIX
+#define CONFIG_USB_ETHER_SMSC95XX
+#define CONFIG_TFTP_TSIZE
+#define CONFIG_CMD_DHCP
+#define CONFIG_BOOTP_BOOTFILESIZE
+#define CONFIG_BOOTP_BOOTPATH
+#define CONFIG_BOOTP_GATEWAY
Quoted 8 lines

include/configs/x86-common.h line 272

Quoted 8 lines
include/configs/x86-common.h new file +8 -0
+#define CONFIG_BOOTP_HOSTNAME
+
+#define CONFIG_CMD_USB
+
+#define CONFIG_EXTRA_ENV_SETTINGS \
+       CONFIG_STD_DEVICES_SETTINGS
+
+#endif /* __CONFIG_H */

Regards,
Simon

#9 lore raw

PATCH 7/39 x86: Add processor functions for cpuid and stack pointer

In reply to Simon Glass

Add some functions to access cpuid from C in various useful ways. Also add a function to get the stack pointer and another to halt the CPU.

---

 arch/x86/include/asm/processor.h | 121 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 121 insertions(+)
arch/x86/include/asm/processor.h +121 -0
index bb3172f..30d7d48 100644
@@ -30,4 +30,125 @@ enum {
 
 #define X86_GDT_SIZE		(X86_GDT_NUM_ENTRIES * X86_GDT_ENTRY_SIZE)
 
+#ifndef __ASSEMBLY__
+
+static inline __attribute__((always_inline)) void cpu_hlt(void)
+{
+	asm("hlt");
+}
+
+struct cpuid_result {
+	uint32_t eax;
+	uint32_t ebx;
+	uint32_t ecx;
+	uint32_t edx;
+};
+
+/*
+ * Generic CPUID function
+ */
+static inline struct cpuid_result cpuid(int op)
+{
+	struct cpuid_result result;
+	asm volatile(
+		"mov %%ebx, %%edi;"
+		"cpuid;"
+		"mov %%ebx, %%esi;"
+		"mov %%edi, %%ebx;"
+		: "=a" (result.eax),
+		  "=S" (result.ebx),
+		  "=c" (result.ecx),
+		  "=d" (result.edx)
+		: "0" (op)
+		: "edi");
+	return result;
+}
+
+/*
+ * Generic Extended CPUID function
+ */
+static inline struct cpuid_result cpuid_ext(int op, unsigned ecx)
+{
+	struct cpuid_result result;
+	asm volatile(
+		"mov %%ebx, %%edi;"
+		"cpuid;"
+		"mov %%ebx, %%esi;"
+		"mov %%edi, %%ebx;"
+		: "=a" (result.eax),
+		  "=S" (result.ebx),
+		  "=c" (result.ecx),
+		  "=d" (result.edx)
+		: "0" (op), "2" (ecx)
+		: "edi");
+	return result;
+}
+
+static inline ulong cpu_get_sp(void)
+{
+	ulong result;
+
+	asm volatile(
+		"mov %%esp, %%eax"
+		: "=a" (result));
+	return result;
+}
+
+/*
+ * CPUID functions returning a single datum
+ */
+static inline unsigned int cpuid_eax(unsigned int op)
+{
+	unsigned int eax;
+
+	__asm__("mov %%ebx, %%edi;"
+		"cpuid;"
+		"mov %%edi, %%ebx;"
+		: "=a" (eax)
+		: "0" (op)
+		: "ecx", "edx", "edi");
+	return eax;
+}
+
+static inline unsigned int cpuid_ebx(unsigned int op)
+{
+	unsigned int eax, ebx;
+
+	__asm__("mov %%ebx, %%edi;"
+		"cpuid;"
+		"mov %%ebx, %%esi;"
+		"mov %%edi, %%ebx;"
+		: "=a" (eax), "=S" (ebx)
+		: "0" (op)
+		: "ecx", "edx", "edi");
+	return ebx;
+}
+
+static inline unsigned int cpuid_ecx(unsigned int op)
+{
+	unsigned int eax, ecx;
+
+	__asm__("mov %%ebx, %%edi;"
+		"cpuid;"
+		"mov %%edi, %%ebx;"
+		: "=a" (eax), "=c" (ecx)
+		: "0" (op)
+		: "edx", "edi");
+	return ecx;
+}
+
+static inline unsigned int cpuid_edx(unsigned int op)
+{
+	unsigned int eax, edx;
+
+	__asm__("mov %%ebx, %%edi;"
+		"cpuid;"
+		"mov %%edi, %%ebx;"
+		: "=a" (eax), "=d" (edx)
+		: "0" (op)
+		: "ecx", "edi");
+	return edx;
+}
+#endif /* __ASSEMBLY__ */
+
 #endif
Signature · 1 line
2.1.0.rc2.206.gedb03e5
#10 lore raw

PATCH 7/39 x86: Add processor functions for cpuid and stack pointer

Hi Simon,

Quoted 129 lines · Simon Glass

Add some functions to access cpuid from C in various useful ways. Also add a function to get the stack pointer and another to halt the CPU.

---

 arch/x86/include/asm/processor.h | 121 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 121 insertions(+)
arch/x86/include/asm/processor.h +112 -0
index bb3172f..30d7d48 100644
@@ -30,4 +30,125 @@ enum {
 
 #define X86_GDT_SIZE           (X86_GDT_NUM_ENTRIES * X86_GDT_ENTRY_SIZE)
 
+#ifndef __ASSEMBLY__
+
+static inline __attribute__((always_inline)) void cpu_hlt(void)
+{
+       asm("hlt");
+}
+
+struct cpuid_result {
+       uint32_t eax;
+       uint32_t ebx;
+       uint32_t ecx;
+       uint32_t edx;
+};
+
+/*
+ * Generic CPUID function
+ */
+static inline struct cpuid_result cpuid(int op)
+{
+       struct cpuid_result result;
+       asm volatile(
+               "mov %%ebx, %%edi;"
+               "cpuid;"
+               "mov %%ebx, %%esi;"
+               "mov %%edi, %%ebx;"
+               : "=a" (result.eax),
+                 "=S" (result.ebx),
+                 "=c" (result.ecx),
+                 "=d" (result.edx)
+               : "0" (op)
+               : "edi");
+       return result;
+}
+
+/*
+ * Generic Extended CPUID function
+ */
+static inline struct cpuid_result cpuid_ext(int op, unsigned ecx)
+{
+       struct cpuid_result result;
+       asm volatile(
+               "mov %%ebx, %%edi;"
+               "cpuid;"
+               "mov %%ebx, %%esi;"
+               "mov %%edi, %%ebx;"
+               : "=a" (result.eax),
+                 "=S" (result.ebx),
+                 "=c" (result.ecx),
+                 "=d" (result.edx)
+               : "0" (op), "2" (ecx)
+               : "edi");
+       return result;
+}
+
+static inline ulong cpu_get_sp(void)
+{
+       ulong result;
+
+       asm volatile(
+               "mov %%esp, %%eax"
+               : "=a" (result));
+       return result;
+}
+
+/*
+ * CPUID functions returning a single datum
+ */
+static inline unsigned int cpuid_eax(unsigned int op)
+{
+       unsigned int eax;
+
+       __asm__("mov %%ebx, %%edi;"
+               "cpuid;"
+               "mov %%edi, %%ebx;"
+               : "=a" (eax)
+               : "0" (op)
+               : "ecx", "edx", "edi");
+       return eax;
+}
+
+static inline unsigned int cpuid_ebx(unsigned int op)
+{
+       unsigned int eax, ebx;
+
+       __asm__("mov %%ebx, %%edi;"
+               "cpuid;"
+               "mov %%ebx, %%esi;"
+               "mov %%edi, %%ebx;"
+               : "=a" (eax), "=S" (ebx)
+               : "0" (op)
+               : "ecx", "edx", "edi");
+       return ebx;
+}
+
+static inline unsigned int cpuid_ecx(unsigned int op)
+{
+       unsigned int eax, ecx;
+
+       __asm__("mov %%ebx, %%edi;"
+               "cpuid;"
+               "mov %%edi, %%ebx;"
+               : "=a" (eax), "=c" (ecx)
+               : "0" (op)
+               : "edx", "edi");
+       return ecx;
+}
+
+static inline unsigned int cpuid_edx(unsigned int op)
+{
+       unsigned int eax, edx;
+
+       __asm__("mov %%ebx, %%edi;"

arch/x86/include/asm/processor.h enum { · line 154

Quoted 10 lines
arch/x86/include/asm/processor.h +9 -0
+               "cpuid;"
+               "mov %%edi, %%ebx;"
+               : "=a" (eax), "=d" (edx)
+               : "0" (op)
+               : "ecx", "edi");
+       return edx;
+}
+#endif /* __ASSEMBLY__ */
+
 #endif

My previous patch (http://patchwork.ozlabs.org/patch/406636/)
introduced these cpuid_xxx functions already. Would you consider merging the two patches?

Regards,
Bin

#11 lore raw

PATCH 7/39 x86: Add processor functions for cpuid and stack pointer

Hi Bin,

Quoted 138 lines · Bin Meng

Hi Simon,

Quoted 135 lines · Simon Glass

Add some functions to access cpuid from C in various useful ways. Also add a function to get the stack pointer and another to halt the CPU.

---

 arch/x86/include/asm/processor.h | 121 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 121 insertions(+)
arch/x86/include/asm/processor.h +118 -0
index bb3172f..30d7d48 100644
@@ -30,4 +30,125 @@ enum {
 
 #define X86_GDT_SIZE           (X86_GDT_NUM_ENTRIES * X86_GDT_ENTRY_SIZE)
 
+#ifndef __ASSEMBLY__
+
+static inline __attribute__((always_inline)) void cpu_hlt(void)
+{
+       asm("hlt");
+}
+
+struct cpuid_result {
+       uint32_t eax;
+       uint32_t ebx;
+       uint32_t ecx;
+       uint32_t edx;
+};
+
+/*
+ * Generic CPUID function
+ */
+static inline struct cpuid_result cpuid(int op)
+{
+       struct cpuid_result result;
+       asm volatile(
+               "mov %%ebx, %%edi;"
+               "cpuid;"
+               "mov %%ebx, %%esi;"
+               "mov %%edi, %%ebx;"
+               : "=a" (result.eax),
+                 "=S" (result.ebx),
+                 "=c" (result.ecx),
+                 "=d" (result.edx)
+               : "0" (op)
+               : "edi");
+       return result;
+}
+
+/*
+ * Generic Extended CPUID function
+ */
+static inline struct cpuid_result cpuid_ext(int op, unsigned ecx)
+{
+       struct cpuid_result result;
+       asm volatile(
+               "mov %%ebx, %%edi;"
+               "cpuid;"
+               "mov %%ebx, %%esi;"
+               "mov %%edi, %%ebx;"
+               : "=a" (result.eax),
+                 "=S" (result.ebx),
+                 "=c" (result.ecx),
+                 "=d" (result.edx)
+               : "0" (op), "2" (ecx)
+               : "edi");
+       return result;
+}
+
+static inline ulong cpu_get_sp(void)
+{
+       ulong result;
+
+       asm volatile(
+               "mov %%esp, %%eax"
+               : "=a" (result));
+       return result;
+}
+
+/*
+ * CPUID functions returning a single datum
+ */
+static inline unsigned int cpuid_eax(unsigned int op)
+{
+       unsigned int eax;
+
+       __asm__("mov %%ebx, %%edi;"
+               "cpuid;"
+               "mov %%edi, %%ebx;"
+               : "=a" (eax)
+               : "0" (op)
+               : "ecx", "edx", "edi");
+       return eax;
+}
+
+static inline unsigned int cpuid_ebx(unsigned int op)
+{
+       unsigned int eax, ebx;
+
+       __asm__("mov %%ebx, %%edi;"
+               "cpuid;"
+               "mov %%ebx, %%esi;"
+               "mov %%edi, %%ebx;"
+               : "=a" (eax), "=S" (ebx)
+               : "0" (op)
+               : "ecx", "edx", "edi");
+       return ebx;
+}
+
+static inline unsigned int cpuid_ecx(unsigned int op)
+{
+       unsigned int eax, ecx;
+
+       __asm__("mov %%ebx, %%edi;"
+               "cpuid;"
+               "mov %%edi, %%ebx;"
+               : "=a" (eax), "=c" (ecx)
+               : "0" (op)
+               : "edx", "edi");
+       return ecx;
+}
+
+static inline unsigned int cpuid_edx(unsigned int op)
+{
+       unsigned int eax, edx;
+
+       __asm__("mov %%ebx, %%edi;"
+               "cpuid;"
+               "mov %%edi, %%ebx;"
+               : "=a" (eax), "=d" (edx)
+               : "0" (op)
+               : "ecx", "edi");
+       return edx;
Quoted 8 lines

arch/x86/include/asm/processor.h enum { · line 154

Quoted 4 lines
arch/x86/include/asm/processor.h +3 -0
+}
+#endif /* __ASSEMBLY__ */
+
 #endif

My previous patch (http://patchwork.ozlabs.org/patch/406636/)
introduced these cpuid_xxx functions already. Would you consider merging the two patches?

Yes I saw your patch, thank you. I will sort it out once I get a chance to test your series. Have been travelling.

Regards,
Simon

#12 lore raw

PATCH 8/39 x86: Remove REALMODE_BASE which is no longer used

In reply to Simon Glass

This was missed when the real mode support was dropped. Remove it.

---

 arch/x86/config.mk | 1 -
 1 file changed, 1 deletion(-)
arch/x86/config.mk +0 -1
index 3e7fedb..bb2da46 100644
@@ -15,7 +15,6 @@ PF_CPPFLAGS_X86   := $(call cc-option, -fno-toplevel-reorder, \
 		     $(call cc-option, -mpreferred-stack-boundary=2)
 PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_X86)
 PLATFORM_CPPFLAGS += -fno-dwarf2-cfi-asm
-PLATFORM_CPPFLAGS += -DREALMODE_BASE=0x7c0
 PLATFORM_CPPFLAGS += -march=i386 -m32
 
 # Support generic board on x86
Signature · 1 line
2.1.0.rc2.206.gedb03e5
#13 lore raw

PATCH 8/39 x86: Remove REALMODE_BASE which is no longer used

Quoted 13 lines · Simon Glass

This was missed when the real mode support was dropped. Remove it.

---

 arch/x86/config.mk | 1 -
 1 file changed, 1 deletion(-)
arch/x86/config.mk +0 -0
index 3e7fedb..bb2da46 100644

arch/x86/config.mk PF_CPPFLAGS_X86 := $(call cc-option, -fno-toplevel-reorder, \

Quoted 8 lines
arch/x86/config.mk +0 -2
@@ -15,7 +15,6 @@ PF_CPPFLAGS_X86   := $(call cc-option, -fno-toplevel-reorder, \
                     $(call cc-option, -mpreferred-stack-boundary=2)
 PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_X86)
 PLATFORM_CPPFLAGS += -fno-dwarf2-cfi-asm
-PLATFORM_CPPFLAGS += -DREALMODE_BASE=0x7c0
 PLATFORM_CPPFLAGS += -march=i386 -m32
 
 # Support generic board on x86
--
#14 lore raw

PATCH 8/39 x86: Remove REALMODE_BASE which is no longer used

Quoted 20 lines · Bin Meng
Quoted 19 lines · Simon Glass

This was missed when the real mode support was dropped. Remove it.

---

 arch/x86/config.mk | 1 -
 1 file changed, 1 deletion(-)
arch/x86/config.mk +0 -1
index 3e7fedb..bb2da46 100644
@@ -15,7 +15,6 @@ PF_CPPFLAGS_X86   := $(call cc-option, -fno-toplevel-reorder, \
                     $(call cc-option, -mpreferred-stack-boundary=2)
 PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_X86)
 PLATFORM_CPPFLAGS += -fno-dwarf2-cfi-asm
-PLATFORM_CPPFLAGS += -DREALMODE_BASE=0x7c0
 PLATFORM_CPPFLAGS += -march=i386 -m32
 
Quoted 4 lines

arch/x86/config.mk PF_CPPFLAGS_X86 := $(call cc-option, -fno-toplevel-reorder, \

Quoted 2 lines
arch/x86/config.mk +0 -1
 # Support generic board on x86
--

Applied to u-boot-x86.

#15 lore raw

PATCH 9/39 x86: Remove board_init16() call which is not used

In reply to Simon Glass

This allows a board to do very early init, but no boards need to do this. We may as well drop this feature.

---

 arch/x86/cpu/start16.S | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
arch/x86/cpu/start16.S +1 -9
index 6968fda..e718d4b 100644
@@ -24,15 +24,7 @@ start16:
 	/* Set the Cold Boot / Hard Reset flag */
 	movl	$GD_FLG_COLD_BOOT, %ebx
 
-	/*
-	 * First we let the BSP do some early initialization
-	 * this code have to map the flash to its final position
-	 */
-	jmp	board_init16
-.globl board_init16_ret
-board_init16_ret:
-
-	/* Turn of cache (this might require a 486-class CPU) */
+	/* Turn off cache (this might require a 486-class CPU) */
 	movl	%cr0, %eax
 	orl	$(X86_CR0_NW | X86_CR0_CD), %eax
 	movl	%eax, %cr0
Signature · 1 line
2.1.0.rc2.206.gedb03e5
#16 lore raw

PATCH 9/39 x86: Remove board_init16() call which is not used

Quoted 21 lines · Simon Glass

This allows a board to do very early init, but no boards need to do this. We may as well drop this feature.

---

 arch/x86/cpu/start16.S | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
arch/x86/cpu/start16.S +0 -4
index 6968fda..e718d4b 100644
@@ -24,15 +24,7 @@ start16:
        /* Set the Cold Boot / Hard Reset flag */
        movl    $GD_FLG_COLD_BOOT, %ebx
 
-       /*
-        * First we let the BSP do some early initialization
-        * this code have to map the flash to its final position
-        */

arch/x86/cpu/start16.S start16:

Quoted 10 lines
arch/x86/cpu/start16.S +1 -6
-       jmp     board_init16
-.globl board_init16_ret
-board_init16_ret:
-
-       /* Turn of cache (this might require a 486-class CPU) */
+       /* Turn off cache (this might require a 486-class CPU) */
        movl    %cr0, %eax
        orl     $(X86_CR0_NW | X86_CR0_CD), %eax
        movl    %eax, %cr0
--
#17 lore raw

PATCH 9/39 x86: Remove board_init16() call which is not used

Quoted 18 lines · Bin Meng
Quoted 17 lines · Simon Glass

This allows a board to do very early init, but no boards need to do this. We may as well drop this feature.

---

 arch/x86/cpu/start16.S | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
arch/x86/cpu/start16.S +0 -0
index 6968fda..e718d4b 100644
@@ -24,15 +24,7 @@ start16:
        /* Set the Cold Boot / Hard Reset flag */
        movl    $GD_FLG_COLD_BOOT, %ebx
 
Quoted 16 lines
Quoted 4 lines
arch/x86/cpu/start16.S +0 -4
-       /*
-        * First we let the BSP do some early initialization
-        * this code have to map the flash to its final position
-        */

arch/x86/cpu/start16.S start16:

Quoted 10 lines
arch/x86/cpu/start16.S +1 -6
-       jmp     board_init16
-.globl board_init16_ret
-board_init16_ret:
-
-       /* Turn of cache (this might require a 486-class CPU) */
+       /* Turn off cache (this might require a 486-class CPU) */
        movl    %cr0, %eax
        orl     $(X86_CR0_NW | X86_CR0_CD), %eax
        movl    %eax, %cr0
--

Applied to u-boot-x86.

#18 lore raw

PATCH 10/39 x86: Remove unused early_board_init() call

In reply to Simon Glass

This allows early board init before board_init_f() is called. We already have a standard U-Boot board call, and no boards use this, so drop it.

---

 arch/x86/cpu/start.S                           |  5 -----
 board/chromebook-x86/coreboot/Makefile         |  2 +-
 board/chromebook-x86/coreboot/coreboot_start.S | 13 -------------
 3 files changed, 1 insertion(+), 19 deletions(-)
 delete mode 100644 board/chromebook-x86/coreboot/coreboot_start.S
arch/x86/cpu/start.S +0 -5
index 338bab1..62ac4cd 100644
@@ -61,11 +61,6 @@ _start:
 	/* Clear the interrupt vectors */
 	lidt	blank_idt_ptr
 
-	/* Early platform init (setup gpio, etc ) */
-	jmp	early_board_init
-.globl early_board_init_ret
-early_board_init_ret:
-
 	/* Initialise Cache-As-RAM */
 	jmp	car_init
 .globl car_init_ret
board/chromebook-x86/coreboot/Makefile +1 -1
index 27ebe78..071bdc4 100644
@@ -12,4 +12,4 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-obj-y	+= coreboot_start.o coreboot.o
+obj-y	+= coreboot.o
board/chromebook-x86/coreboot/coreboot_start.S deleted +0 -13
deleted file mode 100644
index 932fe6c..0000000
@@ -1,13 +0,0 @@
-/*
- * Copyright (c) 2011 The Chromium OS Authors.
- * (C) Copyright 2008
- * Graeme Russ, graeme.russ at gmail.com.
- *
- * SPDX-License-Identifier:	GPL-2.0+
- */
-
-/* board early intialization */
-.globl early_board_init
-early_board_init:
-	/* No 32-bit board specific initialisation */
-	jmp	early_board_init_ret
Signature · 1 line
2.1.0.rc2.206.gedb03e5
#19 lore raw

PATCH 10/39 x86: Remove unused early_board_init() call

Quoted 48 lines · Simon Glass

This allows early board init before board_init_f() is called. We already have a standard U-Boot board call, and no boards use this, so drop it.

---

 arch/x86/cpu/start.S                           |  5 -----
 board/chromebook-x86/coreboot/Makefile         |  2 +-
 board/chromebook-x86/coreboot/coreboot_start.S | 13 -------------
 3 files changed, 1 insertion(+), 19 deletions(-)
 delete mode 100644 board/chromebook-x86/coreboot/coreboot_start.S
arch/x86/cpu/start.S +0 -5
index 338bab1..62ac4cd 100644
@@ -61,11 +61,6 @@ _start:
        /* Clear the interrupt vectors */
        lidt    blank_idt_ptr
 
-       /* Early platform init (setup gpio, etc ) */
-       jmp     early_board_init
-.globl early_board_init_ret
-early_board_init_ret:
-
        /* Initialise Cache-As-RAM */
        jmp     car_init
 .globl car_init_ret
board/chromebook-x86/coreboot/Makefile +1 -1
index 27ebe78..071bdc4 100644
@@ -12,4 +12,4 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-obj-y  += coreboot_start.o coreboot.o
+obj-y  += coreboot.o
board/chromebook-x86/coreboot/coreboot_start.S deleted +0 -4
deleted file mode 100644
index 932fe6c..0000000
@@ -1,13 +0,0 @@
-/*
- * Copyright (c) 2011 The Chromium OS Authors.
- * (C) Copyright 2008
- * Graeme Russ, graeme.russ at gmail.com.

board/chromebook-x86/coreboot/coreboot_start.S

Quoted 10 lines
board/chromebook-x86/coreboot/coreboot_start.S deleted +0 -10
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-/* board early intialization */
-.globl early_board_init
-early_board_init:
-       /* No 32-bit board specific initialisation */
-       jmp     early_board_init_ret
--
#20 lore raw

PATCH 11/39 x86: Invalidate TLB as early as possible

In reply to Simon Glass

We should invalidate the TLB right at the start to ensure that we don't get false address translations even though paging is disabled.

---

 arch/x86/cpu/start16.S | 3 +++
 1 file changed, 3 insertions(+)
arch/x86/cpu/start16.S +3 -0
index e718d4b..445d5a1 100644
@@ -24,6 +24,9 @@ start16:
 	/* Set the Cold Boot / Hard Reset flag */
 	movl	$GD_FLG_COLD_BOOT, %ebx
 
+	xorl	%eax, %eax
+	movl	%eax, %cr3    /* Invalidate TLB */
+
 	/* Turn off cache (this might require a 486-class CPU) */
 	movl	%cr0, %eax
 	orl	$(X86_CR0_NW | X86_CR0_CD), %eax
Signature · 1 line
2.1.0.rc2.206.gedb03e5
#21 lore raw

PATCH 11/39 x86: Invalidate TLB as early as possible

Quoted 14 lines · Simon Glass

We should invalidate the TLB right at the start to ensure that we don't get false address translations even though paging is disabled.

---

 arch/x86/cpu/start16.S | 3 +++
 1 file changed, 3 insertions(+)
arch/x86/cpu/start16.S +0 -0
index e718d4b..445d5a1 100644

arch/x86/cpu/start16.S start16:

Quoted 10 lines
arch/x86/cpu/start16.S +3 -1
@@ -24,6 +24,9 @@ start16:
        /* Set the Cold Boot / Hard Reset flag */
        movl    $GD_FLG_COLD_BOOT, %ebx
 
+       xorl    %eax, %eax
+       movl    %eax, %cr3    /* Invalidate TLB */
+
        /* Turn off cache (this might require a 486-class CPU) */
        movl    %cr0, %eax
        orl     $(X86_CR0_NW | X86_CR0_CD), %eax
--
#22 lore raw

PATCH 11/39 x86: Invalidate TLB as early as possible

Quoted 18 lines · Bin Meng
Quoted 17 lines · Simon Glass

We should invalidate the TLB right at the start to ensure that we don't get false address translations even though paging is disabled.

---

 arch/x86/cpu/start16.S | 3 +++
 1 file changed, 3 insertions(+)
arch/x86/cpu/start16.S +0 -0
index e718d4b..445d5a1 100644
@@ -24,6 +24,9 @@ start16:
        /* Set the Cold Boot / Hard Reset flag */
        movl    $GD_FLG_COLD_BOOT, %ebx
 
Quoted 9 lines

arch/x86/cpu/start16.S start16:

Quoted 7 lines
arch/x86/cpu/start16.S +3 -1
+       xorl    %eax, %eax
+       movl    %eax, %cr3    /* Invalidate TLB */
+
        /* Turn off cache (this might require a 486-class CPU) */
        movl    %cr0, %eax
        orl     $(X86_CR0_NW | X86_CR0_CD), %eax
--

Applied to u-boot-x86.

#23 lore raw

PATCH 12/39 x86: Tidy up global descriptor table setup

In reply to Simon Glass

This code is a little muddled, so tidy it up. Make sure that we put the GDT in the right place and set it up properly.

---

 arch/x86/cpu/start.S | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)
arch/x86/cpu/start.S +16 -3
index 62ac4cd..c41e1ae 100644
@@ -69,6 +69,16 @@ car_init_ret:
 	 * We now have CONFIG_SYS_CAR_SIZE bytes of Cache-As-RAM (or SRAM,
 	 * or fully initialised SDRAM - we really don't care which)
 	 * starting at CONFIG_SYS_CAR_ADDR to be used as a temporary stack
+	 * and early malloc area.
+	 *
+	 * Stack grows down from top of CAR. We have:
+	 *
+	 * top-> CONFIG_SYS_CAR_ADDR + CONFIG_SYS_CAR_SIZE
+	 *	global_data
+	 *	x86 global descriptor table
+	 *	early malloc area
+	 *	stack
+	 * bottom-> CONFIG_SYS_CAR_ADDR
 	 */
 
 	/* Stack grows down from top of CAR */
@@ -86,12 +96,16 @@ car_init_ret:
 	movl	%esp, %edi
 	rep	stosb
 
-	/* Setup first parameter to setup_gdt */
+	/* Setup first parameter to setup_gdt, pointer to global_data */
 	movl	%esp, %eax
 
 	/* Reserve space for global descriptor table */
 	subl	$X86_GDT_SIZE, %esp
 
+	/* Align temporary global descriptor table to 16-byte boundary */
+	andl	$0xfffffff0, %esp
+	movl	%esp, %ecx
+
 #if defined(CONFIG_SYS_MALLOC_F_LEN)
 	subl	$CONFIG_SYS_MALLOC_F_LEN, %esp
 	movl	%eax, %edx
@@ -103,14 +117,13 @@ car_init_ret:
 	andl	$0xfffffff0, %esp
 
 	/* Set second parameter to setup_gdt */
-	movl	%esp, %edx
+	movl	%ecx, %edx
 
 	/* Setup global descriptor table so gd->xyz works */
 	call	setup_gdt
 
 	/* Set parameter to board_init_f() to boot flags */
 	xorl	%eax, %eax
-	movw	%bx, %ax
 
 	/* Enter, U-boot! */
 	call	board_init_f
Signature · 1 line
2.1.0.rc2.206.gedb03e5
#24 lore raw

PATCH 12/39 x86: Tidy up global descriptor table setup

Quoted 55 lines · Simon Glass

This code is a little muddled, so tidy it up. Make sure that we put the GDT in the right place and set it up properly.

---

 arch/x86/cpu/start.S | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)
arch/x86/cpu/start.S +16 -2
index 62ac4cd..c41e1ae 100644
@@ -69,6 +69,16 @@ car_init_ret:
         * We now have CONFIG_SYS_CAR_SIZE bytes of Cache-As-RAM (or SRAM,
         * or fully initialised SDRAM - we really don't care which)
         * starting at CONFIG_SYS_CAR_ADDR to be used as a temporary stack
+        * and early malloc area.
+        *
+        * Stack grows down from top of CAR. We have:
+        *
+        * top-> CONFIG_SYS_CAR_ADDR + CONFIG_SYS_CAR_SIZE
+        *      global_data
+        *      x86 global descriptor table
+        *      early malloc area
+        *      stack
+        * bottom-> CONFIG_SYS_CAR_ADDR
         */
 
        /* Stack grows down from top of CAR */
@@ -86,12 +96,16 @@ car_init_ret:
        movl    %esp, %edi
        rep     stosb
 
-       /* Setup first parameter to setup_gdt */
+       /* Setup first parameter to setup_gdt, pointer to global_data */
        movl    %esp, %eax
 
        /* Reserve space for global descriptor table */
        subl    $X86_GDT_SIZE, %esp
 
+       /* Align temporary global descriptor table to 16-byte boundary */
+       andl    $0xfffffff0, %esp
+       movl    %esp, %ecx
+
 #if defined(CONFIG_SYS_MALLOC_F_LEN)
        subl    $CONFIG_SYS_MALLOC_F_LEN, %esp
        movl    %eax, %edx
@@ -103,14 +117,13 @@ car_init_ret:
        andl    $0xfffffff0, %esp
 
        /* Set second parameter to setup_gdt */
-       movl    %esp, %edx
+       movl    %ecx, %edx
 

arch/x86/cpu/start.S car_init_ret:

Quoted 10 lines
arch/x86/cpu/start.S +0 -2
        /* Setup global descriptor table so gd->xyz works */
        call    setup_gdt
 
        /* Set parameter to board_init_f() to boot flags */
        xorl    %eax, %eax
-       movw    %bx, %ax
 
        /* Enter, U-boot! */
        call    board_init_f
--
#25 lore raw

PATCH 12/39 x86: Tidy up global descriptor table setup

Quoted 63 lines · Bin Meng
Quoted 62 lines · Simon Glass

This code is a little muddled, so tidy it up. Make sure that we put the GDT in the right place and set it up properly.

---

 arch/x86/cpu/start.S | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)
arch/x86/cpu/start.S +16 -3
index 62ac4cd..c41e1ae 100644
@@ -69,6 +69,16 @@ car_init_ret:
         * We now have CONFIG_SYS_CAR_SIZE bytes of Cache-As-RAM (or SRAM,
         * or fully initialised SDRAM - we really don't care which)
         * starting at CONFIG_SYS_CAR_ADDR to be used as a temporary stack
+        * and early malloc area.
+        *
+        * Stack grows down from top of CAR. We have:
+        *
+        * top-> CONFIG_SYS_CAR_ADDR + CONFIG_SYS_CAR_SIZE
+        *      global_data
+        *      x86 global descriptor table
+        *      early malloc area
+        *      stack
+        * bottom-> CONFIG_SYS_CAR_ADDR
         */
 
        /* Stack grows down from top of CAR */
@@ -86,12 +96,16 @@ car_init_ret:
        movl    %esp, %edi
        rep     stosb
 
-       /* Setup first parameter to setup_gdt */
+       /* Setup first parameter to setup_gdt, pointer to global_data */
        movl    %esp, %eax
 
        /* Reserve space for global descriptor table */
        subl    $X86_GDT_SIZE, %esp
 
+       /* Align temporary global descriptor table to 16-byte boundary */
+       andl    $0xfffffff0, %esp
+       movl    %esp, %ecx
+
 #if defined(CONFIG_SYS_MALLOC_F_LEN)
        subl    $CONFIG_SYS_MALLOC_F_LEN, %esp
        movl    %eax, %edx
@@ -103,14 +117,13 @@ car_init_ret:
        andl    $0xfffffff0, %esp
 
        /* Set second parameter to setup_gdt */
-       movl    %esp, %edx
+       movl    %ecx, %edx
 
        /* Setup global descriptor table so gd->xyz works */
        call    setup_gdt
 
        /* Set parameter to board_init_f() to boot flags */
        xorl    %eax, %eax
-       movw    %bx, %ax
 
Quoted 5 lines

arch/x86/cpu/start.S car_init_ret:

Quoted 3 lines
arch/x86/cpu/start.S +0 -1
        /* Enter, U-boot! */
        call    board_init_f
--

Applied to u-boot-x86.

#26 lore raw

PATCH 13/39 x86: Use the standard dram_init() function

In reply to Simon Glass

Instead of having an x86-specific DRAM init function, adjust things so we can use the normal one.

---

 arch/x86/cpu/coreboot/sdram.c     | 11 ++++-------
 arch/x86/include/asm/u-boot-x86.h |  4 ++--
 common/board_f.c                  |  6 +-----
 3 files changed, 7 insertions(+), 14 deletions(-)
arch/x86/cpu/coreboot/sdram.c +4 -7
index 959feaa..ca651c7 100644
@@ -11,6 +11,7 @@
 #include <asm/e820.h>
 #include <asm/u-boot-x86.h>
 #include <asm/global_data.h>
+#include <asm/init_helpers.h>
 #include <asm/processor.h>
 #include <asm/sections.h>
 #include <asm/arch/sysinfo.h>
@@ -79,7 +80,7 @@ ulong board_get_usable_ram_top(ulong total_size)
 	return (ulong)dest_addr;
 }
 
-int dram_init_f(void)
+int dram_init(void)
 {
 	int i;
 	phys_size_t ram_size = 0;
@@ -94,7 +95,8 @@ int dram_init_f(void)
 	gd->ram_size = ram_size;
 	if (ram_size == 0)
 		return -1;
-	return 0;
+
+	return calculate_relocation_address();
 }
 
 int dram_init_banksize(void)
@@ -116,8 +118,3 @@ int dram_init_banksize(void)
 	}
 	return 0;
 }
-
-int dram_init(void)
-{
-	return dram_init_banksize();
-}
arch/x86/include/asm/u-boot-x86.h +2 -2
index 9e525dd..89618c7 100644
@@ -27,8 +27,8 @@ unsigned long get_tbclk_mhz(void);
 void timer_set_base(uint64_t base);
 int pcat_timer_init(void);
 
-/* Architecture specific - can be in arch/x86/cpu/, arch/x86/lib/, or $(BOARD)/ */
-int dram_init_f(void);
+/* Architecture specific DRAM init */
+int dram_init(void);
 
 /* cpu/.../interrupts.c */
 int cpu_init_interrupts(void);
common/board_f.c +1 -5
index 31f1d5c..df02ca5 100644
@@ -903,13 +903,9 @@ static init_fnc_t init_sequence_f[] = {
 #if defined(CONFIG_HARD_SPI)
 	init_func_spi,
 #endif
-#ifdef CONFIG_X86
-	dram_init_f,		/* configure available RAM banks */
-	calculate_relocation_address,
-#endif
 	announce_dram_init,
 	/* TODO: unify all these dram functions? */
-#ifdef CONFIG_ARM
+#if defined(CONFIG_ARM) || defined(CONFIG_X86)
 	dram_init,		/* configure available RAM banks */
 #endif
 #if defined(CONFIG_MIPS) || defined(CONFIG_PPC)
Signature · 1 line
2.1.0.rc2.206.gedb03e5
#27 lore raw

PATCH 13/39 x86: Use the standard dram_init() function

Quoted 76 lines · Simon Glass

Instead of having an x86-specific DRAM init function, adjust things so we can use the normal one.

---

 arch/x86/cpu/coreboot/sdram.c     | 11 ++++-------
 arch/x86/include/asm/u-boot-x86.h |  4 ++--
 common/board_f.c                  |  6 +-----
 3 files changed, 7 insertions(+), 14 deletions(-)
arch/x86/cpu/coreboot/sdram.c +4 -7
index 959feaa..ca651c7 100644
@@ -11,6 +11,7 @@
 #include <asm/e820.h>
 #include <asm/u-boot-x86.h>
 #include <asm/global_data.h>
+#include <asm/init_helpers.h>
 #include <asm/processor.h>
 #include <asm/sections.h>
 #include <asm/arch/sysinfo.h>
@@ -79,7 +80,7 @@ ulong board_get_usable_ram_top(ulong total_size)
        return (ulong)dest_addr;
 }
 
-int dram_init_f(void)
+int dram_init(void)
 {
        int i;
        phys_size_t ram_size = 0;
@@ -94,7 +95,8 @@ int dram_init_f(void)
        gd->ram_size = ram_size;
        if (ram_size == 0)
                return -1;
-       return 0;
+
+       return calculate_relocation_address();
 }
 
 int dram_init_banksize(void)
@@ -116,8 +118,3 @@ int dram_init_banksize(void)
        }
        return 0;
 }
-
-int dram_init(void)
-{
-       return dram_init_banksize();
-}
arch/x86/include/asm/u-boot-x86.h +2 -2
index 9e525dd..89618c7 100644
@@ -27,8 +27,8 @@ unsigned long get_tbclk_mhz(void);
 void timer_set_base(uint64_t base);
 int pcat_timer_init(void);
 
-/* Architecture specific - can be in arch/x86/cpu/, arch/x86/lib/, or $(BOARD)/ */
-int dram_init_f(void);
+/* Architecture specific DRAM init */
+int dram_init(void);
 
 /* cpu/.../interrupts.c */
 int cpu_init_interrupts(void);
common/board_f.c +0 -2
index 31f1d5c..df02ca5 100644
@@ -903,13 +903,9 @@ static init_fnc_t init_sequence_f[] = {
 #if defined(CONFIG_HARD_SPI)
        init_func_spi,
 #endif
-#ifdef CONFIG_X86
-       dram_init_f,            /* configure available RAM banks */

common/board_f.c static init_fnc_t init_sequence_f[] = {

Quoted 10 lines
common/board_f.c +1 -4
-       calculate_relocation_address,
-#endif
        announce_dram_init,
        /* TODO: unify all these dram functions? */
-#ifdef CONFIG_ARM
+#if defined(CONFIG_ARM) || defined(CONFIG_X86)
        dram_init,              /* configure available RAM banks */
 #endif
 #if defined(CONFIG_MIPS) || defined(CONFIG_PPC)
--
#28 lore raw

PATCH 13/39 x86: Use the standard dram_init() function

Quoted 81 lines · Bin Meng
Quoted 80 lines · Simon Glass

Instead of having an x86-specific DRAM init function, adjust things so we can use the normal one.

---

 arch/x86/cpu/coreboot/sdram.c     | 11 ++++-------
 arch/x86/include/asm/u-boot-x86.h |  4 ++--
 common/board_f.c                  |  6 +-----
 3 files changed, 7 insertions(+), 14 deletions(-)
arch/x86/cpu/coreboot/sdram.c +4 -7
index 959feaa..ca651c7 100644
@@ -11,6 +11,7 @@
 #include <asm/e820.h>
 #include <asm/u-boot-x86.h>
 #include <asm/global_data.h>
+#include <asm/init_helpers.h>
 #include <asm/processor.h>
 #include <asm/sections.h>
 #include <asm/arch/sysinfo.h>
@@ -79,7 +80,7 @@ ulong board_get_usable_ram_top(ulong total_size)
        return (ulong)dest_addr;
 }
 
-int dram_init_f(void)
+int dram_init(void)
 {
        int i;
        phys_size_t ram_size = 0;
@@ -94,7 +95,8 @@ int dram_init_f(void)
        gd->ram_size = ram_size;
        if (ram_size == 0)
                return -1;
-       return 0;
+
+       return calculate_relocation_address();
 }
 
 int dram_init_banksize(void)
@@ -116,8 +118,3 @@ int dram_init_banksize(void)
        }
        return 0;
 }
-
-int dram_init(void)
-{
-       return dram_init_banksize();
-}
arch/x86/include/asm/u-boot-x86.h +2 -2
index 9e525dd..89618c7 100644
@@ -27,8 +27,8 @@ unsigned long get_tbclk_mhz(void);
 void timer_set_base(uint64_t base);
 int pcat_timer_init(void);
 
-/* Architecture specific - can be in arch/x86/cpu/, arch/x86/lib/, or $(BOARD)/ */
-int dram_init_f(void);
+/* Architecture specific DRAM init */
+int dram_init(void);
 
 /* cpu/.../interrupts.c */
 int cpu_init_interrupts(void);
common/board_f.c +0 -4
index 31f1d5c..df02ca5 100644
@@ -903,13 +903,9 @@ static init_fnc_t init_sequence_f[] = {
 #if defined(CONFIG_HARD_SPI)
        init_func_spi,
 #endif
-#ifdef CONFIG_X86
-       dram_init_f,            /* configure available RAM banks */
-       calculate_relocation_address,
-#endif
        announce_dram_init,
        /* TODO: unify all these dram functions? */
Quoted 8 lines

common/board_f.c static init_fnc_t init_sequence_f[] = {

Quoted 6 lines
common/board_f.c +1 -2
-#ifdef CONFIG_ARM
+#if defined(CONFIG_ARM) || defined(CONFIG_X86)
        dram_init,              /* configure available RAM banks */
 #endif
 #if defined(CONFIG_MIPS) || defined(CONFIG_PPC)
--

Applied to u-boot-x86.

#29 lore raw

PATCH 14/39 x86: Use the standard arch_cpu_init() function

In reply to Simon Glass

Instead of an x86-specific cpu_init_f() function, use the normal U-Boot one for this purpose. Also remove a useless/misleading comment.

---

 arch/x86/cpu/coreboot/coreboot.c  | 5 +----
 arch/x86/cpu/cpu.c                | 1 -
 arch/x86/include/asm/u-boot-x86.h | 1 +
 common/board_f.c                  | 1 -
 4 files changed, 2 insertions(+), 6 deletions(-)
arch/x86/cpu/coreboot/coreboot.c +1 -4
index e24f13a..b640f35 100644
@@ -20,10 +20,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-/*
- * Miscellaneous platform dependent initializations
- */
-int cpu_init_f(void)
+int arch_cpu_init(void)
 {
 	int ret = get_coreboot_info(&lib_sysinfo);
 	if (ret != 0)
arch/x86/cpu/cpu.c +0 -1
index 2e25253..d6ba246 100644
@@ -130,7 +130,6 @@ int x86_cpu_init_f(void)
 
 	return 0;
 }
-int cpu_init_f(void) __attribute__((weak, alias("x86_cpu_init_f")));
 
 int x86_cpu_init_r(void)
 {
arch/x86/include/asm/u-boot-x86.h +1 -0
index 89618c7..fdb8a6c 100644
@@ -9,6 +9,7 @@
 #define _U_BOOT_I386_H_	1
 
 /* cpu/.../cpu.c */
+int arch_cpu_init(void);
 int x86_cpu_init_r(void);
 int cpu_init_r(void);
 int x86_cpu_init_f(void);
common/board_f.c +0 -1
index df02ca5..f81f70d 100644
@@ -819,7 +819,6 @@ static init_fnc_t init_sequence_f[] = {
 #endif
 	arch_cpu_init,		/* basic arch cpu dependent setup */
 #ifdef CONFIG_X86
-	cpu_init_f,		/* TODO(sjg at chromium.org): remove */
 # ifdef CONFIG_OF_CONTROL
 	find_fdt,		/* TODO(sjg at chromium.org): remove */
 # endif
Signature · 1 line
2.1.0.rc2.206.gedb03e5
#30 lore raw

PATCH 14/39 x86: Use the standard arch_cpu_init() function

Quoted 57 lines · Simon Glass

Instead of an x86-specific cpu_init_f() function, use the normal U-Boot one for this purpose. Also remove a useless/misleading comment.

---

 arch/x86/cpu/coreboot/coreboot.c  | 5 +----
 arch/x86/cpu/cpu.c                | 1 -
 arch/x86/include/asm/u-boot-x86.h | 1 +
 common/board_f.c                  | 1 -
 4 files changed, 2 insertions(+), 6 deletions(-)
arch/x86/cpu/coreboot/coreboot.c +1 -4
index e24f13a..b640f35 100644
@@ -20,10 +20,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-/*
- * Miscellaneous platform dependent initializations
- */
-int cpu_init_f(void)
+int arch_cpu_init(void)
 {
        int ret = get_coreboot_info(&lib_sysinfo);
        if (ret != 0)
arch/x86/cpu/cpu.c +0 -1
index 2e25253..d6ba246 100644
@@ -130,7 +130,6 @@ int x86_cpu_init_f(void)
 
        return 0;
 }
-int cpu_init_f(void) __attribute__((weak, alias("x86_cpu_init_f")));
 
 int x86_cpu_init_r(void)
 {
arch/x86/include/asm/u-boot-x86.h +1 -0
index 89618c7..fdb8a6c 100644
@@ -9,6 +9,7 @@
 #define _U_BOOT_I386_H_        1
 
 /* cpu/.../cpu.c */
+int arch_cpu_init(void);
 int x86_cpu_init_r(void);
 int cpu_init_r(void);
 int x86_cpu_init_f(void);
common/board_f.c +0 -0
index df02ca5..f81f70d 100644

common/board_f.c static init_fnc_t init_sequence_f[] = {

Quoted 8 lines
common/board_f.c +0 -2
@@ -819,7 +819,6 @@ static init_fnc_t init_sequence_f[] = {
 #endif
        arch_cpu_init,          /* basic arch cpu dependent setup */
 #ifdef CONFIG_X86
-       cpu_init_f,             /* TODO(sjg at chromium.org): remove */
 # ifdef CONFIG_OF_CONTROL
        find_fdt,               /* TODO(sjg at chromium.org): remove */
 # endif
--
#31 lore raw

PATCH 14/39 x86: Use the standard arch_cpu_init() function

Quoted 60 lines · Bin Meng
Quoted 59 lines · Simon Glass

Instead of an x86-specific cpu_init_f() function, use the normal U-Boot one for this purpose. Also remove a useless/misleading comment.

---

 arch/x86/cpu/coreboot/coreboot.c  | 5 +----
 arch/x86/cpu/cpu.c                | 1 -
 arch/x86/include/asm/u-boot-x86.h | 1 +
 common/board_f.c                  | 1 -
 4 files changed, 2 insertions(+), 6 deletions(-)
arch/x86/cpu/coreboot/coreboot.c +1 -4
index e24f13a..b640f35 100644
@@ -20,10 +20,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-/*
- * Miscellaneous platform dependent initializations
- */
-int cpu_init_f(void)
+int arch_cpu_init(void)
 {
        int ret = get_coreboot_info(&lib_sysinfo);
        if (ret != 0)
arch/x86/cpu/cpu.c +0 -1
index 2e25253..d6ba246 100644
@@ -130,7 +130,6 @@ int x86_cpu_init_f(void)
 
        return 0;
 }
-int cpu_init_f(void) __attribute__((weak, alias("x86_cpu_init_f")));
 
 int x86_cpu_init_r(void)
 {
arch/x86/include/asm/u-boot-x86.h +1 -0
index 89618c7..fdb8a6c 100644
@@ -9,6 +9,7 @@
 #define _U_BOOT_I386_H_        1
 
 /* cpu/.../cpu.c */
+int arch_cpu_init(void);
 int x86_cpu_init_r(void);
 int cpu_init_r(void);
 int x86_cpu_init_f(void);
common/board_f.c +0 -0
index df02ca5..f81f70d 100644
@@ -819,7 +819,6 @@ static init_fnc_t init_sequence_f[] = {
 #endif
        arch_cpu_init,          /* basic arch cpu dependent setup */
Quoted 8 lines

common/board_f.c static init_fnc_t init_sequence_f[] = {

Quoted 6 lines
common/board_f.c +0 -2
 #ifdef CONFIG_X86
-       cpu_init_f,             /* TODO(sjg at chromium.org): remove */
 # ifdef CONFIG_OF_CONTROL
        find_fdt,               /* TODO(sjg at chromium.org): remove */
 # endif
--

Applied to u-boot-x86.

#32 lore raw

PATCH 14/39 x86: Use the standard arch_cpu_init() function

Hi,

Quoted 70 lines · Simon Glass
Quoted 60 lines · Bin Meng
Quoted 59 lines · Simon Glass

Instead of an x86-specific cpu_init_f() function, use the normal U-Boot one for this purpose. Also remove a useless/misleading comment.

---

 arch/x86/cpu/coreboot/coreboot.c  | 5 +----
 arch/x86/cpu/cpu.c                | 1 -
 arch/x86/include/asm/u-boot-x86.h | 1 +
 common/board_f.c                  | 1 -
 4 files changed, 2 insertions(+), 6 deletions(-)
arch/x86/cpu/coreboot/coreboot.c +1 -4
index e24f13a..b640f35 100644
@@ -20,10 +20,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-/*
- * Miscellaneous platform dependent initializations
- */
-int cpu_init_f(void)
+int arch_cpu_init(void)
 {
        int ret = get_coreboot_info(&lib_sysinfo);
        if (ret != 0)
arch/x86/cpu/cpu.c +0 -1
index 2e25253..d6ba246 100644
@@ -130,7 +130,6 @@ int x86_cpu_init_f(void)
 
        return 0;
 }
-int cpu_init_f(void) __attribute__((weak, alias("x86_cpu_init_f")));
 
 int x86_cpu_init_r(void)
 {
arch/x86/include/asm/u-boot-x86.h +1 -0
index 89618c7..fdb8a6c 100644
@@ -9,6 +9,7 @@
 #define _U_BOOT_I386_H_        1
 
 /* cpu/.../cpu.c */
+int arch_cpu_init(void);
 int x86_cpu_init_r(void);
 int cpu_init_r(void);
 int x86_cpu_init_f(void);
common/board_f.c +0 -0
index df02ca5..f81f70d 100644
@@ -819,7 +819,6 @@ static init_fnc_t init_sequence_f[] = {
 #endif
        arch_cpu_init,          /* basic arch cpu dependent setup */
Quoted 8 lines

common/board_f.c static init_fnc_t init_sequence_f[] = {

Quoted 6 lines
common/board_f.c +0 -2
 #ifdef CONFIG_X86
-       cpu_init_f,             /* TODO(sjg at chromium.org): remove */
 # ifdef CONFIG_OF_CONTROL
        find_fdt,               /* TODO(sjg at chromium.org): remove */
 # endif
--
Quoted 1 line

Applied to u-boot-x86.

Unfortunately this conflicts with your patch Bin, in that cpu_init_f() is actually still needed. I tweaked this to call cpu_init_f() from arch_cpu_init() and that seems to work. We'll have to deal with any problems with an additional patch.

Regards,
Simon

#33 lore raw

PATCH 15/39 x86: Remove unnecessary find_fdt() function

In reply to Simon Glass

This is no-longer needed so drop it.

---

 arch/x86/include/asm/init_helpers.h | 1 -
 common/board_f.c                    | 5 -----
 2 files changed, 6 deletions(-)
arch/x86/include/asm/init_helpers.h +0 -1
index b07887e..f380a8d 100644
@@ -13,7 +13,6 @@ int calculate_relocation_address(void);
 int init_cache_f_r(void);
 int init_bd_struct_r(void);
 int init_func_spi(void);
-int find_fdt(void);
 int prepare_fdt(void);
 
 #endif	/* !_INIT_HELPERS_H_ */
common/board_f.c +0 -5
index f81f70d..6e6a1a2 100644
@@ -818,11 +818,6 @@ static init_fnc_t init_sequence_f[] = {
 	probecpu,
 #endif
 	arch_cpu_init,		/* basic arch cpu dependent setup */
-#ifdef CONFIG_X86
-# ifdef CONFIG_OF_CONTROL
-	find_fdt,		/* TODO(sjg at chromium.org): remove */
-# endif
-#endif
 	mark_bootstage,
 #ifdef CONFIG_OF_CONTROL
 	fdtdec_check_fdt,
Signature · 1 line
2.1.0.rc2.206.gedb03e5
#34 lore raw

PATCH 15/39 x86: Remove unnecessary find_fdt() function

Hi Simon,

Quoted 28 lines · Simon Glass

This is no-longer needed so drop it.

---

 arch/x86/include/asm/init_helpers.h | 1 -
 common/board_f.c                    | 5 -----
 2 files changed, 6 deletions(-)
arch/x86/include/asm/init_helpers.h +0 -1
index b07887e..f380a8d 100644
@@ -13,7 +13,6 @@ int calculate_relocation_address(void);
 int init_cache_f_r(void);
 int init_bd_struct_r(void);
 int init_func_spi(void);
-int find_fdt(void);
 int prepare_fdt(void);
 
 #endif /* !_INIT_HELPERS_H_ */
common/board_f.c +0 -0
index f81f70d..6e6a1a2 100644
@@ -818,11 +818,6 @@ static init_fnc_t init_sequence_f[] = {
        probecpu,
 #endif

common/board_f.c static init_fnc_t init_sequence_f[] = {

Quoted 10 lines
common/board_f.c +0 -6
        arch_cpu_init,          /* basic arch cpu dependent setup */
-#ifdef CONFIG_X86
-# ifdef CONFIG_OF_CONTROL
-       find_fdt,               /* TODO(sjg at chromium.org): remove */
-# endif
-#endif
        mark_bootstage,
 #ifdef CONFIG_OF_CONTROL
        fdtdec_check_fdt,
--

Please remove the find_fdt() in arch/x86/lib/init_helpers.c as well.

Regards,
Bin

#35 lore raw

PATCH 16/39 x86: Fix up some missing prototypes

In reply to Simon Glass

Some functions are missing prototypes. Fix those that are specific to x86.

---

 arch/x86/cpu/coreboot/coreboot.c  | 4 +---
 arch/x86/cpu/coreboot/sdram.c     | 4 ++--
 arch/x86/cpu/cpu.c                | 3 +--
 arch/x86/cpu/interrupts.c         | 2 +-
 arch/x86/include/asm/u-boot-x86.h | 9 +++++++++
 5 files changed, 14 insertions(+), 8 deletions(-)
arch/x86/cpu/coreboot/coreboot.c +1 -3
index b640f35..c430ab1 100644
@@ -95,7 +95,7 @@ int board_eth_init(bd_t *bis)
 #define MTRRphysBase_MSR(reg) (0x200 + 2 * (reg))
 #define MTRRphysMask_MSR(reg) (0x200 + 2 * (reg) + 1)
 
-int board_final_cleanup(void)
+void board_final_cleanup(void)
 {
 	/* Un-cache the ROM so the kernel has one
 	 * more MTRR available.
@@ -117,8 +117,6 @@ int board_final_cleanup(void)
 	/* Issue SMI to Coreboot to lock down ME and registers */
 	printf("Finalizing Coreboot\n");
 	outb(0xcb, 0xb2);
-
-	return 0;
 }
 
 void panic_puts(const char *str)
arch/x86/cpu/coreboot/sdram.c +2 -2
index ca651c7..342ff30 100644
@@ -14,6 +14,7 @@
 #include <asm/init_helpers.h>
 #include <asm/processor.h>
 #include <asm/sections.h>
+#include <asm/zimage.h>
 #include <asm/arch/sysinfo.h>
 #include <asm/arch/tables.h>
 
@@ -99,7 +100,7 @@ int dram_init(void)
 	return calculate_relocation_address();
 }
 
-int dram_init_banksize(void)
+void dram_init_banksize(void)
 {
 	int i, j;
 
@@ -116,5 +117,4 @@ int dram_init_banksize(void)
 			}
 		}
 	}
-	return 0;
 }
arch/x86/cpu/cpu.c +1 -2
index d6ba246..6441dde 100644
@@ -197,14 +197,13 @@ asm(".globl generate_gpf\n"
 	"generate_gpf:\n"
 	"ljmp   $0x70, $0x47114711\n");
 
-void __reset_cpu(ulong addr)
+__weak void reset_cpu(ulong addr)
 {
 	printf("Resetting using x86 Triple Fault\n");
 	set_vector(13, generate_gpf);	/* general protection fault handler */
 	set_vector(8, generate_gpf);	/* double fault handler */
 	generate_gpf();			/* start the show */
 }
-void reset_cpu(ulong addr) __attribute__((weak, alias("__reset_cpu")));
 
 int dcache_status(void)
 {
arch/x86/cpu/interrupts.c +1 -1
index 6f3d85f..51e2c59 100644
@@ -31,7 +31,7 @@ DECLARE_GLOBAL_DATA_PTR;
 	"pushl $"#x"\n" \
 	"jmp irq_common_entry\n"
 
-void dump_regs(struct irq_regs *regs)
+static void dump_regs(struct irq_regs *regs)
 {
 	unsigned long cr0 = 0L, cr2 = 0L, cr3 = 0L, cr4 = 0L;
 	unsigned long d0, d1, d2, d3, d6, d7;
arch/x86/include/asm/u-boot-x86.h +9 -0
index fdb8a6c..8d5b438 100644
@@ -37,6 +37,15 @@ int cpu_init_interrupts(void);
 /* board/.../... */
 int dram_init(void);
 
+int cleanup_before_linux(void);
+int x86_cleanup_before_linux(void);
+void x86_enable_caches(void);
+void x86_disable_caches(void);
+int x86_init_cache(void);
+void reset_cpu(ulong addr);
+ulong board_get_usable_ram_top(ulong total_size);
+void dram_init_banksize(void);
+
 void setup_pcat_compatibility(void);
 
 void isa_unmap_rom(u32 addr);
Signature · 1 line
2.1.0.rc2.206.gedb03e5
#36 lore raw

PATCH 16/39 x86: Fix up some missing prototypes

Quoted 105 lines · Simon Glass

Some functions are missing prototypes. Fix those that are specific to x86.

---

 arch/x86/cpu/coreboot/coreboot.c  | 4 +---
 arch/x86/cpu/coreboot/sdram.c     | 4 ++--
 arch/x86/cpu/cpu.c                | 3 +--
 arch/x86/cpu/interrupts.c         | 2 +-
 arch/x86/include/asm/u-boot-x86.h | 9 +++++++++
 5 files changed, 14 insertions(+), 8 deletions(-)
arch/x86/cpu/coreboot/coreboot.c +1 -3
index b640f35..c430ab1 100644
@@ -95,7 +95,7 @@ int board_eth_init(bd_t *bis)
 #define MTRRphysBase_MSR(reg) (0x200 + 2 * (reg))
 #define MTRRphysMask_MSR(reg) (0x200 + 2 * (reg) + 1)
 
-int board_final_cleanup(void)
+void board_final_cleanup(void)
 {
        /* Un-cache the ROM so the kernel has one
         * more MTRR available.
@@ -117,8 +117,6 @@ int board_final_cleanup(void)
        /* Issue SMI to Coreboot to lock down ME and registers */
        printf("Finalizing Coreboot\n");
        outb(0xcb, 0xb2);
-
-       return 0;
 }
 
 void panic_puts(const char *str)
arch/x86/cpu/coreboot/sdram.c +2 -2
index ca651c7..342ff30 100644
@@ -14,6 +14,7 @@
 #include <asm/init_helpers.h>
 #include <asm/processor.h>
 #include <asm/sections.h>
+#include <asm/zimage.h>
 #include <asm/arch/sysinfo.h>
 #include <asm/arch/tables.h>
 
@@ -99,7 +100,7 @@ int dram_init(void)
        return calculate_relocation_address();
 }
 
-int dram_init_banksize(void)
+void dram_init_banksize(void)
 {
        int i, j;
 
@@ -116,5 +117,4 @@ int dram_init_banksize(void)
                        }
                }
        }
-       return 0;
 }
arch/x86/cpu/cpu.c +1 -2
index d6ba246..6441dde 100644
@@ -197,14 +197,13 @@ asm(".globl generate_gpf\n"
        "generate_gpf:\n"
        "ljmp   $0x70, $0x47114711\n");
 
-void __reset_cpu(ulong addr)
+__weak void reset_cpu(ulong addr)
 {
        printf("Resetting using x86 Triple Fault\n");
        set_vector(13, generate_gpf);   /* general protection fault handler */
        set_vector(8, generate_gpf);    /* double fault handler */
        generate_gpf();                 /* start the show */
 }
-void reset_cpu(ulong addr) __attribute__((weak, alias("__reset_cpu")));
 
 int dcache_status(void)
 {
arch/x86/cpu/interrupts.c +1 -1
index 6f3d85f..51e2c59 100644
@@ -31,7 +31,7 @@ DECLARE_GLOBAL_DATA_PTR;
        "pushl $"#x"\n" \
        "jmp irq_common_entry\n"
 
-void dump_regs(struct irq_regs *regs)
+static void dump_regs(struct irq_regs *regs)
 {
        unsigned long cr0 = 0L, cr2 = 0L, cr3 = 0L, cr4 = 0L;
        unsigned long d0, d1, d2, d3, d6, d7;
arch/x86/include/asm/u-boot-x86.h +3 -0
index fdb8a6c..8d5b438 100644
@@ -37,6 +37,15 @@ int cpu_init_interrupts(void);
 /* board/.../... */
 int dram_init(void);
 
+int cleanup_before_linux(void);
+int x86_cleanup_before_linux(void);
+void x86_enable_caches(void);

arch/x86/include/asm/u-boot-x86.h int cpu_init_interrupts(void);

Quoted 10 lines
arch/x86/include/asm/u-boot-x86.h +6 -1
+void x86_disable_caches(void);
+int x86_init_cache(void);
+void reset_cpu(ulong addr);
+ulong board_get_usable_ram_top(ulong total_size);
+void dram_init_banksize(void);
+
 void setup_pcat_compatibility(void);
 
 void isa_unmap_rom(u32 addr);
--
#37 lore raw

PATCH 16/39 x86: Fix up some missing prototypes

Quoted 114 lines · Bin Meng
Quoted 113 lines · Simon Glass

Some functions are missing prototypes. Fix those that are specific to x86.

---

 arch/x86/cpu/coreboot/coreboot.c  | 4 +---
 arch/x86/cpu/coreboot/sdram.c     | 4 ++--
 arch/x86/cpu/cpu.c                | 3 +--
 arch/x86/cpu/interrupts.c         | 2 +-
 arch/x86/include/asm/u-boot-x86.h | 9 +++++++++
 5 files changed, 14 insertions(+), 8 deletions(-)
arch/x86/cpu/coreboot/coreboot.c +1 -3
index b640f35..c430ab1 100644
@@ -95,7 +95,7 @@ int board_eth_init(bd_t *bis)
 #define MTRRphysBase_MSR(reg) (0x200 + 2 * (reg))
 #define MTRRphysMask_MSR(reg) (0x200 + 2 * (reg) + 1)
 
-int board_final_cleanup(void)
+void board_final_cleanup(void)
 {
        /* Un-cache the ROM so the kernel has one
         * more MTRR available.
@@ -117,8 +117,6 @@ int board_final_cleanup(void)
        /* Issue SMI to Coreboot to lock down ME and registers */
        printf("Finalizing Coreboot\n");
        outb(0xcb, 0xb2);
-
-       return 0;
 }
 
 void panic_puts(const char *str)
arch/x86/cpu/coreboot/sdram.c +2 -2
index ca651c7..342ff30 100644
@@ -14,6 +14,7 @@
 #include <asm/init_helpers.h>
 #include <asm/processor.h>
 #include <asm/sections.h>
+#include <asm/zimage.h>
 #include <asm/arch/sysinfo.h>
 #include <asm/arch/tables.h>
 
@@ -99,7 +100,7 @@ int dram_init(void)
        return calculate_relocation_address();
 }
 
-int dram_init_banksize(void)
+void dram_init_banksize(void)
 {
        int i, j;
 
@@ -116,5 +117,4 @@ int dram_init_banksize(void)
                        }
                }
        }
-       return 0;
 }
arch/x86/cpu/cpu.c +1 -2
index d6ba246..6441dde 100644
@@ -197,14 +197,13 @@ asm(".globl generate_gpf\n"
        "generate_gpf:\n"
        "ljmp   $0x70, $0x47114711\n");
 
-void __reset_cpu(ulong addr)
+__weak void reset_cpu(ulong addr)
 {
        printf("Resetting using x86 Triple Fault\n");
        set_vector(13, generate_gpf);   /* general protection fault handler */
        set_vector(8, generate_gpf);    /* double fault handler */
        generate_gpf();                 /* start the show */
 }
-void reset_cpu(ulong addr) __attribute__((weak, alias("__reset_cpu")));
 
 int dcache_status(void)
 {
arch/x86/cpu/interrupts.c +1 -1
index 6f3d85f..51e2c59 100644
@@ -31,7 +31,7 @@ DECLARE_GLOBAL_DATA_PTR;
        "pushl $"#x"\n" \
        "jmp irq_common_entry\n"
 
-void dump_regs(struct irq_regs *regs)
+static void dump_regs(struct irq_regs *regs)
 {
        unsigned long cr0 = 0L, cr2 = 0L, cr3 = 0L, cr4 = 0L;
        unsigned long d0, d1, d2, d3, d6, d7;
arch/x86/include/asm/u-boot-x86.h +9 -0
index fdb8a6c..8d5b438 100644
@@ -37,6 +37,15 @@ int cpu_init_interrupts(void);
 /* board/.../... */
 int dram_init(void);
 
+int cleanup_before_linux(void);
+int x86_cleanup_before_linux(void);
+void x86_enable_caches(void);
+void x86_disable_caches(void);
+int x86_init_cache(void);
+void reset_cpu(ulong addr);
+ulong board_get_usable_ram_top(ulong total_size);
+void dram_init_banksize(void);
+
 void setup_pcat_compatibility(void);
 
Quoted 4 lines

arch/x86/include/asm/u-boot-x86.h int cpu_init_interrupts(void);

Quoted 2 lines
arch/x86/include/asm/u-boot-x86.h +0 -1
 void isa_unmap_rom(u32 addr);
--

Applied to u-boot-x86.

#38 lore raw

PATCH 17/39 x86: Add chromebook_link board

In reply to Simon Glass

This board is a 'bare' version of the existing 'link 'board. It does not require coreboot to run, but is intended to start directly from the reset vector.

This initial commit has place holders for a wide range of features. These will be added in follow-on patches and series. So far it cannot be booted as there is no ROM image produced, but it does build without errors.

---

 arch/x86/Kconfig                           |  23 +++++
 arch/x86/cpu/coreboot/coreboot.c           |   8 ++
 arch/x86/cpu/cpu.c                         |  32 ++++--
 arch/x86/cpu/ivybridge/Kconfig             | 157 +++++++++++++++++++++++++++++
 arch/x86/cpu/ivybridge/Makefile            |   9 ++
 arch/x86/cpu/ivybridge/car.S               |  20 ++++
 arch/x86/cpu/ivybridge/cpu.c               |  41 ++++++++
 arch/x86/cpu/ivybridge/sdram.c             |  20 ++++
 arch/x86/dts/Makefile                      |   1 +
 arch/x86/dts/chromebook_link.dts           |   1 +
 arch/x86/include/asm/arch-ivybridge/gpio.h |  10 ++
 arch/x86/include/asm/processor.h           |  12 +++
 board/google/chromebook_link/Kconfig       |  15 +++
 board/google/chromebook_link/MAINTAINERS   |   6 ++
 board/google/chromebook_link/Makefile      |  15 +++
 board/google/chromebook_link/link.c        |  17 ++++
 configs/chromebook_link_defconfig          |  10 ++
 include/configs/chromebook_link.h          |  53 ++++++++++
 18 files changed, 443 insertions(+), 7 deletions(-)
 create mode 100644 arch/x86/cpu/ivybridge/Kconfig
 create mode 100644 arch/x86/cpu/ivybridge/Makefile
 create mode 100644 arch/x86/cpu/ivybridge/car.S
 create mode 100644 arch/x86/cpu/ivybridge/cpu.c
 create mode 100644 arch/x86/cpu/ivybridge/sdram.c
 create mode 120000 arch/x86/dts/chromebook_link.dts
 create mode 100644 arch/x86/include/asm/arch-ivybridge/gpio.h
 create mode 100644 board/google/chromebook_link/Kconfig
 create mode 100644 board/google/chromebook_link/MAINTAINERS
 create mode 100644 board/google/chromebook_link/Makefile
 create mode 100644 board/google/chromebook_link/link.c
 create mode 100644 configs/chromebook_link_defconfig
 create mode 100644 include/configs/chromebook_link.h
arch/x86/Kconfig +23 -0
index 0dba8ac..07ff149 100644
@@ -12,9 +12,32 @@ choice
 
 config TARGET_COREBOOT
 	bool "Support coreboot"
+	help
+	  This target is used for running U-Boot on top of Coreboot. In
+	  this case Coreboot does the early inititalisation, and U-Boot
+	  takes over once the RAM, video and CPU are fully running.
+	  U-Boot is loaded as a fallback payload from Coreboot, in
+	  Coreboot terminology. This method was used for the Chromebook
+	  Pixel when launched.
+
+config TARGET_CHROMEBOOK_LINK
+	bool "Support Chromebook link"
+	help
+	  This is the Chromebook Pixel released in 2013. It uses an Intel
+	  i5 Ivybridge which is a die-shrink of Sandybridge, with 4GB of
+	  SDRAM. It has a Panther Point peripheral controller hub, PCIe
+	  WiFi and Bluetooth. It also includes a 720p webcam, USB SD
+	  reader, microphone and speakers, display port and 32GB SATA
+	  solid state drive. There is a Chrome OS EC connected on LPC,
+	  and it provides a 2560x1700 high resolution touch-enabled LCD
+	  display.
 
 endchoice
 
+source "arch/x86/cpu/ivybridge/Kconfig"
+
 source "board/chromebook-x86/coreboot/Kconfig"
 
+source "board/google/chromebook_link/Kconfig"
+
 endmenu
arch/x86/cpu/coreboot/coreboot.c +8 -0
index c430ab1..257faa1 100644
@@ -13,6 +13,7 @@
 #include <ns16550.h>
 #include <asm/msr.h>
 #include <asm/cache.h>
+#include <asm/cpu.h>
 #include <asm/io.h>
 #include <asm/arch-coreboot/tables.h>
 #include <asm/arch-coreboot/sysinfo.h>
@@ -127,3 +128,10 @@ void panic_puts(const char *str)
 	while (*str)
 		NS16550_putc(port, *str++);
 }
+
+int print_cpuinfo(void)
+{
+	printf("CPU:   %s\n", cpu_has_64bit() ? "x86_64" : "x86");
+
+	return 0;
+}
arch/x86/cpu/cpu.c +25 -7
index 6441dde..61c198e 100644
@@ -334,13 +334,6 @@ int cpu_has_64bit(void)
 		has_long_mode();
 }
 
-int print_cpuinfo(void)
-{
-	printf("CPU:   %s\n", cpu_has_64bit() ? "x86_64" : "x86");
-
-	return 0;
-}
-
 #define PAGETABLE_SIZE		(6 * 4096)
 
 /**
@@ -382,3 +375,28 @@ int cpu_jump_to_64bit(ulong setup_base, ulong target)
 
 	return -EFAULT;
 }
+
+char *cpu_get_name(char *name)
+{
+	unsigned int *name_as_ints = (unsigned int *)name;
+	struct cpuid_result regs;
+	char *ptr;
+	int i;
+
+	/* This bit adds up to 48 bytes */
+	for (i = 0; i < 3; i++) {
+		regs = cpuid(0x80000002 + i);
+		name_as_ints[i * 4 + 0] = regs.eax;
+		name_as_ints[i * 4 + 1] = regs.ebx;
+		name_as_ints[i * 4 + 2] = regs.ecx;
+		name_as_ints[i * 4 + 3] = regs.edx;
+	}
+	name[CPU_MAX_NAME_LEN - 1] = '\0';
+
+	/* Skip leading spaces. */
+	ptr = name;
+	while (*ptr == ' ')
+		ptr++;
+
+	return ptr;
+}
arch/x86/cpu/ivybridge/Kconfig new file +157 -0

157 lines not on this page · raw message

arch/x86/cpu/ivybridge/Makefile new file +9 -0
new file mode 100644
index 0000000..dbcd4bd
@@ -0,0 +1,9 @@
+#
+# Copyright (c) 2014 Google, Inc
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+obj-y += car.o
+obj-y += cpu.o
+obj-y += sdram.o
arch/x86/cpu/ivybridge/car.S new file +20 -0
new file mode 100644
index 0000000..0480813
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2014 Google, Inc
+ *
+ * From Coreboot file cpu/intel/model_206ax/cache_as_ram.inc
+ *
+ * Copyright (C) 2000,2007 Ronald G. Minnich <[email protected]>
+ * Copyright (C) 2005 Tyan (written by Yinghai Lu for Tyan)
+ * Copyright (C) 2007-2008 coresystems GmbH
+ * Copyright (C) 2012 Ky?sti M?lkki <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0
+ */
+
+#include <common.h>
+
+	/* Note: ebp must not be touched in this code */
+.globl car_init
+car_init:
+	/* TODO: Add cache-as-RAM init here */
+	jmp	car_init_ret
arch/x86/cpu/ivybridge/cpu.c new file +41 -0

41 lines not on this page · raw message

arch/x86/cpu/ivybridge/sdram.c new file +20 -0
new file mode 100644
index 0000000..5f9ae5e
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ * (C) Copyright 2010,2011
+ * Graeme Russ, <[email protected]>
+ *
+ * Portions from Coreboot mainboard/google/link/romstage.c
+ * Copyright (C) 2007-2010 coresystems GmbH
+ * Copyright (C) 2011 Google Inc.
+ *
+ * SPDX-License-Identifier:	GPL-2.0
+ */
+
+#include <common.h>
+
+int dram_init(void)
+{
+	/* TODO: Set up DRAM */
+
+	return 0;
+}
arch/x86/dts/Makefile +1 -0
index 48265ef..bb3b116 100644
@@ -1,4 +1,5 @@
 dtb-y += link.dtb \
+	chromebook_link.dtb \
 	alex.dtb
 
 targets += $(dtb-y)
arch/x86/dts/chromebook_link.dts new file +1 -0
new file mode 120000
index 0000000..6f8c5cd
@@ -0,0 +1 @@
+link.dts
\ No newline at end of file
arch/x86/include/asm/arch-ivybridge/gpio.h new file +10 -0
new file mode 100644
index 0000000..4951a8c
@@ -0,0 +1,10 @@
+/*
+ * Copyright (c) 2014, Google Inc.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef _X86_ARCH_GPIO_H_
+#define _X86_ARCH_GPIO_H_
+
+#endif /* _X86_ARCH_GPIO_H_ */
arch/x86/include/asm/processor.h +12 -0
index 30d7d48..2c33723 100644
@@ -149,6 +149,18 @@ static inline unsigned int cpuid_edx(unsigned int op)
 		: "ecx", "edi");
 	return edx;
 }
+
+#define CPU_MAX_NAME_LEN	49
+
+/**
+ * cpu_get_name() - Get the name of the current cpu
+ *
+ * @name: Place to put name, which must be CPU_MAX_NAME_LEN bytes including
+ * @return pointer to name, which will likely be a few bytes after the start
+ * of @name
+ * \0 terminator
+ */
+char *cpu_get_name(char *name);
 #endif /* __ASSEMBLY__ */
 
 #endif
board/google/chromebook_link/Kconfig new file +15 -0
new file mode 100644
index 0000000..975d557
@@ -0,0 +1,15 @@
+if TARGET_CHROMEBOOK_LINK
+
+config SYS_BOARD
+	default "chromebook_link"
+
+config SYS_VENDOR
+	default "google"
+
+config SYS_SOC
+	default "ivybridge"
+
+config SYS_CONFIG_NAME
+	default "chromebook_link"
+
+endif
board/google/chromebook_link/MAINTAINERS new file +6 -0
new file mode 100644
index 0000000..bc253a2
@@ -0,0 +1,6 @@
+CHROMEBOOK LINK BOARD
+M:	Simon Glass <[email protected]>
+S:	Maintained
+F:	board/google/chromebook_link/
+F:	include/configs/chromebook_link.h
+F:	configs/chromebook_link_defconfig
board/google/chromebook_link/Makefile new file +15 -0
new file mode 100644
index 0000000..a133c2e
@@ -0,0 +1,15 @@
+#
+# Copyright (c) 2011 The Chromium OS Authors.
+# (C) Copyright 2008
+# Graeme Russ, graeme.russ at gmail.com.
+#
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# (C) Copyright 2002
+# Daniel Engstr?m, Omicron Ceti AB, daniel at omicron.se.
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+obj-y	+= link.o
board/google/chromebook_link/link.c new file +17 -0
new file mode 100644
index 0000000..ffa9d60
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2014 Google, Inc
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+
+int arch_early_init_r(void)
+{
+	return 0;
+}
+
+int board_early_init_r(void)
+{
+	return 0;
+}
configs/chromebook_link_defconfig new file +10 -0
new file mode 100644
index 0000000..b83803e
@@ -0,0 +1,10 @@
+CONFIG_SYS_EXTRA_OPTIONS="SYS_TEXT_BASE=0xfff00000"
+CONFIG_X86=y
+CONFIG_TARGET_CHROMEBOOK_LINK=y
+CONFIG_OF_CONTROL=y
+CONFIG_OF_SEPARATE=y
+CONFIG_DEFAULT_DEVICE_TREE="chromebook_link"
+CONFIG_HAVE_MRC=y
+CONFIG_SMM_TSEG_SIZE=0x800000
+CONFIG_FRAMEBUFFER_SET_VESA_MODE=y
+CONFIG_FRAMEBUFFER_VESA_MODE_11A=y
include/configs/chromebook_link.h new file +53 -0

53 lines not on this page · raw message

Signature · 1 line
2.1.0.rc2.206.gedb03e5
#39 lore raw

PATCH 17/39 x86: Add chromebook_link board

Hi Simon,

Quoted 56 lines · Simon Glass

This board is a 'bare' version of the existing 'link 'board. It does not require coreboot to run, but is intended to start directly from the reset vector.

This initial commit has place holders for a wide range of features. These will be added in follow-on patches and series. So far it cannot be booted as there is no ROM image produced, but it does build without errors.

---

 arch/x86/Kconfig                           |  23 +++++
 arch/x86/cpu/coreboot/coreboot.c           |   8 ++
 arch/x86/cpu/cpu.c                         |  32 ++++--
 arch/x86/cpu/ivybridge/Kconfig             | 157 +++++++++++++++++++++++++++++
 arch/x86/cpu/ivybridge/Makefile            |   9 ++
 arch/x86/cpu/ivybridge/car.S               |  20 ++++
 arch/x86/cpu/ivybridge/cpu.c               |  41 ++++++++
 arch/x86/cpu/ivybridge/sdram.c             |  20 ++++
 arch/x86/dts/Makefile                      |   1 +
 arch/x86/dts/chromebook_link.dts           |   1 +
 arch/x86/include/asm/arch-ivybridge/gpio.h |  10 ++
 arch/x86/include/asm/processor.h           |  12 +++
 board/google/chromebook_link/Kconfig       |  15 +++
 board/google/chromebook_link/MAINTAINERS   |   6 ++
 board/google/chromebook_link/Makefile      |  15 +++
 board/google/chromebook_link/link.c        |  17 ++++
 configs/chromebook_link_defconfig          |  10 ++
 include/configs/chromebook_link.h          |  53 ++++++++++
 18 files changed, 443 insertions(+), 7 deletions(-)
 create mode 100644 arch/x86/cpu/ivybridge/Kconfig
 create mode 100644 arch/x86/cpu/ivybridge/Makefile
 create mode 100644 arch/x86/cpu/ivybridge/car.S
 create mode 100644 arch/x86/cpu/ivybridge/cpu.c
 create mode 100644 arch/x86/cpu/ivybridge/sdram.c
 create mode 120000 arch/x86/dts/chromebook_link.dts
 create mode 100644 arch/x86/include/asm/arch-ivybridge/gpio.h
 create mode 100644 board/google/chromebook_link/Kconfig
 create mode 100644 board/google/chromebook_link/MAINTAINERS
 create mode 100644 board/google/chromebook_link/Makefile
 create mode 100644 board/google/chromebook_link/link.c
 create mode 100644 configs/chromebook_link_defconfig
 create mode 100644 include/configs/chromebook_link.h
arch/x86/Kconfig +4 -0
index 0dba8ac..07ff149 100644
@@ -12,9 +12,32 @@ choice
 
 config TARGET_COREBOOT
        bool "Support coreboot"
+       help
+         This target is used for running U-Boot on top of Coreboot. In
+         this case Coreboot does the early inititalisation, and U-Boot
+         takes over once the RAM, video and CPU are fully running.

arch/x86/Kconfig choice · line 28

Quoted 10 lines
arch/x86/Kconfig +10 -0
+         U-Boot is loaded as a fallback payload from Coreboot, in
+         Coreboot terminology. This method was used for the Chromebook
+         Pixel when launched.
+
+config TARGET_CHROMEBOOK_LINK
+       bool "Support Chromebook link"
+       help
+         This is the Chromebook Pixel released in 2013. It uses an Intel
+         i5 Ivybridge which is a die-shrink of Sandybridge, with 4GB of
+         SDRAM. It has a Panther Point peripheral controller hub, PCIe

Intel official name is 'platform controller hub'.

arch/x86/Kconfig choice · line 39

Quoted 11 lines
arch/x86/Kconfig +7 -0
+         WiFi and Bluetooth. It also includes a 720p webcam, USB SD
+         reader, microphone and speakers, display port and 32GB SATA
+         solid state drive. There is a Chrome OS EC connected on LPC,
+         and it provides a 2560x1700 high resolution touch-enabled LCD
+         display.
 
 endchoice
 
+source "arch/x86/cpu/ivybridge/Kconfig"
+
 source "board/chromebook-x86/coreboot/Kconfig"

Not related to this patch, but do you consider renaming 'board/chromebook-x86/' to something like 'board/generic-x86/' since this build of U-Boot is supposed to run as a payload from coreboot on every board that coreboot supports in theory.

Quoted 550 lines
arch/x86/Kconfig +2 -0
+source "board/google/chromebook_link/Kconfig"
+
 endmenu
arch/x86/cpu/coreboot/coreboot.c +8 -0
index c430ab1..257faa1 100644
@@ -13,6 +13,7 @@
 #include <ns16550.h>
 #include <asm/msr.h>
 #include <asm/cache.h>
+#include <asm/cpu.h>
 #include <asm/io.h>
 #include <asm/arch-coreboot/tables.h>
 #include <asm/arch-coreboot/sysinfo.h>
@@ -127,3 +128,10 @@ void panic_puts(const char *str)
        while (*str)
                NS16550_putc(port, *str++);
 }
+
+int print_cpuinfo(void)
+{
+       printf("CPU:   %s\n", cpu_has_64bit() ? "x86_64" : "x86");
+
+       return 0;
+}
arch/x86/cpu/cpu.c +25 -7
index 6441dde..61c198e 100644
@@ -334,13 +334,6 @@ int cpu_has_64bit(void)
                has_long_mode();
 }
 
-int print_cpuinfo(void)
-{
-       printf("CPU:   %s\n", cpu_has_64bit() ? "x86_64" : "x86");
-
-       return 0;
-}
-
 #define PAGETABLE_SIZE         (6 * 4096)
 
 /**
@@ -382,3 +375,28 @@ int cpu_jump_to_64bit(ulong setup_base, ulong target)
 
        return -EFAULT;
 }
+
+char *cpu_get_name(char *name)
+{
+       unsigned int *name_as_ints = (unsigned int *)name;
+       struct cpuid_result regs;
+       char *ptr;
+       int i;
+
+       /* This bit adds up to 48 bytes */
+       for (i = 0; i < 3; i++) {
+               regs = cpuid(0x80000002 + i);
+               name_as_ints[i * 4 + 0] = regs.eax;
+               name_as_ints[i * 4 + 1] = regs.ebx;
+               name_as_ints[i * 4 + 2] = regs.ecx;
+               name_as_ints[i * 4 + 3] = regs.edx;
+       }
+       name[CPU_MAX_NAME_LEN - 1] = '\0';
+
+       /* Skip leading spaces. */
+       ptr = name;
+       while (*ptr == ' ')
+               ptr++;
+
+       return ptr;
+}
arch/x86/cpu/ivybridge/Kconfig new file +157 -0
new file mode 100644
index 0000000..030d813
@@ -0,0 +1,157 @@
+#
+# From Coreboot src/northbridge/intel/sandybridge/Kconfig
+#
+# Copyright (C) 2010 Google Inc.
+#
+# SPDX-License-Identifier:     GPL-2.0
+
+
+config NORTHBRIDGE_INTEL_SANDYBRIDGE
+       bool
+       select CACHE_MRC_BIN
+       select CPU_INTEL_MODEL_206AX
+
+config NORTHBRIDGE_INTEL_IVYBRIDGE
+       bool
+       select CACHE_MRC_BIN
+       select CPU_INTEL_MODEL_306AX
+
+if NORTHBRIDGE_INTEL_SANDYBRIDGE
+
+config VGA_BIOS_ID
+       string
+       default "8086,0106"
+
+config CACHE_MRC_SIZE_KB
+       int
+       default 256
+
+config MRC_CACHE_BASE
+       hex
+       default 0xff800000
+
+config MRC_CACHE_LOCATION
+       hex
+       depends on !CHROMEOS
+       default 0x1ec000
+
+config MRC_CACHE_SIZE
+       hex
+       depends on !CHROMEOS
+       default 0x10000
+
+config DCACHE_RAM_BASE
+       hex
+       default 0xff7f0000
+
+config DCACHE_RAM_SIZE
+       hex
+       default 0x10000
+
+endif
+
+if NORTHBRIDGE_INTEL_IVYBRIDGE
+
+config VGA_BIOS_ID
+       string
+       default "8086,0166"
+
+config EXTERNAL_MRC_BLOB
+       bool
+       default n
+
+config CACHE_MRC_SIZE_KB
+       int
+       default 512
+
+config MRC_CACHE_BASE
+       hex
+       default 0xff800000
+
+config MRC_CACHE_LOCATION
+       hex
+       depends on !CHROMEOS
+       default 0x370000
+
+config MRC_CACHE_SIZE
+       hex
+       depends on !CHROMEOS
+       default 0x10000
+
+config DCACHE_RAM_BASE
+       hex
+       default 0xff7e0000
+
+config DCACHE_RAM_SIZE
+       hex
+       default 0x20000
+
+endif
+
+if NORTHBRIDGE_INTEL_SANDYBRIDGE || NORTHBRIDGE_INTEL_IVYBRIDGE
+
+config HAVE_MRC
+        bool "Add a System Agent binary"
+        help
+          Select this option to add a System Agent binary to
+          the resulting U-Boot image. MRC stands for Memory Reference Code.
+          It is a binary blob which U-Boot uses to set up SDRAM.
+
+          Note: Without this binary U-Boot will not be able to set up its
+          SDRAM so will not boot.
+
+config DCACHE_RAM_MRC_VAR_SIZE
+       hex
+       default 0x4000
+       help
+         This is the amount of CAR (Cache as RAM) reserved for use by the
+         memory reference code. This should be set to 16KB (0x4000 hex)
+         so that MRC has enough space to run.
+
+config MRC_FILE
+       string "Intel System Agent path and filename"
+       depends on HAVE_MRC
+       default "systemagent-ivybridge.bin" if NORTHBRIDGE_INTEL_IVYBRIDGE
+       default "systemagent-sandybridge.bin" if NORTHBRIDGE_INTEL_SANDYBRIDGE
+       help
+         The path and filename of the file to use as System Agent
+         binary.
+
+config CPU_SPECIFIC_OPTIONS
+       def_bool y
+       select SMM_TSEG
+       select ARCH_BOOTBLOCK_X86_32
+       select ARCH_ROMSTAGE_X86_32
+       select ARCH_RAMSTAGE_X86_32
+       select SMP
+       select SSE2
+       select UDELAY_LAPIC
+       select CPU_MICROCODE_IN_CBFS
+       select TSC_SYNC_MFENCE
+
+config SMM_TSEG_SIZE
+       hex
+       default 0x800000
+
+config ENABLE_VMX
+       bool "Enable VMX for virtualization"
+       default n
+
+endif
+
+config CPU_INTEL_SOCKET_RPGA989
+       bool
+
+if CPU_INTEL_SOCKET_RPGA989
+
+config SOCKET_SPECIFIC_OPTIONS # dummy
+       def_bool y
+       select MMX
+       select SSE
+       select CACHE_AS_RAM
+
+config CACHE_MRC_BIN
+       bool
+       default n
+
+endif
arch/x86/cpu/ivybridge/Makefile new file +9 -0
new file mode 100644
index 0000000..dbcd4bd
@@ -0,0 +1,9 @@
+#
+# Copyright (c) 2014 Google, Inc
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+obj-y += car.o
+obj-y += cpu.o
+obj-y += sdram.o
arch/x86/cpu/ivybridge/car.S new file +20 -0
new file mode 100644
index 0000000..0480813
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2014 Google, Inc
+ *
+ * From Coreboot file cpu/intel/model_206ax/cache_as_ram.inc
+ *
+ * Copyright (C) 2000,2007 Ronald G. Minnich <[email protected]>
+ * Copyright (C) 2005 Tyan (written by Yinghai Lu for Tyan)
+ * Copyright (C) 2007-2008 coresystems GmbH
+ * Copyright (C) 2012 Ky?sti M?lkki <[email protected]>
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+
+       /* Note: ebp must not be touched in this code */
+.globl car_init
+car_init:
+       /* TODO: Add cache-as-RAM init here */
+       jmp     car_init_ret
arch/x86/cpu/ivybridge/cpu.c new file +41 -0
new file mode 100644
index 0000000..7e77be6
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2014 Google, Inc
+ * (C) Copyright 2008
+ * Graeme Russ, graeme.russ at gmail.com.
+ *
+ * Some portions from coreboot src/mainboard/google/link/romstage.c
+ * Copyright (C) 2007-2010 coresystems GmbH
+ * Copyright (C) 2011 Google Inc.
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <asm/processor.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int arch_cpu_init(void)
+{
+       int ret;
+
+       timer_set_base(rdtsc());
+
+       ret = x86_cpu_init_f();
+       if (ret)
+               return ret;
+
+       return 0;
+}
+
+int print_cpuinfo(void)
+{
+       char processor_name[CPU_MAX_NAME_LEN];
+       const char *name;
+
+       /* Print processor name */
+       name = cpu_get_name(processor_name);
+       printf("CPU:   %s\n", name);
+
+       return 0;
+}
arch/x86/cpu/ivybridge/sdram.c new file +20 -0
new file mode 100644
index 0000000..5f9ae5e
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ * (C) Copyright 2010,2011
+ * Graeme Russ, <[email protected]>
+ *
+ * Portions from Coreboot mainboard/google/link/romstage.c
+ * Copyright (C) 2007-2010 coresystems GmbH
+ * Copyright (C) 2011 Google Inc.
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+
+int dram_init(void)
+{
+       /* TODO: Set up DRAM */
+
+       return 0;
+}
arch/x86/dts/Makefile +1 -0
index 48265ef..bb3b116 100644
@@ -1,4 +1,5 @@
 dtb-y += link.dtb \
+       chromebook_link.dtb \
        alex.dtb
 
 targets += $(dtb-y)
arch/x86/dts/chromebook_link.dts new file +1 -0
new file mode 120000
index 0000000..6f8c5cd
@@ -0,0 +1 @@
+link.dts
\ No newline at end of file
arch/x86/include/asm/arch-ivybridge/gpio.h new file +10 -0
new file mode 100644
index 0000000..4951a8c
@@ -0,0 +1,10 @@
+/*
+ * Copyright (c) 2014, Google Inc.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef _X86_ARCH_GPIO_H_
+#define _X86_ARCH_GPIO_H_
+
+#endif /* _X86_ARCH_GPIO_H_ */
arch/x86/include/asm/processor.h +12 -0
index 30d7d48..2c33723 100644
@@ -149,6 +149,18 @@ static inline unsigned int cpuid_edx(unsigned int op)
                : "ecx", "edi");
        return edx;
 }
+
+#define CPU_MAX_NAME_LEN       49
+
+/**
+ * cpu_get_name() - Get the name of the current cpu
+ *
+ * @name: Place to put name, which must be CPU_MAX_NAME_LEN bytes including
+ * @return pointer to name, which will likely be a few bytes after the start
+ * of @name
+ * \0 terminator
+ */
+char *cpu_get_name(char *name);
 #endif /* __ASSEMBLY__ */
 
 #endif
board/google/chromebook_link/Kconfig new file +15 -0
new file mode 100644
index 0000000..975d557
@@ -0,0 +1,15 @@
+if TARGET_CHROMEBOOK_LINK
+
+config SYS_BOARD
+       default "chromebook_link"
+
+config SYS_VENDOR
+       default "google"
+
+config SYS_SOC
+       default "ivybridge"
+
+config SYS_CONFIG_NAME
+       default "chromebook_link"
+
+endif
board/google/chromebook_link/MAINTAINERS new file +6 -0
new file mode 100644
index 0000000..bc253a2
@@ -0,0 +1,6 @@
+CHROMEBOOK LINK BOARD
+M:     Simon Glass <[email protected]>
+S:     Maintained
+F:     board/google/chromebook_link/
+F:     include/configs/chromebook_link.h
+F:     configs/chromebook_link_defconfig
board/google/chromebook_link/Makefile new file +15 -0
new file mode 100644
index 0000000..a133c2e
@@ -0,0 +1,15 @@
+#
+# Copyright (c) 2011 The Chromium OS Authors.
+# (C) Copyright 2008
+# Graeme Russ, graeme.russ at gmail.com.
+#
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# (C) Copyright 2002
+# Daniel Engstr?m, Omicron Ceti AB, daniel at omicron.se.
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+obj-y  += link.o
board/google/chromebook_link/link.c new file +17 -0
new file mode 100644
index 0000000..ffa9d60
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2014 Google, Inc
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+
+int arch_early_init_r(void)
+{
+       return 0;
+}
+
+int board_early_init_r(void)
+{
+       return 0;
+}
configs/chromebook_link_defconfig new file +10 -0
new file mode 100644
index 0000000..b83803e
@@ -0,0 +1,10 @@
+CONFIG_SYS_EXTRA_OPTIONS="SYS_TEXT_BASE=0xfff00000"
+CONFIG_X86=y
+CONFIG_TARGET_CHROMEBOOK_LINK=y
+CONFIG_OF_CONTROL=y
+CONFIG_OF_SEPARATE=y
+CONFIG_DEFAULT_DEVICE_TREE="chromebook_link"
+CONFIG_HAVE_MRC=y
+CONFIG_SMM_TSEG_SIZE=0x800000
+CONFIG_FRAMEBUFFER_SET_VESA_MODE=y
+CONFIG_FRAMEBUFFER_VESA_MODE_11A=y
include/configs/chromebook_link.h new file +44 -0
new file mode 100644
index 0000000..1d6f55b
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ * (C) Copyright 2008
+ * Graeme Russ, graeme.russ at gmail.com.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+/*
+ * board/config.h - configuration options, board specific
+ */
+
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+#include <configs/x86-common.h>
+
+#define CONFIG_SYS_CAR_ADDR                    0xff7e0000
+#define CONFIG_SYS_CAR_SIZE                    (128 * 1024)
+#define CONFIG_SYS_MONITOR_LEN                 (1 << 20)
+#define CONFIG_BOARD_EARLY_INIT_R
+
+#define CONFIG_NR_DRAM_BANKS                   8
+
+/*
+ * These common x86 features are not yet supported, but are added in
+ * follow-on patches in this series. Add undefs here to avoid every patch
+ * having to put things back into x86-common.h
+ */
+#undef CONFIG_INTEL_ICH6_GPIO
+#undef CONFIG_DM_GPIO
+#undef CONFIG_CMD_GPIO
+#undef CONFIG_CROS_EC
+#undef CONFIG_CROS_EC_LPC
+#undef CONFIG_CMD_CROS_EC
+#undef CONFIG_ARCH_EARLY_INIT_R
+#undef CONFIG_VIDEO
+#undef CONFIG_CFB_CONSOLE
+#undef CONFIG_SYS_EARLY_PCI_INIT
+#undef CONFIG_PCI
+#undef CONFIG_ICH_SPI
+#undef CONFIG_SPI
+#undef CONFIG_CMD_SPI
+#undef CONFIG_CMD_SF

include/configs/chromebook_link.h

Quoted 10 lines
include/configs/chromebook_link.h new file +9 -1
+#undef CONFIG_USB_EHCI
+#undef CONFIG_CMD_USB
+#undef CONFIG_CMD_SCSI
+
+#define CONFIG_STD_DEVICES_SETTINGS     "stdin=usbkbd,vga,serial\0" \
+                                       "stdout=vga,serial\0" \
+                                       "stderr=vga,serial\0"
+
+#endif /* __CONFIG_H */
--

Regards,
Bin

#40 lore raw

PATCH 17/39 x86: Add chromebook_link board

Hi Bin,

Quoted 64 lines · Bin Meng

Hi Simon,

Quoted 60 lines · Simon Glass

This board is a 'bare' version of the existing 'link 'board. It does not require coreboot to run, but is intended to start directly from the reset vector.

This initial commit has place holders for a wide range of features. These will be added in follow-on patches and series. So far it cannot be booted as there is no ROM image produced, but it does build without errors.

---

 arch/x86/Kconfig                           |  23 +++++
 arch/x86/cpu/coreboot/coreboot.c           |   8 ++
 arch/x86/cpu/cpu.c                         |  32 ++++--
 arch/x86/cpu/ivybridge/Kconfig             | 157 +++++++++++++++++++++++++++++
 arch/x86/cpu/ivybridge/Makefile            |   9 ++
 arch/x86/cpu/ivybridge/car.S               |  20 ++++
 arch/x86/cpu/ivybridge/cpu.c               |  41 ++++++++
 arch/x86/cpu/ivybridge/sdram.c             |  20 ++++
 arch/x86/dts/Makefile                      |   1 +
 arch/x86/dts/chromebook_link.dts           |   1 +
 arch/x86/include/asm/arch-ivybridge/gpio.h |  10 ++
 arch/x86/include/asm/processor.h           |  12 +++
 board/google/chromebook_link/Kconfig       |  15 +++
 board/google/chromebook_link/MAINTAINERS   |   6 ++
 board/google/chromebook_link/Makefile      |  15 +++
 board/google/chromebook_link/link.c        |  17 ++++
 configs/chromebook_link_defconfig          |  10 ++
 include/configs/chromebook_link.h          |  53 ++++++++++
 18 files changed, 443 insertions(+), 7 deletions(-)
 create mode 100644 arch/x86/cpu/ivybridge/Kconfig
 create mode 100644 arch/x86/cpu/ivybridge/Makefile
 create mode 100644 arch/x86/cpu/ivybridge/car.S
 create mode 100644 arch/x86/cpu/ivybridge/cpu.c
 create mode 100644 arch/x86/cpu/ivybridge/sdram.c
 create mode 120000 arch/x86/dts/chromebook_link.dts
 create mode 100644 arch/x86/include/asm/arch-ivybridge/gpio.h
 create mode 100644 board/google/chromebook_link/Kconfig
 create mode 100644 board/google/chromebook_link/MAINTAINERS
 create mode 100644 board/google/chromebook_link/Makefile
 create mode 100644 board/google/chromebook_link/link.c
 create mode 100644 configs/chromebook_link_defconfig
 create mode 100644 include/configs/chromebook_link.h
arch/x86/Kconfig +8 -0
index 0dba8ac..07ff149 100644
@@ -12,9 +12,32 @@ choice
 
 config TARGET_COREBOOT
        bool "Support coreboot"
+       help
+         This target is used for running U-Boot on top of Coreboot. In
+         this case Coreboot does the early inititalisation, and U-Boot
+         takes over once the RAM, video and CPU are fully running.
+         U-Boot is loaded as a fallback payload from Coreboot, in
+         Coreboot terminology. This method was used for the Chromebook
+         Pixel when launched.
+
Quoted 8 lines

arch/x86/Kconfig choice · line 28

Quoted 6 lines
arch/x86/Kconfig +6 -0
+config TARGET_CHROMEBOOK_LINK
+       bool "Support Chromebook link"
+       help
+         This is the Chromebook Pixel released in 2013. It uses an Intel
+         i5 Ivybridge which is a die-shrink of Sandybridge, with 4GB of
+         SDRAM. It has a Panther Point peripheral controller hub, PCIe

Intel official name is 'platform controller hub'.

OK I'll update this.

Quoted 10 lines
Quoted 10 lines
arch/x86/Kconfig +5 -0
+         WiFi and Bluetooth. It also includes a 720p webcam, USB SD
+         reader, microphone and speakers, display port and 32GB SATA
+         solid state drive. There is a Chrome OS EC connected on LPC,
+         and it provides a 2560x1700 high resolution touch-enabled LCD
+         display.
 
 endchoice
 
Quoted 8 lines

arch/x86/Kconfig choice · line 39

Quoted 3 lines
arch/x86/Kconfig +2 -0
+source "arch/x86/cpu/ivybridge/Kconfig"
+
 source "board/chromebook-x86/coreboot/Kconfig"

Not related to this patch, but do you consider renaming 'board/chromebook-x86/' to something like 'board/generic-x86/' since this build of U-Boot is supposed to run as a payload from coreboot on every board that coreboot supports in theory.

Possibly, although it isn't really generic. Probably we should just use the name coreboot consistently. Actually I think I had this discussion with the original author but he wasn't having it...

[snip]

Regards,
Simon

#41 lore raw

PATCH 18/39 x86: Save the BIST value on reset

In reply to Simon Glass

The built in self test value is available in register eax on start-up. Save it so that it can be accessed later. Unfortunately we must wait until the global_data is available before we can do this, so there is a little bit of shuffling to keep it around.

---

 arch/x86/cpu/start.S               | 9 ++++++---
 arch/x86/cpu/start16.S             | 7 ++++++-
 arch/x86/include/asm/global_data.h | 1 +
 lib/asm-offsets.c                  | 3 +++
 4 files changed, 16 insertions(+), 4 deletions(-)
arch/x86/cpu/start.S +6 -3
index c41e1ae..7f41475 100644
@@ -49,6 +49,8 @@ _start:
 	 */
 	movw	$GD_FLG_COLD_BOOT, %bx
 1:
+	/* Save BIST */
+	movl	%eax, %ebp
 
 	/* Load the segement registes to match the gdt loaded in start16.S */
 	movl	$(X86_GDT_ENTRY_32BIT_DS * X86_GDT_ENTRY_SIZE), %eax
@@ -112,9 +114,10 @@ car_init_ret:
 	addl	$GD_MALLOC_BASE, %edx
 	movl	%esp, (%edx)
 #endif
-
-	/* Align temporary global descriptor table to 16-byte boundary */
-	andl	$0xfffffff0, %esp
+	/* Store BIST */
+	movl	%eax, %edx
+	addl	$GD_BIST, %edx
+	movl	%ebp, (%edx)
 
 	/* Set second parameter to setup_gdt */
 	movl	%ecx, %edx
arch/x86/cpu/start16.S +6 -1
index 445d5a1..9550502 100644
@@ -21,6 +21,9 @@
 .code16
 .globl start16
 start16:
+	/* Save BIST */
+	movl	%eax, %ecx
+
 	/* Set the Cold Boot / Hard Reset flag */
 	movl	$GD_FLG_COLD_BOOT, %ebx
 
@@ -45,9 +48,11 @@ o32 cs	lgdt	gdt_ptr
 	/* Flush the prefetch queue */
 	jmp	ff
 ff:
-	/* Finally jump to the 32bit initialization code */
+
+	/* Finally restore BIST and jump to the 32bit initialization code */
 	movw	$code32start, %ax
 	movw	%ax, %bp
+	movl	%ecx, %eax
 o32 cs	ljmp	*(%bp)
 
 	/* 48-bit far pointer */
arch/x86/include/asm/global_data.h +1 -0
index 3e8e2cd..9eae228 100644
@@ -17,6 +17,7 @@ struct arch_global_data {
 	uint32_t tsc_base_kclocks;	/* Initial tsc as a kclocks value */
 	uint32_t tsc_prev;		/* For show_boot_progress() */
 	void *new_fdt;			/* Relocated FDT */
+	uint32_t bist;			/* Built-in self test value */
 };
 
 #endif
lib/asm-offsets.c +3 -0
index 129bc3e..580f763 100644
@@ -31,6 +31,9 @@ int main(void)
 #ifdef CONFIG_SYS_MALLOC_F_LEN
 	DEFINE(GD_MALLOC_BASE, offsetof(struct global_data, malloc_base));
 #endif
+#ifdef CONFIG_X86
+	DEFINE(GD_BIST, offsetof(struct global_data, arch.bist));
+#endif
 
 #if defined(CONFIG_ARM)
 
Signature · 1 line
2.1.0.rc2.206.gedb03e5
#42 lore raw

PATCH 18/39 x86: Save the BIST value on reset

Quoted 85 lines · Simon Glass

The built in self test value is available in register eax on start-up. Save it so that it can be accessed later. Unfortunately we must wait until the global_data is available before we can do this, so there is a little bit of shuffling to keep it around.

---

 arch/x86/cpu/start.S               | 9 ++++++---
 arch/x86/cpu/start16.S             | 7 ++++++-
 arch/x86/include/asm/global_data.h | 1 +
 lib/asm-offsets.c                  | 3 +++
 4 files changed, 16 insertions(+), 4 deletions(-)
arch/x86/cpu/start.S +6 -3
index c41e1ae..7f41475 100644
@@ -49,6 +49,8 @@ _start:
         */
        movw    $GD_FLG_COLD_BOOT, %bx
 1:
+       /* Save BIST */
+       movl    %eax, %ebp
 
        /* Load the segement registes to match the gdt loaded in start16.S */
        movl    $(X86_GDT_ENTRY_32BIT_DS * X86_GDT_ENTRY_SIZE), %eax
@@ -112,9 +114,10 @@ car_init_ret:
        addl    $GD_MALLOC_BASE, %edx
        movl    %esp, (%edx)
 #endif
-
-       /* Align temporary global descriptor table to 16-byte boundary */
-       andl    $0xfffffff0, %esp
+       /* Store BIST */
+       movl    %eax, %edx
+       addl    $GD_BIST, %edx
+       movl    %ebp, (%edx)
 
        /* Set second parameter to setup_gdt */
        movl    %ecx, %edx
arch/x86/cpu/start16.S +6 -1
index 445d5a1..9550502 100644
@@ -21,6 +21,9 @@
 .code16
 .globl start16
 start16:
+       /* Save BIST */
+       movl    %eax, %ecx
+
        /* Set the Cold Boot / Hard Reset flag */
        movl    $GD_FLG_COLD_BOOT, %ebx
 
@@ -45,9 +48,11 @@ o32 cs       lgdt    gdt_ptr
        /* Flush the prefetch queue */
        jmp     ff
 ff:
-       /* Finally jump to the 32bit initialization code */
+
+       /* Finally restore BIST and jump to the 32bit initialization code */
        movw    $code32start, %ax
        movw    %ax, %bp
+       movl    %ecx, %eax
 o32 cs ljmp    *(%bp)
 
        /* 48-bit far pointer */
arch/x86/include/asm/global_data.h +1 -0
index 3e8e2cd..9eae228 100644
@@ -17,6 +17,7 @@ struct arch_global_data {
        uint32_t tsc_base_kclocks;      /* Initial tsc as a kclocks value */
        uint32_t tsc_prev;              /* For show_boot_progress() */
        void *new_fdt;                  /* Relocated FDT */
+       uint32_t bist;                  /* Built-in self test value */
 };
 
 #endif
lib/asm-offsets.c +0 -0
index 129bc3e..580f763 100644

lib/asm-offsets.c int main(void)

Quoted 10 lines
lib/asm-offsets.c +3 -1
@@ -31,6 +31,9 @@ int main(void)
 #ifdef CONFIG_SYS_MALLOC_F_LEN
        DEFINE(GD_MALLOC_BASE, offsetof(struct global_data, malloc_base));
 #endif
+#ifdef CONFIG_X86
+       DEFINE(GD_BIST, offsetof(struct global_data, arch.bist));
+#endif
 
 #if defined(CONFIG_ARM)
 
--
#43 lore raw

PATCH 18/39 x86: Save the BIST value on reset

Quoted 93 lines · Bin Meng
Quoted 92 lines · Simon Glass

The built in self test value is available in register eax on start-up. Save it so that it can be accessed later. Unfortunately we must wait until the global_data is available before we can do this, so there is a little bit of shuffling to keep it around.

---

 arch/x86/cpu/start.S               | 9 ++++++---
 arch/x86/cpu/start16.S             | 7 ++++++-
 arch/x86/include/asm/global_data.h | 1 +
 lib/asm-offsets.c                  | 3 +++
 4 files changed, 16 insertions(+), 4 deletions(-)
arch/x86/cpu/start.S +6 -3
index c41e1ae..7f41475 100644
@@ -49,6 +49,8 @@ _start:
         */
        movw    $GD_FLG_COLD_BOOT, %bx
 1:
+       /* Save BIST */
+       movl    %eax, %ebp
 
        /* Load the segement registes to match the gdt loaded in start16.S */
        movl    $(X86_GDT_ENTRY_32BIT_DS * X86_GDT_ENTRY_SIZE), %eax
@@ -112,9 +114,10 @@ car_init_ret:
        addl    $GD_MALLOC_BASE, %edx
        movl    %esp, (%edx)
 #endif
-
-       /* Align temporary global descriptor table to 16-byte boundary */
-       andl    $0xfffffff0, %esp
+       /* Store BIST */
+       movl    %eax, %edx
+       addl    $GD_BIST, %edx
+       movl    %ebp, (%edx)
 
        /* Set second parameter to setup_gdt */
        movl    %ecx, %edx
arch/x86/cpu/start16.S +6 -1
index 445d5a1..9550502 100644
@@ -21,6 +21,9 @@
 .code16
 .globl start16
 start16:
+       /* Save BIST */
+       movl    %eax, %ecx
+
        /* Set the Cold Boot / Hard Reset flag */
        movl    $GD_FLG_COLD_BOOT, %ebx
 
@@ -45,9 +48,11 @@ o32 cs       lgdt    gdt_ptr
        /* Flush the prefetch queue */
        jmp     ff
 ff:
-       /* Finally jump to the 32bit initialization code */
+
+       /* Finally restore BIST and jump to the 32bit initialization code */
        movw    $code32start, %ax
        movw    %ax, %bp
+       movl    %ecx, %eax
 o32 cs ljmp    *(%bp)
 
        /* 48-bit far pointer */
arch/x86/include/asm/global_data.h +1 -0
index 3e8e2cd..9eae228 100644
@@ -17,6 +17,7 @@ struct arch_global_data {
        uint32_t tsc_base_kclocks;      /* Initial tsc as a kclocks value */
        uint32_t tsc_prev;              /* For show_boot_progress() */
        void *new_fdt;                  /* Relocated FDT */
+       uint32_t bist;                  /* Built-in self test value */
 };
 
 #endif
lib/asm-offsets.c +3 -0
index 129bc3e..580f763 100644
@@ -31,6 +31,9 @@ int main(void)
 #ifdef CONFIG_SYS_MALLOC_F_LEN
        DEFINE(GD_MALLOC_BASE, offsetof(struct global_data, malloc_base));
 #endif
+#ifdef CONFIG_X86
+       DEFINE(GD_BIST, offsetof(struct global_data, arch.bist));
+#endif
 
Quoted 5 lines

lib/asm-offsets.c int main(void)

Quoted 3 lines
lib/asm-offsets.c +0 -1
 #if defined(CONFIG_ARM)
 
--

Applied to u-boot-x86.

#44 lore raw

PATCH 19/39 x86: Build a .rom file which can be flashed to an x86 machine

In reply to Simon Glass

On x86 machines U-Boot needs to be added to a large ROM image which is then flashed onto the target board. The ROM has a particular format so it makes sense for U-Boot to build this image automatically. Unfortunately it relies on binary blobs so we cannot require this for the default build as yet.

Create a u-boot.rom output file for this purpose.

---

 Makefile                          | 27 ++++++++++++++++++++++++++-
 arch/x86/Kconfig                  |  4 ++++
 include/configs/chromebook_link.h |  2 ++
 3 files changed, 32 insertions(+), 1 deletion(-)
Makefile +26 -1
index 9c8a580..86d0510 100644
@@ -743,6 +743,9 @@ ALL-$(CONFIG_SPL) += $(CONFIG_SPL_TARGET:"%"=%)
 endif
 ALL-$(CONFIG_REMAKE_ELF) += u-boot.elf
 
+# We can't do this yet due to the need for binary blobs
+# ALL-$(CONFIG_X86_RESET_VECTOR) += u-boot.rom
+
 # enable combined SPL/u-boot/dtb rules for tegra
 ifneq ($(CONFIG_TEGRA),)
 ifeq ($(CONFIG_SPL),y)
@@ -804,7 +807,8 @@ OBJCOPYFLAGS_u-boot.srec := -O srec
 u-boot.hex u-boot.srec: u-boot FORCE
 	$(call if_changed,objcopy)
 
-OBJCOPYFLAGS_u-boot.bin := -O binary
+OBJCOPYFLAGS_u-boot.bin := -O binary \
+		$(if $(CONFIG_X86_RESET_VECTOR),-R .start16 -R .resetvec)
 
 binary_size_check: u-boot.bin FORCE
 	@file_size=$(shell wc -c u-boot.bin | awk '{print $$1}') ; \
@@ -943,6 +947,27 @@ u-boot-nand.gph: u-boot.bin FORCE
 	$(call if_changed,mkimage)
 	@dd if=/dev/zero bs=8 count=1 2>/dev/null >> $@
 
+# x86 uses a large ROM. We fill it with 0xff, put the 16-bit stuff (including
+# reset vector) at the top, Intel ME at the bottom, and U-Boot in the middle.
+ifneq ($(CONFIG_X86_RESET_VECTOR),)
+rom: u-boot.rom FORCE
+
+u-boot.rom: u-boot-x86-16bit.bin u-boot-dtb.bin \
+		$(srctree)/board/$(BOARDDIR)/descriptor.bin
+	$(objtree)/tools/ifdtool -c -r $(CONFIG_ROM_SIZE) \
+		-D $(srctree)/board/$(BOARDDIR)/descriptor.bin u-boot.tmp
+	$(objtree)/tools/ifdtool -w \
+		$(CONFIG_SYS_TEXT_BASE):$(objtree)/u-boot-dtb.bin u-boot.tmp
+	$(objtree)/tools/ifdtool -w \
+		$(CONFIG_SYS_X86_START16):$(objtree)/u-boot-x86-16bit.bin \
+		u-boot.tmp
+	mv u-boot.tmp $@
+
+OBJCOPYFLAGS_u-boot-x86-16bit.bin := -O binary -j .start16 -j .resetvec
+u-boot-x86-16bit.bin: u-boot FORCE
+	$(call if_changed,objcopy)
+endif
+
 ifneq ($(CONFIG_SUNXI),)
 OBJCOPYFLAGS_u-boot-sunxi-with-spl.bin = -I binary -O binary \
 				   --pad-to=$(CONFIG_SPL_PAD_TO) --gap-fill=0xff
arch/x86/Kconfig +4 -0
index 07ff149..d9ce129 100644
@@ -34,6 +34,10 @@ config TARGET_CHROMEBOOK_LINK
 
 endchoice
 
+config ROM_SIZE
+	hex
+	default 0x800000
+
 source "arch/x86/cpu/ivybridge/Kconfig"
 
 source "board/chromebook-x86/coreboot/Kconfig"
include/configs/chromebook_link.h +2 -0
index 1d6f55b..5e8a747 100644
@@ -18,8 +18,10 @@
 #define CONFIG_SYS_CAR_ADDR			0xff7e0000
 #define CONFIG_SYS_CAR_SIZE			(128 * 1024)
 #define CONFIG_SYS_MONITOR_LEN			(1 << 20)
+#define CONFIG_SYS_X86_START16			0xfffff800
 #define CONFIG_BOARD_EARLY_INIT_R
 
+#define CONFIG_X86_RESET_VECTOR
 #define CONFIG_NR_DRAM_BANKS			8
 
 /*
Signature · 1 line
2.1.0.rc2.206.gedb03e5
#45 lore raw

PATCH 19/39 x86: Build a .rom file which can be flashed to an x86 machine

Hi Simon,

Quoted 41 lines · Simon Glass

On x86 machines U-Boot needs to be added to a large ROM image which is then flashed onto the target board. The ROM has a particular format so it makes sense for U-Boot to build this image automatically. Unfortunately it relies on binary blobs so we cannot require this for the default build as yet.

Create a u-boot.rom output file for this purpose.

---

 Makefile                          | 27 ++++++++++++++++++++++++++-
 arch/x86/Kconfig                  |  4 ++++
 include/configs/chromebook_link.h |  2 ++
 3 files changed, 32 insertions(+), 1 deletion(-)
Makefile +5 -1
index 9c8a580..86d0510 100644
@@ -743,6 +743,9 @@ ALL-$(CONFIG_SPL) += $(CONFIG_SPL_TARGET:"%"=%)
 endif
 ALL-$(CONFIG_REMAKE_ELF) += u-boot.elf
 
+# We can't do this yet due to the need for binary blobs
+# ALL-$(CONFIG_X86_RESET_VECTOR) += u-boot.rom
+
 # enable combined SPL/u-boot/dtb rules for tegra
 ifneq ($(CONFIG_TEGRA),)
 ifeq ($(CONFIG_SPL),y)
@@ -804,7 +807,8 @@ OBJCOPYFLAGS_u-boot.srec := -O srec
 u-boot.hex u-boot.srec: u-boot FORCE
        $(call if_changed,objcopy)
 
-OBJCOPYFLAGS_u-boot.bin := -O binary
+OBJCOPYFLAGS_u-boot.bin := -O binary \
+               $(if $(CONFIG_X86_RESET_VECTOR),-R .start16 -R .resetvec)
 
 binary_size_check: u-boot.bin FORCE
        @file_size=$(shell wc -c u-boot.bin | awk '{print $$1}') ; \

Makefile u-boot-nand.gph: u-boot.bin FORCE · line 955

Quoted 9 lines
Makefile +6 -0
@@ -943,6 +947,27 @@ u-boot-nand.gph: u-boot.bin FORCE
        $(call if_changed,mkimage)
        @dd if=/dev/zero bs=8 count=1 2>/dev/null >> $@
 
+# x86 uses a large ROM. We fill it with 0xff, put the 16-bit stuff (including
+# reset vector) at the top, Intel ME at the bottom, and U-Boot in the middle.
+ifneq ($(CONFIG_X86_RESET_VECTOR),)
+rom: u-boot.rom FORCE
+
+u-boot.rom: u-boot-x86-16bit.bin u-boot-dtb.bin \

The u-boot-dtb.bin means we have to use device tree for all x86 board port. Is this a must-have?

Makefile u-boot-nand.gph: u-boot.bin FORCE · line 956

Quoted 1 line
Makefile +1 -0
+               $(srctree)/board/$(BOARDDIR)/descriptor.bin

I don't see where the descriptor.bin is created?

Quoted 4 lines
Makefile +4 -0
+       $(objtree)/tools/ifdtool -c -r $(CONFIG_ROM_SIZE) \
+               -D $(srctree)/board/$(BOARDDIR)/descriptor.bin u-boot.tmp
+       $(objtree)/tools/ifdtool -w \
+               $(CONFIG_SYS_TEXT_BASE):$(objtree)/u-boot-dtb.bin u-boot.tmp

Makefile u-boot-nand.gph: u-boot.bin FORCE · line 970

Quoted 10 lines
Makefile +10 -0
+       $(objtree)/tools/ifdtool -w \
+               $(CONFIG_SYS_X86_START16):$(objtree)/u-boot-x86-16bit.bin \
+               u-boot.tmp
+       mv u-boot.tmp $@
+
+OBJCOPYFLAGS_u-boot-x86-16bit.bin := -O binary -j .start16 -j .resetvec
+u-boot-x86-16bit.bin: u-boot FORCE
+       $(call if_changed,objcopy)
+endif
+

[snip]

Regards,
Bin

#46 lore raw

PATCH 19/39 x86: Build a .rom file which can be flashed to an x86 machine

Hi Bin,

Quoted 47 lines · Bin Meng

Hi Simon,

Quoted 44 lines · Simon Glass

On x86 machines U-Boot needs to be added to a large ROM image which is then flashed onto the target board. The ROM has a particular format so it makes sense for U-Boot to build this image automatically. Unfortunately it relies on binary blobs so we cannot require this for the default build as yet.

Create a u-boot.rom output file for this purpose.

---

 Makefile                          | 27 ++++++++++++++++++++++++++-
 arch/x86/Kconfig                  |  4 ++++
 include/configs/chromebook_link.h |  2 ++
 3 files changed, 32 insertions(+), 1 deletion(-)
Makefile +5 -1
index 9c8a580..86d0510 100644
@@ -743,6 +743,9 @@ ALL-$(CONFIG_SPL) += $(CONFIG_SPL_TARGET:"%"=%)
 endif
 ALL-$(CONFIG_REMAKE_ELF) += u-boot.elf
 
+# We can't do this yet due to the need for binary blobs
+# ALL-$(CONFIG_X86_RESET_VECTOR) += u-boot.rom
+
 # enable combined SPL/u-boot/dtb rules for tegra
 ifneq ($(CONFIG_TEGRA),)
 ifeq ($(CONFIG_SPL),y)
@@ -804,7 +807,8 @@ OBJCOPYFLAGS_u-boot.srec := -O srec
 u-boot.hex u-boot.srec: u-boot FORCE
        $(call if_changed,objcopy)
 
-OBJCOPYFLAGS_u-boot.bin := -O binary
+OBJCOPYFLAGS_u-boot.bin := -O binary \
+               $(if $(CONFIG_X86_RESET_VECTOR),-R .start16 -R .resetvec)
 
 binary_size_check: u-boot.bin FORCE
        @file_size=$(shell wc -c u-boot.bin | awk '{print $$1}') ; \
@@ -943,6 +947,27 @@ u-boot-nand.gph: u-boot.bin FORCE
        $(call if_changed,mkimage)
        @dd if=/dev/zero bs=8 count=1 2>/dev/null >> $@
 
Quoted 9 lines

Makefile u-boot-nand.gph: u-boot.bin FORCE · line 955

Quoted 6 lines
Makefile +6 -0
+# x86 uses a large ROM. We fill it with 0xff, put the 16-bit stuff (including
+# reset vector) at the top, Intel ME at the bottom, and U-Boot in the middle.
+ifneq ($(CONFIG_X86_RESET_VECTOR),)
+rom: u-boot.rom FORCE
+
+u-boot.rom: u-boot-x86-16bit.bin u-boot-dtb.bin \

The u-boot-dtb.bin means we have to use device tree for all x86 board port. Is this a must-have?

Yes I'd like to use device tree, since it is a convenient way of getting configuration into U-Boot.

Quoted 4 lines

Makefile u-boot-nand.gph: u-boot.bin FORCE · line 956

Quoted 2 lines
Makefile +1 -0
+               $(srctree)/board/$(BOARDDIR)/descriptor.bin

I don't see where the descriptor.bin is created?

This needs to be downloaded and provided, as with mrc.bin, etc.

I think I will adjust it (later) so that it builds an empty u-boot.rom and prints a warning on stdout if the binaries are not available. That way the buildman build will still succeed, but the user will see the problem. It might also be useful to have U-Boot report missing binaries when it starts up.

Regards,
Simon

#47 lore raw

PATCH 19/39 x86: Build a .rom file which can be flashed to an x86 machine

Hi Simon,

Quoted 2 lines · Simon Glass

Hi Bin,

[snip]

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

+ $(srctree)/board/$(BOARDDIR)/descriptor.bin

I don't see where the descriptor.bin is created?

This needs to be downloaded and provided, as with mrc.bin, etc.

I thought the descriptor.bin is used to describe the u-boot.rom layout, but seems you are saying it is coming from Intel(?). Is the format defined by Intel so that all the BIOS for that platform (u-boot.rom in our case) has to obey?

Quoted 5 lines

I think I will adjust it (later) so that it builds an empty u-boot.rom and prints a warning on stdout if the binaries are not available. That way the buildman build will still succeed, but the user will see the problem. It might also be useful to have U-Boot report missing binaries when it starts up.

Sounds good.

Regards,
Bin

#48 lore raw

PATCH 19/39 x86: Build a .rom file which can be flashed to an x86 machine

Hi Bin,

Quoted 11 lines · Bin Meng

Hi Simon,

Quoted 2 lines · Simon Glass

Hi Bin,

[snip]

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

+ $(srctree)/board/$(BOARDDIR)/descriptor.bin

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

I don't see where the descriptor.bin is created?

This needs to be downloaded and provided, as with mrc.bin, etc.

I thought the descriptor.bin is used to describe the u-boot.rom layout, but seems you are saying it is coming from Intel(?). Is the format defined by Intel so that all the BIOS for that platform (u-boot.rom in our case) has to obey?

Yes, but only if there is a management engine (the CONFIG option you asked for).

Quoted 11 lines
Quoted 6 lines

I think I will adjust it (later) so that it builds an empty u-boot.rom and prints a warning on stdout if the binaries are not available. That way the buildman build will still succeed, but the user will see the problem. It might also be useful to have U-Boot report missing binaries when it starts up.

Sounds good.

Regards,
Bin

Regards,
Simon

#49 lore raw

PATCH 19/39 x86: Build a .rom file which can be flashed to an x86 machine

Hi Simon,

Quoted 16 lines · Simon Glass

Hi Bin,

Quoted 13 lines · Bin Meng

Hi Simon,

Quoted 2 lines · Simon Glass

Hi Bin,

[snip]

Quoted 5 lines
Quoted 4 lines
Quoted 2 lines

+ $(srctree)/board/$(BOARDDIR)/descriptor.bin

I don't see where the descriptor.bin is created?

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

This needs to be downloaded and provided, as with mrc.bin, etc.

I thought the descriptor.bin is used to describe the u-boot.rom layout, but seems you are saying it is coming from Intel(?). Is the format defined by Intel so that all the BIOS for that platform (u-boot.rom in our case) has to obey?

Yes, but only if there is a management engine (the CONFIG option you asked for).

So we need bundle the descriptor.bin and me.bin together with a CONFIG option, and has better documentation to describe this.

[snip]

Regards,
Bin

#50 lore raw

PATCH 19/39 x86: Build a .rom file which can be flashed to an x86 machine

Hi Bin,

Quoted 26 lines · Bin Meng

Hi Simon,

Quoted 23 lines · Simon Glass

Hi Bin,

Quoted 19 lines · Bin Meng

Hi Simon,

Quoted 2 lines · Simon Glass

Hi Bin,

[snip]

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

+ $(srctree)/board/$(BOARDDIR)/descriptor.bin

I don't see where the descriptor.bin is created?

This needs to be downloaded and provided, as with mrc.bin, etc.

I thought the descriptor.bin is used to describe the u-boot.rom layout, but seems you are saying it is coming from Intel(?). Is the format defined by Intel so that all the BIOS for that platform (u-boot.rom in our case) has to obey?

Quoted 4 lines
Quoted 1 line

Yes, but only if there is a management engine (the CONFIG option you asked for).

So we need bundle the descriptor.bin and me.bin together with a CONFIG option, and has better documentation to describe this.

Yes that sounds right.

Regards,
Simon

#51 lore raw

PATCH 20/39 x86: Emit post codes in startup code

In reply to Simon Glass

On x86 it is common to use 'post codes' which are 8-bit hex values emitted from the code and visible to the user. Traditionally two 7-segment displays were made available on the motherboard to show the last post code that was emitted. This allows diagnosis of a boot problem since it is possible to see where the code got to before it died.

On modern hardware these codes are not normally visible. On Chromebooks they are displayed by the Embedded Controller (EC), so it is useful to emit them. We must enable this feature for the EC to see the codes, so add an option for this.

---

 arch/x86/cpu/coreboot/coreboot.c     |  3 ++-
 arch/x86/cpu/start.S                 | 25 +++++++++++++++++++++++++
 arch/x86/include/asm/post.h          | 32 ++++++++++++++++++++++++++++++++
 board/google/chromebook_link/Kconfig |  4 ++++
 4 files changed, 63 insertions(+), 1 deletion(-)
 create mode 100644 arch/x86/include/asm/post.h
arch/x86/cpu/coreboot/coreboot.c +2 -1
index 257faa1..cc7398f 100644
@@ -15,6 +15,7 @@
 #include <asm/cache.h>
 #include <asm/cpu.h>
 #include <asm/io.h>
+#include <asm/post.h>
 #include <asm/arch-coreboot/tables.h>
 #include <asm/arch-coreboot/sysinfo.h>
 #include <asm/arch/timestamp.h>
@@ -68,7 +69,7 @@ void show_boot_progress(int val)
 		gd->arch.tsc_prev = now;
 	}
 #endif
-	outb(val, 0x80);
+	outb(val, POST_PORT);
 }
 
 int last_stage_init(void)
arch/x86/cpu/start.S +25 -0
index 7f41475..f62ffeb 100644
@@ -13,6 +13,7 @@
 #include <config.h>
 #include <version.h>
 #include <asm/global_data.h>
+#include <asm/post.h>
 #include <asm/processor.h>
 #include <asm/processor-flags.h>
 #include <generated/generic-asm-offsets.h>
@@ -60,6 +61,28 @@ _start:
 	movw	%ax, %es
 	movw	%ax, %ss
 
+	/* Enable post codes to EC */
+#ifdef CONFIG_EARLY_POST_CROS_EC
+	mov    $0x1b, %ecx
+	rdmsr
+	and    $0x100, %eax
+	test   %eax, %eax
+	je     2f
+
+	mov    $0x8000f8f0, %eax
+	mov    $0xcf8, %dx
+	out    %eax, (%dx)
+	mov    $0xfed1c001, %eax
+	mov    $0xcfc, %dx
+	out    %eax, (%dx)
+	mov    $0xfed1f410, %esp
+	mov    (%esp), %eax
+	and    $0xfffffffb, %eax
+	mov    %eax, (%esp)
+2:
+#endif
+	post_code(POST_START)
+
 	/* Clear the interrupt vectors */
 	lidt	blank_idt_ptr
 
@@ -91,6 +114,7 @@ car_init_ret:
 
 	/* Align global data to 16-byte boundary */
 	andl	$0xfffffff0, %esp
+	post_code(POST_START_STACK)
 
 	/* Zero the global data since it won't happen later */
 	xorl	%eax, %eax
@@ -126,6 +150,7 @@ car_init_ret:
 	call	setup_gdt
 
 	/* Set parameter to board_init_f() to boot flags */
+	post_code(POST_START_DONE)
 	xorl	%eax, %eax
 
 	/* Enter, U-boot! */
arch/x86/include/asm/post.h new file +32 -0
new file mode 100644
index 0000000..3371185
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2014 Google, Inc
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef _post_h
+#define _post_h
+
+/* port to use for post codes */
+#define POST_PORT		0x80
+
+/* post codes which represent various stages of init */
+#define POST_START		0x1e
+#define POST_CAR_START		0x1f
+
+#define POST_START_STACK	0x29
+#define POST_START_DONE		0x2a
+
+/* Output a post code using al - value must be 0 to 0xff */
+#ifdef __ASSEMBLY__
+#define post_code(value) \
+	movb	$value, %al; \
+	outb	%al, $POST_PORT
+#else
+static inline void post_code(int code)
+{
+	outb(code, POST_PORT);
+}
+#endif
+
+#endif
board/google/chromebook_link/Kconfig +4 -0
index 975d557..9c715ba 100644
@@ -12,4 +12,8 @@ config SYS_SOC
 config SYS_CONFIG_NAME
 	default "chromebook_link"
 
+config EARLY_POST_CROS_EC
+	bool "Enable early post to Chrome OS EC"
+	default y
+
 endif
Signature · 1 line
2.1.0.rc2.206.gedb03e5
#52 lore raw

PATCH 20/39 x86: Emit post codes in startup code

Hi Simon,

Quoted 68 lines · Simon Glass

On x86 it is common to use 'post codes' which are 8-bit hex values emitted from the code and visible to the user. Traditionally two 7-segment displays were made available on the motherboard to show the last post code that was emitted. This allows diagnosis of a boot problem since it is possible to see where the code got to before it died.

On modern hardware these codes are not normally visible. On Chromebooks they are displayed by the Embedded Controller (EC), so it is useful to emit them. We must enable this feature for the EC to see the codes, so add an option for this.

---

 arch/x86/cpu/coreboot/coreboot.c     |  3 ++-
 arch/x86/cpu/start.S                 | 25 +++++++++++++++++++++++++
 arch/x86/include/asm/post.h          | 32 ++++++++++++++++++++++++++++++++
 board/google/chromebook_link/Kconfig |  4 ++++
 4 files changed, 63 insertions(+), 1 deletion(-)
 create mode 100644 arch/x86/include/asm/post.h
arch/x86/cpu/coreboot/coreboot.c +2 -1
index 257faa1..cc7398f 100644
@@ -15,6 +15,7 @@
 #include <asm/cache.h>
 #include <asm/cpu.h>
 #include <asm/io.h>
+#include <asm/post.h>
 #include <asm/arch-coreboot/tables.h>
 #include <asm/arch-coreboot/sysinfo.h>
 #include <asm/arch/timestamp.h>
@@ -68,7 +69,7 @@ void show_boot_progress(int val)
                gd->arch.tsc_prev = now;
        }
 #endif
-       outb(val, 0x80);
+       outb(val, POST_PORT);
 }
 
 int last_stage_init(void)
arch/x86/cpu/start.S +11 -0
index 7f41475..f62ffeb 100644
@@ -13,6 +13,7 @@
 #include <config.h>
 #include <version.h>
 #include <asm/global_data.h>
+#include <asm/post.h>
 #include <asm/processor.h>
 #include <asm/processor-flags.h>
 #include <generated/generic-asm-offsets.h>
@@ -60,6 +61,28 @@ _start:
        movw    %ax, %es
        movw    %ax, %ss
 
+       /* Enable post codes to EC */
+#ifdef CONFIG_EARLY_POST_CROS_EC
+       mov    $0x1b, %ecx
+       rdmsr
+       and    $0x100, %eax
+       test   %eax, %eax
+       je     2f
+
+       mov    $0x8000f8f0, %eax
+       mov    $0xcf8, %dx

arch/x86/cpu/start.S _start: · line 83

Quoted 10 lines
arch/x86/cpu/start.S +10 -0
+       out    %eax, (%dx)
+       mov    $0xfed1c001, %eax
+       mov    $0xcfc, %dx
+       out    %eax, (%dx)
+       mov    $0xfed1f410, %esp
+       mov    (%esp), %eax
+       and    $0xfffffffb, %eax
+       mov    %eax, (%esp)
+2:
+#endif

IMHO the early_board_init() removal should be rolled back, and the enable post codes is better to put there.

Quoted 35 lines
arch/x86/cpu/start.S +4 -0
+       post_code(POST_START)
+
        /* Clear the interrupt vectors */
        lidt    blank_idt_ptr
 
@@ -91,6 +114,7 @@ car_init_ret:
 
        /* Align global data to 16-byte boundary */
        andl    $0xfffffff0, %esp
+       post_code(POST_START_STACK)
 
        /* Zero the global data since it won't happen later */
        xorl    %eax, %eax
@@ -126,6 +150,7 @@ car_init_ret:
        call    setup_gdt
 
        /* Set parameter to board_init_f() to boot flags */
+       post_code(POST_START_DONE)
        xorl    %eax, %eax
 
        /* Enter, U-boot! */
arch/x86/include/asm/post.h new file +8 -0
new file mode 100644
index 0000000..3371185
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2014 Google, Inc
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef _post_h
+#define _post_h

arch/x86/include/asm/post.h line 18

Quoted 10 lines
arch/x86/include/asm/post.h new file +10 -0
+
+/* port to use for post codes */
+#define POST_PORT              0x80
+
+/* post codes which represent various stages of init */
+#define POST_START             0x1e
+#define POST_CAR_START         0x1f
+
+#define POST_START_STACK       0x29
+#define POST_START_DONE                0x2a

Do we follow some specification about post codes values, or are them just some random numbers?

Quoted 18 lines
arch/x86/include/asm/post.h new file +13 -0
+/* Output a post code using al - value must be 0 to 0xff */
+#ifdef __ASSEMBLY__
+#define post_code(value) \
+       movb    $value, %al; \
+       outb    %al, $POST_PORT
+#else
+static inline void post_code(int code)
+{
+       outb(code, POST_PORT);
+}
+#endif
+
+#endif
board/google/chromebook_link/Kconfig +0 -0
index 975d557..9c715ba 100644

board/google/chromebook_link/Kconfig config SYS_SOC

Quoted 9 lines
board/google/chromebook_link/Kconfig +4 -1
@@ -12,4 +12,8 @@ config SYS_SOC
 config SYS_CONFIG_NAME
        default "chromebook_link"
 
+config EARLY_POST_CROS_EC
+       bool "Enable early post to Chrome OS EC"
+       default y
+
 endif
--

Regards,
Bin

#53 lore raw

PATCH 20/39 x86: Emit post codes in startup code

Hi Bin,

Quoted 76 lines · Bin Meng

Hi Simon,

Quoted 73 lines · Simon Glass

On x86 it is common to use 'post codes' which are 8-bit hex values emitted from the code and visible to the user. Traditionally two 7-segment displays were made available on the motherboard to show the last post code that was emitted. This allows diagnosis of a boot problem since it is possible to see where the code got to before it died.

On modern hardware these codes are not normally visible. On Chromebooks they are displayed by the Embedded Controller (EC), so it is useful to emit them. We must enable this feature for the EC to see the codes, so add an option for this.

---

 arch/x86/cpu/coreboot/coreboot.c     |  3 ++-
 arch/x86/cpu/start.S                 | 25 +++++++++++++++++++++++++
 arch/x86/include/asm/post.h          | 32 ++++++++++++++++++++++++++++++++
 board/google/chromebook_link/Kconfig |  4 ++++
 4 files changed, 63 insertions(+), 1 deletion(-)
 create mode 100644 arch/x86/include/asm/post.h
arch/x86/cpu/coreboot/coreboot.c +2 -1
index 257faa1..cc7398f 100644
@@ -15,6 +15,7 @@
 #include <asm/cache.h>
 #include <asm/cpu.h>
 #include <asm/io.h>
+#include <asm/post.h>
 #include <asm/arch-coreboot/tables.h>
 #include <asm/arch-coreboot/sysinfo.h>
 #include <asm/arch/timestamp.h>
@@ -68,7 +69,7 @@ void show_boot_progress(int val)
                gd->arch.tsc_prev = now;
        }
 #endif
-       outb(val, 0x80);
+       outb(val, POST_PORT);
 }
 
 int last_stage_init(void)
arch/x86/cpu/start.S +16 -0
index 7f41475..f62ffeb 100644
@@ -13,6 +13,7 @@
 #include <config.h>
 #include <version.h>
 #include <asm/global_data.h>
+#include <asm/post.h>
 #include <asm/processor.h>
 #include <asm/processor-flags.h>
 #include <generated/generic-asm-offsets.h>
@@ -60,6 +61,28 @@ _start:
        movw    %ax, %es
        movw    %ax, %ss
 
+       /* Enable post codes to EC */
+#ifdef CONFIG_EARLY_POST_CROS_EC
+       mov    $0x1b, %ecx
+       rdmsr
+       and    $0x100, %eax
+       test   %eax, %eax
+       je     2f
+
+       mov    $0x8000f8f0, %eax
+       mov    $0xcf8, %dx
+       out    %eax, (%dx)
+       mov    $0xfed1c001, %eax
+       mov    $0xcfc, %dx
+       out    %eax, (%dx)
+       mov    $0xfed1f410, %esp
Quoted 8 lines

arch/x86/cpu/start.S _start: · line 83

Quoted 5 lines
arch/x86/cpu/start.S +5 -0
+       mov    (%esp), %eax
+       and    $0xfffffffb, %eax
+       mov    %eax, (%esp)
+2:
+#endif

IMHO the early_board_init() removal should be rolled back, and the enable post codes is better to put there.

Yes I was thinking about that, I'll make that change.

Quoted 41 lines
Quoted 41 lines
arch/x86/cpu/start.S +4 -0
+       post_code(POST_START)
+
        /* Clear the interrupt vectors */
        lidt    blank_idt_ptr
 
@@ -91,6 +114,7 @@ car_init_ret:
 
        /* Align global data to 16-byte boundary */
        andl    $0xfffffff0, %esp
+       post_code(POST_START_STACK)
 
        /* Zero the global data since it won't happen later */
        xorl    %eax, %eax
@@ -126,6 +150,7 @@ car_init_ret:
        call    setup_gdt
 
        /* Set parameter to board_init_f() to boot flags */
+       post_code(POST_START_DONE)
        xorl    %eax, %eax
 
        /* Enter, U-boot! */
arch/x86/include/asm/post.h new file +13 -0
new file mode 100644
index 0000000..3371185
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2014 Google, Inc
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef _post_h
+#define _post_h
+
+/* port to use for post codes */
+#define POST_PORT              0x80
+
+/* post codes which represent various stages of init */
Quoted 8 lines

arch/x86/include/asm/post.h line 18

Quoted 5 lines
arch/x86/include/asm/post.h new file +5 -0
+#define POST_START             0x1e
+#define POST_CAR_START         0x1f
+
+#define POST_START_STACK       0x29
+#define POST_START_DONE                0x2a

Do we follow some specification about post codes values, or are them just some random numbers?

Just random - they're all in one place so we can change them pretty easily.

Quoted 22 lines
Quoted 22 lines
arch/x86/include/asm/post.h new file +13 -0
+/* Output a post code using al - value must be 0 to 0xff */
+#ifdef __ASSEMBLY__
+#define post_code(value) \
+       movb    $value, %al; \
+       outb    %al, $POST_PORT
+#else
+static inline void post_code(int code)
+{
+       outb(code, POST_PORT);
+}
+#endif
+
+#endif
board/google/chromebook_link/Kconfig +0 -0
index 975d557..9c715ba 100644
@@ -12,4 +12,8 @@ config SYS_SOC
 config SYS_CONFIG_NAME
        default "chromebook_link"
 
Quoted 9 lines

board/google/chromebook_link/Kconfig config SYS_SOC

Quoted 6 lines
board/google/chromebook_link/Kconfig +4 -1
+config EARLY_POST_CROS_EC
+       bool "Enable early post to Chrome OS EC"
+       default y
+
 endif
--

Regards,
Bin

Regards,
Simon

#54 lore raw

PATCH 21/39 x86: chromebook_link: Implement CAR support (cache as RAM)

In reply to Simon Glass

Add support for CAR so that we have memory to use prior to DRAM init. On link there is a total of 128KB of CAR available, although some is used for the memory reference code.

---

 arch/x86/Kconfig                     |  16 ++++
 arch/x86/cpu/ivybridge/car.S         | 156 ++++++++++++++++++++++++++++++++++-
 arch/x86/cpu/ivybridge/cpu.c         |   2 +
 arch/x86/include/asm/mtrr.h          | 121 +++++++++++++++++++++++++++
 arch/x86/include/asm/post.h          |  13 ++-
 board/google/chromebook_link/Kconfig |  12 +++
 6 files changed, 318 insertions(+), 2 deletions(-)
 create mode 100644 arch/x86/include/asm/mtrr.h
arch/x86/Kconfig +16 -0
index d9ce129..73fe8b2 100644
@@ -34,6 +34,22 @@ config TARGET_CHROMEBOOK_LINK
 
 endchoice
 
+config RAMBASE
+	hex
+	default 0x100000
+
+config RAMTOP
+	hex
+	default 0x200000
+
+config XIP_ROM_SIZE
+	hex
+	default 0x10000
+
+config CPU_ADDR_BITS
+	int
+	default 36
+
 config ROM_SIZE
 	hex
 	default 0x800000
arch/x86/cpu/ivybridge/car.S +155 -1

164 lines not on this page · raw message

arch/x86/cpu/ivybridge/cpu.c +2 -0
index 7e77be6..a9884ca 100644
@@ -11,6 +11,7 @@
  */
 
 #include <common.h>
+#include <asm/post.h>
 #include <asm/processor.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -19,6 +20,7 @@ int arch_cpu_init(void)
 {
 	int ret;
 
+	post_code(POST_CPU_INIT);
 	timer_set_base(rdtsc());
 
 	ret = x86_cpu_init_f();
arch/x86/include/asm/mtrr.h new file +121 -0

121 lines not on this page · raw message

arch/x86/include/asm/post.h +12 -1
index 3371185..b203dc9 100644
@@ -13,9 +13,18 @@
 /* post codes which represent various stages of init */
 #define POST_START		0x1e
 #define POST_CAR_START		0x1f
-
+#define POST_CAR_SIPI		0x20
+#define POST_CAR_MTRR		0x21
+#define POST_CAR_UNCACHEABLE	0x22
+#define POST_CAR_BASE_ADDRESS	0x23
+#define POST_CAR_MASK		0x24
+#define POST_CAR_FILL		0x25
+#define POST_CAR_ROM_CACHE	0x26
+#define POST_CAR_MRC_CACHE	0x27
+#define POST_CAR_CPU_CACHE	0x28
 #define POST_START_STACK	0x29
 #define POST_START_DONE		0x2a
+#define POST_CPU_INIT		0x2b
 
 /* Output a post code using al - value must be 0 to 0xff */
 #ifdef __ASSEMBLY__
@@ -23,6 +32,8 @@
 	movb	$value, %al; \
 	outb	%al, $POST_PORT
 #else
+#include <asm/io.h>
+
 static inline void post_code(int code)
 {
 	outb(code, POST_PORT);
board/google/chromebook_link/Kconfig +12 -0
index 9c715ba..3a4f557 100644
@@ -12,6 +12,18 @@ config SYS_SOC
 config SYS_CONFIG_NAME
 	default "chromebook_link"
 
+config BOARD_SPECIFIC_OPTIONS # dummy
+	def_bool y
+	select CPU_INTEL_SOCKET_RPGA989
+	select NORTHBRIDGE_INTEL_IVYBRIDGE
+	select SOUTHBRIDGE_INTEL_C216
+	select HAVE_ACPI_RESUME
+	select MARK_GRAPHICS_MEM_WRCOMB
+
+config MMCONF_BASE_ADDRESS
+	hex
+	default 0xf0000000
+
 config EARLY_POST_CROS_EC
 	bool "Enable early post to Chrome OS EC"
 	default y
Signature · 1 line
2.1.0.rc2.206.gedb03e5
#55 lore raw

PATCH 21/39 x86: chromebook_link: Implement CAR support (cache as RAM)

Hi Simon,

Quoted 48 lines · Simon Glass

Add support for CAR so that we have memory to use prior to DRAM init. On link there is a total of 128KB of CAR available, although some is used for the memory reference code.

---

 arch/x86/Kconfig                     |  16 ++++
 arch/x86/cpu/ivybridge/car.S         | 156 ++++++++++++++++++++++++++++++++++-
 arch/x86/cpu/ivybridge/cpu.c         |   2 +
 arch/x86/include/asm/mtrr.h          | 121 +++++++++++++++++++++++++++
 arch/x86/include/asm/post.h          |  13 ++-
 board/google/chromebook_link/Kconfig |  12 +++
 6 files changed, 318 insertions(+), 2 deletions(-)
 create mode 100644 arch/x86/include/asm/mtrr.h
arch/x86/Kconfig +16 -0
index d9ce129..73fe8b2 100644
@@ -34,6 +34,22 @@ config TARGET_CHROMEBOOK_LINK
 
 endchoice
 
+config RAMBASE
+       hex
+       default 0x100000
+
+config RAMTOP
+       hex
+       default 0x200000
+
+config XIP_ROM_SIZE
+       hex
+       default 0x10000
+
+config CPU_ADDR_BITS
+       int
+       default 36
+
 config ROM_SIZE
        hex
        default 0x800000
arch/x86/cpu/ivybridge/car.S +0 -0
index 0480813..391f6df 100644

arch/x86/cpu/ivybridge/car.S line 20

Quoted 9 lines
arch/x86/cpu/ivybridge/car.S +6 -0
@@ -12,9 +12,163 @@
  */
 
 #include <common.h>
+#include <asm/mtrr.h>
+#include <asm/post.h>
+#include <asm/processor-flags.h>
+
+#define MTRRphysBase_MSR(reg) (0x200 + 2 * (reg))
+#define MTRRphysMask_MSR(reg) (0x200 + 2 * (reg) + 1)

Should these macros be all capital?

arch/x86/cpu/ivybridge/car.S line 32

Quoted 11 lines
arch/x86/cpu/ivybridge/car.S +11 -0
+#define CACHE_AS_RAM_SIZE      CONFIG_DCACHE_RAM_SIZE
+#define CACHE_AS_RAM_BASE      CONFIG_DCACHE_RAM_BASE
+
+/* Cache 4GB - MRC_SIZE_KB for MRC */
+#define CACHE_MRC_BYTES        ((CONFIG_CACHE_MRC_SIZE_KB << 10) - 1)
+#define CACHE_MRC_BASE         (0xFFFFFFFF - CACHE_MRC_BYTES)
+#define CACHE_MRC_MASK         (~CACHE_MRC_BYTES)
+
+#define CPU_PHYSMASK_HI        (1 << (CONFIG_CPU_ADDR_BITS - 32) - 1)
+
+#define NoEvictMod_MSR 0x2e0

Ditto.

arch/x86/cpu/ivybridge/car.S line 34

Quoted 1 line
arch/x86/cpu/ivybridge/car.S +0 -0
        /* Note: ebp must not be touched in this code */

I think mentioning ebp holds the value of BIST would help more?

Quoted 5 lines
arch/x86/cpu/ivybridge/car.S +2 -1
 .globl car_init
 car_init:
-       /* TODO: Add cache-as-RAM init here */
+       post_code(POST_CAR_START)
+

arch/x86/cpu/ivybridge/car.S line 48

Quoted 10 lines
arch/x86/cpu/ivybridge/car.S +10 -0
+       /* Send INIT IPI to all excluding ourself */
+       movl    $0x000C4500, %eax
+       movl    $0xFEE00300, %esi
+       movl    %eax, (%esi)
+
+       /* All CPUs need to be in Wait for SIPI state */
+wait_for_sipi:
+       movl    (%esi), %eax
+       bt      $12, %eax
+       jc      wait_for_sipi

Is this a must to send INIT IPI before CAR initialization?

Quoted 189 lines
arch/x86/cpu/ivybridge/car.S +124 -0
+       post_code(POST_CAR_SIPI)
+       /* Zero out all fixed range and variable range MTRRs */
+       movl    $mtrr_table, %esi
+       movl    $((mtrr_table_end - mtrr_table) / 2), %edi
+       xorl    %eax, %eax
+       xorl    %edx, %edx
+clear_mtrrs:
+       movw    (%esi), %bx
+       movzx   %bx, %ecx
+       wrmsr
+       add     $2, %esi
+       dec     %edi
+       jnz     clear_mtrrs
+
+       post_code(POST_CAR_MTRR)
+       /* Configure the default memory type to uncacheable */
+       movl    $MTRRdefType_MSR, %ecx
+       rdmsr
+       andl    $(~0x00000cff), %eax
+       wrmsr
+
+       post_code(POST_CAR_UNCACHEABLE)
+       /* Set Cache-as-RAM base address */
+       movl    $(MTRRphysBase_MSR(0)), %ecx
+       movl    $(CACHE_AS_RAM_BASE | MTRR_TYPE_WRBACK), %eax
+       xorl    %edx, %edx
+       wrmsr
+
+       post_code(POST_CAR_BASE_ADDRESS)
+       /* Set Cache-as-RAM mask */
+       movl    $(MTRRphysMask_MSR(0)), %ecx
+       movl    $(~(CACHE_AS_RAM_SIZE - 1) | MTRRphysMaskValid), %eax
+       movl    $CPU_PHYSMASK_HI, %edx
+       wrmsr
+
+       post_code(POST_CAR_MASK)
+
+       /* Enable MTRR */
+       movl    $MTRRdefType_MSR, %ecx
+       rdmsr
+       orl     $MTRRdefTypeEn, %eax
+       wrmsr
+
+       /* Enable cache (CR0.CD = 0, CR0.NW = 0) */
+        movl   %cr0, %eax
+       andl    $(~(X86_CR0_CD | X86_CR0_NW)), %eax
+       invd
+       movl    %eax, %cr0
+
+       /* enable the 'no eviction' mode */
+       movl    $NoEvictMod_MSR, %ecx
+       rdmsr
+       orl     $1, %eax
+       andl    $~2, %eax
+       wrmsr
+
+       /* Clear the cache memory region. This will also fill up the cache */
+       movl    $CACHE_AS_RAM_BASE, %esi
+       movl    %esi, %edi
+       movl    $(CACHE_AS_RAM_SIZE / 4), %ecx
+       xorl    %eax, %eax
+       rep     stosl
+
+       /* enable the 'no eviction run' state */
+       movl    $NoEvictMod_MSR, %ecx
+       rdmsr
+       orl     $3, %eax
+       wrmsr
+
+       post_code(POST_CAR_FILL)
+       /* Enable Cache-as-RAM mode by disabling cache */
+       movl    %cr0, %eax
+       orl     $X86_CR0_CD, %eax
+       movl    %eax, %cr0
+
+       /* Enable cache for our code in Flash because we do XIP here */
+       movl    $MTRRphysBase_MSR(1), %ecx
+       xorl    %edx, %edx
+       movl    $car_init_ret, %eax
+       andl    $(~(CONFIG_XIP_ROM_SIZE - 1)), %eax
+       orl     $MTRR_TYPE_WRPROT, %eax
+       wrmsr
+
+       movl    $MTRRphysMask_MSR(1), %ecx
+       movl    $CPU_PHYSMASK_HI, %edx
+       movl    $(~(CONFIG_XIP_ROM_SIZE - 1) | MTRRphysMaskValid), %eax
+       wrmsr
+
+       post_code(POST_CAR_ROM_CACHE)
+#ifdef CONFIG_CACHE_MRC_BIN
+       /* Enable caching for ram init code to run faster */
+       movl    $MTRRphysBase_MSR(2), %ecx
+       movl    $(CACHE_MRC_BASE | MTRR_TYPE_WRPROT), %eax
+       xorl    %edx, %edx
+       wrmsr
+       movl    $MTRRphysMask_MSR(2), %ecx
+       movl    $(CACHE_MRC_MASK | MTRRphysMaskValid), %eax
+       movl    $CPU_PHYSMASK_HI, %edx
+       wrmsr
+#endif
+
+       post_code(POST_CAR_MRC_CACHE)
+       /* Enable cache */
+       movl    %cr0, %eax
+       andl    $(~(X86_CR0_CD | X86_CR0_NW)), %eax
+       movl    %eax, %cr0
+
+       post_code(POST_CAR_CPU_CACHE)
+
+       /* return */
        jmp     car_init_ret
+
+mtrr_table:
+       /* Fixed MTRRs */
+       .word 0x250, 0x258, 0x259
+       .word 0x268, 0x269, 0x26A
+       .word 0x26B, 0x26C, 0x26D
+       .word 0x26E, 0x26F
+       /* Variable MTRRs */
+       .word 0x200, 0x201, 0x202, 0x203
+       .word 0x204, 0x205, 0x206, 0x207
+       .word 0x208, 0x209, 0x20A, 0x20B
+       .word 0x20C, 0x20D, 0x20E, 0x20F
+       .word 0x210, 0x211, 0x212, 0x213
+mtrr_table_end:
arch/x86/cpu/ivybridge/cpu.c +2 -0
index 7e77be6..a9884ca 100644
@@ -11,6 +11,7 @@
  */
 
 #include <common.h>
+#include <asm/post.h>
 #include <asm/processor.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -19,6 +20,7 @@ int arch_cpu_init(void)
 {
        int ret;
 
+       post_code(POST_CPU_INIT);
        timer_set_base(rdtsc());
 
        ret = x86_cpu_init_f();
arch/x86/include/asm/mtrr.h new file +38 -0
new file mode 100644
index 0000000..5f05a48
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2014 Google, Inc
+ *
+ * From Coreboot file of the same name
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef _ASM_MTRR_H
+#define _ASM_MTRR_H
+
+/*  These are the region types  */
+#define MTRR_TYPE_UNCACHEABLE 0
+#define MTRR_TYPE_WRCOMB     1
+/*#define MTRR_TYPE_         2*/
+/*#define MTRR_TYPE_         3*/
+#define MTRR_TYPE_WRTHROUGH  4
+#define MTRR_TYPE_WRPROT     5
+#define MTRR_TYPE_WRBACK     6
+#define MTRR_NUM_TYPES       7
+
+#define MTRRcap_MSR     0x0fe
+#define MTRRdefType_MSR 0x2ff
+
+#define MTRRdefTypeEn          (1 << 11)
+#define MTRRdefTypeFixEn       (1 << 10)
+
+#define SMRRphysBase_MSR 0x1f2
+#define SMRRphysMask_MSR 0x1f3
+
+#define MTRRphysBase_MSR(reg) (0x200 + 2 * (reg))
+#define MTRRphysMask_MSR(reg) (0x200 + 2 * (reg) + 1)
+
+#define MTRRphysMaskValid      (1 << 11)
+
+#define NUM_FIXED_RANGES 88
+#define RANGES_PER_FIXED_MTRR 8
+#define MTRRfix64K_00000_MSR 0x250

arch/x86/include/asm/mtrr.h line 48

Quoted 10 lines
arch/x86/include/asm/mtrr.h new file +10 -0
+#define MTRRfix16K_80000_MSR 0x258
+#define MTRRfix16K_A0000_MSR 0x259
+#define MTRRfix4K_C0000_MSR 0x268
+#define MTRRfix4K_C8000_MSR 0x269
+#define MTRRfix4K_D0000_MSR 0x26a
+#define MTRRfix4K_D8000_MSR 0x26b
+#define MTRRfix4K_E0000_MSR 0x26c
+#define MTRRfix4K_E8000_MSR 0x26d
+#define MTRRfix4K_F0000_MSR 0x26e
+#define MTRRfix4K_F8000_MSR 0x26f

Ditto.

Quoted 119 lines
arch/x86/include/asm/mtrr.h new file +72 -0
+#if !defined(__ASSEMBLER__)
+
+/*
+ * The MTRR code has some side effects that the callers should be aware for.
+ * 1. The call sequence matters. x86_setup_mtrrs() calls
+ *    x86_setup_fixed_mtrrs_no_enable() then enable_fixed_mtrrs() (equivalent
+ *    of x86_setup_fixed_mtrrs()) then x86_setup_var_mtrrs(). If the callers
+ *    want to call the components of x86_setup_mtrrs() because of other
+ *    rquirements the ordering should still preserved.
+ * 2. enable_fixed_mtrr() will enable both variable and fixed MTRRs because
+ *    of the nature of the global MTRR enable flag. Therefore, all direct
+ *    or indirect callers of enable_fixed_mtrr() should ensure that the
+ *    variable MTRR MSRs do not contain bad ranges.
+ * 3. If CONFIG_CACHE_ROM is selected an MTRR is allocated for enabling
+ *    the caching of the ROM. However, it is set to uncacheable (UC). It
+ *    is the responsiblity of the caller to enable it by calling
+ *    x86_mtrr_enable_rom_caching().
+ */
+void x86_setup_mtrrs(void);
+/*
+ * x86_setup_var_mtrrs() parameters:
+ * address_bits - number of physical address bits supported by cpu
+ * above4gb - 2 means dynamically detect number of variable MTRRs available.
+ *            non-zero means handle memory ranges above 4GiB.
+ *            0 means ignore memory ranges above 4GiB
+ */
+void x86_setup_var_mtrrs(unsigned int address_bits, unsigned int above4gb);
+void enable_fixed_mtrr(void);
+void x86_setup_fixed_mtrrs(void);
+/* Set up fixed MTRRs but do not enable them. */
+void x86_setup_fixed_mtrrs_no_enable(void);
+int x86_mtrr_check(void);
+/* ROM caching can be used after variable MTRRs are set up. Beware that
+ * enabling CONFIG_CACHE_ROM will eat through quite a few MTRRs based on
+ * one's IO hole size and WRCOMB resources. Be sure to check the console
+ * log when enabling CONFIG_CACHE_ROM or adding WRCOMB resources. Beware that
+ * on CPUs with core-scoped MTRR registers such as hyperthreaded CPUs the
+ * rom caching will be disabled if all threads run the MTRR code. Therefore,
+ * one needs to call x86_mtrr_enable_rom_caching() after all threads of the
+ * same core have run the MTRR code. */
+#if CONFIG_CACHE_ROM
+void x86_mtrr_enable_rom_caching(void);
+void x86_mtrr_disable_rom_caching(void);
+/* Return the variable range MTRR index of the ROM cache. */
+long x86_mtrr_rom_cache_var_index(void);
+#else
+static inline void x86_mtrr_enable_rom_caching(void) {}
+static inline void x86_mtrr_disable_rom_caching(void) {}
+static inline long x86_mtrr_rom_cache_var_index(void) { return -1; }
+#endif /* CONFIG_CACHE_ROM */
+
+#endif
+
+#if !defined(CONFIG_RAMTOP)
+# error "CONFIG_RAMTOP not defined"
+#endif
+
+#if ((CONFIG_XIP_ROM_SIZE & (CONFIG_XIP_ROM_SIZE - 1)) != 0)
+# error "CONFIG_XIP_ROM_SIZE is not a power of 2"
+#endif
+
+#if ((CONFIG_CACHE_ROM_SIZE & (CONFIG_CACHE_ROM_SIZE - 1)) != 0)
+# error "CONFIG_CACHE_ROM_SIZE is not a power of 2"
+#endif
+
+#define CACHE_ROM_BASE (((1 << 20) - (CONFIG_CACHE_ROM_SIZE >> 12)) << 12)
+
+#if (CONFIG_RAMTOP & (CONFIG_RAMTOP - 1)) != 0
+# error "CONFIG_RAMTOP must be a power of 2"
+#endif
+
+#endif
arch/x86/include/asm/post.h +12 -1
index 3371185..b203dc9 100644
@@ -13,9 +13,18 @@
 /* post codes which represent various stages of init */
 #define POST_START             0x1e
 #define POST_CAR_START         0x1f
-
+#define POST_CAR_SIPI          0x20
+#define POST_CAR_MTRR          0x21
+#define POST_CAR_UNCACHEABLE   0x22
+#define POST_CAR_BASE_ADDRESS  0x23
+#define POST_CAR_MASK          0x24
+#define POST_CAR_FILL          0x25
+#define POST_CAR_ROM_CACHE     0x26
+#define POST_CAR_MRC_CACHE     0x27
+#define POST_CAR_CPU_CACHE     0x28
 #define POST_START_STACK       0x29
 #define POST_START_DONE                0x2a
+#define POST_CPU_INIT          0x2b
 
 /* Output a post code using al - value must be 0 to 0xff */
 #ifdef __ASSEMBLY__
@@ -23,6 +32,8 @@
        movb    $value, %al; \
        outb    %al, $POST_PORT
 #else
+#include <asm/io.h>
+
 static inline void post_code(int code)
 {
        outb(code, POST_PORT);
board/google/chromebook_link/Kconfig +6 -0
index 9c715ba..3a4f557 100644
@@ -12,6 +12,18 @@ config SYS_SOC
 config SYS_CONFIG_NAME
        default "chromebook_link"
 
+config BOARD_SPECIFIC_OPTIONS # dummy
+       def_bool y
+       select CPU_INTEL_SOCKET_RPGA989
+       select NORTHBRIDGE_INTEL_IVYBRIDGE
+       select SOUTHBRIDGE_INTEL_C216
+       select HAVE_ACPI_RESUME

board/google/chromebook_link/Kconfig config SYS_SOC

Quoted 10 lines
board/google/chromebook_link/Kconfig +6 -1
+       select MARK_GRAPHICS_MEM_WRCOMB
+
+config MMCONF_BASE_ADDRESS
+       hex
+       default 0xf0000000
+
 config EARLY_POST_CROS_EC
        bool "Enable early post to Chrome OS EC"
        default y
--

Regards,
Bin

#56 lore raw

PATCH 21/39 x86: chromebook_link: Implement CAR support (cache as RAM)

Hi Bin,

Quoted 53 lines · Bin Meng

Hi Simon,

Quoted 50 lines · Simon Glass

Add support for CAR so that we have memory to use prior to DRAM init. On link there is a total of 128KB of CAR available, although some is used for the memory reference code.

---

 arch/x86/Kconfig                     |  16 ++++
 arch/x86/cpu/ivybridge/car.S         | 156 ++++++++++++++++++++++++++++++++++-
 arch/x86/cpu/ivybridge/cpu.c         |   2 +
 arch/x86/include/asm/mtrr.h          | 121 +++++++++++++++++++++++++++
 arch/x86/include/asm/post.h          |  13 ++-
 board/google/chromebook_link/Kconfig |  12 +++
 6 files changed, 318 insertions(+), 2 deletions(-)
 create mode 100644 arch/x86/include/asm/mtrr.h
arch/x86/Kconfig +16 -0
index d9ce129..73fe8b2 100644
@@ -34,6 +34,22 @@ config TARGET_CHROMEBOOK_LINK
 
 endchoice
 
+config RAMBASE
+       hex
+       default 0x100000
+
+config RAMTOP
+       hex
+       default 0x200000
+
+config XIP_ROM_SIZE
+       hex
+       default 0x10000
+
+config CPU_ADDR_BITS
+       int
+       default 36
+
 config ROM_SIZE
        hex
        default 0x800000
arch/x86/cpu/ivybridge/car.S +0 -0
index 0480813..391f6df 100644
@@ -12,9 +12,163 @@
  */
 
Quoted 9 lines

arch/x86/cpu/ivybridge/car.S line 20

Quoted 7 lines
arch/x86/cpu/ivybridge/car.S +6 -0
 #include <common.h>
+#include <asm/mtrr.h>
+#include <asm/post.h>
+#include <asm/processor-flags.h>
+
+#define MTRRphysBase_MSR(reg) (0x200 + 2 * (reg))
+#define MTRRphysMask_MSR(reg) (0x200 + 2 * (reg) + 1)

Should these macros be all capital?

Yes I'll fix that. I had in mind keeping it similar to where it came from, but there are lots of changes needed so it's not worth it.

Quoted 15 lines

arch/x86/cpu/ivybridge/car.S line 32

Quoted 12 lines
arch/x86/cpu/ivybridge/car.S +11 -0
+#define CACHE_AS_RAM_SIZE      CONFIG_DCACHE_RAM_SIZE
+#define CACHE_AS_RAM_BASE      CONFIG_DCACHE_RAM_BASE
+
+/* Cache 4GB - MRC_SIZE_KB for MRC */
+#define CACHE_MRC_BYTES        ((CONFIG_CACHE_MRC_SIZE_KB << 10) - 1)
+#define CACHE_MRC_BASE         (0xFFFFFFFF - CACHE_MRC_BYTES)
+#define CACHE_MRC_MASK         (~CACHE_MRC_BYTES)
+
+#define CPU_PHYSMASK_HI        (1 << (CONFIG_CPU_ADDR_BITS - 32) - 1)
+
+#define NoEvictMod_MSR 0x2e0

Ditto.

Quoted 3 lines

arch/x86/cpu/ivybridge/car.S line 34

Quoted 1 line
arch/x86/cpu/ivybridge/car.S +0 -0
        /* Note: ebp must not be touched in this code */

I think mentioning ebp holds the value of BIST would help more?

OK

Quoted 10 lines
Quoted 10 lines
arch/x86/cpu/ivybridge/car.S +6 -1
 .globl car_init
 car_init:
-       /* TODO: Add cache-as-RAM init here */
+       post_code(POST_CAR_START)
+
+       /* Send INIT IPI to all excluding ourself */
+       movl    $0x000C4500, %eax
+       movl    $0xFEE00300, %esi
+       movl    %eax, (%esi)
Quoted 8 lines

arch/x86/cpu/ivybridge/car.S line 48

Quoted 6 lines
arch/x86/cpu/ivybridge/car.S +6 -0
+
+       /* All CPUs need to be in Wait for SIPI state */
+wait_for_sipi:
+       movl    (%esi), %eax
+       bt      $12, %eax
+       jc      wait_for_sipi

Is this a must to send INIT IPI before CAR initialization?

I'll test it.

[snip]

Regards,
Simon

#57 lore raw

PATCH 22/39 x86: Move Coreboot PCI into common cpu area

In reply to Simon Glass

This code is not really Coreboot-specific, so move it into the common area and rename it.

---

 arch/x86/cpu/Makefile             |  1 +
 arch/x86/cpu/coreboot/Makefile    |  1 -
 arch/x86/cpu/{coreboot => }/pci.c | 24 +++++++++++++-----------
 3 files changed, 14 insertions(+), 12 deletions(-)
 rename arch/x86/cpu/{coreboot => }/pci.c (63%)
arch/x86/cpu/Makefile +1 -0
index 9d38ef7..97f36d5 100644
@@ -11,3 +11,4 @@
 extra-y	= start.o
 obj-$(CONFIG_X86_RESET_VECTOR) += resetvec.o start16.o
 obj-y	+= interrupts.o cpu.o call64.o
+obj-$(CONFIG_PCI) += pci.o
arch/x86/cpu/coreboot/Makefile +0 -1
index cd0bf4e..65cf2cb 100644
@@ -19,4 +19,3 @@ obj-$(CONFIG_SYS_COREBOOT) += tables.o
 obj-$(CONFIG_SYS_COREBOOT) += ipchecksum.o
 obj-$(CONFIG_SYS_COREBOOT) += sdram.o
 obj-$(CONFIG_SYS_COREBOOT) += timestamp.o
-obj-$(CONFIG_PCI) += pci.o
arch/x86/cpu/pci.c renamed from arch/x86/cpu/coreboot/pci.c +13 -11
similarity index 63%
rename from arch/x86/cpu/coreboot/pci.c
rename to arch/x86/cpu/pci.c
index 33f16a3..f35c8b3 100644
@@ -13,7 +13,7 @@
 #include <pci.h>
 #include <asm/pci.h>
 
-static struct pci_controller coreboot_hose;
+static struct pci_controller x86_hose;
 
 static void config_pci_bridge(struct pci_controller *hose, pci_dev_t dev,
 			      struct pci_config_table *table)
@@ -24,7 +24,7 @@ static void config_pci_bridge(struct pci_controller *hose, pci_dev_t dev,
 	pci_hose_scan_bus(hose, secondary);
 }
 
-static struct pci_config_table pci_coreboot_config_table[] = {
+static struct pci_config_table pci_x86_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 },
@@ -33,17 +33,19 @@ static struct pci_config_table pci_coreboot_config_table[] = {
 
 void pci_init_board(void)
 {
-	coreboot_hose.config_table = pci_coreboot_config_table;
-	coreboot_hose.first_busno = 0;
-	coreboot_hose.last_busno = 0;
+	struct pci_controller *hose = &x86_hose;
 
-	pci_set_region(coreboot_hose.regions + 0, 0x0, 0x0, 0xffffffff,
-		PCI_REGION_MEM);
-	coreboot_hose.region_count = 1;
+	hose->config_table = pci_x86_config_table;
+	hose->first_busno = 0;
+	hose->last_busno = 0;
 
-	pci_setup_type1(&coreboot_hose);
+	pci_set_region(hose->regions + 0, 0x0, 0x0, 0xffffffff,
+		       PCI_REGION_MEM);
+	hose->region_count = 1;
 
-	pci_register_hose(&coreboot_hose);
+	pci_setup_type1(hose);
 
-	pci_hose_scan(&coreboot_hose);
+	pci_register_hose(hose);
+
+	pci_hose_scan(hose);
 }
Signature · 1 line
2.1.0.rc2.206.gedb03e5
#58 lore raw

PATCH 22/39 x86: Move Coreboot PCI into common cpu area

Hi Simon,

Quoted 2 lines · Simon Glass

This code is not really Coreboot-specific, so move it into the common area and rename it.

OK, but current coreboot pci codes are broken, thus need to be fixed before making it common.

arch/x86/cpu/pci.c static struct pci_config_table pci_coreboot_config_table[] = {

Quoted 53 lines

---

 arch/x86/cpu/Makefile             |  1 +
 arch/x86/cpu/coreboot/Makefile    |  1 -
 arch/x86/cpu/{coreboot => }/pci.c | 24 +++++++++++++-----------
 3 files changed, 14 insertions(+), 12 deletions(-)
 rename arch/x86/cpu/{coreboot => }/pci.c (63%)
arch/x86/cpu/Makefile +1 -0
index 9d38ef7..97f36d5 100644
@@ -11,3 +11,4 @@
 extra-y        = start.o
 obj-$(CONFIG_X86_RESET_VECTOR) += resetvec.o start16.o
 obj-y  += interrupts.o cpu.o call64.o
+obj-$(CONFIG_PCI) += pci.o
arch/x86/cpu/coreboot/Makefile +0 -1
index cd0bf4e..65cf2cb 100644
@@ -19,4 +19,3 @@ obj-$(CONFIG_SYS_COREBOOT) += tables.o
 obj-$(CONFIG_SYS_COREBOOT) += ipchecksum.o
 obj-$(CONFIG_SYS_COREBOOT) += sdram.o
 obj-$(CONFIG_SYS_COREBOOT) += timestamp.o
-obj-$(CONFIG_PCI) += pci.o
arch/x86/cpu/pci.c renamed from arch/x86/cpu/coreboot/pci.c +2 -2
similarity index 63%
rename from arch/x86/cpu/coreboot/pci.c
rename to arch/x86/cpu/pci.c
index 33f16a3..f35c8b3 100644
@@ -13,7 +13,7 @@
 #include <pci.h>
 #include <asm/pci.h>
 
-static struct pci_controller coreboot_hose;
+static struct pci_controller x86_hose;
 
 static void config_pci_bridge(struct pci_controller *hose, pci_dev_t dev,
                              struct pci_config_table *table)
@@ -24,7 +24,7 @@ static void config_pci_bridge(struct pci_controller *hose, pci_dev_t dev,
        pci_hose_scan_bus(hose, secondary);
 }
 
-static struct pci_config_table pci_coreboot_config_table[] = {
+static struct pci_config_table pci_x86_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 },
@@ -33,17 +33,19 @@ static struct pci_config_table pci_coreboot_config_table[] = {

Use this config_table will cause infinite loop when doing pci_hose_scan later. I do not use config_table on my Crown Bay port, instead using CONFIG_PCI_PNP which works very well.

Quoted 8 lines
arch/x86/cpu/pci.c renamed from arch/x86/cpu/coreboot/pci.c +1 -4
 void pci_init_board(void)
 {
-       coreboot_hose.config_table = pci_coreboot_config_table;
-       coreboot_hose.first_busno = 0;
-       coreboot_hose.last_busno = 0;
+       struct pci_controller *hose = &x86_hose;
 
-       pci_set_region(coreboot_hose.regions + 0, 0x0, 0x0, 0xffffffff,

arch/x86/cpu/pci.c static struct pci_config_table pci_coreboot_config_table[] = { · line 44

Quoted 10 lines
arch/x86/cpu/pci.c renamed from arch/x86/cpu/coreboot/pci.c +6 -3
-               PCI_REGION_MEM);
-       coreboot_hose.region_count = 1;
+       hose->config_table = pci_x86_config_table;
+       hose->first_busno = 0;
+       hose->last_busno = 0;
 
-       pci_setup_type1(&coreboot_hose);
+       pci_set_region(hose->regions + 0, 0x0, 0x0, 0xffffffff,
+                      PCI_REGION_MEM);
+       hose->region_count = 1;

There are 3 issues with the pci_set_region here:
1). The whole 4GiB PCI memory region creats conflicts with the systeam RAM memory map. This is a programming effor and normally causes undefined behaviour from chipset perspective.
2). There is no IO region configured, that means any device behind the PCI/PCIe bridge with only IO bar will fail to work.
3). There is no systeam RAM region configured, that means any device driver behind the PCI/PCIe bridge will fail to create pci addr <-> cpu physical addr mappings.

arch/x86/cpu/pci.c static struct pci_config_table pci_coreboot_config_table[] = { · line 51

Quoted 8 lines
arch/x86/cpu/pci.c renamed from arch/x86/cpu/coreboot/pci.c +4 -2
-       pci_register_hose(&coreboot_hose);
+       pci_setup_type1(hose);
 
-       pci_hose_scan(&coreboot_hose);
+       pci_register_hose(hose);
+
+       pci_hose_scan(hose);
 }

Regards,
Bin

#59 lore raw

PATCH 22/39 x86: Move Coreboot PCI into common cpu area

Hi Bin,

Quoted 56 lines · Bin Meng

Hi Simon,

Quoted 2 lines · Simon Glass

This code is not really Coreboot-specific, so move it into the common area and rename it.

OK, but current coreboot pci codes are broken, thus need to be fixed before making it common.

Quoted 47 lines

---

 arch/x86/cpu/Makefile             |  1 +
 arch/x86/cpu/coreboot/Makefile    |  1 -
 arch/x86/cpu/{coreboot => }/pci.c | 24 +++++++++++++-----------
 3 files changed, 14 insertions(+), 12 deletions(-)
 rename arch/x86/cpu/{coreboot => }/pci.c (63%)
arch/x86/cpu/Makefile +1 -0
index 9d38ef7..97f36d5 100644
@@ -11,3 +11,4 @@
 extra-y        = start.o
 obj-$(CONFIG_X86_RESET_VECTOR) += resetvec.o start16.o
 obj-y  += interrupts.o cpu.o call64.o
+obj-$(CONFIG_PCI) += pci.o
arch/x86/cpu/coreboot/Makefile +0 -1
index cd0bf4e..65cf2cb 100644
@@ -19,4 +19,3 @@ obj-$(CONFIG_SYS_COREBOOT) += tables.o
 obj-$(CONFIG_SYS_COREBOOT) += ipchecksum.o
 obj-$(CONFIG_SYS_COREBOOT) += sdram.o
 obj-$(CONFIG_SYS_COREBOOT) += timestamp.o
-obj-$(CONFIG_PCI) += pci.o
arch/x86/cpu/pci.c renamed from arch/x86/cpu/coreboot/pci.c +1 -1
similarity index 63%
rename from arch/x86/cpu/coreboot/pci.c
rename to arch/x86/cpu/pci.c
index 33f16a3..f35c8b3 100644
@@ -13,7 +13,7 @@
 #include <pci.h>
 #include <asm/pci.h>
 
-static struct pci_controller coreboot_hose;
+static struct pci_controller x86_hose;
 
 static void config_pci_bridge(struct pci_controller *hose, pci_dev_t dev,
                              struct pci_config_table *table)
@@ -24,7 +24,7 @@ static void config_pci_bridge(struct pci_controller *hose, pci_dev_t dev,
        pci_hose_scan_bus(hose, secondary);
 }
 
Quoted 10 lines

arch/x86/cpu/pci.c static struct pci_config_table pci_coreboot_config_table[] = {

Quoted 6 lines
arch/x86/cpu/pci.c renamed from arch/x86/cpu/coreboot/pci.c +1 -1
-static struct pci_config_table pci_coreboot_config_table[] = {
+static struct pci_config_table pci_x86_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 },
@@ -33,17 +33,19 @@ static struct pci_config_table pci_coreboot_config_table[] = {

Use this config_table will cause infinite loop when doing pci_hose_scan later. I do not use config_table on my Crown Bay port, instead using CONFIG_PCI_PNP which works very well.

OK, so are you saying that we should leave this separate for each board?

Quoted 20 lines
Quoted 9 lines
arch/x86/cpu/pci.c renamed from arch/x86/cpu/coreboot/pci.c +1 -4
 void pci_init_board(void)
 {
-       coreboot_hose.config_table = pci_coreboot_config_table;
-       coreboot_hose.first_busno = 0;
-       coreboot_hose.last_busno = 0;
+       struct pci_controller *hose = &x86_hose;
 
-       pci_set_region(coreboot_hose.regions + 0, 0x0, 0x0, 0xffffffff,

arch/x86/cpu/pci.c static struct pci_config_table pci_coreboot_config_table[] = { · line 44

Quoted 10 lines
arch/x86/cpu/pci.c renamed from arch/x86/cpu/coreboot/pci.c +6 -3
-               PCI_REGION_MEM);
-       coreboot_hose.region_count = 1;
+       hose->config_table = pci_x86_config_table;
+       hose->first_busno = 0;
+       hose->last_busno = 0;
 
-       pci_setup_type1(&coreboot_hose);
+       pci_set_region(hose->regions + 0, 0x0, 0x0, 0xffffffff,
+                      PCI_REGION_MEM);
+       hose->region_count = 1;
Quoted 9 lines

There are 3 issues with the pci_set_region here:
1). The whole 4GiB PCI memory region creats conflicts with the systeam RAM memory map. This is a programming effor and normally causes undefined behaviour from chipset perspective.
2). There is no IO region configured, that means any device behind the PCI/PCIe bridge with only IO bar will fail to work.
3). There is no systeam RAM region configured, that means any device driver behind the PCI/PCIe bridge will fail to create pci addr <-> cpu physical addr mappings.

Actually this is not real setup - for the coreboot case it is scan-only, there is no memory or I/O allocation going on.

Quoted 4 lines
Quoted 4 lines
arch/x86/cpu/pci.c renamed from arch/x86/cpu/coreboot/pci.c +1 -1
-       pci_register_hose(&coreboot_hose);
+       pci_setup_type1(hose);
 
Quoted 8 lines

arch/x86/cpu/pci.c static struct pci_config_table pci_coreboot_config_table[] = { · line 51

Quoted 5 lines
arch/x86/cpu/pci.c renamed from arch/x86/cpu/coreboot/pci.c +3 -1
-       pci_hose_scan(&coreboot_hose);
+       pci_register_hose(hose);
+
+       pci_hose_scan(hose);
 }

Regards,
Bin

Regards,
Simon

#60 lore raw

PATCH 22/39 x86: Move Coreboot PCI into common cpu area

Hi Simon,

Quoted 17 lines · Simon Glass

Hi Bin,

Quoted 12 lines · Bin Meng

Hi Simon,

arch/x86/cpu/pci.c static struct pci_config_table pci_coreboot_config_table[] = {

Quoted 6 lines
arch/x86/cpu/pci.c renamed from arch/x86/cpu/coreboot/pci.c +1 -1
-static struct pci_config_table pci_coreboot_config_table[] = {
+static struct pci_config_table pci_x86_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 },
@@ -33,17 +33,19 @@ static struct pci_config_table pci_coreboot_config_table[] = {

Use this config_table will cause infinite loop when doing pci_hose_scan later. I do not use config_table on my Crown Bay port, instead using CONFIG_PCI_PNP which works very well.

Quoted 1 line

OK, so are you saying that we should leave this separate for each board?

Not really. But we can make this code really generic. So far it is broken.

Quoted 29 lines
Quoted 19 lines
Quoted 8 lines
arch/x86/cpu/pci.c renamed from arch/x86/cpu/coreboot/pci.c +1 -4
 void pci_init_board(void)
 {
-       coreboot_hose.config_table = pci_coreboot_config_table;
-       coreboot_hose.first_busno = 0;
-       coreboot_hose.last_busno = 0;
+       struct pci_controller *hose = &x86_hose;
 
-       pci_set_region(coreboot_hose.regions + 0, 0x0, 0x0, 0xffffffff,

arch/x86/cpu/pci.c static struct pci_config_table pci_coreboot_config_table[] = { · line 44

Quoted 10 lines
arch/x86/cpu/pci.c renamed from arch/x86/cpu/coreboot/pci.c +6 -3
-               PCI_REGION_MEM);
-       coreboot_hose.region_count = 1;
+       hose->config_table = pci_x86_config_table;
+       hose->first_busno = 0;
+       hose->last_busno = 0;
 
-       pci_setup_type1(&coreboot_hose);
+       pci_set_region(hose->regions + 0, 0x0, 0x0, 0xffffffff,
+                      PCI_REGION_MEM);
+       hose->region_count = 1;
Quoted 9 lines

There are 3 issues with the pci_set_region here:
1). The whole 4GiB PCI memory region creats conflicts with the systeam RAM memory map. This is a programming effor and normally causes undefined behaviour from chipset perspective.
2). There is no IO region configured, that means any device behind the PCI/PCIe bridge with only IO bar will fail to work.
3). There is no systeam RAM region configured, that means any device driver behind the PCI/PCIe bridge will fail to create pci addr <-> cpu physical addr mappings.

Quoted 2 lines

Actually this is not real setup - for the coreboot case it is scan-only, there is no memory or I/O allocation going on.

OK, so if U-Boot boots from coreboot, the issue #1 and #2 disappear because coreboot has already enumerated the buses and devices and have memory/io allocation setup. That's fine. But this code is assumed to be used in U-Boot without coreboot too, thus U-Boot has to do the same thing as coreboot. And in the latter case, issue #1 and #2 do matter. About the issue #3, even when U-Boot is booting from coreboot, the system RAM region still needs to be set up otherwise you won't get any PCI device driver in U-Boot work. You can try adding CONFIG_E1000 to test an Intel Pro/1000 NIC in U-Boot and see what's happening.

Regards,
Bin

#61 lore raw

PATCH 22/39 x86: Move Coreboot PCI into common cpu area

Hi Bin,

Quoted 20 lines · Bin Meng

Hi Simon,

Quoted 17 lines · Simon Glass

Hi Bin,

Quoted 12 lines · Bin Meng

Hi Simon,

arch/x86/cpu/pci.c static struct pci_config_table pci_coreboot_config_table[] = {

Quoted 6 lines
arch/x86/cpu/pci.c renamed from arch/x86/cpu/coreboot/pci.c +1 -1
-static struct pci_config_table pci_coreboot_config_table[] = {
+static struct pci_config_table pci_x86_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 },
@@ -33,17 +33,19 @@ static struct pci_config_table pci_coreboot_config_table[] = {

Use this config_table will cause infinite loop when doing pci_hose_scan later. I do not use config_table on my Crown Bay port, instead using CONFIG_PCI_PNP which works very well.

Quoted 3 lines
Quoted 1 line

OK, so are you saying that we should leave this separate for each board?

Not really. But we can make this code really generic. So far it is broken.

I think the issue is that booting from Coreboot is quite a different use case from everything else.

Quoted 33 lines
Quoted 30 lines
Quoted 20 lines
Quoted 9 lines
arch/x86/cpu/pci.c renamed from arch/x86/cpu/coreboot/pci.c +1 -4
 void pci_init_board(void)
 {
-       coreboot_hose.config_table = pci_coreboot_config_table;
-       coreboot_hose.first_busno = 0;
-       coreboot_hose.last_busno = 0;
+       struct pci_controller *hose = &x86_hose;
 
-       pci_set_region(coreboot_hose.regions + 0, 0x0, 0x0, 0xffffffff,

arch/x86/cpu/pci.c static struct pci_config_table pci_coreboot_config_table[] = { · line 44

Quoted 10 lines
arch/x86/cpu/pci.c renamed from arch/x86/cpu/coreboot/pci.c +6 -3
-               PCI_REGION_MEM);
-       coreboot_hose.region_count = 1;
+       hose->config_table = pci_x86_config_table;
+       hose->first_busno = 0;
+       hose->last_busno = 0;
 
-       pci_setup_type1(&coreboot_hose);
+       pci_set_region(hose->regions + 0, 0x0, 0x0, 0xffffffff,
+                      PCI_REGION_MEM);
+       hose->region_count = 1;
Quoted 9 lines

There are 3 issues with the pci_set_region here:
1). The whole 4GiB PCI memory region creats conflicts with the systeam RAM memory map. This is a programming effor and normally causes undefined behaviour from chipset perspective.
2). There is no IO region configured, that means any device behind the PCI/PCIe bridge with only IO bar will fail to work.
3). There is no systeam RAM region configured, that means any device driver behind the PCI/PCIe bridge will fail to create pci addr <-> cpu physical addr mappings.

Quoted 2 lines

Actually this is not real setup - for the coreboot case it is scan-only, there is no memory or I/O allocation going on.

Quoted 9 lines

OK, so if U-Boot boots from coreboot, the issue #1 and #2 disappear because coreboot has already enumerated the buses and devices and have memory/io allocation setup. That's fine. But this code is assumed to be used in U-Boot without coreboot too, thus U-Boot has to do the same thing as coreboot. And in the latter case, issue #1 and #2 do matter. About the issue #3, even when U-Boot is booting from coreboot, the system RAM region still needs to be set up otherwise you won't get any PCI device driver in U-Boot work. You can try adding CONFIG_E1000 to test an Intel Pro/1000 NIC in U-Boot and see what's happening.

If I do that, then Coreboot will find the device and allocate space for it, then U-Boot will juts use the allocated space.

Actually I think the region is completely misleading in the Coreboot case and should juts be remove.

Issue 3 is not a problem either I think, since again Coreboot will allocate it.

Regards,
Simon

#62 lore raw

PATCH 22/39 x86: Move Coreboot PCI into common cpu area

Hi Simon,

Quoted 24 lines · Simon Glass

Hi Bin,

Quoted 20 lines · Bin Meng

Hi Simon,

Quoted 17 lines · Simon Glass

Hi Bin,

Quoted 12 lines · Bin Meng

Hi Simon,

arch/x86/cpu/pci.c static struct pci_config_table pci_coreboot_config_table[] = {

Quoted 6 lines
arch/x86/cpu/pci.c renamed from arch/x86/cpu/coreboot/pci.c +1 -1
-static struct pci_config_table pci_coreboot_config_table[] = {
+static struct pci_config_table pci_x86_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 },
@@ -33,17 +33,19 @@ static struct pci_config_table pci_coreboot_config_table[] = {

Use this config_table will cause infinite loop when doing pci_hose_scan later. I do not use config_table on my Crown Bay port, instead using CONFIG_PCI_PNP which works very well.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

OK, so are you saying that we should leave this separate for each board?

Not really. But we can make this code really generic. So far it is broken.

I think the issue is that booting from Coreboot is quite a different use case from everything else.

We can use #ifdef CONFIG_SYS_COREBOOT in avoid re-allocating memory resources in U-Boot.

Quoted 42 lines
Quoted 32 lines
Quoted 29 lines
Quoted 19 lines
Quoted 8 lines
arch/x86/cpu/pci.c renamed from arch/x86/cpu/coreboot/pci.c +1 -4
 void pci_init_board(void)
 {
-       coreboot_hose.config_table = pci_coreboot_config_table;
-       coreboot_hose.first_busno = 0;
-       coreboot_hose.last_busno = 0;
+       struct pci_controller *hose = &x86_hose;
 
-       pci_set_region(coreboot_hose.regions + 0, 0x0, 0x0, 0xffffffff,

arch/x86/cpu/pci.c static struct pci_config_table pci_coreboot_config_table[] = { · line 44

Quoted 10 lines
arch/x86/cpu/pci.c renamed from arch/x86/cpu/coreboot/pci.c +6 -3
-               PCI_REGION_MEM);
-       coreboot_hose.region_count = 1;
+       hose->config_table = pci_x86_config_table;
+       hose->first_busno = 0;
+       hose->last_busno = 0;
 
-       pci_setup_type1(&coreboot_hose);
+       pci_set_region(hose->regions + 0, 0x0, 0x0, 0xffffffff,
+                      PCI_REGION_MEM);
+       hose->region_count = 1;
Quoted 9 lines

There are 3 issues with the pci_set_region here:
1). The whole 4GiB PCI memory region creats conflicts with the systeam RAM memory map. This is a programming effor and normally causes undefined behaviour from chipset perspective.
2). There is no IO region configured, that means any device behind the PCI/PCIe bridge with only IO bar will fail to work.
3). There is no systeam RAM region configured, that means any device driver behind the PCI/PCIe bridge will fail to create pci addr <-> cpu physical addr mappings.

Quoted 2 lines

Actually this is not real setup - for the coreboot case it is scan-only, there is no memory or I/O allocation going on.

Quoted 9 lines

OK, so if U-Boot boots from coreboot, the issue #1 and #2 disappear because coreboot has already enumerated the buses and devices and have memory/io allocation setup. That's fine. But this code is assumed to be used in U-Boot without coreboot too, thus U-Boot has to do the same thing as coreboot. And in the latter case, issue #1 and #2 do matter. About the issue #3, even when U-Boot is booting from coreboot, the system RAM region still needs to be set up otherwise you won't get any PCI device driver in U-Boot work. You can try adding CONFIG_E1000 to test an Intel Pro/1000 NIC in U-Boot and see what's happening.

Quoted 2 lines

If I do that, then Coreboot will find the device and allocate space for it, then U-Boot will juts use the allocated space.

Yes, I understand this.

Quoted 2 lines

Actually I think the region is completely misleading in the Coreboot case and should juts be remove.

I am not sure if memory and IO can be removed completely for the coreboot case. I will need look into the pci.c/pci_auto.c and PCI device driver to confirm.

Quoted 1 line

Issue 3 is not a problem either I think, since again Coreboot will allocate it.

No, it does matter for coreboot. If the pci hose does not have the system RAM region setup, the pci_mem_to_phys will fail when PCI device driver wants to do DMA to RAM.

Regards,
Bin

#63 lore raw

PATCH 22/39 x86: Move Coreboot PCI into common cpu area

Hi Bin,

Quoted 29 lines · Bin Meng

Hi Simon,

Quoted 26 lines · Simon Glass

Hi Bin,

Quoted 22 lines · Bin Meng

Hi Simon,

Quoted 18 lines · Simon Glass

Hi Bin,

Quoted 12 lines · Bin Meng

Hi Simon,

arch/x86/cpu/pci.c static struct pci_config_table pci_coreboot_config_table[] = {

Quoted 6 lines
arch/x86/cpu/pci.c renamed from arch/x86/cpu/coreboot/pci.c +1 -1
-static struct pci_config_table pci_coreboot_config_table[] = {
+static struct pci_config_table pci_x86_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 },
@@ -33,17 +33,19 @@ static struct pci_config_table pci_coreboot_config_table[] = {

Use this config_table will cause infinite loop when doing pci_hose_scan later. I do not use config_table on my Crown Bay port, instead using CONFIG_PCI_PNP which works very well.

OK, so are you saying that we should leave this separate for each board?

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Not really. But we can make this code really generic. So far it is broken.

I think the issue is that booting from Coreboot is quite a different use case from everything else.

We can use #ifdef CONFIG_SYS_COREBOOT in avoid re-allocating memory resources in U-Boot.

Hmm in that case I'd rather keep the files separate, since I'd like to minimise the use of #ifdef.

Can we just leave off CONFIG_PCI_PNP?

Quoted 55 lines
Quoted 43 lines
Quoted 33 lines
Quoted 30 lines
Quoted 20 lines
Quoted 9 lines
arch/x86/cpu/pci.c renamed from arch/x86/cpu/coreboot/pci.c +1 -4
 void pci_init_board(void)
 {
-       coreboot_hose.config_table = pci_coreboot_config_table;
-       coreboot_hose.first_busno = 0;
-       coreboot_hose.last_busno = 0;
+       struct pci_controller *hose = &x86_hose;
 
-       pci_set_region(coreboot_hose.regions + 0, 0x0, 0x0, 0xffffffff,

arch/x86/cpu/pci.c static struct pci_config_table pci_coreboot_config_table[] = { · line 44

Quoted 10 lines
arch/x86/cpu/pci.c renamed from arch/x86/cpu/coreboot/pci.c +6 -3
-               PCI_REGION_MEM);
-       coreboot_hose.region_count = 1;
+       hose->config_table = pci_x86_config_table;
+       hose->first_busno = 0;
+       hose->last_busno = 0;
 
-       pci_setup_type1(&coreboot_hose);
+       pci_set_region(hose->regions + 0, 0x0, 0x0, 0xffffffff,
+                      PCI_REGION_MEM);
+       hose->region_count = 1;
Quoted 9 lines

There are 3 issues with the pci_set_region here:
1). The whole 4GiB PCI memory region creats conflicts with the systeam RAM memory map. This is a programming effor and normally causes undefined behaviour from chipset perspective.
2). There is no IO region configured, that means any device behind the PCI/PCIe bridge with only IO bar will fail to work.
3). There is no systeam RAM region configured, that means any device driver behind the PCI/PCIe bridge will fail to create pci addr <-> cpu physical addr mappings.

Quoted 2 lines

Actually this is not real setup - for the coreboot case it is scan-only, there is no memory or I/O allocation going on.

Quoted 9 lines

OK, so if U-Boot boots from coreboot, the issue #1 and #2 disappear because coreboot has already enumerated the buses and devices and have memory/io allocation setup. That's fine. But this code is assumed to be used in U-Boot without coreboot too, thus U-Boot has to do the same thing as coreboot. And in the latter case, issue #1 and #2 do matter. About the issue #3, even when U-Boot is booting from coreboot, the system RAM region still needs to be set up otherwise you won't get any PCI device driver in U-Boot work. You can try adding CONFIG_E1000 to test an Intel Pro/1000 NIC in U-Boot and see what's happening.

Quoted 2 lines

If I do that, then Coreboot will find the device and allocate space for it, then U-Boot will juts use the allocated space.

Yes, I understand this.

Quoted 2 lines

Actually I think the region is completely misleading in the Coreboot case and should juts be remove.

I am not sure if memory and IO can be removed completely for the coreboot case. I will need look into the pci.c/pci_auto.c and PCI device driver to confirm.

Quoted 5 lines
Quoted 1 line

Issue 3 is not a problem either I think, since again Coreboot will allocate it.

No, it does matter for coreboot. If the pci hose does not have the system RAM region setup, the pci_mem_to_phys will fail when PCI device driver wants to do DMA to RAM.

Good point, that is not supported at present.

So perhaps we should always set up suitable memory/I/O/bus-master regions and for Coreboot they will just not be used.

Regards,
Simon

#64 lore raw

PATCH 23/39 x86: Refactor PCI to permit alternate init

In reply to Simon Glass

We want access PCI earlier in the init sequence, so refactor the code so that it does not require use of a BSS variable to work. This will allow us to use early malloc() to store information about a PCI hose.

---

 arch/x86/cpu/pci.c                | 26 +++++++++++++++++++++++---
 arch/x86/include/asm/u-boot-x86.h |  3 +++
 2 files changed, 26 insertions(+), 3 deletions(-)
arch/x86/cpu/pci.c +23 -3
index f35c8b3..a72175d 100644
@@ -10,6 +10,8 @@
  */
 
 #include <common.h>
+#include <errno.h>
+#include <malloc.h>
 #include <pci.h>
 #include <asm/pci.h>
 
@@ -31,10 +33,8 @@ static struct pci_config_table pci_x86_config_table[] = {
 	{}
 };
 
-void pci_init_board(void)
+static void pci_setup_hose(struct pci_controller *hose)
 {
-	struct pci_controller *hose = &x86_hose;
-
 	hose->config_table = pci_x86_config_table;
 	hose->first_busno = 0;
 	hose->last_busno = 0;
@@ -44,7 +44,27 @@ void pci_init_board(void)
 	hose->region_count = 1;
 
 	pci_setup_type1(hose);
+}
+
+int pci_early_init_hose(struct pci_controller **hosep)
+{
+	struct pci_controller *hose;
+
+	hose = calloc(1, sizeof(struct pci_controller));
+	if (!hose)
+		return -ENOMEM;
+
+	pci_setup_hose(hose);
+	*hosep = hose;
+
+	return 0;
+}
+
+void pci_init_board(void)
+{
+	struct pci_controller *hose = &x86_hose;
 
+	pci_setup_hose(hose);
 	pci_register_hose(hose);
 
 	pci_hose_scan(hose);
arch/x86/include/asm/u-boot-x86.h +3 -0
index 8d5b438..6404cd3 100644
@@ -37,6 +37,9 @@ int cpu_init_interrupts(void);
 /* board/.../... */
 int dram_init(void);
 
+struct pci_controller;
+int pci_early_init_hose(struct pci_controller **hosep);
+
 int cleanup_before_linux(void);
 int x86_cleanup_before_linux(void);
 void x86_enable_caches(void);
Signature · 1 line
2.1.0.rc2.206.gedb03e5
#65 lore raw

PATCH 24/39 x86: ivybridge: Enable PCI in early init

In reply to Simon Glass

Enable PCI so we can access devices that need to be set up before relocation.

---

 arch/x86/cpu/ivybridge/cpu.c       |  5 +++++
 arch/x86/cpu/pci.c                 | 31 ++++++++++++++++++++++++++++++-
 arch/x86/include/asm/global_data.h |  1 +
 include/configs/chromebook_link.h  | 14 ++++++++++++--
 4 files changed, 48 insertions(+), 3 deletions(-)
arch/x86/cpu/ivybridge/cpu.c +5 -0
index a9884ca..06f4d68 100644
@@ -18,6 +18,7 @@ DECLARE_GLOBAL_DATA_PTR;
 
 int arch_cpu_init(void)
 {
+	struct pci_controller *hose;
 	int ret;
 
 	post_code(POST_CPU_INIT);
@@ -27,6 +28,10 @@ int arch_cpu_init(void)
 	if (ret)
 		return ret;
 
+	ret = pci_early_init_hose(&hose);
+	if (ret)
+		return ret;
+
 	return 0;
 }
 
arch/x86/cpu/pci.c +30 -1
index a72175d..4035fa0 100644
@@ -23,7 +23,8 @@ static void config_pci_bridge(struct pci_controller *hose, pci_dev_t dev,
 	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);
+	if (secondary != 0)
+		pci_hose_scan_bus(hose, secondary);
 }
 
 static struct pci_config_table pci_x86_config_table[] = {
@@ -39,9 +40,33 @@ static void pci_setup_hose(struct pci_controller *hose)
 	hose->first_busno = 0;
 	hose->last_busno = 0;
 
+#ifdef CONFIG_PCI_MEM_BUS
+	/* PCI memory space */
+	pci_set_region(hose->regions + 0,
+		       CONFIG_PCI_MEM_BUS,
+		       CONFIG_PCI_MEM_PHYS,
+		       CONFIG_PCI_MEM_SIZE,
+		       PCI_REGION_MEM);
+
+	/* PCI IO space */
+	pci_set_region(hose->regions + 1,
+		       CONFIG_PCI_IO_BUS,
+		       CONFIG_PCI_IO_PHYS,
+		       CONFIG_PCI_IO_SIZE,
+		       PCI_REGION_IO);
+
+	pci_set_region(hose->regions + 2,
+		       CONFIG_PCI_PREF_BUS,
+		       CONFIG_PCI_PREF_PHYS,
+		       CONFIG_PCI_PREF_SIZE,
+		       PCI_REGION_PREFETCH);
+
+	hose->region_count = 3;
+#else
 	pci_set_region(hose->regions + 0, 0x0, 0x0, 0xffffffff,
 		       PCI_REGION_MEM);
 	hose->region_count = 1;
+#endif
 
 	pci_setup_type1(hose);
 }
@@ -55,6 +80,7 @@ int pci_early_init_hose(struct pci_controller **hosep)
 		return -ENOMEM;
 
 	pci_setup_hose(hose);
+	gd->arch.hose = hose;
 	*hosep = hose;
 
 	return 0;
@@ -64,6 +90,9 @@ void pci_init_board(void)
 {
 	struct pci_controller *hose = &x86_hose;
 
+	/* Stop using the early hose */
+	gd->arch.hose = NULL;
+
 	pci_setup_hose(hose);
 	pci_register_hose(hose);
 
arch/x86/include/asm/global_data.h +1 -0
index 9eae228..998053c 100644
@@ -18,6 +18,7 @@ struct arch_global_data {
 	uint32_t tsc_prev;		/* For show_boot_progress() */
 	void *new_fdt;			/* Relocated FDT */
 	uint32_t bist;			/* Built-in self test value */
+	struct pci_controller *hose;	/* PCI hose for early use */
 };
 
 #endif
include/configs/chromebook_link.h +12 -2
index 5e8a747..5290814 100644
@@ -38,8 +38,6 @@
 #undef CONFIG_ARCH_EARLY_INIT_R
 #undef CONFIG_VIDEO
 #undef CONFIG_CFB_CONSOLE
-#undef CONFIG_SYS_EARLY_PCI_INIT
-#undef CONFIG_PCI
 #undef CONFIG_ICH_SPI
 #undef CONFIG_SPI
 #undef CONFIG_CMD_SPI
@@ -48,6 +46,18 @@
 #undef CONFIG_CMD_USB
 #undef CONFIG_CMD_SCSI
 
+#define CONFIG_PCI_MEM_BUS	0xe0000000
+#define CONFIG_PCI_MEM_PHYS	CONFIG_PCI_MEM_BUS
+#define CONFIG_PCI_MEM_SIZE	0x10000000
+
+#define CONFIG_PCI_PREF_BUS	0xd0000000
+#define CONFIG_PCI_PREF_PHYS	CONFIG_PCI_PREF_BUS
+#define CONFIG_PCI_PREF_SIZE	0x10000000
+
+#define CONFIG_PCI_IO_BUS	0x1000
+#define CONFIG_PCI_IO_PHYS	CONFIG_PCI_IO_BUS
+#define CONFIG_PCI_IO_SIZE	0xefff
+
 #define CONFIG_STD_DEVICES_SETTINGS     "stdin=usbkbd,vga,serial\0" \
 					"stdout=vga,serial\0" \
 					"stderr=vga,serial\0"
Signature · 1 line
2.1.0.rc2.206.gedb03e5
#66 lore raw

PATCH 25/39 x86: pci: Allow configuration before relocation

In reply to Simon Glass

Add simple PCI access routines for x86 which permit use before relocation. The normal PCI stack is still used, but for pre-relocation use there can only ever be a single hose. After relocation, fall back to the normal access, although even then on x86 machines there is normally only a single PCI bus.

---

 arch/x86/cpu/pci.c         | 50 ++++++++++++++++++++++++++++++++++++++++++++++
 arch/x86/include/asm/pci.h | 13 ++++++++++++
 2 files changed, 63 insertions(+)
arch/x86/cpu/pci.c +50 -0
index 4035fa0..9ee663e 100644
@@ -98,3 +98,53 @@ void pci_init_board(void)
 
 	pci_hose_scan(hose);
 }
+
+static struct pci_controller *get_hose(void)
+{
+	if (gd->arch.hose)
+		return gd->arch.hose;
+
+	return pci_bus_to_hose(0);
+}
+
+unsigned int pci_read_config8(pci_dev_t dev, unsigned where)
+{
+	uint8_t value;
+
+	pci_hose_read_config_byte(get_hose(), dev, where, &value);
+
+	return value;
+}
+
+unsigned int pci_read_config16(pci_dev_t dev, unsigned where)
+{
+	uint16_t value;
+
+	pci_hose_read_config_word(get_hose(), dev, where, &value);
+
+	return value;
+}
+
+unsigned int pci_read_config32(pci_dev_t dev, unsigned where)
+{
+	uint32_t value;
+
+	pci_hose_read_config_dword(get_hose(), dev, where, &value);
+
+	return value;
+}
+
+void pci_write_config8(pci_dev_t dev, unsigned where, unsigned value)
+{
+	pci_hose_write_config_byte(get_hose(), dev, where, value);
+}
+
+void pci_write_config16(pci_dev_t dev, unsigned where, unsigned value)
+{
+	pci_hose_write_config_word(get_hose(), dev, where, value);
+}
+
+void pci_write_config32(pci_dev_t dev, unsigned where, unsigned value)
+{
+	pci_hose_write_config_dword(get_hose(), dev, where, value);
+}
arch/x86/include/asm/pci.h +13 -0
index 6b16188..fc9a3b8 100644
@@ -13,4 +13,17 @@
 	const struct pci_device_id _table[]
 
 void pci_setup_type1(struct pci_controller *hose);
+
+/*
+ * Simple PCI access routines - these work from either the early PCI hose
+ * or the 'real' one, created after U-Boot has memory available
+ */
+unsigned int pci_read_config8(pci_dev_t dev, unsigned where);
+unsigned int pci_read_config16(pci_dev_t dev, unsigned where);
+unsigned int pci_read_config32(pci_dev_t dev, unsigned where);
+
+void pci_write_config8(pci_dev_t dev, unsigned where, unsigned value);
+void pci_write_config16(pci_dev_t dev, unsigned where, unsigned value);
+void pci_write_config32(pci_dev_t dev, unsigned where, unsigned value);
+
 #endif
Signature · 1 line
2.1.0.rc2.206.gedb03e5
#67 lore raw

PATCH 26/39 x86: ivybridge: Add early LPC init so that serial works

In reply to Simon Glass

The PCH (Peripheral Controller Hub) includes an LPC (Low Pin Count) device which provides a serial port. This is accessible on Chromebooks, so enable it early in the boot process.

---

 arch/x86/cpu/ivybridge/Makefile             |  1 +
 arch/x86/cpu/ivybridge/cpu.c                | 12 ++++++++
 arch/x86/cpu/ivybridge/lpc.c                | 48 +++++++++++++++++++++++++++++
 arch/x86/dts/link.dts                       |  3 +-
 arch/x86/include/asm/arch-ivybridge/pch.h   | 48 +++++++++++++++++++++++++++++
 doc/device-tree-bindings/misc/intel-lpc.txt | 23 ++++++++++++++
 6 files changed, 134 insertions(+), 1 deletion(-)
 create mode 100644 arch/x86/cpu/ivybridge/lpc.c
 create mode 100644 arch/x86/include/asm/arch-ivybridge/pch.h
 create mode 100644 doc/device-tree-bindings/misc/intel-lpc.txt
arch/x86/cpu/ivybridge/Makefile +1 -0
index dbcd4bd..ce16697 100644
@@ -6,4 +6,5 @@
 
 obj-y += car.o
 obj-y += cpu.o
+obj-y += lpc.o
 obj-y += sdram.o
arch/x86/cpu/ivybridge/cpu.c +12 -0
index 06f4d68..04708fb 100644
@@ -11,14 +11,19 @@
  */
 
 #include <common.h>
+#include <errno.h>
+#include <fdtdec.h>
 #include <asm/post.h>
 #include <asm/processor.h>
+#include <asm/arch/pch.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
 int arch_cpu_init(void)
 {
+	const void *blob = gd->fdt_blob;
 	struct pci_controller *hose;
+	int node;
 	int ret;
 
 	post_code(POST_CPU_INIT);
@@ -32,6 +37,13 @@ int arch_cpu_init(void)
 	if (ret)
 		return ret;
 
+	node = fdtdec_next_compatible(blob, 0, COMPAT_INTEL_LPC);
+	if (node < 0)
+		return -ENOENT;
+	ret = lpc_early_init(gd->fdt_blob, node, PCH_LPC_DEV);
+	if (ret)
+		return ret;
+
 	return 0;
 }
 
arch/x86/cpu/ivybridge/lpc.c new file +48 -0

48 lines not on this page · raw message

arch/x86/dts/link.dts +2 -1
index f2fcb39..2e91631 100644
@@ -53,9 +53,10 @@
 		compatible = "intel,lpc";
 		#address-cells = <1>;
 		#size-cells = <1>;
+		reg = <0x204 1 0x200 1 0x880 0x80>;
+		gen-dec = <0x800 0xfc 0x900 0xfc>;
 		cros-ec at 200 {
 			compatible = "google,cros-ec";
-			reg = <0x204 1 0x200 1 0x880 0x80>;
 
 			/* This describes the flash memory within the EC */
 			#address-cells = <1>;
arch/x86/include/asm/arch-ivybridge/pch.h new file +48 -0

48 lines not on this page · raw message

doc/device-tree-bindings/misc/intel-lpc.txt new file +23 -0
new file mode 100644
index 0000000..7e1b389
@@ -0,0 +1,23 @@
+Intel LPC Device Binding
+========================
+
+The device tree node which describes the operation of the Intel Low Pin
+Count device is as follows:
+
+Required properties :
+- compatible = "intel,lpc"
+- gen-dec : Specifies the values for the gen-dec registers. Up to four cell
+   pairs can be provided - the first of each pair is the base address and
+   the second is the size. These are written into the GENx_DEC registers of
+   the LPC device
+
+
+Example
+-------
+
+lpc {
+	compatible = "intel,lpc";
+	#address-cells = <1>;
+	#size-cells = <1>;
+	gen-dec = <0x800 0xfc 0x900 0xfc>;
+};
Signature · 1 line
2.1.0.rc2.206.gedb03e5
#68 lore raw

PATCH 27/39 x86: Tidy up coreboot header usage

In reply to Simon Glass

There is no need to explicitly write 'arch-coreboot' when including headers, as when the arch directory points to coreboot the correct files will be used.

---

 arch/x86/cpu/coreboot/coreboot.c   | 4 ++--
 arch/x86/cpu/coreboot/ipchecksum.c | 2 +-
 arch/x86/cpu/coreboot/tables.c     | 6 +++---
 3 files changed, 6 insertions(+), 6 deletions(-)
arch/x86/cpu/coreboot/coreboot.c +2 -2
index cc7398f..41c3936 100644
@@ -16,8 +16,8 @@
 #include <asm/cpu.h>
 #include <asm/io.h>
 #include <asm/post.h>
-#include <asm/arch-coreboot/tables.h>
-#include <asm/arch-coreboot/sysinfo.h>
+#include <asm/arch/tables.h>
+#include <asm/arch/sysinfo.h>
 #include <asm/arch/timestamp.h>
 
 DECLARE_GLOBAL_DATA_PTR;
arch/x86/cpu/coreboot/ipchecksum.c +1 -1
index 57733d8..5f6c009 100644
@@ -30,7 +30,7 @@
  */
 
 #include <compiler.h>
-#include <asm/arch-coreboot/ipchecksum.h>
+#include <asm/arch/ipchecksum.h>
 
 unsigned short ipchksum(const void *vptr, unsigned long nbytes)
 {
arch/x86/cpu/coreboot/tables.c +3 -3
index 0d91adc..92b7528 100644
@@ -8,9 +8,9 @@
  */
 
 #include <common.h>
-#include <asm/arch-coreboot/ipchecksum.h>
-#include <asm/arch-coreboot/sysinfo.h>
-#include <asm/arch-coreboot/tables.h>
+#include <asm/arch/ipchecksum.h>
+#include <asm/arch/sysinfo.h>
+#include <asm/arch/tables.h>
 
 /*
  * This needs to be in the .data section so that it's copied over during
Signature · 1 line
2.1.0.rc2.206.gedb03e5
#69 lore raw

PATCH 28/39 x86: Add clr/setbits functions

In reply to Simon Glass

These are available on other architectures. Make them available on x86 also.

---

 arch/x86/include/asm/io.h | 49 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
arch/x86/include/asm/io.h +49 -0
index 86bac90..fcd9aa9 100644
@@ -69,6 +69,55 @@
 #define memcpy_fromio(a,b,c)	memcpy((a),(b),(c))
 #define memcpy_toio(a,b,c)	memcpy((a),(b),(c))
 
+#define write_arch(type, endian, a, v) __raw_write##type(cpu_to_##endian(v), a)
+#define read_arch(type, endian, a) endian##_to_cpu(__raw_read##type(a))
+
+#define write_le64(a, v)	write_arch(q, le64, a, v)
+#define write_le32(a, v)	write_arch(l, le32, a, v)
+#define write_le16(a, v)	write_arch(w, le16, a, v)
+
+#define read_le64(a)	read_arch(q, le64, a)
+#define read_le32(a)	read_arch(l, le32, a)
+#define read_le16(a)	read_arch(w, le16, a)
+
+#define write_be32(a, v)	write_arch(l, be32, a, v)
+#define write_be16(a, v)	write_arch(w, be16, a, v)
+
+#define read_be32(a)	read_arch(l, be32, a)
+#define read_be16(a)	read_arch(w, be16, a)
+
+#define write_8(a, v)	__raw_writeb(v, a)
+#define read_8(a)	__raw_readb(a)
+
+#define clrbits(type, addr, clear) \
+	write_##type((addr), read_##type(addr) & ~(clear))
+
+#define setbits(type, addr, set) \
+	write_##type((addr), read_##type(addr) | (set))
+
+#define clrsetbits(type, addr, clear, set) \
+	write_##type((addr), (read_##type(addr) & ~(clear)) | (set))
+
+#define clrbits_be32(addr, clear) clrbits(be32, addr, clear)
+#define setbits_be32(addr, set) setbits(be32, addr, set)
+#define clrsetbits_be32(addr, clear, set) clrsetbits(be32, addr, clear, set)
+
+#define clrbits_le32(addr, clear) clrbits(le32, addr, clear)
+#define setbits_le32(addr, set) setbits(le32, addr, set)
+#define clrsetbits_le32(addr, clear, set) clrsetbits(le32, addr, clear, set)
+
+#define clrbits_be16(addr, clear) clrbits(be16, addr, clear)
+#define setbits_be16(addr, set) setbits(be16, addr, set)
+#define clrsetbits_be16(addr, clear, set) clrsetbits(be16, addr, clear, set)
+
+#define clrbits_le16(addr, clear) clrbits(le16, addr, clear)
+#define setbits_le16(addr, set) setbits(le16, addr, set)
+#define clrsetbits_le16(addr, clear, set) clrsetbits(le16, addr, clear, set)
+
+#define clrbits_8(addr, clear) clrbits(8, addr, clear)
+#define setbits_8(addr, set) setbits(8, addr, set)
+#define clrsetbits_8(addr, clear, set) clrsetbits(8, addr, clear, set)
+
 /*
  * ISA space is 'always mapped' on a typical x86 system, no need to
  * explicitly ioremap() it. The fact that the ISA IO space is mapped
Signature · 1 line
2.1.0.rc2.206.gedb03e5
#70 lore raw

PATCH 29/39 x86: Add msr read/write functions that use a structure

In reply to Simon Glass

It is convenient to be able to adjust MSRs with a structure that splits the two 32-bit halves into separate fields, as they are often dealt with separately. Add a few functions to support this.

---

 arch/x86/include/asm/msr.h | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
arch/x86/include/asm/msr.h +19 -0
index 3b5915d..df43983 100644
@@ -175,6 +175,25 @@ static inline int wrmsr_safe_regs(u32 regs[8])
 	return native_wrmsr_safe_regs(regs);
 }
 
+typedef struct msr_t {
+	uint32_t lo;
+	uint32_t hi;
+} msr_t;
+
+static inline struct msr_t msr_read(unsigned msr_num)
+{
+	struct msr_t msr;
+
+	rdmsr(msr_num, msr.lo, msr.hi);
+
+	return msr;
+}
+
+static inline void msr_write(unsigned msr_num, msr_t msr)
+{
+	wrmsr(msr_num, msr.lo, msr.hi);
+}
+
 #define rdtscl(low)						\
 	((low) = (u32)__native_read_tsc())
 
Signature · 1 line
2.1.0.rc2.206.gedb03e5
#71 lore raw

PATCH 30/39 x86: ivybridge: Perform initial CPU setup

In reply to Simon Glass

Set up the flex ratio (controls speed versus heat output) and a few other very early things.

---

 arch/x86/cpu/ivybridge/cpu.c                      | 130 ++++++++++++++++++++++
 arch/x86/include/asm/arch-ivybridge/model_206ax.h |  82 ++++++++++++++
 arch/x86/include/asm/arch-ivybridge/pch.h         |  60 ++++++++++
 arch/x86/include/asm/processor.h                  |   2 +
 4 files changed, 274 insertions(+)
 create mode 100644 arch/x86/include/asm/arch-ivybridge/model_206ax.h
arch/x86/cpu/ivybridge/cpu.c +130 -0
index 04708fb..aa825c7 100644
@@ -13,12 +13,122 @@
 #include <common.h>
 #include <errno.h>
 #include <fdtdec.h>
+#include <asm/io.h>
+#include <asm/msr.h>
+#include <asm/mtrr.h>
 #include <asm/post.h>
 #include <asm/processor.h>
+#include <asm/arch/model_206ax.h>
 #include <asm/arch/pch.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
+static void enable_port80_on_lpc(struct pci_controller *hose, pci_dev_t dev)
+{
+	/* Enable port 80 POST on LPC */
+	pci_hose_write_config_dword(hose, dev, PCH_RCBA_BASE, DEFAULT_RCBA | 1);
+	clrbits_le32(RCB_REG(GCS), 4);
+}
+
+/*
+ * Enable Prefetching and Caching.
+ */
+static void enable_spi_prefetch(struct pci_controller *hose, pci_dev_t dev)
+{
+	u8 reg8;
+
+	pci_hose_read_config_byte(hose, dev, 0xdc, &reg8);
+	reg8 &= ~(3 << 2);
+	reg8 |= (2 << 2); /* Prefetching and Caching Enabled */
+	pci_hose_write_config_byte(hose, dev, 0xdc, reg8);
+}
+
+static void set_var_mtrr(
+	unsigned reg, unsigned base, unsigned size, unsigned type)
+
+{
+	/* Bit Bit 32-35 of MTRRphysMask should be set to 1 */
+	/* FIXME: It only support 4G less range */
+	wrmsr(MTRRphysBase_MSR(reg), base | type, 0);
+	wrmsr(MTRRphysMask_MSR(reg), ~(size - 1) | MTRRphysMaskValid,
+	      (1 << (CONFIG_CPU_ADDR_BITS - 32)) - 1);
+}
+
+static void enable_rom_caching(void)
+{
+	disable_caches();
+	set_var_mtrr(1, 0xffc00000, 4 << 20, MTRR_TYPE_WRPROT);
+	enable_caches();
+
+	/* Enable Variable MTRRs */
+	wrmsr(MTRRdefType_MSR, 0x800, 0);
+}
+
+static int set_flex_ratio_to_tdp_nominal(void)
+{
+	msr_t flex_ratio, msr;
+	u8 nominal_ratio;
+
+	/* Minimum CPU revision for configurable TDP support */
+	if (cpuid_eax(1) < IVB_CONFIG_TDP_MIN_CPUID)
+		return -EINVAL;
+
+	/* Check for Flex Ratio support */
+	flex_ratio = msr_read(MSR_FLEX_RATIO);
+	if (!(flex_ratio.lo & FLEX_RATIO_EN))
+		return -EINVAL;
+
+	/* Check for >0 configurable TDPs */
+	msr = msr_read(MSR_PLATFORM_INFO);
+	if (((msr.hi >> 1) & 3) == 0)
+		return -EINVAL;
+
+	/* Use nominal TDP ratio for flex ratio */
+	msr = msr_read(MSR_CONFIG_TDP_NOMINAL);
+	nominal_ratio = msr.lo & 0xff;
+
+	/* See if flex ratio is already set to nominal TDP ratio */
+	if (((flex_ratio.lo >> 8) & 0xff) == nominal_ratio)
+		return 0;
+
+	/* Set flex ratio to nominal TDP ratio */
+	flex_ratio.lo &= ~0xff00;
+	flex_ratio.lo |= nominal_ratio << 8;
+	flex_ratio.lo |= FLEX_RATIO_LOCK;
+	msr_write(MSR_FLEX_RATIO, flex_ratio);
+
+	/* Set flex ratio in soft reset data register bits 11:6 */
+	clrsetbits_le32(RCB_REG(SOFT_RESET_DATA), 0x3f << 6,
+			(nominal_ratio & 0x3f) << 6);
+
+	/* Set soft reset control to use register value */
+	setbits_le32(RCB_REG(SOFT_RESET_CTRL), 1);
+
+	/* Issue warm reset, will be "CPU only" due to soft reset data */
+	outb(0x0, PORT_RESET);
+	outb(0x6, PORT_RESET);
+	cpu_hlt();
+
+	/* Not reached */
+	return -EINVAL;
+}
+
+static void set_spi_speed(void)
+{
+	u32 fdod;
+
+	/* Observe SPI Descriptor Component Section 0 */
+	writel(0x1000, RCB_REG(SPI_DESC_COMP0));
+
+	/* Extract the1 Write/Erase SPI Frequency from descriptor */
+	fdod = readl(RCB_REG(SPI_FREQ_WR_ERA));
+	fdod >>= 24;
+	fdod &= 7;
+
+	/* Set Software Sequence frequency to match */
+	clrsetbits_8(RCB_REG(SPI_FREQ_SWSEQ), 7, fdod);
+}
+
 int arch_cpu_init(void)
 {
 	const void *blob = gd->fdt_blob;
@@ -44,6 +154,26 @@ int arch_cpu_init(void)
 	if (ret)
 		return ret;
 
+	enable_spi_prefetch(hose, PCH_LPC_DEV);
+
+	/* This is already done in start.S, but let's do it in C */
+	enable_port80_on_lpc(hose, PCH_LPC_DEV);
+
+	/* already done in car.S */
+	if (false)
+		enable_rom_caching();
+
+	set_spi_speed();
+
+	/*
+	 * We should do as little as possible before the serial console is
+	 * up. Perhaps this should move to later. Our next lot of init
+	 * happens in print_cpuinfo() when we have a console
+	 */
+	ret = set_flex_ratio_to_tdp_nominal();
+	if (ret)
+		return ret;
+
 	return 0;
 }
 
arch/x86/include/asm/arch-ivybridge/model_206ax.h new file +82 -0

82 lines not on this page · raw message

arch/x86/include/asm/arch-ivybridge/pch.h +60 -0

66 lines not on this page · raw message

arch/x86/include/asm/processor.h +2 -0
index 2c33723..e675c78 100644
@@ -32,6 +32,8 @@ enum {
 
 #ifndef __ASSEMBLY__
 
+#define PORT_RESET		0xcf9
+
 static inline __attribute__((always_inline)) void cpu_hlt(void)
 {
 	asm("hlt");
Signature · 1 line
2.1.0.rc2.206.gedb03e5
#72 lore raw

PATCH 31/39 x86: ivybridge: Check BIST value on boot

In reply to Simon Glass

The built-in self test value should be checked before we continue booting. Refuse to continue if there is something wrong.

---

 arch/x86/cpu/ivybridge/cpu.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
arch/x86/cpu/ivybridge/cpu.c +16 -0
index aa825c7..e73ccb7 100644
@@ -177,10 +177,26 @@ int arch_cpu_init(void)
 	return 0;
 }
 
+static int report_bist_failure(void)
+{
+	if (gd->arch.bist != 0) {
+		printf("BIST failed: %08x\n", gd->arch.bist);
+		return -EFAULT;
+	}
+
+	return 0;
+}
+
 int print_cpuinfo(void)
 {
 	char processor_name[CPU_MAX_NAME_LEN];
 	const char *name;
+	int ret;
+
+	/* Halt if there was a built in self test failure */
+	ret = report_bist_failure();
+	if (ret)
+		return ret;
 
 	/* Print processor name */
 	name = cpu_get_name(processor_name);
Signature · 1 line
2.1.0.rc2.206.gedb03e5
#73 lore raw

PATCH 31/39 x86: ivybridge: Check BIST value on boot

Hi Simon,

Quoted 19 lines · Simon Glass

The built-in self test value should be checked before we continue booting. Refuse to continue if there is something wrong.

---

 arch/x86/cpu/ivybridge/cpu.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
arch/x86/cpu/ivybridge/cpu.c +2 -0
index aa825c7..e73ccb7 100644
@@ -177,10 +177,26 @@ int arch_cpu_init(void)
        return 0;
 }
 
+static int report_bist_failure(void)
+{

arch/x86/cpu/ivybridge/cpu.c int arch_cpu_init(void) · line 191

Quoted 10 lines
arch/x86/cpu/ivybridge/cpu.c +8 -0
+       if (gd->arch.bist != 0) {
+               printf("BIST failed: %08x\n", gd->arch.bist);
+               return -EFAULT;
+       }
+
+       return 0;
+}
+
 int print_cpuinfo(void)
 {

I don't see patch that moves print_cpuinfo() from arch/x86/cpu/cpu.c to this. Is there anything I missed?

[snip]

Regards,
Bin

#74 lore raw

PATCH 31/39 x86: ivybridge: Check BIST value on boot

Hi Bin,

Quoted 20 lines · Bin Meng

Hi Simon,

Quoted 17 lines · Simon Glass

The built-in self test value should be checked before we continue booting. Refuse to continue if there is something wrong.

---

 arch/x86/cpu/ivybridge/cpu.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
arch/x86/cpu/ivybridge/cpu.c +0 -0
index aa825c7..e73ccb7 100644
@@ -177,10 +177,26 @@ int arch_cpu_init(void)
        return 0;
 }
 
Quoted 15 lines

arch/x86/cpu/ivybridge/cpu.c int arch_cpu_init(void) · line 191

Quoted 12 lines
arch/x86/cpu/ivybridge/cpu.c +10 -0
+static int report_bist_failure(void)
+{
+       if (gd->arch.bist != 0) {
+               printf("BIST failed: %08x\n", gd->arch.bist);
+               return -EFAULT;
+       }
+
+       return 0;
+}
+
 int print_cpuinfo(void)
 {

I don't see patch that moves print_cpuinfo() from arch/x86/cpu/cpu.c to this. Is there anything I missed?

You will see it when I resend the series.

Regards,
Simon

#75 lore raw

PATCH 32/39 x86: ivybridge: Perform Intel microcode update on boot

In reply to Simon Glass

Microcode updates are stored in the device tree. Work through these and apply any that are needed.

---

 arch/x86/cpu/ivybridge/Makefile                 |   1 +
 arch/x86/cpu/ivybridge/cpu.c                    |   5 +
 arch/x86/cpu/ivybridge/microcode_intel.c        | 150 ++++++++++++++++++++++++
 arch/x86/include/asm/arch-ivybridge/microcode.h |  20 ++++
 include/fdtdec.h                                |   1 +
 lib/fdtdec.c                                    |   1 +
 6 files changed, 178 insertions(+)
 create mode 100644 arch/x86/cpu/ivybridge/microcode_intel.c
 create mode 100644 arch/x86/include/asm/arch-ivybridge/microcode.h
arch/x86/cpu/ivybridge/Makefile +1 -0
index ce16697..a3ea566 100644
@@ -7,4 +7,5 @@
 obj-y += car.o
 obj-y += cpu.o
 obj-y += lpc.o
+obj-y += microcode_intel.o
 obj-y += sdram.o
arch/x86/cpu/ivybridge/cpu.c +5 -0
index e73ccb7..bd2660f 100644
@@ -19,6 +19,7 @@
 #include <asm/post.h>
 #include <asm/processor.h>
 #include <asm/arch/model_206ax.h>
+#include <asm/arch/microcode.h>
 #include <asm/arch/pch.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -198,6 +199,10 @@ int print_cpuinfo(void)
 	if (ret)
 		return ret;
 
+	ret = microcode_update_intel();
+	if (ret && ret != -ENOENT && ret != -EEXIST)
+		return ret;
+
 	/* Print processor name */
 	name = cpu_get_name(processor_name);
 	printf("CPU:   %s\n", name);
arch/x86/cpu/ivybridge/microcode_intel.c new file +150 -0

150 lines not on this page · raw message

arch/x86/include/asm/arch-ivybridge/microcode.h new file +20 -0
new file mode 100644
index 0000000..bc9b87c
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2015 Google, Inc
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef __ASM_ARCH_MICROCODE_H
+#define __ASM_ARCH_MICROCODE_H
+
+/**
+ * microcode_update_intel() - Apply microcode updates
+ *
+ * Applies any microcode updates in the device tree.
+ *
+ * @return 0 if OK, -EEXIST if the updates were already applied, -ENOENT if
+ * not updates were found, -EINVAL if an update was invalid
+ */
+int microcode_update_intel(void);
+
+#endif
include/fdtdec.h +1 -0
index 6b40006..3bd60b7 100644
@@ -118,6 +118,7 @@ enum fdt_compat_id {
 	COMPAT_SAMSUNG_EXYNOS_SYSMMU,	/* Exynos sysmmu */
 	COMPAT_PARADE_PS8625,		/* Parade PS8622 EDP->LVDS bridge */
 	COMPAT_INTEL_LPC,		/* Intel Low Pin Count I/F */
+	COMPAT_INTEL_MICROCODE,		/* Intel microcode update */
 
 	COMPAT_COUNT,
 };
lib/fdtdec.c +1 -0
index 4aa227a..9a68f9c 100644
@@ -73,6 +73,7 @@ static const char * const compat_names[COMPAT_COUNT] = {
 	COMPAT(SAMSUNG_EXYNOS_SYSMMU, "samsung,sysmmu-v3.3"),
 	COMPAT(PARADE_PS8625, "parade,ps8625"),
 	COMPAT(COMPAT_INTEL_LPC, "intel,lpc"),
+	COMPAT(INTEL_MICROCODE, "intel,microcode"),
 };
 
 const char *fdtdec_get_compatible(enum fdt_compat_id id)
Signature · 1 line
2.1.0.rc2.206.gedb03e5
#76 lore raw

PATCH 32/39 x86: ivybridge: Perform Intel microcode update on boot

Hi Simon,

Quoted 55 lines · Simon Glass

Microcode updates are stored in the device tree. Work through these and apply any that are needed.

---

 arch/x86/cpu/ivybridge/Makefile                 |   1 +
 arch/x86/cpu/ivybridge/cpu.c                    |   5 +
 arch/x86/cpu/ivybridge/microcode_intel.c        | 150 ++++++++++++++++++++++++
 arch/x86/include/asm/arch-ivybridge/microcode.h |  20 ++++
 include/fdtdec.h                                |   1 +
 lib/fdtdec.c                                    |   1 +
 6 files changed, 178 insertions(+)
 create mode 100644 arch/x86/cpu/ivybridge/microcode_intel.c
 create mode 100644 arch/x86/include/asm/arch-ivybridge/microcode.h
arch/x86/cpu/ivybridge/Makefile +1 -0
index ce16697..a3ea566 100644
@@ -7,4 +7,5 @@
 obj-y += car.o
 obj-y += cpu.o
 obj-y += lpc.o
+obj-y += microcode_intel.o
 obj-y += sdram.o
arch/x86/cpu/ivybridge/cpu.c +5 -0
index e73ccb7..bd2660f 100644
@@ -19,6 +19,7 @@
 #include <asm/post.h>
 #include <asm/processor.h>
 #include <asm/arch/model_206ax.h>
+#include <asm/arch/microcode.h>
 #include <asm/arch/pch.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -198,6 +199,10 @@ int print_cpuinfo(void)
        if (ret)
                return ret;
 
+       ret = microcode_update_intel();
+       if (ret && ret != -ENOENT && ret != -EEXIST)
+               return ret;
+
        /* Print processor name */
        name = cpu_get_name(processor_name);
        printf("CPU:   %s\n", name);
arch/x86/cpu/ivybridge/microcode_intel.c new file +0 -0
new file mode 100644
index 0000000..fbb55f2

arch/x86/cpu/ivybridge/microcode_intel.c line 5

Quoted 5 lines
arch/x86/cpu/ivybridge/microcode_intel.c new file +5 -0
@@ -0,0 +1,150 @@
+/*
+ * Copyright (c) 2014 Google, Inc
+ * Copyright (C) 2000 Ronald G. Minnich
+ *
+ * Microcode update for Intel PIII and later CPUs

This comment suggests that the code is generic for all Intel CPUs, so should we move this code to arch/x86/lib?

[snip]

Regards,
Bin

#77 lore raw

PATCH 32/39 x86: ivybridge: Perform Intel microcode update on boot

Hi Bin,

Quoted 58 lines · Bin Meng

Hi Simon,

Quoted 55 lines · Simon Glass

Microcode updates are stored in the device tree. Work through these and apply any that are needed.

---

 arch/x86/cpu/ivybridge/Makefile                 |   1 +
 arch/x86/cpu/ivybridge/cpu.c                    |   5 +
 arch/x86/cpu/ivybridge/microcode_intel.c        | 150 ++++++++++++++++++++++++
 arch/x86/include/asm/arch-ivybridge/microcode.h |  20 ++++
 include/fdtdec.h                                |   1 +
 lib/fdtdec.c                                    |   1 +
 6 files changed, 178 insertions(+)
 create mode 100644 arch/x86/cpu/ivybridge/microcode_intel.c
 create mode 100644 arch/x86/include/asm/arch-ivybridge/microcode.h
arch/x86/cpu/ivybridge/Makefile +1 -0
index ce16697..a3ea566 100644
@@ -7,4 +7,5 @@
 obj-y += car.o
 obj-y += cpu.o
 obj-y += lpc.o
+obj-y += microcode_intel.o
 obj-y += sdram.o
arch/x86/cpu/ivybridge/cpu.c +5 -0
index e73ccb7..bd2660f 100644
@@ -19,6 +19,7 @@
 #include <asm/post.h>
 #include <asm/processor.h>
 #include <asm/arch/model_206ax.h>
+#include <asm/arch/microcode.h>
 #include <asm/arch/pch.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -198,6 +199,10 @@ int print_cpuinfo(void)
        if (ret)
                return ret;
 
+       ret = microcode_update_intel();
+       if (ret && ret != -ENOENT && ret != -EEXIST)
+               return ret;
+
        /* Print processor name */
        name = cpu_get_name(processor_name);
        printf("CPU:   %s\n", name);
arch/x86/cpu/ivybridge/microcode_intel.c new file +0 -0
new file mode 100644
index 0000000..fbb55f2
@@ -0,0 +1,150 @@
Quoted 8 lines

arch/x86/cpu/ivybridge/microcode_intel.c line 5

Quoted 5 lines
arch/x86/cpu/ivybridge/microcode_intel.c new file +5 -0
+/*
+ * Copyright (c) 2014 Google, Inc
+ * Copyright (C) 2000 Ronald G. Minnich
+ *
+ * Microcode update for Intel PIII and later CPUs

This comment suggests that the code is generic for all Intel CPUs, so should we move this code to arch/x86/lib?

Actually I think a lot of code is in that category, or at least I fervently hope so! We may end up with an 'intel-common' directory, I'm not sure. But I'd rather leave common discussions until we know things are common.

Regards,
Simon

#78 lore raw

PATCH 33/39 RFC: x86: dts: Add microcode updates for ivybridge CPU

In reply to Simon Glass

Add two microcode updates that are provided for this CPU. The updates have been converted to a device tree form.

(The license needs to be converted to SPDX)

---

 arch/x86/dts/link.dts               |  10 +
 arch/x86/dts/m12206a7_00000028.dtsi | 622 ++++++++++++++++++++++++++++++
 arch/x86/dts/m12306a9_00000017.dtsi | 750 ++++++++++++++++++++++++++++++++++++
 3 files changed, 1382 insertions(+)
 create mode 100644 arch/x86/dts/m12206a7_00000028.dtsi
 create mode 100644 arch/x86/dts/m12306a9_00000017.dtsi
arch/x86/dts/link.dts +10 -0
index 2e91631..ea4b0ba 100644
@@ -67,4 +67,14 @@
 			};
 		};
 	};
+
+	microcode {
+		update at 0 {
+#include "m12206a7_00000028.dtsi"
+		};
+		update at 1 {
+#include "m12306a9_00000017.dtsi"
+		};
+	};
+
 };
arch/x86/dts/m12206a7_00000028.dtsi new file +622 -0

622 lines not on this page · raw message

arch/x86/dts/m12306a9_00000017.dtsi new file +750 -0

750 lines not on this page · raw message

Signature · 1 line
2.1.0.rc2.206.gedb03e5
#79 lore raw

PATCH 33/39 RFC: x86: dts: Add microcode updates for ivybridge CPU

Hi Simon,

Quoted 84 lines · Simon Glass

Add two microcode updates that are provided for this CPU. The updates have been converted to a device tree form.

(The license needs to be converted to SPDX)

---

 arch/x86/dts/link.dts               |  10 +
 arch/x86/dts/m12206a7_00000028.dtsi | 622 ++++++++++++++++++++++++++++++
 arch/x86/dts/m12306a9_00000017.dtsi | 750 ++++++++++++++++++++++++++++++++++++
 3 files changed, 1382 insertions(+)
 create mode 100644 arch/x86/dts/m12206a7_00000028.dtsi
 create mode 100644 arch/x86/dts/m12306a9_00000017.dtsi
arch/x86/dts/link.dts +10 -0
index 2e91631..ea4b0ba 100644
@@ -67,4 +67,14 @@
                        };
                };
        };
+
+       microcode {
+               update at 0 {
+#include "m12206a7_00000028.dtsi"
+               };
+               update at 1 {
+#include "m12306a9_00000017.dtsi"
+               };
+       };
+
 };
arch/x86/dts/m12206a7_00000028.dtsi new file +44 -0
new file mode 100644
index 0000000..bcd5248
@@ -0,0 +1,622 @@
+/*
+ * Copyright (c) <1995-2013>, Intel Corporation.
+ * All rights reserved.
+ *
+ * Redistribution. Redistribution and use in binary form, without modification, are
+ * permitted provided that the following conditions are met:
+ *     .Redistributions must reproduce the above copyright notice and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ * Neither the name of Intel Corporation nor the names of its suppliers may be used
+ * to endorse or promote products derived from this software without specific prior
+ * written permission.
+ *     .No reverse engineering, decompilation, or disassembly of this software is
+ * permitted.
+ *     ."Binary form" includes any format commonly used for electronic conveyance
+ * which is a reversible, bit-exact translation of binary representation to ASCII or
+ * ISO text, for example, "uuencode."
+ *
+ * DISCLAIMER. 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.
+ *
+ *---
+ * This is a device tree fragment. Use #include to add these properties to a
+ * node.
+ */
+
+compatible = "intel,microcode";
+intel,header-version = <1>;
+intel,update-revision = <0x28>;
+intel,date-code = <0x04242012>;
+intel,processor-signature = <0x000206a7>;
+intel,checksum = <0xf3e9935d>;
+intel,loader-revision = <1>;

arch/x86/dts/m12206a7_00000028.dtsi line 54

Quoted 10 lines
arch/x86/dts/m12206a7_00000028.dtsi new file +10 -0
+intel,processor-flags = <0x12>;
+
+/* The 48-byte public header is omitted. */
+data = <
+       0x00000000      0x000000a1      0x00020001      0x00000028
+       0x00000000      0x00000000      0x20120423      0x000008f1
+       0x00000001      0x000206a7      0x00000000      0x00000000
+       0x00000000      0x00000000      0x00000000      0x00000000
+       0x00000000      0x000008f1      0x00000000      0x00000000
+       0x00000000      0x00000000      0x00000000      0x00000000

Do you plan to create a tool to convert the Intel released microcode file to dts automatically? Or if not, we need document on how to convert the Intel version to dts manually, maybe in the dts-bindings documentation.

[snip]

Regards,
Bin

#80 lore raw

PATCH 33/39 RFC: x86: dts: Add microcode updates for ivybridge CPU

Hi Bin,

Quoted 94 lines · Bin Meng

Hi Simon,

Quoted 91 lines · Simon Glass

Add two microcode updates that are provided for this CPU. The updates have been converted to a device tree form.

(The license needs to be converted to SPDX)

---

 arch/x86/dts/link.dts               |  10 +
 arch/x86/dts/m12206a7_00000028.dtsi | 622 ++++++++++++++++++++++++++++++
 arch/x86/dts/m12306a9_00000017.dtsi | 750 ++++++++++++++++++++++++++++++++++++
 3 files changed, 1382 insertions(+)
 create mode 100644 arch/x86/dts/m12206a7_00000028.dtsi
 create mode 100644 arch/x86/dts/m12306a9_00000017.dtsi
arch/x86/dts/link.dts +10 -0
index 2e91631..ea4b0ba 100644
@@ -67,4 +67,14 @@
                        };
                };
        };
+
+       microcode {
+               update at 0 {
+#include "m12206a7_00000028.dtsi"
+               };
+               update at 1 {
+#include "m12306a9_00000017.dtsi"
+               };
+       };
+
 };
arch/x86/dts/m12206a7_00000028.dtsi new file +51 -0
new file mode 100644
index 0000000..bcd5248
@@ -0,0 +1,622 @@
+/*
+ * Copyright (c) <1995-2013>, Intel Corporation.
+ * All rights reserved.
+ *
+ * Redistribution. Redistribution and use in binary form, without modification, are
+ * permitted provided that the following conditions are met:
+ *     .Redistributions must reproduce the above copyright notice and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ * Neither the name of Intel Corporation nor the names of its suppliers may be used
+ * to endorse or promote products derived from this software without specific prior
+ * written permission.
+ *     .No reverse engineering, decompilation, or disassembly of this software is
+ * permitted.
+ *     ."Binary form" includes any format commonly used for electronic conveyance
+ * which is a reversible, bit-exact translation of binary representation to ASCII or
+ * ISO text, for example, "uuencode."
+ *
+ * DISCLAIMER. 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.
+ *
+ *---
+ * This is a device tree fragment. Use #include to add these properties to a
+ * node.
+ */
+
+compatible = "intel,microcode";
+intel,header-version = <1>;
+intel,update-revision = <0x28>;
+intel,date-code = <0x04242012>;
+intel,processor-signature = <0x000206a7>;
+intel,checksum = <0xf3e9935d>;
+intel,loader-revision = <1>;
+intel,processor-flags = <0x12>;
+
+/* The 48-byte public header is omitted. */
+data = <
+       0x00000000      0x000000a1      0x00020001      0x00000028
+       0x00000000      0x00000000      0x20120423      0x000008f1
+       0x00000001      0x000206a7      0x00000000      0x00000000
Quoted 8 lines

arch/x86/dts/m12206a7_00000028.dtsi line 54

Quoted 3 lines
arch/x86/dts/m12206a7_00000028.dtsi new file +3 -0
+       0x00000000      0x00000000      0x00000000      0x00000000
+       0x00000000      0x000008f1      0x00000000      0x00000000
+       0x00000000      0x00000000      0x00000000      0x00000000

Do you plan to create a tool to convert the Intel released microcode file to dts automatically? Or if not, we need document on how to convert the Intel version to dts manually, maybe in the dts-bindings documentation.

Yes I think a tool would be great. It could operate on the tar file that Intel provides. I'll take a look sometime.

Regards,
Simon

#81 lore raw

PATCH 34/39 x86: ivybridge: Add early init for PCH devices

In reply to Simon Glass

Many PCH devices are hard-coded to a particular PCI address. Set these up early in case they are needed.

---

 arch/x86/cpu/ivybridge/Makefile                   |   1 +
 arch/x86/cpu/ivybridge/cpu.c                      | 142 +++++++++++++++++++++
 arch/x86/cpu/ivybridge/early_init.c               | 145 ++++++++++++++++++++++
 arch/x86/include/asm/arch-ivybridge/pch.h         | 121 +++++++++++++++++-
 arch/x86/include/asm/arch-ivybridge/sandybridge.h | 107 ++++++++++++++++
 arch/x86/include/asm/global_data.h                |   8 ++
 arch/x86/include/asm/post.h                       |   2 +
 7 files changed, 525 insertions(+), 1 deletion(-)
 create mode 100644 arch/x86/cpu/ivybridge/early_init.c
 create mode 100644 arch/x86/include/asm/arch-ivybridge/sandybridge.h
arch/x86/cpu/ivybridge/Makefile +1 -0
index a3ea566..4bfb03a 100644
@@ -6,6 +6,7 @@
 
 obj-y += car.o
 obj-y += cpu.o
+obj-y += early_init.o
 obj-y += lpc.o
 obj-y += microcode_intel.o
 obj-y += sdram.o
arch/x86/cpu/ivybridge/cpu.c +142 -0

182 lines not on this page · raw message

arch/x86/cpu/ivybridge/early_init.c new file +145 -0

145 lines not on this page · raw message

arch/x86/include/asm/arch-ivybridge/pch.h +120 -1

144 lines not on this page · raw message

arch/x86/include/asm/arch-ivybridge/sandybridge.h new file +107 -0

107 lines not on this page · raw message

arch/x86/include/asm/global_data.h +8 -0
index 998053c..c60deda 100644
@@ -10,6 +10,13 @@
 
 #ifndef __ASSEMBLY__
 
+enum pei_boot_mode_t {
+	PEI_BOOT_NONE = 0,
+	PEI_BOOT_SOFT_RESET,
+	PEI_BOOT_RESUME,
+
+};
+
 /* Architecture-specific global data */
 struct arch_global_data {
 	struct global_data *gd_addr;		/* Location of Global Data */
@@ -19,6 +26,7 @@ struct arch_global_data {
 	void *new_fdt;			/* Relocated FDT */
 	uint32_t bist;			/* Built-in self test value */
 	struct pci_controller *hose;	/* PCI hose for early use */
+	enum pei_boot_mode_t pei_boot_mode;
 };
 
 #endif
arch/x86/include/asm/post.h +2 -0
index b203dc9..61dcda1 100644
@@ -25,6 +25,8 @@
 #define POST_START_STACK	0x29
 #define POST_START_DONE		0x2a
 #define POST_CPU_INIT		0x2b
+#define POST_EARLY_INIT		0x2c
+#define POST_CPU_INFO		0x2d
 
 /* Output a post code using al - value must be 0 to 0xff */
 #ifdef __ASSEMBLY__
Signature · 1 line
2.1.0.rc2.206.gedb03e5
#82 lore raw

PATCH 34/39 x86: ivybridge: Add early init for PCH devices

Hi Simon,

Quoted 202 lines · Simon Glass

Many PCH devices are hard-coded to a particular PCI address. Set these up early in case they are needed.

---

 arch/x86/cpu/ivybridge/Makefile                   |   1 +
 arch/x86/cpu/ivybridge/cpu.c                      | 142 +++++++++++++++++++++
 arch/x86/cpu/ivybridge/early_init.c               | 145 ++++++++++++++++++++++
 arch/x86/include/asm/arch-ivybridge/pch.h         | 121 +++++++++++++++++-
 arch/x86/include/asm/arch-ivybridge/sandybridge.h | 107 ++++++++++++++++
 arch/x86/include/asm/global_data.h                |   8 ++
 arch/x86/include/asm/post.h                       |   2 +
 7 files changed, 525 insertions(+), 1 deletion(-)
 create mode 100644 arch/x86/cpu/ivybridge/early_init.c
 create mode 100644 arch/x86/include/asm/arch-ivybridge/sandybridge.h
arch/x86/cpu/ivybridge/Makefile +1 -0
index a3ea566..4bfb03a 100644
@@ -6,6 +6,7 @@
 
 obj-y += car.o
 obj-y += cpu.o
+obj-y += early_init.o
 obj-y += lpc.o
 obj-y += microcode_intel.o
 obj-y += sdram.o
arch/x86/cpu/ivybridge/cpu.c +130 -0
index bd2660f..a435520 100644
@@ -4,6 +4,7 @@
  * Graeme Russ, graeme.russ at gmail.com.
  *
  * Some portions from coreboot src/mainboard/google/link/romstage.c
+ * and src/cpu/intel/model_206ax/bootblock.c
  * Copyright (C) 2007-2010 coresystems GmbH
  * Copyright (C) 2011 Google Inc.
  *
@@ -16,11 +17,13 @@
 #include <asm/io.h>
 #include <asm/msr.h>
 #include <asm/mtrr.h>
+#include <asm/pci.h>
 #include <asm/post.h>
 #include <asm/processor.h>
 #include <asm/arch/model_206ax.h>
 #include <asm/arch/microcode.h>
 #include <asm/arch/pch.h>
+#include <asm/arch/sandybridge.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -178,6 +181,83 @@ int arch_cpu_init(void)
        return 0;
 }
 
+static int enable_smbus(void)
+{
+       pci_dev_t dev;
+       uint16_t value;
+
+       /* Set the SMBus device statically. */
+       dev = PCI_BDF(0x0, 0x1f, 0x3);
+
+       /* Check to make sure we've got the right device. */
+       value = pci_read_config16(dev, 0x0);
+       if (value != 0x8086) {
+               printf("SMBus controller not found\n");
+               return -ENOSYS;
+       }
+
+       /* Set SMBus I/O base. */
+       pci_write_config32(dev, SMB_BASE,
+                          SMBUS_IO_BASE | PCI_BASE_ADDRESS_SPACE_IO);
+
+       /* Set SMBus enable. */
+       pci_write_config8(dev, HOSTC, HST_EN);
+
+       /* Set SMBus I/O space enable. */
+       pci_write_config16(dev, PCI_COMMAND, PCI_COMMAND_IO);
+
+       /* Disable interrupt generation. */
+       outb(0, SMBUS_IO_BASE + SMBHSTCTL);
+
+       /* Clear any lingering errors, so transactions can run. */
+       outb(inb(SMBUS_IO_BASE + SMBHSTSTAT), SMBUS_IO_BASE + SMBHSTSTAT);
+       debug("SMBus controller enabled\n");
+
+       return 0;
+}
+
+#define PCH_EHCI0_TEMP_BAR0 0xe8000000
+#define PCH_EHCI1_TEMP_BAR0 0xe8000400
+#define PCH_XHCI_TEMP_BAR0  0xe8001000
+
+/*
+ * Setup USB controller MMIO BAR to prevent the reference code from
+ * resetting the controller.
+ *
+ * The BAR will be re-assigned during device enumeration so these are only
+ * temporary.
+ *
+ * This is used to speed up the resume path.
+ */
+static void enable_usb_bar(void)
+{
+       pci_dev_t usb0 = PCH_EHCI1_DEV;
+       pci_dev_t usb1 = PCH_EHCI2_DEV;
+       pci_dev_t usb3 = PCH_XHCI_DEV;
+       u32 cmd;
+
+       /* USB Controller 1 */
+       pci_write_config32(usb0, PCI_BASE_ADDRESS_0,
+                          PCH_EHCI0_TEMP_BAR0);
+       cmd = pci_read_config32(usb0, PCI_COMMAND);
+       cmd |= PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
+       pci_write_config32(usb0, PCI_COMMAND, cmd);
+
+       /* USB Controller 1 */
+       pci_write_config32(usb1, PCI_BASE_ADDRESS_0,
+                          PCH_EHCI1_TEMP_BAR0);
+       cmd = pci_read_config32(usb1, PCI_COMMAND);
+       cmd |= PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
+       pci_write_config32(usb1, PCI_COMMAND, cmd);
+
+       /* USB3 Controller */
+       pci_write_config32(usb3, PCI_BASE_ADDRESS_0,
+                          PCH_XHCI_TEMP_BAR0);
+       cmd = pci_read_config32(usb3, PCI_COMMAND);
+       cmd |= PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
+       pci_write_config32(usb3, PCI_COMMAND, cmd);
+}
+
 static int report_bist_failure(void)
 {
        if (gd->arch.bist != 0) {
@@ -190,8 +270,11 @@ static int report_bist_failure(void)
 
 int print_cpuinfo(void)
 {
+       enum pei_boot_mode_t boot_mode = PEI_BOOT_NONE;
        char processor_name[CPU_MAX_NAME_LEN];
        const char *name;
+       uint32_t pm1_cnt;
+       uint16_t pm1_sts;
        int ret;
 
        /* Halt if there was a built in self test failure */
@@ -203,9 +286,68 @@ int print_cpuinfo(void)
        if (ret && ret != -ENOENT && ret != -EEXIST)
                return ret;
 
+       /* Enable upper 128bytes of CMOS */
+       writel(1 << 2, RCB_REG(RC));
+
+       /* TODO: cmos_post_init() */
+       if (readl(MCHBAR_REG(SSKPD)) == 0xCAFE) {
+               debug("soft reset detected\n");
+               boot_mode = PEI_BOOT_SOFT_RESET;
+
+               /* System is not happy after keyboard reset... */
+               debug("Issuing CF9 warm reset\n");
+               outb(0x6, 0xcf9);
+               cpu_hlt();
+       }
+
+       /* Early chipset init required before RAM init can work */
+       sandybridge_early_init(SANDYBRIDGE_MOBILE);
+
+       /* Check PM1_STS[15] to see if we are waking from Sx */
+       pm1_sts = inw(DEFAULT_PMBASE + PM1_STS);
+
+       /* Read PM1_CNT[12:10] to determine which Sx state */
+       pm1_cnt = inl(DEFAULT_PMBASE + PM1_CNT);
+
+       if ((pm1_sts & WAK_STS) && ((pm1_cnt >> 10) & 7) == 5) {
+#if CONFIG_HAVE_ACPI_RESUME
+               debug("Resume from S3 detected.\n");
+               boot_mode = PEI_BOOT_RESUME;
+               /* Clear SLP_TYPE. This will break stage2 but
+                * we care for that when we get there.
+                */
+               outl(pm1_cnt & ~(7 << 10), DEFAULT_PMBASE + PM1_CNT);
+#else
+               debug("Resume from S3 detected, but disabled.\n");
+#endif
+       } else {
+               /*
+                * TODO: An indication of life might be possible here (e.g.
+                * keyboard light)
+                */
+       }
+       post_code(POST_EARLY_INIT);
+
+       /* Enable SPD ROMs and DDR-III DRAM */
+       ret = enable_smbus();
+       if (ret)
+               return ret;
+

arch/x86/cpu/ivybridge/cpu.c int print_cpuinfo(void) · line 345

Quoted 10 lines
arch/x86/cpu/ivybridge/cpu.c +10 -0
+       /* Prepare USB controller early in S3 resume */
+       if (boot_mode == PEI_BOOT_RESUME)
+               enable_usb_bar();
+
+       gd->arch.pei_boot_mode = boot_mode;
+
+       /* TODO: Move this to the board or driver */
+       pci_write_config32(PCH_LPC_DEV, GPIO_BASE, DEFAULT_GPIOBASE | 1);
+       pci_write_config32(PCH_LPC_DEV, GPIO_CNTL, 0x10);
+

Are these additional initialization needed right here? Can they be moved to somewhere else, so that print_cpuinfo() is just doing its job of printing cpu information?

arch/x86/cpu/ivybridge/cpu.c int print_cpuinfo(void) · line 353

Quoted 8 lines
arch/x86/cpu/ivybridge/cpu.c +2 -0
        /* Print processor name */
        name = cpu_get_name(processor_name);
        printf("CPU:   %s\n", name);
 
+       post_code(POST_CPU_INFO);
+
        return 0;
 }

[snip]

Regards,
Bin

#83 lore raw

PATCH 34/39 x86: ivybridge: Add early init for PCH devices

Hi Bin,

Quoted 211 lines · Bin Meng

Hi Simon,

Quoted 208 lines · Simon Glass

Many PCH devices are hard-coded to a particular PCI address. Set these up early in case they are needed.

---

 arch/x86/cpu/ivybridge/Makefile                   |   1 +
 arch/x86/cpu/ivybridge/cpu.c                      | 142 +++++++++++++++++++++
 arch/x86/cpu/ivybridge/early_init.c               | 145 ++++++++++++++++++++++
 arch/x86/include/asm/arch-ivybridge/pch.h         | 121 +++++++++++++++++-
 arch/x86/include/asm/arch-ivybridge/sandybridge.h | 107 ++++++++++++++++
 arch/x86/include/asm/global_data.h                |   8 ++
 arch/x86/include/asm/post.h                       |   2 +
 7 files changed, 525 insertions(+), 1 deletion(-)
 create mode 100644 arch/x86/cpu/ivybridge/early_init.c
 create mode 100644 arch/x86/include/asm/arch-ivybridge/sandybridge.h
arch/x86/cpu/ivybridge/Makefile +1 -0
index a3ea566..4bfb03a 100644
@@ -6,6 +6,7 @@
 
 obj-y += car.o
 obj-y += cpu.o
+obj-y += early_init.o
 obj-y += lpc.o
 obj-y += microcode_intel.o
 obj-y += sdram.o
arch/x86/cpu/ivybridge/cpu.c +136 -0
index bd2660f..a435520 100644
@@ -4,6 +4,7 @@
  * Graeme Russ, graeme.russ at gmail.com.
  *
  * Some portions from coreboot src/mainboard/google/link/romstage.c
+ * and src/cpu/intel/model_206ax/bootblock.c
  * Copyright (C) 2007-2010 coresystems GmbH
  * Copyright (C) 2011 Google Inc.
  *
@@ -16,11 +17,13 @@
 #include <asm/io.h>
 #include <asm/msr.h>
 #include <asm/mtrr.h>
+#include <asm/pci.h>
 #include <asm/post.h>
 #include <asm/processor.h>
 #include <asm/arch/model_206ax.h>
 #include <asm/arch/microcode.h>
 #include <asm/arch/pch.h>
+#include <asm/arch/sandybridge.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -178,6 +181,83 @@ int arch_cpu_init(void)
        return 0;
 }
 
+static int enable_smbus(void)
+{
+       pci_dev_t dev;
+       uint16_t value;
+
+       /* Set the SMBus device statically. */
+       dev = PCI_BDF(0x0, 0x1f, 0x3);
+
+       /* Check to make sure we've got the right device. */
+       value = pci_read_config16(dev, 0x0);
+       if (value != 0x8086) {
+               printf("SMBus controller not found\n");
+               return -ENOSYS;
+       }
+
+       /* Set SMBus I/O base. */
+       pci_write_config32(dev, SMB_BASE,
+                          SMBUS_IO_BASE | PCI_BASE_ADDRESS_SPACE_IO);
+
+       /* Set SMBus enable. */
+       pci_write_config8(dev, HOSTC, HST_EN);
+
+       /* Set SMBus I/O space enable. */
+       pci_write_config16(dev, PCI_COMMAND, PCI_COMMAND_IO);
+
+       /* Disable interrupt generation. */
+       outb(0, SMBUS_IO_BASE + SMBHSTCTL);
+
+       /* Clear any lingering errors, so transactions can run. */
+       outb(inb(SMBUS_IO_BASE + SMBHSTSTAT), SMBUS_IO_BASE + SMBHSTSTAT);
+       debug("SMBus controller enabled\n");
+
+       return 0;
+}
+
+#define PCH_EHCI0_TEMP_BAR0 0xe8000000
+#define PCH_EHCI1_TEMP_BAR0 0xe8000400
+#define PCH_XHCI_TEMP_BAR0  0xe8001000
+
+/*
+ * Setup USB controller MMIO BAR to prevent the reference code from
+ * resetting the controller.
+ *
+ * The BAR will be re-assigned during device enumeration so these are only
+ * temporary.
+ *
+ * This is used to speed up the resume path.
+ */
+static void enable_usb_bar(void)
+{
+       pci_dev_t usb0 = PCH_EHCI1_DEV;
+       pci_dev_t usb1 = PCH_EHCI2_DEV;
+       pci_dev_t usb3 = PCH_XHCI_DEV;
+       u32 cmd;
+
+       /* USB Controller 1 */
+       pci_write_config32(usb0, PCI_BASE_ADDRESS_0,
+                          PCH_EHCI0_TEMP_BAR0);
+       cmd = pci_read_config32(usb0, PCI_COMMAND);
+       cmd |= PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
+       pci_write_config32(usb0, PCI_COMMAND, cmd);
+
+       /* USB Controller 1 */
+       pci_write_config32(usb1, PCI_BASE_ADDRESS_0,
+                          PCH_EHCI1_TEMP_BAR0);
+       cmd = pci_read_config32(usb1, PCI_COMMAND);
+       cmd |= PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
+       pci_write_config32(usb1, PCI_COMMAND, cmd);
+
+       /* USB3 Controller */
+       pci_write_config32(usb3, PCI_BASE_ADDRESS_0,
+                          PCH_XHCI_TEMP_BAR0);
+       cmd = pci_read_config32(usb3, PCI_COMMAND);
+       cmd |= PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
+       pci_write_config32(usb3, PCI_COMMAND, cmd);
+}
+
 static int report_bist_failure(void)
 {
        if (gd->arch.bist != 0) {
@@ -190,8 +270,11 @@ static int report_bist_failure(void)
 
 int print_cpuinfo(void)
 {
+       enum pei_boot_mode_t boot_mode = PEI_BOOT_NONE;
        char processor_name[CPU_MAX_NAME_LEN];
        const char *name;
+       uint32_t pm1_cnt;
+       uint16_t pm1_sts;
        int ret;
 
        /* Halt if there was a built in self test failure */
@@ -203,9 +286,68 @@ int print_cpuinfo(void)
        if (ret && ret != -ENOENT && ret != -EEXIST)
                return ret;
 
+       /* Enable upper 128bytes of CMOS */
+       writel(1 << 2, RCB_REG(RC));
+
+       /* TODO: cmos_post_init() */
+       if (readl(MCHBAR_REG(SSKPD)) == 0xCAFE) {
+               debug("soft reset detected\n");
+               boot_mode = PEI_BOOT_SOFT_RESET;
+
+               /* System is not happy after keyboard reset... */
+               debug("Issuing CF9 warm reset\n");
+               outb(0x6, 0xcf9);
+               cpu_hlt();
+       }
+
+       /* Early chipset init required before RAM init can work */
+       sandybridge_early_init(SANDYBRIDGE_MOBILE);
+
+       /* Check PM1_STS[15] to see if we are waking from Sx */
+       pm1_sts = inw(DEFAULT_PMBASE + PM1_STS);
+
+       /* Read PM1_CNT[12:10] to determine which Sx state */
+       pm1_cnt = inl(DEFAULT_PMBASE + PM1_CNT);
+
+       if ((pm1_sts & WAK_STS) && ((pm1_cnt >> 10) & 7) == 5) {
+#if CONFIG_HAVE_ACPI_RESUME
+               debug("Resume from S3 detected.\n");
+               boot_mode = PEI_BOOT_RESUME;
+               /* Clear SLP_TYPE. This will break stage2 but
+                * we care for that when we get there.
+                */
+               outl(pm1_cnt & ~(7 << 10), DEFAULT_PMBASE + PM1_CNT);
+#else
+               debug("Resume from S3 detected, but disabled.\n");
+#endif
+       } else {
+               /*
+                * TODO: An indication of life might be possible here (e.g.
+                * keyboard light)
+                */
+       }
+       post_code(POST_EARLY_INIT);
+
+       /* Enable SPD ROMs and DDR-III DRAM */
+       ret = enable_smbus();
+       if (ret)
+               return ret;
+
+       /* Prepare USB controller early in S3 resume */
+       if (boot_mode == PEI_BOOT_RESUME)
+               enable_usb_bar();
+
+       gd->arch.pei_boot_mode = boot_mode;
+
Quoted 8 lines

arch/x86/cpu/ivybridge/cpu.c int print_cpuinfo(void) · line 345

Quoted 4 lines
arch/x86/cpu/ivybridge/cpu.c +4 -0
+       /* TODO: Move this to the board or driver */
+       pci_write_config32(PCH_LPC_DEV, GPIO_BASE, DEFAULT_GPIOBASE | 1);
+       pci_write_config32(PCH_LPC_DEV, GPIO_CNTL, 0x10);
+

Are these additional initialization needed right here? Can they be moved to somewhere else, so that print_cpuinfo() is just doing its job of printing cpu information?

I believe it is all needed. I have already moved out quite a bit of stuff. We could add a new init function, but for now I wanted to avoid this, since the init list is generic.

Re the last bit (GPIO) it seems to have to happen here, or at least a while before the GPIOs are actually used. Otherwise they fail.

Regards,
Simon

#84 lore raw

PATCH 34/39 x86: ivybridge: Add early init for PCH devices

Hi Simon,

Quoted 223 lines · Simon Glass

Hi Bin,

Quoted 211 lines · Bin Meng

Hi Simon,

Quoted 208 lines · Simon Glass

Many PCH devices are hard-coded to a particular PCI address. Set these up early in case they are needed.

---

 arch/x86/cpu/ivybridge/Makefile                   |   1 +
 arch/x86/cpu/ivybridge/cpu.c                      | 142 +++++++++++++++++++++
 arch/x86/cpu/ivybridge/early_init.c               | 145 ++++++++++++++++++++++
 arch/x86/include/asm/arch-ivybridge/pch.h         | 121 +++++++++++++++++-
 arch/x86/include/asm/arch-ivybridge/sandybridge.h | 107 ++++++++++++++++
 arch/x86/include/asm/global_data.h                |   8 ++
 arch/x86/include/asm/post.h                       |   2 +
 7 files changed, 525 insertions(+), 1 deletion(-)
 create mode 100644 arch/x86/cpu/ivybridge/early_init.c
 create mode 100644 arch/x86/include/asm/arch-ivybridge/sandybridge.h
arch/x86/cpu/ivybridge/Makefile +1 -0
index a3ea566..4bfb03a 100644
@@ -6,6 +6,7 @@
 
 obj-y += car.o
 obj-y += cpu.o
+obj-y += early_init.o
 obj-y += lpc.o
 obj-y += microcode_intel.o
 obj-y += sdram.o
arch/x86/cpu/ivybridge/cpu.c +136 -0
index bd2660f..a435520 100644
@@ -4,6 +4,7 @@
  * Graeme Russ, graeme.russ at gmail.com.
  *
  * Some portions from coreboot src/mainboard/google/link/romstage.c
+ * and src/cpu/intel/model_206ax/bootblock.c
  * Copyright (C) 2007-2010 coresystems GmbH
  * Copyright (C) 2011 Google Inc.
  *
@@ -16,11 +17,13 @@
 #include <asm/io.h>
 #include <asm/msr.h>
 #include <asm/mtrr.h>
+#include <asm/pci.h>
 #include <asm/post.h>
 #include <asm/processor.h>
 #include <asm/arch/model_206ax.h>
 #include <asm/arch/microcode.h>
 #include <asm/arch/pch.h>
+#include <asm/arch/sandybridge.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -178,6 +181,83 @@ int arch_cpu_init(void)
        return 0;
 }
 
+static int enable_smbus(void)
+{
+       pci_dev_t dev;
+       uint16_t value;
+
+       /* Set the SMBus device statically. */
+       dev = PCI_BDF(0x0, 0x1f, 0x3);
+
+       /* Check to make sure we've got the right device. */
+       value = pci_read_config16(dev, 0x0);
+       if (value != 0x8086) {
+               printf("SMBus controller not found\n");
+               return -ENOSYS;
+       }
+
+       /* Set SMBus I/O base. */
+       pci_write_config32(dev, SMB_BASE,
+                          SMBUS_IO_BASE | PCI_BASE_ADDRESS_SPACE_IO);
+
+       /* Set SMBus enable. */
+       pci_write_config8(dev, HOSTC, HST_EN);
+
+       /* Set SMBus I/O space enable. */
+       pci_write_config16(dev, PCI_COMMAND, PCI_COMMAND_IO);
+
+       /* Disable interrupt generation. */
+       outb(0, SMBUS_IO_BASE + SMBHSTCTL);
+
+       /* Clear any lingering errors, so transactions can run. */
+       outb(inb(SMBUS_IO_BASE + SMBHSTSTAT), SMBUS_IO_BASE + SMBHSTSTAT);
+       debug("SMBus controller enabled\n");
+
+       return 0;
+}
+
+#define PCH_EHCI0_TEMP_BAR0 0xe8000000
+#define PCH_EHCI1_TEMP_BAR0 0xe8000400
+#define PCH_XHCI_TEMP_BAR0  0xe8001000
+
+/*
+ * Setup USB controller MMIO BAR to prevent the reference code from
+ * resetting the controller.
+ *
+ * The BAR will be re-assigned during device enumeration so these are only
+ * temporary.
+ *
+ * This is used to speed up the resume path.
+ */
+static void enable_usb_bar(void)
+{
+       pci_dev_t usb0 = PCH_EHCI1_DEV;
+       pci_dev_t usb1 = PCH_EHCI2_DEV;
+       pci_dev_t usb3 = PCH_XHCI_DEV;
+       u32 cmd;
+
+       /* USB Controller 1 */
+       pci_write_config32(usb0, PCI_BASE_ADDRESS_0,
+                          PCH_EHCI0_TEMP_BAR0);
+       cmd = pci_read_config32(usb0, PCI_COMMAND);
+       cmd |= PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
+       pci_write_config32(usb0, PCI_COMMAND, cmd);
+
+       /* USB Controller 1 */
+       pci_write_config32(usb1, PCI_BASE_ADDRESS_0,
+                          PCH_EHCI1_TEMP_BAR0);
+       cmd = pci_read_config32(usb1, PCI_COMMAND);
+       cmd |= PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
+       pci_write_config32(usb1, PCI_COMMAND, cmd);
+
+       /* USB3 Controller */
+       pci_write_config32(usb3, PCI_BASE_ADDRESS_0,
+                          PCH_XHCI_TEMP_BAR0);
+       cmd = pci_read_config32(usb3, PCI_COMMAND);
+       cmd |= PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
+       pci_write_config32(usb3, PCI_COMMAND, cmd);
+}
+
 static int report_bist_failure(void)
 {
        if (gd->arch.bist != 0) {
@@ -190,8 +270,11 @@ static int report_bist_failure(void)
 
 int print_cpuinfo(void)
 {
+       enum pei_boot_mode_t boot_mode = PEI_BOOT_NONE;
        char processor_name[CPU_MAX_NAME_LEN];
        const char *name;
+       uint32_t pm1_cnt;
+       uint16_t pm1_sts;
        int ret;
 
        /* Halt if there was a built in self test failure */
@@ -203,9 +286,68 @@ int print_cpuinfo(void)
        if (ret && ret != -ENOENT && ret != -EEXIST)
                return ret;
 
+       /* Enable upper 128bytes of CMOS */
+       writel(1 << 2, RCB_REG(RC));
+
+       /* TODO: cmos_post_init() */
+       if (readl(MCHBAR_REG(SSKPD)) == 0xCAFE) {
+               debug("soft reset detected\n");
+               boot_mode = PEI_BOOT_SOFT_RESET;
+
+               /* System is not happy after keyboard reset... */
+               debug("Issuing CF9 warm reset\n");
+               outb(0x6, 0xcf9);
+               cpu_hlt();
+       }
+
+       /* Early chipset init required before RAM init can work */
+       sandybridge_early_init(SANDYBRIDGE_MOBILE);
+
+       /* Check PM1_STS[15] to see if we are waking from Sx */
+       pm1_sts = inw(DEFAULT_PMBASE + PM1_STS);
+
+       /* Read PM1_CNT[12:10] to determine which Sx state */
+       pm1_cnt = inl(DEFAULT_PMBASE + PM1_CNT);
+
+       if ((pm1_sts & WAK_STS) && ((pm1_cnt >> 10) & 7) == 5) {
+#if CONFIG_HAVE_ACPI_RESUME
+               debug("Resume from S3 detected.\n");
+               boot_mode = PEI_BOOT_RESUME;
+               /* Clear SLP_TYPE. This will break stage2 but
+                * we care for that when we get there.
+                */
+               outl(pm1_cnt & ~(7 << 10), DEFAULT_PMBASE + PM1_CNT);
+#else
+               debug("Resume from S3 detected, but disabled.\n");
+#endif
+       } else {
+               /*
+                * TODO: An indication of life might be possible here (e.g.
+                * keyboard light)
+                */
+       }
+       post_code(POST_EARLY_INIT);
+
+       /* Enable SPD ROMs and DDR-III DRAM */
+       ret = enable_smbus();
+       if (ret)
+               return ret;
+
+       /* Prepare USB controller early in S3 resume */
+       if (boot_mode == PEI_BOOT_RESUME)
+               enable_usb_bar();
+
+       gd->arch.pei_boot_mode = boot_mode;
+
Quoted 8 lines

arch/x86/cpu/ivybridge/cpu.c int print_cpuinfo(void) · line 345

Quoted 4 lines
arch/x86/cpu/ivybridge/cpu.c +4 -0
+       /* TODO: Move this to the board or driver */
+       pci_write_config32(PCH_LPC_DEV, GPIO_BASE, DEFAULT_GPIOBASE | 1);
+       pci_write_config32(PCH_LPC_DEV, GPIO_CNTL, 0x10);
+

Are these additional initialization needed right here? Can they be moved to somewhere else, so that print_cpuinfo() is just doing its job of printing cpu information?

Quoted 3 lines

I believe it is all needed. I have already moved out quite a bit of stuff. We could add a new init function, but for now I wanted to avoid this, since the init list is generic.

After looking all the initialization routines in common/board_f.c, if these cannot be done in arch_cpu_init(), could we move them to board_early_init_f()?

Quoted 5 lines

Re the last bit (GPIO) it seems to have to happen here, or at least a while before the GPIOs are actually used. Otherwise they fail.

Regards,
Simon

Regards,
Bin

#85 lore raw

PATCH 34/39 x86: ivybridge: Add early init for PCH devices

Hi Bin,

Quoted 226 lines · Bin Meng

Hi Simon,

Quoted 223 lines · Simon Glass

Hi Bin,

Quoted 219 lines · Bin Meng

Hi Simon,

Quoted 202 lines · Simon Glass

Many PCH devices are hard-coded to a particular PCI address. Set these up early in case they are needed.

---

 arch/x86/cpu/ivybridge/Makefile                   |   1 +
 arch/x86/cpu/ivybridge/cpu.c                      | 142 +++++++++++++++++++++
 arch/x86/cpu/ivybridge/early_init.c               | 145 ++++++++++++++++++++++
 arch/x86/include/asm/arch-ivybridge/pch.h         | 121 +++++++++++++++++-
 arch/x86/include/asm/arch-ivybridge/sandybridge.h | 107 ++++++++++++++++
 arch/x86/include/asm/global_data.h                |   8 ++
 arch/x86/include/asm/post.h                       |   2 +
 7 files changed, 525 insertions(+), 1 deletion(-)
 create mode 100644 arch/x86/cpu/ivybridge/early_init.c
 create mode 100644 arch/x86/include/asm/arch-ivybridge/sandybridge.h
arch/x86/cpu/ivybridge/Makefile +1 -0
index a3ea566..4bfb03a 100644
@@ -6,6 +6,7 @@
 
 obj-y += car.o
 obj-y += cpu.o
+obj-y += early_init.o
 obj-y += lpc.o
 obj-y += microcode_intel.o
 obj-y += sdram.o
arch/x86/cpu/ivybridge/cpu.c +130 -0
index bd2660f..a435520 100644
@@ -4,6 +4,7 @@
  * Graeme Russ, graeme.russ at gmail.com.
  *
  * Some portions from coreboot src/mainboard/google/link/romstage.c
+ * and src/cpu/intel/model_206ax/bootblock.c
  * Copyright (C) 2007-2010 coresystems GmbH
  * Copyright (C) 2011 Google Inc.
  *
@@ -16,11 +17,13 @@
 #include <asm/io.h>
 #include <asm/msr.h>
 #include <asm/mtrr.h>
+#include <asm/pci.h>
 #include <asm/post.h>
 #include <asm/processor.h>
 #include <asm/arch/model_206ax.h>
 #include <asm/arch/microcode.h>
 #include <asm/arch/pch.h>
+#include <asm/arch/sandybridge.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -178,6 +181,83 @@ int arch_cpu_init(void)
        return 0;
 }
 
+static int enable_smbus(void)
+{
+       pci_dev_t dev;
+       uint16_t value;
+
+       /* Set the SMBus device statically. */
+       dev = PCI_BDF(0x0, 0x1f, 0x3);
+
+       /* Check to make sure we've got the right device. */
+       value = pci_read_config16(dev, 0x0);
+       if (value != 0x8086) {
+               printf("SMBus controller not found\n");
+               return -ENOSYS;
+       }
+
+       /* Set SMBus I/O base. */
+       pci_write_config32(dev, SMB_BASE,
+                          SMBUS_IO_BASE | PCI_BASE_ADDRESS_SPACE_IO);
+
+       /* Set SMBus enable. */
+       pci_write_config8(dev, HOSTC, HST_EN);
+
+       /* Set SMBus I/O space enable. */
+       pci_write_config16(dev, PCI_COMMAND, PCI_COMMAND_IO);
+
+       /* Disable interrupt generation. */
+       outb(0, SMBUS_IO_BASE + SMBHSTCTL);
+
+       /* Clear any lingering errors, so transactions can run. */
+       outb(inb(SMBUS_IO_BASE + SMBHSTSTAT), SMBUS_IO_BASE + SMBHSTSTAT);
+       debug("SMBus controller enabled\n");
+
+       return 0;
+}
+
+#define PCH_EHCI0_TEMP_BAR0 0xe8000000
+#define PCH_EHCI1_TEMP_BAR0 0xe8000400
+#define PCH_XHCI_TEMP_BAR0  0xe8001000
+
+/*
+ * Setup USB controller MMIO BAR to prevent the reference code from
+ * resetting the controller.
+ *
+ * The BAR will be re-assigned during device enumeration so these are only
+ * temporary.
+ *
+ * This is used to speed up the resume path.
+ */
+static void enable_usb_bar(void)
+{
+       pci_dev_t usb0 = PCH_EHCI1_DEV;
+       pci_dev_t usb1 = PCH_EHCI2_DEV;
+       pci_dev_t usb3 = PCH_XHCI_DEV;
+       u32 cmd;
+
+       /* USB Controller 1 */
+       pci_write_config32(usb0, PCI_BASE_ADDRESS_0,
+                          PCH_EHCI0_TEMP_BAR0);
+       cmd = pci_read_config32(usb0, PCI_COMMAND);
+       cmd |= PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
+       pci_write_config32(usb0, PCI_COMMAND, cmd);
+
+       /* USB Controller 1 */
+       pci_write_config32(usb1, PCI_BASE_ADDRESS_0,
+                          PCH_EHCI1_TEMP_BAR0);
+       cmd = pci_read_config32(usb1, PCI_COMMAND);
+       cmd |= PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
+       pci_write_config32(usb1, PCI_COMMAND, cmd);
+
+       /* USB3 Controller */
+       pci_write_config32(usb3, PCI_BASE_ADDRESS_0,
+                          PCH_XHCI_TEMP_BAR0);
+       cmd = pci_read_config32(usb3, PCI_COMMAND);
+       cmd |= PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
+       pci_write_config32(usb3, PCI_COMMAND, cmd);
+}
+
 static int report_bist_failure(void)
 {
        if (gd->arch.bist != 0) {
@@ -190,8 +270,11 @@ static int report_bist_failure(void)
 
 int print_cpuinfo(void)
 {
+       enum pei_boot_mode_t boot_mode = PEI_BOOT_NONE;
        char processor_name[CPU_MAX_NAME_LEN];
        const char *name;
+       uint32_t pm1_cnt;
+       uint16_t pm1_sts;
        int ret;
 
        /* Halt if there was a built in self test failure */
@@ -203,9 +286,68 @@ int print_cpuinfo(void)
        if (ret && ret != -ENOENT && ret != -EEXIST)
                return ret;
 
+       /* Enable upper 128bytes of CMOS */
+       writel(1 << 2, RCB_REG(RC));
+
+       /* TODO: cmos_post_init() */
+       if (readl(MCHBAR_REG(SSKPD)) == 0xCAFE) {
+               debug("soft reset detected\n");
+               boot_mode = PEI_BOOT_SOFT_RESET;
+
+               /* System is not happy after keyboard reset... */
+               debug("Issuing CF9 warm reset\n");
+               outb(0x6, 0xcf9);
+               cpu_hlt();
+       }
+
+       /* Early chipset init required before RAM init can work */
+       sandybridge_early_init(SANDYBRIDGE_MOBILE);
+
+       /* Check PM1_STS[15] to see if we are waking from Sx */
+       pm1_sts = inw(DEFAULT_PMBASE + PM1_STS);
+
+       /* Read PM1_CNT[12:10] to determine which Sx state */
+       pm1_cnt = inl(DEFAULT_PMBASE + PM1_CNT);
+
+       if ((pm1_sts & WAK_STS) && ((pm1_cnt >> 10) & 7) == 5) {
+#if CONFIG_HAVE_ACPI_RESUME
+               debug("Resume from S3 detected.\n");
+               boot_mode = PEI_BOOT_RESUME;
+               /* Clear SLP_TYPE. This will break stage2 but
+                * we care for that when we get there.
+                */
+               outl(pm1_cnt & ~(7 << 10), DEFAULT_PMBASE + PM1_CNT);
+#else
+               debug("Resume from S3 detected, but disabled.\n");
+#endif
+       } else {
+               /*
+                * TODO: An indication of life might be possible here (e.g.
+                * keyboard light)
+                */
+       }
+       post_code(POST_EARLY_INIT);
+
+       /* Enable SPD ROMs and DDR-III DRAM */
+       ret = enable_smbus();
+       if (ret)
+               return ret;
+

arch/x86/cpu/ivybridge/cpu.c int print_cpuinfo(void) · line 345

Quoted 10 lines
arch/x86/cpu/ivybridge/cpu.c +10 -0
+       /* Prepare USB controller early in S3 resume */
+       if (boot_mode == PEI_BOOT_RESUME)
+               enable_usb_bar();
+
+       gd->arch.pei_boot_mode = boot_mode;
+
+       /* TODO: Move this to the board or driver */
+       pci_write_config32(PCH_LPC_DEV, GPIO_BASE, DEFAULT_GPIOBASE | 1);
+       pci_write_config32(PCH_LPC_DEV, GPIO_CNTL, 0x10);
+

Are these additional initialization needed right here? Can they be moved to somewhere else, so that print_cpuinfo() is just doing its job of printing cpu information?

Quoted 7 lines
Quoted 3 lines

I believe it is all needed. I have already moved out quite a bit of stuff. We could add a new init function, but for now I wanted to avoid this, since the init list is generic.

After looking all the initialization routines in common/board_f.c, if these cannot be done in arch_cpu_init(), could we move them to board_early_init_f()?

I feel that this is not board init, but arch init. As you say, arch_cpu_init() should do the minimum. We could add a new arch_lnit() or similar, but I don't want to add another init function. I hope to fire up driver model for PCI and use that. But for now, this way seems reasonable.

Regards,
Simon

#86 lore raw

PATCH 35/39 x86: ivybridge: Add support for early GPIO init

In reply to Simon Glass

When not relying on Coreboot for GPIO init the GPIOs must be set up correctly. This is currently done statically through a rather ugly method. As the GPIOs are figured out they can be moved to the device tree and set up as needed rather than all at the start.

In this implementation, board files should call ich_gpio_set_gpio_map() before the GPIO driver is used in order to provide the GPIO information. We use the early PCI interface so that this driver can now be used before relocation.

---

 arch/x86/include/asm/arch-coreboot/gpio.h |   5 --
 arch/x86/include/asm/arch-ivybridge/pch.h |  16 ++++
 arch/x86/include/asm/global_data.h        |   1 +
 arch/x86/include/asm/gpio.h               | 142 +++++++++++++++++++++++++++++-
 drivers/gpio/intel_ich6_gpio.c            |  79 ++++++++++++++---
 5 files changed, 227 insertions(+), 16 deletions(-)
arch/x86/include/asm/arch-coreboot/gpio.h +0 -5
index 3ec1816..4951a8c 100644
@@ -7,9 +7,4 @@
 #ifndef _X86_ARCH_GPIO_H_
 #define _X86_ARCH_GPIO_H_
 
-struct ich6_bank_platdata {
-	uint32_t base_addr;
-	const char *bank_name;
-};
-
 #endif /* _X86_ARCH_GPIO_H_ */
arch/x86/include/asm/arch-ivybridge/pch.h +16 -0
index 290a737..ae338e3 100644
@@ -142,6 +142,22 @@
 #define FD2		0x3428	/* 32bit */
 #define CG		0x341c	/* 32bit */
 
+/* ICH7 GPIOBASE */
+#define GPIO_USE_SEL	0x00
+#define GP_IO_SEL	0x04
+#define GP_LVL		0x0c
+#define GPO_BLINK	0x18
+#define GPI_INV		0x2c
+#define GPIO_USE_SEL2	0x30
+#define GP_IO_SEL2	0x34
+#define GP_LVL2		0x38
+#define GPIO_USE_SEL3	0x40
+#define GP_IO_SEL3	0x44
+#define GP_LVL3		0x48
+#define GP_RST_SEL1	0x60
+#define GP_RST_SEL2	0x64
+#define GP_RST_SEL3	0x68
+
 /* ICH7 PMBASE */
 #define PM1_STS		0x00
 #define   WAK_STS	(1 << 15)
arch/x86/include/asm/global_data.h +1 -0
index c60deda..351581b 100644
@@ -27,6 +27,7 @@ struct arch_global_data {
 	uint32_t bist;			/* Built-in self test value */
 	struct pci_controller *hose;	/* PCI hose for early use */
 	enum pei_boot_mode_t pei_boot_mode;
+	const struct pch_gpio_map *gpio_map;	/* board GPIO map */
 };
 
 #endif
arch/x86/include/asm/gpio.h +141 -1

153 lines not on this page · raw message

drivers/gpio/intel_ich6_gpio.c +69 -10

154 lines not on this page · raw message

Signature · 1 line
2.1.0.rc2.206.gedb03e5
#87 lore raw

PATCH 36/39 x86: chromebook_link: Enable GPIO support

In reply to Simon Glass

Enable GPIO support and provide the required GPIO setup information to the driver.

---

 arch/x86/dts/link.dts               |   3 +
 board/google/chromebook_link/link.c | 107 ++++++++++++++++++++++++++++++++++++
 include/configs/chromebook_link.h   |   4 +-
 3 files changed, 111 insertions(+), 3 deletions(-)
arch/x86/dts/link.dts +3 -0
index ea4b0ba..84fb0a9 100644
@@ -14,18 +14,21 @@
 
 	gpioa {
 		compatible = "intel,ich6-gpio";
+		u-boot,dm-pre-reloc;
 		reg = <0 0x10>;
 		bank-name = "A";
 	};
 
 	gpiob {
 		compatible = "intel,ich6-gpio";
+		u-boot,dm-pre-reloc;
 		reg = <0x30 0x10>;
 		bank-name = "B";
 	};
 
 	gpioc {
 		compatible = "intel,ich6-gpio";
+		u-boot,dm-pre-reloc;
 		reg = <0x40 0x10>;
 		bank-name = "C";
 	};
board/google/chromebook_link/link.c +107 -0

116 lines not on this page · raw message

include/configs/chromebook_link.h +1 -3
index 5290814..637bdb9 100644
@@ -19,6 +19,7 @@
 #define CONFIG_SYS_CAR_SIZE			(128 * 1024)
 #define CONFIG_SYS_MONITOR_LEN			(1 << 20)
 #define CONFIG_SYS_X86_START16			0xfffff800
+#define CONFIG_BOARD_EARLY_INIT_F
 #define CONFIG_BOARD_EARLY_INIT_R
 
 #define CONFIG_X86_RESET_VECTOR
@@ -29,9 +30,6 @@
  * follow-on patches in this series. Add undefs here to avoid every patch
  * having to put things back into x86-common.h
  */
-#undef CONFIG_INTEL_ICH6_GPIO
-#undef CONFIG_DM_GPIO
-#undef CONFIG_CMD_GPIO
 #undef CONFIG_CROS_EC
 #undef CONFIG_CROS_EC_LPC
 #undef CONFIG_CMD_CROS_EC
Signature · 1 line
2.1.0.rc2.206.gedb03e5
#88 lore raw

PATCH 37/39 x86: Make show_boot_progress() common

In reply to Simon Glass

This function can probably be used on all x86 boards, so move it into the common file.

---

 arch/x86/cpu/coreboot/coreboot.c | 24 ------------------------
 arch/x86/cpu/cpu.c               | 24 ++++++++++++++++++++++++
 2 files changed, 24 insertions(+), 24 deletions(-)
arch/x86/cpu/coreboot/coreboot.c +0 -24
index 41c3936..8295b0e 100644
@@ -15,7 +15,6 @@
 #include <asm/cache.h>
 #include <asm/cpu.h>
 #include <asm/io.h>
-#include <asm/post.h>
 #include <asm/arch/tables.h>
 #include <asm/arch/sysinfo.h>
 #include <asm/arch/timestamp.h>
@@ -49,29 +48,6 @@ int board_early_init_r(void)
 	return 0;
 }
 
-void show_boot_progress(int val)
-{
-#if MIN_PORT80_KCLOCKS_DELAY
-	/*
-	 * Scale the time counter reading to avoid using 64 bit arithmetics.
-	 * Can't use get_timer() here becuase it could be not yet
-	 * initialized or even implemented.
-	 */
-	if (!gd->arch.tsc_prev) {
-		gd->arch.tsc_base_kclocks = rdtsc() / 1000;
-		gd->arch.tsc_prev = 0;
-	} else {
-		uint32_t now;
-
-		do {
-			now = rdtsc() / 1000 - gd->arch.tsc_base_kclocks;
-		} while (now < (gd->arch.tsc_prev + MIN_PORT80_KCLOCKS_DELAY));
-		gd->arch.tsc_prev = now;
-	}
-#endif
-	outb(val, POST_PORT);
-}
-
 int last_stage_init(void)
 {
 	if (gd->flags & GD_FLG_COLD_BOOT)
arch/x86/cpu/cpu.c +24 -0
index 61c198e..7ab2570 100644
@@ -22,6 +22,7 @@
 #include <malloc.h>
 #include <asm/control_regs.h>
 #include <asm/cpu.h>
+#include <asm/post.h>
 #include <asm/processor.h>
 #include <asm/processor-flags.h>
 #include <asm/interrupt.h>
@@ -400,3 +401,26 @@ char *cpu_get_name(char *name)
 
 	return ptr;
 }
+
+void show_boot_progress(int val)
+{
+#if MIN_PORT80_KCLOCKS_DELAY
+	/*
+	 * Scale the time counter reading to avoid using 64 bit arithmetics.
+	 * Can't use get_timer() here becuase it could be not yet
+	 * initialized or even implemented.
+	 */
+	if (!gd->arch.tsc_prev) {
+		gd->arch.tsc_base_kclocks = rdtsc() / 1000;
+		gd->arch.tsc_prev = 0;
+	} else {
+		uint32_t now;
+
+		do {
+			now = rdtsc() / 1000 - gd->arch.tsc_base_kclocks;
+		} while (now < (gd->arch.tsc_prev + MIN_PORT80_KCLOCKS_DELAY));
+		gd->arch.tsc_prev = now;
+	}
+#endif
+	outb(val, POST_PORT);
+}
Signature · 1 line
2.1.0.rc2.206.gedb03e5
#89 lore raw

PATCH 38/39 x86: ivybridge: Add LAPIC support

In reply to Simon Glass

The local advanced programmable interrupt controller is not used much in U-Boot but we do need to set it up. Add basic support for this, which will be extended as needed.

---

 arch/x86/cpu/ivybridge/cpu.c     |   3 ++
 arch/x86/include/asm/lapic.h     |  59 +++++++++++++++++++++++
 arch/x86/include/asm/lapic_def.h | 101 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 163 insertions(+)
 create mode 100644 arch/x86/include/asm/lapic.h
 create mode 100644 arch/x86/include/asm/lapic_def.h
arch/x86/cpu/ivybridge/cpu.c +3 -0
index a435520..831dd8c 100644
@@ -15,6 +15,7 @@
 #include <errno.h>
 #include <fdtdec.h>
 #include <asm/io.h>
+#include <asm/lapic.h>
 #include <asm/msr.h>
 #include <asm/mtrr.h>
 #include <asm/pci.h>
@@ -282,6 +283,8 @@ int print_cpuinfo(void)
 	if (ret)
 		return ret;
 
+	enable_lapic();
+
 	ret = microcode_update_intel();
 	if (ret && ret != -ENOENT && ret != -EEXIST)
 		return ret;
arch/x86/include/asm/lapic.h new file +59 -0

59 lines not on this page · raw message

arch/x86/include/asm/lapic_def.h new file +101 -0

101 lines not on this page · raw message

Signature · 1 line
2.1.0.rc2.206.gedb03e5
#90 lore raw

PATCH 39/39 x86: ivybridge: Implement SDRAM init

In reply to Simon Glass

Implement SDRAM init using the Memory Reference Code (mrc.bin) provided in the board directory and the SDRAM SPD information in the device tree. This also needs the Intel Management Engine (me.bin) to work. Binary blobs
everywhere: so far we have MRC, ME and microcode.

SDRAM init works by setting up various parameters and calling the MRC. This in turn does some sort of magic to work out how much memory there is and the timing parameters to use. It also sets up the DRAM controllers. When the MRC returns, we use the information it provides to map out the available memory in U-Boot.

U-Boot normally moves itself to the top of RAM. On x86 the RAM is not generally contiguous, and anyway some RAM may be above 4GB which doesn't work in 32-bit mode. So we relocate to the top of the largest block of RAM we can find below 4GB. Memory above 4GB is accessible with special functions (see physmem).

It would be possible to build U-Boot in 64-bit mode but this wouldn't necessarily provide any more memory, since the largest block is often below 4GB. Anyway U-Boot doesn't need huge amounts of memory - even a very large ramdisk seldom exceeds 100-200MB. U-Boot has support for booting 64-bit kernels directly so this does not pose a limitation in that area. Also there are probably parts of U-Boot that will not work correctly in 64-bit mode. The MRC is one.

There is some work remaining in this area. Since memory init is very slow (over 500ms) it is possible to save the parameters in SPI flash to speed it up next time. Suspend/resume support is not fully implemented, or at least it is not efficient.

With this patch, link boots to a prompt.

---

 Makefile                                          |   5 +
 arch/x86/Kconfig                                  |  11 +
 arch/x86/cpu/ivybridge/Makefile                   |   3 +
 arch/x86/cpu/ivybridge/early_me.c                 | 191 ++++++++
 arch/x86/cpu/ivybridge/me_status.c                | 195 ++++++++
 arch/x86/cpu/ivybridge/report_platform.c          |  98 ++++
 arch/x86/cpu/ivybridge/sdram.c                    | 553 +++++++++++++++++++++-
 arch/x86/cpu/start.S                              |  10 +-
 arch/x86/dts/link.dts                             | 111 +++++
 arch/x86/include/asm/arch-ivybridge/me.h          | 357 ++++++++++++++
 arch/x86/include/asm/arch-ivybridge/pch.h         | 113 +++++
 arch/x86/include/asm/arch-ivybridge/pei_data.h    | 121 +++++
 arch/x86/include/asm/arch-ivybridge/sandybridge.h |   2 +
 arch/x86/include/asm/config.h                     |   1 +
 arch/x86/include/asm/global_data.h                |  13 +
 arch/x86/include/asm/post.h                       |   5 +
 arch/x86/include/asm/u-boot-x86.h                 |   2 +
 arch/x86/lib/Makefile                             |   1 +
 arch/x86/lib/ramtest.c                            |  79 ++++
 include/configs/chromebook_link.h                 |   5 +
 include/configs/x86-common.h                      |   2 +-
 include/fdtdec.h                                  |   1 +
 lib/fdtdec.c                                      |   1 +
 23 files changed, 1874 insertions(+), 6 deletions(-)
 create mode 100644 arch/x86/cpu/ivybridge/early_me.c
 create mode 100644 arch/x86/cpu/ivybridge/me_status.c
 create mode 100644 arch/x86/cpu/ivybridge/report_platform.c
 create mode 100644 arch/x86/include/asm/arch-ivybridge/me.h
 create mode 100644 arch/x86/include/asm/arch-ivybridge/pei_data.h
 create mode 100644 arch/x86/lib/ramtest.c
Makefile +5 -0
index 86d0510..4f0260f 100644
@@ -956,9 +956,14 @@ u-boot.rom: u-boot-x86-16bit.bin u-boot-dtb.bin \
 		$(srctree)/board/$(BOARDDIR)/descriptor.bin
 	$(objtree)/tools/ifdtool -c -r $(CONFIG_ROM_SIZE) \
 		-D $(srctree)/board/$(BOARDDIR)/descriptor.bin u-boot.tmp
+	$(objtree)/tools/ifdtool \
+		-i ME:$(srctree)/board/$(BOARDDIR)/me.bin u-boot.tmp
 	$(objtree)/tools/ifdtool -w \
 		$(CONFIG_SYS_TEXT_BASE):$(objtree)/u-boot-dtb.bin u-boot.tmp
 	$(objtree)/tools/ifdtool -w \
+		$(CONFIG_X86_MRC_START):$(srctree)/board/$(BOARDDIR)/mrc.bin \
+		u-boot.tmp
+	$(objtree)/tools/ifdtool -w \
 		$(CONFIG_SYS_X86_START16):$(objtree)/u-boot-x86-16bit.bin \
 		u-boot.tmp
 	mv u-boot.tmp $@
arch/x86/Kconfig +11 -0
index 73fe8b2..e992610 100644
@@ -50,6 +50,17 @@ config CPU_ADDR_BITS
 	int
 	default 36
 
+config HPET_ADDRESS
+	hex
+	default 0xfed00000 if !HPET_ADDRESS_OVERRIDE
+
+config SMM_TSEG
+	bool
+	default n
+
+config SMM_TSEG_SIZE
+	hex
+
 config ROM_SIZE
 	hex
 	default 0x800000
arch/x86/cpu/ivybridge/Makefile +3 -0
index 4bfb03a..6669a6f 100644
@@ -7,6 +7,9 @@
 obj-y += car.o
 obj-y += cpu.o
 obj-y += early_init.o
+obj-y += early_me.o
 obj-y += lpc.o
+obj-y += me_status.o
+obj-y += report_platform.o
 obj-y += microcode_intel.o
 obj-y += sdram.o
arch/x86/cpu/ivybridge/early_me.c new file +191 -0

191 lines not on this page · raw message

arch/x86/cpu/ivybridge/me_status.c new file +195 -0

195 lines not on this page · raw message

arch/x86/cpu/ivybridge/report_platform.c new file +98 -0

98 lines not on this page · raw message

arch/x86/cpu/ivybridge/sdram.c +552 -1

562 lines not on this page · raw message

arch/x86/cpu/start.S +6 -4
index f62ffeb..4e973f1 100644
@@ -94,20 +94,22 @@ car_init_ret:
 	 * We now have CONFIG_SYS_CAR_SIZE bytes of Cache-As-RAM (or SRAM,
 	 * or fully initialised SDRAM - we really don't care which)
 	 * starting at CONFIG_SYS_CAR_ADDR to be used as a temporary stack
-	 * and early malloc area.
+	 * and early malloc area. The MRC requires some space at the top.
 	 *
 	 * Stack grows down from top of CAR. We have:
 	 *
 	 * top-> CONFIG_SYS_CAR_ADDR + CONFIG_SYS_CAR_SIZE
+	 *	MRC area
 	 *	global_data
 	 *	x86 global descriptor table
 	 *	early malloc area
 	 *	stack
 	 * bottom-> CONFIG_SYS_CAR_ADDR
 	 */
-
-	/* Stack grows down from top of CAR */
-	movl	$(CONFIG_SYS_CAR_ADDR + CONFIG_SYS_CAR_SIZE), %esp
+	movl	$(CONFIG_SYS_CAR_ADDR + CONFIG_SYS_CAR_SIZE - 4), %esp
+#ifdef CONFIG_DCACHE_RAM_MRC_VAR_SIZE
+	subl	CONFIG_DCACHE_RAM_MRC_VAR_SIZE, %esp
+#endif
 
 	/* Reserve space on stack for global data */
 	subl	$GENERATED_GBL_DATA_SIZE, %esp
arch/x86/dts/link.dts +111 -0

117 lines not on this page · raw message

arch/x86/include/asm/arch-ivybridge/me.h new file +357 -0

357 lines not on this page · raw message

arch/x86/include/asm/arch-ivybridge/pch.h +113 -0

137 lines not on this page · raw message

arch/x86/include/asm/arch-ivybridge/pei_data.h new file +121 -0

121 lines not on this page · raw message

arch/x86/include/asm/arch-ivybridge/sandybridge.h +2 -0
index a1072f2..114ee19 100644
@@ -102,6 +102,8 @@
 #define SSKPD		0x5d14	/* 16bit (scratchpad) */
 #define BIOS_RESET_CPL	0x5da8	/* 8bit */
 
+void report_platform_info(void);
+
 void sandybridge_early_init(int chipset_type);
 
 #endif
arch/x86/include/asm/config.h +1 -0
index ff15828..c97d988 100644
@@ -10,5 +10,6 @@
 #define CONFIG_SYS_GENERIC_BOARD
 #define CONFIG_LMB
 #define CONFIG_SYS_BOOT_RAMDISK_HIGH
+#define asmlinkage __attribute__((regparm(0)))
 
 #endif
arch/x86/include/asm/global_data.h +13 -0
index 351581b..80bc3e8 100644
@@ -17,6 +17,18 @@ enum pei_boot_mode_t {
 
 };
 
+struct memory_area {
+	uint64_t start;
+	uint64_t size;
+};
+
+struct memory_info {
+	int num_areas;
+	uint64_t total_memory;
+	uint64_t total_32bit_memory;
+	struct memory_area area[CONFIG_NR_DRAM_BANKS];
+};
+
 /* Architecture-specific global data */
 struct arch_global_data {
 	struct global_data *gd_addr;		/* Location of Global Data */
@@ -28,6 +40,7 @@ struct arch_global_data {
 	struct pci_controller *hose;	/* PCI hose for early use */
 	enum pei_boot_mode_t pei_boot_mode;
 	const struct pch_gpio_map *gpio_map;	/* board GPIO map */
+	struct memory_info meminfo;	/* Memory information */
 };
 
 #endif
arch/x86/include/asm/post.h +5 -0
index 61dcda1..ce68839 100644
@@ -27,6 +27,11 @@
 #define POST_CPU_INIT		0x2b
 #define POST_EARLY_INIT		0x2c
 #define POST_CPU_INFO		0x2d
+#define POST_PRE_MRC		0x2e
+#define POST_MRC		0x2f
+#define POST_DRAM		0x2f
+
+#define POST_RAM_FAILURE	0xea
 
 /* Output a post code using al - value must be 0 to 0xff */
 #ifdef __ASSEMBLY__
arch/x86/include/asm/u-boot-x86.h +2 -0
index 6404cd3..f20e5b5 100644
@@ -72,4 +72,6 @@ static inline __attribute__((no_instrument_function)) uint64_t rdtsc(void)
 void timer_set_tsc_base(uint64_t new_base);
 uint64_t timer_get_tsc(void);
 
+void quick_ram_check(void);
+
 #endif	/* _U_BOOT_I386_H_ */
arch/x86/lib/Makefile +1 -0
index 25b672a..d0c7f30 100644
@@ -15,6 +15,7 @@ obj-$(CONFIG_SYS_PCAT_TIMER) += pcat_timer.o
 obj-$(CONFIG_PCI) += pci_type1.o
 obj-y	+= relocate.o
 obj-y += physmem.o
+obj-y += ramtest.o
 obj-y	+= string.o
 obj-$(CONFIG_SYS_X86_TSC_TIMER)	+= tsc_timer.o
 obj-$(CONFIG_VIDEO_VGA)	+= video.o
arch/x86/lib/ramtest.c new file +79 -0

79 lines not on this page · raw message

include/configs/chromebook_link.h +5 -0
index 637bdb9..64b7490 100644
@@ -18,13 +18,18 @@
 #define CONFIG_SYS_CAR_ADDR			0xff7e0000
 #define CONFIG_SYS_CAR_SIZE			(128 * 1024)
 #define CONFIG_SYS_MONITOR_LEN			(1 << 20)
+#define CONFIG_DCACHE_RAM_MRC_VAR_SIZE		0x4000
 #define CONFIG_SYS_X86_START16			0xfffff800
 #define CONFIG_BOARD_EARLY_INIT_F
 #define CONFIG_BOARD_EARLY_INIT_R
+#define CONFIG_DISPLAY_CPUINFO
 
 #define CONFIG_X86_RESET_VECTOR
 #define CONFIG_NR_DRAM_BANKS			8
 
+#define CONFIG_X86_MRC_START			0xfffa0000
+#define CONFIG_CACHE_MRC_SIZE_KB		512
+
 /*
  * These common x86 features are not yet supported, but are added in
  * follow-on patches in this series. Add undefs here to avoid every patch
include/configs/x86-common.h +1 -1
index 33ff04f..6d3bcc9 100644
@@ -208,7 +208,7 @@
 #define CONFIG_SYS_STACK_SIZE			(32 * 1024)
 #define CONFIG_SYS_MONITOR_BASE		CONFIG_SYS_TEXT_BASE
 #define CONFIG_SYS_MALLOC_LEN			0x200000
-#define CONFIG_SYS_MALLOC_F_LEN			(1 << 10)
+#define CONFIG_SYS_MALLOC_F_LEN			(2 << 10)
 
 /* allow to overwrite serial and ethaddr */
 #define CONFIG_ENV_OVERWRITE
include/fdtdec.h +1 -0
index 3bd60b7..abfd678 100644
@@ -119,6 +119,7 @@ enum fdt_compat_id {
 	COMPAT_PARADE_PS8625,		/* Parade PS8622 EDP->LVDS bridge */
 	COMPAT_INTEL_LPC,		/* Intel Low Pin Count I/F */
 	COMPAT_INTEL_MICROCODE,		/* Intel microcode update */
+	COMPAT_MEMORY_SPD,		/* Memory SPD information */
 
 	COMPAT_COUNT,
 };
lib/fdtdec.c +1 -0
index 9a68f9c..aafc4f9 100644
@@ -74,6 +74,7 @@ static const char * const compat_names[COMPAT_COUNT] = {
 	COMPAT(PARADE_PS8625, "parade,ps8625"),
 	COMPAT(COMPAT_INTEL_LPC, "intel,lpc"),
 	COMPAT(INTEL_MICROCODE, "intel,microcode"),
+	COMPAT(MEMORY_SPD, "memory-spd"),
 };
 
 const char *fdtdec_get_compatible(enum fdt_compat_id id)
Signature · 1 line
2.1.0.rc2.206.gedb03e5
#91 lore raw

PATCH 39/39 x86: ivybridge: Implement SDRAM init

Hi Simon,

Quoted 553 lines · Simon Glass

Implement SDRAM init using the Memory Reference Code (mrc.bin) provided in the board directory and the SDRAM SPD information in the device tree. This also needs the Intel Management Engine (me.bin) to work. Binary blobs
everywhere: so far we have MRC, ME and microcode.

SDRAM init works by setting up various parameters and calling the MRC. This in turn does some sort of magic to work out how much memory there is and the timing parameters to use. It also sets up the DRAM controllers. When the MRC returns, we use the information it provides to map out the available memory in U-Boot.

U-Boot normally moves itself to the top of RAM. On x86 the RAM is not generally contiguous, and anyway some RAM may be above 4GB which doesn't work in 32-bit mode. So we relocate to the top of the largest block of RAM we can find below 4GB. Memory above 4GB is accessible with special functions (see physmem).

It would be possible to build U-Boot in 64-bit mode but this wouldn't necessarily provide any more memory, since the largest block is often below 4GB. Anyway U-Boot doesn't need huge amounts of memory - even a very large ramdisk seldom exceeds 100-200MB. U-Boot has support for booting 64-bit kernels directly so this does not pose a limitation in that area. Also there are probably parts of U-Boot that will not work correctly in 64-bit mode. The MRC is one.

There is some work remaining in this area. Since memory init is very slow (over 500ms) it is possible to save the parameters in SPI flash to speed it up next time. Suspend/resume support is not fully implemented, or at least it is not efficient.

With this patch, link boots to a prompt.

---

 Makefile                                          |   5 +
 arch/x86/Kconfig                                  |  11 +
 arch/x86/cpu/ivybridge/Makefile                   |   3 +
 arch/x86/cpu/ivybridge/early_me.c                 | 191 ++++++++
 arch/x86/cpu/ivybridge/me_status.c                | 195 ++++++++
 arch/x86/cpu/ivybridge/report_platform.c          |  98 ++++
 arch/x86/cpu/ivybridge/sdram.c                    | 553 +++++++++++++++++++++-
 arch/x86/cpu/start.S                              |  10 +-
 arch/x86/dts/link.dts                             | 111 +++++
 arch/x86/include/asm/arch-ivybridge/me.h          | 357 ++++++++++++++
 arch/x86/include/asm/arch-ivybridge/pch.h         | 113 +++++
 arch/x86/include/asm/arch-ivybridge/pei_data.h    | 121 +++++
 arch/x86/include/asm/arch-ivybridge/sandybridge.h |   2 +
 arch/x86/include/asm/config.h                     |   1 +
 arch/x86/include/asm/global_data.h                |  13 +
 arch/x86/include/asm/post.h                       |   5 +
 arch/x86/include/asm/u-boot-x86.h                 |   2 +
 arch/x86/lib/Makefile                             |   1 +
 arch/x86/lib/ramtest.c                            |  79 ++++
 include/configs/chromebook_link.h                 |   5 +
 include/configs/x86-common.h                      |   2 +-
 include/fdtdec.h                                  |   1 +
 lib/fdtdec.c                                      |   1 +
 23 files changed, 1874 insertions(+), 6 deletions(-)
 create mode 100644 arch/x86/cpu/ivybridge/early_me.c
 create mode 100644 arch/x86/cpu/ivybridge/me_status.c
 create mode 100644 arch/x86/cpu/ivybridge/report_platform.c
 create mode 100644 arch/x86/include/asm/arch-ivybridge/me.h
 create mode 100644 arch/x86/include/asm/arch-ivybridge/pei_data.h
 create mode 100644 arch/x86/lib/ramtest.c
Makefile +5 -0
index 86d0510..4f0260f 100644
@@ -956,9 +956,14 @@ u-boot.rom: u-boot-x86-16bit.bin u-boot-dtb.bin \
                $(srctree)/board/$(BOARDDIR)/descriptor.bin
        $(objtree)/tools/ifdtool -c -r $(CONFIG_ROM_SIZE) \
                -D $(srctree)/board/$(BOARDDIR)/descriptor.bin u-boot.tmp
+       $(objtree)/tools/ifdtool \
+               -i ME:$(srctree)/board/$(BOARDDIR)/me.bin u-boot.tmp
        $(objtree)/tools/ifdtool -w \
                $(CONFIG_SYS_TEXT_BASE):$(objtree)/u-boot-dtb.bin u-boot.tmp
        $(objtree)/tools/ifdtool -w \
+               $(CONFIG_X86_MRC_START):$(srctree)/board/$(BOARDDIR)/mrc.bin \
+               u-boot.tmp
+       $(objtree)/tools/ifdtool -w \
                $(CONFIG_SYS_X86_START16):$(objtree)/u-boot-x86-16bit.bin \
                u-boot.tmp
        mv u-boot.tmp $@
arch/x86/Kconfig +11 -0
index 73fe8b2..e992610 100644
@@ -50,6 +50,17 @@ config CPU_ADDR_BITS
        int
        default 36
 
+config HPET_ADDRESS
+       hex
+       default 0xfed00000 if !HPET_ADDRESS_OVERRIDE
+
+config SMM_TSEG
+       bool
+       default n
+
+config SMM_TSEG_SIZE
+       hex
+
 config ROM_SIZE
        hex
        default 0x800000
arch/x86/cpu/ivybridge/Makefile +3 -0
index 4bfb03a..6669a6f 100644
@@ -7,6 +7,9 @@
 obj-y += car.o
 obj-y += cpu.o
 obj-y += early_init.o
+obj-y += early_me.o
 obj-y += lpc.o
+obj-y += me_status.o
+obj-y += report_platform.o
 obj-y += microcode_intel.o
 obj-y += sdram.o
arch/x86/cpu/ivybridge/early_me.c new file +191 -0
new file mode 100644
index 0000000..5528a9a
@@ -0,0 +1,191 @@
+/*
+ * From Coreboot src/southbridge/intel/bd82x6x/early_me.c
+ *
+ * Copyright (C) 2011 The Chromium OS Authors. All rights reserved.
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <errno.h>
+#include <asm/pci.h>
+#include <asm/processor.h>
+#include <asm/arch/me.h>
+#include <asm/arch/pch.h>
+#include <asm/io.h>
+
+static const char *const me_ack_values[] = {
+       [ME_HFS_ACK_NO_DID]     = "No DID Ack received",
+       [ME_HFS_ACK_RESET]      = "Non-power cycle reset",
+       [ME_HFS_ACK_PWR_CYCLE]  = "Power cycle reset",
+       [ME_HFS_ACK_S3]         = "Go to S3",
+       [ME_HFS_ACK_S4]         = "Go to S4",
+       [ME_HFS_ACK_S5]         = "Go to S5",
+       [ME_HFS_ACK_GBL_RESET]  = "Global Reset",
+       [ME_HFS_ACK_CONTINUE]   = "Continue to boot"
+};
+
+static inline void pci_read_dword_ptr(void *ptr, int offset)
+{
+       u32 dword;
+
+       dword = pci_read_config32(PCH_ME_DEV, offset);
+       memcpy(ptr, &dword, sizeof(dword));
+}
+
+static inline void pci_write_dword_ptr(void *ptr, int offset)
+{
+       u32 dword = 0;
+       memcpy(&dword, ptr, sizeof(dword));
+       pci_write_config32(PCH_ME_DEV, offset, dword);
+}
+
+void intel_early_me_status(void)
+{
+       struct me_hfs hfs;
+       struct me_gmes gmes;
+
+       pci_read_dword_ptr(&hfs, PCI_ME_HFS);
+       pci_read_dword_ptr(&gmes, PCI_ME_GMES);
+
+       intel_me_status(&hfs, &gmes);
+}
+
+int intel_early_me_init(void)
+{
+       int count;
+       struct me_uma uma;
+       struct me_hfs hfs;
+
+       debug("Intel ME early init\n");
+
+       /* Wait for ME UMA SIZE VALID bit to be set */
+       for (count = ME_RETRY; count > 0; --count) {
+               pci_read_dword_ptr(&uma, PCI_ME_UMA);
+               if (uma.valid)
+                       break;
+               udelay(ME_DELAY);
+       }
+       if (!count) {
+               printf("ERROR: ME is not ready!\n");
+               return -EBUSY;
+       }
+
+       /* Check for valid firmware */
+       pci_read_dword_ptr(&hfs, PCI_ME_HFS);
+       if (hfs.fpt_bad) {
+               printf("WARNING: ME has bad firmware\n");
+               return -EBADF;
+       }
+
+       debug("Intel ME firmware is ready\n");
+
+       return 0;
+}
+
+int intel_early_me_uma_size(void)
+{
+       struct me_uma uma;
+
+       pci_read_dword_ptr(&uma, PCI_ME_UMA);
+       if (uma.valid) {
+               debug("ME: Requested %uMB UMA\n", uma.size);
+               return uma.size;
+       }
+
+       debug("ME: Invalid UMA size\n");
+       return -EINVAL;
+}
+
+static inline void set_global_reset(int enable)
+{
+       u32 etr3;
+
+       etr3 = pci_read_config32(PCH_LPC_DEV, ETR3);
+
+       /* Clear CF9 Without Resume Well Reset Enable */
+       etr3 &= ~ETR3_CWORWRE;
+
+       /* CF9GR indicates a Global Reset */
+       if (enable)
+               etr3 |= ETR3_CF9GR;
+       else
+               etr3 &= ~ETR3_CF9GR;
+
+       pci_write_config32(PCH_LPC_DEV, ETR3, etr3);
+}
+
+int intel_early_me_init_done(u8 status)
+{
+       u8 reset;
+       int count;
+       u32 mebase_l, mebase_h;
+       struct me_hfs hfs;
+       struct me_did did = {
+               .init_done = ME_INIT_DONE,
+               .status = status
+       };
+
+       /* MEBASE from MESEG_BASE[35:20] */
+       mebase_l = pci_read_config32(PCI_CPU_DEVICE, PCI_CPU_MEBASE_L);
+       mebase_h = pci_read_config32(PCI_CPU_DEVICE, PCI_CPU_MEBASE_H);
+       mebase_h &= 0xf;
+       did.uma_base = (mebase_l >> 20) | (mebase_h << 12);
+
+       /* Send message to ME */
+       debug("ME: Sending Init Done with status: %d, UMA base: 0x%04x\n",
+             status, did.uma_base);
+
+       pci_write_dword_ptr(&did, PCI_ME_H_GS);
+
+       /* Must wait for ME acknowledgement */
+       for (count = ME_RETRY; count > 0; --count) {
+               pci_read_dword_ptr(&hfs, PCI_ME_HFS);
+               if (hfs.bios_msg_ack)
+                       break;
+               udelay(ME_DELAY);
+       }
+       if (!count) {
+               printf("ERROR: ME failed to respond\n");
+               return -1;
+       }
+
+       /* Return the requested BIOS action */
+       debug("ME: Requested BIOS Action: %s\n", me_ack_values[hfs.ack_data]);
+
+       /* Check status after acknowledgement */
+       intel_early_me_status();
+
+       reset = 0;
+       switch (hfs.ack_data) {
+       case ME_HFS_ACK_CONTINUE:
+               /* Continue to boot */
+               return 0;
+       case ME_HFS_ACK_RESET:
+               /* Non-power cycle reset */
+               set_global_reset(0);
+               reset = 0x06;
+               break;
+       case ME_HFS_ACK_PWR_CYCLE:
+               /* Power cycle reset */
+               set_global_reset(0);
+               reset = 0x0e;
+               break;
+       case ME_HFS_ACK_GBL_RESET:
+               /* Global reset */
+               set_global_reset(1);
+               reset = 0x0e;
+               break;
+       case ME_HFS_ACK_S3:
+       case ME_HFS_ACK_S4:
+       case ME_HFS_ACK_S5:
+               break;
+       }
+
+       /* Perform the requested reset */
+       if (reset) {
+               outb(reset, 0xcf9);
+               cpu_hlt();
+       }
+       return -1;
+}
arch/x86/cpu/ivybridge/me_status.c new file +195 -0
new file mode 100644
index 0000000..15cf69f
@@ -0,0 +1,195 @@
+/*
+ * From Coreboot src/southbridge/intel/bd82x6x/me_status.c
+ *
+ * Copyright (C) 2011 The Chromium OS Authors. All rights reserved.
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <asm/arch/me.h>
+
+/* HFS1[3:0] Current Working State Values */
+static const char *const me_cws_values[] = {
+       [ME_HFS_CWS_RESET]      = "Reset",
+       [ME_HFS_CWS_INIT]       = "Initializing",
+       [ME_HFS_CWS_REC]        = "Recovery",
+       [ME_HFS_CWS_NORMAL]     = "Normal",
+       [ME_HFS_CWS_WAIT]       = "Platform Disable Wait",
+       [ME_HFS_CWS_TRANS]      = "OP State Transition",
+       [ME_HFS_CWS_INVALID]    = "Invalid CPU Plugged In"
+};
+
+/* HFS1[8:6] Current Operation State Values */
+static const char *const me_opstate_values[] = {
+       [ME_HFS_STATE_PREBOOT]  = "Preboot",
+       [ME_HFS_STATE_M0_UMA]   = "M0 with UMA",
+       [ME_HFS_STATE_M3]       = "M3 without UMA",
+       [ME_HFS_STATE_M0]       = "M0 without UMA",
+       [ME_HFS_STATE_BRINGUP]  = "Bring up",
+       [ME_HFS_STATE_ERROR]    = "M0 without UMA but with error"
+};
+
+/* HFS[19:16] Current Operation Mode Values */
+static const char *const me_opmode_values[] = {
+       [ME_HFS_MODE_NORMAL]    = "Normal",
+       [ME_HFS_MODE_DEBUG]     = "Debug",
+       [ME_HFS_MODE_DIS]       = "Soft Temporary Disable",
+       [ME_HFS_MODE_OVER_JMPR] = "Security Override via Jumper",
+       [ME_HFS_MODE_OVER_MEI]  = "Security Override via MEI Message"
+};
+
+/* HFS[15:12] Error Code Values */
+static const char *const me_error_values[] = {
+       [ME_HFS_ERROR_NONE]     = "No Error",
+       [ME_HFS_ERROR_UNCAT]    = "Uncategorized Failure",
+       [ME_HFS_ERROR_IMAGE]    = "Image Failure",
+       [ME_HFS_ERROR_DEBUG]    = "Debug Failure"
+};
+
+/* GMES[31:28] ME Progress Code */
+static const char *const me_progress_values[] = {
+       [ME_GMES_PHASE_ROM]     = "ROM Phase",
+       [ME_GMES_PHASE_BUP]     = "BUP Phase",
+       [ME_GMES_PHASE_UKERNEL] = "uKernel Phase",
+       [ME_GMES_PHASE_POLICY]  = "Policy Module",
+       [ME_GMES_PHASE_MODULE]  = "Module Loading",
+       [ME_GMES_PHASE_UNKNOWN] = "Unknown",
+       [ME_GMES_PHASE_HOST]    = "Host Communication"
+};
+
+/* GMES[27:24] Power Management Event */
+static const char *const me_pmevent_values[] = {
+       [0x00] = "Clean Moff->Mx wake",
+       [0x01] = "Moff->Mx wake after an error",
+       [0x02] = "Clean global reset",
+       [0x03] = "Global reset after an error",
+       [0x04] = "Clean Intel ME reset",
+       [0x05] = "Intel ME reset due to exception",
+       [0x06] = "Pseudo-global reset",
+       [0x07] = "S0/M0->Sx/M3",
+       [0x08] = "Sx/M3->S0/M0",
+       [0x09] = "Non-power cycle reset",
+       [0x0a] = "Power cycle reset through M3",
+       [0x0b] = "Power cycle reset through Moff",
+       [0x0c] = "Sx/Mx->Sx/Moff"
+};
+
+/* Progress Code 0 states */
+static const char *const me_progress_rom_values[] = {
+       [0x00] = "BEGIN",
+       [0x06] = "DISABLE"
+};
+
+/* Progress Code 1 states */
+static const char *const me_progress_bup_values[] = {
+       [0x00] = "Initialization starts",
+       [0x01] = "Disable the host wake event",
+       [0x04] = "Flow determination start process",
+       [0x08] = "Error reading/matching the VSCC table in the descriptor",
+       [0x0a] = "Check to see if straps say ME DISABLED",
+       [0x0b] = "Timeout waiting for PWROK",
+       [0x0d] = "Possibly handle BUP manufacturing override strap",
+       [0x11] = "Bringup in M3",
+       [0x12] = "Bringup in M0",
+       [0x13] = "Flow detection error",
+       [0x15] = "M3 clock switching error",
+       [0x18] = "M3 kernel load",
+       [0x1c] = "T34 missing - cannot program ICC",
+       [0x1f] = "Waiting for DID BIOS message",
+       [0x20] = "Waiting for DID BIOS message failure",
+       [0x21] = "DID reported an error",
+       [0x22] = "Enabling UMA",
+       [0x23] = "Enabling UMA error",
+       [0x24] = "Sending DID Ack to BIOS",
+       [0x25] = "Sending DID Ack to BIOS error",
+       [0x26] = "Switching clocks in M0",
+       [0x27] = "Switching clocks in M0 error",
+       [0x28] = "ME in temp disable",
+       [0x32] = "M0 kernel load",
+};
+
+/* Progress Code 3 states */
+static const char *const me_progress_policy_values[] = {
+       [0x00] = "Entery into Policy Module",
+       [0x03] = "Received S3 entry",
+       [0x04] = "Received S4 entry",
+       [0x05] = "Received S5 entry",
+       [0x06] = "Received UPD entry",
+       [0x07] = "Received PCR entry",
+       [0x08] = "Received NPCR entry",
+       [0x09] = "Received host wake",
+       [0x0a] = "Received AC<>DC switch",
+       [0x0b] = "Received DRAM Init Done",
+       [0x0c] = "VSCC Data not found for flash device",
+       [0x0d] = "VSCC Table is not valid",
+       [0x0e] = "Flash Partition Boundary is outside address space",
+       [0x0f] = "ME cannot access the chipset descriptor region",
+       [0x10] = "Required VSCC values for flash parts do not match",
+};
+
+void intel_me_status(struct me_hfs *hfs, struct me_gmes *gmes)
+{
+       /* Check Current States */
+       debug("ME: FW Partition Table      : %s\n",
+             hfs->fpt_bad ? "BAD" : "OK");
+       debug("ME: Bringup Loader Failure  : %s\n",
+             hfs->ft_bup_ld_flr ? "YES" : "NO");
+       debug("ME: Firmware Init Complete  : %s\n",
+             hfs->fw_init_complete ? "YES" : "NO");
+       debug("ME: Manufacturing Mode      : %s\n",
+             hfs->mfg_mode ? "YES" : "NO");
+       debug("ME: Boot Options Present    : %s\n",
+             hfs->boot_options_present ? "YES" : "NO");
+       debug("ME: Update In Progress      : %s\n",
+             hfs->update_in_progress ? "YES" : "NO");
+       debug("ME: Current Working State   : %s\n",
+             me_cws_values[hfs->working_state]);
+       debug("ME: Current Operation State : %s\n",
+             me_opstate_values[hfs->operation_state]);
+       debug("ME: Current Operation Mode  : %s\n",
+             me_opmode_values[hfs->operation_mode]);
+       debug("ME: Error Code              : %s\n",
+             me_error_values[hfs->error_code]);
+       debug("ME: Progress Phase          : %s\n",
+             me_progress_values[gmes->progress_code]);
+       debug("ME: Power Management Event  : %s\n",
+             me_pmevent_values[gmes->current_pmevent]);
+
+       debug("ME: Progress Phase State    : ");
+       switch (gmes->progress_code) {
+       case ME_GMES_PHASE_ROM:         /* ROM Phase */
+               debug("%s", me_progress_rom_values[gmes->current_state]);
+               break;
+
+       case ME_GMES_PHASE_BUP:         /* Bringup Phase */
+               if (gmes->current_state < ARRAY_SIZE(me_progress_bup_values) &&
+                   me_progress_bup_values[gmes->current_state])
+                       debug("%s",
+                             me_progress_bup_values[gmes->current_state]);
+               else
+                       debug("0x%02x", gmes->current_state);
+               break;
+
+       case ME_GMES_PHASE_POLICY:      /* Policy Module Phase */
+               if (gmes->current_state <
+                               ARRAY_SIZE(me_progress_policy_values) &&
+                   me_progress_policy_values[gmes->current_state])
+                       debug("%s",
+                             me_progress_policy_values[gmes->current_state]);
+               else
+                       debug("0x%02x", gmes->current_state);
+               break;
+
+       case ME_GMES_PHASE_HOST:        /* Host Communication Phase */
+               if (!gmes->current_state)
+                       debug("Host communication established");
+               else
+                       debug("0x%02x", gmes->current_state);
+               break;
+
+       default:
+               debug("Unknown 0x%02x", gmes->current_state);
+       }
+       debug("\n");
+}
arch/x86/cpu/ivybridge/report_platform.c new file +28 -0
new file mode 100644
index 0000000..b236ecb
@@ -0,0 +1,98 @@
+/*
+ * From Coreboot src/northbridge/intel/sandybridge/report_platform.c
+ *
+ * Copyright (C) 2012 Google Inc.
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <asm/processor.h>
+#include <asm/pci.h>
+#include <asm/arch/pch.h>
+
+static void report_cpu_info(void)
+{
+       struct cpuid_result cpuidr;
+       u32 i, index;
+       char cpu_string[50], *cpu_name = cpu_string; /* 48 bytes are reported */
+       int vt, txt, aes;
+       const char *mode[] = {"NOT ", ""};
+
+       index = 0x80000000;
+       cpuidr = cpuid(index);
+       if (cpuidr.eax < 0x80000004) {
+               strcpy(cpu_string, "Platform info not available");
+       } else {
+               u32 *p = (u32 *)cpu_string;
+               for (i = 2; i <= 4 ; i++) {

arch/x86/cpu/ivybridge/report_platform.c line 38

Quoted 10 lines
arch/x86/cpu/ivybridge/report_platform.c new file +10 -0
+                       cpuidr = cpuid(index + i);
+                       *p++ = cpuidr.eax;
+                       *p++ = cpuidr.ebx;
+                       *p++ = cpuidr.ecx;
+                       *p++ = cpuidr.edx;
+               }
+       }
+       /* Skip leading spaces in CPU name string */
+       while (cpu_name[0] == ' ')
+               cpu_name++;

The above codes can be just replaced by a call to fill_processor_name()

Quoted 694 lines
arch/x86/cpu/ivybridge/report_platform.c new file +59 -0
+       cpuidr = cpuid(1);
+       debug("CPU id(%x): %s\n", cpuidr.eax, cpu_name);
+       aes = (cpuidr.ecx & (1 << 25)) ? 1 : 0;
+       txt = (cpuidr.ecx & (1 << 6)) ? 1 : 0;
+       vt = (cpuidr.ecx & (1 << 5)) ? 1 : 0;
+       debug("AES %ssupported, TXT %ssupported, VT %ssupported\n",
+             mode[aes], mode[txt], mode[vt]);
+}
+
+/* The PCI id name match comes from Intel document 472178 */
+static struct {
+       u16 dev_id;
+       const char *dev_name;
+} pch_table[] = {
+       {0x1E41, "Desktop Sample"},
+       {0x1E42, "Mobile Sample"},
+       {0x1E43, "SFF Sample"},
+       {0x1E44, "Z77"},
+       {0x1E45, "H71"},
+       {0x1E46, "Z75"},
+       {0x1E47, "Q77"},
+       {0x1E48, "Q75"},
+       {0x1E49, "B75"},
+       {0x1E4A, "H77"},
+       {0x1E53, "C216"},
+       {0x1E55, "QM77"},
+       {0x1E56, "QS77"},
+       {0x1E58, "UM77"},
+       {0x1E57, "HM77"},
+       {0x1E59, "HM76"},
+       {0x1E5D, "HM75"},
+       {0x1E5E, "HM70"},
+       {0x1E5F, "NM70"},
+};
+
+static void report_pch_info(void)
+{
+       const char *pch_type = "Unknown";
+       int i;
+       u16 dev_id;
+       uint8_t rev_id;
+
+       dev_id = pci_read_config16(PCH_LPC_DEV, 2);
+       for (i = 0; i < ARRAY_SIZE(pch_table); i++) {
+               if (pch_table[i].dev_id == dev_id) {
+                       pch_type = pch_table[i].dev_name;
+                       break;
+               }
+       }
+       rev_id = pci_read_config8(PCH_LPC_DEV, 8);
+       debug("PCH type: %s, device id: %x, rev id %x\n", pch_type, dev_id,
+             rev_id);
+}
+
+void report_platform_info(void)
+{
+       report_cpu_info();
+       report_pch_info();
+}
arch/x86/cpu/ivybridge/sdram.c +552 -1
index 5f9ae5e..ed89f60 100644
@@ -11,10 +11,561 @@
  */
 
 #include <common.h>
+#include <errno.h>
+#include <fdtdec.h>
+#include <malloc.h>
+#include <asm/processor.h>
+#include <asm/gpio.h>
+#include <asm/global_data.h>
+#include <asm/pci.h>
+#include <asm/arch/me.h>
+#include <asm/arch/pei_data.h>
+#include <asm/arch/pch.h>
+#include <asm/post.h>
+#include <asm/arch/sandybridge.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/*
+ * This function looks for the highest region of memory lower than 4GB which
+ * has enough space for U-Boot where U-Boot is aligned on a page boundary.
+ * It overrides the default implementation found elsewhere which simply
+ * picks the end of ram, wherever that may be. The location of the stack,
+ * the relocation address, and how far U-Boot is moved by relocation are
+ * set in the global data structure.
+ */
+ulong board_get_usable_ram_top(ulong total_size)
+{
+       struct memory_info *info = &gd->arch.meminfo;
+       uintptr_t dest_addr = 0;
+       struct memory_area *largest = NULL;
+       int i;
+
+       /* Find largest area of memory below 4GB */
+
+       for (i = 0; i < info->num_areas; i++) {
+               struct memory_area *area = &info->area[i];
+
+               if (area->start >= 1ULL << 32)
+                       continue;
+               if (!largest || area->size > largest->size)
+                       largest = area;
+       }
+
+       /* If no suitable area was found, return an error. */
+       assert(largest);
+       if (!largest || largest->size < (2 << 20))
+               panic("No available memory found for relocation");
+
+       dest_addr = largest->start + largest->size;
+
+       return (ulong)dest_addr;
+}
+
+void dram_init_banksize(void)
+{
+       struct memory_info *info = &gd->arch.meminfo;
+       int num_banks;
+       int i;
+
+       for (i = 0, num_banks = 0; i < info->num_areas; i++) {
+               struct memory_area *area = &info->area[i];
+
+               if (area->start >= 1ULL << 32)
+                       continue;
+               gd->bd->bi_dram[num_banks].start = area->start;
+               gd->bd->bi_dram[num_banks].size = area->size;
+               num_banks++;
+       }
+}
+
+static const char *const ecc_decoder[] = {
+       "inactive",
+       "active on IO",
+       "disabled on IO",
+       "active"
+};
+
+/*
+ * Dump in the log memory controller configuration as read from the memory
+ * controller registers.
+ */
+static void report_memory_config(void)
+{
+       u32 addr_decoder_common, addr_decode_ch[2];
+       int i;
+
+       addr_decoder_common = readl(MCHBAR_REG(0x5000));
+       addr_decode_ch[0] = readl(MCHBAR_REG(0x5004));
+       addr_decode_ch[1] = readl(MCHBAR_REG(0x5008));
+
+       debug("memcfg DDR3 clock %d MHz\n",
+             (readl(MCHBAR_REG(0x5e04)) * 13333 * 2 + 50) / 100);
+       debug("memcfg channel assignment: A: %d, B % d, C % d\n",
+             addr_decoder_common & 3,
+             (addr_decoder_common >> 2) & 3,
+             (addr_decoder_common >> 4) & 3);
+
+       for (i = 0; i < ARRAY_SIZE(addr_decode_ch); i++) {
+               u32 ch_conf = addr_decode_ch[i];
+               debug("memcfg channel[%d] config (%8.8x):\n", i, ch_conf);
+               debug("   ECC %s\n", ecc_decoder[(ch_conf >> 24) & 3]);
+               debug("   enhanced interleave mode %s\n",
+                     ((ch_conf >> 22) & 1) ? "on" : "off");
+               debug("   rank interleave %s\n",
+                     ((ch_conf >> 21) & 1) ? "on" : "off");
+               debug("   DIMMA %d MB width x%d %s rank%s\n",
+                     ((ch_conf >> 0) & 0xff) * 256,
+                     ((ch_conf >> 19) & 1) ? 16 : 8,
+                     ((ch_conf >> 17) & 1) ? "dual" : "single",
+                     ((ch_conf >> 16) & 1) ? "" : ", selected");
+               debug("   DIMMB %d MB width x%d %s rank%s\n",
+                     ((ch_conf >> 8) & 0xff) * 256,
+                     ((ch_conf >> 20) & 1) ? 16 : 8,
+                     ((ch_conf >> 18) & 1) ? "dual" : "single",
+                     ((ch_conf >> 16) & 1) ? ", selected" : "");
+       }
+}
+
+static void post_system_agent_init(struct pei_data *pei_data)
+{
+       /* If PCIe init is skipped, set the PEG clock gating */
+       if (!pei_data->pcie_init)
+               setbits_le32(MCHBAR_REG(0x7010), 1);
+}
+
+static asmlinkage void console_tx_byte(unsigned char byte)
+{
+#ifdef DEBUG
+       putc(byte);
+#endif
+}
+
+/**
+ * Find PEI executable in coreboot filesystem and execute it.
+ *
+ * @param pei_data: configuration data for UEFI PEI reference code
+ */
+int sdram_initialise(struct pei_data *pei_data)
+{
+       unsigned version;
+       const char *data;
+       uint16_t done;
+       int ret;
+
+       report_platform_info();
+
+       /* Wait for ME to be ready */
+       ret = intel_early_me_init();
+       if (ret)
+               return ret;
+       ret = intel_early_me_uma_size();
+       if (ret < 0)
+               return ret;
+
+       debug("Starting UEFI PEI System Agent\n");
+
+       /* If MRC data is not found we cannot continue S3 resume. */
+       if (pei_data->boot_mode == PEI_BOOT_RESUME && !pei_data->mrc_input) {
+               debug("Giving up in sdram_initialize: No MRC data\n");
+               outb(0x6, PORT_RESET);
+               cpu_hlt();
+       }
+
+       /* Pass console handler in pei_data */
+       pei_data->tx_byte = console_tx_byte;
+
+       debug("PEI data at %p, size %x:\n", pei_data, sizeof(*pei_data));
+
+       data = (char *)CONFIG_X86_MRC_START;
+       if (data) {
+               int rv;
+               int (*func)(struct pei_data *);
+
+               debug("Calling MRC at %p\n", data);
+               post_code(POST_PRE_MRC);
+               func = (int (*)(struct pei_data *))data;
+               rv = func(pei_data);
+               post_code(POST_MRC);
+               if (rv) {
+                       switch (rv) {
+                       case -1:
+                               printf("PEI version mismatch.\n");
+                               break;
+                       case -2:
+                               printf("Invalid memory frequency.\n");
+                               break;
+                       default:
+                               printf("MRC returned %x.\n", rv);
+                       }
+                       printf("Nonzero MRC return value.\n");
+                       return -EFAULT;
+               }
+       } else {
+               printf("UEFI PEI System Agent not found.\n");
+               return -ENOSYS;
+       }
+
+#if CONFIG_USBDEBUG
+       /* mrc.bin reconfigures USB, so reinit it to have debug */
+       early_usbdebug_init();
+#endif
+
+       version = readl(MCHBAR_REG(0x5034));
+       debug("System Agent Version %d.%d.%d Build %d\n",
+             version >> 24 , (version >> 16) & 0xff,
+             (version >> 8) & 0xff, version & 0xff);
+
+       /*
+        * Send ME init done for SandyBridge here.  This is done inside the
+        * SystemAgent binary on IvyBridge
+        */
+       done = pci_read_config32(PCI_CPU_DEVICE, PCI_DEVICE_ID);
+       done &= BASE_REV_MASK;
+       if (BASE_REV_SNB == done)
+               intel_early_me_init_done(ME_INIT_STATUS_SUCCESS);
+       else
+               intel_early_me_status();
+
+       post_system_agent_init(pei_data);
+       report_memory_config();
+
+       return 0;
+}
+
+static int copy_spd(struct pei_data *peid)
+{
+       const int gpio_vector[] = {41, 42, 43, 10, -1};
+       int spd_index;
+       const void *blob = gd->fdt_blob;
+       int node, spd_node;
+       int ret, i;
+
+       for (i = 0; ; i++) {
+               if (gpio_vector[i] == -1)
+                       break;
+               ret = gpio_requestf(gpio_vector[i], "spd_id%d", i);
+               if (ret) {
+                       debug("%s: Could not request gpio %d\n", __func__,
+                             gpio_vector[i]);
+                       return ret;
+               }
+       }
+       spd_index = gpio_get_values_as_int(gpio_vector);
+       debug("spd index %d\n", spd_index);
+       node = fdtdec_next_compatible(blob, 0, COMPAT_MEMORY_SPD);
+       if (node < 0) {
+               printf("SPD data not found.\n");
+               return -ENOENT;
+       }
+
+       for (spd_node = fdt_first_subnode(blob, node);
+            spd_node > 0;
+            spd_node = fdt_next_subnode(blob, spd_node)) {
+               const char *data;
+               int len;
+
+               if (fdtdec_get_int(blob, spd_node, "reg", -1) != spd_index)
+                       continue;
+               data = fdt_getprop(blob, spd_node, "data", &len);
+               if (len < sizeof(peid->spd_data[0])) {
+                       printf("Missing SPD data\n");
+                       return -EINVAL;
+               }
+
+               debug("Using SDRAM SPD data for '%s'\n",
+                     fdt_get_name(blob, spd_node, NULL));
+               memcpy(peid->spd_data[0], data, sizeof(peid->spd_data[0]));
+               break;
+       }
+
+       if (spd_node < 0) {
+               printf("No SPD data found for index %d\n", spd_index);
+               return -ENOENT;
+       }
+
+       return 0;
+}
+
+/**
+ * add_memory_area() - Add a new usable memory area to our list
+ *
+ * Note: @start and @end must not span the first 4GB boundary
+ *
+ * @info:      Place to store memory info
+ * @start:     Start of this memory area
+ * @end:       End of this memory area + 1
+ */
+static int add_memory_area(struct memory_info *info,
+                          uint64_t start, uint64_t end)
+{
+       struct memory_area *ptr;
+
+       if (info->num_areas == CONFIG_NR_DRAM_BANKS)
+               return -ENOSPC;
+
+       ptr = &info->area[info->num_areas];
+       ptr->start = start;
+       ptr->size = end - start;
+       info->total_memory += ptr->size;
+       if (ptr->start < (1ULL << 32))
+               info->total_32bit_memory += ptr->size;
+       debug("%d: memory %llx size %llx, total now %llx / %llx\n",
+             info->num_areas, ptr->start, ptr->size,
+             info->total_32bit_memory, info->total_memory);
+       info->num_areas++;
+
+       return 0;
+}
+
+/**
+ * sdram_find() - Find available memory
+ *
+ * This is a bit complicated since on x86 there are system memory holes all
+ * over the place. We create a list of available memory blocks
+ */
+static int sdram_find(pci_dev_t dev)
+{
+       struct memory_info *info = &gd->arch.meminfo;
+       uint32_t tseg_base, uma_size, tolud;
+       uint64_t tom, me_base, touud;
+       uint64_t uma_memory_base = 0;
+       uint64_t uma_memory_size;
+       unsigned long long tomk;
+       uint16_t ggc;
+
+       /* Total Memory 2GB example:
+        *
+        *  00000000  0000MB-1992MB  1992MB  RAM     (writeback)
+        *  7c800000  1992MB-2000MB     8MB  TSEG    (SMRR)
+        *  7d000000  2000MB-2002MB     2MB  GFX GTT (uncached)
+        *  7d200000  2002MB-2034MB    32MB  GFX UMA (uncached)
+        *  7f200000   2034MB TOLUD
+        *  7f800000   2040MB MEBASE
+        *  7f800000  2040MB-2048MB     8MB  ME UMA  (uncached)
+        *  80000000   2048MB TOM
+        * 100000000  4096MB-4102MB     6MB  RAM     (writeback)
+        *
+        * Total Memory 4GB example:
+        *
+        *  00000000  0000MB-2768MB  2768MB  RAM     (writeback)
+        *  ad000000  2768MB-2776MB     8MB  TSEG    (SMRR)
+        *  ad800000  2776MB-2778MB     2MB  GFX GTT (uncached)
+        *  ada00000  2778MB-2810MB    32MB  GFX UMA (uncached)
+        *  afa00000   2810MB TOLUD
+        *  ff800000   4088MB MEBASE
+        *  ff800000  4088MB-4096MB     8MB  ME UMA  (uncached)
+        * 100000000   4096MB TOM
+        * 100000000  4096MB-5374MB  1278MB  RAM     (writeback)
+        * 14fe00000   5368MB TOUUD
+        */
+
+       /* Top of Upper Usable DRAM, including remap */
+       touud = pci_read_config32(dev, TOUUD+4);
+       touud <<= 32;
+       touud |= pci_read_config32(dev, TOUUD);
+
+       /* Top of Lower Usable DRAM */
+       tolud = pci_read_config32(dev, TOLUD);
+
+       /* Top of Memory - does not account for any UMA */
+       tom = pci_read_config32(dev, 0xa4);
+       tom <<= 32;
+       tom |= pci_read_config32(dev, 0xa0);
+
+       debug("TOUUD %llx TOLUD %08x TOM %llx\n", touud, tolud, tom);
+
+       /* ME UMA needs excluding if total memory <4GB */
+       me_base = pci_read_config32(dev, 0x74);
+       me_base <<= 32;
+       me_base |= pci_read_config32(dev, 0x70);
+
+       debug("MEBASE %llx\n", me_base);
+
+       /* TODO: Get rid of all this shifting by 10 bits */
+       tomk = tolud >> 10;
+       if (me_base == tolud) {
+               /* ME is from MEBASE-TOM */
+               uma_size = (tom - me_base) >> 10;
+               /* Increment TOLUD to account for ME as RAM */
+               tolud += uma_size << 10;
+               /* UMA starts at old TOLUD */
+               uma_memory_base = tomk * 1024ULL;
+               uma_memory_size = uma_size * 1024ULL;
+               debug("ME UMA base %llx size %uM\n", me_base, uma_size >> 10);
+       }
+
+       /* Graphics memory comes next */
+       ggc = pci_read_config16(dev, GGC);
+       if (!(ggc & 2)) {
+               debug("IGD decoded, subtracting ");
+
+               /* Graphics memory */
+               uma_size = ((ggc >> 3) & 0x1f) * 32 * 1024ULL;
+               debug("%uM UMA", uma_size >> 10);
+               tomk -= uma_size;
+               uma_memory_base = tomk * 1024ULL;
+               uma_memory_size += uma_size * 1024ULL;
+
+               /* GTT Graphics Stolen Memory Size (GGMS) */
+               uma_size = ((ggc >> 8) & 0x3) * 1024ULL;
+               tomk -= uma_size;
+               uma_memory_base = tomk * 1024ULL;
+               uma_memory_size += uma_size * 1024ULL;
+               debug(" and %uM GTT\n", uma_size >> 10);
+       }
+
+       /* Calculate TSEG size from its base which must be below GTT */
+       tseg_base = pci_read_config32(dev, 0xb8);
+       uma_size = (uma_memory_base - tseg_base) >> 10;
+       tomk -= uma_size;
+       uma_memory_base = tomk * 1024ULL;
+       uma_memory_size += uma_size * 1024ULL;
+       debug("TSEG base 0x%08x size %uM\n", tseg_base, uma_size >> 10);
+
+       debug("Available memory below 4GB: %lluM\n", tomk >> 10);
+
+       /* Report the memory regions */
+       add_memory_area(info, 1 << 20, 2 << 28);
+       add_memory_area(info, (2 << 28) + (2 << 20), 4 << 28);
+       add_memory_area(info, (4 << 28) + (2 << 20), tseg_base);
+       add_memory_area(info, 1ULL << 32, touud);
+       /*
+        * If >= 4GB installed then memory from TOLUD to 4GB
+        * is remapped above TOM, TOUUD will account for both
+        */
+       if (touud > (1ULL << 32ULL)) {
+               debug("Available memory above 4GB: %lluM\n",
+                     (touud >> 20) - 4096);
+       }
+
+       return 0;
+}
+
+static void rcba_config(void)
+{
+       /*
+        *             GFX    INTA -> PIRQA (MSI)
+        * D28IP_P3IP  WLAN   INTA -> PIRQB
+        * D29IP_E1P   EHCI1  INTA -> PIRQD
+        * D26IP_E2P   EHCI2  INTA -> PIRQF
+        * D31IP_SIP   SATA   INTA -> PIRQF (MSI)
+        * D31IP_SMIP  SMBUS  INTB -> PIRQH
+        * D31IP_TTIP  THRT   INTC -> PIRQA
+        * D27IP_ZIP   HDA    INTA -> PIRQA (MSI)
+        *
+        * TRACKPAD                -> PIRQE (Edge Triggered)
+        * TOUCHSCREEN             -> PIRQG (Edge Triggered)
+        */
+
+       /* Device interrupt pin register (board specific) */
+       writel((INTC << D31IP_TTIP) | (NOINT << D31IP_SIP2) |
+              (INTB << D31IP_SMIP) | (INTA << D31IP_SIP), RCB_REG(D31IP));
+       writel(NOINT << D30IP_PIP, RCB_REG(D30IP));
+       writel(INTA << D29IP_E1P, RCB_REG(D29IP));
+       writel(INTA << D28IP_P3IP, RCB_REG(D28IP));
+       writel(INTA << D27IP_ZIP, RCB_REG(D27IP));
+       writel(INTA << D26IP_E2P, RCB_REG(D26IP));
+       writel(NOINT << D25IP_LIP, RCB_REG(D25IP));
+       writel(NOINT << D22IP_MEI1IP, RCB_REG(D22IP));
+
+       /* Device interrupt route registers */
+       writel(DIR_ROUTE(PIRQB, PIRQH, PIRQA, PIRQC), RCB_REG(D31IR));
+       writel(DIR_ROUTE(PIRQD, PIRQE, PIRQF, PIRQG), RCB_REG(D29IR));
+       writel(DIR_ROUTE(PIRQB, PIRQC, PIRQD, PIRQE), RCB_REG(D28IR));
+       writel(DIR_ROUTE(PIRQA, PIRQH, PIRQA, PIRQB), RCB_REG(D27IR));
+       writel(DIR_ROUTE(PIRQF, PIRQE, PIRQG, PIRQH), RCB_REG(D26IR));
+       writel(DIR_ROUTE(PIRQA, PIRQB, PIRQC, PIRQD), RCB_REG(D25IR));
+       writel(DIR_ROUTE(PIRQA, PIRQB, PIRQC, PIRQD), RCB_REG(D22IR));
+
+       /* Enable IOAPIC (generic) */
+       writew(0x0100, RCB_REG(OIC));
+       /* PCH BWG says to read back the IOAPIC enable register */
+       (void)readw(RCB_REG(OIC));
+
+       /* Disable unused devices (board specific) */
+       setbits_le32(RCB_REG(FD), PCH_DISABLE_ALWAYS);
+}
 
 int dram_init(void)
 {
-       /* TODO: Set up DRAM */
+       struct pei_data pei_data __aligned(8) = {
+               .pei_version = PEI_VERSION,
+               .mchbar = DEFAULT_MCHBAR,
+               .dmibar = DEFAULT_DMIBAR,
+               .epbar = DEFAULT_EPBAR,
+               .pciexbar = CONFIG_MMCONF_BASE_ADDRESS,
+               .smbusbar = SMBUS_IO_BASE,
+               .wdbbar = 0x4000000,
+               .wdbsize = 0x1000,
+               .hpet_address = CONFIG_HPET_ADDRESS,
+               .rcba = DEFAULT_RCBABASE,
+               .pmbase = DEFAULT_PMBASE,
+               .gpiobase = DEFAULT_GPIOBASE,
+               .thermalbase = 0xfed08000,
+               .system_type = 0, /* 0 Mobile, 1 Desktop/Server */
+               .tseg_size = CONFIG_SMM_TSEG_SIZE,
+               .ts_addresses = { 0x00, 0x00, 0x00, 0x00 },
+               .ec_present = 1,
+               .ddr3lv_support = 1,
+               /*
+                * 0 = leave channel enabled
+                * 1 = disable dimm 0 on channel
+                * 2 = disable dimm 1 on channel
+                * 3 = disable dimm 0+1 on channel
+                */
+               .dimm_channel0_disabled = 2,
+               .dimm_channel1_disabled = 2,
+               .max_ddr3_freq = 1600,
+               .usb_port_config = {
+                       /*
+                        * Empty and onboard Ports 0-7, set to un-used pin
+                        * OC3
+                        */
+                       { 0, 3, 0x0000 }, /* P0= Empty */
+                       { 1, 0, 0x0040 }, /* P1= Left USB 1  (OC0) */
+                       { 1, 1, 0x0040 }, /* P2= Left USB 2  (OC1) */
+                       { 1, 3, 0x0040 }, /* P3= SDCARD      (no OC) */
+                       { 0, 3, 0x0000 }, /* P4= Empty */
+                       { 1, 3, 0x0040 }, /* P5= WWAN        (no OC) */
+                       { 0, 3, 0x0000 }, /* P6= Empty */
+                       { 0, 3, 0x0000 }, /* P7= Empty */
+                       /*
+                        * Empty and onboard Ports 8-13, set to un-used pin
+                        * OC4
+                        */
+                       { 1, 4, 0x0040 }, /* P8= Camera      (no OC) */
+                       { 1, 4, 0x0040 }, /* P9= Bluetooth   (no OC) */
+                       { 0, 4, 0x0000 }, /* P10= Empty */
+                       { 0, 4, 0x0000 }, /* P11= Empty */
+                       { 0, 4, 0x0000 }, /* P12= Empty */
+                       { 0, 4, 0x0000 }, /* P13= Empty */
+               },
+       };
+       pci_dev_t dev = PCI_BDF(0, 0, 0);
+       int ret;
+
+       debug("Boot mode %d\n", gd->arch.pei_boot_mode);
+       debug("mcr_input %p\n", pei_data.mrc_input);
+       pei_data.boot_mode = gd->arch.pei_boot_mode;
+       ret = copy_spd(&pei_data);
+       if (!ret)
+               ret = sdram_initialise(&pei_data);
+       if (ret)
+               return ret;
+
+       rcba_config();
+       quick_ram_check();
+
+       writew(0xCAFE, MCHBAR_REG(SSKPD));
+
+       post_code(POST_DRAM);
+
+       ret = sdram_find(dev);
+       if (ret)
+               return ret;
+
+       gd->ram_size = gd->arch.meminfo.total_32bit_memory;
 
        return 0;
 }
arch/x86/cpu/start.S +6 -4
index f62ffeb..4e973f1 100644
@@ -94,20 +94,22 @@ car_init_ret:
         * We now have CONFIG_SYS_CAR_SIZE bytes of Cache-As-RAM (or SRAM,
         * or fully initialised SDRAM - we really don't care which)
         * starting at CONFIG_SYS_CAR_ADDR to be used as a temporary stack
-        * and early malloc area.
+        * and early malloc area. The MRC requires some space at the top.
         *
         * Stack grows down from top of CAR. We have:
         *
         * top-> CONFIG_SYS_CAR_ADDR + CONFIG_SYS_CAR_SIZE
+        *      MRC area
         *      global_data
         *      x86 global descriptor table
         *      early malloc area
         *      stack
         * bottom-> CONFIG_SYS_CAR_ADDR
         */
-
-       /* Stack grows down from top of CAR */
-       movl    $(CONFIG_SYS_CAR_ADDR + CONFIG_SYS_CAR_SIZE), %esp
+       movl    $(CONFIG_SYS_CAR_ADDR + CONFIG_SYS_CAR_SIZE - 4), %esp
+#ifdef CONFIG_DCACHE_RAM_MRC_VAR_SIZE
+       subl    CONFIG_DCACHE_RAM_MRC_VAR_SIZE, %esp
+#endif
 
        /* Reserve space on stack for global data */
        subl    $GENERATED_GBL_DATA_SIZE, %esp
arch/x86/dts/link.dts +29 -0
index 84fb0a9..f152da5 100644
@@ -41,6 +41,117 @@
        chosen { };
        memory { device_type = "memory"; reg = <0 0>; };
 
+       spd {
+               compatible = "memory-spd";
+               #address-cells = <1>;
+               #size-cells = <0>;
+               elpida_4Gb_1600_x16 {
+                       reg = <0>;
+                       data = [92 10 0b 03 04 19 02 02
+                               03 52 01 08 0a 00 fe 00
+                               69 78 69 3c 69 11 18 81
+                               20 08 3c 3c 01 40 83 81
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 0f 11 42 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 02 fe 00
+                               11 52 00 00 00 07 7f 37
+                               45 42 4a 32 30 55 47 36
+                               45 42 55 30 2d 47 4e 2d
+                               46 20 30 20 02 fe 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00

arch/x86/dts/link.dts line 82

Quoted 10 lines
arch/x86/dts/link.dts +10 -0
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00];
+               };

Is this the limitation of the MRC that it cannot read SPD from the DIMM? Or is it because the RAM chip is soldered on board?

Quoted 796 lines
arch/x86/dts/link.dts +72 -0
+               samsung_4Gb_1600_1.35v_x16 {
+                       reg = <1>;
+                       data = [92 11 0b 03 04 19 02 02
+                               03 11 01 08 0a 00 fe 00
+                               69 78 69 3c 69 11 18 81
+                               f0 0a 3c 3c 01 40 83 01
+                               00 80 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 0f 11 02 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 80 ce 01
+                               00 00 00 00 00 00 6a 04
+                               4d 34 37 31 42 35 36 37
+                               34 42 48 30 2d 59 4b 30
+                               20 20 00 00 80 ce 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00];
+                       };
+               micron_4Gb_1600_1.35v_x16 {
+                       reg = <2>;
+                       data = [92 11 0b 03 04 19 02 02
+                               03 11 01 08 0a 00 fe 00
+                               69 78 69 3c 69 11 18 81
+                               20 08 3c 3c 01 40 83 05
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 0f 01 02 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 80 2c 00
+                               00 00 00 00 00 00 ad 75
+                               34 4b 54 46 32 35 36 36
+                               34 48 5a 2d 31 47 36 45
+                               31 20 45 31 80 2c 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               00 00 00 00 00 00 00 00
+                               ff ff ff ff ff ff ff ff
+                               ff ff ff ff ff ff ff ff
+                               ff ff ff ff ff ff ff ff
+                               ff ff ff ff ff ff ff ff
+                               ff ff ff ff ff ff ff ff
+                               ff ff ff ff ff ff ff ff
+                               ff ff ff ff ff ff ff ff
+                               ff ff ff ff ff ff ff ff
+                               ff ff ff ff ff ff ff ff
+                               ff ff ff ff ff ff ff ff];
+               };
+       };
+
        spi {
                #address-cells = <1>;
                #size-cells = <0>;
arch/x86/include/asm/arch-ivybridge/me.h new file +357 -0
new file mode 100644
index 0000000..e0e41c8
@@ -0,0 +1,357 @@
+/*
+ * From Coreboot src/southbridge/intel/bd82x6x/me.h
+ *
+ * Copyright (C) 2011 The Chromium OS Authors. All rights reserved.
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#ifndef _ASM_INTEL_ME_H
+#define _ASM_INTEL_ME_H
+
+#include <linux/compiler.h>
+#include <linux/types.h>
+
+#define ME_RETRY               100000  /* 1 second */
+#define ME_DELAY               10      /* 10 us */
+
+/*
+ * Management Engine PCI registers
+ */
+
+#define PCI_CPU_DEVICE         PCI_BDF(0, 0, 0)
+#define PCI_CPU_MEBASE_L       0x70    /* Set by MRC */
+#define PCI_CPU_MEBASE_H       0x74    /* Set by MRC */
+
+#define PCI_ME_HFS             0x40
+#define  ME_HFS_CWS_RESET      0
+#define  ME_HFS_CWS_INIT       1
+#define  ME_HFS_CWS_REC                2
+#define  ME_HFS_CWS_NORMAL     5
+#define  ME_HFS_CWS_WAIT       6
+#define  ME_HFS_CWS_TRANS      7
+#define  ME_HFS_CWS_INVALID    8
+#define  ME_HFS_STATE_PREBOOT  0
+#define  ME_HFS_STATE_M0_UMA   1
+#define  ME_HFS_STATE_M3       4
+#define  ME_HFS_STATE_M0       5
+#define  ME_HFS_STATE_BRINGUP  6
+#define  ME_HFS_STATE_ERROR    7
+#define  ME_HFS_ERROR_NONE     0
+#define  ME_HFS_ERROR_UNCAT    1
+#define  ME_HFS_ERROR_IMAGE    3
+#define  ME_HFS_ERROR_DEBUG    4
+#define  ME_HFS_MODE_NORMAL    0
+#define  ME_HFS_MODE_DEBUG     2
+#define  ME_HFS_MODE_DIS       3
+#define  ME_HFS_MODE_OVER_JMPR 4
+#define  ME_HFS_MODE_OVER_MEI  5
+#define  ME_HFS_BIOS_DRAM_ACK  1
+#define  ME_HFS_ACK_NO_DID     0
+#define  ME_HFS_ACK_RESET      1
+#define  ME_HFS_ACK_PWR_CYCLE  2
+#define  ME_HFS_ACK_S3         3
+#define  ME_HFS_ACK_S4         4
+#define  ME_HFS_ACK_S5         5
+#define  ME_HFS_ACK_GBL_RESET  6
+#define  ME_HFS_ACK_CONTINUE   7
+
+struct me_hfs {
+       u32 working_state:4;
+       u32 mfg_mode:1;
+       u32 fpt_bad:1;
+       u32 operation_state:3;
+       u32 fw_init_complete:1;
+       u32 ft_bup_ld_flr:1;
+       u32 update_in_progress:1;
+       u32 error_code:4;
+       u32 operation_mode:4;
+       u32 reserved:4;
+       u32 boot_options_present:1;
+       u32 ack_data:3;
+       u32 bios_msg_ack:4;
+} __packed;
+
+#define PCI_ME_UMA             0x44
+
+struct me_uma {
+       u32 size:6;
+       u32 reserved_1:10;
+       u32 valid:1;
+       u32 reserved_0:14;
+       u32 set_to_one:1;
+} __packed;
+
+#define PCI_ME_H_GS            0x4c
+#define  ME_INIT_DONE          1
+#define  ME_INIT_STATUS_SUCCESS        0
+#define  ME_INIT_STATUS_NOMEM  1
+#define  ME_INIT_STATUS_ERROR  2
+
+struct me_did {
+       u32 uma_base:16;
+       u32 reserved:8;
+       u32 status:4;
+       u32 init_done:4;
+} __packed;
+
+#define PCI_ME_GMES            0x48
+#define  ME_GMES_PHASE_ROM     0
+#define  ME_GMES_PHASE_BUP     1
+#define  ME_GMES_PHASE_UKERNEL 2
+#define  ME_GMES_PHASE_POLICY  3
+#define  ME_GMES_PHASE_MODULE  4
+#define  ME_GMES_PHASE_UNKNOWN 5
+#define  ME_GMES_PHASE_HOST    6
+
+struct me_gmes {
+       u32 bist_in_prog:1;
+       u32 icc_prog_sts:2;
+       u32 invoke_mebx:1;
+       u32 cpu_replaced_sts:1;
+       u32 mbp_rdy:1;
+       u32 mfs_failure:1;
+       u32 warm_rst_req_for_df:1;
+       u32 cpu_replaced_valid:1;
+       u32 reserved_1:2;
+       u32 fw_upd_ipu:1;
+       u32 reserved_2:4;
+       u32 current_state:8;
+       u32 current_pmevent:4;
+       u32 progress_code:4;
+} __packed;
+
+#define PCI_ME_HERES           0xbc
+#define  PCI_ME_EXT_SHA1       0x00
+#define  PCI_ME_EXT_SHA256     0x02
+#define PCI_ME_HER(x)          (0xc0+(4*(x)))
+
+struct me_heres {
+       u32 extend_reg_algorithm:4;
+       u32 reserved:26;
+       u32 extend_feature_present:1;
+       u32 extend_reg_valid:1;
+} __packed;
+
+/*
+ * Management Engine MEI registers
+ */
+
+#define MEI_H_CB_WW            0x00
+#define MEI_H_CSR              0x04
+#define MEI_ME_CB_RW           0x08
+#define MEI_ME_CSR_HA          0x0c
+
+struct mei_csr {
+       u32 interrupt_enable:1;
+       u32 interrupt_status:1;
+       u32 interrupt_generate:1;
+       u32 ready:1;
+       u32 reset:1;
+       u32 reserved:3;
+       u32 buffer_read_ptr:8;
+       u32 buffer_write_ptr:8;
+       u32 buffer_depth:8;
+} __packed;
+
+#define MEI_ADDRESS_CORE       0x01
+#define MEI_ADDRESS_AMT                0x02
+#define MEI_ADDRESS_RESERVED   0x03
+#define MEI_ADDRESS_WDT                0x04
+#define MEI_ADDRESS_MKHI       0x07
+#define MEI_ADDRESS_ICC                0x08
+#define MEI_ADDRESS_THERMAL    0x09
+
+#define MEI_HOST_ADDRESS       0
+
+struct mei_header {
+       u32 client_address:8;
+       u32 host_address:8;
+       u32 length:9;
+       u32 reserved:6;
+       u32 is_complete:1;
+} __packed;
+
+#define MKHI_GROUP_ID_CBM      0x00
+#define MKHI_GROUP_ID_FWCAPS   0x03
+#define MKHI_GROUP_ID_MDES     0x08
+#define MKHI_GROUP_ID_GEN      0xff
+
+#define MKHI_GLOBAL_RESET      0x0b
+
+#define MKHI_FWCAPS_GET_RULE   0x02
+
+#define MKHI_MDES_ENABLE       0x09
+
+#define MKHI_GET_FW_VERSION    0x02
+#define MKHI_END_OF_POST       0x0c
+#define MKHI_FEATURE_OVERRIDE  0x14
+
+struct mkhi_header {
+       u32 group_id:8;
+       u32 command:7;
+       u32 is_response:1;
+       u32 reserved:8;
+       u32 result:8;
+} __packed;
+
+struct me_fw_version {
+       u16 code_minor;
+       u16 code_major;
+       u16 code_build_number;
+       u16 code_hot_fix;
+       u16 recovery_minor;
+       u16 recovery_major;
+       u16 recovery_build_number;
+       u16 recovery_hot_fix;
+} __packed;
+
+
+#define HECI_EOP_STATUS_SUCCESS       0x0
+#define HECI_EOP_PERFORM_GLOBAL_RESET 0x1
+
+#define CBM_RR_GLOBAL_RESET    0x01
+
+#define GLOBAL_RESET_BIOS_MRC  0x01
+#define GLOBAL_RESET_BIOS_POST 0x02
+#define GLOBAL_RESET_MEBX      0x03
+
+struct me_global_reset {
+       u8 request_origin;
+       u8 reset_type;
+} __packed;
+
+enum me_bios_path {
+       ME_NORMAL_BIOS_PATH,
+       ME_S3WAKE_BIOS_PATH,
+       ME_ERROR_BIOS_PATH,
+       ME_RECOVERY_BIOS_PATH,
+       ME_DISABLE_BIOS_PATH,
+       ME_FIRMWARE_UPDATE_BIOS_PATH,
+};
+
+struct __packed mbp_fw_version_name {
+       u32 major_version:16;
+       u32 minor_version:16;
+       u32 hotfix_version:16;
+       u32 build_version:16;
+};
+
+struct __packed mbp_icc_profile {
+       u8 num_icc_profiles;
+       u8 icc_profile_soft_strap;
+       u8 icc_profile_index;
+       u8 reserved;
+       u32 register_lock_mask[3];
+};
+
+struct __packed mefwcaps_sku {
+       u32 full_net:1;
+       u32 std_net:1;
+       u32 manageability:1;
+       u32 small_business:1;
+       u32 l3manageability:1;
+       u32 intel_at:1;
+       u32 intel_cls:1;
+       u32 reserved:3;
+       u32 intel_mpc:1;
+       u32 icc_over_clocking:1;
+       u32 pavp:1;
+       u32 reserved_1:4;
+       u32 ipv6:1;
+       u32 kvm:1;
+       u32 och:1;
+       u32 vlan:1;
+       u32 tls:1;
+       u32 reserved_4:1;
+       u32 wlan:1;
+       u32 reserved_5:8;
+};
+
+struct __packed tdt_state_flag {
+       u16 lock_state:1;
+       u16 authenticate_module:1;
+       u16 s3authentication:1;
+       u16 flash_wear_out:1;
+       u16 flash_variable_security:1;
+       u16 wwan3gpresent:1;
+       u16 wwan3goob:1;
+       u16 reserved:9;
+};
+
+struct __packed tdt_state_info {
+       u8 state;
+       u8 last_theft_trigger;
+       struct tdt_state_flag flags;
+};
+
+struct __packed platform_type_rule_data {
+       u32 platform_target_usage_type:4;
+       u32 platform_target_market_type:2;
+       u32 super_sku:1;
+       u32 reserved:1;
+       u32 intel_me_fw_image_type:4;
+       u32 platform_brand:4;
+       u32 reserved_1:16;
+};
+
+struct __packed mbp_fw_caps {
+       struct mefwcaps_sku fw_capabilities;
+       u8 available;
+};
+
+struct __packed mbp_rom_bist_data {
+       u16 device_id;
+       u16 fuse_test_flags;
+       u32 umchid[4];
+};
+
+struct __packed mbp_platform_key {
+       u32 key[8];
+};
+
+struct __packed mbp_plat_type {
+       struct platform_type_rule_data rule_data;
+       u8 available;
+};
+
+struct __packed me_bios_payload {
+       struct mbp_fw_version_name fw_version_name;
+       struct mbp_fw_caps fw_caps_sku;
+       struct mbp_rom_bist_data rom_bist_data;
+       struct mbp_platform_key platform_key;
+       struct mbp_plat_type fw_plat_type;
+       struct mbp_icc_profile icc_profile;
+       struct tdt_state_info at_state;
+       u32 mfsintegrity;
+};
+
+struct __packed mbp_header {
+       u32 mbp_size:8;
+       u32 num_entries:8;
+       u32 rsvd:16;
+};
+
+struct __packed mbp_item_header {
+       u32 app_id:8;
+       u32 item_id:8;
+       u32 length:8;
+       u32 rsvd:8;
+};
+
+struct __packed me_fwcaps {
+       u32 id;
+       u8 length;
+       struct mefwcaps_sku caps_sku;
+       u8 reserved[3];
+};
+
+/* Defined in me_status.c for both romstage and ramstage */
+void intel_me_status(struct me_hfs *hfs, struct me_gmes *gmes);
+
+void intel_early_me_status(void);
+int intel_early_me_init(void);
+int intel_early_me_uma_size(void);
+int intel_early_me_init_done(u8 status);
+
+#endif
arch/x86/include/asm/arch-ivybridge/pch.h +113 -0
index ae338e3..c6efdb8 100644
@@ -31,6 +31,13 @@
 /* PCI Configuration Space (D31:F0): LPC */
 #define PCH_LPC_DEV            PCI_BDF(0, 0x1f, 0)
 
+#define GEN_PMCON_1            0xa0
+#define GEN_PMCON_2            0xa2
+#define GEN_PMCON_3            0xa4
+#define ETR3                   0xac
+#define  ETR3_CWORWRE          (1 << 18)
+#define  ETR3_CF9GR            (1 << 20)
+
 #define PMBASE                 0x40
 #define ACPI_CNTL              0x44
 #define BIOS_CNTL              0xDC
@@ -126,12 +133,97 @@
 #define RPC            0x0400  /* 32bit */
 #define RPFN           0x0404  /* 32bit */
 
+#define TRSR           0x1e00  /*  8bit */
+#define TRCR           0x1e10  /* 64bit */
+#define TWDR           0x1e18  /* 64bit */
+
+#define IOTR0          0x1e80  /* 64bit */
+#define IOTR1          0x1e88  /* 64bit */
+#define IOTR2          0x1e90  /* 64bit */
+#define IOTR3          0x1e98  /* 64bit */
+
+#define TCTL           0x3000  /*  8bit */
+
+#define NOINT          0
+#define INTA           1
+#define INTB           2
+#define INTC           3
+#define INTD           4
+
+#define DIR_IDR                12      /* Interrupt D Pin Offset */
+#define DIR_ICR                8       /* Interrupt C Pin Offset */
+#define DIR_IBR                4       /* Interrupt B Pin Offset */
+#define DIR_IAR                0       /* Interrupt A Pin Offset */
+
+#define PIRQA          0
+#define PIRQB          1
+#define PIRQC          2
+#define PIRQD          3
+#define PIRQE          4
+#define PIRQF          5
+#define PIRQG          6
+#define PIRQH          7
+
+/* IO Buffer Programming */
+#define IOBPIRI                0x2330
+#define IOBPD          0x2334
+#define IOBPS          0x2338
+#define  IOBPS_RW_BX    ((1 << 9)|(1 << 10))
+#define  IOBPS_WRITE_AX        ((1 << 9)|(1 << 10))
+#define  IOBPS_READ_AX ((1 << 8)|(1 << 9)|(1 << 10))
+
+#define D31IP          0x3100  /* 32bit */
+#define D31IP_TTIP     24      /* Thermal Throttle Pin */
+#define D31IP_SIP2     20      /* SATA Pin 2 */
+#define D31IP_SMIP     12      /* SMBUS Pin */
+#define D31IP_SIP      8       /* SATA Pin */
+#define D30IP          0x3104  /* 32bit */
+#define D30IP_PIP      0       /* PCI Bridge Pin */
+#define D29IP          0x3108  /* 32bit */
+#define D29IP_E1P      0       /* EHCI #1 Pin */
+#define D28IP          0x310c  /* 32bit */
+#define D28IP_P8IP     28      /* PCI Express Port 8 */
+#define D28IP_P7IP     24      /* PCI Express Port 7 */
+#define D28IP_P6IP     20      /* PCI Express Port 6 */
+#define D28IP_P5IP     16      /* PCI Express Port 5 */
+#define D28IP_P4IP     12      /* PCI Express Port 4 */
+#define D28IP_P3IP     8       /* PCI Express Port 3 */
+#define D28IP_P2IP     4       /* PCI Express Port 2 */
+#define D28IP_P1IP     0       /* PCI Express Port 1 */
+#define D27IP          0x3110  /* 32bit */
+#define D27IP_ZIP      0       /* HD Audio Pin */
+#define D26IP          0x3114  /* 32bit */
+#define D26IP_E2P      0       /* EHCI #2 Pin */
+#define D25IP          0x3118  /* 32bit */
+#define D25IP_LIP      0       /* GbE LAN Pin */
+#define D22IP          0x3124  /* 32bit */
+#define D22IP_KTIP     12      /* KT Pin */
+#define D22IP_IDERIP   8       /* IDE-R Pin */
+#define D22IP_MEI2IP   4       /* MEI #2 Pin */
+#define D22IP_MEI1IP   0       /* MEI #1 Pin */
+#define D20IP          0x3128  /* 32bit */
+#define D20IP_XHCIIP   0
+#define D31IR          0x3140  /* 16bit */
+#define D30IR          0x3142  /* 16bit */
+#define D29IR          0x3144  /* 16bit */
+#define D28IR          0x3146  /* 16bit */
+#define D27IR          0x3148  /* 16bit */
+#define D26IR          0x314c  /* 16bit */
+#define D25IR          0x3150  /* 16bit */
+#define D22IR          0x315c  /* 16bit */
+#define D20IR          0x3160  /* 16bit */
+#define OIC            0x31fe  /* 16bit */
+
 #define SPI_FREQ_SWSEQ 0x3893
 #define SPI_DESC_COMP0 0x38b0
 #define SPI_FREQ_WR_ERA        0x38b4
 #define SOFT_RESET_CTRL 0x38f4
 #define SOFT_RESET_DATA 0x38f8
 
+#define DIR_ROUTE(a, b, c, d) \
+               (((d) << DIR_IDR) | ((c) << DIR_ICR) | \
+                       ((b) << DIR_IBR) | ((a) << DIR_IAR))
+
 #define RC             0x3400  /* 32bit */
 #define HPTC           0x3404  /* 32bit */
 #define GCS            0x3410  /* 32bit */
@@ -142,6 +234,27 @@
 #define FD2            0x3428  /* 32bit */
 #define CG             0x341c  /* 32bit */
 
+/* Function Disable 1 RCBA 0x3418 */
+#define PCH_DISABLE_ALWAYS     ((1 << 0)|(1 << 26))
+#define PCH_DISABLE_P2P                (1 << 1)
+#define PCH_DISABLE_SATA1      (1 << 2)
+#define PCH_DISABLE_SMBUS      (1 << 3)
+#define PCH_DISABLE_HD_AUDIO   (1 << 4)
+#define PCH_DISABLE_EHCI2      (1 << 13)
+#define PCH_DISABLE_LPC                (1 << 14)
+#define PCH_DISABLE_EHCI1      (1 << 15)
+#define PCH_DISABLE_PCIE(x)    (1 << (16 + x))
+#define PCH_DISABLE_THERMAL    (1 << 24)
+#define PCH_DISABLE_SATA2      (1 << 25)
+#define PCH_DISABLE_XHCI       (1 << 27)
+
+/* Function Disable 2 RCBA 0x3428 */
+#define PCH_DISABLE_KT         (1 << 4)
+#define PCH_DISABLE_IDER       (1 << 3)
+#define PCH_DISABLE_MEI2       (1 << 2)
+#define PCH_DISABLE_MEI1       (1 << 1)
+#define PCH_ENABLE_DBDF                (1 << 0)
+
 /* ICH7 GPIOBASE */
 #define GPIO_USE_SEL   0x00
 #define GP_IO_SEL      0x04
arch/x86/include/asm/arch-ivybridge/pei_data.h new file +121 -0
new file mode 100644
index 0000000..5026c8b
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2011, Google Inc.
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#ifndef ASM_ARCH_PEI_DATA_H
+#define ASM_ARCH_PEI_DATA_H
+
+struct pch_usb3_controller_settings {
+       /* 0: Disable, 1: Enable, 2: Auto, 3: Smart Auto */
+       uint16_t mode;
+       /* 4 bit mask, 1: switchable, 0: not switchable */
+       uint16_t hs_port_switch_mask;
+       /* 0: No xHCI preOS driver, 1: xHCI preOS driver */
+       uint16_t preboot_support;
+       /* 0: Disable, 1: Enable */
+       uint16_t xhci_streams;
+};
+
+typedef asmlinkage void (*tx_byte_func)(unsigned char byte);
+
+#define PEI_VERSION 6
+
+struct __packed pei_data {
+       uint32_t pei_version;
+       uint32_t mchbar;
+       uint32_t dmibar;
+       uint32_t epbar;
+       uint32_t pciexbar;
+       uint16_t smbusbar;
+       uint32_t wdbbar;
+       uint32_t wdbsize;
+       uint32_t hpet_address;
+       uint32_t rcba;
+       uint32_t pmbase;
+       uint32_t gpiobase;
+       uint32_t thermalbase;
+       uint32_t system_type; /* 0 Mobile, 1 Desktop/Server */
+       uint32_t tseg_size;
+       uint8_t spd_addresses[4];
+       uint8_t ts_addresses[4];
+       int boot_mode;
+       int ec_present;
+       int gbe_enable;
+       /*
+        * 0 = leave channel enabled
+        * 1 = disable dimm 0 on channel
+        * 2 = disable dimm 1 on channel
+        * 3 = disable dimm 0+1 on channel
+        */
+       int dimm_channel0_disabled;
+       int dimm_channel1_disabled;
+       /* Seed values saved in CMOS */
+       uint32_t scrambler_seed;
+       uint32_t scrambler_seed_s3;
+       /* Data read from flash and passed into MRC */
+       unsigned char *mrc_input;
+       unsigned int mrc_input_len;
+       /* Data from MRC that should be saved to flash */
+       unsigned char *mrc_output;
+       unsigned int mrc_output_len;
+       /*
+        * Max frequency DDR3 could be ran at. Could be one of four values:
+        * 800, 1067, 1333, 1600
+        */
+       uint32_t max_ddr3_freq;
+       /*
+        * USB Port Configuration:
+        *  [0] = enable
+        *  [1] = overcurrent pin
+        *  [2] = length
+        *
+        * Ports 0-7 can be mapped to OC0-OC3
+        * Ports 8-13 can be mapped to OC4-OC7
+        *
+        * Port Length
+        *  MOBILE:
+        *   < 0x050 = Setting 1 (back panel, 1-5in, lowest tx amplitude)
+        *   < 0x140 = Setting 2 (back panel, 5-14in, highest tx amplitude)
+        *  DESKTOP:
+        *   < 0x080 = Setting 1 (front/back panel, <8in, lowest tx amplitude)
+        *   < 0x130 = Setting 2 (back panel, 8-13in, higher tx amplitude)
+        *   < 0x150 = Setting 3 (back panel, 13-15in, higest tx amplitude)
+        */
+       uint16_t usb_port_config[16][3];
+       /* See the usb3 struct above for details */
+       struct pch_usb3_controller_settings usb3;
+       /*
+        * SPD data array for onboard RAM. Specify address 0xf0,
+        * 0xf1, 0xf2, 0xf3 to index one of the 4 slots in
+        * spd_address for a given "DIMM".
+        */
+       uint8_t spd_data[4][256];
+       tx_byte_func tx_byte;
+       int ddr3lv_support;
+       /*
+        * pcie_init needs to be set to 1 to have the system agent initialise
+        * PCIe. Note: This should only be required if your system has Gen3
+        * devices and it will increase your boot time by at least 100ms.
+        */
+       int pcie_init;
+       /*
+        * N mode functionality. Leave this setting at 0.
+        * 0 Auto
+        * 1 1N
+        * 2 2N
+        */
+       int nmode;
+       /*
+        * DDR refresh rate config. JEDEC Standard No.21-C Annex K allows
+        * for DIMM SPD data to specify whether double-rate is required for
+        * extended operating temperature range.
+        * 0 Enable double rate based upon temperature thresholds
+        * 1 Normal rate
+        * 2 Always enable double rate
+        */
+       int ddr_refresh_rate_config;
+};
+
+#endif
arch/x86/include/asm/arch-ivybridge/sandybridge.h +2 -0
index a1072f2..114ee19 100644
@@ -102,6 +102,8 @@
 #define SSKPD          0x5d14  /* 16bit (scratchpad) */
 #define BIOS_RESET_CPL 0x5da8  /* 8bit */
 
+void report_platform_info(void);
+
 void sandybridge_early_init(int chipset_type);
 
 #endif
arch/x86/include/asm/config.h +1 -0
index ff15828..c97d988 100644
@@ -10,5 +10,6 @@
 #define CONFIG_SYS_GENERIC_BOARD
 #define CONFIG_LMB
 #define CONFIG_SYS_BOOT_RAMDISK_HIGH
+#define asmlinkage __attribute__((regparm(0)))
 
 #endif
arch/x86/include/asm/global_data.h +13 -0
index 351581b..80bc3e8 100644
@@ -17,6 +17,18 @@ enum pei_boot_mode_t {
 
 };
 
+struct memory_area {
+       uint64_t start;
+       uint64_t size;
+};
+
+struct memory_info {
+       int num_areas;
+       uint64_t total_memory;
+       uint64_t total_32bit_memory;
+       struct memory_area area[CONFIG_NR_DRAM_BANKS];
+};
+
 /* Architecture-specific global data */
 struct arch_global_data {
        struct global_data *gd_addr;            /* Location of Global Data */
@@ -28,6 +40,7 @@ struct arch_global_data {
        struct pci_controller *hose;    /* PCI hose for early use */
        enum pei_boot_mode_t pei_boot_mode;
        const struct pch_gpio_map *gpio_map;    /* board GPIO map */
+       struct memory_info meminfo;     /* Memory information */
 };
 
 #endif
arch/x86/include/asm/post.h +5 -0
index 61dcda1..ce68839 100644
@@ -27,6 +27,11 @@
 #define POST_CPU_INIT          0x2b
 #define POST_EARLY_INIT                0x2c
 #define POST_CPU_INFO          0x2d
+#define POST_PRE_MRC           0x2e
+#define POST_MRC               0x2f
+#define POST_DRAM              0x2f
+
+#define POST_RAM_FAILURE       0xea
 
 /* Output a post code using al - value must be 0 to 0xff */
 #ifdef __ASSEMBLY__
arch/x86/include/asm/u-boot-x86.h +2 -0
index 6404cd3..f20e5b5 100644
@@ -72,4 +72,6 @@ static inline __attribute__((no_instrument_function)) uint64_t rdtsc(void)
 void timer_set_tsc_base(uint64_t new_base);
 uint64_t timer_get_tsc(void);
 
+void quick_ram_check(void);
+
 #endif /* _U_BOOT_I386_H_ */
arch/x86/lib/Makefile +0 -0
index 25b672a..d0c7f30 100644

arch/x86/lib/Makefile obj-$(CONFIG_SYS_PCAT_TIMER) += pcat_timer.o · line 18

Quoted 4 lines
arch/x86/lib/Makefile +1 -0
@@ -15,6 +15,7 @@ obj-$(CONFIG_SYS_PCAT_TIMER) += pcat_timer.o
 obj-$(CONFIG_PCI) += pci_type1.o
 obj-y  += relocate.o
 obj-y += physmem.o
+obj-y += ramtest.o

Can we make the ramtest wrapped by CONFIG_X86_RAMTEST?

Quoted 141 lines
arch/x86/lib/Makefile +0 -0
 obj-y  += string.o
 obj-$(CONFIG_SYS_X86_TSC_TIMER)        += tsc_timer.o
 obj-$(CONFIG_VIDEO_VGA)        += video.o
arch/x86/lib/ramtest.c new file +79 -0
new file mode 100644
index 0000000..c21be03
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2014 Google, Inc
+ *
+ * From Coreboot src/lib/ramtest.c
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/post.h>
+
+static void write_phys(unsigned long addr, u32 value)
+{
+#if CONFIG_SSE2
+       asm volatile(
+               "movnti %1, (%0)"
+               : /* outputs */
+               : "r" (addr), "r" (value) /* inputs */
+               : /* clobbers */
+               );
+#else
+       writel(value, addr);
+#endif
+}
+
+static u32 read_phys(unsigned long addr)
+{
+       return readl(addr);
+}
+
+static void phys_memory_barrier(void)
+{
+#if CONFIG_SSE2
+       /* Needed for movnti */
+       asm volatile(
+               "sfence"
+               :
+               :
+               : "memory"
+       );
+#else
+       asm volatile(""
+               :
+               :
+               : "memory");
+#endif
+}
+
+void quick_ram_check(void)
+{
+       int fail = 0;
+       u32 backup;
+
+       backup = read_phys(CONFIG_RAMBASE);
+       write_phys(CONFIG_RAMBASE, 0x55555555);
+       phys_memory_barrier();
+       if (read_phys(CONFIG_RAMBASE) != 0x55555555)
+               fail = 1;
+       write_phys(CONFIG_RAMBASE, 0xaaaaaaaa);
+       phys_memory_barrier();
+       if (read_phys(CONFIG_RAMBASE) != 0xaaaaaaaa)
+               fail = 1;
+       write_phys(CONFIG_RAMBASE, 0x00000000);
+       phys_memory_barrier();
+       if (read_phys(CONFIG_RAMBASE) != 0x00000000)
+               fail = 1;
+       write_phys(CONFIG_RAMBASE, 0xffffffff);
+       phys_memory_barrier();
+       if (read_phys(CONFIG_RAMBASE) != 0xffffffff)
+               fail = 1;
+
+       write_phys(CONFIG_RAMBASE, backup);
+       if (fail) {
+               post_code(POST_RAM_FAILURE);
+               panic("RAM INIT FAILURE!\n");
+       }
+       phys_memory_barrier();
+}
include/configs/chromebook_link.h +5 -0
index 637bdb9..64b7490 100644
@@ -18,13 +18,18 @@
 #define CONFIG_SYS_CAR_ADDR                    0xff7e0000
 #define CONFIG_SYS_CAR_SIZE                    (128 * 1024)
 #define CONFIG_SYS_MONITOR_LEN                 (1 << 20)
+#define CONFIG_DCACHE_RAM_MRC_VAR_SIZE         0x4000
 #define CONFIG_SYS_X86_START16                 0xfffff800
 #define CONFIG_BOARD_EARLY_INIT_F
 #define CONFIG_BOARD_EARLY_INIT_R
+#define CONFIG_DISPLAY_CPUINFO
 
 #define CONFIG_X86_RESET_VECTOR
 #define CONFIG_NR_DRAM_BANKS                   8
 
+#define CONFIG_X86_MRC_START                   0xfffa0000
+#define CONFIG_CACHE_MRC_SIZE_KB               512
+
 /*
  * These common x86 features are not yet supported, but are added in
  * follow-on patches in this series. Add undefs here to avoid every patch
include/configs/x86-common.h +1 -1
index 33ff04f..6d3bcc9 100644
@@ -208,7 +208,7 @@
 #define CONFIG_SYS_STACK_SIZE                  (32 * 1024)
 #define CONFIG_SYS_MONITOR_BASE                CONFIG_SYS_TEXT_BASE
 #define CONFIG_SYS_MALLOC_LEN                  0x200000
-#define CONFIG_SYS_MALLOC_F_LEN                        (1 << 10)
+#define CONFIG_SYS_MALLOC_F_LEN                        (2 << 10)
 
 /* allow to overwrite serial and ethaddr */
 #define CONFIG_ENV_OVERWRITE
include/fdtdec.h +1 -0
index 3bd60b7..abfd678 100644
@@ -119,6 +119,7 @@ enum fdt_compat_id {
        COMPAT_PARADE_PS8625,           /* Parade PS8622 EDP->LVDS bridge */
        COMPAT_INTEL_LPC,               /* Intel Low Pin Count I/F */
        COMPAT_INTEL_MICROCODE,         /* Intel microcode update */
+       COMPAT_MEMORY_SPD,              /* Memory SPD information */
 
        COMPAT_COUNT,
 };
lib/fdtdec.c +0 -0
index 9a68f9c..aafc4f9 100644

lib/fdtdec.c static const char * const compat_names[COMPAT_COUNT] = {

Quoted 8 lines
lib/fdtdec.c +1 -1
@@ -74,6 +74,7 @@ static const char * const compat_names[COMPAT_COUNT] = {
        COMPAT(PARADE_PS8625, "parade,ps8625"),
        COMPAT(COMPAT_INTEL_LPC, "intel,lpc"),
        COMPAT(INTEL_MICROCODE, "intel,microcode"),
+       COMPAT(MEMORY_SPD, "memory-spd"),
 };
 
 const char *fdtdec_get_compatible(enum fdt_compat_id id)
--

Regards,
Bin

#92 lore raw

PATCH 39/39 x86: ivybridge: Implement SDRAM init

In reply to Simon Glass

Hi Simon,

Quoted 5 lines · Simon Glass

Implement SDRAM init using the Memory Reference Code (mrc.bin) provided in the board directory and the SDRAM SPD information in the device tree. This also needs the Intel Management Engine (me.bin) to work. Binary blobs
everywhere: so far we have MRC, ME and microcode.

[snip]

Makefile u-boot.rom: u-boot-x86-16bit.bin u-boot-dtb.bin \ · line 960

Quoted 10 lines
Makefile +2 -0
index 86d0510..4f0260f 100644
@@ -956,9 +956,14 @@ u-boot.rom: u-boot-x86-16bit.bin u-boot-dtb.bin \
                $(srctree)/board/$(BOARDDIR)/descriptor.bin
        $(objtree)/tools/ifdtool -c -r $(CONFIG_ROM_SIZE) \
                -D $(srctree)/board/$(BOARDDIR)/descriptor.bin u-boot.tmp
+       $(objtree)/tools/ifdtool \
+               -i ME:$(srctree)/board/$(BOARDDIR)/me.bin u-boot.tmp

Can we make the ME injection depend on something like CONFIG_X86_HAVE_ME?

Makefile u-boot.rom: u-boot-x86-16bit.bin u-boot-dtb.bin \ · line 965

Quoted 5 lines
Makefile +2 -0
        $(objtree)/tools/ifdtool -w \
                $(CONFIG_SYS_TEXT_BASE):$(objtree)/u-boot-dtb.bin u-boot.tmp
        $(objtree)/tools/ifdtool -w \
+               $(CONFIG_X86_MRC_START):$(srctree)/board/$(BOARDDIR)/mrc.bin \
+               u-boot.tmp

Ditto.

Makefile u-boot.rom: u-boot-x86-16bit.bin u-boot-dtb.bin \ · line 969

Quoted 4 lines
Makefile +1 -0
+       $(objtree)/tools/ifdtool -w \
                $(CONFIG_SYS_X86_START16):$(objtree)/u-boot-x86-16bit.bin \
                u-boot.tmp
        mv u-boot.tmp $@

Regards,
Bin

#93 lore raw

PATCH 39/39 x86: ivybridge: Implement SDRAM init

Hi Bin,

Quoted 11 lines · Bin Meng

Hi Simon,

Quoted 5 lines · Simon Glass

Implement SDRAM init using the Memory Reference Code (mrc.bin) provided in the board directory and the SDRAM SPD information in the device tree. This also needs the Intel Management Engine (me.bin) to work. Binary blobs
everywhere: so far we have MRC, ME and microcode.

[snip]

Quoted 12 lines

Makefile u-boot.rom: u-boot-x86-16bit.bin u-boot-dtb.bin \ · line 960

Quoted 10 lines
Makefile +2 -0
index 86d0510..4f0260f 100644
@@ -956,9 +956,14 @@ u-boot.rom: u-boot-x86-16bit.bin u-boot-dtb.bin \
                $(srctree)/board/$(BOARDDIR)/descriptor.bin
        $(objtree)/tools/ifdtool -c -r $(CONFIG_ROM_SIZE) \
                -D $(srctree)/board/$(BOARDDIR)/descriptor.bin u-boot.tmp
+       $(objtree)/tools/ifdtool \
+               -i ME:$(srctree)/board/$(BOARDDIR)/me.bin u-boot.tmp

Can we make the ME injection depend on something like CONFIG_X86_HAVE_ME?

Sure - do you have a case that doesn't use ME?

Quoted 9 lines

Makefile u-boot.rom: u-boot-x86-16bit.bin u-boot-dtb.bin \ · line 965

Quoted 6 lines
Makefile +2 -0
        $(objtree)/tools/ifdtool -w \
                $(CONFIG_SYS_TEXT_BASE):$(objtree)/u-boot-dtb.bin u-boot.tmp
        $(objtree)/tools/ifdtool -w \
+               $(CONFIG_X86_MRC_START):$(srctree)/board/$(BOARDDIR)/mrc.bin \
+               u-boot.tmp

Ditto.

Quoted 7 lines

Makefile u-boot.rom: u-boot-x86-16bit.bin u-boot-dtb.bin \ · line 969

Quoted 4 lines
Makefile +1 -0
+       $(objtree)/tools/ifdtool -w \
                $(CONFIG_SYS_X86_START16):$(objtree)/u-boot-x86-16bit.bin \
                u-boot.tmp
        mv u-boot.tmp $@

Regards,
Bin

Regards,
Simon

#94 lore raw

PATCH 39/39 x86: ivybridge: Implement SDRAM init

Hi Simon,

Quoted 27 lines · Simon Glass

Hi Bin,

Quoted 11 lines · Bin Meng

Hi Simon,

Quoted 5 lines · Simon Glass

Implement SDRAM init using the Memory Reference Code (mrc.bin) provided in the board directory and the SDRAM SPD information in the device tree. This also needs the Intel Management Engine (me.bin) to work. Binary blobs
everywhere: so far we have MRC, ME and microcode.

[snip]

Quoted 12 lines

Makefile u-boot.rom: u-boot-x86-16bit.bin u-boot-dtb.bin \ · line 960

Quoted 10 lines
Makefile +2 -0
index 86d0510..4f0260f 100644
@@ -956,9 +956,14 @@ u-boot.rom: u-boot-x86-16bit.bin u-boot-dtb.bin \
                $(srctree)/board/$(BOARDDIR)/descriptor.bin
        $(objtree)/tools/ifdtool -c -r $(CONFIG_ROM_SIZE) \
                -D $(srctree)/board/$(BOARDDIR)/descriptor.bin u-boot.tmp
+       $(objtree)/tools/ifdtool \
+               -i ME:$(srctree)/board/$(BOARDDIR)/me.bin u-boot.tmp

Can we make the ME injection depend on something like CONFIG_X86_HAVE_ME?

Quoted 1 line

Sure - do you have a case that doesn't use ME?

The platform (Atom E6xx and EG20T) I am working on does not have the ME. Note it also does not have the descriptor.bin.

Regards,
Bin