the following patch was just integrated into master:
commit 22009a3a582e52d5f78ce9e04705e1888263eeda
Author: Stefan Reinauer <stefan.reinauer(a)coreboot.org>
Date: Fri Jan 29 17:39:07 2016 -0800
buildgcc: Reorganize when IASL is built
Instead of passing a variable around and painstakingly making sure that
one target builds with it, and the others without, make IASL a
dependency of the "catch all" targets.
This also drops iasl as dependency from individual architecture targets,
but things are more orthogonal that way.
Note: instead of `make crossgcc-i386`, use `make crossgcc-i386 iasl`
Change-Id: I8cd2e89acdd0f795836571470bad28fbf8797f58
Signed-off-by: Stefan Reinauer <stefan.reinauer(a)coreboot.org>
Signed-off-by: Patrick Georgi <pgeorgi(a)chromium.org>
Reviewed-on: https://review.coreboot.org/13563
Tested-by: build bot (Jenkins)
Reviewed-by: Martin Roth <martinroth(a)google.com>
See https://review.coreboot.org/13563 for details.
-gerrit
the following patch was just integrated into master:
commit 8adbcc24309a5965c0e28aa3deca57cf23088ddb
Author: Stefan Reinauer <stefan.reinauer(a)coreboot.org>
Date: Fri Jan 29 17:39:07 2016 -0800
buildgcc: add nds32le compiler
Some Chrome ECs are based on that architecture
Change-Id: Ib5d0c2f6f518fafc1ceb02c5f71c0935d16c66bb
Signed-off-by: Stefan Reinauer <stefan.reinauer(a)coreboot.org>
Signed-off-by: Patrick Georgi <pgeorgi(a)chromium.org>
Reviewed-on: https://review.coreboot.org/13562
Tested-by: build bot (Jenkins)
Reviewed-by: Martin Roth <martinroth(a)google.com>
See https://review.coreboot.org/13562 for details.
-gerrit
the following patch was just integrated into master:
commit 2cc2ff6f3fb6311ca4ae308b105b185edfb9e10f
Author: Stefan Reinauer <stefan.reinauer(a)coreboot.org>
Date: Fri Jan 29 17:39:07 2016 -0800
buildgcc: Rename ARM target from armv7a to arm
The ARM target can compile for much more than just v7a.
Change-Id: Ia4f67abcffdfe9c56c5d1848c75dfea83755e755
Signed-off-by: Stefan Reinauer <stefan.reinauer(a)coreboot.org>
Signed-off-by: Patrick Georgi <pgeorgi(a)chromium.org>
Reviewed-on: https://review.coreboot.org/13517
Tested-by: build bot (Jenkins)
Reviewed-by: Martin Roth <martinroth(a)google.com>
See https://review.coreboot.org/13517 for details.
-gerrit
Alexandru Gagniuc (mr.nuke.me(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/13391
-gerrit
commit a0db0015a3223863de7c078030e325e430725265
Author: Alexandru Gagniuc <mr.nuke.me(a)gmail.com>
Date: Tue Nov 24 16:40:10 2015 -0800
libpayload: x86/timer: Implement constant TSC based calibration
On certain SOCs, such as Apollolake, the 8254 timer is not present or
not operational. On such systems, attempting to calibrate the TSC
against the 8254 will hang the payload. The next best approach is to
identify processors with a constant TSC rate, and determine the actual
speed by reading model-specific registers.
With this patch, filo can now succesfully load the filo shell on
Appololalke RVP2 board.
Change-Id: I863acbc015cf072fa007584ab1d4f4531f0a6d4f
Signed-off-by: Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com>
Signed-off-by: Andrey Petrov <andrey.petrov(a)intel.com>
---
payloads/libpayload/arch/x86/timer.c | 99 ++++++++++++++++++++++++++++++++++--
1 file changed, 95 insertions(+), 4 deletions(-)
diff --git a/payloads/libpayload/arch/x86/timer.c b/payloads/libpayload/arch/x86/timer.c
index bf0c30a..eb222b2 100644
--- a/payloads/libpayload/arch/x86/timer.c
+++ b/payloads/libpayload/arch/x86/timer.c
@@ -33,20 +33,93 @@
*/
#include <libpayload.h>
+#include <arch/cpuid.h>
#include <arch/rdtsc.h>
+#include <arch/msr.h>
+#define MSR_PLATFORM_INFO 0xce
/**
* @ingroup arch
* Global variable containing the speed of the processor in KHz.
*/
uint32_t cpu_khz;
-/**
- * Calculate the speed of the processor for use in delays.
+static const char intel_cpuid_mfg_string[] = "GenuineIntel";
+
+/*
+ * Certain Atom SOCs don't either don't have an 8254 timer (PIT), or coreboot
+ * disables the PIT. In these cases TSC calibration by PIT will hang.
*
- * @return The CPU speed in kHz.
+ * NOTE: This table and its associated helper functions can be extended to
+ * support a larger range of CPUs and access methods. This only includes tested
+ * CPUs.
*/
-unsigned int get_cpu_speed(void)
+static const struct fsb_freq_descriptor {
+ uint8_t cpu_family;
+ uint8_t cpu_model;
+ unsigned int base_clock_khz;
+} intel_freq_table[] = {
+ { 6, 0x5c, 100000 }, /* Apollolake (Broxton A0) */
+};
+
+static const struct fsb_freq_descriptor *get_cpu_freq_info(void)
+{
+ size_t i;
+ struct cpuid_fms fms = cpuid_get_fms();
+
+ for (i = 0; i < ARRAY_SIZE(intel_freq_table); i++) {
+ if ((intel_freq_table[i].cpu_family == fms.family) &&
+ (intel_freq_table[i].cpu_model == fms.model)) {
+ return &intel_freq_table[i];
+ }
+ }
+
+ return NULL;
+}
+
+static int is_intel_cpu(void)
+{
+ char id_string[12];
+ struct cpuid_result res;
+
+ /* Get manufacturer's ID string */
+ res = cpuid(0);
+ memcpy(id_string + 0, &res.ebx, 4);
+ memcpy(id_string + 4, &res.edx, 4);
+ memcpy(id_string + 8, &res.ecx, 4);
+
+ return !memcmp(intel_cpuid_mfg_string, id_string, 12);
+}
+
+/*
+ * Get the speed of the processor's timestamp counter on supported CPUs
+ */
+static unsigned int get_cpu_speed_by_const_tsc(void)
+{
+ uint64_t msr;
+ uint32_t tsc_multiplier;
+ const struct fsb_freq_descriptor *freq_info;
+
+ if (!is_intel_cpu())
+ return 0;
+
+ freq_info = get_cpu_freq_info();
+ if (!freq_info)
+ return 0;
+
+ msr = _rdmsr(MSR_PLATFORM_INFO);
+ tsc_multiplier = (msr >> 8) & 0xff;
+
+ cpu_khz = (freq_info->base_clock_khz * tsc_multiplier);
+ return cpu_khz;
+}
+
+/*
+ * Get the speed of the processor's timestamp counter by calibrating it
+ * against the 8254 programmable interval timer.
+ * This function waits 2 ms to get an accurate calibration.
+ */
+static unsigned int get_cpu_speed_by_8254_timer(void)
{
unsigned long long start, end;
const uint32_t clock_rate = 1193182; // 1.193182 MHz
@@ -76,3 +149,21 @@ unsigned int get_cpu_speed(void)
return cpu_khz;
}
+
+/**
+ * Calculate the speed of the processor for use in delays.
+ *
+ * @return The CPU speed in kHz.
+ */
+unsigned int get_cpu_speed(void)
+{
+ uint32_t tsc_rate_khz;
+
+ tsc_rate_khz = get_cpu_speed_by_const_tsc();
+ if (tsc_rate_khz)
+ return tsc_rate_khz;
+
+ tsc_rate_khz = get_cpu_speed_by_8254_timer();
+
+ return tsc_rate_khz;
+}
Alexandru Gagniuc (mr.nuke.me(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/13303
-gerrit
commit 62778a6106c09fc0b4a25e8cbf33432b3f213dd6
Author: Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com>
Date: Tue Oct 6 16:31:34 2015 -0700
soc/apollolake: Add tsc_freq_mhz() functionality for udelay()
Change-Id: I2f1147cefe2438992bff45fc0a1e91064217915d
Signed-off-by: Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com>
---
src/soc/intel/apollolake/Kconfig | 1 +
src/soc/intel/apollolake/Makefile.inc | 5 +++++
src/soc/intel/apollolake/include/soc/cpu.h | 20 ++++++++++++++++++++
src/soc/intel/apollolake/tsc_freq.c | 21 +++++++++++++++++++++
4 files changed, 47 insertions(+)
diff --git a/src/soc/intel/apollolake/Kconfig b/src/soc/intel/apollolake/Kconfig
index f7ae68e..825a40f 100644
--- a/src/soc/intel/apollolake/Kconfig
+++ b/src/soc/intel/apollolake/Kconfig
@@ -32,6 +32,7 @@ config CPU_SPECIFIC_OPTIONS
select RELOCATABLE_RAMSTAGE # Build fails if this is not selected
select SOC_INTEL_COMMON
select UDELAY_TSC
+ select TSC_CONSTANT_RATE
config MMCONF_BASE_ADDRESS
hex "PCI MMIO Base Address"
diff --git a/src/soc/intel/apollolake/Makefile.inc b/src/soc/intel/apollolake/Makefile.inc
index cc3e013..17b4ae4 100644
--- a/src/soc/intel/apollolake/Makefile.inc
+++ b/src/soc/intel/apollolake/Makefile.inc
@@ -10,6 +10,11 @@ subdirs-y += ../../../cpu/x86/tsc
bootblock-y += bootblock/bootblock_car.c
bootblock-y += bootblock/cache_as_ram.S
bootblock-y += bootblock/early_chipset_config.S
+bootblock-y += tsc_freq.c
+
+romstage-y += tsc_freq.c
+
+ramstage-y += tsc_freq.c
romstage-y += placeholders.c
smm-y += placeholders.c
diff --git a/src/soc/intel/apollolake/include/soc/cpu.h b/src/soc/intel/apollolake/include/soc/cpu.h
new file mode 100644
index 0000000..d0d6afd
--- /dev/null
+++ b/src/soc/intel/apollolake/include/soc/cpu.h
@@ -0,0 +1,20 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2015 Intel Corp.
+ * (Written by Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com> for Intel Corp.)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef _SOC_APOLLOLAKE_CPU_H_
+#define _SOC_APOLLOLAKE_CPU_H_
+
+#define MSR_PLATFORM_INFO 0xce
+
+#define BASE_CLOCK_MHZ 100
+
+#endif /* _SOC_APOLLOLAKE_CPU_H_ */
diff --git a/src/soc/intel/apollolake/tsc_freq.c b/src/soc/intel/apollolake/tsc_freq.c
new file mode 100644
index 0000000..2e90ef2
--- /dev/null
+++ b/src/soc/intel/apollolake/tsc_freq.c
@@ -0,0 +1,21 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2015 Intel Corp.
+ * (Written by Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com> for Intel Corp.)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <cpu/x86/msr.h>
+#include <cpu/x86/tsc.h>
+#include <soc/cpu.h>
+
+unsigned long tsc_freq_mhz(void)
+{
+ msr_t msr = rdmsr(MSR_PLATFORM_INFO);
+ return (BASE_CLOCK_MHZ * ((msr.lo >> 8) & 0xff));
+}
Alexandru Gagniuc (mr.nuke.me(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/13304
-gerrit
commit d5a348adab0501b2f135d3c6f45ce13375b760cd
Author: Alexandru Gagniuc <mr.nuke.me(a)gmail.com>
Date: Mon Oct 5 13:45:22 2015 -0700
soc/apollolake: Add minimal accessors for sideband bus (IOSF)
Some configuration registers for the UART are placed behind the
sideband bus.
Change-Id: I84a620dbd0cf4b8f3fec119836d1c8f75c7f200a
Signed-off-by: Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com>
---
src/soc/intel/apollolake/include/soc/iosf.h | 30 +++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/src/soc/intel/apollolake/include/soc/iosf.h b/src/soc/intel/apollolake/include/soc/iosf.h
new file mode 100644
index 0000000..c9f578c
--- /dev/null
+++ b/src/soc/intel/apollolake/include/soc/iosf.h
@@ -0,0 +1,30 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2015 Intel Corp.
+ * (Written by Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com> for Intel Corp.)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef _SOC_APOLLOLAKE_IOSF_H_
+#define _SOC_APOLLOLAKE_IOSF_H_
+
+#include <arch/io.h>
+
+inline static void iosf_write(uint8_t port, uint16_t reg, uint32_t val)
+{
+ uintptr_t base = CONFIG_IOSF_BASE_ADDRESS | (port << 16) | (reg & ~3);
+ write32((void *)base, val);
+}
+
+inline static uint32_t iosf_read(uint8_t port, uint16_t reg)
+{
+ uintptr_t base = CONFIG_IOSF_BASE_ADDRESS | (port << 16) | (reg & ~3);
+ return read32((void *)base);
+}
+
+#endif /* _SOC_APOLLOLAKE_IOSF_H_ */
Alexandru Gagniuc (mr.nuke.me(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/13303
-gerrit
commit 048adf8601cd78ddc3833341ec2c9e76b2c9c2ab
Author: Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com>
Date: Tue Oct 6 16:31:34 2015 -0700
soc/apollolake: Add tsc_freq_mhz() functionality for udelay()
Change-Id: I2f1147cefe2438992bff45fc0a1e91064217915d
Signed-off-by: Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com>
---
src/soc/intel/apollolake/Kconfig | 1 +
src/soc/intel/apollolake/Makefile.inc | 5 +++++
src/soc/intel/apollolake/include/soc/cpu.h | 20 ++++++++++++++++++++
src/soc/intel/apollolake/tsc_freq.c | 21 +++++++++++++++++++++
4 files changed, 47 insertions(+)
diff --git a/src/soc/intel/apollolake/Kconfig b/src/soc/intel/apollolake/Kconfig
index f7ae68e..825a40f 100644
--- a/src/soc/intel/apollolake/Kconfig
+++ b/src/soc/intel/apollolake/Kconfig
@@ -32,6 +32,7 @@ config CPU_SPECIFIC_OPTIONS
select RELOCATABLE_RAMSTAGE # Build fails if this is not selected
select SOC_INTEL_COMMON
select UDELAY_TSC
+ select TSC_CONSTANT_RATE
config MMCONF_BASE_ADDRESS
hex "PCI MMIO Base Address"
diff --git a/src/soc/intel/apollolake/Makefile.inc b/src/soc/intel/apollolake/Makefile.inc
index cc3e013..17b4ae4 100644
--- a/src/soc/intel/apollolake/Makefile.inc
+++ b/src/soc/intel/apollolake/Makefile.inc
@@ -10,6 +10,11 @@ subdirs-y += ../../../cpu/x86/tsc
bootblock-y += bootblock/bootblock_car.c
bootblock-y += bootblock/cache_as_ram.S
bootblock-y += bootblock/early_chipset_config.S
+bootblock-y += tsc_freq.c
+
+romstage-y += tsc_freq.c
+
+ramstage-y += tsc_freq.c
romstage-y += placeholders.c
smm-y += placeholders.c
diff --git a/src/soc/intel/apollolake/include/soc/cpu.h b/src/soc/intel/apollolake/include/soc/cpu.h
new file mode 100644
index 0000000..d0d6afd
--- /dev/null
+++ b/src/soc/intel/apollolake/include/soc/cpu.h
@@ -0,0 +1,20 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2015 Intel Corp.
+ * (Written by Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com> for Intel Corp.)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef _SOC_APOLLOLAKE_CPU_H_
+#define _SOC_APOLLOLAKE_CPU_H_
+
+#define MSR_PLATFORM_INFO 0xce
+
+#define BASE_CLOCK_MHZ 100
+
+#endif /* _SOC_APOLLOLAKE_CPU_H_ */
diff --git a/src/soc/intel/apollolake/tsc_freq.c b/src/soc/intel/apollolake/tsc_freq.c
new file mode 100644
index 0000000..2e90ef2
--- /dev/null
+++ b/src/soc/intel/apollolake/tsc_freq.c
@@ -0,0 +1,21 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2015 Intel Corp.
+ * (Written by Alexandru Gagniuc <alexandrux.gagniuc(a)intel.com> for Intel Corp.)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <cpu/x86/msr.h>
+#include <cpu/x86/tsc.h>
+#include <soc/cpu.h>
+
+unsigned long tsc_freq_mhz(void)
+{
+ msr_t msr = rdmsr(MSR_PLATFORM_INFO);
+ return (BASE_CLOCK_MHZ * ((msr.lo >> 8) & 0xff));
+}