diff --git a/3rdparty/blobs b/3rdparty/blobs
index d7600dd871..62aa0e0c54 160000
--- a/3rdparty/blobs
+++ b/3rdparty/blobs
@@ -1 +1 @@
-Subproject commit d7600dd8718a076f0f9a89e53968b484254624dc
+Subproject commit 62aa0e0c54295bbb7b1a3e5e73f960bafdb59d04
diff --git a/3rdparty/libgfxinit b/3rdparty/libgfxinit
index b3b9fa34bb..a815704c84 160000
--- a/3rdparty/libgfxinit
+++ b/3rdparty/libgfxinit
@@ -1 +1 @@
-Subproject commit b3b9fa34bb99d33d0fc6a69c64966a71cebd5bd6
+Subproject commit a815704c84b4823f5b723404a37efed9d6c85d66
diff --git a/3rdparty/opensbi b/3rdparty/opensbi
index 804b997ed4..ce228ee091 160000
--- a/3rdparty/opensbi
+++ b/3rdparty/opensbi
@@ -1 +1 @@
-Subproject commit 804b997ed415001097803e4b537fd63d043874b9
+Subproject commit ce228ee0919deb9957192d723eecc8aaae2697c6
diff --git a/3rdparty/vboot b/3rdparty/vboot
index dac763c782..9c90611097 160000
--- a/3rdparty/vboot
+++ b/3rdparty/vboot
@@ -1 +1 @@
-Subproject commit dac763c782ce05476dec02e855f349d2b6f3a910
+Subproject commit 9c906110972f538ee5753845916ebd1f826f54b6
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000000..c5fec189ab
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,14 @@
+# This is the list of coreboot authors for copyright purposes.
+#
+# This does not necessarily list everyone who has contributed code, since in
+# some cases, their employer may be the copyright holder. To see the full list
+# of contributors, see the revision history in source control.
+# git log --pretty=format:%an | sort | uniq
+#
+
+Alexander Couzens
+
+
+
+# Directories transferred
+src/acpi
diff --git a/Documentation/Intel/SoC/soc.html b/Documentation/Intel/SoC/soc.html
index fff536b9b1..6b1bb30740 100644
--- a/Documentation/Intel/SoC/soc.html
+++ b/Documentation/Intel/SoC/soc.html
@@ -148,7 +148,6 @@ mv build/coreboot.rom.new build/coreboot.rom
Edit the src/soc/<Vendor>/<Chip Family>/memmap.c file
- Add the fsp/memmap.h include file
- - Add the mmap_region_granularity routine
Add the necessary .h files to define the necessary values and structures
diff --git a/Documentation/arch/riscv/index.md b/Documentation/arch/riscv/index.md
index 9a5de34f09..ea6a5cd47e 100644
--- a/Documentation/arch/riscv/index.md
+++ b/Documentation/arch/riscv/index.md
@@ -23,8 +23,20 @@ On entry to a stage or payload (including SELF payloads),
## Additional payload handoff requirements
The location of cbmem should be placed in a node in the FDT.
+## OpenSBI
+In case the payload doesn't install it's own SBI, like the [RISCV-PK] does,
+[OpenSBI] can be used instead.
+It's loaded into RAM after coreboot has finished loading the payload.
+coreboot then will jump to OpenSBI providing a pointer to the real payload,
+which OpenSBI will jump to once the SBI is installed.
+
+Besides providing SBI it also sets protected memory regions and provides
+a platform independent console.
+
+The OpenSBI code is always run in M mode.
+
## Trap delegation
-Traps are delegated in the ramstage.
+Traps are delegated to the payload.
## SMP within a stage
At the beginning of each stage, all harts save 0 are spinning in a loop on
@@ -44,3 +56,6 @@ The hart blocks until fn is non-null, and then calls it. If fn returns, we
will panic if possible, but behavior is largely undefined.
Only hart 0 runs through most of the code in each stage.
+
+[RISCV-PK]: https://github.com/riscv/riscv-pk
+[OpenSBI]: https://github.com/riscv/opensbi
diff --git a/Documentation/community/code_of_conduct.md b/Documentation/community/code_of_conduct.md
index c40393f919..249a575f0d 100644
--- a/Documentation/community/code_of_conduct.md
+++ b/Documentation/community/code_of_conduct.md
@@ -22,19 +22,30 @@ Refrain from insulting anyone or the group they belong to. Remember that
people might be sensitive to other things than you are.
Most of our community members are not native English speakers, thus
-misunderstandings can (and do) happen. Always assume that others are
-friendly and may have picked less-than-stellar wording by accident.
+misunderstandings can (and do) happen. Assume that others are friendly
+and may have picked less-than-stellar wording by accident as long as
+you possibly can.
-If you have a grievance due to conduct in this community, we want to hear
-about it so we can handle the situation. Please contact our arbitration
-team directly: They will listen to you and react in a timely fashion.
+## Reporting Issues
+
+If you have a grievance due to conduct in this community, we're sorry
+that you have had a bad experience, and we want to hear about it so
+we can resolve the situation.
+
+Please contact members of our arbitration team (listed below) promptly
+and directly, in person (if available) or by email: They will listen
+to you and react in a timely fashion.
+
+If you feel uncomfortable, please don't wait it out, ask for help,
+so we can work on setting things right.
For transparency there is no alias or private mailing list address for
you to reach out to, since we want to make sure that you know who will
-(and who won't) read your message.
+and who won't read your message.
-However since people might be on travel or otherwise be unavailable at
-times, consider reaching out to multiple persons.
+However since people might be on travel or otherwise be unavailable
+at times, please reach out to multiple persons at once, especially
+when using email.
The team will treat your messages confidential as far as the law permits.
For the purpose of knowing what law applies, the list provides the usual
@@ -73,15 +84,10 @@ immediately.
If a community member engages in unacceptable behavior, the community
organizers may take any action they deem appropriate, up to and including
a temporary ban or permanent expulsion from the community without warning
-(and without refund in the case of a paid event). Community organizers
-can be part of the arbitration team, or organizers of events and online
-communities.
-
-## If You Witness or Are Subject to Unacceptable Behavior
-
-If you are subject to or witness unacceptable behavior, or have any other
-concerns, please notify someone from the arbitration team immediately.
+(and without refund in the case of a paid event).
+Community organizers can be members of the arbitration team, or organizers
+of events and online communities.
## Addressing Grievances
@@ -102,7 +108,7 @@ Our arbitration team consists of the following people
* Stefan Reinauer (USA)
* Patrick Georgi (Germany)
* Ronald Minnich (USA)
-* Marc Jones (USA)
+* Martin Roth (USA)
## License and attribution
diff --git a/Documentation/distributions.md b/Documentation/distributions.md
index 1deff6349d..fbfeb7c378 100644
--- a/Documentation/distributions.md
+++ b/Documentation/distributions.md
@@ -58,16 +58,6 @@ fixes not found in the stock firmware, and offer much broader OS compatibility
microcode, as well as firmware updates for the device's embedded controller
(EC). This firmware "takes the training wheels off" your ChromeOS device :)
-### John Lewis
-
-[John Lewis](https://johnlewis.ie/custom-chromebook-firmware) also provides
-replacement firmware for ChromeOS devices, for the express purpose of
-running Linux on Chromebooks. John Lewis' firmware supports a much smaller
-set of devices, and uses SeaBIOS as the payload to support Legacy BIOS booting.
-His firmware images are significantly older, and not actively maintained or
-supported, but worth a look if you need Legacy Boot support and is not
-available via Mr Chromebox's firmware.
-
### Heads
[Heads](http://osresearch.net) is an open source custom firmware and OS
diff --git a/Documentation/drivers/index.md b/Documentation/drivers/index.md
index 642ae1a5f3..60e90c3bf6 100644
--- a/Documentation/drivers/index.md
+++ b/Documentation/drivers/index.md
@@ -1,4 +1,4 @@
-# Platform indenpendend drivers documentation
+# Platform independent drivers documentation
The drivers can be found in `src/drivers`. They are intended for onboard
and plugin devices, significantly reducing integration complexity and
diff --git a/Documentation/lessons/lesson1.md b/Documentation/lessons/lesson1.md
index 2ca25b3b25..bbb3eb5582 100644
--- a/Documentation/lessons/lesson1.md
+++ b/Documentation/lessons/lesson1.md
@@ -1,5 +1,5 @@
-coreboot lesson 1 - Starting from scratch
-=========================================
+coreboot Lesson 1: Starting from scratch
+========================================
From a fresh Ubuntu 16.04 or 18.04 install, here are all the steps required for
a very basic build:
diff --git a/Documentation/lib/payloads/fit.md b/Documentation/lib/payloads/fit.md
index 24807bfc6a..57a1a54566 100644
--- a/Documentation/lib/payloads/fit.md
+++ b/Documentation/lib/payloads/fit.md
@@ -6,6 +6,7 @@
## Supported architectures
* aarch64
+* riscv
## Supported FIT sections
@@ -24,6 +25,7 @@ The section must be named in order to be found by the FIT parser:
## Architecture specifics
The FIT parser needs architecure support.
+
### aarch64
The source code can be found in `src/arch/arm64/fit_payload.c`.
@@ -31,6 +33,13 @@ On aarch64 the kernel (a section named 'kernel') must be in **Image**
format and it needs a devicetree (a section named 'fdt') to boot.
The kernel will be placed close to "*DRAMSTART*".
+### RISC-V
+The source code can be found in `src/arch/riscv/fit_payload.c`.
+
+On RISC-V the kernel (a section named 'kernel') must be in **Image**
+format and it needs a devicetree (a section named 'fdt') to boot.
+The kernel will be placed close to "*DRAMSTART*".
+
### Other
Other architectures aren't supported.
diff --git a/Documentation/mainboard/emulation/qemu-aarch64.md b/Documentation/mainboard/emulation/qemu-aarch64.md
new file mode 100644
index 0000000000..ee4c9e7a3b
--- /dev/null
+++ b/Documentation/mainboard/emulation/qemu-aarch64.md
@@ -0,0 +1,47 @@
+# QEMU AArch64 emulator
+This page discribes how to build and run coreboot for QEMU/AArch64.
+You can use LinuxBoot via `make menuconfig` or an arbitrary FIT image
+as a payload for QEMU/AArch64.
+
+## Running coreboot in QEMU
+```bash
+qemu-system-aarch64 -bios ./build/coreboot.rom \
+ -M virt,secure=on,virtualization=on -cpu cortex-a53 \
+ -nographic -m 8912M
+```
+
+- The default CPU in QEMU for AArch64 is a cortex-a15 which is 32-bit
+ARM CPU. You need to specify 64-bit ARM CPU via `-cpu cortex-a53`.
+- The default privilege level in QEMU for AArch64 is EL1 that we can't
+have the right to access EL3/EL2 registers. You need to enable EL3/EL2
+via `-machine secure=on,virtualization=on`.
+- You need to specify the size of memory more than 544 MiB because 512
+MiB is reserved for the kernel.
+
+## Building coreboot with an arbitrary FIT payload
+There are 3 steps to make coreboot.rom for QEMU/AArch64. If you select
+LinuxBoot, step 2 and 3 have done by LinuxBoot.
+1. Get a DTB (Device Tree Blob)
+2. Build a FIT image with a DTB
+3. Add a FIT image to coreboot.rom
+
+### 1. Get a DTB
+You can get the DTB from QEMU with the following command.
+```
+$ qemu-system-aarch64 \
+ -M virt,dumpdtb=virt.dtb,secure=on,virtualization=on \
+ -cpu cortex-a53 -nographic -m 2048M
+```
+
+### 2. Build a FIT image with a DTB
+You need to write an image source file that has an `.its` extension to
+configure kernels, ramdisks, and DTBs.
+See [Flattened uImage Tree documentation](../../lib/payloads/fit.md) for more details.
+
+### 3. Add a FIT image to coreboot.rom
+You can use cbfstool to add the payload you created in step 2 to
+the coreboot.rom.
+```
+$ ./build/cbfstool ./build/coreboot.rom add -f /uImage \
+ -n fallback/payload -t fit -c lzma
+```
diff --git a/Documentation/mainboard/index.md b/Documentation/mainboard/index.md
index 14c62edeb9..0f3105f85b 100644
--- a/Documentation/mainboard/index.md
+++ b/Documentation/mainboard/index.md
@@ -24,6 +24,7 @@ The boards in this section are not real mainboards, but emulators.
- [Spike RISC-V emulator](emulation/spike-riscv.md)
- [Qemu RISC-V emulator](emulation/qemu-riscv.md)
+- [Qemu AArch64 emulator](emulation/qemu-aarch64.md)
## Intel
@@ -69,6 +70,10 @@ The boards in this section are not real mainboards, but emulators.
- [T4xx common](lenovo/t4xx_series.md)
- [X2xx common](lenovo/x2xx_series.md)
+## Portwell
+
+- [PQ7-M107](portwell/pq7-m107.md)
+
### Sandy Bridge series
- [T420](lenovo/t420.md)
diff --git a/Documentation/mainboard/portwell/pq7-m107.md b/Documentation/mainboard/portwell/pq7-m107.md
new file mode 100644
index 0000000000..e4da415bf4
--- /dev/null
+++ b/Documentation/mainboard/portwell/pq7-m107.md
@@ -0,0 +1,79 @@
+# Portwell PQ7-M107
+
+This page describes how to run coreboot on the [Portwell PQ7-M107].
+
+PQ7-M107 are assembled with different onboard memory modules:
+ Rev 1.0 Onboard Samsung K4B8G1646D-MYKO memory
+ Rev 1.1 and 1.2 Onboard Micron MT41K512M16HA-125A memory
+
+Use 'make menuconfig' to configure `onboard memory manufacture` in Mainboard
+menu.
+
+## Required blobs
+
+This board currently requires:
+fsp blob 3rdparty/fsp/BraswellFspBinPkg/FspBin/BSWFSP.fd
+Microcode Intel Braswell cpuid 1046C4 version 410
+ (Used pre-built binary retrieved from Intel site)
+
+## Flashing coreboot
+
+### Internal programming
+
+The main SPI flash can be accessed using [flashrom].
+
+### External programming
+
+The system has an internal flash chip which is a 8 MiB soldered SOIC-8 chip.
+This chip is located on the top middle side of the board. It's located
+between SoC and Q7 connector. Use clip (or solder wires) to program
+the chip.
+Specifically, it's a Winbond W25Q64FW (1.8V), whose datasheet can be found
+[here][W25Q64FW].
+
+## Known issues
+
+- The PQ7 module contains Q7 connector only. Depending on the carrier
+serial/video/pcie ports might be available.
+
+## Untested
+
+- hardware monitor
+- SDIO
+- Full Embedded Controller support
+
+## Working (using carrier)
+
+- USB
+- Gigabit Ethernet
+- integrated graphics
+- flashrom
+- external graphics
+- PCIe
+- eMMC
+- SATA
+- serial port
+- SMbus
+- HDA (codec on carrier)
+- initialization with FSP MR2
+- SeaBIOS payload (version rel-1.11.0-44-g7961917)
+- Embedded Linux (Ubuntu 4.15+)
+
+## Technology
+
+```eval_rst
++------------------+--------------------------------------------------+
+| SoC | Intel Atom Processor N3710 |
++------------------+--------------------------------------------------+
+| CPU | Intel Braswell (N3710) |
++------------------+--------------------------------------------------+
+| Super I/O, EC | ITE8256 |
++------------------+--------------------------------------------------+
+| Coprocessor | Intel Management Engine |
++------------------+--------------------------------------------------+
+```
+
+[Portwell PQ7-M107]: http://portwell.com/products/detail.php?CUSTCHAR1=PQ7-M107
+[W25Q64FW]: https://www.winbond.com/resource-files/w25q64fw%20revn%2005182017%20sfdp.pdf
+[flashrom]: https://flashrom.org/Flashrom
+[Board manual]: www.portwell.com/pdf/embedded/PQ7-M107.pdf
diff --git a/Documentation/mainboard/sifive/hifive-unleashed.md b/Documentation/mainboard/sifive/hifive-unleashed.md
index 495dade212..4dbbf0e073 100644
--- a/Documentation/mainboard/sifive/hifive-unleashed.md
+++ b/Documentation/mainboard/sifive/hifive-unleashed.md
@@ -17,7 +17,6 @@ The following things are still missing from this coreboot port:
- Provide serial number to payload (e.g. in device tree)
- Implement instruction emulation
- Support for booting Linux on RISC-V
-- Add support to run OpenSBI payload in m-mode
- SMP support in trap handler
## Configuration
diff --git a/Documentation/releases/checklist.md b/Documentation/releases/checklist.md
index f03f87d937..ad00ce8de7 100644
--- a/Documentation/releases/checklist.md
+++ b/Documentation/releases/checklist.md
@@ -68,6 +68,7 @@ be more frequent than was needed, so we scaled it back to twice a year.
- [ ] Announce that the release tag is done on IRC
- [ ] Update release notes with actual commit id, push to repo
- [ ] Upload release files to web server
+- [ ] Upload crossgcc sources to web server
- [ ] Update download page to point to files, push to repo
- [ ] Write and publish blog post with release notes.
- [ ] Update the topic in the irc channel that the release is done.
@@ -195,6 +196,22 @@ The downloads page is the official place to download the releases from, and it n
Here is an example commit to change it: https://review.coreboot.org/#/c/19515/
+## Upload crossgcc sources
+Sometimes the source files for older revisions of
+crossgcc disappear. To deal with that we maintain a mirror at
+https://www.coreboot.org/releases/crossgcc-sources/ where we host the
+sources used by the crossgcc scripts that are part of coreboot releases.
+
+Run
+
+````
+% util/crossgcc/buildgcc -u
+````
+
+This will output the set of URLs that the script uses to download the
+sources. Download them yourself and copy them into the crossgcc-sources
+directory on the server.
+
## After the release is complete
Post the release notes on https://blogs.coreboot.org
diff --git a/Documentation/releases/coreboot-4.10-relnotes.md b/Documentation/releases/coreboot-4.10-relnotes.md
index 9a6d63c16c..0f935c21cc 100644
--- a/Documentation/releases/coreboot-4.10-relnotes.md
+++ b/Documentation/releases/coreboot-4.10-relnotes.md
@@ -1,18 +1,39 @@
-Upcoming release - coreboot 4.10
+coreboot 4.10 release notes
===========================
-The 4.10 release is planned for April/May 2019
+The 4.10 release covers commit a2faaa9a2 to commit ae317695e3
+There is a pgp signed 4.10 tag in the git repository, and a branch will
+be created as needed.
-Update this document with changes that should be in the release
-notes.
-* Please use Markdown.
-* See the [4.7](coreboot-4.7-relnotes.md) and [4.9](coreboot-4.9-relnotes.md)
- release notes for the general format.
-* The chip and board additions and removals will be updated right
-before the release, so those do not need to be added.
+In nearly 8 months since 4.9 we had 198 authors commit 2538 changes
+to master. Of these, 85 authors made their first commit to coreboot:
+Welcome!
-Significant changes
--------------------
+Between the releases the tree grew by about 11000 lines of code plus
+5000 lines of comments.
+
+Again, a big Thank You to all contributors who helped shape the coreboot
+project, community and code with their effort, no matter if through
+development, review, testing, documentation or by helping people asking
+questions on our venues like IRC or our mailing list.
+
+What's New
+----------
+
+Most of the changes were to mainboards, and on the chipset side, lots
+of activity concentrated on x86. However compared to previous releases
+activity (and therefore interest, probably) increased in vboot and in
+non-x86 architectures. However it's harder this time to give this release
+a single topic like the last: This release accumulates some of everything.
+
+Clean Up
+--------
+As usual, there was a lot of cleaning up going on, and there notably,
+a good chunk of this year's Google Summer of Code project to clean out
+the issues reported by Coverity Scan is already in.
+
+The only larger scale change that was registered in the pre-release
+notes was also about cleaning up the tree:
### `device_t` is no more
coreboot used to have a data type, `device_t` that changed shape depending on
@@ -22,3 +43,97 @@ time when romstage wasn't operated in Cache-As-RAM mode, but compiled with
our romcc compiler.
That data type is now gone.
+
+Release Notes maintenance
+-------------------------
+Speaking of pre-release notes: After 4.10 we'll start a document for
+4.11 in the git repository. Feel free to add notable achievements there
+so we remember to give them a shout out in the next release's notes.
+
+Known Issues
+------------
+Sadly, Google Cyan is broken in this release. It doesn't work with the
+"C environment" bootblock (as compared to the old romcc type bootblock)
+which is now the default. Sadly it doesn't help to simply revert that
+change because doing so breaks other boards.
+
+If you want to use Google Cyan with the release (or if
+you're tracking the master branch), please keep an eye on
+https://review.coreboot.org/c/coreboot/+/34304 where a solution for this
+issue is sought.
+
+Deprecations
+------------
+As announced in the 4.9 release notes, there are no deprecations after 4.10.
+While 4.10 is also released late and we target a 4.11 release in October we
+nonetheless want to announce deprecations this time: These are under
+discussion since January, people are working on mitigations for about as long
+and so it should be possible to resolve the outstanding issues by the end of
+October.
+
+Specifically, we want to require code to work with the following Kconfig
+options so we can remove the options and the code they disable:
+
+* C\_ENVIRONMENT\_BOOTBLOCK
+* NO\_CAR\_GLOBAL\_MIGRATION
+* RELOCATABLE\_RAMSTAGE
+
+These only affect x86. If your platform only works without them, please
+look into fixing that.
+
+Added 28 mainboards:
+--------------------
+* ASROCK H110M-DVS
+* ASUS H61M-CS
+* ASUS P5G41T-M-LX
+* ASUS P5QPL-AM
+* ASUS P8Z77-M-PRO
+* FACEBOOK FBG1701
+* FOXCONN G41M
+* GIGABYTE GA-H61MA-D3V
+* GOOGLE BLOOG
+* GOOGLE FLAPJACK
+* GOOGLE GARG
+* GOOGLE HATCH-WHL
+* GOOGLE HELIOS
+* GOOGLE KINDRED
+* GOOGLE KODAMA
+* GOOGLE KOHAKU
+* GOOGLE KRANE
+* GOOGLE MISTRAL
+* HP COMPAQ-8200-ELITE-SFF-PC
+* INTEL COMETLAKE-RVP
+* INTEL KBLRVP11
+* LENOVO R500
+* LENOVO X1
+* MSI MS7707
+* PORTWELL M107
+* PURISM LIBREM13-V4
+* PURISM LIBREM15-V4
+* SUPERMICRO X10SLM-PLUS-F
+* UP SQUARED
+
+Removed 7 mainboards:
+---------------------
+* GOOGLE BIP
+* GOOGLE DELAN
+* GOOGLE ROWAN
+* PCENGINES ALIX1C
+* PCENGINES ALIX2C
+* PCENGINES ALIX2D
+* PCENGINES ALIX6
+
+Removed 3 processors:
+---------------------
+* src/cpu/amd/geode\_lx
+* src/cpu/intel/model\_69x
+* src/cpu/intel/model\_6dx
+
+Added 2 socs:
+-------------
+* src/soc/amd/picasso
+* src/soc/qualcomm/qcs405
+
+Toolchain
+---------
+* Update to gcc 8.3.0, binutils 2.32, IASL 20190509, clang 8
diff --git a/Documentation/releases/coreboot-4.11-relnotes.md b/Documentation/releases/coreboot-4.11-relnotes.md
new file mode 100644
index 0000000000..995a8e7eea
--- /dev/null
+++ b/Documentation/releases/coreboot-4.11-relnotes.md
@@ -0,0 +1,17 @@
+Upcoming release - coreboot 4.11
+================================
+
+The 4.11 release is planned for October 2019
+
+Update this document with changes that should be in the release
+notes.
+* Please use Markdown.
+* See the [4.9](coreboot-4.9-relnotes.md) and [4.10](coreboot-4.10-relnotes.md)
+ release notes for the general format.
+* The chip and board additions and removals will be updated right
+ before the release, so those do not need to be added.
+
+Significant changes
+-------------------
+
+### Add significant changes here
diff --git a/Documentation/security/index.md b/Documentation/security/index.md
index 379375b616..d5d4e2b93e 100644
--- a/Documentation/security/index.md
+++ b/Documentation/security/index.md
@@ -7,3 +7,9 @@ This section describes documentation about the security architecture of coreboot
- [Verified Boot](vboot/index.md)
- [Measured Boot](vboot/measured_boot.md)
- [Memory clearing](memory_clearing.md)
+
+## Intel TXT
+
+- [Intel TXT in general](intel/txt.md)
+- [Intel TXT Initial Boot Block](intel/txt_ibb.md)
+- [Intel Authenticated Code Modules](intel/acm.md)
diff --git a/Documentation/security/intel/acm.md b/Documentation/security/intel/acm.md
new file mode 100644
index 0000000000..b7dfacde8c
--- /dev/null
+++ b/Documentation/security/intel/acm.md
@@ -0,0 +1,57 @@
+# Intel Authenticated Code Modules
+
+The Authenticated Code Modules (ACMs) are Intel digitally signed modules
+that contain code to be run before the traditional x86 CPU reset vector.
+The ACMs can be invoked at runtime through the GETSEC instruction, too.
+
+A platform that wants to use Intel TXT must use two ACMs:
+1. BIOS ACM
+ * The BIOS ACM must be present in the boot flash.
+ * The BIOS ACM must be referenced by the [FIT].
+2. SINIT ACM
+ * The SINIT ACM isn't referenced by the [FIT].
+ * The SINIT ACM should be provided by the boot firmware, but bootloaders
+ like [TBOOT] are able to load them from the filesystem as well.
+
+## Retrieving ACMs
+
+The ACMs can be downloaded on Intel's website:
+[Intel Trusted Execution Technology](https://software.intel.com/en-us/articles/intel-trusted-execution-technology)
+
+If you want to extract the BLOB from vendor firmware you can search for the
+string ``LCP_POLICY_DATA`` or ``TXT``.
+
+## Header
+
+Every ACM has a fixed size header:
+
+```c
+/*
+ * ACM Header v0.0 without dynamic part
+ * Chapter A.1
+ * Intel TXT Software Development Guide (Document: 315168-015)
+ */
+struct acm_header_v0 {
+ uint16_t module_type;
+ uint16_t module_sub_type;
+ uint32_t header_len;
+ uint16_t header_version[2];
+ uint16_t chipset_id;
+ uint16_t flags;
+ uint32_t module_vendor;
+ uint32_t date;
+ uint32_t size;
+ uint16_t txt_svn;
+ uint16_t se_svn;
+ uint32_t code_control;
+ uint32_t error_entry_point;
+ uint32_t gdt_limit;
+ uint32_t gdt_ptr;
+ uint32_t seg_sel;
+ uint32_t entry_point;
+ uint8_t reserved2[63];
+} __packed;
+```
+
+[FIT]: ../../soc/intel/fit.md
+[TBOOT]: https://sourceforge.net/p/tboot/wiki/Home/
diff --git a/Documentation/security/intel/fit_ibb.dia b/Documentation/security/intel/fit_ibb.dia
new file mode 100644
index 0000000000..9d389e1e9b
Binary files /dev/null and b/Documentation/security/intel/fit_ibb.dia differ
diff --git a/Documentation/security/intel/fit_ibb.svg b/Documentation/security/intel/fit_ibb.svg
new file mode 100644
index 0000000000..cadf2cde6c
--- /dev/null
+++ b/Documentation/security/intel/fit_ibb.svg
@@ -0,0 +1,153 @@
+
+
+
diff --git a/Documentation/security/intel/txt.md b/Documentation/security/intel/txt.md
new file mode 100644
index 0000000000..f67b63942e
--- /dev/null
+++ b/Documentation/security/intel/txt.md
@@ -0,0 +1,117 @@
+# Intel Trusted Execution Technology
+
+Intel TXT allows
+1. Attestation of the authenticity of a platform and its operating system.
+2. Assuring that an authentic operating system starts in a
+ trusted environment, which can then be considered trusted.
+3. Providing of a trusted operating system with additional
+ security capabilities not available to an unproven one.
+
+Intel TXT requirements:
+
+1. Intel TXT requires a **TPM** to measure parts of the firmware before it's
+ run on the BSP.
+2. Intel TXT requires signed **Authenticated Code Modules** ([ACM]s), provided
+ by Intel.
+3. Intel TXT requires **CPU and Chipset** support (supported since
+ Intel Core 2 Duo/ICH9).
+
+## Authenticated Code Modules
+
+The ACMs are Intel digitally signed modules that contain code to be run
+before the traditional x86 CPU reset vector.
+
+More details can be found here: [Intel ACM].
+
+## Modified bootflow with Intel TXT
+
+With Intel TXT the first instruction executed on the BSP isn't the
+*reset vector*, but the [Intel ACM].
+It initializes the TPM and measures parts of the firmware, the IBB.
+
+### Marking the Initial Boot Block
+
+Individual files in the CBFS can be marked as IBB.
+
+More details can be found in the [Intel TXT IBB] chapter.
+
+### Measurements
+The IBBs (Initial Boot Blocks) are measured into TPM's PCR0 by the BIOS [ACM]
+before the CPU reset vector is executed. To indentify the regions that need
+to be measured, the [FIT] contains one ore multiple *Type 7* entries, that
+point to the IBBs.
+
+### Authentication
+
+After the IBBs have been measured, the ACM decides if the boot firmware is
+trusted. There exists two validation modes:
+1. HASH Autopromotion
+ * Uses a known good HASH stored in TPM NVRAM
+ * Doesn't allow to boot a fallback IBB
+2. Signed BIOS policy
+ * Uses a signed policy stored in flash containing multiple HASHes
+ * The public key HASH of BIOS policy is burned into TPM by manufacturer
+ * Can be updated by firmware
+ * Allows to boot a fallback IBB
+
+At the moment only *Autopromotion mode* is implemented and tested well.
+
+In the next step the ACM terminates and the regular x86 CPU reset vector
+is being executed on the BSP.
+
+### Protecting Secrets in Memory
+
+Intel TXT sets the `Secrets in Memory` bit, whenever the launch of the SINIT
+ACM was successful.
+The bit is reset when leaving the *MLE* by a regular shutdown or by removing
+the CMOS battery.
+
+When `Secrets in Memory` bit is set and the IBB isn't trusted, the memory
+controller won't be unlocked, resulting in a platform that cannot access DRAM.
+
+When `Secrets in Memory` bit is set and the IBB is trusted, the memory
+controller will be unlocked, and it's the responsibility of the firmware to
+[clear all DRAM] and wipe any secrets of the MLE.
+The platform will be reset after all DRAM has been wiped and will boot
+with the `Secrets in Memory` bit cleared.
+
+### Configuring protected regions for SINIT ACM
+
+The memory regions used by the SINIT ACM need to be prepared and protected
+against DMA attacks.
+The SINIT ACM as well as the SINIT handoff data are placed in memory.
+
+### Locking TXT register
+
+As last step the TXT registers are locked.
+
+Whenever the SINIT ACM is invoked, it verifies that the hardware is in the
+correct state. If it's not the SINIT ACM will reset the platform.
+
+## For developers
+### Configuring Intel TXT in Kconfig
+Enable ``TEE_INTEL_TXT`` and set the following:
+
+``TEE_INTEL_TXT_BIOSACM_FILE`` to the path of the BIOS ACM provided by Intel
+
+``TEE_INTEL_TXT_SINITACM_FILE`` to the path of the SINIT ACM provided by Intel
+### Print TXT status as early as possible
+Add platform code to print the TXT status as early as possible, as the register
+is cleared on cold reset.
+
+## References
+More information can be found here:
+* [Intel TXT Software Development Guide]
+* [Intel TXT enabling]
+* [FIT]
+* [Intel TXT Lab Handout]
+
+[Intel TXT IBB]: txt_ibb.md
+[FIT]: ../../soc/intel/fit.md
+[Intel ACM]: acm.md
+[ACM]: acm.md
+[FIT table]: ../../soc/intel/fit.md
+[clear all DRAM]: ../memory_clearing.md
+[Intel TXT Lab Handout]: https://downloadmirror.intel.com/18931/eng/Intel%20TXT%20LAB%20Handout.pdf
+[Intel TXT Software Development Guide]: https://www.intel.com/content/dam/www/public/us/en/documents/guides/intel-txt-software-development-guide.pdf
+[Intel TXT enabling]: https://www.intel.com/content/dam/www/public/us/en/documents/guides/txt-enabling-guide.pdf
diff --git a/Documentation/security/intel/txt_ibb.md b/Documentation/security/intel/txt_ibb.md
new file mode 100644
index 0000000000..56cee8dca5
--- /dev/null
+++ b/Documentation/security/intel/txt_ibb.md
@@ -0,0 +1,39 @@
+# Intel TXT Initial Boot Block
+
+The Initial Boot Block (IBB) consists out of one or more files in the CBFS.
+
+## Constraints
+
+The IBB must follow the following constrains:
+* One IBB must contain the reset vector as well as the [FIT table].
+* The IBB should be as small as possible.
+* The IBBs must not overlap each other.
+* The IBB might overlap with microcode.
+* The IBB must not overlap the BIOS ACM.
+* The IBB size must be a multiple of 16.
+* Either one of the following:
+ * The IBB must be able to train the main system memory and clear all secrets.
+ * If the IBB cannot train the main system memory it must verify the code
+ that can train the main system memory and is able to clear all secrets.
+
+## Identification
+
+To add the IBBs to the [FIT], all CBFS files are added using the `cbfstool`
+with the `--ibb` flag set.
+The flags sets the CBFS file attribute tag to LE `' IBB'`.
+
+The make system in turn adds all those files to the [FIT] as type 7.
+
+## Intel TXT measurements
+
+Each IBB is measured and extended into PCR0 by [Intel TXT], before the CPU
+reset vector is executed.
+The IBBs are measured in the order they are listed in the [FIT].
+
+## FIT schematic
+
+![][fit_ibb]
+
+[fit_ibb]: fit_ibb.svg
+[FIT]: ../../soc/intel/fit.md
+[Intel TXT]: txt.md
diff --git a/MAINTAINERS b/MAINTAINERS
index 73ca6dfed9..030ed7a593 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -135,7 +135,6 @@ Maintainers List (try to look for most precise areas first)
RISC-V ARCHITECTURE
M: Ronald Minnich
-M: Jonathan Neuschäfer
R: Philipp Hug
S: Maintained
F: src/arch/riscv/
@@ -398,6 +397,12 @@ M: Wim Vervoorn
S: Maintained
F: src/mainboard/facebook/fbg1701/
+PORTWELL PQ-M107 MAINBOARD
+M: Frans Hendriks
+M: Wim Vervoorn
+S: Maintained
+F: src/mainboard/portwell/m107/
+
AMD FAMILY10H & FAMILY15H (NON-AGESA) CPUS & NORTHBRIDGE
M: Timothy Pearson
S: Supported
@@ -674,6 +679,14 @@ MISSING: SPI
# Owners: Patrick, Philipp
# Backups:
+CODE OF CONDUCT
+M: Stefan Reinauer
+M: Patrick Georgi
+M: Ronald Minnich
+M: Martin Roth
+S: Maintained
+F: Documentation/community/code_of_conduct.md
+
# Wiki
# Owners: Stefan, Patrick
# Backups:
diff --git a/Makefile b/Makefile
index 45b0bc5f8c..317a8eb1cf 100644
--- a/Makefile
+++ b/Makefile
@@ -124,16 +124,17 @@ ifneq ($(MAKECMDGOALS),)
ifneq ($(filter %config %clean cross% clang iasl gnumake lint% help% what-jenkins-does,$(MAKECMDGOALS)),)
NOCOMPILE:=1
endif
-ifeq ($(MAKECMDGOALS), %clean)
+ifneq ($(filter %clean lint% help% what-jenkins-does,$(MAKECMDGOALS)),)
NOMKDIR:=1
endif
endif
+-include $(TOPLEVEL)/site-local/Makefile.inc
+
ifeq ($(NOCOMPILE),1)
include $(TOPLEVEL)/Makefile.inc
include $(TOPLEVEL)/payloads/Makefile.inc
include $(TOPLEVEL)/util/testing/Makefile.inc
--include $(TOPLEVEL)/site-local/Makefile.inc
real-all:
@echo "Error: Expected config file ($(DOTCONFIG)) not present." >&2
@echo "Please specify a config file or run 'make menuconfig' to" >&2
diff --git a/Makefile.inc b/Makefile.inc
index 28f1363131..c275d1efa5 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -401,7 +401,7 @@ endif
CFLAGS_common += -pipe -g -nostdinc -std=gnu11
CFLAGS_common += -nostdlib -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS_common += -Wwrite-strings -Wredundant-decls -Wno-trigraphs
+CFLAGS_common += -Wwrite-strings -Wredundant-decls -Wno-trigraphs -Wimplicit-fallthrough
CFLAGS_common += -Wstrict-aliasing -Wshadow -Wdate-time -Wtype-limits
CFLAGS_common += -fno-common -ffreestanding -fno-builtin -fomit-frame-pointer
CFLAGS_common += -ffunction-sections -fdata-sections -fno-pie
@@ -705,6 +705,11 @@ $(objcbfs)/bootblock.raw.bin: $(objcbfs)/bootblock.raw.elf
@printf " OBJCOPY $(notdir $(@))\n"
$(OBJCOPY_bootblock) -O binary $< $@
+ifneq ($(CONFIG_HAVE_BOOTBLOCK),y)
+$(objcbfs)/bootblock.bin:
+ dd if=/dev/zero of=$@ bs=64 count=1
+endif
+
$(objcbfs)/%.bin: $(objcbfs)/%.raw.bin
cp $< $@
diff --git a/configs/config.emulation_qemu_riscv_rv64 b/configs/config.emulation_qemu_riscv_rv64
new file mode 100644
index 0000000000..d41963c157
--- /dev/null
+++ b/configs/config.emulation_qemu_riscv_rv64
@@ -0,0 +1,2 @@
+CONFIG_BOARD_EMULATION_QEMU_RISCV_RV64=y
+CONFIG_RISCV_OPENSBI=y
diff --git a/configs/config.up_squared.vboot b/configs/config.up_squared.vboot
new file mode 100644
index 0000000000..130c02f6ec
--- /dev/null
+++ b/configs/config.up_squared.vboot
@@ -0,0 +1,2 @@
+CONFIG_VENDOR_UP=y
+CONFIG_VBOOT=y
diff --git a/payloads/Kconfig b/payloads/Kconfig
index d0f8a44080..46cfaf5ad0 100644
--- a/payloads/Kconfig
+++ b/payloads/Kconfig
@@ -30,7 +30,7 @@ config PAYLOAD_ELF
config PAYLOAD_FIT
bool "A FIT payload"
- depends on ARCH_ARM64
+ depends on ARCH_ARM64 || ARCH_RISCV
select PAYLOAD_FIT_SUPPORT
help
Select this option if you have a payload image (a FIT file) which
@@ -99,8 +99,8 @@ config PAYLOAD_IS_FLAT_BINARY
config PAYLOAD_FIT_SUPPORT
bool "FIT support"
default n
- default y if PAYLOAD_LINUX && (ARCH_ARM || ARCH_ARM64)
- depends on ARCH_ARM64
+ default y if PAYLOAD_LINUX && (ARCH_ARM || ARCH_ARM64 || ARCH_RISCV)
+ depends on ARCH_ARM64 || ARCH_RISCV
select FLATTENED_DEVICE_TREE
help
Select this option if your payload is of type FIT.
diff --git a/payloads/external/GRUB2/Makefile b/payloads/external/GRUB2/Makefile
index 43da597eb7..b433bc09b3 100644
--- a/payloads/external/GRUB2/Makefile
+++ b/payloads/external/GRUB2/Makefile
@@ -28,7 +28,7 @@ grub2/build/config.h: $(CONFIG_DEP) | checkout
echo " CONFIG GRUB2 $(NAME-y)"
rm -rf grub2/build
mkdir grub2/build
- cd grub2 && ./bootstrap.sh ; ./autogen.sh
+ cd grub2 && ./bootstrap ; ./autogen.sh
cd grub2/build && ../configure CC="$(HOSTCC)" LD="$(LD)" \
FREETYPE="pkg-config freetype2" BUILD_FREETYPE="pkg-config freetype2" \
TARGET_CC="$(CC)" TARGET_OBJCOPY="$(OBJCOPY)" TARGET_STRIP="$(STRIP)" \
diff --git a/payloads/external/LinuxBoot/Kconfig b/payloads/external/LinuxBoot/Kconfig
index 84af49ccc0..a91288bca7 100644
--- a/payloads/external/LinuxBoot/Kconfig
+++ b/payloads/external/LinuxBoot/Kconfig
@@ -39,6 +39,13 @@ config LINUXBOOT_ARM64
help
AARCH64 kernel and initramfs
+config LINUXBOOT_RISCV
+ bool "RISC-V"
+ depends on ARCH_RISCV
+ select PAYLOAD_FIT_SUPPORT
+ help
+ RISC-V kernel and initramfs
+
endchoice
comment "Linux kernel"
@@ -126,7 +133,7 @@ config LINUXBOOT_KERNEL_CONFIGFILE
choice
prompt "Kernel binary format"
default LINUXBOOT_KERNEL_BZIMAGE if LINUXBOOT_X86 || LINUXBOOT_X86_64
- default LINUXBOOT_KERNEL_UIMAGE if LINUXBOOT_ARM64
+ default LINUXBOOT_KERNEL_UIMAGE if LINUXBOOT_ARM64 || LINUXBOOT_RISCV
config LINUXBOOT_KERNEL_BZIMAGE
bool "bzImage"
@@ -134,14 +141,14 @@ config LINUXBOOT_KERNEL_BZIMAGE
config LINUXBOOT_KERNEL_UIMAGE
bool "uImage"
- depends on LINUXBOOT_ARM64
+ depends on LINUXBOOT_ARM64 || LINUXBOOT_RISCV
endchoice
config LINUXBOOT_DTB_FILE
string "Compiled devicetree file"
- depends on LINUXBOOT_ARM64
+ depends on LINUXBOOT_ARM64 || LINUXBOOT_RISCV
default ""
endif #LINUXBOOT_COMPILE_KERNEL
@@ -154,7 +161,7 @@ config LINUX_COMMAND_LINE
config PAYLOAD_FILE
default "payloads/external/LinuxBoot/linuxboot/bzImage" if LINUXBOOT_COMPILE_KERNEL && ( LINUXBOOT_X86 || LINUXBOOT_X86_64 )
- default "payloads/external/LinuxBoot/linuxboot/uImage" if LINUXBOOT_COMPILE_KERNEL && LINUXBOOT_ARM64
+ default "payloads/external/LinuxBoot/linuxboot/uImage" if LINUXBOOT_COMPILE_KERNEL && (LINUXBOOT_ARM64 || LINUXBOOT_RISCV)
default LINUXBOOT_KERNEL_PATH if !LINUXBOOT_COMPILE_KERNEL
comment "Linux initramfs"
diff --git a/payloads/external/LinuxBoot/Kconfig.name b/payloads/external/LinuxBoot/Kconfig.name
index 18438c7861..c59a8bcee9 100644
--- a/payloads/external/LinuxBoot/Kconfig.name
+++ b/payloads/external/LinuxBoot/Kconfig.name
@@ -14,7 +14,7 @@
config PAYLOAD_LINUXBOOT
bool "LinuxBoot"
- depends on ARCH_X86 || ARCH_ARM64
+ depends on ARCH_X86 || ARCH_ARM64 || ARCH_RISCV
help
Select this option if you want to build a coreboot image
with a LinuxBoot payload. If you don't know what this is
diff --git a/payloads/external/Makefile.inc b/payloads/external/Makefile.inc
index 9c34efabeb..df168f2bee 100644
--- a/payloads/external/Makefile.inc
+++ b/payloads/external/Makefile.inc
@@ -300,10 +300,7 @@ payloads/external/LinuxBoot/linuxboot/initramfs_u-root.cpio: linuxboot
payloads/external/Yabits/uefi/build/uefi.elf yabits:
$(MAKE) -C payloads/external/Yabits all \
- CC="$(CC_x86_32)" \
- LD="$(LD_x86_32)" \
- OBJCOPY="$(OBJCOPY_x86_32)" \
- AS="$(AS_x86_32)" \
+ XGCCPATH="$(XGCCPATH)" \
CONFIG_YABITS_REVISION=$(CONFIG_YABITS_REVISION) \
CONFIG_YABITS_REVISION_ID=$(CONFIG_YABITS_REVISION_ID) \
CONFIG_YABITS_MASTER=$(CONFIG_YABITS_MASTER) \
diff --git a/payloads/external/linux/Kconfig.name b/payloads/external/linux/Kconfig.name
index 63621d88c7..493eb982ef 100644
--- a/payloads/external/linux/Kconfig.name
+++ b/payloads/external/linux/Kconfig.name
@@ -1,6 +1,6 @@
config PAYLOAD_LINUX
bool "A Linux payload"
- depends on ARCH_X86 || ARCH_ARM
+ depends on ARCH_X86 || ARCH_ARM || ARCH_RISCV
help
Select this option if you have a Linux bzImage which coreboot
should run as soon as the basic hardware initialization
diff --git a/payloads/libpayload/Makefile.inc b/payloads/libpayload/Makefile.inc
index 1fa07f9a7a..f0aaa2727f 100644
--- a/payloads/libpayload/Makefile.inc
+++ b/payloads/libpayload/Makefile.inc
@@ -63,7 +63,7 @@ CFLAGS += $(EXTRA_CFLAGS) $(INCLUDES) -Os -pipe -nostdinc -ggdb3
CFLAGS += -nostdlib -fno-builtin -ffreestanding -fomit-frame-pointer
CFLAGS += -ffunction-sections -fdata-sections
CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Wwrite-strings -Wredundant-decls -Wno-trigraphs
+CFLAGS += -Wwrite-strings -Wredundant-decls -Wno-trigraphs -Wimplicit-fallthrough
CFLAGS += -Wstrict-aliasing -Wshadow -Werror
$(obj)/libpayload-config.h: $(KCONFIG_AUTOHEADER)
diff --git a/payloads/libpayload/curses/PDCurses/pdcurses/scanw.c b/payloads/libpayload/curses/PDCurses/pdcurses/scanw.c
index 47f205052b..d1fd908dab 100644
--- a/payloads/libpayload/curses/PDCurses/pdcurses/scanw.c
+++ b/payloads/libpayload/curses/PDCurses/pdcurses/scanw.c
@@ -274,7 +274,7 @@ static int _pdc_vsscanf(const char *buf, const char *fmt, va_list arg_ptr)
NEXT(c);
goto string;
}
- /* no break */
+ /* fall through */
default:
if (fmt[1] == '-' && fmt[2]
&& f < (unsigned char)fmt[2])
diff --git a/payloads/libpayload/drivers/serial/qcs405.c b/payloads/libpayload/drivers/serial/qcs405.c
index 7a80aae9c3..06ec5b9e1d 100644
--- a/payloads/libpayload/drivers/serial/qcs405.c
+++ b/payloads/libpayload/drivers/serial/qcs405.c
@@ -285,6 +285,7 @@ struct uart_params_t {
static struct console_input_driver consin = {
.havekey = serial_havechar,
.getchar = serial_getchar,
+ .input_type = CONSOLE_INPUT_TYPE_UART,
};
static struct console_output_driver consout = {
diff --git a/payloads/libpayload/drivers/video/graphics.c b/payloads/libpayload/drivers/video/graphics.c
index 85a8642c72..6b5664bbcf 100644
--- a/payloads/libpayload/drivers/video/graphics.c
+++ b/payloads/libpayload/drivers/video/graphics.c
@@ -129,8 +129,30 @@ static inline void set_pixel(struct vector *coord, uint32_t color)
{
const int bpp = fbinfo->bits_per_pixel;
const int bpl = fbinfo->bytes_per_line;
+ struct vector rcoord;
int i;
- uint8_t * const pixel = fbaddr + coord->y * bpl + coord->x * bpp / 8;
+
+ switch (fbinfo->orientation) {
+ case CB_FB_ORIENTATION_NORMAL:
+ default:
+ rcoord.x = coord->x;
+ rcoord.y = coord->y;
+ break;
+ case CB_FB_ORIENTATION_BOTTOM_UP:
+ rcoord.x = screen.size.width - 1 - coord->x;
+ rcoord.y = screen.size.height - 1 - coord->y;
+ break;
+ case CB_FB_ORIENTATION_LEFT_UP:
+ rcoord.x = coord->y;
+ rcoord.y = screen.size.width - 1 - coord->x;
+ break;
+ case CB_FB_ORIENTATION_RIGHT_UP:
+ rcoord.x = screen.size.height - 1 - coord->y;
+ rcoord.y = coord->x;
+ break;
+ }
+
+ uint8_t * const pixel = fbaddr + rcoord.y * bpl + rcoord.x * bpp / 8;
for (i = 0; i < bpp / 8; i++)
pixel[i] = (color >> (i * 8));
}
@@ -152,8 +174,17 @@ static int cbgfx_init(void)
if (!fbaddr)
return CBGFX_ERROR_FRAMEBUFFER_ADDR;
- screen.size.width = fbinfo->x_resolution;
- screen.size.height = fbinfo->y_resolution;
+ switch (fbinfo->orientation) {
+ default: /* Normal or rotated 180 degrees. */
+ screen.size.width = fbinfo->x_resolution;
+ screen.size.height = fbinfo->y_resolution;
+ break;
+ case CB_FB_ORIENTATION_LEFT_UP: /* 90 degree rotation. */
+ case CB_FB_ORIENTATION_RIGHT_UP:
+ screen.size.width = fbinfo->y_resolution;
+ screen.size.height = fbinfo->x_resolution;
+ break;
+ }
screen.offset.x = 0;
screen.offset.y = 0;
@@ -242,7 +273,7 @@ int clear_screen(const struct rgb_color *rgb)
* We assume that for 32bpp the high byte gets ignored anyway. */
if ((((color >> 8) & 0xff) == (color & 0xff)) && (bpp == 16 ||
(((color >> 16) & 0xff) == (color & 0xff)))) {
- memset(fbaddr, color & 0xff, screen.size.height * bpl);
+ memset(fbaddr, color & 0xff, fbinfo->y_resolution * bpl);
} else {
for (p.y = 0; p.y < screen.size.height; p.y++)
for (p.x = 0; p.x < screen.size.width; p.x++)
diff --git a/payloads/libpayload/include/coreboot_tables.h b/payloads/libpayload/include/coreboot_tables.h
index b0d7c90389..bf2cf022d1 100644
--- a/payloads/libpayload/include/coreboot_tables.h
+++ b/payloads/libpayload/include/coreboot_tables.h
@@ -57,7 +57,7 @@ enum {
CB_TAG_CBMEM_CONSOLE = 0x0017,
CB_TAG_MRC_CACHE = 0x0018,
CB_TAG_VBNV = 0x0019,
- CB_TAG_VBOOT_HANDOFF = 0x0020,
+ CB_TAG_VBOOT_HANDOFF = 0x0020, /* deprecated */
CB_TAG_X86_ROM_MTRR = 0x0021,
CB_TAG_DMA = 0x0022,
CB_TAG_RAM_OOPS = 0x0023,
@@ -189,6 +189,14 @@ struct cb_forward {
u64 forward;
};
+/* Panel orientation, matches drm_connector.h in the Linux kernel. */
+enum cb_fb_orientation {
+ CB_FB_ORIENTATION_NORMAL = 0,
+ CB_FB_ORIENTATION_BOTTOM_UP = 1,
+ CB_FB_ORIENTATION_LEFT_UP = 2,
+ CB_FB_ORIENTATION_RIGHT_UP = 3,
+};
+
struct cb_framebuffer {
u32 tag;
u32 size;
@@ -206,6 +214,7 @@ struct cb_framebuffer {
u8 blue_mask_size;
u8 reserved_mask_pos;
u8 reserved_mask_size;
+ u8 orientation;
};
#define CB_GPIO_ACTIVE_LOW 0
diff --git a/payloads/libpayload/include/string.h b/payloads/libpayload/include/string.h
index 4aff0e8994..52379a034d 100644
--- a/payloads/libpayload/include/string.h
+++ b/payloads/libpayload/include/string.h
@@ -73,7 +73,7 @@ char *strerror(int errnum);
* @defgroup string Unicode functions
* @{
*/
-char *utf16le_to_ascii(uint16_t *utf16_string, int maxlen);
+char *utf16le_to_ascii(const uint16_t *utf16_string, size_t maxlen);
/** @} */
/**
diff --git a/payloads/libpayload/include/sysinfo.h b/payloads/libpayload/include/sysinfo.h
index 72059adb91..50f0e3962c 100644
--- a/payloads/libpayload/include/sysinfo.h
+++ b/payloads/libpayload/include/sysinfo.h
@@ -95,8 +95,6 @@ struct sysinfo_t {
struct cb_header *header;
struct cb_mainboard *mainboard;
- void *vboot_handoff;
- u32 vboot_handoff_size;
void *vboot_workbuf;
uint32_t vboot_workbuf_size;
diff --git a/payloads/libpayload/libc/coreboot.c b/payloads/libpayload/libc/coreboot.c
index 26a3a48c23..03778b6d2a 100644
--- a/payloads/libpayload/libc/coreboot.c
+++ b/payloads/libpayload/libc/coreboot.c
@@ -78,14 +78,6 @@ static void cb_parse_serial(void *ptr, struct sysinfo_t *info)
info->serial = ((struct cb_serial *)ptr);
}
-static void cb_parse_vboot_handoff(unsigned char *ptr, struct sysinfo_t *info)
-{
- struct lb_range *vbho = (struct lb_range *)ptr;
-
- info->vboot_handoff = (void *)(uintptr_t)vbho->range_start;
- info->vboot_handoff_size = vbho->range_size;
-}
-
static void cb_parse_vboot_workbuf(unsigned char *ptr, struct sysinfo_t *info)
{
struct lb_range *vbwb = (struct lb_range *)ptr;
@@ -367,9 +359,6 @@ int cb_parse_header(void *addr, int len, struct sysinfo_t *info)
case CB_TAG_VBNV:
cb_parse_vbnv(ptr, info);
break;
- case CB_TAG_VBOOT_HANDOFF:
- cb_parse_vboot_handoff(ptr, info);
- break;
case CB_TAG_VBOOT_WORKBUF:
cb_parse_vboot_workbuf(ptr, info);
break;
diff --git a/payloads/libpayload/libc/printf.c b/payloads/libpayload/libc/printf.c
index cb623aa51a..3896f01b86 100644
--- a/payloads/libpayload/libc/printf.c
+++ b/payloads/libpayload/libc/printf.c
@@ -585,6 +585,7 @@ static int printf_core(const char *fmt, struct printf_spec *ps, va_list ap)
/* Integer values */
case 'P': /* pointer */
flags |= __PRINTF_FLAG_BIGCHARS;
+ /* fall through */
case 'p':
flags |= __PRINTF_FLAG_PREFIX;
base = 16;
@@ -599,10 +600,12 @@ static int printf_core(const char *fmt, struct printf_spec *ps, va_list ap)
case 'd':
case 'i':
flags |= __PRINTF_FLAG_SIGNED;
+ break;
case 'u':
break;
case 'X':
flags |= __PRINTF_FLAG_BIGCHARS;
+ /* fall through */
case 'x':
base = 16;
break;
diff --git a/payloads/libpayload/libc/string.c b/payloads/libpayload/libc/string.c
index 6c257cbdaa..0e34a036b0 100644
--- a/payloads/libpayload/libc/string.c
+++ b/payloads/libpayload/libc/string.c
@@ -91,9 +91,9 @@ size_t strlen(const char *str)
*/
int strcasecmp(const char *s1, const char *s2)
{
- int i, res;
+ int res;
- for (i = 0; 1; i++) {
+ for (size_t i = 0; 1; i++) {
res = tolower(s1[i]) - tolower(s2[i]);
if (res || (s1[i] == '\0'))
break;
@@ -112,10 +112,9 @@ int strcasecmp(const char *s1, const char *s2)
*/
int strncasecmp(const char *s1, const char *s2, size_t maxlen)
{
- int i, res;
+ int res = 0;
- res = 0;
- for (i = 0; i < maxlen; i++) {
+ for (size_t i = 0; i < maxlen; i++) {
res = tolower(s1[i]) - tolower(s2[i]);
if (res || (s1[i] == '\0'))
break;
@@ -135,9 +134,9 @@ int strncasecmp(const char *s1, const char *s2, size_t maxlen)
*/
int strcmp(const char *s1, const char *s2)
{
- int i, res;
+ int res;
- for (i = 0; 1; i++) {
+ for (size_t i = 0; 1; i++) {
res = s1[i] - s2[i];
if (res || (s1[i] == '\0'))
break;
@@ -156,10 +155,9 @@ int strcmp(const char *s1, const char *s2)
*/
int strncmp(const char *s1, const char *s2, size_t maxlen)
{
- int i, res;
+ int res = 0;
- res = 0;
- for (i = 0; i < maxlen; i++) {
+ for (size_t i = 0; i < maxlen; i++) {
res = s1[i] - s2[i];
if (res || (s1[i] == '\0'))
break;
@@ -179,10 +177,9 @@ int strncmp(const char *s1, const char *s2, size_t maxlen)
char *strncpy(char *d, const char *s, size_t n)
{
/* Use +1 to get the NUL terminator. */
- int max = n > strlen(s) + 1 ? strlen(s) + 1 : n;
- int i;
+ size_t max = n > strlen(s) + 1 ? strlen(s) + 1 : n;
- for (i = 0; i < max; i++)
+ for (size_t i = 0; i < max; i++)
d[i] = (char)s[i];
return d;
@@ -210,13 +207,12 @@ char *strcpy(char *d, const char *s)
char *strcat(char *d, const char *s)
{
char *p = d + strlen(d);
- int sl = strlen(s);
- int i;
+ size_t sl = strlen(s);
- for (i = 0; i < sl; i++)
+ for (size_t i = 0; i < sl; i++)
p[i] = s[i];
- p[i] = '\0';
+ p[sl] = '\0';
return d;
}
@@ -231,15 +227,13 @@ char *strcat(char *d, const char *s)
char *strncat(char *d, const char *s, size_t n)
{
char *p = d + strlen(d);
- int sl = strlen(s);
- int max = n > sl ? sl : n;
- // int max = n > strlen(s) ? strlen(s) : n;
- int i;
+ size_t sl = strlen(s);
+ size_t max = n > sl ? sl : n;
- for (i = 0; i < max; i++)
+ for (size_t i = 0; i < max; i++)
p[i] = s[i];
- p[i] = '\0';
+ p[max] = '\0';
return d;
}
@@ -249,22 +243,24 @@ char *strncat(char *d, const char *s, size_t n)
* @param d The destination string.
* @param s The source string.
* @param n d will have at most n-1 characters (plus NUL) after invocation.
- * @return A pointer to the destination string.
+ * @return The total length of the concatenated string.
*/
size_t strlcat(char *d, const char *s, size_t n)
{
- int sl = strlen(s);
- int dl = strlen(d);
+ size_t sl = strlen(s);
+ size_t dl = strlen(d);
+
+ if (n <= dl + 1)
+ return sl + dl;
char *p = d + dl;
- int max = n > (sl + dl) ? sl : (n - dl - 1);
- int i;
+ size_t max = n > (sl + dl) ? sl : (n - dl - 1);
- for (i = 0; i < max; i++)
+ for (size_t i = 0; i < max; i++)
p[i] = s[i];
- p[i] = '\0';
- return max;
+ p[max] = '\0';
+ return sl + dl;
}
/**
@@ -316,7 +312,7 @@ char *strrchr(const char *s, int c)
*/
char *strdup(const char *s)
{
- int n = strlen(s);
+ size_t n = strlen(s);
char *p = malloc(n + 1);
if (p != NULL) {
@@ -336,11 +332,13 @@ char *strdup(const char *s)
*/
char *strstr(const char *h, const char *n)
{
- int hn = strlen(h);
- int nn = strlen(n);
- int i;
+ size_t hn = strlen(h);
+ size_t nn = strlen(n);
- for (i = 0; i <= hn - nn; i++)
+ if (hn < nn)
+ return NULL;
+
+ for (size_t i = 0; i <= hn - nn; i++)
if (!memcmp(&h[i], n, nn))
return (char *)&h[i];
@@ -532,11 +530,11 @@ unsigned long int strtoul(const char *ptr, char **endptr, int base)
*/
size_t strspn(const char *s, const char *a)
{
- int i, j;
- int al = strlen(a);
+ size_t i;
+ size_t al = strlen(a);
for (i = 0; s[i] != 0; i++) {
int found = 0;
- for (j = 0; j < al; j++) {
+ for (size_t j = 0; j < al; j++) {
if (s[i] == a[j]) {
found = 1;
break;
@@ -556,11 +554,11 @@ size_t strspn(const char *s, const char *a)
*/
size_t strcspn(const char *s, const char *a)
{
- int i, j;
- int al = strlen(a);
+ size_t i;
+ size_t al = strlen(a);
for (i = 0; s[i] != 0; i++) {
int found = 0;
- for (j = 0; j < al; j++) {
+ for (size_t j = 0; j < al; j++) {
if (s[i] == a[j]) {
found = 1;
break;
@@ -645,12 +643,11 @@ char *strerror(int errnum)
* @param maxlen Maximum possible length of the string in code points
* @return Newly allocated ASCII string
*/
-char *utf16le_to_ascii(uint16_t *utf16_string, int maxlen)
+char *utf16le_to_ascii(const uint16_t *utf16_string, size_t maxlen)
{
char *ascii_string = xmalloc(maxlen + 1); /* +1 for trailing \0 */
ascii_string[maxlen] = '\0';
- int i;
- for (i = 0; i < maxlen; i++) {
+ for (size_t i = 0; i < maxlen; i++) {
uint16_t wchar = utf16_string[i];
ascii_string[i] = wchar > 0x7f ? '?' : (char)wchar;
}
diff --git a/src/Kconfig b/src/Kconfig
index 2bb5bfeab0..6288d0bc74 100644
--- a/src/Kconfig
+++ b/src/Kconfig
@@ -250,12 +250,28 @@ config RELOCATABLE_RAMSTAGE
wake. When selecting this option the romstage is responsible for
determing a stack location to use for loading the ramstage.
-config CACHE_RELOCATED_RAMSTAGE_OUTSIDE_CBMEM
- depends on RELOCATABLE_RAMSTAGE
+config TSEG_STAGE_CACHE
bool
+ default y
+ depends on !NO_STAGE_CACHE && SMM_TSEG
help
- The relocated ramstage is saved in an area specified by the
- by the board and/or chipset.
+ The option enables stage cache support for platform. Platform
+ can stash copies of postcar, ramstage and raw runtime data
+ inside SMM TSEG, to be restored on S3 resume path.
+
+config CBMEM_STAGE_CACHE
+ bool "Cache stages in CBMEM"
+ depends on !NO_STAGE_CACHE && !TSEG_STAGE_CACHE
+ help
+ The option enables stage cache support for platform. Platform
+ can stash copies of postcar, ramstage and raw runtime data
+ inside CBMEM.
+
+ While the approach is faster than reloading stages from boot media
+ it is also a possible attack scenario via which OS can possibly
+ circumvent SMM locks and SPI write protections.
+
+ If unsure, select 'N'
config UPDATE_IMAGE
bool "Update existing coreboot.rom image"
@@ -1143,7 +1159,7 @@ config RELOCATABLE_MODULES
config NO_STAGE_CACHE
bool
- default y if !HAVE_ACPI_RESUME
+ default y if !HAVE_ACPI_RESUME || !RELOCATABLE_RAMSTAGE
help
Do not save any component in stage cache for resume path. On resume,
all components would be read back from CBFS again.
diff --git a/src/acpi/sata.c b/src/acpi/sata.c
index ec0d505ca0..d7fcbd6daf 100644
--- a/src/acpi/sata.c
+++ b/src/acpi/sata.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 Alexander Couzens
+ * This file is part of the coreboot project.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
diff --git a/src/arch/mips/bootblock.S b/src/arch/mips/bootblock.S
index 849c168fd0..f8049c96d4 100644
--- a/src/arch/mips/bootblock.S
+++ b/src/arch/mips/bootblock.S
@@ -33,7 +33,7 @@ _start:
addi $t0, $t0, 4
/* Run main */
- b main
+ b mips_main
/*
* Should never return from main. Make sure there is no branch in the
diff --git a/src/arch/mips/bootblock_simple.c b/src/arch/mips/bootblock_simple.c
index 84029ebedb..e195b6ac85 100644
--- a/src/arch/mips/bootblock_simple.c
+++ b/src/arch/mips/bootblock_simple.c
@@ -19,7 +19,10 @@
#include
#include
-void main(void)
+/* called from assembly in bootblock.S */
+void mips_main(void);
+
+void mips_main(void)
{
bootblock_cpu_init();
diff --git a/src/arch/ppc64/Kconfig b/src/arch/ppc64/Kconfig
index 9e37bfc15f..0699e910ce 100644
--- a/src/arch/ppc64/Kconfig
+++ b/src/arch/ppc64/Kconfig
@@ -1,25 +1,20 @@
config ARCH_PPC64
bool
- default n
config ARCH_BOOTBLOCK_PPC64
bool
- default n
select ARCH_PPC64
select BOOTBLOCK_CUSTOM
select C_ENVIRONMENT_BOOTBLOCK
- select ARCH_VERSTAGE_PPC64
- select ARCH_ROMSTAGE_PPC64
- select ARCH_RAMSTAGE_PPC64
config ARCH_VERSTAGE_PPC64
bool
- default n
+ select ARCH_PPC64
config ARCH_ROMSTAGE_PPC64
bool
- default n
+ select ARCH_PPC64
config ARCH_RAMSTAGE_PPC64
bool
- default n
+ select ARCH_PPC64
diff --git a/src/arch/riscv/Kconfig b/src/arch/riscv/Kconfig
index a4f1788497..f2ca571c97 100644
--- a/src/arch/riscv/Kconfig
+++ b/src/arch/riscv/Kconfig
@@ -41,6 +41,30 @@ config ARCH_RISCV_S
bool
default n
+config RISCV_HAS_OPENSBI
+ def_bool n
+
+config RISCV_OPENSBI
+ bool "Use OpenSBI to hand over control to payload"
+ depends on ARCH_RISCV_M && ARCH_RISCV_S
+ depends on RISCV_HAS_OPENSBI
+ default n
+ help
+ Load OpenSBI after payload has been loaded and use it to
+ provide the SBI and to handover control to payload.
+
+config OPENSBI_PLATFORM
+ string
+ depends on RISCV_HAS_OPENSBI
+ help
+ The OpenSBI platform to build for.
+
+config OPENSBI_TEXT_START
+ hex
+ depends on RISCV_HAS_OPENSBI
+ help
+ The linking address used to build opensbi.
+
config ARCH_RISCV_U
# U (user) mode is for programs.
bool
diff --git a/src/arch/riscv/Makefile.inc b/src/arch/riscv/Makefile.inc
index d5f62954eb..0039fab180 100644
--- a/src/arch/riscv/Makefile.inc
+++ b/src/arch/riscv/Makefile.inc
@@ -147,6 +147,7 @@ ramstage-y += boot.c
ramstage-y += tables.c
ramstage-y += payload.c
ramstage-$(ARCH_RISCV_PMP) += pmp.c
+ramstage-y += fit_payload.c
ramstage-y += \
$(top)/src/lib/memchr.c \
$(top)/src/lib/memcmp.c \
@@ -174,4 +175,45 @@ LDFLAGS_ramstage += -m elf32lriscv
endif #CONFIG_ARCH_RISCV_RV32
endif #CONFIG_ARCH_RAMSTAGE_RISCV
+
+ifeq ($(CONFIG_RISCV_OPENSBI),y)
+
+OPENSBI_SOURCE := $(top)/3rdparty/opensbi
+OPENSBI_BUILD := $(abspath $(obj)/3rdparty/opensbi)
+OPENSBI_TARGET := $(OPENSBI_BUILD)/platform/$(CONFIG_OPENSBI_PLATFORM)/firmware/fw_dynamic.elf
+OPENSBI := $(obj)/opensbi.elf
+
+$(OPENSBI_TARGET): $(obj)/config.h | $(OPENSBI_SOURCE)
+ printf " MAKE $(subst $(obj)/,,$(@))\n"
+ mkdir -p $(OPENSBI_BUILD)
+ $(MAKE) \
+ -C "$(OPENSBI_SOURCE)" \
+ CC="$(CC_ramstage)" \
+ LD="$(LD_ramstage)" \
+ OBJCOPY="$(OBJCOPY_ramstage)" \
+ AR="$(AR_ramstage)" \
+ PLATFORM=$(CONFIG_OPENSBI_PLATFORM) \
+ O="$(OPENSBI_BUILD)" \
+ FW_JUMP=y \
+ FW_DYNAMIC=y \
+ FW_PAYLOAD=n \
+ FW_PAYLOAD_OFFSET=0 \
+ FW_TEXT_START=$(CONFIG_OPENSBI_TEXT_START)
+
+$(OPENSBI): $(OPENSBI_TARGET)
+ cp $< $@
+
+OPENSBI_CBFS := $(CONFIG_CBFS_PREFIX)/opensbi
+$(OPENSBI_CBFS)-file := $(OPENSBI)
+$(OPENSBI_CBFS)-type := payload
+$(OPENSBI_CBFS)-compression := $(CBFS_COMPRESS_FLAG)
+cbfs-files-y += $(OPENSBI_CBFS)
+
+check-ramstage-overlap-files += $(OPENSBI_CBFS)
+
+CPPFLAGS_common += -I$(OPENSBI_SOURCE)/include
+ramstage-y += opensbi.c
+
+endif #CONFIG_RISCV_OPENSBI
+
endif #CONFIG_ARCH_RISCV
diff --git a/src/arch/riscv/boot.c b/src/arch/riscv/boot.c
index 8e4bb36af5..6a23b8a696 100644
--- a/src/arch/riscv/boot.c
+++ b/src/arch/riscv/boot.c
@@ -20,6 +20,12 @@
#include
#include
#include
+#include
+
+struct arch_prog_run_args {
+ struct prog *prog;
+ struct prog *opensbi;
+};
/*
* A pointer to the Flattened Device Tree passed to coreboot by the boot ROM.
@@ -28,10 +34,10 @@
* This pointer is only used in ramstage!
*/
-static void do_arch_prog_run(struct prog *prog)
+static void do_arch_prog_run(struct arch_prog_run_args *args)
{
- void (*doit)(int hart_id, void *fdt);
int hart_id;
+ struct prog *prog = args->prog;
void *fdt = prog_entry_arg(prog);
/*
@@ -48,17 +54,39 @@ static void do_arch_prog_run(struct prog *prog)
fdt = HLS()->fdt;
if (ENV_RAMSTAGE && prog_type(prog) == PROG_PAYLOAD) {
- run_payload(prog, fdt, RISCV_PAYLOAD_MODE_S);
- return;
+ if (CONFIG(RISCV_OPENSBI))
+ run_payload_opensbi(prog, fdt, args->opensbi, RISCV_PAYLOAD_MODE_S);
+ else
+ run_payload(prog, fdt, RISCV_PAYLOAD_MODE_S);
+ } else {
+ void (*doit)(int hart_id, void *fdt) = prog_entry(prog);
+
+ hart_id = HLS()->hart_id;
+
+ doit(hart_id, fdt);
}
- doit = prog_entry(prog);
- hart_id = HLS()->hart_id;
-
- doit(hart_id, fdt);
+ die("Failed to run stage");
}
void arch_prog_run(struct prog *prog)
{
- smp_resume((void (*)(void *))do_arch_prog_run, prog);
+ struct arch_prog_run_args args = {};
+
+ args.prog = prog;
+
+ /* In case of OpenSBI we have to load it before resuming all HARTs */
+ if (ENV_RAMSTAGE && CONFIG(RISCV_OPENSBI)) {
+ struct prog sbi = PROG_INIT(PROG_OPENSBI, CONFIG_CBFS_PREFIX"/opensbi");
+
+ if (prog_locate(&sbi))
+ die("OpenSBI not found");
+
+ if (!selfload_check(&sbi, BM_MEM_OPENSBI))
+ die("OpenSBI load failed");
+
+ args.opensbi = &sbi;
+ }
+
+ smp_resume((void (*)(void *))do_arch_prog_run, &args);
}
diff --git a/src/arch/riscv/fit_payload.c b/src/arch/riscv/fit_payload.c
new file mode 100644
index 0000000000..60a4bc0557
--- /dev/null
+++ b/src/arch/riscv/fit_payload.c
@@ -0,0 +1,141 @@
+/*
+ * Copyright 2013 Google Inc.
+ * Copyright 2018 Facebook, Inc.
+ * Copyright 2019 9elements Agency GmbH
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+/* Implements a Berkley Boot Loader (BBL) compatible payload loading */
+
+#define MAX_KERNEL_SIZE (64*MiB)
+
+#if CONFIG(ARCH_RISCV_RV32)
+#define SECTION_ALIGN (4 * MiB)
+#endif
+#if CONFIG(ARCH_RISCV_RV64)
+#define SECTION_ALIGN (2 * MiB)
+#endif
+
+static size_t get_kernel_size(const struct fit_image_node *node)
+{
+ /*
+ * Since we don't have a way to determine the uncompressed size of the
+ * kernel, we have to keep as much memory as possible free for use by
+ * the kernel immediately after the end of the kernel image. The amount
+ * of space required will vary depending on selected features, and is
+ * effectively unbound.
+ */
+
+ printk(BIOS_INFO,
+ "FIT: Leaving additional %u MiB of free space after kernel.\n",
+ MAX_KERNEL_SIZE >> 20);
+
+ return node->size + MAX_KERNEL_SIZE;
+}
+
+/**
+ * Place the region in free memory range.
+ *
+ * The caller has to set region->offset to the minimum allowed address.
+ */
+static bool fit_place_mem(const struct range_entry *r, void *arg)
+{
+ struct region *region = arg;
+ resource_t start;
+
+ if (range_entry_tag(r) != BM_MEM_RAM)
+ return true;
+
+ /* Section must be aligned at page boundary */
+ start = ALIGN_UP(MAX(region->offset, range_entry_base(r)), SECTION_ALIGN);
+
+ if (start + region->size < range_entry_end(r)) {
+ region->offset = (size_t)start;
+ return false;
+ }
+
+ return true;
+}
+
+bool fit_payload_arch(struct prog *payload, struct fit_config_node *config,
+ struct region *kernel,
+ struct region *fdt,
+ struct region *initrd)
+{
+ void *arg = NULL;
+
+ if (!config->fdt || !fdt) {
+ printk(BIOS_CRIT, "CRIT: Providing a valid FDT is mandatory to "
+ "boot a RISC-V kernel!\n");
+ return false;
+ /* TODO: Fall back to the ROM FDT? */
+ }
+
+ /* Update kernel size from image header, if possible */
+ kernel->size = get_kernel_size(config->kernel);
+ printk(BIOS_DEBUG, "FIT: Using kernel size of 0x%zx bytes\n",
+ kernel->size);
+
+ /*
+ * The code assumes that bootmem_walk provides a sorted list of memory
+ * regions, starting from the lowest address.
+ * The order of the calls here doesn't matter, as the placement is
+ * enforced in the called functions.
+ * For details check code on top.
+ */
+ kernel->offset = 0;
+ if (!bootmem_walk(fit_place_mem, kernel))
+ return false;
+
+ /* Mark as reserved for future allocations. */
+ bootmem_add_range(kernel->offset, kernel->size, BM_MEM_PAYLOAD);
+
+ /* Place FDT and INITRD after kernel. */
+
+ /* Place INITRD */
+ if (config->ramdisk) {
+ initrd->offset = kernel->offset + kernel->size;
+
+ if (!bootmem_walk(fit_place_mem, initrd))
+ return false;
+ /* Mark as reserved for future allocations. */
+ bootmem_add_range(initrd->offset, initrd->size, BM_MEM_PAYLOAD);
+ }
+
+ /* Place FDT */
+ fdt->offset = kernel->offset + kernel->size;
+
+ if (!bootmem_walk(fit_place_mem, fdt))
+ return false;
+ /* Mark as reserved for future allocations. */
+ bootmem_add_range(fdt->offset, fdt->size, BM_MEM_PAYLOAD);
+
+ /* Kernel expects FDT as argument */
+ arg = (void *)fdt->offset;
+
+ prog_set_entry(payload, (void *)kernel->offset, arg);
+
+ bootmem_dump_ranges();
+
+ return true;
+}
diff --git a/src/arch/riscv/include/arch/boot.h b/src/arch/riscv/include/arch/boot.h
index 34a507edec..c05c669f00 100644
--- a/src/arch/riscv/include/arch/boot.h
+++ b/src/arch/riscv/include/arch/boot.h
@@ -16,12 +16,17 @@
#ifndef ARCH_RISCV_INCLUDE_ARCH_BOOT_H
#define ARCH_RISCV_INCLUDE_ARCH_BOOT_H
-#include
-
#define RISCV_PAYLOAD_MODE_U 0
#define RISCV_PAYLOAD_MODE_S 1
#define RISCV_PAYLOAD_MODE_M 3
+struct prog;
void run_payload(struct prog *prog, void *fdt, int payload_mode);
+void run_payload_opensbi(struct prog *prog, void *fdt, struct prog *opensbi, int payload_mode);
+void run_opensbi(const int hart_id,
+ const void *opensbi,
+ const void *fdt,
+ const void *payload,
+ const int payload_mode);
#endif
diff --git a/src/arch/riscv/opensbi.c b/src/arch/riscv/opensbi.c
new file mode 100644
index 0000000000..695c24f756
--- /dev/null
+++ b/src/arch/riscv/opensbi.c
@@ -0,0 +1,41 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2019 9elements Agency GmbH
+ *
+ * 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; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include
+#include
+/* DO NOT INLCUDE COREBOOT HEADERS HERE */
+
+void run_opensbi(const int hart_id,
+ const void *fdt,
+ const void *opensbi,
+ const void *payload,
+ const int payload_mode)
+{
+ struct fw_dynamic_info info = {
+ .magic = FW_DYNAMIC_INFO_MAGIC_VALUE,
+ .version = FW_DYNAMIC_INFO_VERSION_MAX,
+ .next_mode = payload_mode,
+ .next_addr = (uintptr_t)payload,
+ };
+
+ csr_write(mepc, opensbi);
+ asm volatile (
+ "mv a0, %0\n\t"
+ "mv a1, %1\n\t"
+ "mv a2, %2\n\t"
+ "mret" :
+ : "r"(hart_id), "r"(fdt), "r"(&info)
+ : "a0", "a1", "a2");
+}
diff --git a/src/arch/riscv/payload.c b/src/arch/riscv/payload.c
index 903e8a6ab6..297d30d2a5 100644
--- a/src/arch/riscv/payload.c
+++ b/src/arch/riscv/payload.c
@@ -15,18 +15,44 @@
* GNU General Public License for more details.
*/
+#include
#include
#include
#include
+#include
#include
#include
+/* Run OpenSBI and let OpenSBI hand over control to the payload */
+void run_payload_opensbi(struct prog *prog, void *fdt, struct prog *opensbi, int payload_mode)
+{
+ int hart_id = read_csr(mhartid);
+ uintptr_t status = read_csr(mstatus);
+ status = INSERT_FIELD(status, MSTATUS_MPIE, 0);
+
+ /*
+ * In case of OpenSBI we always run it in M-Mode.
+ * OpenSBI will switch to payload_mode when done.
+ */
+
+ status = INSERT_FIELD(status, MSTATUS_MPP, PRV_M);
+ /* Trap vector base address point to the payload */
+ write_csr(mtvec, prog_entry(opensbi));
+ /* disable M-Mode interrupt */
+ write_csr(mie, 0);
+ write_csr(mstatus, status);
+
+ run_opensbi(hart_id, fdt, prog_entry(opensbi), prog_entry(prog), payload_mode);
+}
+
+/* Runs the payload without OpenSBI integration */
void run_payload(struct prog *prog, void *fdt, int payload_mode)
{
void (*doit)(int hart_id, void *fdt) = prog_entry(prog);
int hart_id = read_csr(mhartid);
uintptr_t status = read_csr(mstatus);
status = INSERT_FIELD(status, MSTATUS_MPIE, 0);
+
switch (payload_mode) {
case RISCV_PAYLOAD_MODE_U:
status = INSERT_FIELD(status, MSTATUS_MPP, PRV_U);
diff --git a/src/arch/riscv/stages.c b/src/arch/riscv/stages.c
index 07b898f853..5b27508c47 100644
--- a/src/arch/riscv/stages.c
+++ b/src/arch/riscv/stages.c
@@ -24,8 +24,6 @@
* linker script.
*/
-#include
-#include
#include
#include
#include
diff --git a/src/arch/riscv/tables.c b/src/arch/riscv/tables.c
index eef6bf2ffd..c5bcab0661 100644
--- a/src/arch/riscv/tables.c
+++ b/src/arch/riscv/tables.c
@@ -18,6 +18,9 @@
#include
#include
#include
+#include
+
+DECLARE_OPTIONAL_REGION(opensbi);
void arch_write_tables(uintptr_t coreboot_table)
{
@@ -25,6 +28,9 @@ void arch_write_tables(uintptr_t coreboot_table)
void bootmem_arch_add_ranges(void)
{
+ if (CONFIG(RISCV_OPENSBI) && REGION_SIZE(opensbi) > 0)
+ bootmem_add_range((uintptr_t)_opensbi, REGION_SIZE(opensbi),
+ BM_MEM_OPENSBI);
}
void lb_arch_add_records(struct lb_header *header)
diff --git a/src/arch/x86/acpi.c b/src/arch/x86/acpi.c
index 8ab993ec48..fdcbcd3fb5 100644
--- a/src/arch/x86/acpi.c
+++ b/src/arch/x86/acpi.c
@@ -386,10 +386,15 @@ static void acpi_create_tpm2(acpi_tpm2_t *tpm2)
/* Hard to detect for coreboot. Just set it to 0 */
tpm2->platform_class = 0;
- /* Must be set to 0 for TIS interface support */
- tpm2->control_area = 0;
- /* coreboot only supports the TIS interface driver. */
- tpm2->start_method = 6;
+ if (CONFIG(CRB_TPM)) {
+ /* Must be set to 7 for CRB Support */
+ tpm2->control_area = CONFIG_CRB_TPM_BASE_ADDRESS + 0x40;
+ tpm2->start_method = 7;
+ } else {
+ /* Must be set to 0 for FIFO interface support */
+ tpm2->control_area = 0;
+ tpm2->start_method = 6;
+ }
memset(tpm2->msp, 0, sizeof(tpm2->msp));
/* Fill the log area size and start address fields. */
@@ -946,7 +951,7 @@ void acpi_create_dbg2(acpi_dbg2_header_t *dbg2,
}
unsigned long acpi_write_dbg2_pci_uart(acpi_rsdp_t *rsdp, unsigned long current,
- struct device *dev, uint8_t access_size)
+ const struct device *dev, uint8_t access_size)
{
acpi_dbg2_header_t *dbg2 = (acpi_dbg2_header_t *)current;
struct resource *res;
diff --git a/src/arch/x86/acpi_device.c b/src/arch/x86/acpi_device.c
index 0fb8f3b000..47bcc52c1e 100644
--- a/src/arch/x86/acpi_device.c
+++ b/src/arch/x86/acpi_device.c
@@ -53,9 +53,9 @@ static void acpi_device_fill_len(void *ptr)
}
/* Locate and return the ACPI name for this device */
-const char *acpi_device_name(struct device *dev)
+const char *acpi_device_name(const struct device *dev)
{
- struct device *pdev = dev;
+ const struct device *pdev = dev;
const char *name = NULL;
if (!dev)
@@ -82,7 +82,7 @@ const char *acpi_device_name(struct device *dev)
}
/* Recursive function to find the root device and print a path from there */
-static ssize_t acpi_device_path_fill(struct device *dev, char *buf,
+static ssize_t acpi_device_path_fill(const struct device *dev, char *buf,
size_t buf_len, size_t cur)
{
const char *name = acpi_device_name(dev);
@@ -117,7 +117,7 @@ static ssize_t acpi_device_path_fill(struct device *dev, char *buf,
* Warning: just as with dev_path() this uses a static buffer
* so should not be called mulitple times in one statement
*/
-const char *acpi_device_path(struct device *dev)
+const char *acpi_device_path(const struct device *dev)
{
static char buf[DEVICE_PATH_MAX] = {};
@@ -131,7 +131,7 @@ const char *acpi_device_path(struct device *dev)
}
/* Return the path of the parent device as the ACPI Scope for this device */
-const char *acpi_device_scope(struct device *dev)
+const char *acpi_device_scope(const struct device *dev)
{
static char buf[DEVICE_PATH_MAX] = {};
@@ -145,7 +145,7 @@ const char *acpi_device_scope(struct device *dev)
}
/* Concatentate the device path and provided name suffix */
-const char *acpi_device_path_join(struct device *dev, const char *name)
+const char *acpi_device_path_join(const struct device *dev, const char *name)
{
static char buf[DEVICE_PATH_MAX] = {};
ssize_t len;
diff --git a/src/arch/x86/include/arch/acpi.h b/src/arch/x86/include/arch/acpi.h
index 6251b98142..259efcd2d5 100644
--- a/src/arch/x86/include/arch/acpi.h
+++ b/src/arch/x86/include/arch/acpi.h
@@ -901,7 +901,7 @@ void acpi_create_dbg2(acpi_dbg2_header_t *dbg2_header,
const char *device_path);
unsigned long acpi_write_dbg2_pci_uart(acpi_rsdp_t *rsdp, unsigned long current,
- struct device *dev, uint8_t access_size);
+ const struct device *dev, uint8_t access_size);
void acpi_create_dmar(acpi_dmar_t *dmar, enum dmar_flags flags,
unsigned long (*acpi_fill_dmar)(unsigned long));
unsigned long acpi_create_dmar_drhd(unsigned long current, u8 flags,
diff --git a/src/arch/x86/include/arch/acpi_device.h b/src/arch/x86/include/arch/acpi_device.h
index 35695467cb..d74af9da74 100644
--- a/src/arch/x86/include/arch/acpi_device.h
+++ b/src/arch/x86/include/arch/acpi_device.h
@@ -62,10 +62,10 @@ struct acpi_dp {
#define ACPI_DT_NAMESPACE_HID "PRP0001"
struct device;
-const char *acpi_device_name(struct device *dev);
-const char *acpi_device_path(struct device *dev);
-const char *acpi_device_scope(struct device *dev);
-const char *acpi_device_path_join(struct device *dev, const char *name);
+const char *acpi_device_name(const struct device *dev);
+const char *acpi_device_path(const struct device *dev);
+const char *acpi_device_scope(const struct device *dev);
+const char *acpi_device_path_join(const struct device *dev, const char *name);
int acpi_device_status(const struct device *dev);
/*
diff --git a/src/arch/x86/smbios.c b/src/arch/x86/smbios.c
index 2f5c3a643e..346e874217 100644
--- a/src/arch/x86/smbios.c
+++ b/src/arch/x86/smbios.c
@@ -500,6 +500,11 @@ smbios_board_type __weak smbios_mainboard_board_type(void)
return SMBIOS_BOARD_TYPE_UNKNOWN;
}
+u8 __weak smbios_mainboard_enclosure_type(void)
+{
+ return CONFIG_SMBIOS_ENCLOSURE_TYPE;
+}
+
const char *__weak smbios_system_serial_number(void)
{
return smbios_mainboard_serial_number();
@@ -620,7 +625,7 @@ static int smbios_write_type3(unsigned long *current, int handle)
t->bootup_state = SMBIOS_STATE_SAFE;
t->power_supply_state = SMBIOS_STATE_SAFE;
t->thermal_state = SMBIOS_STATE_SAFE;
- t->_type = CONFIG_SMBIOS_ENCLOSURE_TYPE;
+ t->_type = smbios_mainboard_enclosure_type();
t->security_status = SMBIOS_STATE_SAFE;
len = t->length + smbios_string_table_len(t->eos);
*current += len;
diff --git a/src/commonlib/include/commonlib/cbmem_id.h b/src/commonlib/include/commonlib/cbmem_id.h
index 2236c95b8f..ec702ecfdf 100644
--- a/src/commonlib/include/commonlib/cbmem_id.h
+++ b/src/commonlib/include/commonlib/cbmem_id.h
@@ -68,7 +68,7 @@
#define CBMEM_ID_TCPA_TCG_LOG 0x54445041
#define CBMEM_ID_TIMESTAMP 0x54494d45
#define CBMEM_ID_TPM2_TCG_LOG 0x54504d32
-#define CBMEM_ID_VBOOT_HANDOFF 0x780074f0
+#define CBMEM_ID_VBOOT_HANDOFF 0x780074f0 /* deprecated */
#define CBMEM_ID_VBOOT_SEL_REG 0x780074f1 /* deprecated */
#define CBMEM_ID_VBOOT_WORKBUF 0x78007343
#define CBMEM_ID_VPD 0x56504420
diff --git a/src/commonlib/include/commonlib/coreboot_tables.h b/src/commonlib/include/commonlib/coreboot_tables.h
index 1ae5421bba..7bded2a3a3 100644
--- a/src/commonlib/include/commonlib/coreboot_tables.h
+++ b/src/commonlib/include/commonlib/coreboot_tables.h
@@ -68,7 +68,7 @@ enum {
LB_TAG_CBMEM_CONSOLE = 0x0017,
LB_TAG_MRC_CACHE = 0x0018,
LB_TAG_VBNV = 0x0019,
- LB_TAG_VBOOT_HANDOFF = 0x0020,
+ LB_TAG_VBOOT_HANDOFF = 0x0020, /* deprecated */
LB_TAG_X86_ROM_MTRR = 0x0021,
LB_TAG_DMA = 0x0022,
LB_TAG_RAM_OOPS = 0x0023,
@@ -283,6 +283,18 @@ struct lb_forward {
* fields described above. It may, however, only implement a subset
* of the possible color formats.
*/
+
+/*
+ * Framebuffer orientation, matches drm_connector.h drm_panel_orientation in the
+ * Linux kernel.
+ */
+enum lb_fb_orientation {
+ LB_FB_ORIENTATION_NORMAL = 0,
+ LB_FB_ORIENTATION_BOTTOM_UP = 1,
+ LB_FB_ORIENTATION_LEFT_UP = 2,
+ LB_FB_ORIENTATION_RIGHT_UP = 3,
+};
+
struct lb_framebuffer {
uint32_t tag;
uint32_t size;
@@ -300,6 +312,7 @@ struct lb_framebuffer {
uint8_t blue_mask_size;
uint8_t reserved_mask_pos;
uint8_t reserved_mask_size;
+ uint8_t orientation;
};
diff --git a/src/console/vtxprintf.c b/src/console/vtxprintf.c
index 848ad501ce..f34c91bb5f 100644
--- a/src/console/vtxprintf.c
+++ b/src/console/vtxprintf.c
@@ -271,6 +271,7 @@ repeat:
case 'X':
flags |= LARGE;
+ /* fall through */
case 'x':
base = 16;
break;
diff --git a/src/cpu/allwinner/Kconfig b/src/cpu/allwinner/Kconfig
deleted file mode 100644
index d97cb644ff..0000000000
--- a/src/cpu/allwinner/Kconfig
+++ /dev/null
@@ -1 +0,0 @@
-source src/cpu/allwinner/a10/Kconfig
diff --git a/src/cpu/allwinner/Makefile.inc b/src/cpu/allwinner/Makefile.inc
deleted file mode 100644
index e52a12e41d..0000000000
--- a/src/cpu/allwinner/Makefile.inc
+++ /dev/null
@@ -1 +0,0 @@
-subdirs-$(CONFIG_CPU_ALLWINNER_A10) += a10
diff --git a/src/cpu/allwinner/a10/Kconfig b/src/cpu/allwinner/a10/Kconfig
deleted file mode 100644
index 0b5d9bf60d..0000000000
--- a/src/cpu/allwinner/a10/Kconfig
+++ /dev/null
@@ -1,18 +0,0 @@
-config CPU_ALLWINNER_A10
- bool
- default n
-
-if CPU_ALLWINNER_A10
-
-config CPU_SPECIFIC_OPTIONS
- def_bool y
- select ARCH_BOOTBLOCK_ARMV7
- select ARCH_VERSTAGE_ARMV7
- select ARCH_ROMSTAGE_ARMV7
- select ARCH_RAMSTAGE_ARMV7
- select NO_MONOTONIC_TIMER
- select HAVE_UART_SPECIAL
- select UART_OVERRIDE_REFCLK
- select BOOT_DEVICE_NOT_SPI_FLASH
-
-endif # if CPU_ALLWINNER_A10
diff --git a/src/cpu/allwinner/a10/Makefile.inc b/src/cpu/allwinner/a10/Makefile.inc
deleted file mode 100644
index cbdb5ae856..0000000000
--- a/src/cpu/allwinner/a10/Makefile.inc
+++ /dev/null
@@ -1,55 +0,0 @@
-bootblock-y += bootblock.c
-bootblock-y += bootblock_media.c
-bootblock-y += clock.c
-bootblock-y += gpio.c
-bootblock-y += pinmux.c
-bootblock-y += raminit.c
-bootblock-y += timer.c
-
-romstage-y += bootblock_media.c
-romstage-y += cbmem.c
-romstage-y += clock.c
-romstage-y += pinmux.c
-romstage-y += timer.c
-romstage-y += twi.c
-
-ramstage-y += bootblock_media.c
-ramstage-y += cbmem.c
-ramstage-y += clock.c
-ramstage-y += cpu.c
-ramstage-y += timer.c
-ramstage-y += twi.c
-
-bootblock-y += uart.c uart_console.c
-romstage-y += uart.c uart_console.c
-ramstage-y += uart.c uart_console.c
-
-real-target: $(obj)/BOOT0
-
-get_bootblock_size= \
- $(eval bb_s=$(shell $(CBFSTOOL) $(1) print | grep bootblocksize | \
- sed 's/[^0-9 ]//g')) \
- $(shell echo $$(($(word 2, $(strip $(bb_s))))))
-
-# This tool is used to prepend a header to coreboot.rom to trick the SoC into
-# loading out bootblock
-#
-MKSUNXIBOOT:=$(objutil)/mksunxiboot
-$(MKSUNXIBOOT): $(top)/util/arm_boot_tools/mksunxiboot/mksunxiboot.c
- @printf " HOSTCC $(subst $(obj)/,,$(@))\n"
- $(HOSTCC) $(HOSTCFLAGS) -o $@ $<
-
-# The boot ROM in the SoC will start loading code if a special BOOT0 header is
-# found (at an offset of 8KiB in either NAND or SD), and the checksum is
-# correct. This header is added by the 'mxsunxiboot' tool, which is provided
-# under util/arm_boot_tools/mksunxiboot. The boot ROM will load at most 24KiB of
-# data to SRAM. The BOOT0 header takes 32 bytes, so bootblock is limited to
-# 24KiB - 32 bytes.
-# TODO: make mksunxiboot take the bootblock size as a parameter
-# TODO: print an error if bootblock is too large (maybe place ROMSTAGE at the
-# exact offset needed to collide with the bootblock)
-# FIXME: A10 loads 24KiB. According to Oliver other chips load a little more
-#
-$(obj)/BOOT0: $(obj)/coreboot.rom $(MKSUNXIBOOT)
- @printf " BOOT0 $(subst $(obj)/,,$(^))\n"
- $(MKSUNXIBOOT) $(word 1, $^) $@
diff --git a/src/cpu/allwinner/a10/bootblock.c b/src/cpu/allwinner/a10/bootblock.c
deleted file mode 100644
index 471104b0ed..0000000000
--- a/src/cpu/allwinner/a10/bootblock.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2013 Google Inc.
- * Copyright (C) 2013 Alexandru Gagniuc
- *
- * 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; version 2 of the License or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * Allwinner A10 bootblock initialization
- *
- */
-
-#include
-#include
-#include
-
-void bootblock_soc_init(void)
-{
- uint32_t sctlr;
-
- /* enable dcache */
- sctlr = read_sctlr();
- sctlr |= SCTLR_C;
- write_sctlr(sctlr);
-}
diff --git a/src/cpu/allwinner/a10/bootblock_media.c b/src/cpu/allwinner/a10/bootblock_media.c
deleted file mode 100644
index c89cac0ceb..0000000000
--- a/src/cpu/allwinner/a10/bootblock_media.c
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2013 Alexandru Gagniuc
- *
- * 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; version 2 of the License or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * CBFS accessors for bootblock stage.
- *
- */
-#include
-#include
-
-const struct region_device *boot_device_ro(void)
-{
- printk(BIOS_ERR, "Oh my! I don't know how to access CBFS yet.");
- return NULL;
-}
diff --git a/src/cpu/allwinner/a10/cbmem.c b/src/cpu/allwinner/a10/cbmem.c
deleted file mode 100644
index a4c563a30e..0000000000
--- a/src/cpu/allwinner/a10/cbmem.c
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2013 Alexandru Gagniuc
- *
- * 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; version 2 of the License or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * Provides cbmem utilities for romstage and ramstage
- *
- */
-
-#include "ram_segs.h"
-#include
-
-void *cbmem_top(void)
-{
- return a1x_get_cbmem_top();
-}
diff --git a/src/cpu/allwinner/a10/clock.c b/src/cpu/allwinner/a10/clock.c
deleted file mode 100644
index 9e4e93dfe1..0000000000
--- a/src/cpu/allwinner/a10/clock.c
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2013 Alexandru Gagniuc
- *
- * 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; version 2 of the License or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * Helpers for clock control and gating on Allwinner CPUs
- */
-
-#include "clock.h"
-
-#include
-#include
-#include
-#include
-
-static struct a10_ccm *const ccm = (void *)A1X_CCM_BASE;
-
-/**
- * \brief Enable the clock source for the peripheral
- *
- * @param[in] periph peripheral and clock type to enable @see a1x_clken
- */
-void a1x_periph_clock_enable(enum a1x_clken periph)
-{
- void *addr;
- u32 reg32;
-
- addr = (void *)A1X_CCM_BASE + (periph >> 5);
- reg32 = read32(addr);
- reg32 |= 1 << (periph & 0x1f);
- write32(addr, reg32);
-}
-
-/**
- * \brief Disable the clock source for the peripheral
- *
- * @param[in] periph peripheral and clock type to disable @see a1x_clken
- */
-void a1x_periph_clock_disable(enum a1x_clken periph)
-{
- void *addr;
- u32 reg32;
-
- addr = (void *)A1X_CCM_BASE + (periph >> 5);
- reg32 = read32(addr);
- reg32 &= ~(1 << (periph & 0x1f));
- write32(addr, reg32);
-}
-
-/**
- * \brief Configure PLL5 factors
- *
- * This is a low-level accessor to configure the divisors and multipliers of
- * PLL5. PLL5 uses two factors to multiply the 24MHz oscillator clock to
- * generate a pre-clock. The pre-divided clock is then divided by one of two
- * independent divisors, one for DRAM, and another for peripherals clocked from
- * this PLL. If the PLL was previously disabled, this function will enable it.
- * Other than that, this function only modifies these factors, and leaves the
- * other settings unchanged.
- *
- * The output clocks are given by the following formulas:
- *
- * Pre-clock = (24 MHz * N * K) <- Must be between 240MHz and 2GHz
- * DRAM clock = pre / M
- * Other module = pre / P
- *
- * It is the caller's responsibility to make sure the pre-divided clock falls
- * within the operational range of the PLL, and that the divisors and
- * multipliers are within their ranges.
- *
- * @param[in] mul_n Multiplier N, between 0 and 32
- * @param[in] mul_k Multiplier K, between 1 and 4
- * @param[in] div_m DRAM clock divisor, between 1 and 4
- * @param[in] exp_div_p Peripheral clock divisor exponent, between 0 and 3
- * (P = 1/2/4/8, respectively)
- */
-void a1x_pll5_configure(u8 mul_n, u8 mul_k, u8 div_m, u8 exp_div_p)
-{
- u32 reg32;
-
- reg32 = read32(&ccm->pll5_cfg);
- reg32 &= ~(PLL5_FACTOR_M_MASK | PLL5_FACTOR_N_MASK |
- PLL5_FACTOR_K_MASK | PLL5_DIV_EXP_P_MASK);
- /* The M1 factor is not documented in the datasheet, and the reference
- * raminit code does not use it. Whether this is a fractional divisor,
- * or an additional divisor is unknown, so don't use it for now */
- reg32 &= ~PLL5_FACTOR_M1_MASK;
- reg32 |= (PLL5_FACTOR_M(div_m) | PLL5_FACTOR_N(mul_n) |
- PLL5_FACTOR_K(mul_k) | PLL5_DIV_EXP_P(exp_div_p));
- reg32 |= PLL5_PLL_ENABLE;
- write32(&ccm->pll5_cfg, reg32);
-}
-
-/**
- * \brief Enable the clock output to DRAM chips
- *
- * This enables the DRAM clock to be sent to DRAM chips. This should normally be
- * done after PLL5 is configured and locked. Note that the clock may be gated,
- * and also needs to be ungated in order to reach the DDR chips.
- * Also see @ref clock_ungate_dram_clk_output
- */
-void a1x_pll5_enable_dram_clock_output(void)
-{
- setbits_le32(&ccm->pll5_cfg, PLL5_DDR_CLK_OUT_EN);
-}
-
-/**
- * \brief Ungate the clock to DRAM chips
- *
- * Although the DRAM clock output may be enabled, it is by default gated. It
- * needs to be ungated before reaching DRAM.
- */
-void a1x_ungate_dram_clock_output(void)
-{
- setbits_le32(&ccm->dram_clk_cfg, DRAM_CTRL_DCLK_OUT);
-}
-
-/**
- * \brief Gate the clock to DRAM chips
- *
- * Disable the clock to DRAM without altering PLL configuration, by closing the
- * DRAM clock gate.
- */
-void a1x_gate_dram_clock_output(void)
-{
- clrbits_le32(&ccm->dram_clk_cfg, DRAM_CTRL_DCLK_OUT);
-}
-
-/*
- * Linker doesn't garbage collect and the function below adds about half
- * kilobyte to the bootblock, and log2_ceil is not available in the bootblock.
- */
-#ifndef __BOOTBLOCK__
-
-#define PLL1_CFG(N, K, M, P_EXP) \
- ((1 << 31 | 0 << 30 | 8 << 26 | 0 << 25 | 16 << 20 | 2 << 13) | \
- (P_EXP) << 16 | (N) << 8 | \
- (K - 1) << 4 | 0 << 3 | 0 << 2 | (M -1) << 0)
-
-static const struct {
- u32 pll1_cfg;
- u16 freq_mhz;
-} pll1_table[] = {
- /* PLL1 output = (24MHz * N * K) / (M * P) */
- { PLL1_CFG(16, 1, 1, 0), 384 },
- { PLL1_CFG(16, 2, 1, 0), 768 },
- { PLL1_CFG(20, 2, 1, 0), 960 },
- { PLL1_CFG(21, 2, 1, 0), 1008 },
- { PLL1_CFG(22, 2, 1, 0), 1056 },
- { PLL1_CFG(23, 2, 1, 0), 1104 },
- { PLL1_CFG(24, 2, 1, 0), 1152 },
- { PLL1_CFG(25, 2, 1, 0), 1200 },
- { PLL1_CFG(26, 2, 1, 0), 1248 },
- { PLL1_CFG(27, 2, 1, 0), 1296 },
- { PLL1_CFG(28, 2, 1, 0), 1344 },
- { PLL1_CFG(29, 2, 1, 0), 1392 },
- { PLL1_CFG(30, 2, 1, 0), 1440 },
- { PLL1_CFG(31, 2, 1, 0), 1488 },
- { PLL1_CFG(20, 4, 1, 0), 1944 },
-};
-
-static void cpu_clk_src_switch(u32 clksel_bits)
-{
- u32 reg32;
-
- reg32 = read32(&ccm->cpu_ahb_apb0_cfg);
- reg32 &= ~CPU_CLK_SRC_MASK;
- reg32 |= clksel_bits & CPU_CLK_SRC_MASK;
- write32(&ccm->cpu_ahb_apb0_cfg, reg32);
-}
-
-static void change_sys_divisors(u8 axi, u8 ahb_exp, u8 apb0_exp)
-{
- u32 reg32;
-
- reg32 = read32(&ccm->cpu_ahb_apb0_cfg);
- /* Not a typo: We want to keep only the CLK_SRC bits */
- reg32 &= CPU_CLK_SRC_MASK;
- reg32 |= ((axi - 1) << 0) & AXI_DIV_MASK;
- reg32 |= (ahb_exp << 4) & AHB_DIV_MASK;
- reg32 |= (apb0_exp << 8) & APB0_DIV_MASK;
- write32(&ccm->cpu_ahb_apb0_cfg, reg32);
-}
-
-static void spin_delay(u32 loops)
-{
- volatile u32 x = loops;
- while (x--);
-}
-
-/**
- * \brief Configure the CPU clock and PLL1
- *
- * To run at full speed, the CPU uses PLL1 as the clock source. AXI, AHB, and
- * APB0 are derived from the CPU clock, and need to be kept within certain
- * limits. This function configures PLL1 as close as possible to the desired
- * frequency, based on a set of known working configurations for PLL1. It then
- * calculates and applies the appropriate divisors for the AXI/AHB/APB0 clocks,
- * before finally switching the CPU to run from the new clock.
- * No further configuration of the CPU clock or divisors is needed. after
- * calling this function.
- *
- * @param[in] cpu_clk_mhz Desired CPU clock, in MHz
- */
-void a1x_set_cpu_clock(u16 cpu_clk_mhz)
-{
- int i = 0;
- u8 axi, ahb, ahb_exp, apb0, apb0_exp;
- u32 actual_mhz;
-
- /*
- * Rated clock for PLL1 is 2000 MHz, but there is no combination of
- * parameters that yields that exact frequency. 1944 MHz is the highest.
- */
- if (cpu_clk_mhz > 1944) {
- printk(BIOS_CRIT, "BUG! maximum PLL1 clock is 1944 MHz,"
- "but asked to clock CPU at %d MHz\n",
- cpu_clk_mhz);
- cpu_clk_mhz = 1944;
- }
- /* Find target frequency */
- while (pll1_table[i].freq_mhz < cpu_clk_mhz)
- i++;
-
- actual_mhz = pll1_table[i].freq_mhz;
-
- if (cpu_clk_mhz != actual_mhz) {
- printk(BIOS_WARNING, "Parameters for %d MHz not available, "
- "setting CPU clock at %d MHz\n",
- cpu_clk_mhz, actual_mhz);
- }
-
- /*
- * Calculate system clock divisors:
- * The minimum clock divisor for APB0 is 2, which guarantees that AHB0
- * will always be in spec, as long as AHB is in spec, although the max
- * AHB0 clock we can get is 125 MHz
- */
- axi = DIV_ROUND_UP(actual_mhz, 450); /* Max 450 MHz */
- ahb = DIV_ROUND_UP(actual_mhz/axi, 250); /* Max 250 MHz */
- apb0 = 2; /* Max 150 MHz */
-
- ahb_exp = log2_ceil(ahb);
- ahb = 1 << ahb_exp;
- apb0_exp = 1;
-
- printk(BIOS_INFO, "CPU: %d MHz, AXI %d Mhz, AHB: %d MHz APB0: %d MHz\n",
- actual_mhz,
- actual_mhz / axi,
- actual_mhz / (axi * ahb),
- actual_mhz / (axi * ahb * apb0));
-
- /* Keep the CPU off PLL1 while we change PLL parameters */
- cpu_clk_src_switch(CPU_CLK_SRC_OSC24M);
- /*
- * We can't use udelay() here. udelay() relies on timer 0, but timers
- * have the habit of not ticking when the CPU is clocked from the main
- * oscillator.
- */
- spin_delay(8);
-
- change_sys_divisors(axi, ahb_exp, apb0_exp);
-
- /* Configure PLL1 at the desired frequency */
- write32(&ccm->pll1_cfg, pll1_table[i].pll1_cfg);
- spin_delay(8);
-
- cpu_clk_src_switch(CPU_CLK_SRC_PLL1);
- /* Here, we're running from PLL, so timers will tick */
- udelay(1);
-}
-
-#endif /* __BOOTBLOCK__ */
diff --git a/src/cpu/allwinner/a10/clock.h b/src/cpu/allwinner/a10/clock.h
deleted file mode 100644
index 110a6f8ec9..0000000000
--- a/src/cpu/allwinner/a10/clock.h
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2007-2011 Allwinner Technology Co., Ltd.
- * Tom Cubie
- * Copyright (C) 2013 Alexandru Gagniuc
- *
- * 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; version 2 of the License. or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * Definitions for clock control and gating on Allwinner CPUs
- */
-
-#ifndef CPU_ALLWINNER_A10_CLOCK_H
-#define CPU_ALLWINNER_A10_CLOCK_H
-
-#include "memmap.h"
-#include
-
-/* CPU_AHB_APB0 config values */
-#define CPU_CLK_SRC_MASK (3 << 16)
-#define CPU_CLK_SRC_OSC24M (1 << 16)
-#define CPU_CLK_SRC_PLL1 (2 << 16)
-#define APB0_DIV_MASK (3 << 8)
-#define APB0_DIV_1 (0 << 8)
-#define APB0_DIV_2 (1 << 8)
-#define APB0_DIV_4 (2 << 8)
-#define APB0_DIV_8 (3 << 8)
-#define AHB_DIV_MASK (3 << 4)
-#define AHB_DIV_1 (0 << 4)
-#define AHB_DIV_2 (1 << 4)
-#define AHB_DIV_4 (2 << 4)
-#define AHB_DIV_8 (3 << 4)
-#define AXI_DIV_MASK (3 << 0)
-#define AXI_DIV_1 (0 << 0)
-#define AXI_DIV_2 (1 << 0)
-#define AXI_DIV_3 (2 << 0)
-#define AXI_DIV_4 (3 << 0)
-
-/* APB1_CLK_DIV values */
-#define APB1_CLK_SRC_MASK (3 << 24)
-#define APB1_CLK_SRC_OSC24M (0 << 24)
-#define APB1_CLK_SRC_PLL6 (1 << 24)
-#define APB1_CLK_SRC_32K (2 << 24)
-#define APB1_RAT_N_MASK (3 << 16)
-#define APB1_RAT_N(m) (((m) & 0x3) << 16)
-#define APB1_RAT_M_MASK (0x1f << 0)
-#define APB1_RAT_M(n) (((n) & 0x1f) << 0)
-
-/* PLL5_CFG values */
-#define PLL5_PLL_ENABLE (1 << 31)
-#define PLL5_OUT_BYPASS_EN (1 << 30)
-#define PLL5_DDR_CLK_OUT_EN (1 << 29)
-#define PLL5_DIV_EXP_P_MASK (0x3 << 16)
-#define PLL5_DIV_EXP_P(ep) ((ep << 16) & PLL5_DIV_EXP_P_MASK)
-#define PLL5_DIV_P_1 (0x0 << 16)
-#define PLL5_DIV_P_2 (0x1 << 16)
-#define PLL5_DIV_P_4 (0x2 << 16)
-#define PLL5_DIV_P_8 (0x3 << 16)
-#define PLL5_FACTOR_N_MASK (0x1f << 8)
-#define PLL5_FACTOR_N(n) ((n << 8) & PLL5_FACTOR_N_MASK)
-#define PLL5_LDO_EN (1 << 7)
-#define PLL5_FACTOR_K_MASK (0x3 << 4)
-#define PLL5_FACTOR_K(k) ((((k) - 1) << 4) & PLL5_FACTOR_K_MASK)
-#define PLL5_FACTOR_M1_MASK (0x3 << 2)
-#define PLL5_FACTOR_M1(m1) (((m1) << 2) & PLL5_FACTOR_M1_MASK)
-#define PLL5_FACTOR_M_MASK (0x3 << 0)
-#define PLL5_FACTOR_M(m) ((((m) - 1) << 0) & PLL5_FACTOR_M_MASK)
-
-/* DRAM_CLK values*/
-#define DRAM_CTRL_DCLK_OUT (1 << 15)
-
-/* SDx_CLK values */
-#define SDx_CLK_GATE (1 << 31)
-#define SDx_CLK_SRC_MASK (3 << 24)
-#define SDx_CLK_SRC_OSC24M (0 << 24)
-#define SDx_CLK_SRC_PLL6 (1 << 24)
-#define SDx_CLK_SRC_PLL5 (2 << 24)
-#define SDx_RAT_EXP_N_MASK (3 << 16)
-#define SDx_RAT_EXP_N(n) (((n) << 16) & SDx_RAT_EXP_N_MASK)
-#define SDx_RAT_M_MASK (0xf << 0)
-#define SDx_RAT_M(m) ((((m) - 1) << 0) & SDx_RAT_M_MASK)
-/**
- * \brief Clock gating definitions
- *
- * The definitions are specified in the form:
- * 31:5 register offset from A1X_CCM_BASE for the clock register
- * 4:0 bit offset for the given peripheral
- *
- * The names have the form [periph_type][periph_number]
- *
- * These definitions are meant to be used with @ref a1x_periph_clock_enable and
- * @ref a1x_periph_clock_disable
- */
-
-enum a1x_clken {
- /* AXI module clock gating */
- A1X_CLKEN_DRAM_AXI = (0x5C << 5),
- /* AHB0 module clock gating */
- A1X_CLKEN_USB0 = (0x60 << 5),
- A1X_CLKEN_EHCI0,
- RSVD_0x60_2,
- A1X_CLKEN_EHCI1,
- RSVD_0x60_4,
- A1X_CLKEN_SS,
- A1X_CLKEN_DMA,
- A1X_CLKEN_BIST,
- A1X_CLKEN_MMC0,
- A1X_CLKEN_MMC1,
- A1X_CLKEN_MMC2,
- A1X_CLKEN_MMC3,
- A1X_CLKEN_NC,
- A1X_CLKEN_NAND,
- A1X_CLKEN_SDRAM,
- RSVD_0x60_15,
- A1X_CLKEN_ACE,
- A1X_CLKEN_EMAC,
- A1X_CLKEN_TS,
- RSVD_0x60_19,
- A1X_CLKEN_SPI0,
- A1X_CLKEN_SPI1,
- A1X_CLKEN_SPI2,
- A1X_CLKEN_SPI3,
- A1X_CLKEN_PATA,
- RSVD_0x60_25,
- A1X_CLKEN_GPS,
- /* AHB1 module clock gating */
- A1X_CLKEN_DRAM_VE = (0x64 << 5),
- A1X_CLKEN_TVD,
- A1X_CLKEN_TVE0,
- A1X_CLKEN_TVE1,
- A1X_CLKEN_LCD0,
- A1X_CLKEN_LCD1,
- RSVD_0x64_6,
- RSVD_0x64_7,
- A1X_CLKEN_CSI0,
- A1X_CLKEN_CSI1,
- RSVD_0x64_10,
- A1X_CLKEN_HDMI,
- A1X_CLKEN_DE_BE0,
- A1X_CLKEN_DE_BE1,
- A1X_CLKEN_DE_FE0,
- A1X_CLKEN_DE_FE1,
- RSVD_0x64_16,
- RSVD_0x64_17,
- A1X_CLKEN_MP,
- RSVD_0x64_19,
- A1X_CLKEN_MALI400,
- /* APB0 module clock gating */
- A1X_CLKEN_CODEC = (0x68 << 5),
- A1X_CLKEN_NC_APB,
- A1X_CLKEN_AC97,
- A1X_CLKEN_IIS,
- RSVD_0x68_4,
- A1X_CLKEN_PIO,
- A1X_CLKEN_IR0,
- A1X_CLKEN_IR1,
- RSVD_0x68_8,
- RSVD_0x68_9,
- A1X_CLKEN_KEYPAD,
- /* APB1 module clock gating */
- A1X_CLKEN_TWI0 = (0x6C << 5),
- A1X_CLKEN_TWI1,
- A1X_CLKEN_TWI2,
- RSVD_0x6C_3,
- A1X_CLKEN_CAN,
- A1X_CLKEN_SCR,
- A1X_CLKEN_PS20,
- A1X_CLKEN_PS21,
- RSVD_0x6C_8,
- RSVD_0x6C_9,
- RSVD_0x6C_10,
- RSVD_0x6C_11,
- RSVD_0x6C_12,
- RSVD_0x6C_13,
- RSVD_0x6C_14,
- RSVD_0x6C_15,
- A1X_CLKEN_UART0,
- A1X_CLKEN_UART1,
- A1X_CLKEN_UART2,
- A1X_CLKEN_UART3,
- A1X_CLKEN_UART4,
- A1X_CLKEN_UART5,
- A1X_CLKEN_UART6,
- A1X_CLKEN_UART7,
-};
-
-struct a10_ccm {
- u32 pll1_cfg; /* 0x00 pll1 control */
- u32 pll1_tun; /* 0x04 pll1 tuning */
- u32 pll2_cfg; /* 0x08 pll2 control */
- u32 pll2_tun; /* 0x0c pll2 tuning */
- u32 pll3_cfg; /* 0x10 pll3 control */
- u8 res0[0x4];
- u32 pll4_cfg; /* 0x18 pll4 control */
- u8 res1[0x4];
- u32 pll5_cfg; /* 0x20 pll5 control */
- u32 pll5_tun; /* 0x24 pll5 tuning */
- u32 pll6_cfg; /* 0x28 pll6 control */
- u32 pll6_tun; /* 0x2c pll6 tuning */
- u32 pll7_cfg; /* 0x30 pll7 control */
- u32 pll1_tun2; /* 0x34 pll5 tuning2 */
- u8 res2[0x4];
- u32 pll5_tun2; /* 0x3c pll5 tuning2 */
- u8 res3[0xc];
- u32 pll_lock_dbg; /* 0x4c pll lock time debug */
- u32 osc24m_cfg; /* 0x50 osc24m control */
- u32 cpu_ahb_apb0_cfg; /* 0x54 CPU, ahb and apb0 divide ratio */
- u32 apb1_clk_div_cfg; /* 0x58 apb1 clock dividor */
- u32 axi_gate; /* 0x5c axi module clock gating */
- u32 ahb_gate0; /* 0x60 ahb module clock gating 0 */
- u32 ahb_gate1; /* 0x64 ahb module clock gating 1 */
- u32 apb0_gate; /* 0x68 apb0 module clock gating */
- u32 apb1_gate; /* 0x6c apb1 module clock gating */
- u8 res4[0x10];
- u32 nand_sclk_cfg; /* 0x80 nand sub clock control */
- u32 ms_sclk_cfg; /* 0x84 memory stick sub clock control */
- u32 sd0_clk_cfg; /* 0x88 sd0 clock control */
- u32 sd1_clk_cfg; /* 0x8c sd1 clock control */
- u32 sd2_clk_cfg; /* 0x90 sd2 clock control */
- u32 sd3_clk_cfg; /* 0x94 sd3 clock control */
- u32 ts_clk_cfg; /* 0x98 transport stream clock control */
- u32 ss_clk_cfg; /* 0x9c */
- u32 spi0_clk_cfg; /* 0xa0 */
- u32 spi1_clk_cfg; /* 0xa4 */
- u32 spi2_clk_cfg; /* 0xa8 */
- u32 pata_clk_cfg; /* 0xac */
- u32 ir0_clk_cfg; /* 0xb0 */
- u32 ir1_clk_cfg; /* 0xb4 */
- u32 iis_clk_cfg; /* 0xb8 */
- u32 ac97_clk_cfg; /* 0xbc */
- u32 spdif_clk_cfg; /* 0xc0 */
- u32 keypad_clk_cfg; /* 0xc4 */
- u32 sata_clk_cfg; /* 0xc8 */
- u32 usb_clk_cfg; /* 0xcc */
- u32 gps_clk_cfg; /* 0xd0 */
- u32 spi3_clk_cfg; /* 0xd4 */
- u8 res5[0x28];
- u32 dram_clk_cfg; /* 0x100 */
- u32 be0_clk_cfg; /* 0x104 */
- u32 be1_clk_cfg; /* 0x108 */
- u32 fe0_clk_cfg; /* 0x10c */
- u32 fe1_clk_cfg; /* 0x110 */
- u32 mp_clk_cfg; /* 0x114 */
- u32 lcd0_ch0_clk_cfg; /* 0x118 */
- u32 lcd1_ch0_clk_cfg; /* 0x11c */
- u32 csi_isp_clk_cfg; /* 0x120 */
- u8 res6[0x4];
- u32 tvd_clk_reg; /* 0x128 */
- u32 lcd0_ch1_clk_cfg; /* 0x12c */
- u32 lcd1_ch1_clk_cfg; /* 0x130 */
- u32 csi0_clk_cfg; /* 0x134 */
- u32 csi1_clk_cfg; /* 0x138 */
- u32 ve_clk_cfg; /* 0x13c */
- u32 audio_codec_clk_cfg; /* 0x140 */
- u32 avs_clk_cfg; /* 0x144 */
- u32 ace_clk_cfg; /* 0x148 */
- u32 lvds_clk_cfg; /* 0x14c */
- u32 hdmi_clk_cfg; /* 0x150 */
- u32 mali_clk_cfg; /* 0x154 */
- u8 res7[0x4];
- u32 mbus_clk_cfg; /* 0x15c */
-} __packed;
-
-void a1x_periph_clock_enable(enum a1x_clken periph);
-void a1x_periph_clock_disable(enum a1x_clken periph);
-
-void a1x_pll5_configure(u8 mul_n, u8 mul_k, u8 div_m, u8 exp_div_p);
-void a1x_pll5_enable_dram_clock_output(void);
-void a1x_ungate_dram_clock_output(void);
-void a1x_gate_dram_clock_output(void);
-
-/* Not available in bootblock */
-void a1x_set_cpu_clock(u16 cpu_clk_mhz);
-
-#endif /* CPU_ALLWINNER_A10_CLOCK_H */
diff --git a/src/cpu/allwinner/a10/cpu.c b/src/cpu/allwinner/a10/cpu.c
deleted file mode 100644
index 09f67662bf..0000000000
--- a/src/cpu/allwinner/a10/cpu.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2014 Alexandru Gagniuc
- *
- * 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; version 2 of the License or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * Ramstage initialization for Allwinner CPUs
- *
- */
-
-#include
-#include
-
-static void cpu_enable_resources(struct device *dev)
-{
- ram_resource(dev, 0, (uintptr_t)_dram/KiB,
- CONFIG_DRAM_SIZE_MB << 10);
- /* TODO: Declare CBFS cache as reserved? There's no guarantee we won't
- * overwrite it. It seems to stay intact, being so high in RAM
- */
-}
-
-static void cpu_init(struct device *dev)
-{
- /* TODO: Check if anything else needs to be explicitly initialized */
-}
-
-static struct device_operations cpu_ops = {
- .read_resources = DEVICE_NOOP,
- .set_resources = DEVICE_NOOP,
- .enable_resources = cpu_enable_resources,
- .init = cpu_init,
- .scan_bus = NULL,
-};
-
-static void a1x_cpu_enable_dev(struct device *dev)
-{
- dev->ops = &cpu_ops;
-}
-
-struct chip_operations cpu_allwinner_a10_ops = {
- CHIP_NAME("CPU Allwinner A10")
- .enable_dev = a1x_cpu_enable_dev,
-};
diff --git a/src/cpu/allwinner/a10/dramc.h b/src/cpu/allwinner/a10/dramc.h
deleted file mode 100644
index fe50acda69..0000000000
--- a/src/cpu/allwinner/a10/dramc.h
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2007-2012 Allwinner Technology Co., Ltd.
- * Berg Xing
- * Tom Cubie
- * Copyright (C) 2013 Alexandru Gagniuc
- *
- * 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; version 2 of the License.or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * Allwinner A10 platform dram register definition.
- *
- * Based on sun4i Linux kernel sources mach-sunxi/pm/standby/dram*.c
- * and earlier U-Boot Allwiner A10 SPL work
- */
-
-#ifndef CPU_ALLWINNER_A10_DRAMC_H
-#define CPU_ALLWINNER_A10_DRAMC_H
-
-#include
-
-#define DRAM_CCR_COMMAND_RATE_1T (0x1 << 5)
-#define DRAM_CCR_DQS_GATE (0x1 << 14)
-#define DRAM_CCR_DQS_DRIFT_COMP (0x1 << 17)
-#define DRAM_CCR_ITM_OFF (0x1 << 28)
-#define DRAM_CCR_DATA_TRAINING (0x1 << 30)
-#define DRAM_CCR_INIT (0x1 << 31)
-
-#define DRAM_MEMORY_TYPE_DDR1 1
-#define DRAM_MEMORY_TYPE_DDR2 2
-#define DRAM_MEMORY_TYPE_DDR3 3
-#define DRAM_MEMORY_TYPE_LPDDR2 4
-#define DRAM_MEMORY_TYPE_LPDDR 5
-#define DRAM_DCR_TYPE (0x1 << 0)
-#define DRAM_DCR_TYPE_DDR2 0x0
-#define DRAM_DCR_TYPE_DDR3 0x1
-#define DRAM_DCR_IO_WIDTH(n) (((n) & 0x3) << 1)
-#define DRAM_DCR_IO_WIDTH_MASK DRAM_DCR_IO_WIDTH(0x3)
-#define DRAM_DCR_IO_WIDTH_8BIT 0x0
-#define DRAM_DCR_IO_WIDTH_16BIT 0x1
-#define DRAM_DCR_CHIP_DENSITY(n) (((n) & 0x7) << 3)
-#define DRAM_DCR_CHIP_DENSITY_MASK DRAM_DCR_CHIP_DENSITY(0x7)
-#define DRAM_DCR_CHIP_DENSITY_256M 0x0
-#define DRAM_DCR_CHIP_DENSITY_512M 0x1
-#define DRAM_DCR_CHIP_DENSITY_1024M 0x2
-#define DRAM_DCR_CHIP_DENSITY_2048M 0x3
-#define DRAM_DCR_CHIP_DENSITY_4096M 0x4
-#define DRAM_DCR_CHIP_DENSITY_8192M 0x5
-#define DRAM_DCR_BUS_WIDTH(n) (((n) & 0x7) << 6)
-#define DRAM_DCR_BUS_WIDTH_MASK DRAM_DCR_BUS_WIDTH(0x7)
-#define DRAM_DCR_BUS_WIDTH_32BIT 0x3
-#define DRAM_DCR_BUS_WIDTH_16BIT 0x1
-#define DRAM_DCR_BUS_WIDTH_8BIT 0x0
-#define DRAM_DCR_NR_DLLCR_32BIT 5
-#define DRAM_DCR_NR_DLLCR_16BIT 3
-#define DRAM_DCR_NR_DLLCR_8BIT 2
-#define DRAM_DCR_RANK_SEL(n) (((n) & 0x3) << 10)
-#define DRAM_DCR_RANK_SEL_MASK DRAM_DCR_CMD_RANK(0x3)
-#define DRAM_DCR_CMD_RANK_ALL (0x1 << 12)
-#define DRAM_DCR_MODE(n) (((n) & 0x3) << 13)
-#define DRAM_DCR_MODE_MASK DRAM_DCR_MODE(0x3)
-#define DRAM_DCR_MODE_SEQ 0x0
-#define DRAM_DCR_MODE_INTERLEAVE 0x1
-
-#define DRAM_CSR_FAILED (0x1 << 20)
-
-#define DRAM_MCR_MODE_NORM(n) (((n) & 0x3) << 0)
-#define DRAM_MCR_MODE_NORM_MASK DRAM_MCR_MOD_NORM(0x3)
-#define DRAM_MCR_MODE_DQ_OUT(n) (((n) & 0x3) << 2)
-#define DRAM_MCR_MODE_DQ_OUT_MASK DRAM_MCR_MODE_DQ_OUT(0x3)
-#define DRAM_MCR_MODE_ADDR_OUT(n) (((n) & 0x3) << 4)
-#define DRAM_MCR_MODE_ADDR_OUT_MASK DRAM_MCR_MODE_ADDR_OUT(0x3)
-#define DRAM_MCR_MODE_DQ_IN_OUT(n) (((n) & 0x3) << 6)
-#define DRAM_MCR_MODE_DQ_IN_OUT_MASK DRAM_MCR_MODE_DQ_IN_OUT(0x3)
-#define DRAM_MCR_MODE_DQ_TURNON_DELAY(n) (((n) & 0x7) << 8)
-#define DRAM_MCR_MODE_DQ_TURNON_DELAY_MASK DRAM_MCR_MODE_DQ_TURNON_DELAY(0x7)
-#define DRAM_MCR_MODE_ADDR_IN (0x1 << 11)
-#define DRAM_MCR_RESET (0x1 << 12)
-#define DRAM_MCR_MODE_EN(n) (((n) & 0x3) << 13)
-#define DRAM_MCR_MODE_EN_MASK DRAM_MCR_MOD_EN(0x3)
-#define DRAM_MCR_DCLK_OUT (0x1 << 16)
-
-#define DRAM_DLLCR_NRESET (0x1 << 30)
-#define DRAM_DLLCR_DISABLE (0x1 << 31)
-
-#define DRAM_ZQCR0_IMP_DIV(n) (((n) & 0xff) << 20)
-#define DRAM_ZQCR0_IMP_DIV_MASK DRAM_ZQCR0_IMP_DIV(0xff)
-
-#define DRAM_IOCR_ODT_EN(n) ((((n) & 0x3) << 30) | ((n) & 0x3) << 0)
-#define DRAM_IOCR_ODT_EN_MASK DRAM_IOCR_ODT_EN(0x3)
-
-#define DRAM_MR_BURST_LENGTH(n) (((n) & 0x7) << 0)
-#define DRAM_MR_BURST_LENGTH_MASK DRAM_MR_BURST_LENGTH(0x7)
-#define DRAM_MR_CAS_LAT(n) (((n) & 0x7) << 4)
-#define DRAM_MR_CAS_LAT_MASK DRAM_MR_CAS_LAT(0x7)
-#define DRAM_MR_WRITE_RECOVERY(n) (((n) & 0x7) << 9)
-#define DRAM_MR_WRITE_RECOVERY_MASK DRAM_MR_WRITE_RECOVERY(0x7)
-#define DRAM_MR_POWER_DOWN (0x1 << 12)
-
-#define DRAM_CSEL_MAGIC 0x16237495
-
-struct a1x_dramc {
- u32 ccr; /* 0x00 controller configuration register */
- u32 dcr; /* 0x04 dram configuration register */
- u32 iocr; /* 0x08 i/o configuration register */
- u32 csr; /* 0x0c controller status register */
- u32 drr; /* 0x10 dram refresh register */
- u32 tpr0; /* 0x14 dram timing parameters register 0 */
- u32 tpr1; /* 0x18 dram timing parameters register 1 */
- u32 tpr2; /* 0x1c dram timing parameters register 2 */
- u32 gdllcr; /* 0x20 global dll control register */
- u8 res0[0x28];
- u32 rslr0; /* 0x4c rank system latency register */
- u32 rslr1; /* 0x50 rank system latency register */
- u8 res1[0x8];
- u32 rdgr0; /* 0x5c rank dqs gating register */
- u32 rdgr1; /* 0x60 rank dqs gating register */
- u8 res2[0x34];
- u32 odtcr; /* 0x98 odt configuration register */
- u32 dtr0; /* 0x9c data training register 0 */
- u32 dtr1; /* 0xa0 data training register 1 */
- u32 dtar; /* 0xa4 data training address register */
- u32 zqcr0; /* 0xa8 zq control register 0 */
- u32 zqcr1; /* 0xac zq control register 1 */
- u32 zqsr; /* 0xb0 zq status register */
- u32 idcr; /* 0xb4 initializaton delay configure reg */
- u8 res3[0x138];
- u32 mr; /* 0x1f0 mode register */
- u32 emr; /* 0x1f4 extended mode register */
- u32 emr2; /* 0x1f8 extended mode register */
- u32 emr3; /* 0x1fc extended mode register */
- u32 dllctr; /* 0x200 dll control register */
- u32 dllcr[5]; /* 0x204 dll control register 0(byte 0) */
- /* 0x208 dll control register 1(byte 1) */
- /* 0x20c dll control register 2(byte 2) */
- /* 0x210 dll control register 3(byte 3) */
- /* 0x214 dll control register 4(byte 4) */
- u32 dqtr0; /* 0x218 dq timing register */
- u32 dqtr1; /* 0x21c dq timing register */
- u32 dqtr2; /* 0x220 dq timing register */
- u32 dqtr3; /* 0x224 dq timing register */
- u32 dqstr; /* 0x228 dqs timing register */
- u32 dqsbtr; /* 0x22c dqsb timing register */
- u32 mcr; /* 0x230 mode configure register */
- u8 res[0x8];
- u32 ppwrsctl; /* 0x23c pad power save control */
- u32 apr; /* 0x240 arbiter period register */
- u32 pldtr; /* 0x244 priority level data threshold reg */
- u8 res5[0x8];
- u32 hpcr[32]; /* 0x250 host port configure register */
- u8 res6[0x10];
- u32 csel; /* 0x2e0 controller select register */
-};
-
-struct dram_para {
- u32 clock;
- u32 type;
- u32 rank_num;
- u32 density;
- u32 io_width;
- u32 bus_width;
- u32 cas;
- u32 zq;
- u32 odt_en;
- u32 size;
- u32 tpr0;
- u32 tpr1;
- u32 tpr2;
- u32 tpr3;
- u32 tpr4;
- u32 tpr5;
- u32 emr1;
- u32 emr2;
- u32 emr3;
-};
-
-unsigned long dramc_init(struct dram_para *para);
-
-#endif /* CPU_ALLWINNER_A10_DRAMC_H */
diff --git a/src/cpu/allwinner/a10/gpio.c b/src/cpu/allwinner/a10/gpio.c
deleted file mode 100644
index 7f6bbd8549..0000000000
--- a/src/cpu/allwinner/a10/gpio.c
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2013 Alexandru Gagniuc
- *
- * 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; version 2 of the License or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * Basic GPIO helpers for Allwinner CPUs
- */
-
-#include "gpio.h"
-
-#include
-
-static struct a10_gpio *const gpio = (void *)GPIO_BASE;
-
-/**
- * \brief Set a single output pin
- *
- * @param[in] port GPIO port of the pin (GPA -> GPS)
- * @param[in] pin the pin number in the given port (1 -> 31)
- */
-void gpio_set(u8 port, u8 pin)
-{
- u32 reg32;
-
- if ((port > GPS))
- return;
-
- reg32 = gpio_read(port);
- reg32 |= (1 << pin);
- gpio_write(port, reg32);
-}
-
-/**
- * \brief Clear a single output pin
- *
- * @param[in] port GPIO port of the pin (GPA -> GPS)
- * @param[in] pin the pin number in the given port (1 -> 31)
- */
-void gpio_clear(u8 port, u8 pin)
-{
- u32 reg32;
- if ((port > GPS))
- return;
-
- reg32 = gpio_read(port);
- reg32 &= ~(1 << pin);
- gpio_write(port, reg32);
-}
-
-/**
- * \brief Get the status of a single input pin
- *
- * @param[in] port GPIO port of the pin (GPA -> GPS)
- * @param[in] pin the pin number in the given port (1 -> 31)
- * @return 1 if the pin is high, or 0 if the pin is low
- */
-int gpio_get(u8 port, u8 pin)
-{
- if ((port > GPS))
- return 0;
-
- return (gpio_read(port) & (1 << pin)) ? 1 : 0;
-}
-
-/**
- * \brief Write to a GPIO port
- *
- * Write the state of all output pins in the GPIO port. This only affects pins
- * configured as output pins.
- *
- * @param[in] port GPIO port of the pin (GPA -> GPS)
- * @param[in] val 32-bit mask indicating which pins to set. For a set bit, the
- * corresponding pin will be set. Otherwise, it will be cleared
- */
-void gpio_write(u8 port, u32 val)
-{
- if ((port > GPS))
- return;
-
- write32(&gpio->port[port].dat, val);
-}
-
-/**
- * \brief Write to a GPIO port
- *
- * Read the state of all input pins in the GPIO port.
- *
- * @param[in] port GPIO port of the pin (GPA -> GPS)
- * @return 32-bit mask indicating which pins are high. For each set bit, the
- * corresponding pin is high. The value of bits corresponding to pins
- * which are not configured as inputs is undefined.
- */
-u32 gpio_read(u8 port)
-{
- if ((port > GPS))
- return 0;
-
- return read32(&gpio->port[port].dat);
-}
diff --git a/src/cpu/allwinner/a10/gpio.h b/src/cpu/allwinner/a10/gpio.h
deleted file mode 100644
index c05122fea6..0000000000
--- a/src/cpu/allwinner/a10/gpio.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2013 Alexandru Gagniuc
- *
- * 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; version 2 of the License or (at your option)
- * any later version.
- *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * Definitions for GPIO and pin multiplexing on Allwinner CPUs
- */
-
-#ifndef __CPU_ALLWINNER_A10_PINMUX_H
-#define __CPU_ALLWINNER_A10_PINMUX_H
-
-#include
-
-#define GPIO_BASE 0x01C20800
-
-#define GPA 0
-#define GPB 1
-#define GPC 2
-#define GPD 3
-#define GPE 4
-#define GPF 5
-#define GPG 6
-#define GPH 7
-#define GPI 8
-#define GPS 9
-
-/* GPIO pad functions valid for all pins */
-#define GPIO_PIN_FUNC_INPUT 0
-#define GPIO_PIN_FUNC_OUTPUT 1
-
-struct a10_gpio_port {
- u32 cfg[4];
- u32 dat;
- u32 drv[2];
- u32 pul[2];
-} __packed;
-
-struct a10_gpio {
- struct a10_gpio_port port[10];
- u8 reserved_0x168[0x98];
-
- /* Offset 0x200 */
- u32 int_cfg[4];
-
- u32 int_ctl;
- u32 int_sta;
- u8 reserved_0x21C[4];
- u32 int_deb;
-
- u32 sdr_pad_drv;
- u32 sdr_pad_pul;
-} __packed;
-
-/* gpio.c */
-void gpio_set(u8 port, u8 pin);
-void gpio_clear(u8 port, u8 pin);
-int gpio_get(u8 port, u8 pin);
-void gpio_write(u8 port, u32 val);
-u32 gpio_read(u8 port);
-
-/* pinmux.c */
-void gpio_set_pin_func(u8 port, u8 pin, u8 pad_func);
-void gpio_set_multipin_func(u8 port, u32 pin_mask, u8 pad_func);
-
-#endif /* __CPU_ALLWINNER_A10_PINMUX_H */
diff --git a/src/cpu/allwinner/a10/memmap.h b/src/cpu/allwinner/a10/memmap.h
deleted file mode 100644
index 2c02ec87f0..0000000000
--- a/src/cpu/allwinner/a10/memmap.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2007-2011 Allwinner Technology Co., Ltd.
- * Tom Cubie
- * Copyright (C) 2013 Alexandru Gagniuc
- *
- * 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; version 2 of the License or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * Memory map definitions for Allwinner A10 CPUs
- */
-
-#ifndef CPU_ALLWINNER_A10_MEMMAP_H
-#define CPU_ALLWINNER_A10_MEMMAP_H
-
-#define A1X_SRAM_A1_BASE 0x00000000
-#define A1X_SRAM_A1_SIZE (16 * 1024) /* 16 kiB */
-
-#define A1X_SRAM_A2_BASE 0x00004000 /* 16 kiB */
-#define A1X_SRAM_A3_BASE 0x00008000 /* 13 kiB */
-#define A1X_SRAM_A4_BASE 0x0000b400 /* 3 kiB */
-#define A1X_SRAM_D_BASE 0x01c00000
-#define A1X_SRAM_B_BASE 0x01c00000 /* 64 kiB (secure) */
-
-#define A1X_SRAMC_BASE 0x01c00000
-#define A1X_DRAMC_BASE 0x01c01000
-#define A1X_DMA_BASE 0x01c02000
-#define A1X_NFC_BASE 0x01c03000
-#define A1X_TS_BASE 0x01c04000
-#define A1X_SPI0_BASE 0x01c05000
-#define A1X_SPI1_BASE 0x01c06000
-#define A1X_MS_BASE 0x01c07000
-#define A1X_TVD_BASE 0x01c08000
-#define A1X_CSI0_BASE 0x01c09000
-#define A1X_TVE0_BASE 0x01c0a000
-#define A1X_EMAC_BASE 0x01c0b000
-#define A1X_LCD0_BASE 0x01c0C000
-#define A1X_LCD1_BASE 0x01c0d000
-#define A1X_VE_BASE 0x01c0e000
-#define A1X_MMC0_BASE 0x01c0f000
-#define A1X_MMC1_BASE 0x01c10000
-#define A1X_MMC2_BASE 0x01c11000
-#define A1X_MMC3_BASE 0x01c12000
-#define A1X_USB0_BASE 0x01c13000
-#define A1X_USB1_BASE 0x01c14000
-#define A1X_SS_BASE 0x01c15000
-#define A1X_HDMI_BASE 0x01c16000
-#define A1X_SPI2_BASE 0x01c17000
-#define A1X_SATA_BASE 0x01c18000
-#define A1X_PATA_BASE 0x01c19000
-#define A1X_ACE_BASE 0x01c1a000
-#define A1X_TVE1_BASE 0x01c1b000
-#define A1X_USB2_BASE 0x01c1c000
-#define A1X_CSI1_BASE 0x01c1d000
-#define A1X_TZASC_BASE 0x01c1e000
-#define A1X_SPI3_BASE 0x01c1f000
-
-#define A1X_CCM_BASE 0x01c20000
-#define A1X_INTC_BASE 0x01c20400
-#define A1X_PIO_BASE 0x01c20800
-#define A1X_TIMER_BASE 0x01c20c00
-#define A1X_SPDIF_BASE 0x01c21000
-#define A1X_AC97_BASE 0x01c21400
-#define A1X_IR0_BASE 0x01c21800
-#define A1X_IR1_BASE 0x01c21c00
-
-#define A1X_IIS_BASE 0x01c22400
-#define A1X_LRADC_BASE 0x01c22800
-#define A1X_AD_DA_BASE 0x01c22c00
-#define A1X_KEYPAD_BASE 0x01c23000
-#define A1X_TZPC_BASE 0x01c23400
-#define A1X_SID_BASE 0x01c23800
-#define A1X_SJTAG_BASE 0x01c23c00
-
-#define A1X_TP_BASE 0x01c25000
-#define A1X_PMU_BASE 0x01c25400
-#define A1X_CPUCFG_BASE 0x01c25c00 /* sun7i only ? */
-
-#define A1X_UART0_BASE 0x01c28000
-#define A1X_UART1_BASE 0x01c28400
-#define A1X_UART2_BASE 0x01c28800
-#define A1X_UART3_BASE 0x01c28c00
-#define A1X_UART4_BASE 0x01c29000
-#define A1X_UART5_BASE 0x01c29400
-#define A1X_UART6_BASE 0x01c29800
-#define A1X_UART7_BASE 0x01c29c00
-#define A1X_PS2_0_BASE 0x01c2a000
-#define A1X_PS2_1_BASE 0x01c2a400
-
-#define A1X_TWI0_BASE 0x01c2ac00
-#define A1X_TWI1_BASE 0x01c2b000
-#define A1X_TWI2_BASE 0x01c2b400
-
-#define A1X_CAN_BASE 0x01c2bc00
-
-#define A1X_SCR_BASE 0x01c2c400
-
-#define A1X_GPS_BASE 0x01c30000
-#define A1X_MALI400_BASE 0x01c40000
-
-/* module sram */
-#define A1X_SRAM_C_BASE 0x01d00000
-
-#define A1X_DE_FE0_BASE 0x01e00000
-#define A1X_DE_FE1_BASE 0x01e20000
-#define A1X_DE_BE0_BASE 0x01e60000
-#define A1X_DE_BE1_BASE 0x01e40000
-#define A1X_MP_BASE 0x01e80000
-#define A1X_AVG_BASE 0x01ea0000
-
-/* CoreSight Debug Module */
-#define A1X_CSDM_BASE 0x3f500000
-
-#define A1X_DRAM_BASE 0x40000000 /* 2 GiB */
-
-#define A1X_BROM_BASE 0xffff0000 /* 32 kiB */
-
-#define A1X_CPU_CFG (A1X_TIMER_BASE + 0x13c)
-
-#endif /* CPU_ALLWINNER_A10_MEMMAP_H */
diff --git a/src/cpu/allwinner/a10/pinmux.c b/src/cpu/allwinner/a10/pinmux.c
deleted file mode 100644
index 3415e4fed5..0000000000
--- a/src/cpu/allwinner/a10/pinmux.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2013 Alexandru Gagniuc
- *
- * 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; version 2 of the License or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- *
- * Helpers to multiplex and configure pins on Allwinner SoCs
- *
- */
-
-#include "gpio.h"
-
-#include
-
-static struct a10_gpio *const gpio = (void *)GPIO_BASE;
-
-/**
- * \brief Set the pad function of a single pin
- *
- * @param[in] port GPIO port of the pin (GPA -> GPS)
- * @param[in] pin the pin number in the given port (1 -> 31)
- * @param[in] pad_func The peripheral function to which to connect this pin
- */
-void gpio_set_pin_func(u8 port, u8 pin, u8 pad_func)
-{
- u8 reg, bit;
- u32 reg32;
-
- if ((port > GPS))
- return;
-
- pin &= 0x1f;
- reg = pin / 8;
- bit = (pin % 8) * 4;
-
- reg32 = read32(&gpio->port[port].cfg[reg]);
- reg32 &= ~(0xf << bit);
- reg32 |= (pad_func & 0xf) << bit;
- write32(&gpio->port[port].cfg[reg], reg32);
-}
-
-/**
- * \brief Set the pad function of a group of pins
- *
- * Multiplex a group of pins to the same pad function. This is useful for
- * peripherals that use the same function number for several pins. This function
- * allows those pins to be set with a single call.
- *
- * Example:
- * gpio_set_multipin_func(GPB, (1 << 23) | (1 << 22), 2);
- *
- * @param[in] port GPIO port of the pin (GPA -> GPS)
- * @param[in] pin_mask 32-bit mask indicating which pins to re-multiplex. For
- * each set bit, the corresponding pin will be multiplexed.
- * @param[in] pad_func The peripheral function to which to connect the pins
- */
-void gpio_set_multipin_func(u8 port, u32 pin_mask, u8 pad_func)
-{
- int j;
- u8 reg, bit;
- u32 reg32, mask_offset;
-
- if ((port > GPS))
- return;
-
- for (reg = 0; reg < 4; reg++) {
- mask_offset = 8 * reg;
- /* Don't run the inner loop if we're not touching any pins */
- if (!(pin_mask & (0xff << mask_offset)))
- continue;
-
- reg32 = read32(&gpio->port[port].cfg[reg]);
- for (j = 0; j < 8; j++) {
- if (!(pin_mask & (1 << (j + mask_offset))))
- continue;
- bit = j * 4;
- reg32 &= ~(0xf << bit);
- reg32 |= (pad_func & 0xf) << bit;
- }
- write32(&gpio->port[port].cfg[reg], reg32);
- }
-}
diff --git a/src/cpu/allwinner/a10/ram_segs.h b/src/cpu/allwinner/a10/ram_segs.h
deleted file mode 100644
index fa915cd203..0000000000
--- a/src/cpu/allwinner/a10/ram_segs.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2014 Alexandru Gagniuc
- *
- * 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; version 2 of the License or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- *
- * How we use DRAM on Allwinner CPUs
- */
-
-#include
-
-/*
- * Put CBMEM at top of RAM
- */
-static inline void *a1x_get_cbmem_top(void)
-{
- return _dram + (CONFIG_DRAM_SIZE_MB << 20);
-}
-
-/*
- * By CBFS cache, we mean a cached copy, in RAM, of the entire CBFS region.
- */
-static inline void *a1x_get_cbfs_cache_top(void)
-{
- /* Arbitrary 16 MiB gap for cbmem tables and bouncebuffer */
- return a1x_get_cbmem_top() - (16 << 20);
-}
-
-static inline void *a1x_get_cbfs_cache_base(void)
-{
- return a1x_get_cbfs_cache_top() - CONFIG_ROM_SIZE;
-}
diff --git a/src/cpu/allwinner/a10/raminit.c b/src/cpu/allwinner/a10/raminit.c
deleted file mode 100644
index 3c18183a6b..0000000000
--- a/src/cpu/allwinner/a10/raminit.c
+++ /dev/null
@@ -1,478 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2012 Henrik Nordstrom
- * Copyright (C) 2013 Luke Kenneth Casson Leighton
- * Copyright (C) 2007-2012 Allwinner Technology Co., Ltd.
- * Berg Xing
- * Tom Cubie
- * Copyright (C) 2013 Alexandru Gagniuc
- *
- * 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; version 2 of the License or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * Allwinner A10 DRAM controller initialization
- *
- * Based on sun4i Linux kernel sources mach-sunxi/pm/standby/dram*.c
- * and earlier U-Boot Allwiner A10 SPL work
- */
-
-#include "clock.h"
-#include "dramc.h"
-#include "memmap.h"
-#include "timer.h"
-
-#include
-#include
-
-static struct a1x_dramc *const dram = (void *)A1X_DRAMC_BASE;
-
-static void mctl_ddr3_reset(void)
-{
- if (a1x_get_cpu_chip_revision() != A1X_CHIP_REV_A) {
- setbits_le32(&dram->mcr, DRAM_MCR_RESET);
- udelay(2);
- clrbits_le32(&dram->mcr, DRAM_MCR_RESET);
- } else {
- clrbits_le32(&dram->mcr, DRAM_MCR_RESET);
- udelay(2);
- setbits_le32(&dram->mcr, DRAM_MCR_RESET);
- }
-}
-
-static void mctl_set_drive(void)
-{
- clrsetbits_le32(&dram->mcr, DRAM_MCR_MODE_NORM(0x3),
- DRAM_MCR_MODE_EN(0x3) | 0xffc);
-}
-
-static void mctl_itm_disable(void)
-{
- clrsetbits_le32(&dram->ccr, DRAM_CCR_INIT, DRAM_CCR_ITM_OFF);
-}
-
-static void mctl_itm_enable(void)
-{
- clrbits_le32(&dram->ccr, DRAM_CCR_ITM_OFF);
-}
-
-static void mctl_enable_dll0(u32 phase)
-{
- clrsetbits_le32(&dram->dllcr[0], 0x3f << 6,
- ((phase >> 16) & 0x3f) << 6);
- clrsetbits_le32(&dram->dllcr[0], DRAM_DLLCR_NRESET, DRAM_DLLCR_DISABLE);
- udelay(2);
-
- clrbits_le32(&dram->dllcr[0], DRAM_DLLCR_NRESET | DRAM_DLLCR_DISABLE);
- udelay(22);
-
- clrsetbits_le32(&dram->dllcr[0], DRAM_DLLCR_DISABLE, DRAM_DLLCR_NRESET);
- udelay(22);
-}
-
-/*
- * Note: This differs from pm/standby in that it checks the bus width
- */
-static void mctl_enable_dllx(u32 phase)
-{
- u32 i, n, bus_width;
-
- bus_width = read32(&dram->dcr);
-
- if ((bus_width & DRAM_DCR_BUS_WIDTH_MASK) ==
- DRAM_DCR_BUS_WIDTH(DRAM_DCR_BUS_WIDTH_32BIT))
- n = DRAM_DCR_NR_DLLCR_32BIT;
- else
- n = DRAM_DCR_NR_DLLCR_16BIT;
-
- for (i = 1; i < n; i++) {
- clrsetbits_le32(&dram->dllcr[i], 0x4 << 14,
- (phase & 0xf) << 14);
- clrsetbits_le32(&dram->dllcr[i], DRAM_DLLCR_NRESET,
- DRAM_DLLCR_DISABLE);
- phase >>= 4;
- }
- udelay(2);
-
- for (i = 1; i < n; i++)
- clrbits_le32(&dram->dllcr[i], DRAM_DLLCR_NRESET |
- DRAM_DLLCR_DISABLE);
- udelay(22);
-
- for (i = 1; i < n; i++)
- clrsetbits_le32(&dram->dllcr[i], DRAM_DLLCR_DISABLE,
- DRAM_DLLCR_NRESET);
- udelay(22);
-}
-
-static u32 hpcr_value[32] = {
- 0x0301, 0x0301, 0x0301, 0x0301,
- 0x0301, 0x0301, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0x1031, 0x1031, 0x0735, 0x1035,
- 0x1035, 0x0731, 0x1031, 0x0735,
- 0x1035, 0x1031, 0x0731, 0x1035,
- 0x1031, 0x0301, 0x0301, 0x0731
-};
-
-static void mctl_configure_hostport(void)
-{
- u32 i;
-
- for (i = 0; i < 32; i++)
- write32(&dram->hpcr[i], hpcr_value[i]);
-}
-
-static void mctl_setup_dram_clock(u32 clk)
-{
- /* setup DRAM PLL */
- a1x_pll5_configure(clk / 24, 2, 2, 1);
-
- /* FIXME: This bit is not documented for A10, and altering it doesn't
- * seem to change anything.
- *
- * #define CCM_PLL5_CTRL_VCO_GAIN (0x1 << 19)
- * reg_val = read32(&ccm->pll5_cfg);
- * reg_val &= ~CCM_PLL5_CTRL_VCO_GAIN; // PLL VCO Gain off
- * write32(reg_val, &ccm->pll5_cfg);
- */
- udelay(5500);
-
- a1x_pll5_enable_dram_clock_output();
-
- /* reset GPS */
- /* FIXME: These bits are also undocumented, and seem to have no effect
- * on A10.
- *
- * #define CCM_GPS_CTRL_RESET (0x1 << 0)
- * #define CCM_GPS_CTRL_GATE (0x1 << 1)
- * clrbits_le32(&ccm->gps_clk_cfg, CCM_GPS_CTRL_RESET | CCM_GPS_CTRL_GATE);
- */
- a1x_periph_clock_enable(A1X_CLKEN_GPS);
- udelay(1);
- a1x_periph_clock_disable(A1X_CLKEN_GPS);
-
- /* setup MBUS clock */
- /* FIXME: The MBUS does not seem to be present or do anything on A10. It
- * is documented in the A13 user manual, but changing settings on A10
- * has no effect.
- *
- * #define CCM_MBUS_CTRL_M(n) (((n) & 0xf) << 0)
- * #define CCM_MBUS_CTRL_M_MASK CCM_MBUS_CTRL_M(0xf)
- * #define CCM_MBUS_CTRL_M_X(n) ((n) - 1)
- * #define CCM_MBUS_CTRL_N(n) (((n) & 0xf) << 16)
- * #define CCM_MBUS_CTRL_N_MASK CCM_MBUS_CTRL_N(0xf)
- * #define CCM_MBUS_CTRL_N_X(n) (((n) >> 3) ? 3 : (((n) >> 2) ? 2 : (((n) >> 1) ? 1 : 0)))
- * #define CCM_MBUS_CTRL_CLK_SRC(n) (((n) & 0x3) << 24)
- * #define CCM_MBUS_CTRL_CLK_SRC_MASK CCM_MBUS_CTRL_CLK_SRC(0x3)
- * #define CCM_MBUS_CTRL_CLK_SRC_HOSC 0x0
- * #define CCM_MBUS_CTRL_CLK_SRC_PLL6 0x1
- * #define CCM_MBUS_CTRL_CLK_SRC_PLL5 0x2
- * #define CCM_MBUS_CTRL_GATE (0x1 << 31)
- * reg_val = CCM_MBUS_CTRL_GATE |
- * CCM_MBUS_CTRL_CLK_SRC(CCM_MBUS_CTRL_CLK_SRC_PLL5) |
- * CCM_MBUS_CTRL_N(CCM_MBUS_CTRL_N_X(1)) |
- * CCM_MBUS_CTRL_M(CCM_MBUS_CTRL_M_X(2));
- * write32(reg_val, &ccm->mbus_clk_cfg);
- */
- /*
- * open DRAMC AHB & DLL register clock
- * close it first
- */
- a1x_periph_clock_disable(A1X_CLKEN_SDRAM);
-
- udelay(22);
-
- /* then open it */
- a1x_periph_clock_enable(A1X_CLKEN_SDRAM);
- udelay(22);
-}
-
-static int dramc_scan_readpipe(void)
-{
- u32 reg32;
-
- /* data training trigger */
- setbits_le32(&dram->ccr, DRAM_CCR_DATA_TRAINING);
-
- /* check whether data training process has completed */
- while (read32(&dram->ccr) & DRAM_CCR_DATA_TRAINING);
-
- /* check data training result */
- reg32 = read32(&dram->csr);
- if (reg32 & DRAM_CSR_FAILED)
- return -1;
-
- return 0;
-}
-
-static int dramc_scan_dll_para(void)
-{
- const u32 dqs_dly[7] = { 0x3, 0x2, 0x1, 0x0, 0xe, 0xd, 0xc };
- const u32 clk_dly[15] = { 0x07, 0x06, 0x05, 0x04, 0x03,
- 0x02, 0x01, 0x00, 0x08, 0x10,
- 0x18, 0x20, 0x28, 0x30, 0x38
- };
- u32 clk_dqs_count[15];
- u32 dqs_i, clk_i, cr_i;
- u32 max_val, min_val;
- u32 dqs_index, clk_index;
-
- /* Find DQS_DLY Pass Count for every CLK_DLY */
- for (clk_i = 0; clk_i < 15; clk_i++) {
- clk_dqs_count[clk_i] = 0;
- clrsetbits_le32(&dram->dllcr[0], 0x3f << 6,
- (clk_dly[clk_i] & 0x3f) << 6);
- for (dqs_i = 0; dqs_i < 7; dqs_i++) {
- for (cr_i = 1; cr_i < 5; cr_i++) {
- clrsetbits_le32(&dram->dllcr[cr_i],
- 0x4f << 14,
- (dqs_dly[dqs_i] & 0x4f) << 14);
- }
- udelay(2);
- if (dramc_scan_readpipe() == 0)
- clk_dqs_count[clk_i]++;
- }
- }
- /* Test DQS_DLY Pass Count for every CLK_DLY from up to down */
- for (dqs_i = 15; dqs_i > 0; dqs_i--) {
- max_val = 15;
- min_val = 15;
- for (clk_i = 0; clk_i < 15; clk_i++) {
- if (clk_dqs_count[clk_i] == dqs_i) {
- max_val = clk_i;
- if (min_val == 15)
- min_val = clk_i;
- }
- }
- if (max_val < 15)
- break;
- }
-
- /* Check if Find a CLK_DLY failed */
- if (!dqs_i)
- goto fail;
-
- /* Find the middle index of CLK_DLY */
- clk_index = (max_val + min_val) >> 1;
- if ((max_val == (15 - 1)) && (min_val > 0))
- /* if CLK_DLY[MCTL_CLK_DLY_COUNT] is very good, then the middle
- * value can be more close to the max_val
- */
- clk_index = (15 + clk_index) >> 1;
- else if ((max_val < (15 - 1)) && (min_val == 0))
- /* if CLK_DLY[0] is very good, then the middle value can be more
- * close to the min_val
- */
- clk_index >>= 1;
- if (clk_dqs_count[clk_index] < dqs_i)
- clk_index = min_val;
-
- /* Find the middle index of DQS_DLY for the CLK_DLY got above, and Scan
- * read pipe again
- */
- clrsetbits_le32(&dram->dllcr[0], 0x3f << 6,
- (clk_dly[clk_index] & 0x3f) << 6);
- max_val = 7;
- min_val = 7;
- for (dqs_i = 0; dqs_i < 7; dqs_i++) {
- clk_dqs_count[dqs_i] = 0;
- for (cr_i = 1; cr_i < 5; cr_i++) {
- clrsetbits_le32(&dram->dllcr[cr_i],
- 0x4f << 14,
- (dqs_dly[dqs_i] & 0x4f) << 14);
- }
- udelay(2);
- if (dramc_scan_readpipe() == 0) {
- clk_dqs_count[dqs_i] = 1;
- max_val = dqs_i;
- if (min_val == 7)
- min_val = dqs_i;
- }
- }
-
- if (max_val < 7) {
- dqs_index = (max_val + min_val) >> 1;
- if ((max_val == (7 - 1)) && (min_val > 0))
- dqs_index = (7 + dqs_index) >> 1;
- else if ((max_val < (7 - 1)) && (min_val == 0))
- dqs_index >>= 1;
- if (!clk_dqs_count[dqs_index])
- dqs_index = min_val;
- for (cr_i = 1; cr_i < 5; cr_i++) {
- clrsetbits_le32(&dram->dllcr[cr_i],
- 0x4f << 14,
- (dqs_dly[dqs_index] & 0x4f) << 14);
- }
- udelay(2);
- return dramc_scan_readpipe();
- }
-
-fail:
- clrbits_le32(&dram->dllcr[0], 0x3f << 6);
- for (cr_i = 1; cr_i < 5; cr_i++)
- clrbits_le32(&dram->dllcr[cr_i], 0x4f << 14);
- udelay(2);
-
- return dramc_scan_readpipe();
-}
-
-static void dramc_set_autorefresh_cycle(u32 clk)
-{
- u32 reg32;
- u32 tmp_val;
- u32 reg_dcr;
-
- if (clk < 600) {
- reg_dcr = read32(&dram->dcr);
- if ((reg_dcr & DRAM_DCR_CHIP_DENSITY_MASK) <=
- DRAM_DCR_CHIP_DENSITY(DRAM_DCR_CHIP_DENSITY_1024M))
- reg32 = (131 * clk) >> 10;
- else
- reg32 = (336 * clk) >> 10;
-
- tmp_val = (7987 * clk) >> 10;
- tmp_val = tmp_val * 9 - 200;
- reg32 |= tmp_val << 8;
- reg32 |= 0x8 << 24;
- write32(&dram->drr, reg32);
- } else {
- write32(&dram->drr, 0x0);
- }
-}
-
-unsigned long dramc_init(struct dram_para *para)
-{
- u32 reg32;
- int ret_val;
-
- /* check input dram parameter structure */
- if (!para)
- return 0;
-
- /* setup DRAM relative clock */
- mctl_setup_dram_clock(para->clock);
-
- /* reset external DRAM */
- mctl_ddr3_reset();
-
- mctl_set_drive();
-
- /* dram clock off */
- a1x_gate_dram_clock_output();
-
- /* select dram controller 1 */
- write32(&dram->csel, DRAM_CSEL_MAGIC);
-
- mctl_itm_disable();
- mctl_enable_dll0(para->tpr3);
-
- /* configure external DRAM */
- reg32 = 0x0;
- if (para->type == DRAM_MEMORY_TYPE_DDR3)
- reg32 |= DRAM_DCR_TYPE_DDR3;
- reg32 |= DRAM_DCR_IO_WIDTH(para->io_width >> 3);
-
- if (para->density == 256)
- reg32 |= DRAM_DCR_CHIP_DENSITY(DRAM_DCR_CHIP_DENSITY_256M);
- else if (para->density == 512)
- reg32 |= DRAM_DCR_CHIP_DENSITY(DRAM_DCR_CHIP_DENSITY_512M);
- else if (para->density == 1024)
- reg32 |= DRAM_DCR_CHIP_DENSITY(DRAM_DCR_CHIP_DENSITY_1024M);
- else if (para->density == 2048)
- reg32 |= DRAM_DCR_CHIP_DENSITY(DRAM_DCR_CHIP_DENSITY_2048M);
- else if (para->density == 4096)
- reg32 |= DRAM_DCR_CHIP_DENSITY(DRAM_DCR_CHIP_DENSITY_4096M);
- else if (para->density == 8192)
- reg32 |= DRAM_DCR_CHIP_DENSITY(DRAM_DCR_CHIP_DENSITY_8192M);
- else
- reg32 |= DRAM_DCR_CHIP_DENSITY(DRAM_DCR_CHIP_DENSITY_256M);
-
- reg32 |= DRAM_DCR_BUS_WIDTH((para->bus_width >> 3) - 1);
- reg32 |= DRAM_DCR_RANK_SEL(para->rank_num - 1);
- reg32 |= DRAM_DCR_CMD_RANK_ALL;
- reg32 |= DRAM_DCR_MODE(DRAM_DCR_MODE_INTERLEAVE);
- write32(&dram->dcr, reg32);
-
- /* dram clock on */
- a1x_ungate_dram_clock_output();
-
- udelay(1);
-
- while (read32(&dram->ccr) & DRAM_CCR_INIT);
-
- mctl_enable_dllx(para->tpr3);
-
- /* set odt impendance divide ratio */
- reg32 = ((para->zq) >> 8) & 0xfffff;
- reg32 |= ((para->zq) & 0xff) << 20;
- reg32 |= (para->zq) & 0xf0000000;
- write32(&dram->zqcr0, reg32);
-
- /* set I/O configure register */
- reg32 = 0x00cc0000;
- reg32 |= (para->odt_en) & 0x3;
- reg32 |= ((para->odt_en) & 0x3) << 30;
- write32(&dram->iocr, reg32);
-
- /* set refresh period */
- dramc_set_autorefresh_cycle(para->clock);
-
- /* set timing parameters */
- write32(&dram->tpr0, para->tpr0);
- write32(&dram->tpr1, para->tpr1);
- write32(&dram->tpr2, para->tpr2);
-
- if (para->type == DRAM_MEMORY_TYPE_DDR3) {
- reg32 = DRAM_MR_BURST_LENGTH(0x0);
- reg32 |= DRAM_MR_CAS_LAT(para->cas - 4);
- reg32 |= DRAM_MR_WRITE_RECOVERY(0x5);
- } else if (para->type == DRAM_MEMORY_TYPE_DDR2) {
- reg32 = DRAM_MR_BURST_LENGTH(0x2);
- reg32 |= DRAM_MR_CAS_LAT(para->cas);
- reg32 |= DRAM_MR_WRITE_RECOVERY(0x5);
- }
- write32(&dram->mr, reg32);
-
- write32(&dram->emr, para->emr1);
- write32(&dram->emr2, para->emr2);
- write32(&dram->emr3, para->emr3);
-
- /* set DQS window mode */
- clrsetbits_le32(&dram->ccr, DRAM_CCR_DQS_DRIFT_COMP, DRAM_CCR_DQS_GATE);
-
- /* reset external DRAM */
- setbits_le32(&dram->ccr, DRAM_CCR_INIT);
- while (read32(&dram->ccr) & DRAM_CCR_INIT);
-
- /* scan read pipe value */
- mctl_itm_enable();
- if (para->tpr3 & (0x1 << 31)) {
- ret_val = dramc_scan_dll_para();
- if (ret_val == 0)
- para->tpr3 =
- (((read32(&dram->dllcr[0]) >> 6) & 0x3f) << 16) |
- (((read32(&dram->dllcr[1]) >> 14) & 0xf) << 0) |
- (((read32(&dram->dllcr[2]) >> 14) & 0xf) << 4) |
- (((read32(&dram->dllcr[3]) >> 14) & 0xf) << 8) |
- (((read32(&dram->dllcr[4]) >> 14) & 0xf) << 12);
- } else {
- ret_val = dramc_scan_readpipe();
- }
-
- if (ret_val < 0)
- return 0;
-
- /* configure all host port */
- mctl_configure_hostport();
-
- return para->size;
-}
diff --git a/src/cpu/allwinner/a10/timer.c b/src/cpu/allwinner/a10/timer.c
deleted file mode 100644
index 87228a06d4..0000000000
--- a/src/cpu/allwinner/a10/timer.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2013 Alexandru Gagniuc
- *
- * 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; version 2 of the License or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * Timer control and delays for Allwinner CPUs
- *
- */
-
-#include
-#include
-
-#include "timer.h"
-
-struct a1x_timer_module *const timer_module = (void *)A1X_TIMER_BASE;
-struct a1x_timer *const tmr0 =
- &((struct a1x_timer_module *)A1X_TIMER_BASE)->timer[0];
-
-static inline u32 read_timer(void)
-{
- return read32(&tmr0->val);
-}
-
-void init_timer(void)
-{
- u32 reg32;
- /* Load the timer rollover value */
- write32(&tmr0->interval, 0xffffffff);
- /* Configure the timer to run from 24MHz oscillator, no prescaler */
- reg32 = TIMER_CTRL_PRESC_DIV_EXP(0);
- reg32 |= TIMER_CTRL_CLK_SRC_OSC24M;
- reg32 |= TIMER_CTRL_RELOAD;
- reg32 |= TIMER_CTRL_TMR_EN;
- write32(&tmr0->ctrl, reg32);
-}
-
-void udelay(unsigned usec)
-{
- u32 curr_tick, last_tick;
- s32 ticks_left;
-
- last_tick = read_timer();
- /* 24 timer ticks per microsecond (24 MHz, divided by 1) */
- ticks_left = usec * 24;
-
- /* FIXME: Should we consider timer rollover?
- * From when we start the timer, we have almost three minutes before it
- * rolls over, so we should be long into having booted our payload.
- */
- while (ticks_left > 0) {
- curr_tick = read_timer();
- /* Timer value decreases with each tick */
- ticks_left -= last_tick - curr_tick;
- last_tick = curr_tick;
- }
-
-}
-
-/*
- * This function has nothing to do with timers; however, the chip revision
- * register is in the timer module, so keep this function here.
- */
-u8 a1x_get_cpu_chip_revision(void)
-{
- write32(&timer_module->cpu_cfg, 0);
- return (read32(&timer_module->cpu_cfg) >> 6) & 0x3;
-}
diff --git a/src/cpu/allwinner/a10/timer.h b/src/cpu/allwinner/a10/timer.h
deleted file mode 100644
index b7658da35d..0000000000
--- a/src/cpu/allwinner/a10/timer.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2007-2011 Allwinner Technology Co., Ltd.
- * Tom Cubie
- * Copyright (C) 2013 Alexandru Gagniuc
- *
- * 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; version 2 of the License or (at your option)
- * any later version
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * Definitions for timer control on Allwinner CPUs
- */
-
-#ifndef CPU_ALLWINNER_A10_TIMER_H
-#define CPU_ALLWINNER_A10_TIMER_H
-
-#include "memmap.h"
-#include
-
-/* TMRx_CTRL values */
-#define TIMER_CTRL_MODE_SINGLE (1 << 7)
-#define TIMER_CTRL_PRESC_MASK (0x7 << 4)
-#define TIMER_CTRL_PRESC_DIV_EXP(ep) ((ep << 4) & TIMER_CTRL_PRESC_MASK)
-#define TIMER_CTRL_CLK_SRC_MASK (0x3 << 2)
-#define TIMER_CTRL_CLK_SRC_LOSC (0x0 << 2)
-#define TIMER_CTRL_CLK_SRC_OSC24M (0x1 << 2)
-#define TIMER_CTRL_CLK_SRC_PLL6 (0x2 << 2)
-#define TIMER_CTRL_RELOAD (1 << 1)
-#define TIMER_CTRL_TMR_EN (1 << 0)
-
-/* Chip revision definitions (found in CPU_CFG register) */
-#define A1X_CHIP_REV_A 0x0
-#define A1X_CHIP_REV_C1 0x1
-#define A1X_CHIP_REV_C2 0x2
-#define A1X_CHIP_REV_B 0x3
-
-
-/* General purpose timer */
-struct a1x_timer {
- u32 ctrl;
- u32 interval;
- u32 val;
- u8 res[4];
-} __packed;
-
-/* Audio video sync*/
-struct a1x_avs {
- u32 ctrl; /* 0x80 */
- u32 cnt0; /* 0x84 */
- u32 cnt1; /* 0x88 */
- u32 div; /* 0x8c */
-} __packed;
-
-/* Watchdog */
-struct a1x_wdog {
- u32 ctrl; /* 0x90 */
- u32 mode; /* 0x94 */
-} __packed;
-
-/* 64 bit counter */
-struct a1x_64cnt {
- u32 ctrl; /* 0xa0 */
- u32 lo; /* 0xa4 */
- u32 hi; /* 0xa8 */
-} __packed;
-
-/* Rtc */
-struct a1x_rtc {
- u32 ctrl; /* 0x100 */
- u32 yymmdd; /* 0x104 */
- u32 hhmmss; /* 0x108 */
-} __packed;
-
-/* Alarm */
-struct a1x_alarm {
- u32 ddhhmmss; /* 0x10c */
- u32 hhmmss; /* 0x110 */
- u32 en; /* 0x114 */
- u32 irq_en; /* 0x118 */
- u32 irq_sta; /* 0x11c */
-} __packed;
-
-struct a1x_timer_module {
- u32 irq_en; /* 0x00 */
- u32 irq_sta; /* 0x04 */
- u8 res1[8];
- struct a1x_timer timer[6]; /* We have 6 timers */
- u8 res2[16];
- struct a1x_avs avs;
- struct a1x_wdog wdog;
- u8 res3[8];
- struct a1x_64cnt cnt64;
- u8 res4[0x58];
- struct a1x_rtc rtc;
- struct a1x_alarm alarm;
- u32 gp_data[4];
- u8 res5[8];
- u32 cpu_cfg;
-} __packed;
-
-u8 a1x_get_cpu_chip_revision(void);
-
-#endif /* CPU_ALLWINNER_A10_TIMER_H */
diff --git a/src/cpu/allwinner/a10/twi.c b/src/cpu/allwinner/a10/twi.c
deleted file mode 100644
index 01ee5a5c6f..0000000000
--- a/src/cpu/allwinner/a10/twi.c
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2012 Henrik Nordstrom
- * Copyright (C) 2013 Alexandru Gagniuc
- *
- * 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; version 2 of the License or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * Setup helpers for Two Wire Interface (TWI) (I2C) Allwinner CPUs
- *
- * Only functionality for I2C master is provided.
- * Largely based on the uboot-sunxi code.
- */
-
-#include
-#include
-#include
-#include
-
-#include "memmap.h"
-#include "twi.h"
-
-#define TWI_BASE(n) (A1X_TWI0_BASE + 0x400 * (n))
-
-#define TWI_TIMEOUT (50 * 1000)
-
-static u8 is_busy(struct a1x_twi *twi)
-{
- return (read32(&twi->stat) != TWI_STAT_IDLE);
-}
-
-static enum cb_err wait_until_idle(struct a1x_twi *twi)
-{
- u32 i = TWI_TIMEOUT;
- while (i-- && is_busy((twi)))
- udelay(1);
- return i ? CB_SUCCESS : CB_ERR;
-}
-
-/* FIXME: This function is basic, and unintelligent */
-static void configure_clock(struct a1x_twi *twi, u32 speed_hz)
-{
- /* FIXME: We assume clock is 24MHz, which may not be the case */
- u32 apb_clk = 24000000, m, n;
-
- /* Pre-divide the clock by 8 */
- n = 3;
- m = (apb_clk >> n) / speed_hz;
- write32(&twi->clk, TWI_CLK_M(m) | TWI_CLK_N(n));
-}
-
-void a1x_twi_init(u8 bus, u32 speed_hz)
-{
- u32 i = TWI_TIMEOUT;
- struct a1x_twi *twi = (void *)TWI_BASE(bus);
-
- configure_clock(twi, speed_hz);
-
- /* Enable the I2C bus */
- write32(&twi->ctl, TWI_CTL_BUS_EN);
- /* Issue soft reset */
- write32(&twi->reset, 1);
-
- while (i-- && read32(&twi->reset))
- udelay(1);
-}
-
-static void clear_interrupt_flag(struct a1x_twi *twi)
-{
- write32(&twi->ctl, read32(&twi->ctl) & ~TWI_CTL_INT_FLAG);
-}
-
-static void i2c_send_data(struct a1x_twi *twi, u8 data)
-{
- write32(&twi->data, data);
- clear_interrupt_flag(twi);
-}
-
-static enum twi_status wait_for_status(struct a1x_twi *twi)
-{
- u32 i = TWI_TIMEOUT;
- /* Wait until interrupt is asserted again */
- while (i-- && !(read32(&twi->ctl) & TWI_CTL_INT_FLAG))
- udelay(1);
- /* A timeout here most likely indicates a bus error */
- return i ? read32(&twi->stat) : TWI_STAT_BUS_ERROR;
-}
-
-static void i2c_send_start(struct a1x_twi *twi)
-{
- u32 reg32, i;
-
- /* Send START condition */
- reg32 = read32(&twi->ctl);
- reg32 &= ~TWI_CTL_INT_FLAG;
- reg32 |= TWI_CTL_M_START;
- write32(&twi->ctl, reg32);
-
- /* M_START is automatically cleared after condition is transmitted */
- i = TWI_TIMEOUT;
- while (i-- && (read32(&twi->ctl) & TWI_CTL_M_START))
- udelay(1);
-}
-
-static void i2c_send_stop(struct a1x_twi *twi)
-{
- u32 reg32;
-
- /* Send STOP condition */
- reg32 = read32(&twi->ctl);
- reg32 &= ~TWI_CTL_INT_FLAG;
- reg32 |= TWI_CTL_M_STOP;
- write32(&twi->ctl, reg32);
-}
-
-static int i2c_read(struct a1x_twi *twi, uint8_t chip,
- uint8_t *buf, size_t len)
-{
- unsigned count = len;
- enum twi_status expected_status;
-
- /* Send restart for read */
- i2c_send_start(twi);
- if (wait_for_status(twi) != TWI_STAT_TX_RSTART)
- return CB_ERR;
-
- /* Send chip address */
- i2c_send_data(twi, chip << 1 | 1);
- if (wait_for_status(twi) != TWI_STAT_TX_AR_ACK)
- return CB_ERR;
-
- /* Start ACK-ing received data */
- setbits_le32(&twi->ctl, TWI_CTL_A_ACK);
- expected_status = TWI_STAT_RXD_ACK;
-
- /* Read data */
- while (count > 0) {
- if (count == 1) {
- /* Do not ACK the last byte */
- clrbits_le32(&twi->ctl, TWI_CTL_A_ACK);
- expected_status = TWI_STAT_RXD_NAK;
- }
-
- clear_interrupt_flag(twi);
-
- if (wait_for_status(twi) != expected_status)
- return CB_ERR;
-
- *buf++ = read32(&twi->data);
- count--;
- }
-
- return len;
-}
-
-static int i2c_write(struct a1x_twi *twi, uint8_t chip,
- const uint8_t *buf, size_t len)
-{
- size_t count = len;
-
- i2c_send_start(twi);
- if (wait_for_status(twi) != TWI_STAT_TX_START)
- return CB_ERR;
-
- /* Send chip address */
- i2c_send_data(twi, chip << 1);
- if (wait_for_status(twi) != TWI_STAT_TX_AW_ACK)
- return CB_ERR;
-
- /* Send data */
- while (count > 0) {
- i2c_send_data(twi, *buf++);
- if (wait_for_status(twi) != TWI_STAT_TXD_ACK)
- return CB_ERR;
- count--;
- }
-
- return len;
-}
-
-int platform_i2c_transfer(unsigned bus, struct i2c_msg *segments, int count)
-{
- int i, ret = CB_SUCCESS;
- struct i2c_msg *seg = segments;
- struct a1x_twi *twi = (void *)TWI_BASE(bus);
-
-
- if (wait_until_idle(twi) != CB_SUCCESS)
- return CB_ERR;
-
- for (i = 0; i < count; i++) {
- seg = segments + i;
-
- if (seg->flags & I2C_M_RD) {
- ret = i2c_read(twi, seg->slave, seg->buf, seg->len);
- if (ret < 0)
- break;
- } else {
- ret = i2c_write(twi, seg->slave, seg->buf, seg->len);
- if (ret < 0)
- break;
- }
- }
-
- /* Don't worry about the status. STOP is on a best-effort basis */
- i2c_send_stop(twi);
-
- return ret;
-}
diff --git a/src/cpu/allwinner/a10/twi.h b/src/cpu/allwinner/a10/twi.h
deleted file mode 100644
index 833b1dc101..0000000000
--- a/src/cpu/allwinner/a10/twi.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2013 Alexandru Gagniuc
- *
- * 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; version 2 of the License or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * Definitions Two Wire Interface (TWI) (I2C) Allwinner CPUs
- */
-
-#ifndef CPU_ALLWINNER_A10_TWI_H
-#define CPU_ALLWINNER_A10_TWI_H
-
-#include
-
-/* TWI_CTL values */
-#define TWI_CTL_INT_EN (1 << 7)
-#define TWI_CTL_BUS_EN (1 << 6)
-#define TWI_CTL_M_START (1 << 5)
-#define TWI_CTL_M_STOP (1 << 4)
-#define TWI_CTL_INT_FLAG (1 << 3)
-#define TWI_CTL_A_ACK (1 << 2)
-
-/* TWI_STAT values */
-enum twi_status {
- TWI_STAT_BUS_ERROR = 0x00, /**< Bus error */
- TWI_STAT_TX_START = 0x08, /**< START sent */
- TWI_STAT_TX_RSTART = 0x10, /**< Repeated START sent */
- TWI_STAT_TX_AW_ACK = 0x18, /**< Sent address+read, ACK */
- TWI_STAT_TX_AW_NAK = 0x20, /**< Sent address+read, NAK */
- TWI_STAT_TXD_ACK = 0x28, /**< Sent data, got ACK */
- TWI_STAT_TXD_NAK = 0x30, /**< Sent data, no ACK */
- TWI_STAT_LOST_ARB = 0x38, /**< Lost arbitration */
- TWI_STAT_TX_AR_ACK = 0x40, /**< Sent address+write, ACK */
- TWI_STAT_TX_AR_NAK = 0x48, /**< Sent address+write, NAK */
- TWI_STAT_RXD_ACK = 0x50, /**< Got data, sent ACK */
- TWI_STAT_RXD_NAK = 0x58, /**< Got data, no ACK */
- TWI_STAT_IDLE = 0xf8, /**< Bus idle*/
-};
-
-/* TWI_CLK values */
-#define TWI_CLK_M_MASK (0xf << 3)
-#define TWI_CLK_M(m) (((m - 1) << 3) & TWI_CLK_M_MASK)
-#define TWI_CLK_N_MASK (0x7 << 0)
-#define TWI_CLK_N(n) ((n) & TWI_CLK_N_MASK)
-
-struct a1x_twi {
- u32 addr; /**< 0x00: Slave address */
- u32 xaddr; /**< 0x04: Extended slave address */
- u32 data; /**< 0x08: Data byte */
- u32 ctl; /**< 0x0C: Control register */
- u32 stat; /**< 0x10: Status register */
- u32 clk; /**< 0x14: Clock control register */
- u32 reset; /**< 0x18: Software reset */
- u32 efr; /**< 0x1C: Enhanced Feature register */
- u32 lcr; /**< 0x20: Line control register */
-};
-
-void a1x_twi_init(u8 bus, u32 speed_hz);
-
-#endif /* CPU_ALLWINNER_A10_TWI_H */
diff --git a/src/cpu/allwinner/a10/uart.c b/src/cpu/allwinner/a10/uart.c
deleted file mode 100644
index c721a67b07..0000000000
--- a/src/cpu/allwinner/a10/uart.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2013 Alexandru Gagniuc
- *
- * 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; version 2 of the License (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * Uart setup helpers for Allwinner SoCs
- *
- *
- */
-
-#include "uart.h"
-#include
-#include
-#include
-
-/**
- * \brief Configure line control settings for UART
- */
-static void a10_uart_configure(struct a10_uart *uart, u32 baud_rate, u8 data_bits,
- enum uart_parity parity, u8 stop_bits)
-{
- u32 reg32;
- u16 div;
-
- div = (u16) uart_baudrate_divisor(baud_rate,
- uart_platform_refclk(), 16);
- /* Enable access to Divisor Latch register */
- write32(&uart->lcr, UART8250_LCR_DLAB);
- /* Set baudrate */
- write32(&uart->dlh, (div >> 8) & 0xff);
- write32(&uart->dll, div & 0xff);
- /* Set line control */
- reg32 = (data_bits - 5) & UART8250_LCR_WLS_MSK;
- switch (parity) {
- case UART_PARITY_ODD:
- reg32 |= UART8250_LCR_PEN;
- break;
- case UART_PARITY_EVEN:
- reg32 |= UART8250_LCR_PEN;
- reg32 |= UART8250_LCR_EPS;
- break;
- case UART_PARITY_NONE: /* Fall through */
- default:
- break;
- }
- write32(&uart->lcr, reg32);
-}
-
-static void a10_uart_enable_fifos(struct a10_uart *uart)
-{
- write32(&uart->fcr, UART8250_FCR_FIFO_EN);
-}
-
-static int tx_fifo_full(struct a10_uart *uart)
-{
- /* This may be a misnomer, or a typo in the datasheet. THRE indicates
- * that the TX register is empty, not that the FIFO is not full, but
- * this may be due to a datasheet typo. Keep the current name to signal
- * intent. */
- return !(read32(&uart->lsr) & UART8250_LSR_THRE);
-}
-
-static int rx_fifo_empty(struct a10_uart *uart)
-{
- return !(read32(&uart->lsr) & UART8250_LSR_DR);
-}
-
-/**
- * \brief Read a single byte from the UART.
- *
- * Blocks until at least a byte is available.
- */
-static u8 a10_uart_rx_blocking(struct a10_uart *uart)
-{
- while (rx_fifo_empty(uart));
-
- return read32(&uart->rbr);
-}
-
-/**
- * \brief Write a single byte to the UART.
- *
- * Blocks until there is space in the FIFO.
- */
-static void a10_uart_tx_blocking(struct a10_uart *uart, u8 data)
-{
- while (tx_fifo_full(uart));
-
- return write32(&uart->thr, data);
-}
-
-
-void uart_init(int idx)
-{
- struct a10_uart *uart_base = uart_platform_baseptr(idx);
-
- /* Use default 8N1 encoding */
- a10_uart_configure(uart_base, get_uart_baudrate(),
- 8, UART_PARITY_NONE, 1);
- a10_uart_enable_fifos(uart_base);
-}
-
-unsigned char uart_rx_byte(int idx)
-{
- return a10_uart_rx_blocking(uart_platform_baseptr(idx));
-}
-
-void uart_tx_byte(int idx, unsigned char data)
-{
- a10_uart_tx_blocking(uart_platform_baseptr(idx), data);
-}
-
-void uart_tx_flush(int idx)
-{
-}
diff --git a/src/cpu/allwinner/a10/uart.h b/src/cpu/allwinner/a10/uart.h
deleted file mode 100644
index a57fc9c361..0000000000
--- a/src/cpu/allwinner/a10/uart.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2013 Alexandru Gagniuc
- *
- * 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; version 2 of the License or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * Definitions for UART on Allwinner CPUs
- *
- * The UART on the A10 seems to be 8250-compatible, however, this has not been
- * verified. Our 8250mem code is specific to x86, and does not yet work, so we
- * have to re-implement it ARM-style for the time being. The register
- * definitions are present in , and are not redefined here.
- *
- */
-
-#ifndef CPU_ALLWINNER_A10_UART_H
-#define CPU_ALLWINNER_A10_UART_H
-
-#include
-
-struct a10_uart {
- union {
- /* operational mode */
- u32 rbr; /* receiver buffer (read) */
- u32 thr; /* transmit holding (write) */
- /* config mode (DLAB set) */
- u32 dll; /* divisor latches low */
- };
-
- union {
- /* operational mode */
- u32 ier; /* interrupt enable */
- /* config mode (DLAB set) */
- u32 dlh; /* divisor latches high */
- };
-
- union {
- u32 iir; /* interrupt ID (read) */
- u32 fcr; /* FIFO control (write) */
- };
-
- u32 lcr; /* line control */
-
- /* 0x10 */
- u32 mcr; /* modem control */
- u32 lsr; /* line status, read-only */
- u32 msr; /* modem status */
- u32 sch; /* scratch register */
-
- u8 reserved_0x20[0x50];
-
- /* 0x70 */
- u8 reserved_0x70[0xc];
- u32 usr; /* UART status register */
-
- /* 0x80 */
- u32 tfl; /* Transmit FIFO level */
- u32 rfl; /* Receive FIFO level */
- u8 reserved_0x88[0x18];
-
- /* 0xa0 */
- u8 reserved_0xa0[4];
- u32 halt; /* Halt register */
-
-} __packed;
-
-enum uart_parity {
- UART_PARITY_NONE,
- UART_PARITY_EVEN,
- UART_PARITY_ODD,
-};
-
-#endif /* CPU_ALLWINNER_A10_UART_H */
diff --git a/src/cpu/allwinner/a10/uart_console.c b/src/cpu/allwinner/a10/uart_console.c
deleted file mode 100644
index 363a41a129..0000000000
--- a/src/cpu/allwinner/a10/uart_console.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright 2013 Google Inc.
- * Copyright (C) 2013 Alexandru Gagniuc
- *
- * 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; version 2 of the License or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * Glue to UART code to enable serial console
- */
-
-#include
-#include
-#include
-
-#include "memmap.h"
-
-uintptr_t uart_platform_base(int idx)
-{
- /* UART blocks are mapped 0x400 bytes apart */
- if (idx < 8)
- return A1X_UART0_BASE + 0x400 * idx;
- else
- return 0;
-}
-
-/* FIXME: We assume clock is 24MHz, which may not be the case. */
-unsigned int uart_platform_refclk(void)
-{
- return 24000000;
-}
-
-#ifndef __PRE_RAM__
-void uart_fill_lb(void *data)
-{
- struct lb_serial serial;
- serial.type = LB_SERIAL_TYPE_MEMORY_MAPPED;
- serial.baseaddr = uart_platform_base(CONFIG_UART_FOR_CONSOLE);
- serial.baud = get_uart_baudrate();
- serial.regwidth = 1;
- serial.input_hertz = uart_platform_refclk();
- serial.uart_pci_addr = 0;
- lb_add_serial(&serial, data);
-
- lb_add_console(LB_TAG_CONSOLE_SERIAL8250MEM, data);
-}
-#endif
diff --git a/src/cpu/intel/haswell/Makefile.inc b/src/cpu/intel/haswell/Makefile.inc
index f9606486c2..d46a422e4a 100644
--- a/src/cpu/intel/haswell/Makefile.inc
+++ b/src/cpu/intel/haswell/Makefile.inc
@@ -7,12 +7,8 @@ romstage-y += ../car/romstage.c
postcar-y += tsc_freq.c
ramstage-y += acpi.c
-ramstage-$(CONFIG_CACHE_RELOCATED_RAMSTAGE_OUTSIDE_CBMEM) += stage_cache.c
ramstage-$(CONFIG_HAVE_SMI_HANDLER) += smmrelocate.c
-romstage-$(CONFIG_CACHE_RELOCATED_RAMSTAGE_OUTSIDE_CBMEM) += stage_cache.c
-postcar-$(CONFIG_CACHE_RELOCATED_RAMSTAGE_OUTSIDE_CBMEM) += stage_cache.c
-
smm-y += finalize.c
smm-y += tsc_freq.c
diff --git a/src/cpu/intel/haswell/haswell.h b/src/cpu/intel/haswell/haswell.h
index cd8d5cb52b..cfd9d45690 100644
--- a/src/cpu/intel/haswell/haswell.h
+++ b/src/cpu/intel/haswell/haswell.h
@@ -118,15 +118,9 @@
/* Data is passed through bits 31:0 of the data register. */
#define BIOS_MAILBOX_DATA 0x5da0
-/* Region of SMM space is reserved for multipurpose use. It falls below
- * the IED region and above the SMM handler. */
-#define RESERVED_SMM_SIZE CONFIG_SMM_RESERVED_SIZE
-#define RESERVED_SMM_OFFSET \
- (CONFIG_SMM_TSEG_SIZE - CONFIG_IED_REGION_SIZE - RESERVED_SMM_SIZE)
-
/* Sanity check config options. */
-#if (CONFIG_SMM_TSEG_SIZE <= (CONFIG_IED_REGION_SIZE + RESERVED_SMM_SIZE))
-# error "CONFIG_SMM_TSEG_SIZE <= (CONFIG_IED_REGION_SIZE + RESERVED_SMM_SIZE)"
+#if (CONFIG_SMM_TSEG_SIZE <= (CONFIG_IED_REGION_SIZE + CONFIG_SMM_RESERVED_SIZE))
+# error "CONFIG_SMM_TSEG_SIZE <= (CONFIG_IED_REGION_SIZE + CONFIG_SMM_RESERVED_SIZE)"
#endif
#if (CONFIG_SMM_TSEG_SIZE < 0x800000)
# error "CONFIG_SMM_TSEG_SIZE must at least be 8MiB"
diff --git a/src/cpu/intel/haswell/smmrelocate.c b/src/cpu/intel/haswell/smmrelocate.c
index 3948cfe519..3a4a0a7830 100644
--- a/src/cpu/intel/haswell/smmrelocate.c
+++ b/src/cpu/intel/haswell/smmrelocate.c
@@ -250,7 +250,7 @@ static void fill_in_relocation_params(struct device *dev,
params->ied_size = tseg_size - params->smram_size;
/* Adjust available SMM handler memory size. */
- params->smram_size -= RESERVED_SMM_SIZE;
+ params->smram_size -= CONFIG_SMM_RESERVED_SIZE;
/* SMRR has 32-bits of valid address aligned to 4KiB. */
params->smrr_base.lo = (params->smram_base & rmask) | MTRR_TYPE_WRBACK;
diff --git a/src/cpu/intel/model_2065x/Kconfig b/src/cpu/intel/model_2065x/Kconfig
index 089b3fead0..a3a58b65e6 100644
--- a/src/cpu/intel/model_2065x/Kconfig
+++ b/src/cpu/intel/model_2065x/Kconfig
@@ -21,7 +21,6 @@ config CPU_SPECIFIC_OPTIONS
select CPU_INTEL_COMMON
select NO_FIXED_XIP_ROM_SIZE
select PARALLEL_MP
- select CACHE_RELOCATED_RAMSTAGE_OUTSIDE_CBMEM
config BOOTBLOCK_CPU_INIT
string
diff --git a/src/cpu/intel/model_2065x/Makefile.inc b/src/cpu/intel/model_2065x/Makefile.inc
index 9a11b06e4d..1f6d1a22b9 100644
--- a/src/cpu/intel/model_2065x/Makefile.inc
+++ b/src/cpu/intel/model_2065x/Makefile.inc
@@ -19,10 +19,6 @@ ramstage-y += acpi.c
smm-y += finalize.c
-romstage-y += stage_cache.c
-ramstage-y += stage_cache.c
-postcar-y += stage_cache.c
-
cpu_microcode_bins += $(wildcard 3rdparty/intel-microcode/intel-ucode/06-25-*)
cpu_incs-y += $(src)/cpu/intel/car/non-evict/cache_as_ram.S
diff --git a/src/cpu/intel/model_2065x/model_2065x.h b/src/cpu/intel/model_2065x/model_2065x.h
index eab2dd5c50..2f3584a67e 100644
--- a/src/cpu/intel/model_2065x/model_2065x.h
+++ b/src/cpu/intel/model_2065x/model_2065x.h
@@ -80,16 +80,9 @@ void set_power_limits(u8 power_limit_1_time);
int cpu_config_tdp_levels(void);
#endif
-/*
- * Region of SMM space is reserved for multipurpose use. It falls below
- * the IED region and above the SMM handler.
- */
-#define RESERVED_SMM_SIZE CONFIG_SMM_RESERVED_SIZE
-#define RESERVED_SMM_OFFSET (CONFIG_SMM_TSEG_SIZE - RESERVED_SMM_SIZE)
-
/* Sanity check config options. */
-#if (CONFIG_SMM_TSEG_SIZE <= RESERVED_SMM_SIZE)
-# error "CONFIG_SMM_TSEG_SIZE <= RESERVED_SMM_SIZE"
+#if (CONFIG_SMM_TSEG_SIZE <= CONFIG_SMM_RESERVED_SIZE)
+# error "CONFIG_SMM_TSEG_SIZE <= CONFIG_SMM_RESERVED_SIZE"
#endif
#if (CONFIG_SMM_TSEG_SIZE < 0x800000)
# error "CONFIG_SMM_TSEG_SIZE must at least be 8MiB"
diff --git a/src/cpu/intel/model_2065x/stage_cache.c b/src/cpu/intel/model_2065x/stage_cache.c
deleted file mode 100644
index ab8ac979c1..0000000000
--- a/src/cpu/intel/model_2065x/stage_cache.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright 2015 Google, Inc.
- *
- * 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; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
-
-#include
-#include
-#include
-#include "model_2065x.h"
-
-void stage_cache_external_region(void **base, size_t *size)
-{
- /*
- * The ramstage cache lives in the TSEG region at RESERVED_SMM_OFFSET.
- * The top of RAM is defined to be the TSEG base address.
- */
- *size = RESERVED_SMM_SIZE;
- *base = (void *)((uintptr_t)northbridge_get_tseg_base()
- + RESERVED_SMM_OFFSET);
-}
diff --git a/src/cpu/intel/model_206ax/Kconfig b/src/cpu/intel/model_206ax/Kconfig
index 2af63d6079..ced3340903 100644
--- a/src/cpu/intel/model_206ax/Kconfig
+++ b/src/cpu/intel/model_206ax/Kconfig
@@ -19,7 +19,6 @@ config CPU_SPECIFIC_OPTIONS
#select AP_IN_SIPI_WAIT
select TSC_SYNC_MFENCE
select CPU_INTEL_COMMON
- select CACHE_RELOCATED_RAMSTAGE_OUTSIDE_CBMEM
select PARALLEL_MP
select NO_FIXED_XIP_ROM_SIZE
diff --git a/src/cpu/intel/model_206ax/Makefile.inc b/src/cpu/intel/model_206ax/Makefile.inc
index f5de8c38fa..e723d74d78 100644
--- a/src/cpu/intel/model_206ax/Makefile.inc
+++ b/src/cpu/intel/model_206ax/Makefile.inc
@@ -24,10 +24,6 @@ smm-y += tsc_freq.c
smm-y += finalize.c
-romstage-$(CONFIG_CACHE_RELOCATED_RAMSTAGE_OUTSIDE_CBMEM) += stage_cache.c
-postcar-$(CONFIG_CACHE_RELOCATED_RAMSTAGE_OUTSIDE_CBMEM) += stage_cache.c
-ramstage-$(CONFIG_CACHE_RELOCATED_RAMSTAGE_OUTSIDE_CBMEM) += stage_cache.c
-
cpu_microcode_bins += $(wildcard 3rdparty/intel-microcode/intel-ucode/06-2a-*)
cpu_microcode_bins += $(wildcard 3rdparty/intel-microcode/intel-ucode/06-3a-*)
diff --git a/src/cpu/intel/model_206ax/model_206ax.h b/src/cpu/intel/model_206ax/model_206ax.h
index c0d2434fe6..2dc929345d 100644
--- a/src/cpu/intel/model_206ax/model_206ax.h
+++ b/src/cpu/intel/model_206ax/model_206ax.h
@@ -81,17 +81,9 @@
#define PSS_LATENCY_TRANSITION 10
#define PSS_LATENCY_BUSMASTER 10
-/*
- * Region of SMM space is reserved for multipurpose use. It falls below
- * the IED region and above the SMM handler.
- */
-#define RESERVED_SMM_SIZE CONFIG_SMM_RESERVED_SIZE
-#define RESERVED_SMM_OFFSET \
- (CONFIG_SMM_TSEG_SIZE - CONFIG_IED_REGION_SIZE - RESERVED_SMM_SIZE)
-
/* Sanity check config options. */
-#if (CONFIG_SMM_TSEG_SIZE <= (CONFIG_IED_REGION_SIZE + RESERVED_SMM_SIZE))
-# error "CONFIG_SMM_TSEG_SIZE <= (CONFIG_IED_REGION_SIZE + RESERVED_SMM_SIZE)"
+#if (CONFIG_SMM_TSEG_SIZE <= (CONFIG_IED_REGION_SIZE + CONFIG_SMM_RESERVED_SIZE))
+# error "CONFIG_SMM_TSEG_SIZE <= (CONFIG_IED_REGION_SIZE + CONFIG_SMM_RESERVED_SIZE)"
#endif
#if (CONFIG_SMM_TSEG_SIZE < 0x800000)
# error "CONFIG_SMM_TSEG_SIZE must at least be 8MiB"
diff --git a/src/cpu/intel/smm/gen1/smmrelocate.c b/src/cpu/intel/smm/gen1/smmrelocate.c
index 986929c9cb..d8021e6ac2 100644
--- a/src/cpu/intel/smm/gen1/smmrelocate.c
+++ b/src/cpu/intel/smm/gen1/smmrelocate.c
@@ -121,7 +121,7 @@ static void fill_in_relocation_params(struct smm_relocation_params *params)
}
/* Adjust available SMM handler memory size. */
- if (CONFIG(CACHE_RELOCATED_RAMSTAGE_OUTSIDE_CBMEM)) {
+ if (CONFIG(TSEG_STAGE_CACHE)) {
ASSERT(params->smram_size > CONFIG_SMM_RESERVED_SIZE);
params->smram_size -= CONFIG_SMM_RESERVED_SIZE;
}
diff --git a/src/cpu/intel/turbo/turbo.c b/src/cpu/intel/turbo/turbo.c
index 12cbfc0b81..ae97f9a8cf 100644
--- a/src/cpu/intel/turbo/turbo.c
+++ b/src/cpu/intel/turbo/turbo.c
@@ -50,21 +50,15 @@ static const char *const turbo_state_desc[] = {
};
/*
- * Determine the current state of Turbo and cache it for later.
- * Turbo is a package level config so it does not need to be
- * enabled on every core.
+ * Try to update the global Turbo state.
*/
-int get_turbo_state(void)
+static int update_turbo_state(void)
{
struct cpuid_result cpuid_regs;
int turbo_en, turbo_cap;
msr_t msr;
int turbo_state = get_global_turbo_state();
- /* Return cached state if available */
- if (turbo_state != TURBO_UNKNOWN)
- return turbo_state;
-
cpuid_regs = cpuid(CPUID_LEAF_PM);
turbo_cap = !!(cpuid_regs.eax & PM_CAP_TURBO_MODE);
@@ -84,6 +78,22 @@ int get_turbo_state(void)
set_global_turbo_state(turbo_state);
printk(BIOS_INFO, "Turbo is %s\n", turbo_state_desc[turbo_state]);
+
+ return turbo_state;
+}
+
+/*
+ * Determine the current state of Turbo and cache it for later. Turbo is package
+ * level config so it does not need to be enabled on every core.
+ */
+int get_turbo_state(void)
+{
+ int turbo_state = get_global_turbo_state();
+
+ /* Return cached state if available */
+ if (turbo_state == TURBO_UNKNOWN)
+ turbo_state = update_turbo_state();
+
return turbo_state;
}
@@ -102,8 +112,7 @@ void enable_turbo(void)
wrmsr(IA32_MISC_ENABLE, msr);
/* Update cached turbo state */
- set_global_turbo_state(TURBO_ENABLED);
- printk(BIOS_INFO, "Turbo has been enabled\n");
+ update_turbo_state();
}
}
@@ -114,12 +123,14 @@ void disable_turbo(void)
{
msr_t msr;
- /* Set Turbo Disable bit in Misc Enables */
- msr = rdmsr(IA32_MISC_ENABLE);
- msr.hi |= H_MISC_DISABLE_TURBO;
- wrmsr(IA32_MISC_ENABLE, msr);
+ /* Only possible if turbo is available and visible */
+ if (get_turbo_state() == TURBO_ENABLED) {
+ /* Set Turbo Disable bit in Misc Enables */
+ msr = rdmsr(IA32_MISC_ENABLE);
+ msr.hi |= H_MISC_DISABLE_TURBO;
+ wrmsr(IA32_MISC_ENABLE, msr);
- /* Update cached turbo state */
- set_global_turbo_state(TURBO_UNAVAILABLE);
- printk(BIOS_INFO, "Turbo has been disabled\n");
+ /* Update cached turbo state */
+ update_turbo_state();
+ }
}
diff --git a/src/cpu/x86/Kconfig b/src/cpu/x86/Kconfig
index caee5dbd10..a8cf54d89e 100644
--- a/src/cpu/x86/Kconfig
+++ b/src/cpu/x86/Kconfig
@@ -155,6 +155,14 @@ config X86_AMD_FIXED_MTRRS
This option informs the MTRR code to use the RdMem and WrMem fields
in the fixed MTRR MSRs.
+config X86_AMD_INIT_SIPI
+ bool
+ default n
+ help
+ This option limits the number of SIPI signals sent during during the
+ common AP setup. Intel documentation specifies an INIT SIPI SIPI
+ sequence, however this doesn't work on some AMD platforms.
+
config MIRROR_PAYLOAD_TO_RAM_BEFORE_LOADING
def_bool n
help
diff --git a/src/cpu/x86/mp_init.c b/src/cpu/x86/mp_init.c
index 9528149627..3658a5b698 100644
--- a/src/cpu/x86/mp_init.c
+++ b/src/cpu/x86/mp_init.c
@@ -482,6 +482,9 @@ static int start_aps(struct bus *cpu_bus, int ap_count, atomic_t *num_aps)
/* Wait for CPUs to check in up to 200 us. */
wait_for_aps(num_aps, ap_count, 200 /* us */, 15 /* us */);
+ if (CONFIG(X86_AMD_INIT_SIPI))
+ return 0;
+
/* Send 2nd SIPI */
if ((lapic_read(LAPIC_ICR) & LAPIC_ICR_BUSY)) {
printk(BIOS_DEBUG, "Waiting for ICR not to be busy...");
@@ -910,7 +913,7 @@ static int run_ap_work(struct mp_callback *val, long expire_us)
return 0;
} while (expire_us <= 0 || !stopwatch_expired(&sw));
- printk(BIOS_ERR, "AP call expired. %d/%d CPUs accepted.\n",
+ printk(BIOS_CRIT, "CIRTICAL ERROR: AP call expired. %d/%d CPUs accepted.\n",
cpus_accepted, global_num_aps);
return -1;
}
diff --git a/src/cpu/x86/mtrr/earlymtrr.c b/src/cpu/x86/mtrr/earlymtrr.c
index 02ad85f321..5d7ff2cf45 100644
--- a/src/cpu/x86/mtrr/earlymtrr.c
+++ b/src/cpu/x86/mtrr/earlymtrr.c
@@ -11,6 +11,7 @@
* GNU General Public License for more details.
*/
+#include
#include
#include
#include
@@ -51,6 +52,6 @@ void set_var_mtrr(
basem.hi = 0;
wrmsr(MTRR_PHYS_BASE(reg), basem);
maskm.lo = ~(size - 1) | MTRR_PHYS_MASK_VALID;
- maskm.hi = (1 << (CONFIG_CPU_ADDR_BITS - 32)) - 1;
+ maskm.hi = (1 << (cpu_phys_address_size() - 32)) - 1;
wrmsr(MTRR_PHYS_MASK(reg), maskm);
}
diff --git a/src/cpu/x86/smm/Makefile.inc b/src/cpu/x86/smm/Makefile.inc
index 5c7aab3ffc..fe149f140f 100644
--- a/src/cpu/x86/smm/Makefile.inc
+++ b/src/cpu/x86/smm/Makefile.inc
@@ -42,6 +42,10 @@ endif
ifeq ($(CONFIG_SMM_TSEG),y)
+ramstage-y += stage_cache.c
+romstage-y += stage_cache.c
+postcar-y += stage_cache.c
+
smmstub-y += smm_stub.S
smm-y += smm_module_handler.c
diff --git a/src/drivers/intel/fsp1_1/stage_cache.c b/src/cpu/x86/smm/stage_cache.c
similarity index 69%
rename from src/drivers/intel/fsp1_1/stage_cache.c
rename to src/cpu/x86/smm/stage_cache.c
index 2d594e6048..0a816ba732 100644
--- a/src/drivers/intel/fsp1_1/stage_cache.c
+++ b/src/cpu/x86/smm/stage_cache.c
@@ -1,8 +1,7 @@
/*
* This file is part of the coreboot project.
*
- * Copyright (C) 2013 Google Inc.
- * Copyright (C) 2015 Intel Corp.
+ * Copyright 2013 Google Inc.
*
* 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
@@ -15,12 +14,18 @@
*/
#include
-#include
+#include
#include
+#include
-void stage_cache_external_region(void **base, size_t *size)
+int __weak smm_subregion(int sub, uintptr_t *base, size_t *size)
{
- if (smm_subregion(SMM_SUBREGION_CACHE, base, size)) {
+ return -1;
+}
+
+void __weak stage_cache_external_region(void **base, size_t *size)
+{
+ if (smm_subregion(SMM_SUBREGION_CACHE, (uintptr_t *)base, size)) {
printk(BIOS_ERR, "ERROR: No cache SMM subregion.\n");
*base = NULL;
*size = 0;
diff --git a/src/device/Kconfig b/src/device/Kconfig
index 0539062272..e605bc2097 100644
--- a/src/device/Kconfig
+++ b/src/device/Kconfig
@@ -255,6 +255,7 @@ menu "Display"
config FRAMEBUFFER_SET_VESA_MODE
prompt "Set framebuffer graphics resolution"
bool
+ default y if CHROMEOS
depends on PCI_OPTION_ROM_RUN_YABEL || PCI_OPTION_ROM_RUN_REALMODE
select HAVE_VBE_LINEAR_FRAMEBUFFER
help
@@ -407,6 +408,8 @@ endif # FRAMEBUFFER_SET_VESA_MODE
choice
prompt "Framebuffer mode"
+ default VBE_LINEAR_FRAMEBUFFER if HAVE_VBE_LINEAR_FRAMEBUFFER && CHROMEOS
+ default GENERIC_LINEAR_FRAMEBUFFER if HAVE_LINEAR_FRAMEBUFFER && CHROMEOS
default VGA_TEXT_FRAMEBUFFER
config VGA_TEXT_FRAMEBUFFER
diff --git a/src/device/device_const.c b/src/device/device_const.c
index c1b0b063ff..c472aeaa79 100644
--- a/src/device/device_const.c
+++ b/src/device/device_const.c
@@ -234,6 +234,28 @@ DEVTREE_CONST struct device *pcidev_on_root(uint8_t dev, uint8_t fn)
return pcidev_path_on_root(PCI_DEVFN(dev, fn));
}
+DEVTREE_CONST struct device *pcidev_path_on_root_debug(pci_devfn_t devfn, const char *func)
+{
+ DEVTREE_CONST struct device *dev = pcidev_path_on_root(devfn);
+ if (dev)
+ return dev;
+
+ devtree_bug(func, devfn);
+
+ /* FIXME: This can return wrong device. */
+ return dev_find_slot(0, devfn);
+}
+
+void devtree_bug(const char *func, pci_devfn_t devfn)
+{
+ printk(BIOS_ERR, "BUG: %s requests hidden 00:%02x.%u\n", func, devfn >> 3, devfn & 7);
+}
+
+void __noreturn devtree_die(void)
+{
+ die("DEVTREE: dev or chip_info is NULL\n");
+}
+
/**
* Given an SMBus bus and a device number, find the device structure.
*
diff --git a/src/device/device_util.c b/src/device/device_util.c
index 7ded1df435..38303126bc 100644
--- a/src/device/device_util.c
+++ b/src/device/device_util.c
@@ -229,7 +229,7 @@ const char *dev_path(const struct device *dev)
dev->path.usb.port_type, dev->path.usb.port_id);
break;
case DEVICE_PATH_MMIO:
- snprintf(buffer, sizeof(buffer), "MMIO: %08x",
+ snprintf(buffer, sizeof(buffer), "MMIO: %08lx",
dev->path.mmio.addr);
break;
default:
@@ -331,7 +331,7 @@ void compact_resources(struct device *dev)
* @param index The index of the resource on the device.
* @return The resource, if it already exists.
*/
-struct resource *probe_resource(struct device *dev, unsigned index)
+struct resource *probe_resource(const struct device *dev, unsigned index)
{
struct resource *res;
@@ -401,7 +401,7 @@ struct resource *new_resource(struct device *dev, unsigned index)
* @param index The index of the resource on the device.
* return TODO.
*/
-struct resource *find_resource(struct device *dev, unsigned index)
+struct resource *find_resource(const struct device *dev, unsigned index)
{
struct resource *resource;
diff --git a/src/device/oprom/realmode/x86.c b/src/device/oprom/realmode/x86.c
index a7631a1a84..1a80a000e2 100644
--- a/src/device/oprom/realmode/x86.c
+++ b/src/device/oprom/realmode/x86.c
@@ -18,14 +18,12 @@
#include
#include
#include
-#include
#include
#include
#include
#include
#include
#include
-#include
#include
#include
#include
@@ -36,6 +34,16 @@
#include "x86.h"
+typedef struct {
+ char signature[4];
+ u16 version;
+ u8 *oem_string_ptr;
+ u32 capabilities;
+ u32 video_mode_ptr;
+ u16 total_memory;
+ char reserved[236];
+} __packed vbe_info_block;
+
/* The following symbols cannot be used directly. They need to be fixed up
* to point to the correct address location after the code has been copied
* to REALMODE_BASE. Absolute symbols are not used because those symbols are
@@ -50,11 +58,11 @@ extern unsigned char __realmode_buffer;
/* to have a common register file for interrupt handlers */
X86EMU_sysEnv _X86EMU_env;
-void (*realmode_call)(u32 addr, u32 eax, u32 ebx, u32 ecx, u32 edx,
+unsigned int (*realmode_call)(u32 addr, u32 eax, u32 ebx, u32 ecx, u32 edx,
u32 esi, u32 edi) asmlinkage;
-void (*realmode_interrupt)(u32 intno, u32 eax, u32 ebx, u32 ecx, u32 edx,
- u32 esi, u32 edi) asmlinkage;
+unsigned int (*realmode_interrupt)(u32 intno, u32 eax, u32 ebx, u32 ecx,
+ u32 edx, u32 esi, u32 edi) asmlinkage;
static void setup_realmode_code(void)
{
@@ -213,7 +221,7 @@ static void setup_realmode_idt(void)
}
#if CONFIG(FRAMEBUFFER_SET_VESA_MODE)
-vbe_mode_info_t mode_info;
+static vbe_mode_info_t mode_info;
static int mode_info_valid;
static int vbe_mode_info_valid(void)
@@ -221,6 +229,92 @@ static int vbe_mode_info_valid(void)
return mode_info_valid;
}
+const vbe_mode_info_t *vbe_mode_info(void)
+{
+ if (!mode_info_valid || !mode_info.vesa.phys_base_ptr)
+ return NULL;
+ return &mode_info;
+}
+
+static int vbe_check_for_failure(int ah);
+
+static void vbe_get_ctrl_info(vbe_info_block *info)
+{
+ char *buffer = PTR_TO_REAL_MODE(__realmode_buffer);
+ u16 buffer_seg = (((unsigned long)buffer) >> 4) & 0xff00;
+ u16 buffer_adr = ((unsigned long)buffer) & 0xffff;
+ X86_EAX = realmode_interrupt(0x10, VESA_GET_INFO, 0x0000, 0x0000,
+ 0x0000, buffer_seg, buffer_adr);
+ /* If the VBE function completed successfully, 0x0 is returned in AH */
+ if (X86_AH)
+ die("\nError: In %s function\n", __func__);
+ memcpy(info, buffer, sizeof(vbe_info_block));
+}
+
+static void vbe_oprom_list_supported_mode(uint16_t *video_mode_ptr)
+{
+ uint16_t mode;
+ printk(BIOS_DEBUG, "Supported Video Mode list for OpRom:\n");
+ do {
+ mode = *video_mode_ptr++;
+ if (mode != 0xffff)
+ printk(BIOS_DEBUG, "%x\n", mode);
+ } while (mode != 0xffff);
+}
+
+static void vbe_oprom_supported_mode_list(void)
+{
+ uint16_t segment, offset;
+ vbe_info_block info;
+
+ vbe_get_ctrl_info(&info);
+
+ offset = info.video_mode_ptr;
+ segment = info.video_mode_ptr >> 16;
+
+ vbe_oprom_list_supported_mode((uint16_t *)((segment << 4) + offset));
+}
+/*
+ * EAX register is used to indicate the completion status upon return from
+ * VBE function in real mode.
+ *
+ * If the VBE function completed successfully then 0x0 is returned in the AH
+ * register. Otherwise the AH register is set with the nature of the failure:
+ *
+ * AH == 0x00: Function call successful
+ * AH == 0x01: Function call failed
+ * AH == 0x02: Function is not supported in the current HW configuration
+ * AH == 0x03: Function call invalid in current video mode
+ *
+ * Return 0 on success else -1 for failure
+ */
+static int vbe_check_for_failure(int ah)
+{
+ int status;
+
+ switch (ah) {
+ case 0x0:
+ status = 0;
+ break;
+ case 1:
+ printk(BIOS_DEBUG, "VBE: Function call failed!\n");
+ status = -1;
+ break;
+ case 2:
+ printk(BIOS_DEBUG, "VBE: Function is not supported!\n");
+ status = -1;
+ break;
+ case 3:
+ default:
+ printk(BIOS_DEBUG, "VBE: Unsupported video mode %x!\n",
+ CONFIG_FRAMEBUFFER_VESA_MODE);
+ vbe_oprom_supported_mode_list();
+ status = -1;
+ break;
+ }
+
+ return status;
+}
static u8 vbe_get_mode_info(vbe_mode_info_t * mi)
{
printk(BIOS_DEBUG, "VBE: Getting information about VESA mode %04x\n",
@@ -228,8 +322,10 @@ static u8 vbe_get_mode_info(vbe_mode_info_t * mi)
char *buffer = PTR_TO_REAL_MODE(__realmode_buffer);
u16 buffer_seg = (((unsigned long)buffer) >> 4) & 0xff00;
u16 buffer_adr = ((unsigned long)buffer) & 0xffff;
- realmode_interrupt(0x10, VESA_GET_MODE_INFO, 0x0000,
+ X86_EAX = realmode_interrupt(0x10, VESA_GET_MODE_INFO, 0x0000,
mi->video_mode, 0x0000, buffer_seg, buffer_adr);
+ if (vbe_check_for_failure(X86_AH))
+ die("\nError: In %s function\n", __func__);
memcpy(mi->mode_info_block, buffer, sizeof(mi->mode_info_block));
mode_info_valid = 1;
return 0;
@@ -242,8 +338,10 @@ static u8 vbe_set_mode(vbe_mode_info_t * mi)
mi->video_mode |= (1 << 14);
// request clearing of framebuffer
mi->video_mode &= ~(1 << 15);
- realmode_interrupt(0x10, VESA_SET_MODE, mi->video_mode,
+ X86_EAX = realmode_interrupt(0x10, VESA_SET_MODE, mi->video_mode,
0x0000, 0x0000, 0x0000, 0x0000);
+ if (vbe_check_for_failure(X86_AH))
+ die("\nError: In %s function\n", __func__);
return 0;
}
@@ -260,6 +358,7 @@ void vbe_set_graphics(void)
le16_to_cpu(mode_info.vesa.x_resolution),
le16_to_cpu(mode_info.vesa.y_resolution),
mode_info.vesa.bits_per_pixel);
+
printk(BIOS_DEBUG, "VBE: framebuffer: %p\n", framebuffer);
if (!framebuffer) {
printk(BIOS_DEBUG, "VBE: Mode does not support linear "
@@ -268,26 +367,15 @@ void vbe_set_graphics(void)
}
vbe_set_mode(&mode_info);
-#if CONFIG(BOOTSPLASH)
- struct jpeg_decdata *decdata;
- unsigned char *jpeg = cbfs_boot_map_with_leak("bootsplash.jpg",
- CBFS_TYPE_BOOTSPLASH,
- NULL);
- if (!jpeg) {
- printk(BIOS_DEBUG, "VBE: No bootsplash found.\n");
- return;
- }
- decdata = malloc(sizeof(*decdata));
- int ret = 0;
- ret = jpeg_decode(jpeg, framebuffer, 1024, 768, 16, decdata);
-#endif
}
void vbe_textmode_console(void)
{
delay(2);
- realmode_interrupt(0x10, 0x0003, 0x0000, 0x0000,
+ X86_EAX = realmode_interrupt(0x10, 0x0003, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000);
+ if (vbe_check_for_failure(X86_AH))
+ die("\nError: In %s function\n", __func__);
}
int fill_lb_framebuffer(struct lb_framebuffer *framebuffer)
diff --git a/src/device/oprom/realmode/x86.h b/src/device/oprom/realmode/x86.h
index b8cc02a51e..052c9c0dbf 100644
--- a/src/device/oprom/realmode/x86.h
+++ b/src/device/oprom/realmode/x86.h
@@ -33,11 +33,11 @@ extern unsigned int __idt_handler_size;
extern unsigned char __realmode_code;
extern unsigned int __realmode_code_size;
-extern void (*realmode_call)(u32 addr, u32 eax, u32 ebx, u32 ecx, u32 edx,
- u32 esi, u32 edi) asmlinkage;
+extern unsigned int (*realmode_call)(u32 addr, u32 eax, u32 ebx, u32 ecx,
+ u32 edx, u32 esi, u32 edi) asmlinkage;
-extern void (*realmode_interrupt)(u32 intno, u32 eax, u32 ebx, u32 ecx, u32 edx,
- u32 esi, u32 edi) asmlinkage;
+extern unsigned int (*realmode_interrupt)(u32 intno, u32 eax, u32 ebx, u32 ecx,
+ u32 edx, u32 esi, u32 edi) asmlinkage;
#define FAKE_MEMORY_SIZE (1024*1024) // only 1MB
#define INITIAL_EBDA_SEGMENT 0xF600
diff --git a/src/device/oprom/realmode/x86_asm.S b/src/device/oprom/realmode/x86_asm.S
index 87348cdc22..ec82e53ec5 100644
--- a/src/device/oprom/realmode/x86_asm.S
+++ b/src/device/oprom/realmode/x86_asm.S
@@ -43,6 +43,10 @@ __idt_handler_size:
.globl __realmode_code
__realmode_code:
+/* Realmode function return. */
+__realmode_ret = RELOCATED(.)
+ .long 0
+
/* Realmode IDT pointer structure. */
__realmode_idt = RELOCATED(.)
.word 1023 /* 16 bit limit */
@@ -167,6 +171,13 @@ __lcall_instr = RELOCATED(.)
.word 0x0000, 0x0000
/* ************************************ */
+ /*
+ * Here is end of real mode call and time to go back to protected mode.
+ * Before that its better to store current eax into some memory address
+ * so that context persist in protected mode too.
+ */
+ mov %eax, __realmode_ret
+
/* If we got here, we are just about done.
* Need to get back to protected mode.
*/
@@ -196,7 +207,8 @@ __lcall_instr = RELOCATED(.)
popa
/* and exit */
- // TODO return AX from OPROM call
+ /* return AX from OPROM call */
+ mov __realmode_ret, %eax
ret
.globl __realmode_interrupt
@@ -291,6 +303,13 @@ __realmode_interrupt:
__intXX_instr = RELOCATED(.)
.byte 0xcd, 0x00 /* This becomes intXX */
+ /*
+ * Here is end of real mode call and time to go back to protected mode.
+ * Before that its better to store current eax into some memory address
+ * so that context persist in protected mode too.
+ */
+ mov %eax, __realmode_ret
+
/* Ok, the job is done, now go back to protected mode coreboot */
movl %cr0, %eax
orl $PE, %eax
@@ -314,6 +333,8 @@ __intXX_instr = RELOCATED(.)
movl __stack, %esp
popf
popa
+ /* return AX from OPROM call */
+ mov __realmode_ret, %eax
ret
/* This is the 16-bit interrupt entry point called by the IDT stub code.
diff --git a/src/device/oprom/yabel/io.c b/src/device/oprom/yabel/io.c
index e8c41ce24a..051a601569 100644
--- a/src/device/oprom/yabel/io.c
+++ b/src/device/oprom/yabel/io.c
@@ -184,8 +184,7 @@ my_inb(X86EMU_pioAddr addr)
X86EMU_trace_on();
}
M.x86.debug &= ~DEBUG_DECODE_NOPRINT_F;
- //HALT_SYS();
- // no break, intentional fall-through to default!!
+ // fall-through
default:
DEBUG_PRINTF_IO
("%s(%04x) reading from bios_device.io_buffer\n",
diff --git a/src/device/oprom/yabel/vbe.c b/src/device/oprom/yabel/vbe.c
index 682bf00ba5..9a7fa045c7 100644
--- a/src/device/oprom/yabel/vbe.c
+++ b/src/device/oprom/yabel/vbe.c
@@ -34,9 +34,6 @@
#include
#include
-#if CONFIG(FRAMEBUFFER_SET_VESA_MODE)
-#include
-#endif
#include
@@ -52,13 +49,22 @@
#include "interrupt.h"
#include "device.h"
-#include
-
#include
-#include "../../src/lib/jpeg.h"
#include
+// these structs only store a subset of the VBE defined fields
+// only those needed.
+typedef struct {
+ char signature[4];
+ u16 version;
+ u8 *oem_string_ptr;
+ u32 capabilities;
+ u16 video_mode_list[256]; // lets hope we never have more than
+ // 256 video modes...
+ u16 total_memory;
+} vbe_info_t;
+
// pointer to VBEInfoBuffer, set by vbe_prepare
u8 *vbe_info_buffer = 0;
@@ -705,7 +711,14 @@ vbe_get_info(void)
}
#endif
-vbe_mode_info_t mode_info;
+static vbe_mode_info_t mode_info;
+
+const vbe_mode_info_t *vbe_mode_info(void)
+{
+ if (!mode_info_valid || !mode_info.vesa.phys_base_ptr)
+ return NULL;
+ return &mode_info;
+}
void vbe_set_graphics(void)
{
@@ -733,34 +746,6 @@ void vbe_set_graphics(void)
mode_info.video_mode = (1 << 14) | CONFIG_FRAMEBUFFER_VESA_MODE;
vbe_get_mode_info(&mode_info);
vbe_set_mode(&mode_info);
-
-#if CONFIG(BOOTSPLASH)
- unsigned char *framebuffer =
- (unsigned char *) le32_to_cpu(mode_info.vesa.phys_base_ptr);
- DEBUG_PRINTF_VBE("FRAMEBUFFER: 0x%p\n", framebuffer);
-
- struct jpeg_decdata *decdata;
-
- /* Switching Intel IGD to 1MB video memory will break this. Who
- * cares. */
- // int imagesize = 1024*768*2;
-
- unsigned char *jpeg = cbfs_boot_map_with_leak("bootsplash.jpg",
- CBFS_TYPE_BOOTSPLASH,
- NULL);
- if (!jpeg) {
- DEBUG_PRINTF_VBE("Could not find bootsplash.jpg\n");
- return;
- }
- DEBUG_PRINTF_VBE("Splash at %p ...\n", jpeg);
- dump(jpeg, 64);
-
- decdata = malloc(sizeof(*decdata));
- int ret = 0;
- DEBUG_PRINTF_VBE("Decompressing boot splash screen...\n");
- ret = jpeg_decode(jpeg, framebuffer, 1024, 768, 16, decdata);
- DEBUG_PRINTF_VBE("returns %x\n", ret);
-#endif
}
int fill_lb_framebuffer(struct lb_framebuffer *framebuffer)
diff --git a/src/device/pci_device.c b/src/device/pci_device.c
index 9c47085152..5765529f86 100644
--- a/src/device/pci_device.c
+++ b/src/device/pci_device.c
@@ -34,6 +34,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -49,6 +50,8 @@
#include
#include
#include
+#include
+
u8 pci_moving_config8(struct device *dev, unsigned int reg)
{
@@ -627,11 +630,6 @@ void pci_dev_enable_resources(struct device *dev)
pci_write_config16(dev, PCI_COMMAND, command);
}
-void __noreturn pcidev_die(void)
-{
- die("PCI: dev is NULL!\n");
-}
-
void pci_bus_enable_resources(struct device *dev)
{
u16 ctrl;
@@ -764,9 +762,13 @@ void pci_dev_init(struct device *dev)
return;
run_bios(dev, (unsigned long)ram);
+
gfx_set_init_done(1);
printk(BIOS_DEBUG, "VGA Option ROM was run\n");
timestamp_add_now(TS_OPROM_END);
+
+ if (CONFIG(BOOTSPLASH))
+ set_vesa_bootsplash();
}
/** Default device operation for PCI devices */
diff --git a/src/device/pci_ops.c b/src/device/pci_ops.c
index 96133155be..6f42978e82 100644
--- a/src/device/pci_ops.c
+++ b/src/device/pci_ops.c
@@ -14,6 +14,7 @@
#define __SIMPLE_DEVICE__
#include
+#include
#include
#include
#include
@@ -85,3 +86,8 @@ u16 pci_s_find_capability(pci_devfn_t dev, u16 cap)
{
return pci_s_find_next_capability(dev, cap, 0);
}
+
+void __noreturn pcidev_die(void)
+{
+ die("PCI: dev is NULL!\n");
+}
diff --git a/src/device/pci_rom.c b/src/device/pci_rom.c
index 34a9a81a52..2b2d46d57b 100644
--- a/src/device/pci_rom.c
+++ b/src/device/pci_rom.c
@@ -192,7 +192,7 @@ static struct rom_header *check_initialized(struct device *dev)
return NULL;
rom_data = (struct pci_data *)((u8 *)run_rom
- + read_le32(&run_rom->data));
+ + read_le16(&run_rom->data));
if (read_le32(&rom_data->signature) == PCI_DATA_HDR
&& read_le16(&rom_data->device) == dev->device
diff --git a/src/drivers/crb/Kconfig b/src/drivers/crb/Kconfig
new file mode 100644
index 0000000000..bfd8be06d6
--- /dev/null
+++ b/src/drivers/crb/Kconfig
@@ -0,0 +1,17 @@
+config CRB_TPM
+ bool
+ help
+ CRB TPM driver is enabled!
+
+config CRB_TPM_BASE_ADDRESS
+ hex
+ default 0xfed40000
+ help
+ Base Address of the CRB TPM Command Structure
+
+config MAINBOARD_HAS_CRB_TPM
+ bool
+ default n
+ select CRB_TPM
+ help
+ Mainboard has Command Response Buffer support
diff --git a/src/drivers/crb/Makefile.inc b/src/drivers/crb/Makefile.inc
new file mode 100644
index 0000000000..3f12b36923
--- /dev/null
+++ b/src/drivers/crb/Makefile.inc
@@ -0,0 +1,5 @@
+bootblock-$(CONFIG_CRB_TPM) += tis.c tpm.c
+verstage-$(CONFIG_CRB_TPM) += tis.c tpm.c
+romstage-$(CONFIG_CRB_TPM) += tis.c tpm.c
+ramstage-$(CONFIG_CRB_TPM) += tis.c tpm.c
+postcar-$(CONFIG_CRB_TPM) += tis.c tpm.c
diff --git a/src/soc/amd/picasso/cache_as_ram.S b/src/drivers/crb/chip.h
similarity index 69%
rename from src/soc/amd/picasso/cache_as_ram.S
rename to src/drivers/crb/chip.h
index 28690628d6..8e74a68f97 100644
--- a/src/soc/amd/picasso/cache_as_ram.S
+++ b/src/drivers/crb/chip.h
@@ -1,6 +1,8 @@
/*
* This file is part of the coreboot project.
*
+ * Copyright 2014 Google Inc. All Rights Reserved.
+ *
* 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; version 2 of the License.
@@ -11,10 +13,10 @@
* GNU General Public License for more details.
*/
-/*
- * TODO: This is a dummy file for making bootblock build and link. At some
- * point, this should be removed from picasso since bootblock is
- * ignored.
- */
-.global bootblock_pre_c_entry
-bootblock_pre_c_entry:
+#ifndef DRIVERS_CRB_CHIP_H
+#define DRIVERS_CRB_CHIP_H
+
+typedef struct drivers_crb_config {
+} tpm_config_t;
+
+#endif /* DRIVERS_CRB_CHIP_H */
diff --git a/src/drivers/crb/tis.c b/src/drivers/crb/tis.c
new file mode 100644
index 0000000000..94bfb9ef15
--- /dev/null
+++ b/src/drivers/crb/tis.c
@@ -0,0 +1,159 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "tpm.h"
+#include "chip.h"
+
+static unsigned tpm_is_open CAR_GLOBAL;
+
+static const struct {
+ uint16_t vid;
+ uint16_t did;
+ const char *device_name;
+} dev_map[] = {
+ {0x1ae0, 0x0028, "CR50"},
+ {0xa13a, 0x8086, "Intel iTPM"}
+};
+
+static const char *tis_get_dev_name(struct tpm2_info *info)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(dev_map); i++)
+ if ((dev_map[i].vid == info->vendor_id) && (dev_map[i].did == info->device_id))
+ return dev_map[i].device_name;
+ return "Unknown";
+}
+
+
+int tis_open(void)
+{
+ if (car_get_var(tpm_is_open)) {
+ printk(BIOS_ERR, "%s called twice.\n", __func__);
+ return -1;
+ }
+
+ if (CONFIG(HAVE_INTEL_PTT)) {
+ if (!ptt_active()) {
+ printk(BIOS_ERR, "%s: Intel PTT is not active.\n", __func__);
+ return -1;
+ }
+ printk(BIOS_DEBUG, "%s: Intel PTT is active.\n", __func__);
+ }
+
+ return 0;
+}
+
+int tis_close(void)
+{
+ if (car_get_var(tpm_is_open)) {
+
+ /*
+ * Do we need to do something here, like waiting for a
+ * transaction to stop?
+ */
+ car_set_var(tpm_is_open, 0);
+ }
+
+ return 0;
+}
+
+int tis_init(void)
+{
+ struct tpm2_info info;
+
+ // Wake TPM up (if necessary)
+ if (tpm2_init() != 0)
+ return -1;
+
+ tpm2_get_info(&info);
+
+ printk(BIOS_INFO, "Initialized TPM device %s revision %d\n", tis_get_dev_name(&info),
+ info.revision);
+
+ return 0;
+}
+
+
+int tis_sendrecv(const uint8_t *sendbuf, size_t sbuf_size, uint8_t *recvbuf, size_t *rbuf_len)
+{
+ int len = tpm2_process_command(sendbuf, sbuf_size, recvbuf, *rbuf_len);
+
+ if (len == 0)
+ return -1;
+
+ *rbuf_len = len;
+
+ return 0;
+}
+
+#ifdef __RAMSTAGE__
+
+static void crb_tpm_fill_ssdt(struct device *dev)
+{
+ const char *path = acpi_device_path(dev);
+ if (!path) {
+ path = "\\_SB_.TPM";
+ printk(BIOS_DEBUG, "Using default TPM2 ACPI path: '%s'\n", path);
+ }
+
+ /* Device */
+ acpigen_write_device(path);
+
+ acpigen_write_name_string("_HID", "MSFT0101");
+ acpigen_write_name_string("_CID", "MSFT0101");
+
+ acpigen_write_name_integer("_UID", 1);
+
+ acpigen_write_STA(ACPI_STATUS_DEVICE_ALL_ON);
+
+ /* Resources */
+ acpigen_write_name("_CRS");
+ acpigen_write_resourcetemplate_header();
+ acpigen_write_mem32fixed(1, TPM_CRB_BASE_ADDRESS, 0x5000);
+
+ acpigen_write_resourcetemplate_footer();
+
+ acpigen_pop_len(); /* Device */
+}
+
+static const char *crb_tpm_acpi_name(const struct device *dev)
+{
+ return "TPM";
+}
+
+static struct device_operations crb_ops = {
+ .read_resources = DEVICE_NOOP,
+ .set_resources = DEVICE_NOOP,
+#if CONFIG(HAVE_ACPI_TABLES)
+ .acpi_name = crb_tpm_acpi_name,
+ .acpi_fill_ssdt_generator = crb_tpm_fill_ssdt,
+#endif
+
+};
+
+static void enable_dev(struct device *dev)
+{
+ dev->ops = &crb_ops;
+}
+
+struct chip_operations drivers_crb_ops = {CHIP_NAME("CRB TPM").enable_dev = enable_dev};
+
+#endif /* __RAMSTAGE__ */
diff --git a/src/drivers/crb/tpm.c b/src/drivers/crb/tpm.c
new file mode 100644
index 0000000000..0393417e74
--- /dev/null
+++ b/src/drivers/crb/tpm.c
@@ -0,0 +1,280 @@
+/*.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * This is a driver for a CRB Interface.
+ *
+ * The general flow looks like this:
+ *
+ * TPM starts in IDLE Mode
+ *
+ * IDLE --> READY --> Command Receiption
+ * ^ |
+ * | v
+ -- Cmd Complete <-- Command Execution
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "tpm.h"
+
+static struct control_area {
+ uint32_t request;
+ uint32_t status;
+ uint32_t cancel;
+ uint32_t start;
+ uint64_t interrupt_control;
+ uint32_t command_size;
+ void *command_bfr;
+ uint32_t response_size;
+ void *response_bfr;
+} control_area;
+
+static uint8_t cur_loc = 0;
+
+/* Read Control Area Structure back */
+static void crb_readControlArea(void)
+{
+ control_area.request = read32(CRB_REG(cur_loc, CRB_REG_REQUEST));
+ control_area.status = read32(CRB_REG(cur_loc, CRB_REG_STATUS));
+ control_area.cancel = read32(CRB_REG(cur_loc, CRB_REG_CANCEL));
+ control_area.interrupt_control = read64(CRB_REG(cur_loc, CRB_REG_INT_CTRL));
+ control_area.command_size = read32(CRB_REG(cur_loc, CRB_REG_CMD_SIZE));
+ control_area.command_bfr = (void *)(uint32_t)read64(CRB_REG(cur_loc, CRB_REG_CMD_ADDR));
+ control_area.response_size = read32(CRB_REG(cur_loc, CRB_REG_RESP_SIZE));
+ control_area.response_bfr =
+ (void *)(uint32_t)read64(CRB_REG(cur_loc, CRB_REG_RESP_ADDR));
+}
+
+/* Wait for Reg to be expected Value */
+static int crb_wait_for_reg32(const void *addr, uint32_t timeoutMs, uint32_t mask,
+ uint32_t expectedValue)
+{
+ uint32_t regValue;
+ struct stopwatch sw;
+
+ // Set up a timer which breaks the loop after timeout
+ stopwatch_init_msecs_expire(&sw, timeoutMs);
+
+ while (1) {
+ // Now check if the TPM is in IDLE mode
+ regValue = read32(addr);
+
+ if ((regValue & mask) == expectedValue)
+ return 0;
+
+ if (stopwatch_expired(&sw)) {
+ printk(BIOS_ERR,
+ "CRB_WAIT: Error - Returning Zero with RegValue: %08x, Mask: %08x, Expected: %08x\n",
+ regValue, mask, expectedValue);
+ return -1;
+ }
+ }
+}
+
+/* CRB PROBE
+ *
+ * Checks if the CRB Interface is ready
+ */
+static int crb_probe(void)
+{
+ uint64_t tpmStatus = read64(CRB_REG(cur_loc, CRB_REG_INTF_ID));
+ printk(BIOS_SPEW, "Interface ID Reg. %llx\n", tpmStatus);
+
+ if ((tpmStatus & CRB_INTF_REG_CAP_CRB) == 0) {
+ printk(BIOS_DEBUG, "TPM: CRB Interface is not supported.\n");
+ return -1;
+ }
+
+ if ((tpmStatus & (0xf)) != 1) {
+ printk(BIOS_DEBUG,
+ "TPM: CRB Interface is not active. System needs reboot in order to active TPM.\n");
+ write32(CRB_REG(cur_loc, CRB_REG_INTF_ID), CRB_INTF_REG_INTF_SEL);
+ return -1;
+ }
+
+ write32(CRB_REG(cur_loc, CRB_REG_INTF_ID), CRB_INTF_REG_INTF_SEL);
+ write32(CRB_REG(cur_loc, CRB_REG_INTF_ID), CRB_INTF_REG_INTF_LOCK);
+
+ return 0;
+}
+
+/*
+ * Get active Locality
+ *
+ * Get the active locality
+ */
+static uint8_t crb_activate_locality(void)
+{
+
+ uint8_t locality = (read8(CRB_REG(0, CRB_REG_LOC_STATE)) >> 2) & 0x07;
+ printk(BIOS_SPEW, "Active locality: %i\n", locality);
+
+ int rc = crb_wait_for_reg32(CRB_REG(locality, CRB_REG_LOC_STATE), 750,
+ LOC_STATE_LOC_ASSIGN, LOC_STATE_LOC_ASSIGN);
+ if (!rc && (locality == 0))
+ return locality;
+
+ if (rc)
+ write8(CRB_REG(locality, CRB_REG_LOC_CTRL), LOC_CTRL_REQ_ACCESS);
+
+
+ rc = crb_wait_for_reg32(CRB_REG(locality, CRB_REG_LOC_STATE), 750, LOC_STATE_LOC_ASSIGN,
+ LOC_STATE_LOC_ASSIGN);
+ if (rc) {
+ printk(BIOS_ERR, "TPM: Error - No Locality has been assigned TPM-wise.\n");
+ return 0;
+ }
+
+ rc = crb_wait_for_reg32(CRB_REG(locality, CRB_REG_LOC_STATE), 1500,
+ LOC_STATE_REG_VALID_STS, LOC_STATE_REG_VALID_STS);
+ if (rc) {
+ printk(BIOS_ERR, "TPM: Error - LOC_STATE Register %u contains errors.\n",
+ locality);
+ return 0;
+ }
+
+
+ return locality;
+}
+
+/* Switch Device into a Ready State */
+static int crb_switch_to_ready(void)
+{
+ /* Transition into ready state */
+ write8(CRB_REG(cur_loc, CRB_REG_REQUEST), 0x1);
+ int rc = crb_wait_for_reg32(CRB_REG(cur_loc, CRB_REG_REQUEST), 200,
+ CRB_REG_REQUEST_CMD_RDY, 0x0);
+ if (rc) {
+ printk(BIOS_ERR,
+ "TPM: Error - TPM did not transition into ready state in time.\n");
+ return -1;
+ }
+
+ /* Check TPM_CRB_CTRL_STS[0] to be "0" - no unrecoverable error */
+ rc = crb_wait_for_reg32(CRB_REG(cur_loc, CRB_REG_STATUS), 500, CRB_REG_STATUS_ERROR,
+ 0x0);
+ if (rc) {
+ printk(BIOS_ERR, "TPM: Fatal Error - Could not recover.\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+/*
+ * tpm2_init
+ *
+ * Even though the TPM does not need an initialization we check
+ * if the TPM responds and is in IDLE mode, which should be the
+ * normal bring up mode.
+ *
+ */
+int tpm2_init(void)
+{
+
+
+ if (crb_probe()) {
+ printk(BIOS_ERR, "TPM: Probe failed.\n");
+ return -1;
+ }
+
+ /* Read back control area structure */
+ crb_readControlArea();
+
+ /* Good to go. */
+ printk(BIOS_SPEW, "TPM: CRB TPM initialized successfully\n");
+
+ return 0;
+}
+
+/*
+ * tpm2_process_command
+ */
+size_t tpm2_process_command(const void *tpm2_command, size_t command_size, void *tpm2_response,
+ size_t max_response)
+{
+ int rc;
+
+ if (command_size > control_area.command_size) {
+ printk(BIOS_ERR, "TPM: Command size is too big.\n");
+ return -1;
+ }
+
+ if (control_area.response_size < max_response) {
+ printk(BIOS_ERR, "TPM: Response size could be too big.\n");
+ return -1;
+ }
+
+ cur_loc = crb_activate_locality();
+
+ // Check if CMD bit is cleared.
+ rc = crb_wait_for_reg32(CRB_REG(0, CRB_REG_START), 250, CRB_REG_START_START, 0x0);
+ if (rc) {
+ printk(BIOS_ERR, "TPM: Error - Cmd Bit not cleared.\n");
+ return -1;
+ }
+
+ if (crb_switch_to_ready())
+ return -1;
+
+ // Write to Command Buffer
+ memcpy(control_area.command_bfr, tpm2_command, command_size);
+
+ // Write Start Bit
+ write8(CRB_REG(cur_loc, CRB_REG_START), 0x1);
+
+ // Poll for Response
+ rc = crb_wait_for_reg32(CRB_REG(cur_loc, CRB_REG_START), 3500, CRB_REG_START_START, 0);
+ if (rc) {
+ printk(BIOS_DEBUG, "TPM: Command Timed out.\n");
+ return -1;
+ }
+
+ // Check for errors
+ rc = crb_wait_for_reg32(CRB_REG(cur_loc, CRB_REG_STATUS), 200, CRB_REG_STATUS_ERROR, 0);
+ if (rc) {
+ printk(BIOS_DEBUG, "TPM: Command errored.\n");
+ return -1;
+ }
+
+ // Get Response Length
+ uint32_t length = be32_to_cpu(read32(control_area.response_bfr + 2));
+
+ /* Response has to have at least 6 bytes */
+ if (length < 6)
+ return 1;
+
+ // Copy Response
+ memcpy(tpm2_response, control_area.response_bfr, length);
+
+ if (crb_switch_to_ready()) {
+ printk(BIOS_DEBUG, "TPM: Can not transition into ready state again.\n");
+ return -1;
+ }
+
+ return length;
+}
+
+/*
+ * tp2_get_info
+ *
+ * Returns information about the TPM
+ *
+ */
+void tpm2_get_info(struct tpm2_info *tpm2_info)
+{
+ uint64_t interfaceReg = read64(CRB_REG(cur_loc, CRB_REG_INTF_ID));
+
+ tpm2_info->vendor_id = (interfaceReg >> 48) & 0xFFFF;
+ tpm2_info->device_id = (interfaceReg >> 32) & 0xFFFF;
+ tpm2_info->revision = (interfaceReg >> 24) & 0xFF;
+}
diff --git a/src/drivers/crb/tpm.h b/src/drivers/crb/tpm.h
new file mode 100644
index 0000000000..9bbed198f0
--- /dev/null
+++ b/src/drivers/crb/tpm.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2016 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * This is a driver for a Command Response Buffer Interface
+ */
+
+/* CRB driver */
+/* address of locality 0 (CRB) */
+#define TPM_CRB_BASE_ADDRESS CONFIG_CRB_TPM_BASE_ADDRESS
+
+#define CRB_REG(LOCTY, REG) \
+ (void *)(CONFIG_CRB_TPM_BASE_ADDRESS + (LOCTY << 12) + REG)
+
+/* hardware registers */
+#define CRB_REG_LOC_STATE 0x00
+#define CRB_REG_LOC_CTRL 0x08
+#define CRB_REG_LOC_STS 0x0C
+
+/* LOC_CTRL BIT MASKS */
+#define LOC_CTRL_REQ_ACCESS 0x01
+
+/* LOC STATE BIT MASKS */
+#define LOC_STATE_LOC_ASSIGN 0x02
+#define LOC_STATE_REG_VALID_STS 0x80
+
+/* LOC STS BIT MASKS */
+#define LOC_STS_GRANTED 0x01
+
+#define CRB_REG_INTF_ID 0x30
+#define CRB_REG_REQUEST 0x40
+#define CRB_REG_STATUS 0x44
+#define CRB_REG_CANCEL 0x48
+#define CRB_REG_START 0x4C
+#define CRB_REG_INT_CTRL 0x50
+#define CRB_REG_CMD_SIZE 0x58
+#define CRB_REG_CMD_ADDR 0x5C
+#define CRB_REG_RESP_SIZE 0x64
+#define CRB_REG_RESP_ADDR 0x68
+
+/* CRB INTF BIT MASK */
+#define CRB_INTF_REG_CAP_CRB (1<<14)
+#define CRB_INTF_REG_INTF_SEL (1<<17)
+#define CRB_INTF_REG_INTF_LOCK (1<<19)
+
+
+/*REQUEST Register related */
+#define CRB_REG_REQUEST_CMD_RDY 0x01
+#define CRB_REG_REQUEST_GO_IDLE 0x02
+
+/* STATUS Register related */
+#define CRB_REG_STATUS_ERROR 0x01
+#define CRB_REG_STATUS_IDLE 0x02
+
+/* START Register related */
+#define CRB_REG_START_START 0x01
+
+/* TPM Info Struct */
+struct tpm2_info {
+ uint16_t vendor_id;
+ uint16_t device_id;
+ uint16_t revision;
+};
+
+
+int tpm2_init(void);
+void tpm2_get_info(struct tpm2_info *tpm2_info);
+size_t tpm2_process_command(const void *tpm2_command, size_t command_size,
+ void *tpm2_response, size_t max_response);
diff --git a/src/drivers/i2c/designware/dw_i2c.c b/src/drivers/i2c/designware/dw_i2c.c
index 93b662a63d..760a735380 100644
--- a/src/drivers/i2c/designware/dw_i2c.c
+++ b/src/drivers/i2c/designware/dw_i2c.c
@@ -817,14 +817,9 @@ void dw_i2c_acpi_fill_ssdt(struct device *dev)
const struct dw_i2c_bus_config *bcfg;
uintptr_t dw_i2c_addr;
struct dw_i2c_speed_config sgen;
- enum i2c_speed speeds[DW_I2C_SPEED_CONFIG_COUNT] = {
- I2C_SPEED_STANDARD,
- I2C_SPEED_FAST,
- I2C_SPEED_FAST_PLUS,
- I2C_SPEED_HIGH,
- };
- int i, bus;
+ int bus;
const char *path;
+ unsigned int speed;
if (!dev->enabled)
return;
@@ -847,20 +842,15 @@ void dw_i2c_acpi_fill_ssdt(struct device *dev)
if (!path)
return;
- acpigen_write_scope(path);
+ /* Ensure a default speed is available */
+ speed = (bcfg->speed == 0) ? I2C_SPEED_FAST : bcfg->speed;
/* Report timing values for the OS driver */
- for (i = 0; i < DW_I2C_SPEED_CONFIG_COUNT; i++) {
- /* Generate speed config. */
- if (dw_i2c_gen_speed_config(dw_i2c_addr, speeds[i], bcfg,
- &sgen) < 0)
- continue;
-
- /* Generate ACPI based on selected speed config */
+ if (dw_i2c_gen_speed_config(dw_i2c_addr, speed, bcfg, &sgen) >= 0) {
+ acpigen_write_scope(path);
dw_i2c_acpi_write_speed_config(&sgen);
+ acpigen_pop_len();
}
-
- acpigen_pop_len();
}
static int dw_i2c_dev_transfer(struct device *dev,
diff --git a/src/drivers/intel/fsp1_1/Makefile.inc b/src/drivers/intel/fsp1_1/Makefile.inc
index 10877b9482..1372e98565 100644
--- a/src/drivers/intel/fsp1_1/Makefile.inc
+++ b/src/drivers/intel/fsp1_1/Makefile.inc
@@ -29,7 +29,6 @@ romstage-y += fsp_util.c
romstage-y += hob.c
romstage-y += raminit.c
romstage-y += romstage.c
-romstage-y += stage_cache.c
romstage-$(CONFIG_MMA) += mma_core.c
ramstage-$(CONFIG_RUN_FSP_GOP) += fsp_gop.c
@@ -37,13 +36,11 @@ ramstage-y += fsp_relocate.c
ramstage-y += fsp_util.c
ramstage-y += hob.c
ramstage-y += ramstage.c
-ramstage-y += stage_cache.c
ramstage-$(CONFIG_INTEL_GMA_ADD_VBT) += vbt.c
ramstage-$(CONFIG_MMA) += mma_core.c
CPPFLAGS_common += -Isrc/drivers/intel/fsp1_1/include
-postcar-y += stage_cache.c
ifneq ($(CONFIG_SKIP_FSP_CAR),y)
postcar-y += temp_ram_exit.c
postcar-y += exit_car.S
diff --git a/src/drivers/intel/fsp1_1/car.c b/src/drivers/intel/fsp1_1/car.c
index 19eb041eac..1b6f62c351 100644
--- a/src/drivers/intel/fsp1_1/car.c
+++ b/src/drivers/intel/fsp1_1/car.c
@@ -19,9 +19,9 @@
#include
#include
#include
+#include
#include
#include
-#include
#include
/* platform_enter_postcar() determines the stack to use after
diff --git a/src/drivers/intel/fsp1_1/include/fsp/memmap.h b/src/drivers/intel/fsp1_1/include/fsp/memmap.h
deleted file mode 100644
index 965bce646e..0000000000
--- a/src/drivers/intel/fsp1_1/include/fsp/memmap.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2015-2016 Intel Corporation.
- *
- * 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; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
-
-#ifndef _COMMON_MEMMAP_H_
-#define _COMMON_MEMMAP_H_
-
-#include
-
-/*
- * mmap_region_granularity must to return a size which is a positive non-zero
- * integer multiple of the SMM size when SMM is in use. When not using SMM,
- * this value should be set to 8 MiB.
- */
-size_t mmap_region_granularity(void);
-
-/* Fills in the arguments for the entire SMM region covered by chipset
- * protections. e.g. TSEG. */
-void smm_region(void **start, size_t *size);
-
-enum {
- /* SMM handler area. */
- SMM_SUBREGION_HANDLER,
- /* SMM cache region. */
- SMM_SUBREGION_CACHE,
- /* Chipset specific area. */
- SMM_SUBREGION_CHIPSET,
- /* Total sub regions supported. */
- SMM_SUBREGION_NUM,
-};
-
-/* Fills in the start and size for the requested SMM subregion. Returns
- * 0 on susccess, < 0 on failure. */
-int smm_subregion(int sub, void **start, size_t *size);
-
-#endif /* _COMMON_MEMMAP_H_ */
diff --git a/src/drivers/intel/fsp1_1/raminit.c b/src/drivers/intel/fsp1_1/raminit.c
index e71c9a2ddf..7b893d269e 100644
--- a/src/drivers/intel/fsp1_1/raminit.c
+++ b/src/drivers/intel/fsp1_1/raminit.c
@@ -19,7 +19,7 @@
#include
#include
#include
-#include
+#include
#include
#include
#include /* hexdump */
@@ -53,7 +53,7 @@ void raminit(struct romstage_params *params)
UPD_DATA_REGION *upd_ptr;
int fsp_verification_failure = 0;
EFI_PEI_HOB_POINTERS hob_ptr;
- char *smm_base;
+ uintptr_t smm_base;
size_t smm_size;
/*
@@ -148,9 +148,9 @@ void raminit(struct romstage_params *params)
/* Display SMM area */
if (CONFIG(HAVE_SMI_HANDLER)) {
- smm_region((void **)&smm_base, &smm_size);
+ smm_region(&smm_base, &smm_size);
printk(BIOS_DEBUG, "0x%08x: smm_size\n", (unsigned int)smm_size);
- printk(BIOS_DEBUG, "0x%p: smm_base\n", smm_base);
+ printk(BIOS_DEBUG, "0x%08x: smm_base\n", (unsigned int)smm_base);
}
/* Migrate CAR data */
@@ -238,7 +238,7 @@ void raminit(struct romstage_params *params)
printk(BIOS_ERR, "ERROR - Reserving FSP memory area!\n");
if (CONFIG(HAVE_SMI_HANDLER) && cbmem_root != NULL) {
- size_t delta_bytes = (unsigned int)smm_base
+ size_t delta_bytes = smm_base
- cbmem_root->PhysicalStart
- cbmem_root->ResourceLength;
printk(BIOS_ERR,
@@ -259,7 +259,7 @@ void raminit(struct romstage_params *params)
/* Locate the memory configuration data to speed up the next reboot */
mrc_hob = get_next_guid_hob(&mrc_guid, hob_list_ptr);
- if ((mrc_hob == NULL) && CONFIG(DISPLAY_HOBS))
+ if (mrc_hob == NULL)
printk(BIOS_DEBUG,
"Memory Configuration Data Hob not present\n");
else if (!vboot_recovery_mode_enabled()) {
diff --git a/src/drivers/intel/fsp1_1/ramstage.c b/src/drivers/intel/fsp1_1/ramstage.c
index 52a886ce30..4b567da188 100644
--- a/src/drivers/intel/fsp1_1/ramstage.c
+++ b/src/drivers/intel/fsp1_1/ramstage.c
@@ -17,7 +17,7 @@
#include
#include
#include
-#include
+#include
#include
#include
#include
@@ -33,19 +33,19 @@ __weak void soc_after_silicon_init(void)
/* Display SMM memory map */
static void smm_memory_map(void)
{
- void *base;
+ uintptr_t base;
size_t size;
int i;
printk(BIOS_SPEW, "SMM Memory Map\n");
smm_region(&base, &size);
- printk(BIOS_SPEW, "SMRAM : %p 0x%zx\n", base, size);
+ printk(BIOS_SPEW, "SMRAM : 0x%zx 0x%zx\n", base, size);
for (i = 0; i < SMM_SUBREGION_NUM; i++) {
if (smm_subregion(i, &base, &size))
continue;
- printk(BIOS_SPEW, " Subregion %d: %p 0x%zx\n", i, base, size);
+ printk(BIOS_SPEW, " Subregion %d: 0x%zx 0x%zx\n", i, base, size);
}
}
diff --git a/src/drivers/intel/fsp2_0/include/fsp/memmap.h b/src/drivers/intel/fsp2_0/include/fsp/memmap.h
deleted file mode 100644
index 965bce646e..0000000000
--- a/src/drivers/intel/fsp2_0/include/fsp/memmap.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2015-2016 Intel Corporation.
- *
- * 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; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
-
-#ifndef _COMMON_MEMMAP_H_
-#define _COMMON_MEMMAP_H_
-
-#include
-
-/*
- * mmap_region_granularity must to return a size which is a positive non-zero
- * integer multiple of the SMM size when SMM is in use. When not using SMM,
- * this value should be set to 8 MiB.
- */
-size_t mmap_region_granularity(void);
-
-/* Fills in the arguments for the entire SMM region covered by chipset
- * protections. e.g. TSEG. */
-void smm_region(void **start, size_t *size);
-
-enum {
- /* SMM handler area. */
- SMM_SUBREGION_HANDLER,
- /* SMM cache region. */
- SMM_SUBREGION_CACHE,
- /* Chipset specific area. */
- SMM_SUBREGION_CHIPSET,
- /* Total sub regions supported. */
- SMM_SUBREGION_NUM,
-};
-
-/* Fills in the start and size for the requested SMM subregion. Returns
- * 0 on susccess, < 0 on failure. */
-int smm_subregion(int sub, void **start, size_t *size);
-
-#endif /* _COMMON_MEMMAP_H_ */
diff --git a/src/drivers/intel/gma/Kconfig b/src/drivers/intel/gma/Kconfig
index 59a9e8aa5b..75d268723b 100644
--- a/src/drivers/intel/gma/Kconfig
+++ b/src/drivers/intel/gma/Kconfig
@@ -54,6 +54,9 @@ config INTEL_GMA_SWSMISCI
Select this option for Atom-based platforms which use the SWSMISCI
register (0xe0) rather than the SWSCI register (0xe8).
+config INTEL_GMA_LIBGFXINIT_EDID
+ bool
+
config GFX_GMA_ANALOG_I2C_HDMI_B
bool
@@ -68,8 +71,10 @@ config GFX_GMA
depends on NORTHBRIDGE_INTEL_GM45 || NORTHBRIDGE_INTEL_X4X \
|| NORTHBRIDGE_INTEL_NEHALEM || NORTHBRIDGE_INTEL_SANDYBRIDGE \
|| NORTHBRIDGE_INTEL_HASWELL \
- || SOC_INTEL_BROADWELL || SOC_INTEL_SKYLAKE || SOC_INTEL_APOLLOLAKE
- depends on MAINBOARD_USE_LIBGFXINIT
+ || SOC_INTEL_BROADWELL || SOC_INTEL_SKYLAKE || SOC_INTEL_APOLLOLAKE \
+ || SOC_INTEL_KABYLAKE || SOC_INTEL_COFFEELAKE \
+ || SOC_INTEL_WHISKEYLAKE
+ depends on MAINBOARD_USE_LIBGFXINIT || INTEL_GMA_LIBGFXINIT_EDID
select RAMSTAGE_LIBHWBASE
config GFX_GMA_INTERNAL_IS_EDP
@@ -94,7 +99,8 @@ config GFX_GMA_DYN_CPU
config GFX_GMA_GENERATION
string
default "Broxton" if SOC_INTEL_APOLLOLAKE
- default "Skylake" if SOC_INTEL_SKYLAKE
+ default "Skylake" if SOC_INTEL_SKYLAKE || SOC_INTEL_KABYLAKE || \
+ SOC_INTEL_COFFEELAKE || SOC_INTEL_WHISKEYLAKE
default "Haswell" if NORTHBRIDGE_INTEL_HASWELL || SOC_INTEL_BROADWELL
default "Ironlake" if NORTHBRIDGE_INTEL_NEHALEM || NORTHBRIDGE_INTEL_SANDYBRIDGE
default "G45" if NORTHBRIDGE_INTEL_GM45 || NORTHBRIDGE_INTEL_X4X
diff --git a/src/drivers/intel/gma/Makefile.inc b/src/drivers/intel/gma/Makefile.inc
index e128ad6474..cea319e976 100644
--- a/src/drivers/intel/gma/Makefile.inc
+++ b/src/drivers/intel/gma/Makefile.inc
@@ -50,7 +50,7 @@ CONFIG_GFX_GMA_DEFAULT_MMIO := 0 # dummy, will be overwritten at runtime
subdirs-y += ../../../../3rdparty/libgfxinit
-ramstage-y += gma.ads
+ramstage-y += gma.ads gma.adb
ramstage-$(CONFIG_MAINBOARD_USE_LIBGFXINIT) += gma-gfx_init.ads
ifeq ($(CONFIG_LINEAR_FRAMEBUFFER),y)
diff --git a/src/drivers/intel/gma/gma.adb b/src/drivers/intel/gma/gma.adb
new file mode 100644
index 0000000000..10885e6e09
--- /dev/null
+++ b/src/drivers/intel/gma/gma.adb
@@ -0,0 +1,37 @@
+with HW.GFX.GMA;
+with HW.GFX.GMA.Display_Probing;
+
+use HW.GFX.GMA;
+
+package body GMA is
+
+ function read_edid
+ (raw_edid : out HW.GFX.EDID.Raw_EDID_Data;
+ port : in Interfaces.C.int)
+ return Interfaces.C.int
+ is
+ use type Interfaces.C.int;
+ success : Boolean := true;
+ begin
+ if port not in Active_Port_Type'Pos (Active_Port_Type'First)
+ .. Active_Port_Type'Pos (Active_Port_Type'Last)
+ then
+ raw_edid := (others => 0);
+ return -2;
+ else
+ if not HW.GFX.GMA.Is_Initialized then
+ HW.GFX.GMA.Initialize (Success => success);
+ end if;
+ if success then
+ HW.GFX.GMA.Display_Probing.Read_EDID
+ (raw_edid, Active_Port_Type'Val (port), success);
+ end if;
+ if success then
+ return 0;
+ else
+ return -1;
+ end if;
+ end if;
+ end read_edid;
+
+end GMA;
diff --git a/src/drivers/intel/gma/gma.ads b/src/drivers/intel/gma/gma.ads
index a6ce3a4f77..0b4b66bde7 100644
--- a/src/drivers/intel/gma/gma.ads
+++ b/src/drivers/intel/gma/gma.ads
@@ -1,2 +1,14 @@
+with Interfaces.C;
+
+with HW.GFX.EDID;
+
package GMA is
+
+ function read_edid
+ (raw_edid : out HW.GFX.EDID.Raw_EDID_Data;
+ Port : in Interfaces.C.int)
+ return Interfaces.C.int
+ with
+ Export, Convention => C, External_Name => "gma_read_edid";
+
end GMA;
diff --git a/src/drivers/intel/gma/libgfxinit.h b/src/drivers/intel/gma/libgfxinit.h
index c67870e4e0..c4a8a5b4d2 100644
--- a/src/drivers/intel/gma/libgfxinit.h
+++ b/src/drivers/intel/gma/libgfxinit.h
@@ -14,6 +14,19 @@
#ifndef DRIVERS_INTEL_GMA_LIBGFXINIT_H
#define DRIVERS_INTEL_GMA_LIBGFXINIT_H
+enum {
+ GMA_PORT_DISABLED,
+ GMA_PORT_INTERNAL,
+ GMA_PORT_DP1,
+ GMA_PORT_DP2,
+ GMA_PORT_DP3,
+ GMA_PORT_HDMI1, /* or DVI */
+ GMA_PORT_HDMI2, /* or DVI */
+ GMA_PORT_HDMI3, /* or DVI */
+ GMA_PORT_ANALOG,
+};
+
void gma_gfxinit(int *lightup_ok);
+int gma_read_edid(unsigned char edid[], int port);
#endif
diff --git a/src/drivers/intel/ptt/Kconfig b/src/drivers/intel/ptt/Kconfig
new file mode 100644
index 0000000000..fb70f9a02c
--- /dev/null
+++ b/src/drivers/intel/ptt/Kconfig
@@ -0,0 +1,6 @@
+config HAVE_INTEL_PTT
+ bool
+ default n
+ select VBOOT_MOCK_SECDATA if VBOOT
+ help
+ Activate if your platform has Intel Platform Trust Technology like Intel iTPM and you want to use it.
diff --git a/src/drivers/intel/ptt/Makefile.inc b/src/drivers/intel/ptt/Makefile.inc
new file mode 100644
index 0000000000..fdecc89b9f
--- /dev/null
+++ b/src/drivers/intel/ptt/Makefile.inc
@@ -0,0 +1,4 @@
+romstage-$(CONFIG_HAVE_INTEL_PTT) += ptt.c
+ramstage-$(CONFIG_HAVE_INTEL_PTT) += ptt.c
+postcar-$(CONFIG_HAVE_INTEL_PTT) += ptt.c
+verstage-$(CONFIG_HAVE_INTEL_PTT) += ptt.c
diff --git a/src/drivers/intel/ptt/ptt.c b/src/drivers/intel/ptt/ptt.c
new file mode 100644
index 0000000000..738de50a8f
--- /dev/null
+++ b/src/drivers/intel/ptt/ptt.c
@@ -0,0 +1,53 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include
+#include
+#include
+#include
+
+#include "ptt.h"
+
+#define PCI_ME_HFSTS4 0x64
+#define PTT_ENABLE (1 << 19)
+
+/* Dump Intel ME register */
+static uint32_t read_register(int reg_addr)
+{
+ if (!PCH_DEV_CSE)
+ return 0xFFFFFFFF;
+
+ return pci_read_config32(PCH_DEV_CSE, reg_addr);
+}
+
+/*
+ * ptt_active()
+ *
+ * Check if PTT Flag is set - so that PTT is active.
+ *
+ * Return true if active, false otherwise.
+ */
+bool ptt_active(void)
+{
+ uint32_t fwsts4 = read_register(PCI_ME_HFSTS4);
+
+ if (fwsts4 == 0xFFFFFFFF)
+ return false;
+
+ if ((fwsts4 & PTT_ENABLE) == 0) {
+ printk(BIOS_DEBUG, "Intel ME Establishment bit not valid.\n");
+ return false;
+ }
+
+ return true;
+}
diff --git a/src/northbridge/intel/gm45/stage_cache.c b/src/drivers/intel/ptt/ptt.h
similarity index 52%
rename from src/northbridge/intel/gm45/stage_cache.c
rename to src/drivers/intel/ptt/ptt.h
index 47f08c1397..ed5e90f599 100644
--- a/src/northbridge/intel/gm45/stage_cache.c
+++ b/src/drivers/intel/ptt/ptt.h
@@ -1,8 +1,6 @@
/*
* This file is part of the coreboot project.
*
- * Copyright 2015 Google, Inc.
- *
* 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; version 2 of the License.
@@ -11,19 +9,19 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
+ *
+ * This driver checks if the PTT Bit is set correctly within the FWSTS4
+ * register. This is needed in order to use the iTPM, because we have to
+ * check prior using the interface that this bit is set correctly - otherwise
+ * it could work unpredictable. The bit should already be set if the Intel ME
+ * is still in the preboot phase.
+ *
*/
-
#include
-#include
-#include
-
-void stage_cache_external_region(void **base, size_t *size)
-{
- /*
- * The ramstage cache lives in the TSEG region at RESERVED_SMM_OFFSET.
- * The top of RAM is defined to be the TSEG base address.
- */
- *size = CONFIG_SMM_RESERVED_SIZE;
- *base = (void *)(northbridge_get_tseg_base()
- + CONFIG_SMM_RESERVED_SIZE);
-}
+/*
+ * ptt_active
+ *
+ * Checks if the Intel PTT is active. If PTT is active, returns true,
+ * false otherwise.
+ */
+bool ptt_active(void);
diff --git a/src/drivers/ipmi/chip.h b/src/drivers/ipmi/chip.h
index eb8b4e6d34..1c5afe7b59 100644
--- a/src/drivers/ipmi/chip.h
+++ b/src/drivers/ipmi/chip.h
@@ -24,6 +24,17 @@ struct drivers_ipmi_config {
u8 gpe_interrupt;
u8 have_apic;
u32 apic_interrupt;
+ /*
+ * Wait for BMC to boot.
+ * This can be used if the BMC takes a long time to boot after PoR:
+ * AST2400 on Supermicro X11SSH: 34 s
+ */
+ bool wait_for_bmc;
+ /*
+ * The timeout in seconds to wait for the IPMI service to be loaded.
+ * Will be used if wait_for_bmc is true.
+ */
+ u16 bmc_boot_timeout;
};
#endif /* _IMPI_CHIP_H_ */
diff --git a/src/drivers/ipmi/ipmi_kcs_ops.c b/src/drivers/ipmi/ipmi_kcs_ops.c
index 0cc4e0a965..21102bb74e 100644
--- a/src/drivers/ipmi/ipmi_kcs_ops.c
+++ b/src/drivers/ipmi/ipmi_kcs_ops.c
@@ -32,6 +32,7 @@
#endif
#include
#include
+#include
#include "ipmi_kcs.h"
#include "chip.h"
@@ -62,12 +63,37 @@ static void ipmi_kcs_init(struct device *dev)
{
struct ipmi_devid_rsp rsp;
uint32_t man_id = 0, prod_id = 0;
+ struct drivers_ipmi_config *conf = NULL;
if (!dev->enabled)
return;
+ printk(BIOS_DEBUG, "IPMI: PNP KCS 0x%x\n", dev->path.pnp.port);
+
+ if (dev->chip_info)
+ conf = dev->chip_info;
+
/* Get IPMI version for ACPI and SMBIOS */
+ if (conf && conf->wait_for_bmc && conf->bmc_boot_timeout) {
+ struct stopwatch sw;
+ stopwatch_init_msecs_expire(&sw, conf->bmc_boot_timeout * 1000);
+ printk(BIOS_DEBUG, "IPMI: Waiting for BMC...\n");
+
+ while (!stopwatch_expired(&sw)) {
+ if (inb(dev->path.pnp.port) != 0xff)
+ break;
+ mdelay(100);
+ }
+ if (stopwatch_expired(&sw)) {
+ printk(BIOS_INFO, "IPMI: Waiting for BMC timed out\n");
+ /* Don't write tables if communication failed */
+ dev->enabled = 0;
+ return;
+ }
+ }
+
if (!ipmi_get_device_id(dev, &rsp)) {
+ /* Queried the IPMI revision from BMC */
ipmi_revision_minor = IPMI_IPMI_VERSION_MINOR(rsp.ipmi_version);
ipmi_revision_major = IPMI_IPMI_VERSION_MAJOR(rsp.ipmi_version);
diff --git a/src/drivers/spi/adesto.c b/src/drivers/spi/adesto.c
index 4e1043edb7..c74fd701c9 100644
--- a/src/drivers/spi/adesto.c
+++ b/src/drivers/spi/adesto.c
@@ -181,7 +181,8 @@ static int adesto_write(const struct spi_flash *flash, u32 offset, size_t len,
goto out;
}
- ret = spi_flash_cmd_wait_ready(flash, SPI_FLASH_PROG_TIMEOUT);
+ ret = spi_flash_cmd_wait_ready(flash,
+ SPI_FLASH_PROG_TIMEOUT_MS);
if (ret)
goto out;
diff --git a/src/drivers/spi/amic.c b/src/drivers/spi/amic.c
index b580dc3df0..6e1234baa7 100644
--- a/src/drivers/spi/amic.c
+++ b/src/drivers/spi/amic.c
@@ -155,7 +155,8 @@ static int amic_write(const struct spi_flash *flash, u32 offset, size_t len,
goto out;
}
- ret = spi_flash_cmd_wait_ready(flash, SPI_FLASH_PROG_TIMEOUT);
+ ret = spi_flash_cmd_wait_ready(flash,
+ SPI_FLASH_PROG_TIMEOUT_MS);
if (ret)
goto out;
diff --git a/src/drivers/spi/atmel.c b/src/drivers/spi/atmel.c
index 58a2862eeb..ac7f0d92e7 100644
--- a/src/drivers/spi/atmel.c
+++ b/src/drivers/spi/atmel.c
@@ -137,7 +137,8 @@ static int atmel_write(const struct spi_flash *flash, u32 offset, size_t len,
goto out;
}
- ret = spi_flash_cmd_wait_ready(flash, SPI_FLASH_PROG_TIMEOUT);
+ ret = spi_flash_cmd_wait_ready(flash,
+ SPI_FLASH_PROG_TIMEOUT_MS);
if (ret)
goto out;
diff --git a/src/drivers/spi/eon.c b/src/drivers/spi/eon.c
index f3cf70ef1b..c6fdba17b8 100644
--- a/src/drivers/spi/eon.c
+++ b/src/drivers/spi/eon.c
@@ -270,7 +270,8 @@ static int eon_write(const struct spi_flash *flash,
goto out;
}
- ret = spi_flash_cmd_wait_ready(flash, SPI_FLASH_PROG_TIMEOUT);
+ ret = spi_flash_cmd_wait_ready(flash,
+ SPI_FLASH_PROG_TIMEOUT_MS);
if (ret) {
printk(BIOS_WARNING, "SF: EON Page Program timeout\n");
goto out;
diff --git a/src/drivers/spi/gigadevice.c b/src/drivers/spi/gigadevice.c
index 1ff594a24a..71433cc1ed 100644
--- a/src/drivers/spi/gigadevice.c
+++ b/src/drivers/spi/gigadevice.c
@@ -212,7 +212,8 @@ static int gigadevice_write(const struct spi_flash *flash, u32 offset,
goto out;
}
- ret = spi_flash_cmd_wait_ready(flash, SPI_FLASH_PROG_TIMEOUT);
+ ret = spi_flash_cmd_wait_ready(flash,
+ SPI_FLASH_PROG_TIMEOUT_MS);
if (ret)
goto out;
diff --git a/src/drivers/spi/macronix.c b/src/drivers/spi/macronix.c
index 5a97b8f794..a41e96f671 100644
--- a/src/drivers/spi/macronix.c
+++ b/src/drivers/spi/macronix.c
@@ -249,7 +249,8 @@ static int macronix_write(const struct spi_flash *flash, u32 offset, size_t len,
break;
}
- ret = spi_flash_cmd_wait_ready(flash, SPI_FLASH_PROG_TIMEOUT);
+ ret = spi_flash_cmd_wait_ready(flash,
+ SPI_FLASH_PROG_TIMEOUT_MS);
if (ret)
break;
diff --git a/src/drivers/spi/spansion.c b/src/drivers/spi/spansion.c
index 4a241baf09..c3a071e956 100644
--- a/src/drivers/spi/spansion.c
+++ b/src/drivers/spi/spansion.c
@@ -264,7 +264,8 @@ static int spansion_write(const struct spi_flash *flash, u32 offset, size_t len,
break;
}
- ret = spi_flash_cmd_wait_ready(flash, SPI_FLASH_PROG_TIMEOUT);
+ ret = spi_flash_cmd_wait_ready(flash,
+ SPI_FLASH_PROG_TIMEOUT_MS);
if (ret)
break;
diff --git a/src/drivers/spi/spi_flash.c b/src/drivers/spi/spi_flash.c
index a81306e386..cfa500e6dd 100644
--- a/src/drivers/spi/spi_flash.c
+++ b/src/drivers/spi/spi_flash.c
@@ -232,7 +232,8 @@ int spi_flash_cmd_erase(const struct spi_flash *flash, u32 offset, size_t len)
if (ret)
goto out;
- ret = spi_flash_cmd_wait_ready(flash, SPI_FLASH_PAGE_ERASE_TIMEOUT);
+ ret = spi_flash_cmd_wait_ready(flash,
+ SPI_FLASH_PAGE_ERASE_TIMEOUT_MS);
if (ret)
goto out;
}
diff --git a/src/drivers/spi/spi_flash_internal.h b/src/drivers/spi/spi_flash_internal.h
index 4a9e289029..95c51a8b05 100644
--- a/src/drivers/spi/spi_flash_internal.h
+++ b/src/drivers/spi/spi_flash_internal.h
@@ -7,15 +7,6 @@
#ifndef SPI_FLASH_INTERNAL_H
#define SPI_FLASH_INTERNAL_H
-/* Common parameters -- kind of high, but they should only occur when there
- * is a problem (and well your system already is broken), so err on the side
- * of caution in case we're dealing with slower SPI buses and/or processors.
- */
-#define CONF_SYS_HZ 100
-#define SPI_FLASH_PROG_TIMEOUT (2 * CONF_SYS_HZ)
-#define SPI_FLASH_PAGE_ERASE_TIMEOUT (5 * CONF_SYS_HZ)
-#define SPI_FLASH_SECTOR_ERASE_TIMEOUT (10 * CONF_SYS_HZ)
-
/* Common commands */
#define CMD_READ_ID 0x9f
diff --git a/src/drivers/spi/sst.c b/src/drivers/spi/sst.c
index abe3f2ace6..429afa095d 100644
--- a/src/drivers/spi/sst.c
+++ b/src/drivers/spi/sst.c
@@ -179,7 +179,7 @@ sst_byte_write(const struct spi_flash *flash, u32 offset, const void *buf)
if (ret)
return ret;
- return spi_flash_cmd_wait_ready(flash, SPI_FLASH_PROG_TIMEOUT);
+ return spi_flash_cmd_wait_ready(flash, SPI_FLASH_PROG_TIMEOUT_MS);
}
static int sst_write_256(const struct spi_flash *flash, u32 offset, size_t len,
@@ -239,7 +239,8 @@ static int sst_write_256(const struct spi_flash *flash, u32 offset, size_t len,
break;
}
- ret = spi_flash_cmd_wait_ready(flash, SPI_FLASH_PROG_TIMEOUT);
+ ret = spi_flash_cmd_wait_ready(flash,
+ SPI_FLASH_PROG_TIMEOUT_MS);
if (ret)
break;
@@ -294,7 +295,8 @@ static int sst_write_ai(const struct spi_flash *flash, u32 offset, size_t len,
break;
}
- ret = spi_flash_cmd_wait_ready(flash, SPI_FLASH_PROG_TIMEOUT);
+ ret = spi_flash_cmd_wait_ready(flash,
+ SPI_FLASH_PROG_TIMEOUT_MS);
if (ret)
break;
diff --git a/src/drivers/spi/stmicro.c b/src/drivers/spi/stmicro.c
index 6625764268..98f6e4e5b2 100644
--- a/src/drivers/spi/stmicro.c
+++ b/src/drivers/spi/stmicro.c
@@ -331,7 +331,8 @@ static int stmicro_write(const struct spi_flash *flash,
goto out;
}
- ret = spi_flash_cmd_wait_ready(flash, SPI_FLASH_PROG_TIMEOUT);
+ ret = spi_flash_cmd_wait_ready(flash,
+ SPI_FLASH_PROG_TIMEOUT_MS);
if (ret)
goto out;
diff --git a/src/drivers/spi/winbond.c b/src/drivers/spi/winbond.c
index 9e9bb00464..3e0a2669d9 100644
--- a/src/drivers/spi/winbond.c
+++ b/src/drivers/spi/winbond.c
@@ -326,7 +326,8 @@ static int winbond_write(const struct spi_flash *flash, u32 offset, size_t len,
goto out;
}
- ret = spi_flash_cmd_wait_ready(flash, SPI_FLASH_PROG_TIMEOUT);
+ ret = spi_flash_cmd_wait_ready(flash,
+ SPI_FLASH_PROG_TIMEOUT_MS);
if (ret)
goto out;
diff --git a/src/drivers/xpowers/axp209/Kconfig b/src/drivers/xpowers/axp209/Kconfig
deleted file mode 100644
index 684873c127..0000000000
--- a/src/drivers/xpowers/axp209/Kconfig
+++ /dev/null
@@ -1,15 +0,0 @@
-config DRIVER_XPOWERS_AXP209
- bool
- default n
- help
- X-Powers AXP902 Power Management Unit
-
-if DRIVER_XPOWERS_AXP209
-
-config DRIVER_XPOWERS_AXP209_BOOTBLOCK
- bool
- default n
- help
- Make AXP209 functionality available in he bootblock.
-
-endif # DRIVER_XPOWERS_AXP209
diff --git a/src/drivers/xpowers/axp209/Makefile.inc b/src/drivers/xpowers/axp209/Makefile.inc
deleted file mode 100644
index e08a8e21a6..0000000000
--- a/src/drivers/xpowers/axp209/Makefile.inc
+++ /dev/null
@@ -1,7 +0,0 @@
-ifeq ($(CONFIG_DRIVER_XPOWERS_AXP209),y)
-
-bootblock-$(CONFIG_DRIVER_XPOWERS_AXP209_BOOTBLOCK) += axp209.c
-romstage-y += axp209.c
-ramstage-y += axp209.c
-
-endif
diff --git a/src/drivers/xpowers/axp209/axp209.c b/src/drivers/xpowers/axp209/axp209.c
deleted file mode 100644
index 93e864dff7..0000000000
--- a/src/drivers/xpowers/axp209/axp209.c
+++ /dev/null
@@ -1,324 +0,0 @@
-/*
- * Driver for X-Powers AXP 209 Power Management Unit
- *
- * Despite axp209_read/write only working on a byte at a time, there is no such
- * limitation in the AXP209.
- *
- * Copyright (C) 2013 Alexandru Gagniuc
- * Subject to the GNU GPL v2, or (at your option) any later version.
- */
-
-#include
-#include
-#include
-#include
-
-#include "axp209.h"
-#include "chip.h"
-
-/* Hide these definitions from the rest of the source, so keep them here */
-enum registers {
- REG_POWER_STATUS = 0x00,
- REG_POWER_MODE = 0x01,
- REG_OTG_VBUS = 0x02,
- REG_CHIP_ID = 0x03,
- REG_CHIP_PWROUT_CTL = 0x12,
- REG_DCDC2_VOLTAGE = 0x23,
- REG_DCDC2_LDO3_CTL = 0x25,
- REG_DCDC3_VOLTAGE = 0x27,
- REG_LDO24_VOLTAGE = 0x28,
- REG_LDO3_VOLTAGE = 0x29,
- REG_VBUS_IPSOUT = 0x30,
- REG_PWROFF_VOLTAGE = 0x31,
- REG_SHTDWN_SETTING = 0x32,
-};
-
-/* REG_LDO24_VOLTAGE definitions */
-#define REG_LDO24_VOLTAGE_LDO2_MASK (0xf << 4)
-#define REG_LDO24_VOLTAGE_LDO2_VAL(x) ((x << 4) & REG_LDO24_VOLTAGE_LDO2_MASK)
-#define REG_LDO24_VOLTAGE_LDO4_MASK (0xf << 0)
-#define REG_LDO24_VOLTAGE_LDO4_VAL(x) ((x << 0) & REG_LDO24_VOLTAGE_LDO4_MASK)
-
-/*
- * Read and write accessors. We only work on one register at a time, but there
- * is no limitation on the AXP209 as to how many registers we may read or write
- * in one transaction.
- * These return the number of bytes read/written, or an error code. In this
- * case, they return 1 on success, or an error code otherwise. This is done to
- * work with I2C drivers that return either 0 on success or the number of bytes
- * actually transferred.
- */
-static int axp209_read(u8 bus, u8 reg, u8 *val)
-{
- if (i2c_readb(bus, AXP209_I2C_ADDR, reg, val) < 0)
- return CB_ERR;
- return 1;
-}
-
-static int axp209_write(u8 bus, u8 reg, u8 val)
-{
- if (i2c_writeb(bus, AXP209_I2C_ADDR, reg, val) < 0)
- return CB_ERR;
- return 1;
-}
-
-/**
- * \brief Identify and initialize an AXP209 on the I2C bus
- *
- * @param[in] bus I2C bus to which the AXP209 is connected
- * @return CB_SUCCES on if an AXP209 is found, or an error code otherwise.
- */
-enum cb_err axp209_init(u8 bus)
-{
- u8 id;
-
- if (axp209_read(bus, REG_CHIP_ID, &id) != 1)
- return CB_ERR;
-
- /* From U-Boot code : Low 4 bits is chip version */
- if ((id & 0x0f) != 0x1) {
- printk(BIOS_ERR, "[axp209] ID 0x%x does not match\n", id);
- return CB_ERR;
- }
-
- return CB_SUCCESS;
-}
-
-/**
- * \brief Configure the output voltage of DC-DC2 converter
- *
- * If the requested voltage is not available, the next lowest voltage will
- * be applied.
- * Valid values are between 700mV and 2275mV
- *
- * @param[in] millivolts voltage in mV units.
- * @param[in] bus I2C bus to which the AXP209 is connected
- * @return CB_SUCCES on success,
- * CB_ERR_ARG if voltage is out of range, or an error code otherwise.
- */
-enum cb_err axp209_set_dcdc2_voltage(u8 bus, u16 millivolts)
-{
- u8 val;
-
- if (millivolts < 700 || millivolts > 2275)
- return CB_ERR_ARG;
-
- val = (millivolts - 700) / 25;
-
- if (axp209_write(bus, REG_DCDC2_VOLTAGE, val) != 1)
- return CB_ERR;
-
- return CB_SUCCESS;
-}
-
-/**
- * \brief Configure the output voltage of DC-DC3 converter
- *
- * If the requested voltage is not available, the next lowest voltage will
- * be applied.
- * Valid values are between 700mV and 3500mV
- *
- * @param[in] millivolts voltage in mV units.
- * @param[in] bus I2C bus to which the AXP209 is connected
- * @return CB_SUCCES on success,
- * CB_ERR_ARG if voltage is out of range, or an error code otherwise.
- */
-enum cb_err axp209_set_dcdc3_voltage(u8 bus, u16 millivolts)
-{
- u8 val;
-
- if (millivolts < 700 || millivolts > 3500)
- return CB_ERR_ARG;
-
- val = (millivolts - 700) / 25;
-
- if (axp209_write(bus, REG_DCDC3_VOLTAGE, val) != 1)
- return CB_ERR;
-
- return CB_SUCCESS;
-}
-
-/**
- * \brief Configure the output voltage of LDO2 regulator
- *
- * If the requested voltage is not available, the next lowest voltage will
- * be applied.
- * Valid values are between 700mV and 3300mV
- *
- * @param[in] millivolts voltage in mV units.
- * @param[in] bus I2C bus to which the AXP209 is connected
- * @return CB_SUCCES on success,
- * CB_ERR_ARG if voltage is out of range, or an error code otherwise.
- */
-enum cb_err axp209_set_ldo2_voltage(u8 bus, u16 millivolts)
-{
- u8 reg8, val;
-
- if (millivolts < 1800 || millivolts > 3300)
- return CB_ERR_ARG;
-
- /* Try to read the register first, and stop here on error */
- if (axp209_read(bus, REG_LDO24_VOLTAGE, ®8) != 1)
- return CB_ERR;
-
- val = (millivolts - 1800) / 100;
- reg8 &= ~REG_LDO24_VOLTAGE_LDO2_MASK;
- reg8 |= REG_LDO24_VOLTAGE_LDO2_VAL(val);
-
- if (axp209_write(bus, REG_LDO24_VOLTAGE, reg8) != 1)
- return CB_ERR;
-
- return CB_SUCCESS;
-}
-
-/**
- * \brief Configure the output voltage of LDO4 regulator
- *
- * If the requested voltage is not available, the next lowest voltage will
- * be applied.
- * Valid values are between 700mV and 3500mV. Datasheet lists maximum voltage at
- * 2250mV, but hardware samples go as high as 3500mV.
- *
- * @param[in] millivolts voltage in mV units.
- * @param[in] bus I2C bus to which the AXP209 is connected
- * @return CB_SUCCES on success,
- * CB_ERR_ARG if voltage is out of range, or an error code otherwise.
- */
-enum cb_err axp209_set_ldo3_voltage(u8 bus, u16 millivolts)
-{
- u8 val;
-
- /* Datasheet lists 2250 max, but PMU will output up to 3500mV */
- if (millivolts < 700 || millivolts > 3500)
- return CB_ERR_ARG;
-
- val = (millivolts - 700) / 25;
-
- if (axp209_write(bus, REG_LDO3_VOLTAGE, val) != 1)
- return CB_ERR;
-
- return CB_SUCCESS;
-}
-
-/**
- * \brief Configure the output voltage of DC-DC2 converter
- *
- * If the requested voltage is not available, the next lowest voltage will
- * be applied.
- * Valid values are between 1250V and 3300mV
- *
- * @param[in] millivolts voltage in mV units.
- * @param[in] bus I2C bus to which the AXP209 is connected
- * @return CB_SUCCES on success,
- * CB_ERR_ARG if voltage is out of range, or an error code otherwise.
- */
-enum cb_err axp209_set_ldo4_voltage(u8 bus, u16 millivolts)
-{
- u8 reg8, val;
-
- if (millivolts < 1250 || millivolts > 3300)
- return CB_ERR_ARG;
-
- /* Try to read the register first, and stop here on error */
- if (axp209_read(bus, REG_LDO24_VOLTAGE, ®8) != 1)
- return CB_ERR;
-
- if (millivolts <= 2000)
- val = (millivolts - 1200) / 100;
- else if (millivolts <= 2700)
- val = 9 + (millivolts - 2500) / 100;
- else if (millivolts <= 2800)
- val = 11;
- else
- val = 12 + (millivolts - 3000) / 100;
-
- reg8 &= ~REG_LDO24_VOLTAGE_LDO4_MASK;
- reg8 |= REG_LDO24_VOLTAGE_LDO4_VAL(val);
-
- if (axp209_write(bus, REG_LDO24_VOLTAGE, reg8) != 1)
- return CB_ERR;
-
- return CB_SUCCESS;
-}
-
-static const struct {
- enum cb_err (*set_voltage) (u8 bus, u16 mv);
- const char *name;
-} vtable[] = { {
- .set_voltage = axp209_set_dcdc2_voltage,
- .name = "DCDC2",
- }, {
- .set_voltage = axp209_set_dcdc3_voltage,
- .name = "DCDC3",
- }, {
- .set_voltage = axp209_set_ldo2_voltage,
- .name = "LDO2",
- }, {
- .set_voltage = axp209_set_ldo3_voltage,
- .name = "LDO3",
- }, {
- .set_voltage = axp209_set_ldo4_voltage,
- .name = "LDO4",
- }
-};
-
-static enum cb_err set_rail(u8 bus, int idx, u16 mv)
-{
- enum cb_err err;
- const char *name = vtable[idx].name;
-
- /* If voltage isn't specified, don't touch the rail */
- if (mv == 0) {
- printk(BIOS_DEBUG, "[axp209] Skipping %s configuration\n",
- name);
- return CB_SUCCESS;
- }
-
- if ((err = vtable[idx].set_voltage(bus, mv) != CB_SUCCESS)) {
- printk(BIOS_ERR, "[axp209] Failed to set %s to %u mv\n",
- name, mv);
- return err;
- }
-
- return CB_SUCCESS;
-}
-
-/**
- * \brief Configure all voltage rails
- *
- * Configure all converters and regulators from devicetree config. If any of the
- * voltages are not declared (i.e. are zero), the respective rail will not be
- * reconfigured, and retain its powerup voltage.
- *
- * @param[in] cfg pointer to @ref drivers_xpowers_axp209_config structure
- * @param[in] bus I2C bus to which the AXP209 is connected
- * @return CB_SUCCES on success, or an error code otherwise.
- */
-enum cb_err axp209_set_voltages(u8 bus, const struct
- drivers_xpowers_axp209_config *cfg)
-{
- enum cb_err err;
-
- /* Don't worry about what the error is. Console prints that */
- err = set_rail(bus, 0, cfg->dcdc2_voltage_mv);
- err |= set_rail(bus, 1, cfg->dcdc3_voltage_mv);
- err |= set_rail(bus, 2, cfg->ldo2_voltage_mv);
- err |= set_rail(bus, 3, cfg->ldo3_voltage_mv);
- err |= set_rail(bus, 4, cfg->ldo4_voltage_mv);
-
- if (err != CB_SUCCESS)
- return CB_ERR;
-
- return CB_SUCCESS;
-}
-
-/*
- * Usually, the AXP209 is enabled and configured in romstage, so there is no
- * need for a full ramstage driver. Hence .enable_dev is NULL.
- */
-#ifndef __PRE_RAM__
-struct chip_operations drivers_xpowers_axp209_config = {
- CHIP_NAME("X-Powers AXP 209 Power Management Unit")
- .enable_dev = NULL,
-};
-#endif /* __PRE_RAM__ */
diff --git a/src/drivers/xpowers/axp209/axp209.h b/src/drivers/xpowers/axp209/axp209.h
deleted file mode 100644
index c9cdd7efba..0000000000
--- a/src/drivers/xpowers/axp209/axp209.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Definitions for X-Powers AXP 209 Power Management Unit
- *
- * Copyright (C) 2013 Alexandru Gagniuc
- * Subject to the GNU GPL v2, or (at your option) any later version.
- */
-
-#include
-#include "chip.h"
-
-#define AXP209_I2C_ADDR (0x68 >> 1)
-
-enum cb_err axp209_init(u8 bus);
-enum cb_err axp209_set_dcdc2_voltage(u8 bus, u16 millivolts);
-enum cb_err axp209_set_dcdc3_voltage(u8 bus, u16 millivolts);
-enum cb_err axp209_set_ldo2_voltage(u8 bus, u16 millivolts);
-enum cb_err axp209_set_ldo3_voltage(u8 bus, u16 millivolts);
-enum cb_err axp209_set_ldo4_voltage(u8 bus, u16 millivolts);
-enum cb_err axp209_set_voltages(u8 bus, const struct
- drivers_xpowers_axp209_config *cfg);
diff --git a/src/drivers/xpowers/axp209/chip.h b/src/drivers/xpowers/axp209/chip.h
deleted file mode 100644
index c19253d6b5..0000000000
--- a/src/drivers/xpowers/axp209/chip.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * X-Powers AXP 209 devicetree.cb interface
- *
- * Copyright (C) 2013 Alexandru Gagniuc
- * Subject to the GNU GPL v2, or (at your option) any later version.
- */
-
-#ifndef AXP209_CHIP_H
-#define AXP209_CHIP_H
-
-#include
-
-struct drivers_xpowers_axp209_config {
- u16 dcdc2_voltage_mv; /**< DCDC2 converter voltage output */
- u16 dcdc3_voltage_mv; /**< DCDC3 converter voltage output */
- u16 ldo2_voltage_mv; /**< LDO2 regulator voltage output */
- u16 ldo3_voltage_mv; /**< LDO3 regulator voltage output */
- u16 ldo4_voltage_mv; /**< LDO4 regulator voltage output */
-};
-
-#endif /* AXP209_CHIP_H */
diff --git a/src/ec/google/chromeec/acpi/battery.asl b/src/ec/google/chromeec/acpi/battery.asl
index 1ff50991c0..025339540f 100644
--- a/src/ec/google/chromeec/acpi/battery.asl
+++ b/src/ec/google/chromeec/acpi/battery.asl
@@ -194,7 +194,7 @@ Method (BBST, 4, Serialized)
Store (Local1, Index (Arg1, 0))
// Notify if battery state has changed since last time
- If (LNotEqual (Local1, Arg2)) {
+ If (LNotEqual (Local1, DeRefOf (Arg2))) {
Store (Local1, Arg2)
If (LEqual(Arg0, 0)) {
Notify (BAT0, 0x80)
@@ -326,7 +326,7 @@ Device (BAT0)
Method (_BST, 0, Serialized)
{
- Return (BBST (0, PBST, BSTP, BFWK))
+ Return (BBST (0, PBST, RefOf (BSTP), BFWK))
}
}
@@ -416,7 +416,7 @@ Device (BAT1)
Method (_BST, 0, Serialized)
{
- Return (BBST (1, PBST, BSTP, BFWK))
+ Return (BBST (1, PBST, RefOf (BSTP), BFWK))
}
}
#endif
diff --git a/src/ec/google/wilco/Kconfig b/src/ec/google/wilco/Kconfig
index 4202c1d7b5..25d7cfafc2 100644
--- a/src/ec/google/wilco/Kconfig
+++ b/src/ec/google/wilco/Kconfig
@@ -6,6 +6,8 @@ config EC_GOOGLE_WILCO
help
Google Wilco Embedded Controller interface.
+if EC_GOOGLE_WILCO
+
config EC_BASE_ACPI_DATA
hex
default 0x930
@@ -46,3 +48,5 @@ config EC_BASE_PACKET
mailbox interface data region. This data buffer is used along
with the host command and data registers to drive the EC
mailbox interface. This is also the MEC EMI base address.
+
+endif # EC_GOOGLE_WILCO
diff --git a/src/include/bootmem.h b/src/include/bootmem.h
index c935cb919f..2e33fcdf76 100644
--- a/src/include/bootmem.h
+++ b/src/include/bootmem.h
@@ -37,6 +37,7 @@ enum bootmem_type {
BM_MEM_NVS, /* ACPI NVS Memory */
BM_MEM_UNUSABLE, /* Unusable address space */
BM_MEM_VENDOR_RSVD, /* Vendor Reserved */
+ BM_MEM_OPENSBI, /* Risc-V OpenSBI */
BM_MEM_BL31, /* Arm64 BL31 exectuable */
BM_MEM_TABLE, /* Ram configuration tables are kept in */
/* Tags below this point are ignored for the OS table. */
diff --git a/src/include/bootsplash.h b/src/include/bootsplash.h
new file mode 100644
index 0000000000..84ba34cc90
--- /dev/null
+++ b/src/include/bootsplash.h
@@ -0,0 +1,36 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2019 Johanna Schander
+ *
+ * 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; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef __BOOTSPLASH_H__
+#define __BOOTSPLASH_H__
+
+#include
+
+/**
+ * Wraps bootsplash setup for vesa
+ */
+void set_vesa_bootsplash(void);
+
+
+/**
+ * Sets up the framebuffer with the bootsplash.jpg from cbfs.
+ * Returns 0 on success
+ * CB_ERR on cbfs errors
+ * and >0 on jpeg errors.
+ */
+void set_bootsplash(unsigned char *framebuffer, unsigned int x_resolution,
+ unsigned int y_resolution, unsigned int fb_resolution);
+
+#endif
diff --git a/src/include/cpu/x86/smm.h b/src/include/cpu/x86/smm.h
index 3071106080..b8b99ecdab 100644
--- a/src/include/cpu/x86/smm.h
+++ b/src/include/cpu/x86/smm.h
@@ -583,4 +583,25 @@ int smm_load_module(void *smram, size_t size, struct smm_loader_params *params);
void *backup_default_smm_area(void);
void restore_default_smm_area(void *smm_save_area);
+/*
+ * Fills in the arguments for the entire SMM region covered by chipset
+ * protections. e.g. TSEG.
+ */
+void smm_region(uintptr_t *start, size_t *size);
+
+enum {
+ /* SMM handler area. */
+ SMM_SUBREGION_HANDLER,
+ /* SMM cache region. */
+ SMM_SUBREGION_CACHE,
+ /* Chipset specific area. */
+ SMM_SUBREGION_CHIPSET,
+ /* Total sub regions supported. */
+ SMM_SUBREGION_NUM,
+};
+
+/* Fills in the start and size for the requested SMM subregion. Returns
+ * 0 on success, < 0 on failure. */
+int smm_subregion(int sub, uintptr_t *start, size_t *size);
+
#endif /* CPU_X86_SMM_H */
diff --git a/src/include/device/device.h b/src/include/device/device.h
index 676da65263..8e1e62aa7c 100644
--- a/src/include/device/device.h
+++ b/src/include/device/device.h
@@ -126,7 +126,6 @@ struct device {
unsigned int on_mainboard : 1;
unsigned int disable_pcie_aspm : 1;
unsigned int hidden : 1; /* set if we should hide from UI */
- struct pci_irq_info pci_irq_info[4];
u8 command;
/* Base registers for this device. I/O, MEM and Expansion ROM */
@@ -138,6 +137,7 @@ struct device {
DEVTREE_CONST struct bus *link_list;
#if !DEVTREE_EARLY
+ struct pci_irq_info pci_irq_info[4];
struct device_operations *ops;
struct chip_operations *chip_ops;
const char *name;
@@ -275,8 +275,6 @@ void mmconf_resource(struct device *dev, unsigned long index);
void tolm_test(void *gp, struct device *dev, struct resource *new);
u32 find_pci_tolm(struct bus *bus);
-DEVTREE_CONST struct device *dev_find_slot(unsigned int bus,
- unsigned int devfn);
DEVTREE_CONST struct device *dev_find_next_pci_device(
DEVTREE_CONST struct device *previous_dev);
DEVTREE_CONST struct device *dev_find_slot_on_smbus(unsigned int bus,
@@ -292,6 +290,34 @@ DEVTREE_CONST struct device *pcidev_path_on_bus(unsigned int bus, pci_devfn_t de
DEVTREE_CONST struct device *pcidev_on_root(uint8_t dev, uint8_t fn);
DEVTREE_CONST struct bus *pci_root_bus(void);
+/* To be deprecated, avoid using. */
+DEVTREE_CONST struct device *dev_find_slot(unsigned int bus, unsigned int devfn);
+DEVTREE_CONST struct device *pcidev_path_on_root_debug(pci_devfn_t devfn, const char *func);
+
+/* Robust discovery of chip_info. */
+void devtree_bug(const char *func, pci_devfn_t devfn);
+void __noreturn devtree_die(void);
+
+static inline DEVTREE_CONST void *config_of(const struct device *dev)
+{
+ if (dev && dev->chip_info)
+ return dev->chip_info;
+
+ devtree_die();
+}
+
+static inline DEVTREE_CONST void *config_of_path(pci_devfn_t devfn)
+{
+ const struct device *dev = pcidev_path_on_root(devfn);
+ if (dev)
+ return config_of(dev);
+
+ devtree_bug(__func__, devfn);
+
+ dev = dev_find_slot(0, devfn);
+ return config_of(dev);
+}
+
void scan_smbus(struct device *bus);
void scan_generic_bus(struct device *bus);
void scan_static_bus(struct device *bus);
diff --git a/src/include/device/pci_ids.h b/src/include/device/pci_ids.h
index 0c846c64d9..1aac48e9aa 100644
--- a/src/include/device/pci_ids.h
+++ b/src/include/device/pci_ids.h
@@ -292,18 +292,19 @@
#define PCI_DEVICE_ID_ATI_RADEON_RC 0x5146
#define PCI_DEVICE_ID_ATI_RADEON_RD 0x5147
+#define PCI_DEVICE_ID_AMD_10H_NB_HT 0x1200
#define PCI_DEVICE_ID_AMD_15H_MODEL_000F_NB_HT 0x1600
#define PCI_DEVICE_ID_AMD_15H_MODEL_101F_NB_HT 0x1400
#define PCI_DEVICE_ID_AMD_15H_MODEL_303F_NB_HT 0x141A
-#define PCI_DEVICE_ID_AMD_16H_MODEL_000F_NB_HT 0x1536
-#define PCI_DEVICE_ID_AMD_16H_MODEL_303F_NB_HT 0x1566
#define PCI_DEVICE_ID_AMD_15H_MODEL_606F_NB_HT 0x1570
#define PCI_DEVICE_ID_AMD_15H_MODEL_707F_NB_HT 0x15B0
-#define PCI_DEVICE_ID_AMD_10H_NB_HT 0x1200
-#define PCI_DEVICE_ID_AMD_15H_NB_IOMMU 0x1419
+#define PCI_DEVICE_ID_AMD_16H_MODEL_000F_NB_HT 0x1536
+#define PCI_DEVICE_ID_AMD_16H_MODEL_303F_NB_HT 0x1566
+#define PCI_DEVICE_ID_AMD_17H_MODEL_101F_NB 0x15d0
+#define PCI_DEVICE_ID_AMD_15H_MODEL_101F_NB_IOMMU 0x1419
#define PCI_DEVICE_ID_AMD_15H_MODEL_303F_NB_IOMMU 0x1423
-#define PCI_DEVICE_ID_AMD_16H_MODEL_303F_NB_IOMMU 0x1567
#define PCI_DEVICE_ID_AMD_15H_MODEL_707F_NB_IOMMU 0x1577
+#define PCI_DEVICE_ID_AMD_16H_MODEL_303F_NB_IOMMU 0x1567
#define PCI_DEVICE_ID_AMD_17H_MODEL_101F_NB_IOMMU 0x15d1
#define PCI_DEVICE_ID_ATI_SB600_LPC 0x438D
@@ -2698,16 +2699,17 @@
#define PCI_DEVICE_ID_INTEL_SPT_LP_U_BASE 0x9d43
#define PCI_DEVICE_ID_INTEL_SPT_LP_U_PREMIUM 0x9d48
#define PCI_DEVICE_ID_INTEL_SPT_LP_Y_PREMIUM 0x9d46
+#define PCI_DEVICE_ID_INTEL_SPT_H_H110 0xa143
#define PCI_DEVICE_ID_INTEL_SPT_H_H170 0xa144
#define PCI_DEVICE_ID_INTEL_SPT_H_Z170 0xa145
#define PCI_DEVICE_ID_INTEL_SPT_H_Q170 0xa146
#define PCI_DEVICE_ID_INTEL_SPT_H_Q150 0xa147
#define PCI_DEVICE_ID_INTEL_SPT_H_B150 0xa148
#define PCI_DEVICE_ID_INTEL_SPT_H_C236 0xa149
-#define PCI_DEVICE_ID_INTEL_SPT_H_CM236 0xa150
-#define PCI_DEVICE_ID_INTEL_SPT_H_PREMIUM 0xa14e
-#define PCI_DEVICE_ID_INTEL_SPT_H_H110 0xa143
+#define PCI_DEVICE_ID_INTEL_SPT_H_C232 0xa14a
#define PCI_DEVICE_ID_INTEL_SPT_H_QM170 0xa14d
+#define PCI_DEVICE_ID_INTEL_SPT_H_HM170 0xa14e
+#define PCI_DEVICE_ID_INTEL_SPT_H_CM236 0xa150
#define PCI_DEVICE_ID_INTEL_SPT_H_HM175 0xa152
#define PCI_DEVICE_ID_INTEL_SPT_H_QM175 0xa153
#define PCI_DEVICE_ID_INTEL_SPT_H_CM238 0xa154
@@ -2728,8 +2730,15 @@
#define PCI_DEVICE_ID_INTEL_CNL_BASE_U_LPC 0x9d85
#define PCI_DEVICE_ID_INTEL_CNL_U_PREMIUM_LPC 0x9d84
#define PCI_DEVICE_ID_INTEL_CNL_Y_PREMIUM_LPC 0x9d83
+#define PCI_DEVICE_ID_INTEL_CNP_H_LPC_H310 0xa303
+#define PCI_DEVICE_ID_INTEL_CNP_H_LPC_H370 0xa304
+#define PCI_DEVICE_ID_INTEL_CNP_H_LPC_Z390 0xa305
#define PCI_DEVICE_ID_INTEL_CNP_H_LPC_Q370 0xa306
+#define PCI_DEVICE_ID_INTEL_CNP_H_LPC_B360 0xa308
+#define PCI_DEVICE_ID_INTEL_CNP_H_LPC_C246 0xa309
+#define PCI_DEVICE_ID_INTEL_CNP_H_LPC_C242 0xa30a
#define PCI_DEVICE_ID_INTEL_CNP_H_LPC_QM370 0xa30c
+#define PCI_DEVICE_ID_INTEL_CNP_H_LPC_HM370 0xa30d
#define PCI_DEVICE_ID_INTEL_CNP_H_LPC_CM246 0xa30e
#define PCI_DEVICE_ID_INTEL_ICL_U_SUPER_U_ESPI 0x3480
#define PCI_DEVICE_ID_INTEL_ICL_U_SUPER_U_ESPI_REV0 0x3481
@@ -3002,6 +3011,10 @@
#define PCI_DEVICE_ID_INTEL_CNL_SPI1 0x9dab
#define PCI_DEVICE_ID_INTEL_CNL_SPI2 0x9dfb
#define PCI_DEVICE_ID_INTEL_CNL_HWSEQ_SPI 0x9da4
+#define PCI_DEVICE_ID_INTEL_CNP_H_SPI0 0xa32a
+#define PCI_DEVICE_ID_INTEL_CNP_H_SPI1 0xa32b
+#define PCI_DEVICE_ID_INTEL_CNP_H_SPI2 0xa37b
+#define PCI_DEVICE_ID_INTEL_CNP_H_HWSEQ_SPI 0xa324
#define PCI_DEVICE_ID_INTEL_ICP_SPI0 0x34aa
#define PCI_DEVICE_ID_INTEL_ICP_SPI1 0x34ab
#define PCI_DEVICE_ID_INTEL_ICP_SPI2 0x34fb
@@ -3042,11 +3055,14 @@
#define PCI_DEVICE_ID_INTEL_CNL_GT2_ULT_4 0x5A4A
#define PCI_DEVICE_ID_INTEL_CFL_GT2_ULT 0x3EA5
#define PCI_DEVICE_ID_INTEL_CFL_H_GT2 0x3e9b
-#define PCI_DEVICE_ID_INTEL_CFL_S_GT2 0x3e92
#define PCI_DEVICE_ID_INTEL_CFL_H_XEON_GT2 0x3e94
-#define PCI_DEVICE_ID_INTEL_ICL_GT0_ULT 0x8A70
+#define PCI_DEVICE_ID_INTEL_CFL_S_GT2_1 0x3e92
+#define PCI_DEVICE_ID_INTEL_CFL_S_GT2_2 0x3e98
+#define PCI_DEVICE_ID_INTEL_CFL_S_GT2_3 0x3e9a
+#define PCI_DEVICE_ID_INTEL_CFL_S_GT2_4 0x3e91
+#define PCI_DEVICE_ID_INTEL_ICL_GT0_ULT 0x8A70
#define PCI_DEVICE_ID_INTEL_ICL_GT0_5_ULT 0x8A71
-#define PCI_DEVICE_ID_INTEL_ICL_GT1_ULT 0x8A40
+#define PCI_DEVICE_ID_INTEL_ICL_GT1_ULT 0x8A40
#define PCI_DEVICE_ID_INTEL_ICL_GT2_ULX_0 0x8A50
#define PCI_DEVICE_ID_INTEL_ICL_GT2_ULX_1 0x8A5D
#define PCI_DEVICE_ID_INTEL_ICL_GT2_ULT_1 0x8A5B
@@ -3059,7 +3075,7 @@
#define PCI_DEVICE_ID_INTEL_ICL_GT2_ULX_5 0x8A55
#define PCI_DEVICE_ID_INTEL_ICL_GT2_ULT_5 0x8A56
#define PCI_DEVICE_ID_INTEL_ICL_GT2_ULX_6 0x8A57
-#define PCI_DEVICE_ID_INTEL_ICL_GT3_ULT 0x8A62
+#define PCI_DEVICE_ID_INTEL_ICL_GT3_ULT 0x8A62
#define PCI_DEVICE_ID_INTEL_CML_GT1_ULT_1 0x9B21
#define PCI_DEVICE_ID_INTEL_CML_GT1_ULT_2 0x9B2A
#define PCI_DEVICE_ID_INTEL_CML_GT2_ULT_1 0x9B41
@@ -3080,43 +3096,47 @@
#define PCI_DEVICE_ID_INTEL_CML_GT2_H_2 0x9B42
/* Intel Northbridge Ids */
-#define PCI_DEVICE_ID_INTEL_APL_NB 0x5af0
-#define PCI_DEVICE_ID_INTEL_GLK_NB 0x31f0
-#define PCI_DEVICE_ID_INTEL_SKL_ID_U 0x1904
-#define PCI_DEVICE_ID_INTEL_SKL_ID_Y 0x190c
-#define PCI_DEVICE_ID_INTEL_SKL_ID_ULX 0x1924
-#define PCI_DEVICE_ID_INTEL_SKL_ID_H_2 0x1900
-#define PCI_DEVICE_ID_INTEL_SKL_ID_H 0x1910
-#define PCI_DEVICE_ID_INTEL_SKL_ID_S_2 0x190f
-#define PCI_DEVICE_ID_INTEL_SKL_ID_S_4 0x191f
-#define PCI_DEVICE_ID_INTEL_KBL_ID_S 0x590f
-#define PCI_DEVICE_ID_INTEL_SKL_ID_H_EM 0x1918
-#define PCI_DEVICE_ID_INTEL_SKL_ID_DT 0x191f
-#define PCI_DEVICE_ID_INTEL_KBL_ID_U 0x5904
-#define PCI_DEVICE_ID_INTEL_KBL_ID_Y 0x590c
-#define PCI_DEVICE_ID_INTEL_KBL_ID_H 0x5910
-#define PCI_DEVICE_ID_INTEL_KBL_U_R 0x5914
-#define PCI_DEVICE_ID_INTEL_KBL_ID_DT_2 0x5918
-#define PCI_DEVICE_ID_INTEL_KBL_ID_DT 0x591f
-#define PCI_DEVICE_ID_INTEL_CNL_ID_U 0x5A04
-#define PCI_DEVICE_ID_INTEL_CNL_ID_Y 0x5A02
-#define PCI_DEVICE_ID_INTEL_WHL_ID_Wx4 0x3E34
-#define PCI_DEVICE_ID_INTEL_WHL_ID_Wx2 0x3E35
-#define PCI_DEVICE_ID_INTEL_CFL_ID_U 0x3ED0
-#define PCI_DEVICE_ID_INTEL_CFL_ID_H 0x3ec4
-#define PCI_DEVICE_ID_INTEL_CFL_ID_S 0x3ec2
-#define PCI_DEVICE_ID_INTEL_ICL_ID_U 0x8A12
+#define PCI_DEVICE_ID_INTEL_APL_NB 0x5af0
+#define PCI_DEVICE_ID_INTEL_GLK_NB 0x31f0
+#define PCI_DEVICE_ID_INTEL_SKL_ID_U 0x1904
+#define PCI_DEVICE_ID_INTEL_SKL_ID_Y 0x190c
+#define PCI_DEVICE_ID_INTEL_SKL_ID_ULX 0x1924
+#define PCI_DEVICE_ID_INTEL_SKL_ID_H_2 0x1900
+#define PCI_DEVICE_ID_INTEL_SKL_ID_H 0x1910
+#define PCI_DEVICE_ID_INTEL_SKL_ID_S_2 0x190f
+#define PCI_DEVICE_ID_INTEL_SKL_ID_S_4 0x191f
+#define PCI_DEVICE_ID_INTEL_KBL_ID_S 0x590f
+#define PCI_DEVICE_ID_INTEL_SKL_ID_H_EM 0x1918
+#define PCI_DEVICE_ID_INTEL_SKL_ID_DT 0x191f
+#define PCI_DEVICE_ID_INTEL_KBL_ID_U 0x5904
+#define PCI_DEVICE_ID_INTEL_KBL_ID_Y 0x590c
+#define PCI_DEVICE_ID_INTEL_KBL_ID_H 0x5910
+#define PCI_DEVICE_ID_INTEL_KBL_U_R 0x5914
+#define PCI_DEVICE_ID_INTEL_KBL_ID_DT_2 0x5918
+#define PCI_DEVICE_ID_INTEL_KBL_ID_DT 0x591f
+#define PCI_DEVICE_ID_INTEL_CNL_ID_U 0x5A04
+#define PCI_DEVICE_ID_INTEL_CNL_ID_Y 0x5A02
+#define PCI_DEVICE_ID_INTEL_WHL_ID_W_4 0x3E34
+#define PCI_DEVICE_ID_INTEL_WHL_ID_W_2 0x3E35
+#define PCI_DEVICE_ID_INTEL_CFL_ID_U 0x3ED0
+#define PCI_DEVICE_ID_INTEL_CFL_ID_H 0x3ec4
+#define PCI_DEVICE_ID_INTEL_CFL_ID_H_8 0x3e20
+#define PCI_DEVICE_ID_INTEL_CFL_ID_S 0x3ec2
+#define PCI_DEVICE_ID_INTEL_CFL_ID_S_DT_4 0x3e1f
+#define PCI_DEVICE_ID_INTEL_CFL_ID_S_DT_8 0x3e30
+#define PCI_DEVICE_ID_INTEL_CFL_ID_S_WS_8 0x3e31
+#define PCI_DEVICE_ID_INTEL_ICL_ID_U 0x8A12
#define PCI_DEVICE_ID_INTEL_ICL_ID_U_2_2 0x8A02
-#define PCI_DEVICE_ID_INTEL_ICL_ID_Y 0x8A10
-#define PCI_DEVICE_ID_INTEL_ICL_ID_Y_2 0x8A00
-#define PCI_DEVICE_ID_INTEL_CML_ULT 0x9B61
-#define PCI_DEVICE_ID_INTEL_CML_ULT_2_2 0x9B71
-#define PCI_DEVICE_ID_INTEL_CML_ULT_6_2 0x9B51
-#define PCI_DEVICE_ID_INTEL_CML_ULX 0x9B60
-#define PCI_DEVICE_ID_INTEL_CML_S 0x9B55
-#define PCI_DEVICE_ID_INTEL_CML_S_10_2 0x9B35
-#define PCI_DEVICE_ID_INTEL_CML_H 0x9B54
-#define PCI_DEVICE_ID_INTEL_CML_H_8_2 0x9B44
+#define PCI_DEVICE_ID_INTEL_ICL_ID_Y 0x8A10
+#define PCI_DEVICE_ID_INTEL_ICL_ID_Y_2 0x8A00
+#define PCI_DEVICE_ID_INTEL_CML_ULT 0x9B61
+#define PCI_DEVICE_ID_INTEL_CML_ULT_2_2 0x9B71
+#define PCI_DEVICE_ID_INTEL_CML_ULT_6_2 0x9B51
+#define PCI_DEVICE_ID_INTEL_CML_ULX 0x9B60
+#define PCI_DEVICE_ID_INTEL_CML_S 0x9B55
+#define PCI_DEVICE_ID_INTEL_CML_S_10_2 0x9B35
+#define PCI_DEVICE_ID_INTEL_CML_H 0x9B54
+#define PCI_DEVICE_ID_INTEL_CML_H_8_2 0x9B44
/* Intel SMBUS device Ids */
#define PCI_DEVICE_ID_INTEL_SPT_LP_SMBUS 0x9d23
diff --git a/src/include/device/pci_ops.h b/src/include/device/pci_ops.h
index 9a9c575e3c..5cc803c737 100644
--- a/src/include/device/pci_ops.h
+++ b/src/include/device/pci_ops.h
@@ -23,22 +23,7 @@
#include
#include
-#ifdef __SIMPLE_DEVICE__
-
-/* Avoid name collisions as different stages have different signature
- * for these functions. The _s_ stands for simple, fundamental IO or
- * MMIO variant.
- */
-#define pci_read_config8 pci_s_read_config8
-#define pci_read_config16 pci_s_read_config16
-#define pci_read_config32 pci_s_read_config32
-#define pci_write_config8 pci_s_write_config8
-#define pci_write_config16 pci_s_write_config16
-#define pci_write_config32 pci_s_write_config32
-#else
-
-#include
-
+#ifndef __ROMCC__
void __noreturn pcidev_die(void);
static __always_inline pci_devfn_t pcidev_bdf(const struct device *dev)
@@ -52,6 +37,21 @@ static __always_inline pci_devfn_t pcidev_assert(const struct device *dev)
pcidev_die();
return pcidev_bdf(dev);
}
+#endif
+
+#ifdef __SIMPLE_DEVICE__
+
+/* Avoid name collisions as different stages have different signature
+ * for these functions. The _s_ stands for simple, fundamental IO or
+ * MMIO variant.
+ */
+#define pci_read_config8 pci_s_read_config8
+#define pci_read_config16 pci_s_read_config16
+#define pci_read_config32 pci_s_read_config32
+#define pci_write_config8 pci_s_write_config8
+#define pci_write_config16 pci_s_write_config16
+#define pci_write_config32 pci_s_write_config32
+#else
static __always_inline
u8 pci_read_config8(const struct device *dev, u16 reg)
diff --git a/src/include/device/resource.h b/src/include/device/resource.h
index eefaf96e28..1d04e9a1c8 100644
--- a/src/include/device/resource.h
+++ b/src/include/device/resource.h
@@ -62,9 +62,11 @@ struct resource {
struct device;
struct bus;
extern void compact_resources(struct device *dev);
-extern struct resource *probe_resource(struct device *dev, unsigned int index);
+extern struct resource *probe_resource(const struct device *dev,
+ unsigned int index);
extern struct resource *new_resource(struct device *dev, unsigned int index);
-extern struct resource *find_resource(struct device *dev, unsigned int index);
+extern struct resource *find_resource(const struct device *dev,
+ unsigned int index);
extern resource_t resource_end(struct resource *resource);
extern resource_t resource_max(struct resource *resource);
extern void report_resource_stored(struct device *dev,
diff --git a/src/include/edid.h b/src/include/edid.h
index d567115744..e5f7d98926 100644
--- a/src/include/edid.h
+++ b/src/include/edid.h
@@ -17,6 +17,7 @@
#define EDID_H
#include
+#include "commonlib/coreboot_tables.h"
enum edid_modes {
EDID_MODE_640x480_60Hz,
@@ -107,6 +108,7 @@ int decode_edid(unsigned char *edid, int size, struct edid *out);
void edid_set_framebuffer_bits_per_pixel(struct edid *edid, int fb_bpp,
int row_byte_alignment);
void set_vbe_mode_info_valid(const struct edid *edid, uintptr_t fb_addr);
+void set_vbe_framebuffer_orientation(enum lb_fb_orientation orientation);
int set_display_mode(struct edid *edid, enum edid_modes mode);
#endif /* EDID_H */
diff --git a/src/include/program_loading.h b/src/include/program_loading.h
index 5ac74bf238..6dec1920b8 100644
--- a/src/include/program_loading.h
+++ b/src/include/program_loading.h
@@ -38,6 +38,7 @@ enum prog_type {
PROG_BL31,
PROG_BL32,
PROG_POSTCAR,
+ PROG_OPENSBI,
};
/*
diff --git a/src/include/ramdetect.h b/src/include/ramdetect.h
new file mode 100644
index 0000000000..b63cdf14cf
--- /dev/null
+++ b/src/include/ramdetect.h
@@ -0,0 +1,22 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+/*
+ * Probe an area if it's read/writable.
+ * Primary use case is the detection of DRAM amount on emulators.
+ *
+ * @param dram_start Physical address of DRAM start
+ * @param probe_size Maximum size in MiB to probe for
+ * @return The detected DRAM size in MiB
+ */
+size_t probe_ramsize(const uintptr_t dram_start, const size_t probe_size);
diff --git a/src/include/spi-generic.h b/src/include/spi-generic.h
index d0f957f1f9..ffd3d2d008 100644
--- a/src/include/spi-generic.h
+++ b/src/include/spi-generic.h
@@ -16,6 +16,14 @@
#ifndef _SPI_GENERIC_H_
#define _SPI_GENERIC_H_
+/* Common parameters -- kind of high, but they should only occur when there
+ * is a problem (and well your system already is broken), so err on the side
+ * of caution in case we're dealing with slower SPI buses and/or processors.
+ */
+#define SPI_FLASH_PROG_TIMEOUT_MS 200
+#define SPI_FLASH_PAGE_ERASE_TIMEOUT_MS 500
+#define SPI_FLASH_SECTOR_ERASE_TIMEOUT_MS 1000
+
#include
#include
#include
diff --git a/src/include/stage_cache.h b/src/include/stage_cache.h
index 192cfb9014..3c7d9face0 100644
--- a/src/include/stage_cache.h
+++ b/src/include/stage_cache.h
@@ -32,21 +32,25 @@ enum {
STAGE_S3_DATA,
};
-#if CONFIG(CACHE_RELOCATED_RAMSTAGE_OUTSIDE_CBMEM) \
- || CONFIG(RELOCATABLE_RAMSTAGE)
+#if CONFIG(TSEG_STAGE_CACHE) || CONFIG(CBMEM_STAGE_CACHE)
/* Cache the loaded stage provided according to the parameters. */
void stage_cache_add(int stage_id, const struct prog *stage);
/* Load the cached stage at given location returning the stage entry point. */
void stage_cache_load_stage(int stage_id, struct prog *stage);
-#else /* CONFIG_NO_STAGE_CACHE */
-static inline void stage_cache_add(int stage_id, const struct prog *stage) {}
-static inline void stage_cache_load_stage(int stage_id, struct prog *stage) {}
-#endif
-
/* Cache non-specific data or code. */
void stage_cache_add_raw(int stage_id, const void *base, const size_t size);
/* Get a pointer to cached raw data and its size. */
void stage_cache_get_raw(int stage_id, void **base, size_t *size);
+
+#else /* CONFIG_NO_STAGE_CACHE */
+
+static inline void stage_cache_add(int stage_id, const struct prog *stage) {}
+static inline void stage_cache_load_stage(int stage_id, struct prog *stage) {}
+static inline void stage_cache_add_raw(int stage_id, const void *base, const size_t size) {}
+static inline void stage_cache_get_raw(int stage_id, void **base, size_t *size) {}
+
+#endif
+
/* Fill in parameters for the external stage cache, if utilized. */
void stage_cache_external_region(void **base, size_t *size);
diff --git a/src/include/symbols.h b/src/include/symbols.h
index b67286ac2d..cc27275f88 100644
--- a/src/include/symbols.h
+++ b/src/include/symbols.h
@@ -56,6 +56,7 @@ DECLARE_REGION(dma_coherent)
DECLARE_REGION(soc_registers)
DECLARE_REGION(framebuffer)
DECLARE_REGION(pdpt)
+DECLARE_REGION(opensbi)
DECLARE_REGION(bl31)
/*
diff --git a/src/include/vbe.h b/src/include/vbe.h
index 2c40d0507e..cfae7e4025 100644
--- a/src/include/vbe.h
+++ b/src/include/vbe.h
@@ -34,18 +34,6 @@ typedef struct {
u8 color_depth;
} __packed screen_info_input_t;
-// these structs only store a subset of the VBE defined fields
-// only those needed.
-typedef struct {
- char signature[4];
- u16 version;
- u8 *oem_string_ptr;
- u32 capabilities;
- u16 video_mode_list[256]; // lets hope we never have more than
- // 256 video modes...
- u16 total_memory;
-} vbe_info_t;
-
typedef struct {
u16 mode_attributes; // 00
u8 win_a_attributes; // 02
@@ -114,4 +102,10 @@ typedef struct {
void vbe_set_graphics(void);
void vbe_textmode_console(void);
+/**
+ * Returns the mode_info struct from the vbe context,
+ * if initialized. NULL on invalid mode_infos.
+ */
+const vbe_mode_info_t *vbe_mode_info(void);
+
#endif // VBE_H
diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc
index f0738eef4e..e5678ffdf1 100644
--- a/src/lib/Makefile.inc
+++ b/src/lib/Makefile.inc
@@ -32,10 +32,7 @@ decompressor-y += memcmp.c
decompressor-y += prog_ops.c
decompressor-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c
-ifneq ($(CONFIG_BOOTBLOCK_CUSTOM),y)
bootblock-y += bootblock.c
-endif
-
bootblock-y += prog_loaders.c
bootblock-y += prog_ops.c
bootblock-y += cbfs.c
@@ -60,6 +57,7 @@ verstage-y += halt.c
verstage-y += fmap.c
verstage-y += libgcc.c
verstage-y += memcmp.c
+verstage-y += string.c
verstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c
verstage-y += boot_device.c
verstage-$(CONFIG_CONSOLE_CBMEM) += cbmem_console.c
@@ -67,6 +65,7 @@ verstage-$(CONFIG_CONSOLE_CBMEM) += cbmem_console.c
verstage-$(CONFIG_GENERIC_UDELAY) += timer.c
verstage-$(CONFIG_GENERIC_GPIO_LIB) += gpio.c
+romstage-$(CONFIG_VENDOR_EMULATION) += ramdetect.c
romstage-y += prog_loaders.c
romstage-y += prog_ops.c
romstage-y += memchr.c
@@ -107,6 +106,7 @@ endif
romstage-$(CONFIG_GENERIC_UDELAY) += timer.c
+ramstage-$(CONFIG_VENDOR_EMULATION) += ramdetect.c
ramstage-y += prog_loaders.c
ramstage-y += prog_ops.c
ramstage-y += hardwaremain.c
@@ -127,6 +127,7 @@ ramstage-y += stack.c
ramstage-y += hexstrtobin.c
ramstage-y += wrdd.c
ramstage-$(CONFIG_CONSOLE_CBMEM) += cbmem_console.c
+ramstage-$(CONFIG_BOOTSPLASH) += bootsplash.c
ramstage-$(CONFIG_BOOTSPLASH) += jpeg.c
ramstage-$(CONFIG_TRACE) += trace.c
postcar-$(CONFIG_TRACE) += trace.c
@@ -156,6 +157,7 @@ ramstage-y += cbmem_common.c
ramstage-y += imd_cbmem.c
ramstage-y += imd.c
+postcar-$(CONFIG_VENDOR_EMULATION) += ramdetect.c
postcar-y += cbmem_common.c
postcar-$(CONFIG_CONSOLE_CBMEM) += cbmem_console.c
postcar-y += imd_cbmem.c
@@ -174,16 +176,13 @@ verstage-$(CONFIG_REG_SCRIPT) += reg_script.c
romstage-$(CONFIG_REG_SCRIPT) += reg_script.c
ramstage-$(CONFIG_REG_SCRIPT) += reg_script.c
-ifeq ($(CONFIG_CACHE_RELOCATED_RAMSTAGE_OUTSIDE_CBMEM),y)
-ramstage-y += ext_stage_cache.c
-romstage-y += ext_stage_cache.c
-postcar-y += ext_stage_cache.c
-else
-ramstage-$(CONFIG_RELOCATABLE_RAMSTAGE) += cbmem_stage_cache.c
-romstage-$(CONFIG_RELOCATABLE_RAMSTAGE) += cbmem_stage_cache.c
-postcar-$(CONFIG_RELOCATABLE_RAMSTAGE) += cbmem_stage_cache.c
-endif
+ramstage-$(CONFIG_TSEG_STAGE_CACHE) += ext_stage_cache.c
+romstage-$(CONFIG_TSEG_STAGE_CACHE) += ext_stage_cache.c
+postcar-$(CONFIG_TSEG_STAGE_CACHE) += ext_stage_cache.c
+ramstage-$(CONFIG_CBMEM_STAGE_CACHE) += cbmem_stage_cache.c
+romstage-$(CONFIG_CBMEM_STAGE_CACHE) += cbmem_stage_cache.c
+postcar-$(CONFIG_CBMEM_STAGE_CACHE) += cbmem_stage_cache.c
romstage-y += boot_device.c
ramstage-y += boot_device.c
diff --git a/src/lib/bootmem.c b/src/lib/bootmem.c
index 01ad3e841b..45f7fe261d 100644
--- a/src/lib/bootmem.c
+++ b/src/lib/bootmem.c
@@ -59,6 +59,8 @@ static uint32_t bootmem_to_lb_tag(const enum bootmem_type tag)
return LB_MEM_UNUSABLE;
case BM_MEM_VENDOR_RSVD:
return LB_MEM_VENDOR_RSVD;
+ case BM_MEM_OPENSBI:
+ return LB_MEM_RESERVED;
case BM_MEM_BL31:
return LB_MEM_RESERVED;
case BM_MEM_TABLE:
@@ -147,6 +149,7 @@ static const struct range_strings type_strings[] = {
{ BM_MEM_UNUSABLE, "UNUSABLE" },
{ BM_MEM_VENDOR_RSVD, "VENDOR RESERVED" },
{ BM_MEM_BL31, "BL31" },
+ { BM_MEM_OPENSBI, "OPENSBI" },
{ BM_MEM_TABLE, "CONFIGURATION TABLES" },
{ BM_MEM_RAMSTAGE, "RAMSTAGE" },
{ BM_MEM_PAYLOAD, "PAYLOAD" },
diff --git a/src/lib/bootmode.c b/src/lib/bootmode.c
index 083fd9d49d..2465966b3a 100644
--- a/src/lib/bootmode.c
+++ b/src/lib/bootmode.c
@@ -2,7 +2,6 @@
* This file is part of the coreboot project.
*
* Copyright (C) 2011 The ChromiumOS Authors. All rights reserved.
- * Copyright (C) 2019 Intel Corporation. All rights reserved.
*
* 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
@@ -34,7 +33,8 @@ void gfx_set_init_done(int done)
int display_init_required(void)
{
- if (CONFIG(VBOOT_MAY_SKIP_DISPLAY_INIT)) {
+ /* For vboot, always honor VBOOT_WD_FLAG_DISPLAY_INIT. */
+ if (CONFIG(VBOOT)) {
/* Must always select MUST_REQUEST_DISPLAY when using this
function. */
if (!CONFIG(VBOOT_MUST_REQUEST_DISPLAY))
diff --git a/src/lib/bootsplash.c b/src/lib/bootsplash.c
new file mode 100644
index 0000000000..5527b233f5
--- /dev/null
+++ b/src/lib/bootsplash.c
@@ -0,0 +1,62 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2019 Johanna Schander
+ *
+ * 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; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include
+#include
+#include
+#include
+#include
+
+#include "jpeg.h"
+
+void set_vesa_bootsplash(void)
+{
+ const vbe_mode_info_t *mode_info = vbe_mode_info();
+ if (mode_info != NULL) {
+ printk(BIOS_INFO, "Setting up bootsplash\n");
+ unsigned int x_resolution = le16_to_cpu(mode_info->vesa.x_resolution);
+ unsigned int y_resolution = le16_to_cpu(mode_info->vesa.y_resolution);
+ unsigned int fb_resolution = mode_info->vesa.bits_per_pixel;
+ unsigned char *framebuffer =
+ (unsigned char *)le32_to_cpu(mode_info->vesa.phys_base_ptr);
+
+ set_bootsplash(framebuffer, x_resolution, y_resolution, fb_resolution);
+ } else {
+ printk(BIOS_ERR, "VBE modeinfo invalid\n");
+ }
+}
+
+
+void set_bootsplash(unsigned char *framebuffer, unsigned int x_resolution,
+ unsigned int y_resolution, unsigned int fb_resolution)
+{
+ struct jpeg_decdata *decdata;
+ unsigned char *jpeg =
+ cbfs_boot_map_with_leak("bootsplash.jpg", CBFS_TYPE_BOOTSPLASH, NULL);
+ if (!jpeg) {
+ printk(BIOS_ERR, "Could not find bootsplash.jpg\n");
+ return;
+ }
+
+ decdata = malloc(sizeof(*decdata));
+ int ret = jpeg_decode(jpeg, framebuffer, x_resolution, y_resolution, fb_resolution,
+ decdata);
+ if (ret != 0) {
+ printk(BIOS_ERR, "Bootsplash could not be decoded. jpeg_decode returned %d.\n",
+ ret);
+ return;
+ }
+ printk(BIOS_INFO, "Bootsplash loaded\n");
+}
diff --git a/src/lib/coreboot_table.c b/src/lib/coreboot_table.c
index df756983d0..95c2ae6e24 100644
--- a/src/lib/coreboot_table.c
+++ b/src/lib/coreboot_table.c
@@ -209,22 +209,6 @@ static void lb_vbnv(struct lb_header *header)
}
#endif /* CONFIG_CHROMEOS */
-static void lb_vboot_handoff(struct lb_header *header)
-{
- void *addr;
- uint32_t size;
- struct lb_range *vbho;
-
- if (vboot_get_handoff_info(&addr, &size))
- return;
-
- vbho = (struct lb_range *)lb_new_record(header);
- vbho->tag = LB_TAG_VBOOT_HANDOFF;
- vbho->size = sizeof(*vbho);
- vbho->range_start = (intptr_t)addr;
- vbho->range_size = size;
-}
-
static void lb_vboot_workbuf(struct lb_header *header)
{
struct lb_range *vbwb;
@@ -563,9 +547,6 @@ static uintptr_t write_coreboot_table(uintptr_t rom_table_end)
#endif
if (CONFIG(VBOOT)) {
- /* pass along the vboot_handoff address. */
- lb_vboot_handoff(head);
-
/* pass along the vboot workbuf address. */
lb_vboot_workbuf(head);
}
diff --git a/src/lib/edid.c b/src/lib/edid.c
index e2f213c5b0..3b81b5c30a 100644
--- a/src/lib/edid.c
+++ b/src/lib/edid.c
@@ -1207,14 +1207,16 @@ int decode_edid(unsigned char *edid, int size, struct edid *out)
switch (edid[0x13]) {
case 4:
c.claims_one_point_four = 1;
+ /* fall through */
case 3:
c.claims_one_point_three = 1;
+ /* fall through */
case 2:
c.claims_one_point_two = 1;
+ /* fall through */
default:
- break;
+ c.claims_one_point_oh = 1;
}
- c.claims_one_point_oh = 1;
}
/* display section */
diff --git a/src/lib/edid_fill_fb.c b/src/lib/edid_fill_fb.c
index 210c727224..1b38ead596 100644
--- a/src/lib/edid_fill_fb.c
+++ b/src/lib/edid_fill_fb.c
@@ -81,6 +81,11 @@ void set_vbe_mode_info_valid(const struct edid *edid, uintptr_t fb_addr)
fb_valid = 1;
}
+void set_vbe_framebuffer_orientation(enum lb_fb_orientation orientation)
+{
+ edid_fb.orientation = orientation;
+}
+
int fill_lb_framebuffer(struct lb_framebuffer *framebuffer)
{
if (!fb_valid)
diff --git a/src/lib/fit_payload.c b/src/lib/fit_payload.c
index a4d370540e..1b6c9860f0 100644
--- a/src/lib/fit_payload.c
+++ b/src/lib/fit_payload.c
@@ -51,6 +51,11 @@ static bool extract(struct region *region, struct fit_image_node *node)
const char *comp_name;
size_t true_size = 0;
+ if (node->size == 0) {
+ printk(BIOS_ERR, "ERROR: The %s size is 0\n", node->name);
+ return true;
+ }
+
switch (node->compression) {
case CBFS_COMPRESS_NONE:
comp_name = "Relocating uncompressed";
diff --git a/src/lib/hexdump.c b/src/lib/hexdump.c
index 1e689e3e53..2c9e483d1d 100644
--- a/src/lib/hexdump.c
+++ b/src/lib/hexdump.c
@@ -19,14 +19,13 @@
void hexdump(const void *memory, size_t length)
{
- int i;
+ size_t i, j;
uint8_t *line;
int all_zero = 0;
int all_one = 0;
size_t num_bytes;
for (i = 0; i < length; i += 16) {
- int j;
num_bytes = MIN(length - i, 16);
line = ((uint8_t *)memory) + i;
@@ -65,7 +64,7 @@ void hexdump(const void *memory, size_t length)
void hexdump32(char LEVEL, const void *d, size_t len)
{
- int count = 0;
+ size_t count = 0;
while (len > 0) {
if (count % 8 == 0) {
diff --git a/src/lib/ramdetect.c b/src/lib/ramdetect.c
new file mode 100644
index 0000000000..5416a580dd
--- /dev/null
+++ b/src/lib/ramdetect.c
@@ -0,0 +1,78 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include
+#include
+#include
+#include
+#include
+
+#define OVERLAP(a, b, s, e) ((b) > (s) && (a) < (e))
+
+static int probe_mb(const uintptr_t dram_start, const uintptr_t size)
+{
+ uintptr_t addr = dram_start + (size * MiB) - sizeof(uint32_t);
+ static const uint32_t patterns[] = {
+ 0x55aa55aa,
+ 0x12345678
+ };
+ void *ptr = (void *) addr;
+ size_t i;
+
+ /* Don't accidentally clober oneself. */
+ if (OVERLAP(addr, addr + sizeof(uint32_t), (uintptr_t)_program, (uintptr_t) _eprogram))
+ return 1;
+
+ uint32_t old = read32(ptr);
+ for (i = 0; i < ARRAY_SIZE(patterns); i++) {
+ write32(ptr, patterns[i]);
+ if (read32(ptr) != patterns[i])
+ break;
+ }
+
+ write32(ptr, old);
+ return i == ARRAY_SIZE(patterns);
+}
+
+/* - 20 as probe_size is in MiB, - 1 as i is signed */
+#define MAX_ADDRESSABLE_SPACE (sizeof(size_t) * 8 - 20 - 1)
+
+/* Probe an area if it's read/writable. */
+size_t probe_ramsize(const uintptr_t dram_start, const size_t probe_size)
+{
+ ssize_t i;
+ size_t msb = 0;
+ size_t discovered = 0;
+
+ static size_t saved_result;
+ if (saved_result)
+ return saved_result;
+
+ /* Find the MSB + 1. */
+ size_t tmp = probe_size;
+ do {
+ msb++;
+ } while (tmp >>= 1);
+
+ /* Limit search to accessible address space */
+ msb = MIN(msb, MAX_ADDRESSABLE_SPACE);
+
+ /* Compact binary search. */
+ for (i = msb; i >= 0; i--)
+ if (probe_mb(dram_start, (discovered | (1ULL << i))))
+ discovered |= (1ULL << i);
+
+ saved_result = discovered;
+ printk(BIOS_DEBUG, "RAMDETECT: Found %zu MiB RAM\n", discovered);
+ return discovered;
+}
diff --git a/src/mainboard/apple/macbookair4_2/devicetree.cb b/src/mainboard/apple/macbookair4_2/devicetree.cb
index 267ecb15fd..15ec61e717 100644
--- a/src/mainboard/apple/macbookair4_2/devicetree.cb
+++ b/src/mainboard/apple/macbookair4_2/devicetree.cb
@@ -38,7 +38,6 @@ chip northbridge/intel/sandybridge
register "gen3_dec" = "0x001c0301"
register "gen4_dec" = "0x00fc0701"
register "gpi7_routing" = "2"
- register "p_cnt_throttling_supported" = "1"
register "pcie_hotplug_map" = "{ 0, 0, 0, 0, 0, 0, 0, 0 }"
register "pcie_port_coalesce" = "1"
register "sata_interface_speed_support" = "0x3"
diff --git a/src/mainboard/apple/macbookair4_2/gpio.c b/src/mainboard/apple/macbookair4_2/gpio.c
index d92269b0dd..485ca9520d 100644
--- a/src/mainboard/apple/macbookair4_2/gpio.c
+++ b/src/mainboard/apple/macbookair4_2/gpio.c
@@ -12,7 +12,7 @@
*/
#include
-const struct pch_gpio_set1 pch_gpio_set1_mode = {
+static const struct pch_gpio_set1 pch_gpio_set1_mode = {
.gpio0 = GPIO_MODE_GPIO,
.gpio1 = GPIO_MODE_GPIO,
.gpio2 = GPIO_MODE_GPIO,
@@ -47,7 +47,7 @@ const struct pch_gpio_set1 pch_gpio_set1_mode = {
.gpio31 = GPIO_MODE_NATIVE,
};
-const struct pch_gpio_set1 pch_gpio_set1_direction = {
+static const struct pch_gpio_set1 pch_gpio_set1_direction = {
.gpio0 = GPIO_DIR_INPUT,
.gpio1 = GPIO_DIR_INPUT,
.gpio2 = GPIO_DIR_INPUT,
@@ -82,7 +82,7 @@ const struct pch_gpio_set1 pch_gpio_set1_direction = {
.gpio31 = GPIO_DIR_INPUT,
};
-const struct pch_gpio_set1 pch_gpio_set1_level = {
+static const struct pch_gpio_set1 pch_gpio_set1_level = {
.gpio0 = GPIO_LEVEL_HIGH,
.gpio1 = GPIO_LEVEL_HIGH,
.gpio2 = GPIO_LEVEL_HIGH,
@@ -117,7 +117,7 @@ const struct pch_gpio_set1 pch_gpio_set1_level = {
.gpio31 = GPIO_LEVEL_HIGH,
};
-const struct pch_gpio_set1 pch_gpio_set1_reset = {
+static const struct pch_gpio_set1 pch_gpio_set1_reset = {
.gpio0 = GPIO_RESET_PWROK,
.gpio1 = GPIO_RESET_PWROK,
.gpio2 = GPIO_RESET_PWROK,
@@ -152,7 +152,7 @@ const struct pch_gpio_set1 pch_gpio_set1_reset = {
.gpio31 = GPIO_RESET_PWROK,
};
-const struct pch_gpio_set1 pch_gpio_set1_invert = {
+static const struct pch_gpio_set1 pch_gpio_set1_invert = {
.gpio0 = GPIO_NO_INVERT,
.gpio1 = GPIO_INVERT,
.gpio2 = GPIO_NO_INVERT,
@@ -187,7 +187,7 @@ const struct pch_gpio_set1 pch_gpio_set1_invert = {
.gpio31 = GPIO_NO_INVERT,
};
-const struct pch_gpio_set1 pch_gpio_set1_blink = {
+static const struct pch_gpio_set1 pch_gpio_set1_blink = {
.gpio0 = GPIO_NO_BLINK,
.gpio1 = GPIO_NO_BLINK,
.gpio2 = GPIO_NO_BLINK,
@@ -222,7 +222,7 @@ const struct pch_gpio_set1 pch_gpio_set1_blink = {
.gpio31 = GPIO_NO_BLINK,
};
-const struct pch_gpio_set2 pch_gpio_set2_mode = {
+static const struct pch_gpio_set2 pch_gpio_set2_mode = {
.gpio32 = GPIO_MODE_NATIVE,
.gpio33 = GPIO_MODE_GPIO,
.gpio34 = GPIO_MODE_GPIO,
@@ -257,7 +257,7 @@ const struct pch_gpio_set2 pch_gpio_set2_mode = {
.gpio63 = GPIO_MODE_NATIVE,
};
-const struct pch_gpio_set2 pch_gpio_set2_direction = {
+static const struct pch_gpio_set2 pch_gpio_set2_direction = {
.gpio32 = GPIO_DIR_OUTPUT,
.gpio33 = GPIO_DIR_OUTPUT,
.gpio34 = GPIO_DIR_OUTPUT,
@@ -292,7 +292,7 @@ const struct pch_gpio_set2 pch_gpio_set2_direction = {
.gpio63 = GPIO_DIR_OUTPUT,
};
-const struct pch_gpio_set2 pch_gpio_set2_level = {
+static const struct pch_gpio_set2 pch_gpio_set2_level = {
.gpio32 = GPIO_LEVEL_LOW,
.gpio33 = GPIO_LEVEL_LOW,
.gpio34 = GPIO_LEVEL_HIGH,
@@ -327,7 +327,7 @@ const struct pch_gpio_set2 pch_gpio_set2_level = {
.gpio63 = GPIO_LEVEL_HIGH,
};
-const struct pch_gpio_set2 pch_gpio_set2_reset = {
+static const struct pch_gpio_set2 pch_gpio_set2_reset = {
.gpio32 = GPIO_RESET_PWROK,
.gpio33 = GPIO_RESET_PWROK,
.gpio34 = GPIO_RESET_PWROK,
@@ -362,7 +362,7 @@ const struct pch_gpio_set2 pch_gpio_set2_reset = {
.gpio63 = GPIO_RESET_PWROK,
};
-const struct pch_gpio_set3 pch_gpio_set3_mode = {
+static const struct pch_gpio_set3 pch_gpio_set3_mode = {
.gpio64 = GPIO_MODE_GPIO,
.gpio65 = GPIO_MODE_GPIO,
.gpio66 = GPIO_MODE_GPIO,
@@ -377,7 +377,7 @@ const struct pch_gpio_set3 pch_gpio_set3_mode = {
.gpio75 = GPIO_MODE_NATIVE,
};
-const struct pch_gpio_set3 pch_gpio_set3_direction = {
+static const struct pch_gpio_set3 pch_gpio_set3_direction = {
.gpio64 = GPIO_DIR_INPUT,
.gpio65 = GPIO_DIR_INPUT,
.gpio66 = GPIO_DIR_INPUT,
@@ -392,7 +392,7 @@ const struct pch_gpio_set3 pch_gpio_set3_direction = {
.gpio75 = GPIO_DIR_INPUT,
};
-const struct pch_gpio_set3 pch_gpio_set3_level = {
+static const struct pch_gpio_set3 pch_gpio_set3_level = {
.gpio64 = GPIO_LEVEL_LOW,
.gpio65 = GPIO_LEVEL_LOW,
.gpio66 = GPIO_LEVEL_LOW,
@@ -407,7 +407,7 @@ const struct pch_gpio_set3 pch_gpio_set3_level = {
.gpio75 = GPIO_LEVEL_HIGH,
};
-const struct pch_gpio_set3 pch_gpio_set3_reset = {
+static const struct pch_gpio_set3 pch_gpio_set3_reset = {
.gpio64 = GPIO_RESET_PWROK,
.gpio65 = GPIO_RESET_PWROK,
.gpio66 = GPIO_RESET_PWROK,
diff --git a/src/mainboard/asrock/b75pro3-m/devicetree.cb b/src/mainboard/asrock/b75pro3-m/devicetree.cb
index 9eba6fca82..32438a102f 100644
--- a/src/mainboard/asrock/b75pro3-m/devicetree.cb
+++ b/src/mainboard/asrock/b75pro3-m/devicetree.cb
@@ -58,7 +58,6 @@ chip northbridge/intel/sandybridge
register "gen1_dec" = "0x000c0291"
register "gen2_dec" = "0x000c0241"
register "gen3_dec" = "0x000c0251"
- register "p_cnt_throttling_supported" = "0"
register "pcie_hotplug_map" = "{ 0, 0, 0, 0, 0, 0, 0, 0 }"
register "pcie_port_coalesce" = "0"
register "sata_interface_speed_support" = "0x3"
diff --git a/src/mainboard/asus/maximus_iv_gene-z/devicetree.cb b/src/mainboard/asus/maximus_iv_gene-z/devicetree.cb
index 4b80f393f6..0c25d4d91a 100644
--- a/src/mainboard/asus/maximus_iv_gene-z/devicetree.cb
+++ b/src/mainboard/asus/maximus_iv_gene-z/devicetree.cb
@@ -40,7 +40,6 @@ chip northbridge/intel/sandybridge
chip southbridge/intel/bd82x6x
register "c2_latency" = "101"
register "gen1_dec" = "0x00000295" # Super I/O HWM
- register "p_cnt_throttling_supported" = "1"
register "sata_port_map" = "0x3f"
register "spi_lvscc" = "0x2005"
register "spi_uvscc" = "0x2005"
diff --git a/src/mainboard/asus/p5gc-mx/devicetree.cb b/src/mainboard/asus/p5gc-mx/devicetree.cb
index de63da2a5d..972dc5dc1f 100644
--- a/src/mainboard/asus/p5gc-mx/devicetree.cb
+++ b/src/mainboard/asus/p5gc-mx/devicetree.cb
@@ -50,7 +50,6 @@ chip northbridge/intel/i945
register "gpe0_en" = "0"
- register "ide_legacy_combined" = "0x0"
register "ide_enable_primary" = "0x1"
register "ide_enable_secondary" = "0x0"
diff --git a/src/mainboard/asus/p5gc-mx/gpio.c b/src/mainboard/asus/p5gc-mx/gpio.c
index 55c2b3f0dc..d225ba00c5 100644
--- a/src/mainboard/asus/p5gc-mx/gpio.c
+++ b/src/mainboard/asus/p5gc-mx/gpio.c
@@ -15,7 +15,7 @@
#include
-const struct pch_gpio_set1 pch_gpio_set1_mode = {
+static const struct pch_gpio_set1 pch_gpio_set1_mode = {
.gpio0 = GPIO_MODE_GPIO,
.gpio6 = GPIO_MODE_GPIO,
.gpio7 = GPIO_MODE_GPIO,
@@ -39,7 +39,7 @@ const struct pch_gpio_set1 pch_gpio_set1_mode = {
.gpio28 = GPIO_MODE_GPIO,
};
-const struct pch_gpio_set1 pch_gpio_set1_direction = {
+static const struct pch_gpio_set1 pch_gpio_set1_direction = {
.gpio0 = GPIO_DIR_OUTPUT,
.gpio6 = GPIO_DIR_INPUT,
.gpio7 = GPIO_DIR_INPUT,
@@ -63,7 +63,7 @@ const struct pch_gpio_set1 pch_gpio_set1_direction = {
.gpio28 = GPIO_DIR_OUTPUT,
};
-const struct pch_gpio_set1 pch_gpio_set1_level = {
+static const struct pch_gpio_set1 pch_gpio_set1_level = {
.gpio0 = GPIO_LEVEL_LOW,
.gpio11 = GPIO_LEVEL_HIGH,
.gpio16 = GPIO_LEVEL_LOW,
@@ -76,15 +76,15 @@ const struct pch_gpio_set1 pch_gpio_set1_level = {
.gpio28 = GPIO_LEVEL_LOW,
};
-const struct pch_gpio_set1 pch_gpio_set1_blink = {
+static const struct pch_gpio_set1 pch_gpio_set1_blink = {
};
-const struct pch_gpio_set1 pch_gpio_set1_invert = {
+static const struct pch_gpio_set1 pch_gpio_set1_invert = {
.gpio13 = GPIO_INVERT,
.gpio14 = GPIO_INVERT,
};
-const struct pch_gpio_set2 pch_gpio_set2_mode = {
+static const struct pch_gpio_set2 pch_gpio_set2_mode = {
.gpio32 = GPIO_MODE_NATIVE,
.gpio33 = GPIO_MODE_NATIVE,
.gpio34 = GPIO_MODE_NATIVE,
@@ -95,7 +95,7 @@ const struct pch_gpio_set2 pch_gpio_set2_mode = {
.gpio39 = GPIO_MODE_NATIVE,
};
-const struct pch_gpio_set2 pch_gpio_set2_direction = {
+static const struct pch_gpio_set2 pch_gpio_set2_direction = {
.gpio32 = GPIO_DIR_OUTPUT,
.gpio33 = GPIO_DIR_OUTPUT,
.gpio34 = GPIO_DIR_OUTPUT,
@@ -106,7 +106,7 @@ const struct pch_gpio_set2 pch_gpio_set2_direction = {
.gpio39 = GPIO_DIR_INPUT,
};
-const struct pch_gpio_set2 pch_gpio_set2_level = {
+static const struct pch_gpio_set2 pch_gpio_set2_level = {
.gpio32 = GPIO_LEVEL_HIGH,
.gpio33 = GPIO_LEVEL_HIGH,
.gpio34 = GPIO_LEVEL_LOW,
diff --git a/src/mainboard/asus/p5qpl-am/variants/p5g41t-m_lx/gpio.c b/src/mainboard/asus/p5qpl-am/variants/p5g41t-m_lx/gpio.c
index 0c191353b1..90fd9e4265 100644
--- a/src/mainboard/asus/p5qpl-am/variants/p5g41t-m_lx/gpio.c
+++ b/src/mainboard/asus/p5qpl-am/variants/p5g41t-m_lx/gpio.c
@@ -15,7 +15,7 @@
#include
-const struct pch_gpio_set1 pch_gpio_set1_mode = {
+static const struct pch_gpio_set1 pch_gpio_set1_mode = {
.gpio0 = GPIO_MODE_GPIO,
.gpio1 = GPIO_MODE_NATIVE,
.gpio2 = GPIO_MODE_NATIVE,
@@ -50,7 +50,7 @@ const struct pch_gpio_set1 pch_gpio_set1_mode = {
.gpio31 = GPIO_MODE_NATIVE,
};
-const struct pch_gpio_set1 pch_gpio_set1_direction = {
+static const struct pch_gpio_set1 pch_gpio_set1_direction = {
.gpio0 = GPIO_DIR_INPUT,
.gpio1 = GPIO_DIR_INPUT,
.gpio2 = GPIO_DIR_OUTPUT,
@@ -85,7 +85,7 @@ const struct pch_gpio_set1 pch_gpio_set1_direction = {
.gpio31 = GPIO_DIR_INPUT,
};
-const struct pch_gpio_set1 pch_gpio_set1_level = {
+static const struct pch_gpio_set1 pch_gpio_set1_level = {
.gpio0 = GPIO_LEVEL_HIGH,
.gpio6 = GPIO_LEVEL_HIGH,
.gpio7 = GPIO_LEVEL_LOW,
@@ -108,12 +108,12 @@ const struct pch_gpio_set1 pch_gpio_set1_level = {
.gpio28 = GPIO_LEVEL_LOW,
};
-const struct pch_gpio_set1 pch_gpio_set1_invert = {
+static const struct pch_gpio_set1 pch_gpio_set1_invert = {
.gpio10 = GPIO_INVERT,
.gpio13 = GPIO_INVERT,
};
-const struct pch_gpio_set2 pch_gpio_set2_mode = {
+static const struct pch_gpio_set2 pch_gpio_set2_mode = {
.gpio32 = GPIO_MODE_GPIO,
.gpio33 = GPIO_MODE_GPIO,
.gpio34 = GPIO_MODE_GPIO,
@@ -124,7 +124,7 @@ const struct pch_gpio_set2 pch_gpio_set2_mode = {
.gpio39 = GPIO_MODE_GPIO,
};
-const struct pch_gpio_set2 pch_gpio_set2_direction = {
+static const struct pch_gpio_set2 pch_gpio_set2_direction = {
.gpio32 = GPIO_DIR_OUTPUT,
.gpio33 = GPIO_DIR_OUTPUT,
.gpio34 = GPIO_DIR_OUTPUT,
@@ -135,7 +135,7 @@ const struct pch_gpio_set2 pch_gpio_set2_direction = {
.gpio39 = GPIO_DIR_INPUT,
};
-const struct pch_gpio_set2 pch_gpio_set2_level = {
+static const struct pch_gpio_set2 pch_gpio_set2_level = {
.gpio32 = GPIO_LEVEL_HIGH,
.gpio33 = GPIO_LEVEL_HIGH,
.gpio34 = GPIO_LEVEL_LOW,
diff --git a/src/mainboard/asus/p8h61-m_lx/devicetree.cb b/src/mainboard/asus/p8h61-m_lx/devicetree.cb
index ef8071fabb..27705b91f7 100644
--- a/src/mainboard/asus/p8h61-m_lx/devicetree.cb
+++ b/src/mainboard/asus/p8h61-m_lx/devicetree.cb
@@ -40,7 +40,6 @@ chip northbridge/intel/sandybridge
chip southbridge/intel/bd82x6x
register "c2_latency" = "101"
register "gen1_dec" = "0x00000295" # Super I/O HWM
- register "p_cnt_throttling_supported" = "1"
register "sata_port_map" = "0x33"
register "spi_lvscc" = "0x2005"
register "spi_uvscc" = "0x2005"
diff --git a/src/mainboard/asus/p8h61-m_pro/devicetree.cb b/src/mainboard/asus/p8h61-m_pro/devicetree.cb
index d3f1795f91..e791d70976 100644
--- a/src/mainboard/asus/p8h61-m_pro/devicetree.cb
+++ b/src/mainboard/asus/p8h61-m_pro/devicetree.cb
@@ -34,7 +34,6 @@ chip northbridge/intel/sandybridge
register "c2_latency" = "0x0065"
register "docking_supported" = "0"
register "gen1_dec" = "0x000c0291" # HWM
- register "p_cnt_throttling_supported" = "0"
register "pcie_hotplug_map" = "{ 0, 0, 0, 0, 0, 0, 0, 0 }"
register "sata_interface_speed_support" = "0x3"
register "sata_port_map" = "0x33"
diff --git a/src/mainboard/cavium/cn8100_sff_evb/Makefile.inc b/src/mainboard/cavium/cn8100_sff_evb/Makefile.inc
index be35511cff..72736255f8 100644
--- a/src/mainboard/cavium/cn8100_sff_evb/Makefile.inc
+++ b/src/mainboard/cavium/cn8100_sff_evb/Makefile.inc
@@ -29,10 +29,10 @@ verstage-y += memlayout.ld
MB_DIR = src/mainboard/$(MAINBOARDDIR)
LINUX_DTB = sff8104-linux.dtb
-build/$(LINUX_DTB):
+$(obj)/$(LINUX_DTB):
# FIXME: why isn't this producing the correct size DTB?
- dtc -p 4096 -I dts -O dtb -o build/$(LINUX_DTB) -i $(MB_DIR) $(MB_DIR)/$(patsubst %.dtb,%.dts,$(LINUX_DTB))
+ dtc -p 4096 -I dts -O dtb -o $(obj)/$(LINUX_DTB) -i $(MB_DIR) $(MB_DIR)/$(patsubst %.dtb,%.dts,$(LINUX_DTB))
cbfs-files-y += $(LINUX_DTB)
-$(LINUX_DTB)-file := build/$(LINUX_DTB)
+$(LINUX_DTB)-file := $(obj)/$(LINUX_DTB)
$(LINUX_DTB)-type := raw
diff --git a/src/mainboard/compulab/intense_pc/devicetree.cb b/src/mainboard/compulab/intense_pc/devicetree.cb
index a6bcb1d7aa..6fa9e8357d 100644
--- a/src/mainboard/compulab/intense_pc/devicetree.cb
+++ b/src/mainboard/compulab/intense_pc/devicetree.cb
@@ -48,7 +48,6 @@ chip northbridge/intel/sandybridge # FIXME: check gfx.ndid and gfx.did
register "gen3_dec" = "0x000406f1"
register "gen4_dec" = "0x000c06a1"
register "gpi7_routing" = "2"
- register "p_cnt_throttling_supported" = "1"
register "pcie_hotplug_map" = "{ 0, 0, 0, 0, 0, 0, 0, 0 }"
register "pcie_port_coalesce" = "1"
register "sata_interface_speed_support" = "0x3"
diff --git a/src/mainboard/cubietech/Kconfig b/src/mainboard/cubietech/Kconfig
deleted file mode 100644
index c0e9cc1357..0000000000
--- a/src/mainboard/cubietech/Kconfig
+++ /dev/null
@@ -1,17 +0,0 @@
-if VENDOR_CUBIETECH
-
-# Auto select common options
-choice
- prompt "Mainboard model"
-
-source "src/mainboard/cubietech/*/Kconfig.name"
-
-endchoice
-
-source "src/mainboard/cubietech/*/Kconfig"
-
-config MAINBOARD_VENDOR
- string
- default "Cubietech"
-
-endif # VENDOR_CUBIETECH
diff --git a/src/mainboard/cubietech/Kconfig.name b/src/mainboard/cubietech/Kconfig.name
deleted file mode 100644
index 0ebc0885be..0000000000
--- a/src/mainboard/cubietech/Kconfig.name
+++ /dev/null
@@ -1,2 +0,0 @@
-config VENDOR_CUBIETECH
- bool "Cubietech"
diff --git a/src/mainboard/cubietech/cubieboard/Kconfig b/src/mainboard/cubietech/cubieboard/Kconfig
deleted file mode 100644
index 9ef5797044..0000000000
--- a/src/mainboard/cubietech/cubieboard/Kconfig
+++ /dev/null
@@ -1,30 +0,0 @@
-if BOARD_CUBIETECH_CUBIEBOARD
-
-config BOARD_SPECIFIC_OPTIONS
- def_bool y
- select CPU_ALLWINNER_A10
- select BOARD_ROMSIZE_KB_4096
- select DRIVER_XPOWERS_AXP209
- select MISSING_BOARD_RESET
-
-config MAINBOARD_DIR
- string
- default cubietech/cubieboard
-
-config MAINBOARD_PART_NUMBER
- string
- default "Cubieboard A10"
-
-config MAX_CPUS
- int
- default 1
-
-config DRAM_SIZE_MB
- int
- default 1024
-
-config UART_FOR_CONSOLE
- int
- default 0
-
-endif # BOARD_CUBIETECH_CUBIEBOARD
diff --git a/src/mainboard/cubietech/cubieboard/Kconfig.name b/src/mainboard/cubietech/cubieboard/Kconfig.name
deleted file mode 100644
index 3a011819b4..0000000000
--- a/src/mainboard/cubietech/cubieboard/Kconfig.name
+++ /dev/null
@@ -1,2 +0,0 @@
-config BOARD_CUBIETECH_CUBIEBOARD
- bool "Cubieboard"
diff --git a/src/mainboard/cubietech/cubieboard/Makefile.inc b/src/mainboard/cubietech/cubieboard/Makefile.inc
deleted file mode 100644
index f3a6de237d..0000000000
--- a/src/mainboard/cubietech/cubieboard/Makefile.inc
+++ /dev/null
@@ -1,6 +0,0 @@
-bootblock-y += bootblock.c
-romstage-y += romstage.c
-
-bootblock-y += memlayout.ld
-romstage-y += memlayout.ld
-ramstage-y += memlayout.ld
diff --git a/src/mainboard/cubietech/cubieboard/board_info.txt b/src/mainboard/cubietech/cubieboard/board_info.txt
deleted file mode 100644
index c67b641a94..0000000000
--- a/src/mainboard/cubietech/cubieboard/board_info.txt
+++ /dev/null
@@ -1 +0,0 @@
-Category: sbc
diff --git a/src/mainboard/cubietech/cubieboard/bootblock.c b/src/mainboard/cubietech/cubieboard/bootblock.c
deleted file mode 100644
index 05e3847d39..0000000000
--- a/src/mainboard/cubietech/cubieboard/bootblock.c
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2013 Alexandru Gagniuc