diff --git a/.clang-format b/.clang-format index d853f50480..5c8aa3c439 100644 --- a/.clang-format +++ b/.clang-format @@ -7,7 +7,7 @@ AllowShortIfStatementsOnASingleLine: false IndentCaseLabels: false SortIncludes: false ContinuationIndentWidth: 8 -ColumnLimit: 0 +ColumnLimit: 96 AlwaysBreakBeforeMultilineStrings: true AllowShortLoopsOnASingleLine: false AllowShortFunctionsOnASingleLine: false diff --git a/.gitmodules b/.gitmodules index ddd8c88094..a656998655 100644 --- a/.gitmodules +++ b/.gitmodules @@ -29,3 +29,8 @@ [submodule "opensbi"] path = 3rdparty/opensbi url = https://github.com/coreboot/opensbi.git +[submodule "intel-microcode"] + path = 3rdparty/intel-microcode + url = https://github.com/coreboot/intel-microcode.git + update = none + ignore = dirty diff --git a/3rdparty/blobs b/3rdparty/blobs index ca6cfcdbe1..d7600dd871 160000 --- a/3rdparty/blobs +++ b/3rdparty/blobs @@ -1 +1 @@ -Subproject commit ca6cfcdbe1cdeb38c2622ee2e5236cc4657e3377 +Subproject commit d7600dd8718a076f0f9a89e53968b484254624dc diff --git a/3rdparty/intel-microcode b/3rdparty/intel-microcode new file mode 160000 index 0000000000..1dd14da6d1 --- /dev/null +++ b/3rdparty/intel-microcode @@ -0,0 +1 @@ +Subproject commit 1dd14da6d1ea5cfbd95923653f31c04aac3aa655 diff --git a/Documentation/arch/riscv/index.md b/Documentation/arch/riscv/index.md index 888651dba6..9a5de34f09 100644 --- a/Documentation/arch/riscv/index.md +++ b/Documentation/arch/riscv/index.md @@ -15,7 +15,7 @@ Payloads run from the ramstage are started in S mode, and trap delegation will have been done. These payloads rely on the SBI and can not replace it. ## Stage handoff protocol -On entry to a stage or payload, +On entry to a stage or payload (including SELF payloads), * all harts are running. * A0 is the hart ID. * A1 is the pointer to the Flattened Device Tree (FDT). diff --git a/Documentation/drivers/index.md b/Documentation/drivers/index.md new file mode 100644 index 0000000000..642ae1a5f3 --- /dev/null +++ b/Documentation/drivers/index.md @@ -0,0 +1,7 @@ +# Platform indenpendend drivers documentation + +The drivers can be found in `src/drivers`. They are intended for onboard +and plugin devices, significantly reducing integration complexity and +they allow to easily reuse existing code accross platforms. + +* [IPMI KCS](ipmi_kcs.md) diff --git a/Documentation/drivers/ipmi_kcs.md b/Documentation/drivers/ipmi_kcs.md new file mode 100644 index 0000000000..f6f0fb986a --- /dev/null +++ b/Documentation/drivers/ipmi_kcs.md @@ -0,0 +1,47 @@ +# IPMI KCS driver + +The driver can be found in `src/drivers/ipmi/`. It works with BMC that provide +a KCS I/O interface as specified in the [IPMI] standard. + +The driver detects the IPMI version, reserves the I/O space in coreboot's +resource allocator and writes the required ACPI and SMBIOS tables. + +## For developers + +To use the driver, select the `IPMI_KCS` Kconfig and add the following PNP +device under the LPC bridge device (in example for the KCS at 0xca2): + +``` + chip drivers/ipmi + device pnp ca2.0 on end # IPMI KCS + end +``` + +**Note:** The I/O base address needs to be aligned to 2. + +The following registers can be set: + +* `have_nv_storage` + * Boolean + * If true `nv_storage_device_address` will be added to SMBIOS type 38. +* `nv_storage_device_address` + * Integer + * The NV storage address as defined in SMBIOS spec for type 38. +* `bmc_i2c_address` + * Integer + * The i2c address of the BMC. zero if not applicable. +* `have_apic` + * Boolean + * If true the `apic_interrupt` will be added to SPMI table. +* `apic_interrupt` + * Integer + * The APIC interrupt used to notify about a change on the KCS. +* `have_gpe` + * Boolean + * If true the `gpe_interrupt` will be added to SPMI table. +* `gpe_interrupt` + * Integer + * The bit in GPE (SCI) used to notify about a change on the KCS. + + +[IPMI]: https://www.intel.com/content/dam/www/public/us/en/documents/product-briefs/ipmi-second-gen-interface-spec-v2-rev1-1.pdf diff --git a/Documentation/index.md b/Documentation/index.md index 76faffa497..a2c2878ddb 100644 --- a/Documentation/index.md +++ b/Documentation/index.md @@ -175,6 +175,7 @@ Contents: * [Native Graphics Initialization with libgfxinit](gfx/libgfxinit.md) * [Display panel-specific documentation](gfx/display-panel.md) * [Architecture-specific documentation](arch/index.md) +* [Platform independend drivers documentation](drivers/index.md) * [Northbridge-specific documentation](northbridge/index.md) * [System on Chip-specific documentation](soc/index.md) * [Mainboard-specific documentation](mainboard/index.md) diff --git a/Documentation/mainboard/asus/p8z77-m_pro.jpg b/Documentation/mainboard/asus/p8z77-m_pro.jpg new file mode 100644 index 0000000000..bc6ef2894b Binary files /dev/null and b/Documentation/mainboard/asus/p8z77-m_pro.jpg differ diff --git a/Documentation/mainboard/asus/p8z77-m_pro.md b/Documentation/mainboard/asus/p8z77-m_pro.md new file mode 100644 index 0000000000..7c841499fc --- /dev/null +++ b/Documentation/mainboard/asus/p8z77-m_pro.md @@ -0,0 +1,168 @@ +# ASUS P8Z77-M Pro + +This page describes how to run coreboot on the [ASUS P8Z77-M Pro] + +## Flashing coreboot + +```eval_rst ++---------------------+----------------+ +| Type | Value | ++=====================+================+ +| Socketed flash | yes | ++---------------------+----------------+ +| Model | W25Q64FVA1Q | ++---------------------+----------------+ +| Size | 8 MiB | ++---------------------+----------------+ +| Package | DIP-8 | ++---------------------+----------------+ +| Write protection | yes | ++---------------------+----------------+ +| Dual BIOS feature | no | ++---------------------+----------------+ +| Internal flashing | yes | ++---------------------+----------------+ +``` + +The flash IC is located right next to one of the SATA ports: +![](p8z77-m_pro.jpg) + +### Internal programming + +The main SPI flash cannot be written because Asus disables BIOSWE and +enables BLE/SMM_BWP flags in BIOS_CNTL for their latest bioses. +An external programmer is required. You must flash standalone, +flashing in-circuit doesn't work. The flash chip is socketed, so it's +easy to remove and reflash. + +## Working + +- PS/2 keyboard with SeaBIOS & Tianocore (in Mint 18.3/19.1) + +- Rear/front headphones connector audio & mic + +- S3 Suspend to RAM (tested with OS installed in a HDD/SSD and also with a + Mint 18.3/19.1 LiveUSB pendrive connected to USB3/USB2), but please + see [Known issues] + +- USB2 on rear (tested mouse/keyboard plugged there. Also, booting with + a Mint 18./19.1 LiveUSB works ok) + +- USB3 (Z77's and Asmedia's works, but please see [Known issues]) + +- Gigabit Ethernet (RTL8111F) + +- SATA3, SATA2 and eSATA (tested on all ports, hot-swap and TCG OPAL working) + (Blue SATA2) (Blue SATA2) (White SATA3) (Red eSATA SATA3 rear) + port 3 port 5 port 1 port 8 + port 4 port 6 port 2 port 7 + +- NVME SSD boot on PCIe-x16/x8/4x slot using Tianocore + (tested with M.2-to-PCIe adapter and a M.2 Samsung EVO 970 SSD) + +- CPU Temp sensors (tested PSensor on linux + HWINFO64 on Win10) + +- TPM on TPM-header (tested tpm-tools with Asus TPM 1.2 Infineon SLB9635TT12) + +- Native raminit and also MRC.bin(systemagent-r6.bin) memory initialization + (please see [Native raminit compatibility] and [MRC memory compatibility]) + +- Integrated graphics with both libgfxinit and the Intel Video BIOS OpROM + (VGA/DVI-D/HDMI tested and working) + +- 1x PCIe GPU in PCIe-16x/8x/4x slots (tested using Zotac GeForce GTX + 750Ti and FirePro W5100 under Mint 18.3/19.1) + +## Known issues + +- The rear's USB3s on bottom (closest to the PCB) have problems booting or + being used before the OS loads. For better compatibility, please use + the Z77's ones above the Ethernet connector or the Asmedia's top one + +- After S3 suspend, some USB3 connectors on rear seem not to work + +- At the moment, the power led does not blink when entering S3 state + +- Currently, we have not setup the SuperIO's Hardware Monitor (HWM), + so only the CPU sensors are reported + +- If you use the MRC.bin, the NVRAM variable gfx_uma_size may be ignored + as IGP's UMA could be reconfigured by the blob + +- Using TianoCore + a PCIe GPU under Windows crashes with an + ACPI_BIOS_ERROR fatal code, not sure why. Using just the IGP + works perfectly + +- Under Windows 10, if you experiment problems with PS/2 devices, change + HKLM\SYSTEM\CurrentControlSet\Services\i8042prt->Start from '3' to '1' + +## Untested + +- EHCI debugging +- S/PDIF audio +- Wake-on-LAN +- Serial port + +## Not working + +- PS/2 keyboard in Win10 using Tianocore (please see [Known issues]) +- PS/2 mouse using Tianocore +- PCIe graphics card on Windows and Tianocore (throws critical ACPI_BIOS_ERROR) + +## Native raminit compatibility + +- GSkill F3-2133C10D-16GAB(XMP,1.60v) 2x8GB kit works at 1333Mhz instead + of XMP 2133Mhz + +- Team Xtreem TXD38G2133HC9NDC01(XMP,1.50v) 2x4GB kit works at 1600Mhz + instead of XMP 2133Mhz + +- Kingston KVR1066D3N7K2/4G(JEDEC,1.50v) 2x4GB kit works at 1066Mhz + but the board only detects half its RAM, because those DIMMs have + Double Sided(DS) chips and seems only Single Sided(SS) ones are + fully detected + +- GSkill F3-10666CL9T2-24GBRL(JEDEC,1.50v) 6x4GB kit (4 DIMMs used) + works perfectly at full speed (1333Mhz) + +## MRC memory compatibility + +- GSkill F3-2133C10D-16GAB(XMP,1.60v) 2x8GB kit works at 1333Mhz + instead of XMP 2133Mhz + +- Team Xtreem TXD38G2133HC9NDC01(XMP,1.50v) 2x4GB kit works at + 1600Mhz instead of XMP 2133Mhz + +- Kingston KVR1066D3N7K2/4G(JEDEC,1.50v) 2x4GB kit works at 1066Mhz + but the board only detects half its RAM, as those DIMMs have + Double Sided(DS) chips and seems only Single Sided(SS) ones are + fully detected + +- GSkill F3-10666CL9T2-24GBRL(JEDEC,1.50v) 6x4GB kit (4 DIMMs used) + works perfectly at full speed (1333Mhz) + +## Technology + +```eval_rst ++------------------+--------------------------------------------------+ +| Northbridge | :doc:`../../northbridge/intel/sandybridge/index` | ++------------------+--------------------------------------------------+ +| Southbridge | bd82x6x | ++------------------+--------------------------------------------------+ +| CPU | model_206ax | ++------------------+--------------------------------------------------+ +| Super I/O | Nuvoton NCT6779D | ++------------------+--------------------------------------------------+ +| EC | None | ++------------------+--------------------------------------------------+ +| Coprocessor | Intel Management Engine | ++------------------+--------------------------------------------------+ +``` + +## Extra resources + +- [Flash chip datasheet][W25Q64FVA1Q] + +[ASUS P8Z88-M Pro]: https://www.asus.com/Motherboards/P8Z77M_PRO/ +[W25Q64FVA1Q]: https://www.winbond.com/resource-files/w25q64fv%20revs%2007182017.pdf +[flashrom]: https://flashrom.org/Flashrom diff --git a/Documentation/mainboard/index.md b/Documentation/mainboard/index.md index 03af2c338c..14c62edeb9 100644 --- a/Documentation/mainboard/index.md +++ b/Documentation/mainboard/index.md @@ -7,6 +7,7 @@ This section contains documentation about coreboot on specific mainboards. - [F2A85-M](asus/f2a85-m.md) - [P8H61-M LX](asus/p8h61-m_lx.md) - [P8H61-M Pro](asus/p8h61-m_pro.md) +- [P8Z77-M Pro](asus/p8z77-m_pro.md) ## ASRock @@ -86,10 +87,18 @@ The boards in this section are not real mainboards, but emulators. - [MS-7707](msi/ms7707/ms7707.md) +## PC Engines + +- [APU2](pcengines/apu2.md) + ## Roda - [RK9 Flash Header](roda/rk9/flash_header.md) +## PC Engines + +- [APU1](pcengines/apu1.md) + ## SiFive - [SiFive HiFive Unleashed](sifive/hifive-unleashed.md) diff --git a/Documentation/mainboard/pcengines/apu1.md b/Documentation/mainboard/pcengines/apu1.md new file mode 100644 index 0000000000..ccadd63a61 --- /dev/null +++ b/Documentation/mainboard/pcengines/apu1.md @@ -0,0 +1,97 @@ +# PC Engines APU1 + +This page describes how to run coreboot on PC Engines APU1 platform. + +## Technology + +```eval_rst ++------------+--------------------------------------------------------+ +| CPU | AMD G series T40E APU | ++------------+--------------------------------------------------------+ +| CPU core | 1 GHz dual core (Bobcat core) with 64 bit support | +| | 32K data + 32K instruction + 512KB L2 cache per core | ++------------+--------------------------------------------------------+ +| DRAM | 2 or 4 GB DDR3-1066 DRAM | ++------------+--------------------------------------------------------+ +| Boot | From SD card, USB, mSATA, SATA | ++------------+--------------------------------------------------------+ +| Power | 6 to 12W of 12V power | ++------------+--------------------------------------------------------+ +| Firmware | coreboot with support for iPXE and USB boot | ++------------+--------------------------------------------------------+ +``` + +## Flashing coreboot + +```eval_rst ++---------------------+--------------------------+ +| Type | Value | ++=====================+==========================+ +| Socketed flash | no | ++---------------------+--------------------------+ +| Model | MX25L1606E | ++---------------------+--------------------------+ +| Size | 2 MiB | ++---------------------+--------------------------+ +| Package | SOP-8 | ++---------------------+--------------------------+ +| Write protection | jumper on WP# pin | ++---------------------+--------------------------+ +| Dual BIOS feature | no | ++---------------------+--------------------------+ +| Internal flashing | yes | ++---------------------+--------------------------+ +``` + +### Internal programming + +The SPI flash can be accessed using [flashrom]. It is important to execute +command with a `-c ` argument: + + flashrom -p internal -c "MX25L1606E" -w coreboot.rom + +### External programming + +**IMPORTANT**: When programming SPI flash, first you need to enter apu1 in S5 +(Soft-off) power state. S5 state can be forced by shorting power button pin on +J2 header. + +The external access to flash chip is available through standard SOP-8 clip or +SOP-8 header next to the flash chip on the board. Notice that not all boards +have a header soldered down originally. Hence, there could be an empty slot with +8 eyelets, so you can solder down a header on your own. The SPI flash chip and +SPI header are marked in the picture below. Also there is SPI header pin layout +included. Notice, that signatures at the schematic can be ambiguous: +- J12 SPIDI = U35 SO = MISO +- J12 SPIDO = U35 SI = MOSI + +There is no restrictions as to the programmer device. It is only recommended to +flash firmware without supplying power. External programming can be performed, +for example using OrangePi and Armbian. You can exploit linux_spi driver which +provide communication with SPI devices. Example command to program SPI flash +with OrangePi using linux_spi: + + flashrom -w coreboot.rom -p linux_spi:dev=/dev/spidev1.0,spispeed=16000 -c + "MX25L1606E" + + +**apu1 platform with marked in SPI header and SPI flash chip** + +![][apu1c1_flash] + +**SPI header pin layout** + +![][spi_header] + + +### Schematics + +PC Engines APU platform schematics are available for free on PC Engines official +site. Depending on the configuration: +[apu1c](https://www.pcengines.ch/schema/apu1c.pdf) and +[apu1d](https://www.pcengines.ch/schema/apu1d.pdf). + + +[apu1c1_flash]: apu1c1.jpg +[spi_header]: apu1_spi.jpg +[flashrom]: https://flashrom.org/Flashrom diff --git a/Documentation/mainboard/pcengines/apu1_spi.jpg b/Documentation/mainboard/pcengines/apu1_spi.jpg new file mode 100644 index 0000000000..0746733c98 Binary files /dev/null and b/Documentation/mainboard/pcengines/apu1_spi.jpg differ diff --git a/Documentation/mainboard/pcengines/apu1c1.jpg b/Documentation/mainboard/pcengines/apu1c1.jpg new file mode 100644 index 0000000000..7ecb41a352 Binary files /dev/null and b/Documentation/mainboard/pcengines/apu1c1.jpg differ diff --git a/Documentation/mainboard/pcengines/apu2.jpg b/Documentation/mainboard/pcengines/apu2.jpg new file mode 100644 index 0000000000..ae83b9ce93 Binary files /dev/null and b/Documentation/mainboard/pcengines/apu2.jpg differ diff --git a/Documentation/mainboard/pcengines/apu2.md b/Documentation/mainboard/pcengines/apu2.md new file mode 100644 index 0000000000..4a02e12f77 --- /dev/null +++ b/Documentation/mainboard/pcengines/apu2.md @@ -0,0 +1,116 @@ +# PC Engines APU2 + +This page describes how to run coreboot on PC Engines APU2 platform. + +## Technology + +```eval_rst ++------------+---------------------------------------------------------------+ +| CPU | AMD G series GX-412TC | ++------------+---------------------------------------------------------------+ +| CPU core | 1 GHz quad Puma core with 64 bit support | +| | 32K data + 32K instruction cache per core, shared 2MB L2 cache| ++------------+---------------------------------------------------------------+ +| DRAM | 2 or 4 GB DDR3-1333 DRAM | ++------------+---------------------------------------------------------------+ +| Boot | From SD card, USB, mSATA SSD, SATA | ++------------+---------------------------------------------------------------+ +| Power | 6 to 12W of 12V power | ++------------+---------------------------------------------------------------+ +| Firmware | coreboot with support for iPXE and USB boot | ++------------+---------------------------------------------------------------+ +``` + +## Required proprietary blobs + +To build working coreboot image some blobs are needed. + +```eval_rst ++-----------------+---------------------------------+---------------------+ +| Binary file | Apply | Required / Optional | ++=================+=================================+=====================+ +| amdfw.rom* | AMD Platform Security Processor | Required | ++-----------------+---------------------------------+---------------------+ +| AGESA.bin | AGESA Platform Initialization | Required | ++-----------------+---------------------------------+---------------------+ +| xhci.bin | AMD XHCI controller | Optional | ++-----------------+---------------------------------+---------------------+ +``` +(\*) - package containing all required blobs for PSP. Directory, in which all +blobs are listed and available is: *3rdparty/southbridge/amd/avalon/PSP* + +## Flashing coreboot + +```eval_rst ++---------------------+--------------------------+ +| Type | Value | ++=====================+==========================+ +| Socketed flash | no | ++---------------------+--------------------------+ +| Model | W25Q64 | ++---------------------+--------------------------+ +| Size | 8 MiB | ++---------------------+--------------------------+ +| Package | SOIC-8 | ++---------------------+--------------------------+ +| Write protection | jumper on WP# pin* | ++---------------------+--------------------------+ +| Dual BIOS feature | no | ++---------------------+--------------------------+ +| Internal flashing | yes | ++---------------------+--------------------------+ +``` +(\*) - It is used in normal SPI mode, but can be dangerous when using Quad SPI +Flash. Then, pull-down resistors should be considered rather than jumper. + +### Internal programming + +The SPI flash can be accessed using [flashrom]. + + flashrom -p internal -w coreboot.rom + +### External programming + +**IMPORTANT**: When programming SPI flash, first you need to enter apu2 in S5 +(Soft-off) power state. S5 state can be forced by shorting power button pin on +J2 header. + +The external access to flash chip is available through standard SOP-8 clip or +SOP-8 header next to the flash chip on the board. Notice that not all boards +have a header soldered down originally. Hence, there could be an empty slot with +8 eyelets, so you can solder down a header on your own. The SPI flash chip and +SPI header are marked in the picture below. Also there is SPI header and SPI +flash pin layout included. Depend on using header or clip there are important +rules: +- using header J6 - don't connect 1,7,8 pins +- using clip U23 - don't connect 3,7,8 pins + +Also signatures at the schematic can be ambiguous: +- J6 SPIDI = U23 SO = MISO +- J6 SPIDO = U23 SI = MOSI + +There is no restrictions as to the programmer device. It is only recommended to +flash firmware without supplying power. External programming can be performed, +for example using OrangePi and Armbian. You can exploit linux_spi driver which +provides communication with SPI devices. Example command to program SPI flash +with OrangePi using linux_spi: + + flashrom -f -w coreboot.rom -p linux_spi:dev=/dev/spidev1.0,spispeed=16000 + +**apu2 platform with marked in SPI header and SPI flash chip** + +![][apu2_flash] + +**SPI header pin layout** + +![][spi_header] + +## Schematics + +PC Engines APU2 [platform schematics](https://pcengines.ch/schema/apu2d.pdf) +are available for free on PC Engines official site. Both configurations +(2GB/4GB) have the same PCB and schematic. + +[apu2_flash]: apu2.jpg +[spi_header]: apu2_spi.jpg +[flashrom]: https://flashrom.org/Flashrom diff --git a/Documentation/mainboard/pcengines/apu2_spi.jpg b/Documentation/mainboard/pcengines/apu2_spi.jpg new file mode 100644 index 0000000000..f8a5b5861e Binary files /dev/null and b/Documentation/mainboard/pcengines/apu2_spi.jpg differ diff --git a/Documentation/mainboard/up/squared/bottom.dia b/Documentation/mainboard/up/squared/bottom.dia new file mode 100644 index 0000000000..f298d669ab Binary files /dev/null and b/Documentation/mainboard/up/squared/bottom.dia differ diff --git a/Documentation/mainboard/up/squared/bottom.jpg b/Documentation/mainboard/up/squared/bottom.jpg index f9aa85db50..3c066a23ad 100644 Binary files a/Documentation/mainboard/up/squared/bottom.jpg and b/Documentation/mainboard/up/squared/bottom.jpg differ diff --git a/Documentation/mainboard/up/squared/header_40pin_gpio_uart1.dia b/Documentation/mainboard/up/squared/header_40pin_gpio_uart1.dia new file mode 100644 index 0000000000..4efc0183e4 Binary files /dev/null and b/Documentation/mainboard/up/squared/header_40pin_gpio_uart1.dia differ diff --git a/Documentation/mainboard/up/squared/header_40pin_gpio_uart1.svg b/Documentation/mainboard/up/squared/header_40pin_gpio_uart1.svg new file mode 100644 index 0000000000..16f6397de4 --- /dev/null +++ b/Documentation/mainboard/up/squared/header_40pin_gpio_uart1.svg @@ -0,0 +1,126 @@ + + + + + 40 pin GPIO header + + + GND + + + UART1 + TX + + + UART1 + RX + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + 4 + + + 2 + + + 3 + + + 5 + + + 7 + + + 8 + + + 6 + + + 9 + + + 11 + + + 12 + + + 10 + + + + + + + + + + + + + + + + + diff --git a/Documentation/mainboard/up/squared/header_cn16_10pin_uart0.dia b/Documentation/mainboard/up/squared/header_cn16_10pin_uart0.dia new file mode 100644 index 0000000000..a35245b9cc Binary files /dev/null and b/Documentation/mainboard/up/squared/header_cn16_10pin_uart0.dia differ diff --git a/Documentation/mainboard/up/squared/header_cn16_10pin_uart0.svg b/Documentation/mainboard/up/squared/header_cn16_10pin_uart0.svg new file mode 100644 index 0000000000..43efc77ac5 --- /dev/null +++ b/Documentation/mainboard/up/squared/header_cn16_10pin_uart0.svg @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + 2 + + + 5 + + + 4 + + + 3 + + + 6 + + + 9 + + + 8 + + + 7 + + + 10 + + + GND + + + UART0 + RX + + + UART0 + TX + + + + + + + + + + + + + + + + + + 10 pin UART0/USB2 header (CN16) + + diff --git a/Documentation/mainboard/up/squared/header_cn22_12pin_spi.dia b/Documentation/mainboard/up/squared/header_cn22_12pin_spi.dia new file mode 100644 index 0000000000..ab556ff819 Binary files /dev/null and b/Documentation/mainboard/up/squared/header_cn22_12pin_spi.dia differ diff --git a/Documentation/mainboard/up/squared/header_cn22_12pin_spi.svg b/Documentation/mainboard/up/squared/header_cn22_12pin_spi.svg new file mode 100644 index 0000000000..7853fb7e7c --- /dev/null +++ b/Documentation/mainboard/up/squared/header_cn22_12pin_spi.svg @@ -0,0 +1,165 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 9 + + + 5 + + + 7 + + + 8 + + + 1 + + + 4 + + + 3 + + + 2 + + + 6 + + + 11 + + + 12 + + + 10 + + + SPI header (CN22) + + + + + + + + + + + + + GND + + + GND + + + + + + + + MISO + + + + + + + + VCC + 1.8V + + + #HOLD + + + + + + + + + + + + + CLK + + + + + + + + MOSI + + + + + + + + #CS + + diff --git a/Documentation/mainboard/up/squared/index.md b/Documentation/mainboard/up/squared/index.md index dcf3ed192d..9242f76d8d 100644 --- a/Documentation/mainboard/up/squared/index.md +++ b/Documentation/mainboard/up/squared/index.md @@ -7,6 +7,12 @@ ### Bottom ![][overview_bottom] +* **Legend** + * [BLUE][header_cn16_link]: UART0 / USB connector + * [GREEN][header_gpio_link]: UART1 / GPIO header + * [RED][header_cn22_link]: SPI header + * YELLOW: Indicates pin 1 + ## Mainboard components ### Platform ```eval_rst @@ -46,6 +52,79 @@ +---------------------+------------+ ``` +### Debugging +#### UART0 (CN16) +This connector is located on the **bottom** side (see [here][overview_bottom_link]). +![][header_cn16] + + +#### UART1 (GPIO header) +The GPIO header is located on the **bottom** side (see [here][overview_bottom_link]). +![][header_gpio] + +## Building and flashing coreboot +### Using the SPI header +The SPI header is located on the **bottom** side (see [here][overview_bottom_link]). +![][header_cn22] + +### Preperations +In order to build coreboot, it's neccessary to extract some files from the vendor firmware. Make sure that you have a fully working dump. +```bash +[upsquared]$ ls +firmware_vendor.rom +``` + +```bash +[upsquared]$ mkdir extracted && cd extracted +[extracted]$ ifdtool -x ../firmware_vendor.rom +File ../firmware_vendor.rom is 16777216 bytes +Peculiar firmware descriptor, assuming Ibex Peak compatibility. + Flash Region 0 (Flash Descriptor): 00000000 - 00000fff + Flash Region 1 (BIOS): 00001000 - 00efefff + Flash Region 2 (Intel ME): 07fff000 - 00000fff (unused) + Flash Region 3 (GbE): 07fff000 - 00000fff (unused) + Flash Region 4 (Platform Data): 07fff000 - 00000fff (unused) + Flash Region 5 (Reserved): 00eff000 - 00ffefff + Flash Region 6 (Reserved): 07fff000 - 00000fff (unused) + Flash Region 7 (Reserved): 07fff000 - 00000fff (unused) + Flash Region 8 (EC): 07fff000 - 00000fff (unused) +``` + +```bash +flashregion_0_flashdescriptor.bin +flashregion_1_bios.bin +flashregion_5_reserved.bin +``` + +### Clean up +```bash +[coreboot]$ make distclean +``` + +### Configuring +```bash +[coreboot]$ touch .config +[coreboot]$ ./util/scripts/config --enable VENDOR_UP +[coreboot]$ ./util/scripts/config --enable BOARD_UP_SQUARED +[coreboot]$ ./util/scripts/config --enable NEED_IFWI +[coreboot]$ ./util/scripts/config --enable HAVE_IFD_BIN +[coreboot]$ ./util/scripts/config --set-str IFWI_FILE_NAME "" +[coreboot]$ ./util/scripts/config --set-str IFD_BIN_PATH "" +[coreboot]$ make olddefconfig +``` + +### Building +```bash +[coreboot]$ make +``` + +Now you should have a working and ready to use coreboot build at `build/coreboot.rom`. + +### Flashing +```bash +[coreboot]$ flashrom -p -w build/coreboot.rom +``` + ## Board status ### Working - bootblock, romstage, ramstage @@ -78,22 +157,13 @@ - mini PCIe - flashing with flashrom internally using Linux -## Building and flashing coreboot -### Building - -```bash -make distclean -touch .config -./util/scripts/config --enable VENDOR_UP -./util/scripts/config --enable BOARD_UP_SQUARED -./util/scripts/config --enable NEED_IFWI -./util/scripts/config --enable HAVE_IFD_BIN -./util/scripts/config --set-str IFWI_FILE_NAME "" -./util/scripts/config --set-str IFD_BIN_PATH "" -make olddefconfig -``` - -### Flashing +[header_cn16]: header_cn16_10pin_uart0.svg +[header_cn16_link]: #uart0-cn16 +[header_cn22]: header_cn22_12pin_spi.svg +[header_cn22_link]: #using-the-spi-header +[header_gpio]: header_40pin_gpio_uart1.svg +[header_gpio_link]: #uart1-gpio-header [overview_top]: top.jpg [overview_bottom]: bottom.jpg +[overview_bottom_link]: #bottom diff --git a/Documentation/security/index.md b/Documentation/security/index.md index 9ad54866c2..379375b616 100644 --- a/Documentation/security/index.md +++ b/Documentation/security/index.md @@ -6,3 +6,4 @@ 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) diff --git a/Documentation/security/memory_clearing.md b/Documentation/security/memory_clearing.md new file mode 100644 index 0000000000..3d985925d9 --- /dev/null +++ b/Documentation/security/memory_clearing.md @@ -0,0 +1,44 @@ +# Memory clearing + +The main memory on computer platforms in high security environments contains +sensible data. On unexpected reboot the data might persist and could be +read by a malicious application in the bootflow or userspace. + +In order to prevent leaking information from pre-reset, the boot firmware can +clear the main system memory on boot, wiping all information. + +A common API indicates if the main memory has to be cleared. That could be +on user request or by a Trusted Execution Environment indicating that secrets +are in memory. + +As every platform has different bring-up mechanisms and memory-layouts, every +The device must indicate support for memory clearing as part of the boot +process. + +## Requirements + +1. The platform must clear all platform memory (DRAM) if requested +2. Code that is placed in DRAM might be skipped (as workaround) +3. Stack that is placed in DRAM might be skipped (as workaround) +4. All DRAM is cleared with zeros + +## Implementation + +A platform that supports memory clearing selects Kconfig +``PLATFORM_HAS_DRAM_CLEAR`` and calls + +```C +bool security_clear_dram_request(void); +``` + +to detect if memory should be cleared. + +The memory is cleared in ramstage as part of `DEV_INIT` stage. It's possible to +clear it earlier on some platforms, but on x86 MTRRs needs to be programmed +first, which happens in `DEV_INIT`. + +Without MTRRs (and caches enabled) clearing memory takes multiple seconds. +## Exceptions + +As some platforms place code and stack in DRAM (FSP1.0), the regions can be +skipped. diff --git a/Documentation/soc/intel/apollolake/flash_layout.dia b/Documentation/soc/intel/apollolake/flash_layout.dia new file mode 100644 index 0000000000..4ea5440619 Binary files /dev/null and b/Documentation/soc/intel/apollolake/flash_layout.dia differ diff --git a/Documentation/soc/intel/apollolake/flash_layout.svg b/Documentation/soc/intel/apollolake/flash_layout.svg new file mode 100644 index 0000000000..9322875d90 --- /dev/null +++ b/Documentation/soc/intel/apollolake/flash_layout.svg @@ -0,0 +1,122 @@ + + + + + + + + + DEVICE_EXTENSION + + + + + + + BIOS + + + + + + + IFD + + + + + + + IFWI + + + + + + + + + + + + + + + + + + + + + FMAP + + + + + + + CONSOLE + + + + + + + COREBOOT(CBFS) + + + + + + + BIOS_UNUSABLE + + + + + + + MRC + + + + + + + OBB + + + + + + + + + + + + + + + + + TXE + + + + + + + BOOTBLOCK + + + + + + + + + + + + diff --git a/Documentation/soc/intel/apollolake/index.md b/Documentation/soc/intel/apollolake/index.md new file mode 100644 index 0000000000..d4a5ee51ae --- /dev/null +++ b/Documentation/soc/intel/apollolake/index.md @@ -0,0 +1,17 @@ +# Apollolake +## SPI flash layout + +![][apl_flash_layout] + +With Apollolake Intel invented another flash layout for x86 firmware called IFWI (Intel FirmWare Image). + +Usually on x86 platforms the bootblock is stored at the end of the bios region +and the Intel ME / TXE has its own IFD region. On Apollolake both have been +moved into the IFWI region, which is a subregion of "BIOS", since it allows to +store multiple firmware components. + +The IFWI region can be manipulated by `ifwitool`. + +[apl_flash_layout]: flash_layout.svg + + diff --git a/Documentation/soc/intel/index.md b/Documentation/soc/intel/index.md index 86f4de7155..f30ff9a1d6 100644 --- a/Documentation/soc/intel/index.md +++ b/Documentation/soc/intel/index.md @@ -9,3 +9,4 @@ This section contains documentation about coreboot on specific Intel SOCs. - [Ice Lake/9th Gen Core-i series](icelake/index.md) - [MP Initialization](mp_init/mp_init.md) - [Firmware Interface Table](fit.md) +- [Apollolake](apollolake/index.md) diff --git a/MAINTAINERS b/MAINTAINERS index f1ae076937..73ca6dfed9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -164,6 +164,11 @@ M: Patrick Rudolph S: Maintained F: src/mainboard/lenovo/ +APPLE MAINBOARDS +M: Evgeny Zinoviev +S: Maintained +F: src/mainboard/apple/ + GETAC P470 MAINBOARD M: Patrick Georgi S: Maintained @@ -364,6 +369,11 @@ M: Angel Pons S: Maintained F: src/mainboard/asus/p8h61-m_pro/ +ASUS P8Z77-M PRO MAINBOARD +M: Vlado Cibic +S: Maintained +F: src/mainboard/asus/p8z77-m_pro/ + PC ENGINES ALL MAINBOARDS M: Piotr Król M: MichaÅ‚ Å»ygowski @@ -624,6 +634,12 @@ S: Supported F: */memlayout.h F: *.ld +ELTAN VENDORCODE +M: Frans Hendriks +M: Wim Vervoorn +S: Maintained +F: src/vendorcode/eltan + MISSING: TIMERS / DELAYS MISSING: TIMESTAMPS diff --git a/Makefile.inc b/Makefile.inc index 14cd50c79d..362243eb6a 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -193,9 +193,10 @@ ifneq ($(UPDATED_SUBMODULES),1) # try to fetch non-optional submodules if the source is under git forgetthis:=$(if $(GIT),$(shell git submodule update --init)) ifeq ($(CONFIG_USE_BLOBS),y) -# this is necessary because 3rdparty/blobs is update=none, and so is ignored +# this is necessary because 3rdparty/{blobs,intel-microcode} is update=none, and so is ignored # unless explicitly requested and enabled through --checkout forgetthis:=$(if $(GIT),$(shell git submodule update --init --checkout 3rdparty/blobs)) +forgetthis:=$(if $(GIT),$(shell git submodule update --init --checkout 3rdparty/intel-microcode)) ifeq ($(CONFIG_PLATFORM_USES_FSP1_0)$(CONFIG_PLATFORM_USES_FSP1_1)$(CONFIG_PLATFORM_USES_FSP2_0),y) # this is necessary because 3rdparty/fsp is update=none, and so is ignored # unless explicitly requested and enabled through --checkout @@ -512,6 +513,7 @@ CBFSTOOL:=$(objutil)/cbfstool/cbfstool FMAPTOOL:=$(objutil)/cbfstool/fmaptool RMODTOOL:=$(objutil)/cbfstool/rmodtool IFWITOOL:=$(objutil)/cbfstool/ifwitool +IFITTOOL:=$(objutil)/cbfstool/ifittool $(obj)/cbfstool: $(CBFSTOOL) cp $< $@ @@ -525,6 +527,9 @@ $(obj)/rmodtool: $(RMODTOOL) $(obj)/ifwitool: $(IFWITOOL) cp $< $@ +$(obj)/ifittool: $(IFITTOOL) + cp $< $@ + _WINCHECK=$(shell uname -o 2> /dev/null) STACK= ifeq ($(_WINCHECK),Msys) @@ -637,7 +642,7 @@ install-git-commit-clangfmt: include util/crossgcc/Makefile.inc .PHONY: tools -tools: $(objutil)/kconfig/conf $(CBFSTOOL) $(objutil)/cbfstool/cbfs-compression-tool $(FMAPTOOL) $(RMODTOOL) $(IFWITOOL) $(objutil)/nvramtool/nvramtool $(ROMCC_BIN) $(objutil)/sconfig/sconfig $(IFDTOOL) $(CBOOTIMAGE) $(AMDFWTOOL) $(FUTILITY) $(BINCFG) +tools: $(objutil)/kconfig/conf $(CBFSTOOL) $(objutil)/cbfstool/cbfs-compression-tool $(FMAPTOOL) $(RMODTOOL) $(IFWITOOL) $(objutil)/nvramtool/nvramtool $(ROMCC_BIN) $(objutil)/sconfig/sconfig $(IFDTOOL) $(CBOOTIMAGE) $(AMDFWTOOL) $(FUTILITY) $(BINCFG) $(IFITTOOL) ########################################################################### # Common recipes for all stages @@ -1007,10 +1012,9 @@ $(obj)/fmap.fmap: $(obj)/fmap.fmd $(FMAPTOOL) ifeq ($(CONFIG_INTEL_ADD_TOP_SWAP_BOOTBLOCK),y) TS_OPTIONS := -j $(CONFIG_INTEL_TOP_SWAP_BOOTBLOCK_SIZE) -FIT_OPTIONS := $(TS_OPTIONS) endif ifneq ($(CONFIG_UPDATE_IMAGE),y) -$(obj)/coreboot.pre: $(objcbfs)/bootblock.bin $$(prebuilt-files) $(CBFSTOOL) $$(cpu_ucode_cbfs_file) $(obj)/fmap.fmap $(obj)/fmap.desc +$(obj)/coreboot.pre: $(objcbfs)/bootblock.bin $$(prebuilt-files) $(CBFSTOOL) $(IFITTOOL) $$(cpu_ucode_cbfs_file) $(obj)/fmap.fmap $(obj)/fmap.desc $(CBFSTOOL) $@.tmp create -M $(obj)/fmap.fmap -r $(shell cat $(obj)/fmap.desc) ifeq ($(CONFIG_ARCH_X86),y) $(CBFSTOOL) $@.tmp add \ @@ -1054,9 +1058,6 @@ $(REFCODE_BLOB): $(RMODTOOL) endif FIT_ENTRY=$(call strip_quotes, $(CONFIG_INTEL_TOP_SWAP_FIT_ENTRY_FMAP_REG)) -ifneq ($(FIT_ENTRY),) -FIT_OPTIONS += -q $(FIT_ENTRY) -endif ifeq ($(CONFIG_HAVE_RAMSTAGE),y) RAMSTAGE=$(objcbfs)/ramstage.elf @@ -1086,15 +1087,38 @@ endif ifeq ($(CONFIG_CPU_INTEL_FIRMWARE_INTERFACE_TABLE),y) ifeq ($(CONFIG_CPU_MICROCODE_CBFS_EXTERNAL_HEADER),y) @printf " UPDATE-FIT\n" - $(CBFSTOOL) $@.tmp update-fit -n cpu_microcode_blob.bin -x $(CONFIG_CPU_INTEL_NUM_FIT_ENTRIES) \ - $(FIT_OPTIONS) + $(IFITTOOL) -f $@.tmp -a -n cpu_microcode_blob.bin -t 1 -s $(CONFIG_CPU_INTEL_NUM_FIT_ENTRIES) \ + -r COREBOOT endif - ifeq ($(CONFIG_USE_CPU_MICROCODE_CBFS_BINS),y) @printf " UPDATE-FIT\n" - $(CBFSTOOL) $@.tmp update-fit -n cpu_microcode_blob.bin -x $(CONFIG_CPU_INTEL_NUM_FIT_ENTRIES) \ - $(FIT_OPTIONS) + $(IFITTOOL) -f $@.tmp -a -n cpu_microcode_blob.bin -t 1 -s $(CONFIG_CPU_INTEL_NUM_FIT_ENTRIES) \ + -r COREBOOT endif + $(IFITTOOL) -f $@.tmp -D -r COREBOOT + +# Second FIT in TOP_SWAP bootblock +ifeq ($(CONFIG_INTEL_ADD_TOP_SWAP_BOOTBLOCK),y) +# INTEL_TOP_SWAP_FIT_ENTRY_FMAP_REG adds a region as first ucode into the seconds bootblock +ifneq ($(FIT_ENTRY),) + @printf " UPDATE-FIT2\n" + $(IFITTOOL) -f $@.tmp -A -n $(FIT_ENTRY) -t 1 -s $(CONFIG_CPU_INTEL_NUM_FIT_ENTRIES) \ + $(TS_OPTIONS) -r COREBOOT +endif +ifeq ($(CONFIG_CPU_MICROCODE_CBFS_EXTERNAL_HEADER),y) + @printf " UPDATE-FIT2\n" + $(IFITTOOL) -f $@.tmp -a -n cpu_microcode_blob.bin -t 1 -s $(CONFIG_CPU_INTEL_NUM_FIT_ENTRIES) \ + $(TS_OPTIONS) -r COREBOOT +endif +ifeq ($(CONFIG_USE_CPU_MICROCODE_CBFS_BINS),y) + @printf " UPDATE-FIT2\n" + $(IFITTOOL) -f $@.tmp -a -n cpu_microcode_blob.bin -t 1 -s $(CONFIG_CPU_INTEL_NUM_FIT_ENTRIES) \ + $(TS_OPTIONS) -r COREBOOT +endif + $(IFITTOOL) -f $@.tmp -D $(TS_OPTIONS) -r COREBOOT + +endif + endif mv $@.tmp $@ @printf " CBFSLAYOUT $(subst $(obj)/,,$(@))\n\n" diff --git a/payloads/external/LinuxBoot/x86_64/defconfig b/payloads/external/LinuxBoot/x86_64/defconfig index 39ae162f5f..b28a80f39a 100644 --- a/payloads/external/LinuxBoot/x86_64/defconfig +++ b/payloads/external/LinuxBoot/x86_64/defconfig @@ -4,6 +4,7 @@ CONFIG_KERNEL_XZ=y CONFIG_SYSVIPC=y CONFIG_NO_HZ_IDLE=y CONFIG_HIGH_RES_TIMERS=y +CONFIG_PREEMPT=y CONFIG_VIRT_CPU_ACCOUNTING_GEN=y CONFIG_CGROUPS=y CONFIG_MEMCG=y @@ -36,36 +37,20 @@ CONFIG_EMBEDDED=y # CONFIG_COMPAT_BRK is not set CONFIG_SLOB=y # CONFIG_SLAB_MERGE_DEFAULT is not set -CONFIG_GCC_PLUGINS=y -CONFIG_GCC_PLUGIN_LATENT_ENTROPY=y -CONFIG_GCC_PLUGIN_STRUCTLEAK=y -CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL=y -CONFIG_GCC_PLUGIN_RANDSTRUCT=y -# CONFIG_VMAP_STACK is not set -CONFIG_REFCOUNT_FULL=y -# CONFIG_BLK_DEV_BSG is not set -CONFIG_PARTITION_ADVANCED=y -# CONFIG_IOSCHED_DEADLINE is not set -# CONFIG_IOSCHED_CFQ is not set -# CONFIG_MQ_IOSCHED_DEADLINE is not set -# CONFIG_MQ_IOSCHED_KYBER is not set # CONFIG_ZONE_DMA is not set # CONFIG_X86_MPPARSE is not set # CONFIG_X86_EXTENDED_PLATFORM is not set -CONFIG_IOSF_MBI=y # CONFIG_SCHED_OMIT_FRAME_POINTER is not set # CONFIG_DMI is not set -CONFIG_PREEMPT=y # CONFIG_X86_MCE is not set # CONFIG_MICROCODE is not set CONFIG_X86_MSR=y CONFIG_X86_CPUID=y -# CONFIG_SPARSEMEM_VMEMMAP is not set -# CONFIG_COMPACTION is not set # CONFIG_MTRR is not set # CONFIG_X86_INTEL_UMIP is not set # CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS is not set CONFIG_KEXEC=y +CONFIG_KEXEC_FILE=y # CONFIG_RELOCATABLE is not set # CONFIG_MODIFY_LDT_SYSCALL is not set # CONFIG_SUSPEND is not set @@ -78,12 +63,30 @@ CONFIG_ACPI_VIDEO=y # CONFIG_ACPI_TABLE_UPGRADE is not set # CONFIG_X86_PM_TIMER is not set # CONFIG_CPU_IDLE is not set -CONFIG_PCIEPORTBUS=y -CONFIG_PCIEASPM_POWER_SUPERSAVE=y -CONFIG_PCI_MSI=y # CONFIG_ISA_DMA_API is not set +CONFIG_GOOGLE_FIRMWARE=y +CONFIG_GOOGLE_COREBOOT_TABLE=y +CONFIG_GOOGLE_FRAMEBUFFER_COREBOOT=y +CONFIG_GOOGLE_MEMCONSOLE_COREBOOT=y +CONFIG_GOOGLE_VPD=y +# CONFIG_VIRTUALIZATION is not set +# CONFIG_VMAP_STACK is not set +CONFIG_REFCOUNT_FULL=y +CONFIG_GCC_PLUGINS=y +CONFIG_GCC_PLUGIN_LATENT_ENTROPY=y +CONFIG_GCC_PLUGIN_STRUCTLEAK=y +CONFIG_GCC_PLUGIN_RANDSTRUCT=y +# CONFIG_BLK_DEV_BSG is not set +CONFIG_PARTITION_ADVANCED=y +# CONFIG_MQ_IOSCHED_DEADLINE is not set +# CONFIG_MQ_IOSCHED_KYBER is not set # CONFIG_BINFMT_SCRIPT is not set # CONFIG_COREDUMP is not set +# CONFIG_SPARSEMEM_VMEMMAP is not set +# CONFIG_COMPACTION is not set +CONFIG_PCI=y +CONFIG_PCIEPORTBUS=y +CONFIG_PCI_MSI=y # CONFIG_UEVENT_HELPER is not set CONFIG_DEVTMPFS=y CONFIG_DEVTMPFS_MOUNT=y @@ -92,35 +95,38 @@ CONFIG_DEVTMPFS_MOUNT=y # CONFIG_ALLOW_DEV_COREDUMP is not set # CONFIG_PNP_DEBUG_MESSAGES is not set CONFIG_BLK_DEV_LOOP=y +CONFIG_BLK_DEV_NVME=y +CONFIG_NVME_MULTIPATH=y CONFIG_BLK_DEV_SD=y # CONFIG_SCSI_LOWLEVEL is not set CONFIG_ATA=y -CONFIG_SATA_AHCI=y CONFIG_MD=y CONFIG_BLK_DEV_DM=y CONFIG_DM_CRYPT=y -CONFIG_SERIAL_8250_CONSOLE=y -# CONFIG_SERIAL_8250_DEPRECATED_OPTIONS is not set -# CONFIG_SERIAL_8250_EXAR is not set -# CONFIG_SERIAL_8250_LPSS is not set -# CONFIG_SERIAL_8250_MID is not set -# CONFIG_SERIAL_8250_PNP is not set CONFIG_SERIAL_8250=y +# CONFIG_SERIAL_8250_DEPRECATED_OPTIONS is not set +# CONFIG_SERIAL_8250_PNP is not set +CONFIG_SERIAL_8250_CONSOLE=y +CONFIG_SERIAL_8250_NR_UARTS=32 +CONFIG_SERIAL_8250_RUNTIME_UARTS=32 +CONFIG_SERIAL_8250_EXTENDED=y +CONFIG_SERIAL_8250_MANY_PORTS=y +CONFIG_SERIAL_8250_DW=y +CONFIG_SERIAL_DEV_BUS=y CONFIG_HW_RANDOM_TIMERIOMEM=y -# CONFIG_HW_RANDOM_AMD is not set # CONFIG_HW_RANDOM_VIA is not set CONFIG_TCG_TPM=y CONFIG_TCG_TIS=y -# CONFIG_DEVPORT is not set CONFIG_I2C=y CONFIG_POWER_SUPPLY=y # CONFIG_HWMON is not set -# CONFIG_VGA_ARB is not set +CONFIG_MFD_INTEL_LPSS_PCI=y CONFIG_FB=y CONFIG_FIRMWARE_EDID=y CONFIG_FB_FOREIGN_ENDIAN=y CONFIG_FB_MODE_HELPERS=y CONFIG_FB_TILEBLITTING=y +CONFIG_FB_SIMPLE=y CONFIG_BACKLIGHT_LCD_SUPPORT=y CONFIG_VGACON_SOFT_SCROLLBACK=y CONFIG_VGACON_SOFT_SCROLLBACK_PERSISTENT_ENABLE_BY_DEFAULT=y @@ -128,14 +134,14 @@ CONFIG_FRAMEBUFFER_CONSOLE=y CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y # CONFIG_USB_SUPPORT is not set +CONFIG_MMC=y +CONFIG_MMC_SDHCI=y +CONFIG_MMC_SDHCI_PCI=y +CONFIG_MMC_SDHCI_ACPI=y +CONFIG_MMC_SDHCI_PLTFM=y CONFIG_SYNC_FILE=y # CONFIG_VIRTIO_MENU is not set # CONFIG_X86_PLATFORM_DEVICES is not set -# CONFIG_FIRMWARE_MEMMAP is not set -CONFIG_GOOGLE_FIRMWARE=y -CONFIG_GOOGLE_COREBOOT_TABLE_ACPI=y -CONFIG_GOOGLE_MEMCONSOLE_COREBOOT=y -CONFIG_GOOGLE_VPD=y CONFIG_EXT4_FS=y # CONFIG_FILE_LOCKING is not set # CONFIG_DNOTIFY is not set @@ -149,7 +155,13 @@ CONFIG_VFAT_FS=y CONFIG_FAT_DEFAULT_UTF8=y CONFIG_TMPFS=y # CONFIG_MISC_FILESYSTEMS is not set -# CONFIG_ENABLE_WARN_DEPRECATED is not set +CONFIG_SECURITY_DMESG_RESTRICT=y +CONFIG_FORTIFY_SOURCE=y +# CONFIG_CRYPTO_ECHAINIV is not set +CONFIG_CRYPTO_SHA256_SSSE3=y +CONFIG_CRYPTO_ANSI_CPRNG=y +CONFIG_CRYPTO_JITTERENTROPY=y +# CONFIG_CRYPTO_HW is not set # CONFIG_ENABLE_MUST_CHECK is not set CONFIG_FRAME_WARN=1024 # CONFIG_UNUSED_SYMBOLS is not set @@ -163,11 +175,3 @@ CONFIG_FRAME_WARN=1024 CONFIG_OPTIMIZE_INLINING=y # CONFIG_X86_DEBUG_FPU is not set CONFIG_UNWINDER_GUESS=y -CONFIG_SECURITY_DMESG_RESTRICT=y -CONFIG_FORTIFY_SOURCE=y -# CONFIG_CRYPTO_ECHAINIV is not set -CONFIG_CRYPTO_SHA256_SSSE3=y -CONFIG_CRYPTO_ANSI_CPRNG=y -CONFIG_CRYPTO_JITTERENTROPY=y -# CONFIG_CRYPTO_HW is not set -# CONFIG_VIRTUALIZATION is not set diff --git a/payloads/libpayload/README b/payloads/libpayload/README index fdf9b1840d..d35f685fd5 100644 --- a/payloads/libpayload/README +++ b/payloads/libpayload/README @@ -22,12 +22,18 @@ Installation $ make - $ sudo make install (optional, will install into /opt per default) + $ make install (optional, will install into ./install per default) -As libpayload is for 32bit x86 systems only, you might have to install the -32bit libgcc version, otherwise your payloads will fail to compile. +On x86 systems, libpayload will always be 32-bit even if your host OS runs +in 64-bit, so you might have to install the 32-bit libgcc version. On Debian systems you'd do 'apt-get install gcc-multilib' for example. +Run 'make distclean' before switching boards. This command will remove +your current .config file, so you need 'make menuconfig' again or +'make defconfig' in order to set up configuration. Default configuration +is based on 'configs/defconfig'. See the configs/ directory for examples +of configuration. + Usage ----- diff --git a/payloads/libpayload/configs/config.emulation-qemu-arm b/payloads/libpayload/configs/config.emulation-qemu-arm new file mode 100644 index 0000000000..4b69caf737 --- /dev/null +++ b/payloads/libpayload/configs/config.emulation-qemu-arm @@ -0,0 +1,6 @@ +CONFIG_LP_ARCH_ARM=y +CONFIG_LP_STACK_SIZE=64000 +CONFIG_LP_BASE_ADDRESS=0x62030000 +CONFIG_LP_TINYCURSES=y +CONFIG_LP_8250_SERIAL_CONSOLE=y +CONFIG_LP_TIMER_GENERIC_HZ=1000000 diff --git a/payloads/libpayload/drivers/i8042/keyboard.c b/payloads/libpayload/drivers/i8042/keyboard.c index 3e5f988c48..48d35a07f7 100644 --- a/payloads/libpayload/drivers/i8042/keyboard.c +++ b/payloads/libpayload/drivers/i8042/keyboard.c @@ -319,25 +319,33 @@ void keyboard_init(void) /* Set scancode set 1 */ ret = keyboard_cmd(I8042_KBCMD_SET_SCANCODE); - if (!ret && !CONFIG(LP_PC_KEYBOARD_IGNORE_INIT_FAILURE)) + if (!ret && !CONFIG(LP_PC_KEYBOARD_IGNORE_INIT_FAILURE)) { + printf("ERROR: Keyboard set scancode failed!\n"); return; + } ret = keyboard_cmd(I8042_SCANCODE_SET_1); - if (!ret && !CONFIG(LP_PC_KEYBOARD_IGNORE_INIT_FAILURE)) + if (!ret && !CONFIG(LP_PC_KEYBOARD_IGNORE_INIT_FAILURE)) { + printf("ERROR: Keyboard scancode set#1 failed!\n"); return; + } /* * Set default parameters. * Fix for broken QEMU ps/2 make scancodes. */ ret = keyboard_cmd(0xf6); - if (!ret) + if (!ret) { + printf("ERROR: Keyboard set default params failed!\n"); return; + } /* Enable scanning */ ret = keyboard_cmd(I8042_KBCMD_EN); - if (!ret && !CONFIG(LP_PC_KEYBOARD_IGNORE_INIT_FAILURE)) + if (!ret && !CONFIG(LP_PC_KEYBOARD_IGNORE_INIT_FAILURE)) { + printf("ERROR: Keyboard enable scanning failed!\n"); return; + } console_add_input_driver(&cons); } diff --git a/payloads/libpayload/drivers/serial/qcs405.c b/payloads/libpayload/drivers/serial/qcs405.c index 9f02e17263..7a80aae9c3 100644 --- a/payloads/libpayload/drivers/serial/qcs405.c +++ b/payloads/libpayload/drivers/serial/qcs405.c @@ -547,8 +547,10 @@ void serial_console_init(void) uart_board_param.uart_dm_base = (void *)(uintptr_t)sc_ptr->baseaddr; - /* TODO: We should rely on coreboot init. */ - msm_boot_uart_dm_init(uart_board_param.uart_dm_base); + /* We should re-initialise uart rx as it gets reset in coreboot. */ + write32(MSM_BOOT_UART_DM_IMR(uart_board_param.uart_dm_base), + MSM_BOOT_UART_DM_IMR_ENABLED); + msm_boot_uart_dm_init_rx_transfer(uart_board_param.uart_dm_base); console_add_output_driver(&consout); console_add_input_driver(&consin); diff --git a/payloads/libpayload/drivers/video/graphics.c b/payloads/libpayload/drivers/video/graphics.c index 49563267a9..85a8642c72 100644 --- a/payloads/libpayload/drivers/video/graphics.c +++ b/payloads/libpayload/drivers/video/graphics.c @@ -183,6 +183,10 @@ int draw_box(const struct rect *box, const struct rgb_color *rgb) struct vector top_left; struct vector size; struct vector p, t; + + if (cbgfx_init()) + return CBGFX_ERROR_INIT; + const uint32_t color = calculate_color(rgb, 0); const struct scale top_left_s = { .x = { .n = box->offset.x, .d = CANVAS_SCALE, }, @@ -193,9 +197,6 @@ int draw_box(const struct rect *box, const struct rgb_color *rgb) .y = { .n = box->size.y, .d = CANVAS_SCALE, } }; - if (cbgfx_init()) - return CBGFX_ERROR_INIT; - transform_vector(&top_left, &canvas.size, &top_left_s, &canvas.offset); transform_vector(&size, &canvas.size, &size_s, &vzero); add_vectors(&t, &top_left, &size); diff --git a/payloads/libpayload/include/coreboot_tables.h b/payloads/libpayload/include/coreboot_tables.h index 8e5cec04bf..b0d7c90389 100644 --- a/payloads/libpayload/include/coreboot_tables.h +++ b/payloads/libpayload/include/coreboot_tables.h @@ -33,6 +33,58 @@ #include #include +enum { + CB_TAG_UNUSED = 0x0000, + CB_TAG_MEMORY = 0x0001, + CB_TAG_HWRPB = 0x0002, + CB_TAG_MAINBOARD = 0x0003, + CB_TAG_VERSION = 0x0004, + CB_TAG_EXTRA_VERSION = 0x0005, + CB_TAG_BUILD = 0x0006, + CB_TAG_COMPILE_TIME = 0x0007, + CB_TAG_COMPILE_BY = 0x0008, + CB_TAG_COMPILE_HOST = 0x0009, + CB_TAG_COMPILE_DOMAIN = 0x000a, + CB_TAG_COMPILER = 0x000b, + CB_TAG_LINKER = 0x000c, + CB_TAG_ASSEMBLER = 0x000d, + CB_TAG_SERIAL = 0x000f, + CB_TAG_CONSOLE = 0x0010, + CB_TAG_FORWARD = 0x0011, + CB_TAG_FRAMEBUFFER = 0x0012, + CB_TAG_GPIO = 0x0013, + CB_TAG_TIMESTAMPS = 0x0016, + CB_TAG_CBMEM_CONSOLE = 0x0017, + CB_TAG_MRC_CACHE = 0x0018, + CB_TAG_VBNV = 0x0019, + CB_TAG_VBOOT_HANDOFF = 0x0020, + CB_TAG_X86_ROM_MTRR = 0x0021, + CB_TAG_DMA = 0x0022, + CB_TAG_RAM_OOPS = 0x0023, + CB_TAG_ACPI_GNVS = 0x0024, + CB_TAG_BOARD_ID = 0x0025, + CB_TAG_VERSION_TIMESTAMP = 0x0026, + CB_TAG_WIFI_CALIBRATION = 0x0027, + CB_TAG_RAM_CODE = 0x0028, + CB_TAG_SPI_FLASH = 0x0029, + CB_TAG_SERIALNO = 0x002a, + CB_TAG_MTC = 0x002b, + CB_TAG_VPD = 0x002c, + CB_TAG_SKU_ID = 0x002d, + CB_TAG_BOOT_MEDIA_PARAMS = 0x0030, + CB_TAG_CBMEM_ENTRY = 0x0031, + CB_TAG_TSC_INFO = 0x0032, + CB_TAG_MAC_ADDRS = 0x0033, + CB_TAG_VBOOT_WORKBUF = 0x0034, + CB_TAG_MMC_INFO = 0x0035, + CB_TAG_TCPA_LOG = 0x0036, + CB_TAG_CMOS_OPTION_TABLE = 0x00c8, + CB_TAG_OPTION = 0x00c9, + CB_TAG_OPTION_ENUM = 0x00ca, + CB_TAG_OPTION_DEFAULTS = 0x00cb, + CB_TAG_OPTION_CHECKSUM = 0x00cc, +}; + struct cbuint64 { u32 lo; u32 hi; @@ -52,9 +104,6 @@ struct cb_record { u32 size; }; -#define CB_TAG_UNUSED 0x0000 -#define CB_TAG_MEMORY 0x0001 - struct cb_memory_range { struct cbuint64 start; struct cbuint64 size; @@ -75,16 +124,12 @@ struct cb_memory { struct cb_memory_range map[0]; }; -#define CB_TAG_HWRPB 0x0002 - struct cb_hwrpb { u32 tag; u32 size; u64 hwrpb; }; -#define CB_TAG_MAINBOARD 0x0003 - struct cb_mainboard { u32 tag; u32 size; @@ -93,25 +138,12 @@ struct cb_mainboard { u8 strings[0]; }; -#define CB_TAG_VERSION 0x0004 -#define CB_TAG_EXTRA_VERSION 0x0005 -#define CB_TAG_BUILD 0x0006 -#define CB_TAG_COMPILE_TIME 0x0007 -#define CB_TAG_COMPILE_BY 0x0008 -#define CB_TAG_COMPILE_HOST 0x0009 -#define CB_TAG_COMPILE_DOMAIN 0x000a -#define CB_TAG_COMPILER 0x000b -#define CB_TAG_LINKER 0x000c -#define CB_TAG_ASSEMBLER 0x000d - struct cb_string { u32 tag; u32 size; u8 string[0]; }; -#define CB_TAG_SERIAL 0x000f - struct cb_serial { u32 tag; u32 size; @@ -138,8 +170,6 @@ struct cb_serial { u32 uart_pci_addr; }; -#define CB_TAG_CONSOLE 0x00010 - struct cb_console { u32 tag; u32 size; @@ -153,15 +183,12 @@ struct cb_console { #define CB_TAG_CONSOLE_SROM 4 // OBSOLETE #define CB_TAG_CONSOLE_EHCI 5 -#define CB_TAG_FORWARD 0x00011 - struct cb_forward { u32 tag; u32 size; u64 forward; }; -#define CB_TAG_FRAMEBUFFER 0x0012 struct cb_framebuffer { u32 tag; u32 size; @@ -181,7 +208,6 @@ struct cb_framebuffer { u8 reserved_mask_size; }; -#define CB_TAG_GPIO 0x0013 #define CB_GPIO_ACTIVE_LOW 0 #define CB_GPIO_ACTIVE_HIGH 1 #define CB_GPIO_MAX_NAME_LENGTH 16 @@ -200,13 +226,6 @@ struct cb_gpios { struct cb_gpio gpios[0]; }; -#define CB_TAG_VBNV 0x0019 -#define CB_TAG_VBOOT_HANDOFF 0x0020 -#define CB_TAG_VBOOT_WORKBUF 0x0034 -#define CB_TAG_DMA 0x0022 -#define CB_TAG_RAM_OOPS 0x0023 -#define CB_TAG_MTC 0x002b -#define CB_TAG_VPD 0x002c struct lb_range { uint32_t tag; uint32_t size; @@ -214,18 +233,12 @@ struct lb_range { uint32_t range_size; }; -#define CB_TAG_TIMESTAMPS 0x0016 -#define CB_TAG_CBMEM_CONSOLE 0x0017 -#define CB_TAG_MRC_CACHE 0x0018 -#define CB_TAG_ACPI_GNVS 0x0024 -#define CB_TAG_WIFI_CALIBRATION 0x0027 struct cb_cbmem_tab { uint32_t tag; uint32_t size; uint64_t cbmem_tab; }; -#define CB_TAG_X86_ROM_MTRR 0x0021 struct cb_x86_rom_mtrr { uint32_t tag; uint32_t size; @@ -236,17 +249,12 @@ struct cb_x86_rom_mtrr { uint32_t index; }; - -#define CB_TAG_BOARD_ID 0x0025 -#define CB_TAG_RAM_CODE 0x0028 -#define CB_TAG_SKU_ID 0x002d struct cb_strapping_id { uint32_t tag; uint32_t size; uint32_t id_code; }; -#define CB_TAG_SPI_FLASH 0x0029 struct cb_spi_flash { uint32_t tag; uint32_t size; @@ -255,7 +263,6 @@ struct cb_spi_flash { uint32_t erase_cmd; }; -#define CB_TAG_BOOT_MEDIA_PARAMS 0x0030 struct cb_boot_media_params { uint32_t tag; uint32_t size; @@ -266,7 +273,6 @@ struct cb_boot_media_params { uint64_t boot_media_size; }; -#define CB_TAG_TSC_INFO 0x0032 struct cb_tsc_info { uint32_t tag; uint32_t size; @@ -274,7 +280,6 @@ struct cb_tsc_info { uint32_t freq_khz; }; -#define CB_TAG_MAC_ADDRS 0x0033 struct mac_address { uint8_t mac_addr[6]; uint8_t pad[2]; /* Pad it to 8 bytes to keep it simple. */ @@ -287,7 +292,6 @@ struct cb_macs { struct mac_address mac_addrs[0]; }; -#define CB_TAG_MMC_INFO 0x0035 struct cb_mmc_info { uint32_t tag; uint32_t size; @@ -302,17 +306,14 @@ struct cb_mmc_info { int32_t early_cmd1_status; }; -#define CB_TAG_SERIALNO 0x002a #define CB_MAX_SERIALNO_LENGTH 32 -#define CB_TAG_CMOS_OPTION_TABLE 0x00c8 struct cb_cmos_option_table { u32 tag; u32 size; u32 header_length; }; -#define CB_TAG_OPTION 0x00c9 #define CB_CMOS_MAX_NAME_LENGTH 32 struct cb_cmos_entries { u32 tag; @@ -324,8 +325,6 @@ struct cb_cmos_entries { u8 name[CB_CMOS_MAX_NAME_LENGTH]; }; - -#define CB_TAG_OPTION_ENUM 0x00ca #define CB_CMOS_MAX_TEXT_LENGTH 32 struct cb_cmos_enums { u32 tag; @@ -335,7 +334,6 @@ struct cb_cmos_enums { u8 text[CB_CMOS_MAX_TEXT_LENGTH]; }; -#define CB_TAG_OPTION_DEFAULTS 0x00cb #define CB_CMOS_IMAGE_BUFFER_SIZE 128 struct cb_cmos_defaults { u32 tag; @@ -345,7 +343,6 @@ struct cb_cmos_defaults { u8 default_set[CB_CMOS_IMAGE_BUFFER_SIZE]; }; -#define CB_TAG_OPTION_CHECKSUM 0x00cc #define CB_CHECKSUM_NONE 0 #define CB_CHECKSUM_PCBIOS 1 struct cb_cmos_checksum { diff --git a/payloads/libpayload/sample/Makefile b/payloads/libpayload/sample/Makefile index 5931d5eb11..18121dfe80 100644 --- a/payloads/libpayload/sample/Makefile +++ b/payloads/libpayload/sample/Makefile @@ -28,19 +28,20 @@ ## # Sample libpayload Makefile. -include ../.xcompile include ../.config +include ../.xcompile -ARCH-$(CONFIG_LP_ARCH_ARMV) := arm -ARCH-$(CONFIG_LP_ARCH_POWERPC) := powerpc -ARCH-$(CONFIG_LP_ARCH_X86) := i386 +ARCH-$(CONFIG_LP_ARCH_ARM) := arm +ARCH-$(CONFIG_LP_ARCH_X86) := x86_32 +ARCH-$(CONFIG_LP_ARCH_ARM64) := arm64 +ARCH-$(CONFIG_LP_ARCH_MIPS) := mips CC := $(CC_$(ARCH-y)) AS := $(AS_$(ARCH-y)) LIBPAYLOAD_DIR := ../install/libpayload XCC := CC="$(CC)" $(LIBPAYLOAD_DIR)/bin/lpgcc XAS := AS="$(AS)" $(LIBPAYLOAD_DIR)/bin/lpas -CFLAGS := -Wall -Werror -Os +CFLAGS := -fno-builtin -Wall -Werror -Os TARGET := hello OBJS := $(TARGET).o diff --git a/src/Kconfig b/src/Kconfig index 5d74d671b2..919d257c62 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -32,8 +32,13 @@ config LOCALVERSION the coreboot version number, so that you can easily distinguish boot logs of different boards from each other. +config CONFIGURABLE_CBFS_PREFIX + bool + help + Select this to prompt to use to configure the prefix for cbfs files. + config CBFS_PREFIX - string "CBFS prefix to use" + string "CBFS prefix to use" if CONFIGURABLE_CBFS_PREFIX default "fallback" help Select the prefix to all files put into the image. It's "fallback" @@ -285,7 +290,7 @@ config HAVE_RAMPAYLOAD config RAMPAYLOAD bool "Enable coreboot flow without executing ramstage" - default n + default y if ARCH_X86 depends on HAVE_RAMPAYLOAD help If this option is enabled, coreboot flow will skip ramstage diff --git a/src/arch/arm/armv7/mmu.c b/src/arch/arm/armv7/mmu.c index ce9d3fd9d8..b3133a08b7 100644 --- a/src/arch/arm/armv7/mmu.c +++ b/src/arch/arm/armv7/mmu.c @@ -29,6 +29,7 @@ */ #include +#include #include #include #include diff --git a/src/arch/arm/cpu.c b/src/arch/arm/cpu.c index fae1a37efc..87fc6b17cc 100644 --- a/src/arch/arm/cpu.c +++ b/src/arch/arm/cpu.c @@ -29,6 +29,7 @@ */ #include #include +#include /* Return the CPU struct which is at the high memory address of the stack. */ @@ -39,7 +40,7 @@ struct cpu_info *cpu_info(void) "feature, make sure you add the proper assertions " \ "(and maybe consider revising the whole thing to work closer to what " \ "arm64 is doing now)." - uintptr_t addr = ALIGN((uintptr_t)__builtin_frame_address(0), + uintptr_t addr = ALIGN_UP((uintptr_t)__builtin_frame_address(0), CONFIG_STACK_SIZE); addr -= sizeof(struct cpu_info); return (void *)addr; diff --git a/src/arch/arm64/armv8/bootblock.S b/src/arch/arm64/armv8/bootblock.S index e5758bca0d..3950f5530d 100644 --- a/src/arch/arm64/armv8/bootblock.S +++ b/src/arch/arm64/armv8/bootblock.S @@ -19,7 +19,7 @@ /* NOTE: When making changes to general ARM64 initialization, keep in mind that * there are other CPU entry points, using BOOTBLOCK_CUSTOM or entering the CPU * in a later stage (like Tegra). Changes should generally be put into - * arm64_cpu_init so they can be shared between those instances. */ + * arm64_init_cpu so they can be shared between those instances. */ ENTRY(_start) /* Initialize PSTATE, SCTLR and caches to clean state, set up stack. */ diff --git a/src/arch/arm64/fit_payload.c b/src/arch/arm64/fit_payload.c index c4bbceee4c..46bea23053 100644 --- a/src/arch/arm64/fit_payload.c +++ b/src/arch/arm64/fit_payload.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -184,20 +185,14 @@ bool fit_payload_arch(struct prog *payload, struct fit_config_node *config, bool place_anywhere; void *arg = NULL; - if (!config->fdt || !fdt) { - printk(BIOS_CRIT, "CRIT: Providing a valid FDT is mandatory to " - "boot an ARM64 kernel!\n"); - return false; - } - - if (!decompress_kernel_header(config->kernel_node)) { + if (!decompress_kernel_header(config->kernel)) { printk(BIOS_CRIT, "CRIT: Payload doesn't look like an ARM64" " kernel Image.\n"); return false; } /* Update kernel size from image header, if possible */ - kernel->size = get_kernel_size(config->kernel_node); + kernel->size = get_kernel_size(config->kernel); printk(BIOS_DEBUG, "FIT: Using kernel size of 0x%zx bytes\n", kernel->size); diff --git a/src/arch/riscv/boot.c b/src/arch/riscv/boot.c index edf5295d79..8e4bb36af5 100644 --- a/src/arch/riscv/boot.c +++ b/src/arch/riscv/boot.c @@ -19,6 +19,7 @@ #include #include #include +#include /* * A pointer to the Flattened Device Tree passed to coreboot by the boot ROM. @@ -33,6 +34,12 @@ static void do_arch_prog_run(struct prog *prog) int hart_id; void *fdt = prog_entry_arg(prog); + /* + * Workaround selfboot putting the coreboot table into prog_entry_arg + */ + if (prog_cbfs_type(prog) == CBFS_TYPE_SELF) + fdt = HLS()->fdt; + /* * If prog_entry_arg is not set (e.g. by fit_payload), use fdt from HLS * instead. diff --git a/src/arch/riscv/include/mcall.h b/src/arch/riscv/include/mcall.h index 192d2b4564..d7d67ce33b 100644 --- a/src/arch/riscv/include/mcall.h +++ b/src/arch/riscv/include/mcall.h @@ -27,7 +27,7 @@ #endif /* We save 37 registers, currently. */ -#define MENTRY_FRAME_SIZE (HLS_SIZE + 37 * 8) +#define MENTRY_FRAME_SIZE (HLS_SIZE + 37 * __SIZEOF_POINTER__) #ifndef __ASSEMBLER__ diff --git a/src/arch/riscv/mcall.c b/src/arch/riscv/mcall.c index eaef6442c5..afb17c1043 100644 --- a/src/arch/riscv/mcall.c +++ b/src/arch/riscv/mcall.c @@ -25,24 +25,15 @@ * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. */ -#include -#include -#include #include #include #include -int mcalldebug; // set this interactively for copious debug. - void hls_init(uint32_t hart_id, void *fdt) { - printk(BIOS_SPEW, "hart %d: HLS is %p\n", hart_id, HLS()); memset(HLS(), 0, sizeof(*HLS())); HLS()->fdt = fdt; HLS()->hart_id = hart_id; mtime_init(); - - printk(BIOS_SPEW, "Time is %p and timecmp is %p\n", - HLS()->time, HLS()->timecmp); } diff --git a/src/arch/riscv/payload.c b/src/arch/riscv/payload.c index f3ed5a44a6..903e8a6ab6 100644 --- a/src/arch/riscv/payload.c +++ b/src/arch/riscv/payload.c @@ -19,23 +19,38 @@ #include #include #include +#include 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 &= ~MSTATUS_MPIE; - status &= ~MSTATUS_MPP; + status = INSERT_FIELD(status, MSTATUS_MPIE, 0); switch (payload_mode) { case RISCV_PAYLOAD_MODE_U: + status = INSERT_FIELD(status, MSTATUS_MPP, PRV_U); + /* Trap vector base address point to the payload */ + write_csr(utvec, doit); + /* disable U-Mode interrupt */ + write_csr(uie, 0); break; case RISCV_PAYLOAD_MODE_S: - status |= MSTATUS_SPP; + status = INSERT_FIELD(status, MSTATUS_MPP, PRV_S); + /* Trap vector base address point to the payload */ + write_csr(stvec, doit); + /* disable S-Mode interrupt */ + write_csr(sie, 0); + /* disable MMU */ + write_csr(satp, 0); break; case RISCV_PAYLOAD_MODE_M: - doit(hart_id, fdt); - return; + status = INSERT_FIELD(status, MSTATUS_MPP, PRV_M); + /* Trap vector base address point to the payload */ + write_csr(mtvec, doit); + /* disable M-Mode interrupt */ + write_csr(mie, 0); + break; default: die("wrong privilege level for payload"); break; diff --git a/src/arch/x86/Kconfig b/src/arch/x86/Kconfig index 827c1cba02..06aadedae6 100644 --- a/src/arch/x86/Kconfig +++ b/src/arch/x86/Kconfig @@ -239,14 +239,17 @@ config ROMSTAGE_DEBUG_SPINLOOP Add a spin (JMP .) in assembly_entry.S during early romstage to wait for a JTAG debugger to break into the execution sequence. +# Selecting a cbfs prefix from the bootblock is only implemented with romcc choice prompt "Bootblock behaviour" default BOOTBLOCK_SIMPLE + depends on !C_ENVIRONMENT_BOOTBLOCK config BOOTBLOCK_SIMPLE bool "Always load fallback" config BOOTBLOCK_NORMAL + select CONFIGURABLE_CBFS_PREFIX bool "Switch to normal if CMOS says so" endchoice diff --git a/src/arch/x86/acpi.c b/src/arch/x86/acpi.c index bf9813cbfe..80923e3edd 100644 --- a/src/arch/x86/acpi.c +++ b/src/arch/x86/acpi.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -772,6 +773,57 @@ void acpi_create_vfct(struct device *device, header->checksum = acpi_checksum((void *)vfct, header->length); } +void acpi_create_ipmi(struct device *device, + struct acpi_spmi *spmi, + const u16 ipmi_revision, + const acpi_addr_t *addr, + const enum acpi_ipmi_interface_type type, + const s8 gpe_interrupt, + const u32 apic_interrupt, + const u32 uid) +{ + acpi_header_t *header = &(spmi->header); + memset((void *)spmi, 0, sizeof(struct acpi_spmi)); + + /* Fill out header fields. */ + memcpy(header->signature, "SPMI", 4); + memcpy(header->oem_id, OEM_ID, 6); + memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); + memcpy(header->asl_compiler_id, ASLC, 4); + + header->asl_compiler_revision = asl_revision; + header->length = sizeof(struct acpi_spmi); + header->revision = get_acpi_table_revision(SPMI); + + spmi->reserved = 1; + + if (device->path.type == DEVICE_PATH_PCI) { + spmi->pci_device_flag = ACPI_IPMI_PCI_DEVICE_FLAG; + spmi->pci_bus = device->bus->secondary; + spmi->pci_device = device->path.pci.devfn >> 3; + spmi->pci_function = device->path.pci.devfn & 0x7; + } else if (type != IPMI_INTERFACE_SSIF) { + memcpy(spmi->uid, &uid, sizeof(spmi->uid)); + } + + spmi->base_address = *addr; + spmi->specification_revision = ipmi_revision; + + spmi->interface_type = type; + + if (gpe_interrupt >= 0 && gpe_interrupt < 32) { + spmi->gpe = gpe_interrupt; + spmi->interrupt_type |= ACPI_IPMI_INT_TYPE_SCI; + } + if (apic_interrupt > 0) { + spmi->global_system_interrupt = apic_interrupt; + spmi->interrupt_type |= ACPI_IPMI_INT_TYPE_APIC; + } + + /* Calculate checksum. */ + header->checksum = acpi_checksum((void *)spmi, header->length); +} + void acpi_create_ivrs(acpi_ivrs_t *ivrs, unsigned long (*acpi_fill_ivrs)(acpi_ivrs_t *ivrs_struct, unsigned long current)) @@ -813,7 +865,7 @@ unsigned long acpi_write_hpet(struct device *device, unsigned long current, hpet = (acpi_hpet_t *) current; current += sizeof(acpi_hpet_t); - current = ALIGN(current, 16); + current = ALIGN_UP(current, 16); acpi_create_hpet(hpet); acpi_add_table(rsdp, hpet); @@ -1271,7 +1323,7 @@ unsigned long write_acpi_tables(unsigned long start) acpi_write_xsdt(xsdt, oem_id, oem_table_id); printk(BIOS_DEBUG, "ACPI: * FACS\n"); - current = (ALIGN(current, 64)); + current = ALIGN_UP(current, 64); facs = (acpi_facs_t *) current; current += sizeof(acpi_facs_t); current = acpi_align_current(current); @@ -1490,6 +1542,8 @@ int get_acpi_table_revision(enum acpi_tables table) return 1; case SLIT: /* ACPI 2.0 upto 6.3: 1 */ return 1; + case SPMI: /* IMPI 2.0 */ + return 5; case HPET: /* Currently 1. Table added in ACPI 2.0. */ return 1; case VFCT: /* ACPI 2.0/3.0/4.0: 1 */ diff --git a/src/arch/x86/acpi_s3.c b/src/arch/x86/acpi_s3.c index 4c573033da..049fb12e75 100644 --- a/src/arch/x86/acpi_s3.c +++ b/src/arch/x86/acpi_s3.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include diff --git a/src/arch/x86/car.ld b/src/arch/x86/car.ld index 29b3600bbe..5802b02896 100644 --- a/src/arch/x86/car.ld +++ b/src/arch/x86/car.ld @@ -91,13 +91,6 @@ _car_global_end = .; _car_relocatable_data_end = .; -#if CONFIG(NORTHBRIDGE_INTEL_SANDYBRIDGE) && !CONFIG(USE_NATIVE_RAMINIT) - . = ABSOLUTE(0xff7e1000); - _mrc_pool = .; - . += 0x5000; - _emrc_pool = .; -#endif - #if !CONFIG(C_ENVIRONMENT_BOOTBLOCK) _car_stack_start = .; _car_stack_end = _car_region_end; diff --git a/src/arch/x86/cpu.c b/src/arch/x86/cpu.c index e6c9435503..cfab21956b 100644 --- a/src/arch/x86/cpu.c +++ b/src/arch/x86/cpu.c @@ -113,6 +113,7 @@ static struct { { X86_VENDOR_TRANSMETA, "TransmetaCPU", }, { X86_VENDOR_NSC, "Geode by NSC", }, { X86_VENDOR_SIS, "SiS SiS SiS ", }, + { X86_VENDOR_HYGON, "HygonGenuine", }, }; static const char *const x86_vendor_name[] = { @@ -126,6 +127,7 @@ static const char *const x86_vendor_name[] = { [X86_VENDOR_TRANSMETA] = "Transmeta", [X86_VENDOR_NSC] = "NSC", [X86_VENDOR_SIS] = "SiS", + [X86_VENDOR_HYGON] = "Hygon", }; static const char *cpu_vendor_name(int vendor) diff --git a/src/arch/x86/gdt.c b/src/arch/x86/gdt.c index c9aec6d111..81756ff568 100644 --- a/src/arch/x86/gdt.c +++ b/src/arch/x86/gdt.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -46,7 +47,7 @@ static void move_gdt(int is_recovery) newgdt = cbmem_find(CBMEM_ID_GDT); num_gdt_bytes = (uintptr_t)&gdt_end - (uintptr_t)&gdt; if (!newgdt) { - newgdt = cbmem_add(CBMEM_ID_GDT, ALIGN(num_gdt_bytes, 512)); + newgdt = cbmem_add(CBMEM_ID_GDT, ALIGN_UP(num_gdt_bytes, 512)); if (!newgdt) { printk(BIOS_ERR, "Error: Could not relocate GDT.\n"); return; diff --git a/src/arch/x86/include/arch/acpi.h b/src/arch/x86/include/arch/acpi.h index dbf46a9b1b..6251b98142 100644 --- a/src/arch/x86/include/arch/acpi.h +++ b/src/arch/x86/include/arch/acpi.h @@ -82,7 +82,7 @@ enum acpi_tables { BERT, DBG2, DMAR, DSDT, FACS, FADT, HEST, HPET, IVRS, MADT, MCFG, RSDP, RSDT, SLIT, SRAT, SSDT, TCPA, TPM2, XSDT, ECDT, /* Additional proprietary tables used by coreboot */ - VFCT, NHLT + VFCT, NHLT, SPMI }; /* RSDP (Root System Description Pointer) */ @@ -782,6 +782,43 @@ enum acpi_upc_type { UPC_TYPE_HUB }; +enum acpi_ipmi_interface_type { + IPMI_INTERFACE_RESERVED = 0, + IPMI_INTERFACE_KCS, + IPMI_INTERFACE_SMIC, + IPMI_INTERFACE_BT, + IPMI_INTERFACE_SSIF, +}; + +#define ACPI_IPMI_PCI_DEVICE_FLAG (1 << 0) +#define ACPI_IPMI_INT_TYPE_SCI (1 << 0) +#define ACPI_IPMI_INT_TYPE_APIC (1 << 1) + +/* ACPI IPMI 2.0 */ +struct acpi_spmi { + struct acpi_table_header header; + u8 interface_type; + u8 reserved; + u16 specification_revision; + u8 interrupt_type; + u8 gpe; + u8 reserved2; + u8 pci_device_flag; + + u32 global_system_interrupt; + acpi_addr_t base_address; + union { + struct { + u8 pci_segment_group; + u8 pci_bus; + u8 pci_device; + u8 pci_function; + }; + u8 uid[4]; + }; + u8 reserved3; +} __packed; + unsigned long fw_cfg_acpi_tables(unsigned long start); /* These are implemented by the target port or north/southbridge. */ @@ -834,6 +871,15 @@ void acpi_create_vfct(struct device *device, struct acpi_vfct *vfct_struct, unsigned long current)); +void acpi_create_ipmi(struct device *device, + struct acpi_spmi *spmi, + const u16 ipmi_revision, + const acpi_addr_t *addr, + const enum acpi_ipmi_interface_type type, + const s8 gpe_interrupt, + const u32 apic_interrupt, + const u32 uid); + void acpi_create_ivrs(acpi_ivrs_t *ivrs, unsigned long (*acpi_fill_ivrs)(acpi_ivrs_t *ivrs_struct, unsigned long current)); @@ -958,7 +1004,7 @@ static inline int acpi_is_wakeup_s4(void) { return 0; } static inline uintptr_t acpi_align_current(uintptr_t current) { - return ALIGN(current, 16); + return ALIGN_UP(current, 16); } /* ACPI table revisions should match the revision of the ACPI spec diff --git a/src/arch/x86/include/arch/cpu.h b/src/arch/x86/include/arch/cpu.h index 078ea1748b..ff1a33b9ea 100644 --- a/src/arch/x86/include/arch/cpu.h +++ b/src/arch/x86/include/arch/cpu.h @@ -152,6 +152,7 @@ static inline unsigned int cpuid_edx(unsigned int op) #define X86_VENDOR_TRANSMETA 8 #define X86_VENDOR_NSC 9 #define X86_VENDOR_SIS 10 +#define X86_VENDOR_HYGON 11 #define X86_VENDOR_ANY 0xfe #define X86_VENDOR_UNKNOWN 0xff diff --git a/src/arch/x86/include/arch/early_variables.h b/src/arch/x86/include/arch/early_variables.h index 9ea1537d81..a69c230596 100644 --- a/src/arch/x86/include/arch/early_variables.h +++ b/src/arch/x86/include/arch/early_variables.h @@ -17,6 +17,7 @@ #define ARCH_EARLY_VARIABLES_H #include +#include #include #if ENV_CACHE_AS_RAM && !CONFIG(NO_CAR_GLOBAL_MIGRATION) @@ -69,7 +70,7 @@ int car_active(void); static inline size_t car_data_size(void) { size_t car_size = _car_relocatable_data_size; - return ALIGN(car_size, 64); + return ALIGN_UP(car_size, 64); } static inline size_t car_object_offset(void *ptr) diff --git a/src/arch/x86/pirq_routing.c b/src/arch/x86/pirq_routing.c index 194efb4ad2..15d7411b3f 100644 --- a/src/arch/x86/pirq_routing.c +++ b/src/arch/x86/pirq_routing.c @@ -16,6 +16,7 @@ */ #include #include +#include #include #include @@ -191,7 +192,7 @@ unsigned long copy_pirq_routing_table(unsigned long addr, const struct irq_routing_table *routing_table) { /* Align the table to be 16 byte aligned. */ - addr = ALIGN(addr, 16); + addr = ALIGN_UP(addr, 16); /* This table must be between 0xf0000 & 0x100000 */ printk(BIOS_INFO, "Copying Interrupt Routing Table to 0x%08lx... ", diff --git a/src/arch/x86/rdrand.c b/src/arch/x86/rdrand.c index 35aac710a8..c9090df1fd 100644 --- a/src/arch/x86/rdrand.c +++ b/src/arch/x86/rdrand.c @@ -75,7 +75,6 @@ int get_random_number_64(uint64_t *rand) #if ENV_X86_64 if (rdrand_64(rand)) return 0; - else #endif if (rdrand_32(&rand_high) && rdrand_32(&rand_low)) { *rand = ((uint64_t)rand_high << 32) | diff --git a/src/arch/x86/smbios.c b/src/arch/x86/smbios.c index 54c2b09c4a..2f5c3a643e 100644 --- a/src/arch/x86/smbios.c +++ b/src/arch/x86/smbios.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -1150,12 +1151,12 @@ unsigned long smbios_write_tables(unsigned long current) int max_struct_size = 0; int handle = 0; - current = ALIGN(current, 16); + current = ALIGN_UP(current, 16); printk(BIOS_DEBUG, "%s: %08lx\n", __func__, current); se = (struct smbios_entry *)current; current += sizeof(struct smbios_entry); - current = ALIGN(current, 16); + current = ALIGN_UP(current, 16); tables = current; update_max(len, max_struct_size, smbios_write_type0(¤t, @@ -1193,7 +1194,7 @@ unsigned long smbios_write_tables(unsigned long current) memcpy(se->anchor, "_SM_", 4); se->length = sizeof(struct smbios_entry); se->major_version = 2; - se->minor_version = 7; + se->minor_version = 8; se->max_struct_size = max_struct_size; se->struct_count = handle; memcpy(se->intermediate_anchor_string, "_DMI_", 5); diff --git a/src/arch/x86/tables.c b/src/arch/x86/tables.c index f17fb858b0..0baa58eb2b 100644 --- a/src/arch/x86/tables.c +++ b/src/arch/x86/tables.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -36,7 +37,7 @@ static unsigned long write_pirq_table(unsigned long rom_table_end) /* This table must be between 0x0f0000 and 0x100000 */ rom_table_end = write_pirq_routing_table(rom_table_end); - rom_table_end = ALIGN(rom_table_end, 1024); + rom_table_end = ALIGN_UP(rom_table_end, 1024); /* And add a high table version for those payloads that * want to live in the F segment @@ -68,7 +69,7 @@ static unsigned long write_mptable(unsigned long rom_table_end) /* The smp table must be in 0-1K, 639K-640K, or 960K-1M */ rom_table_end = write_smp_table(rom_table_end); - rom_table_end = ALIGN(rom_table_end, 1024); + rom_table_end = ALIGN_UP(rom_table_end, 1024); high_table_pointer = (unsigned long)cbmem_add(CBMEM_ID_MPTABLE, MAX_MP_TABLE_SIZE); @@ -114,7 +115,7 @@ static unsigned long write_acpi_table(unsigned long rom_table_end) unsigned long acpi_start = high_table_pointer; unsigned long new_high_table_pointer; - rom_table_end = ALIGN(rom_table_end, 16); + rom_table_end = ALIGN_UP(rom_table_end, 16); new_high_table_pointer = write_acpi_tables(high_table_pointer); if (new_high_table_pointer > (high_table_pointer + MAX_ACPI_SIZE)) @@ -146,10 +147,10 @@ static unsigned long write_acpi_table(unsigned long rom_table_end) printk(BIOS_ERR, "ERROR: Didn't find RSDP in high table.\n"); } - rom_table_end = ALIGN(rom_table_end + sizeof(acpi_rsdp_t), 16); + rom_table_end = ALIGN_UP(rom_table_end + sizeof(acpi_rsdp_t), 16); } else { rom_table_end = write_acpi_tables(rom_table_end); - rom_table_end = ALIGN(rom_table_end, 1024); + rom_table_end = ALIGN_UP(rom_table_end, 1024); } return rom_table_end; @@ -168,7 +169,7 @@ static unsigned long write_smbios_table(unsigned long rom_table_end) new_high_table_pointer = smbios_write_tables(high_table_pointer); - rom_table_end = ALIGN(rom_table_end, 16); + rom_table_end = ALIGN_UP(rom_table_end, 16); memcpy((void *)rom_table_end, (void *)high_table_pointer, sizeof(struct smbios_entry)); rom_table_end += sizeof(struct smbios_entry); @@ -184,7 +185,7 @@ static unsigned long write_smbios_table(unsigned long rom_table_end) new_rom_table_end = smbios_write_tables(rom_table_end); printk(BIOS_DEBUG, "SMBIOS size %ld bytes\n", new_rom_table_end - rom_table_end); - rom_table_end = ALIGN(new_rom_table_end, 16); + rom_table_end = ALIGN_UP(new_rom_table_end, 16); } return rom_table_end; diff --git a/src/commonlib/include/commonlib/coreboot_tables.h b/src/commonlib/include/commonlib/coreboot_tables.h index 277b7467fb..1ae5421bba 100644 --- a/src/commonlib/include/commonlib/coreboot_tables.h +++ b/src/commonlib/include/commonlib/coreboot_tables.h @@ -44,6 +44,58 @@ * table entries and be backwards compatible, but it is not required. */ +enum { + LB_TAG_UNUSED = 0x0000, + LB_TAG_MEMORY = 0x0001, + LB_TAG_HWRPB = 0x0002, + LB_TAG_MAINBOARD = 0x0003, + LB_TAG_VERSION = 0x0004, + LB_TAG_EXTRA_VERSION = 0x0005, + LB_TAG_BUILD = 0x0006, + LB_TAG_COMPILE_TIME = 0x0007, + LB_TAG_COMPILE_BY = 0x0008, + LB_TAG_COMPILE_HOST = 0x0009, + LB_TAG_COMPILE_DOMAIN = 0x000a, + LB_TAG_COMPILER = 0x000b, + LB_TAG_LINKER = 0x000c, + LB_TAG_ASSEMBLER = 0x000d, + LB_TAG_SERIAL = 0x000f, + LB_TAG_CONSOLE = 0x0010, + LB_TAG_FORWARD = 0x0011, + LB_TAG_FRAMEBUFFER = 0x0012, + LB_TAG_GPIO = 0x0013, + LB_TAG_TIMESTAMPS = 0x0016, + LB_TAG_CBMEM_CONSOLE = 0x0017, + LB_TAG_MRC_CACHE = 0x0018, + LB_TAG_VBNV = 0x0019, + LB_TAG_VBOOT_HANDOFF = 0x0020, + LB_TAG_X86_ROM_MTRR = 0x0021, + LB_TAG_DMA = 0x0022, + LB_TAG_RAM_OOPS = 0x0023, + LB_TAG_ACPI_GNVS = 0x0024, + LB_TAG_BOARD_ID = 0x0025, + LB_TAG_VERSION_TIMESTAMP = 0x0026, + LB_TAG_WIFI_CALIBRATION = 0x0027, + LB_TAG_RAM_CODE = 0x0028, + LB_TAG_SPI_FLASH = 0x0029, + LB_TAG_SERIALNO = 0x002a, + LB_TAG_MTC = 0x002b, + LB_TAG_VPD = 0x002c, + LB_TAG_SKU_ID = 0x002d, + LB_TAG_BOOT_MEDIA_PARAMS = 0x0030, + LB_TAG_CBMEM_ENTRY = 0x0031, + LB_TAG_TSC_INFO = 0x0032, + LB_TAG_MAC_ADDRS = 0x0033, + LB_TAG_VBOOT_WORKBUF = 0x0034, + LB_TAG_MMC_INFO = 0x0035, + LB_TAG_TCPA_LOG = 0x0036, + LB_TAG_CMOS_OPTION_TABLE = 0x00c8, + LB_TAG_OPTION = 0x00c9, + LB_TAG_OPTION_ENUM = 0x00ca, + LB_TAG_OPTION_DEFAULTS = 0x00cb, + LB_TAG_OPTION_CHECKSUM = 0x00cc, +}; + /* Since coreboot is usually compiled 32bit, gcc will align 64bit * types to 32bit boundaries. If the coreboot table is dumped on a * 64bit system, a uint64_t would be aligned to 64bit boundaries, @@ -97,9 +149,6 @@ struct lb_record { uint32_t size; /* size of record (in bytes) */ }; -#define LB_TAG_UNUSED 0x0000 - -#define LB_TAG_MEMORY 0x0001 struct lb_memory_range { struct lb_uint64 start; @@ -120,14 +169,12 @@ struct lb_memory { struct lb_memory_range map[0]; }; -#define LB_TAG_HWRPB 0x0002 struct lb_hwrpb { uint32_t tag; uint32_t size; uint64_t hwrpb; }; -#define LB_TAG_MAINBOARD 0x0003 struct lb_mainboard { uint32_t tag; uint32_t size; @@ -136,23 +183,12 @@ struct lb_mainboard { uint8_t strings[0]; }; -#define LB_TAG_VERSION 0x0004 -#define LB_TAG_EXTRA_VERSION 0x0005 -#define LB_TAG_BUILD 0x0006 -#define LB_TAG_COMPILE_TIME 0x0007 -#define LB_TAG_COMPILE_BY 0x0008 -#define LB_TAG_COMPILE_HOST 0x0009 -#define LB_TAG_COMPILE_DOMAIN 0x000a -#define LB_TAG_COMPILER 0x000b -#define LB_TAG_LINKER 0x000c -#define LB_TAG_ASSEMBLER 0x000d struct lb_string { uint32_t tag; uint32_t size; uint8_t string[0]; }; -#define LB_TAG_VERSION_TIMESTAMP 0x0026 struct lb_timestamp { uint32_t tag; uint32_t size; @@ -162,7 +198,6 @@ struct lb_timestamp { /* 0xe is taken by v3 */ -#define LB_TAG_SERIAL 0x000f struct lb_serial { uint32_t tag; uint32_t size; @@ -189,7 +224,6 @@ struct lb_serial { uint32_t uart_pci_addr; }; -#define LB_TAG_CONSOLE 0x0010 struct lb_console { uint32_t tag; uint32_t size; @@ -204,7 +238,6 @@ struct lb_console { #define LB_TAG_CONSOLE_EHCI 5 #define LB_TAG_CONSOLE_SERIAL8250MEM 6 -#define LB_TAG_FORWARD 0x0011 struct lb_forward { uint32_t tag; uint32_t size; @@ -250,7 +283,6 @@ struct lb_forward { * fields described above. It may, however, only implement a subset * of the possible color formats. */ -#define LB_TAG_FRAMEBUFFER 0x0012 struct lb_framebuffer { uint32_t tag; uint32_t size; @@ -270,7 +302,6 @@ struct lb_framebuffer { uint8_t reserved_mask_size; }; -#define LB_TAG_GPIO 0x0013 struct lb_gpio { uint32_t port; @@ -290,12 +321,6 @@ struct lb_gpios { struct lb_gpio gpios[0]; }; -#define LB_TAG_VBNV 0x0019 -#define LB_TAG_VBOOT_HANDOFF 0x0020 -#define LB_TAG_VBOOT_WORKBUF 0x0034 -#define LB_TAG_DMA 0x0022 -#define LB_TAG_RAM_OOPS 0x0023 -#define LB_TAG_MTC 0x002b struct lb_range { uint32_t tag; uint32_t size; @@ -306,13 +331,6 @@ struct lb_range { void lb_ramoops(struct lb_header *header); -#define LB_TAG_TIMESTAMPS 0x0016 -#define LB_TAG_CBMEM_CONSOLE 0x0017 -#define LB_TAG_MRC_CACHE 0x0018 -#define LB_TAG_ACPI_GNVS 0x0024 -#define LB_TAG_TCPA_LOG 0x0036 -#define LB_TAG_WIFI_CALIBRATION 0x0027 -#define LB_TAG_VPD 0x002c struct lb_cbmem_ref { uint32_t tag; uint32_t size; @@ -320,7 +338,6 @@ struct lb_cbmem_ref { uint64_t cbmem_addr; }; -#define LB_TAG_X86_ROM_MTRR 0x0021 struct lb_x86_rom_mtrr { uint32_t tag; uint32_t size; @@ -328,9 +345,6 @@ struct lb_x86_rom_mtrr { uint32_t index; }; -#define LB_TAG_BOARD_ID 0x0025 -#define LB_TAG_RAM_CODE 0x0028 -#define LB_TAG_SKU_ID 0x002d struct lb_strapping_id { uint32_t tag; @@ -338,7 +352,6 @@ struct lb_strapping_id { uint32_t id_code; }; -#define LB_TAG_SPI_FLASH 0x0029 struct lb_spi_flash { uint32_t tag; uint32_t size; @@ -347,7 +360,6 @@ struct lb_spi_flash { uint32_t erase_cmd; }; -#define LB_TAG_BOOT_MEDIA_PARAMS 0x0030 struct lb_boot_media_params { uint32_t tag; uint32_t size; @@ -361,7 +373,6 @@ struct lb_boot_media_params { /* * There can be more than one of these records as there is one per cbmem entry. */ -#define LB_TAG_CBMEM_ENTRY 0x0031 struct lb_cbmem_entry { uint32_t tag; uint32_t size; @@ -371,7 +382,6 @@ struct lb_cbmem_entry { uint32_t id; }; -#define LB_TAG_TSC_INFO 0x0032 struct lb_tsc_info { uint32_t tag; uint32_t size; @@ -379,13 +389,11 @@ struct lb_tsc_info { uint32_t freq_khz; }; -#define LB_TAG_MAC_ADDRS 0x0033 struct mac_address { uint8_t mac_addr[6]; uint8_t pad[2]; /* Pad it to 8 bytes to keep it simple. */ }; -#define LB_TAG_MMC_INFO 0x0035 struct lb_mmc_info { uint32_t tag; uint32_t size; @@ -407,11 +415,9 @@ struct lb_macs { struct mac_address mac_addrs[0]; }; -#define LB_TAG_SERIALNO 0x002a #define MAX_SERIALNO_LENGTH 32 /* The following structures are for the cmos definitions table */ -#define LB_TAG_CMOS_OPTION_TABLE 200 /* cmos header record */ struct cmos_option_table { uint32_t tag; /* CMOS definitions table type */ @@ -426,7 +432,6 @@ struct cmos_option_table { * starts at the beginning of the byte and the length is * fills complete bytes. */ -#define LB_TAG_OPTION 201 struct cmos_entries { uint32_t tag; /* entry type */ uint32_t size; /* length of this record */ @@ -444,7 +449,6 @@ struct cmos_entries { * This record is variable length. The text field may be * shorter than CMOS_MAX_TEXT_LENGTH. */ -#define LB_TAG_OPTION_ENUM 202 struct cmos_enums { uint32_t tag; /* enumeration type */ uint32_t size; /* length of this record */ @@ -458,7 +462,6 @@ struct cmos_enums { /* cmos defaults record * This record contains default settings for the cmos ram. */ -#define LB_TAG_OPTION_DEFAULTS 203 struct cmos_defaults { uint32_t tag; /* default type */ uint32_t size; /* length of this record */ @@ -468,7 +471,6 @@ struct cmos_defaults { uint8_t default_set[CMOS_IMAGE_BUFFER_SIZE]; /* default settings */ }; -#define LB_TAG_OPTION_CHECKSUM 204 struct cmos_checksum { uint32_t tag; uint32_t size; diff --git a/src/commonlib/storage/bouncebuf.h b/src/commonlib/storage/bouncebuf.h index 27d92e826b..0d81be1faa 100644 --- a/src/commonlib/storage/bouncebuf.h +++ b/src/commonlib/storage/bouncebuf.h @@ -88,7 +88,7 @@ int bounce_buffer_stop(struct bounce_buffer *state); #define ALLOC_CACHE_ALIGN_BUFFER(type, name, size) \ char __##name[ROUND(size * sizeof(type), DMA_MINALIGN) + \ DMA_MINALIGN - 1]; \ - type *name = (type *) ALIGN((uintptr_t)__##name, DMA_MINALIGN) + type *name = (type *) ALIGN_UP((uintptr_t)__##name, DMA_MINALIGN) #ifndef ARCH_DMA_MINALIGN #define ARCH_DMA_MINALIGN (DMA_MINALIGN) #endif diff --git a/src/commonlib/storage/storage.h b/src/commonlib/storage/storage.h index 645b6c1abd..c71510dd19 100644 --- a/src/commonlib/storage/storage.h +++ b/src/commonlib/storage/storage.h @@ -23,7 +23,7 @@ #define ALLOC_CACHE_ALIGN_BUFFER(type, name, size) \ char __##name[ROUND(size * sizeof(type), DMA_MINALIGN) + \ DMA_MINALIGN - 1]; \ - type *name = (type *) ALIGN((uintptr_t)__##name, DMA_MINALIGN) + type *name = (type *) ALIGN_UP((uintptr_t)__##name, DMA_MINALIGN) /* NOOPs mirroring ARM's cache API, since x86 devices usually cache snoop */ #define dcache_invalidate_by_mva(addr, len) diff --git a/src/console/vtxprintf.c b/src/console/vtxprintf.c index c429ac79e2..01091c82e8 100644 --- a/src/console/vtxprintf.c +++ b/src/console/vtxprintf.c @@ -16,6 +16,7 @@ */ #include +#include #include #define call_tx(x) tx_byte(x, data) diff --git a/src/cpu/allwinner/a10/clock.c b/src/cpu/allwinner/a10/clock.c index 76198b76ba..9e4e93dfe1 100644 --- a/src/cpu/allwinner/a10/clock.c +++ b/src/cpu/allwinner/a10/clock.c @@ -22,7 +22,6 @@ #include #include #include -#include static struct a10_ccm *const ccm = (void *)A1X_CCM_BASE; diff --git a/src/cpu/amd/car/post_cache_as_ram.c b/src/cpu/amd/car/post_cache_as_ram.c index 18e7542e6d..50ed657f42 100644 --- a/src/cpu/amd/car/post_cache_as_ram.c +++ b/src/cpu/amd/car/post_cache_as_ram.c @@ -16,10 +16,12 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ + #include #include #include #include +#include #include #include #include @@ -45,7 +47,7 @@ static size_t backup_size(void) { size_t car_size = car_data_size(); - return ALIGN(car_size + 1024, 1024); + return ALIGN_UP(car_size + 1024, 1024); } static void memcpy_(void *d, const void *s, size_t len) diff --git a/src/cpu/amd/family_10h-family_15h/init_cpus.c b/src/cpu/amd/family_10h-family_15h/init_cpus.c index d6a4725e2e..f416d9ccdb 100644 --- a/src/cpu/amd/family_10h-family_15h/init_cpus.c +++ b/src/cpu/amd/family_10h-family_15h/init_cpus.c @@ -504,10 +504,9 @@ u32 init_cpus(u32 cpu_init_detectedx, struct sys_info *sysinfo) if (is_fam15h()) { /* core 1 on node 0 is special; to avoid corrupting the * BSP do not alter MTRRs on that core */ + fam15_bsp_core1_apicid = 1; if (CONFIG(ENABLE_APIC_EXT_ID) && (CONFIG_APIC_ID_OFFSET > 0)) - fam15_bsp_core1_apicid = CONFIG_APIC_ID_OFFSET + 1; - else - fam15_bsp_core1_apicid = 1; + fam15_bsp_core1_apicid += CONFIG_APIC_ID_OFFSET; if (apicid == fam15_bsp_core1_apicid) set_mtrrs = 0; diff --git a/src/cpu/amd/family_10h-family_15h/init_cpus.h b/src/cpu/amd/family_10h-family_15h/init_cpus.h index 5d653d123b..cca00496ea 100644 --- a/src/cpu/amd/family_10h-family_15h/init_cpus.h +++ b/src/cpu/amd/family_10h-family_15h/init_cpus.h @@ -16,7 +16,6 @@ #ifndef INIT_CPUS_H #define INIT_CPUS_H -#include #include #include #include diff --git a/src/cpu/amd/family_10h-family_15h/powernow_acpi.c b/src/cpu/amd/family_10h-family_15h/powernow_acpi.c index e648b71750..be936f66e3 100644 --- a/src/cpu/amd/family_10h-family_15h/powernow_acpi.c +++ b/src/cpu/amd/family_10h-family_15h/powernow_acpi.c @@ -259,8 +259,6 @@ void amd_generate_powernow(u32 pcontrol_blk, u8 plen, u8 onlyBSP) else if (mctGetLogicalCPUID(0) & AMD_FAM15_ALL) boost_count = (dtemp >> 2) & 0x7; - Pstate_num = 0; - /* See if the CPUID(0x80000007) returned EDX[7]==1b */ cpuid1 = cpuid(0x80000007); if ((cpuid1.edx & 0x80) != 0x80) { diff --git a/src/cpu/amd/pi/00730F01/Kconfig b/src/cpu/amd/pi/00730F01/Kconfig index 054523ee37..f3f488d2dd 100644 --- a/src/cpu/amd/pi/00730F01/Kconfig +++ b/src/cpu/amd/pi/00730F01/Kconfig @@ -16,6 +16,8 @@ config CPU_AMD_PI_00730F01 bool select X86_AMD_FIXED_MTRRS + select SUPPORT_CPU_UCODE_IN_CBFS + select MICROCODE_BLOB_UNDISCLOSED if CPU_AMD_PI_00730F01 diff --git a/src/cpu/amd/pi/00730F01/Makefile.inc b/src/cpu/amd/pi/00730F01/Makefile.inc index 9367b458a3..99b6ef33a9 100644 --- a/src/cpu/amd/pi/00730F01/Makefile.inc +++ b/src/cpu/amd/pi/00730F01/Makefile.inc @@ -14,10 +14,14 @@ # romstage-y += fixme.c +romstage-y += update_microcode.c +romstage-y += microcode_fam16h.c ramstage-y += fixme.c ramstage-y += chip_name.c ramstage-y += model_16_init.c +ramstage-y += update_microcode.c +ramstage-y += microcode_fam16h.c subdirs-y += ../../mtrr subdirs-y += ../../../x86/tsc diff --git a/src/cpu/amd/pi/00730F01/microcode_fam16h.c b/src/cpu/amd/pi/00730F01/microcode_fam16h.c new file mode 100644 index 0000000000..ad951242a7 --- /dev/null +++ b/src/cpu/amd/pi/00730F01/microcode_fam16h.c @@ -0,0 +1,169 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2007 Advanced Micro Devices, Inc. + * Copyright (C) 2015 Raptor Engineering + * Copyright (C) 2019 PC Engines 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 +#include +#include +#include +#include +#include + +/* + * Values and header structure from: + * BKDG for AMD Family 16h Models 30h-3Fh Processors + * 52740 Rev 3.06 - March 18, 2016 + */ + +#define F16H_MPB_MAX_SIZE 3458 +#define F16H_MPB_DATA_OFFSET 32 + + /* + * STRUCTURE OF A MICROCODE (UCODE) FILE FOR FAM16h + * Microcode Patch Block + * Microcode Header + * Microcode "Blob" + * ... + * ... + * (end of file) + * + * + * MICROCODE HEADER (offset 0 bytes from start of file) + * Total size = 32 bytes + * [0:3] Date code (32 bits) + * [4:7] Patch level (32 bits) + * [8:9] Microcode patch data ID (16 bits) + * [10:15] Reserved (48 bits) + * [16:19] Chipset 1 device ID (32 bits) + * [20:23] Chipset 2 device ID (32 bits) + * [24:25] Processor Revisions ID (16 bits) + * [26] Chipset 1 revision ID (8 bits) + * [27] Chipset 2 revision ID (8 bits) + * [28:31] Reserved (32 bits) + * + * MICROCODE BLOB (offset += 32) + * Total size = m bytes + * + */ + +struct microcode { + uint32_t date_code; + uint32_t patch_id; + + uint16_t mc_patch_data_id; + uint8_t reserved1[6]; + + uint32_t chipset1_dev_id; + uint32_t chipset2_dev_id; + + uint16_t processor_rev_id; + + uint8_t chipset1_rev_id; + uint8_t chipset2_rev_id; + + uint8_t reserved2[4]; + + uint8_t m_patch_data[F16H_MPB_MAX_SIZE-F16H_MPB_DATA_OFFSET]; + +}; + +static void apply_microcode_patch(const struct microcode *m) +{ + uint32_t new_patch_id; + msr_t msr; + + /* apply patch */ + msr.hi = 0; + msr.lo = (uint32_t)m; + + wrmsr(0xc0010020, msr); + + printk(BIOS_DEBUG, "microcode: patch id to apply = 0x%08x\n", + m->patch_id); + + /* patch authentication */ + msr = rdmsr(0x8b); + new_patch_id = msr.lo; + + printk(BIOS_DEBUG, "microcode: updated to patch id = 0x%08x %s\n", + new_patch_id, + (new_patch_id == m->patch_id) ? "success" : "fail"); +} + +static void amd_update_microcode(const void *ucode, size_t ucode_len, + uint32_t equivalent_processor_rev_id) +{ + const struct microcode *m; + const uint8_t *c = ucode; + + m = (struct microcode *)c; + + if (m->processor_rev_id == equivalent_processor_rev_id) + apply_microcode_patch(m); +} + +void amd_update_microcode_from_cbfs(uint32_t equivalent_processor_rev_id) +{ + const void *ucode; + size_t ucode_len; + + if (equivalent_processor_rev_id == 0) { + printk(BIOS_DEBUG, "microcode: rev id not found. " + "Skipping microcode patch!\n"); + return; + } +#ifdef __PRE_RAM__ +#if CONFIG(HAVE_ROMSTAGE_MICROCODE_CBFS_SPINLOCK) + spin_lock(romstage_microcode_cbfs_lock()); +#endif +#endif + ucode = cbfs_boot_map_with_leak("cpu_microcode_blob.bin", + CBFS_TYPE_MICROCODE, + &ucode_len); + if (!ucode) { + printk(BIOS_DEBUG, "cpu_microcode_blob.bin not found. " + "Skipping updates.\n"); +#ifdef __PRE_RAM__ +#if CONFIG(HAVE_ROMSTAGE_MICROCODE_CBFS_SPINLOCK) + spin_unlock(romstage_microcode_cbfs_lock()); +#endif +#endif + return; + } + + if (ucode_len > F16H_MPB_MAX_SIZE || + ucode_len < F16H_MPB_DATA_OFFSET) { + printk(BIOS_DEBUG, "microcode file invalid. Skipping " + "updates.\n"); +#ifdef __PRE_RAM__ +#if CONFIG(HAVE_ROMSTAGE_MICROCODE_CBFS_SPINLOCK) + spin_unlock(romstage_microcode_cbfs_lock()); +#endif +#endif + return; + } + + amd_update_microcode(ucode, ucode_len, + equivalent_processor_rev_id); + +#ifdef __PRE_RAM__ +#if CONFIG(HAVE_ROMSTAGE_MICROCODE_CBFS_SPINLOCK) + spin_unlock(romstage_microcode_cbfs_lock()); +#endif +#endif + +} diff --git a/src/cpu/amd/pi/00730F01/model_16_init.c b/src/cpu/amd/pi/00730F01/model_16_init.c index fe828900fc..b0449a73b2 100644 --- a/src/cpu/amd/pi/00730F01/model_16_init.c +++ b/src/cpu/amd/pi/00730F01/model_16_init.c @@ -14,6 +14,7 @@ */ #include +#include #include #include #include @@ -98,6 +99,8 @@ static void model_16_init(struct device *dev) msr = rdmsr(HWCR_MSR); msr.lo |= (1 << 0); wrmsr(HWCR_MSR, msr); + + update_microcode(cpuid_eax(1)); } static struct device_operations cpu_dev_ops = { diff --git a/src/cpu/amd/pi/00730F01/update_microcode.c b/src/cpu/amd/pi/00730F01/update_microcode.c new file mode 100644 index 0000000000..6acf13a6ef --- /dev/null +++ b/src/cpu/amd/pi/00730F01/update_microcode.c @@ -0,0 +1,58 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2015 Timothy Pearson , Raptor Engineering + * Copyright (C) 2007 Advanced Micro Devices, Inc. + * Copyright (C) 2019 PC Engines 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 + +struct id_mapping { + uint32_t orig_id; + uint16_t new_id; +}; + +static u16 get_equivalent_processor_rev_id(u32 orig_id) +{ + static const struct id_mapping id_mapping_table[] = { + /* Family 16h */ + + /* TODO This equivalent processor revisions ID needs verification */ + { 0x730f01, 0x7301 }, + + /* Array terminator */ + { 0xffffff, 0x0000 }, + }; + + u32 new_id; + int i; + + new_id = 0; + + for (i = 0; id_mapping_table[i].orig_id != 0xffffff; i++) { + if (id_mapping_table[i].orig_id == orig_id) { + new_id = id_mapping_table[i].new_id; + break; + } + } + + return new_id; +} + +void update_microcode(u32 cpu_deviceid) +{ + u32 equivalent_processor_rev_id = + get_equivalent_processor_rev_id(cpu_deviceid); + amd_update_microcode_from_cbfs(equivalent_processor_rev_id); +} diff --git a/src/cpu/intel/car/romstage.c b/src/cpu/intel/car/romstage.c index a7daff4fb2..89052d6be6 100644 --- a/src/cpu/intel/car/romstage.c +++ b/src/cpu/intel/car/romstage.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include diff --git a/src/cpu/intel/common/fsb.c b/src/cpu/intel/common/fsb.c index 83220de3bc..d66e87a396 100644 --- a/src/cpu/intel/common/fsb.c +++ b/src/cpu/intel/common/fsb.c @@ -46,6 +46,7 @@ static int get_fsb(void) case 0x3a: /* IvyBridge BCLK fixed at 100MHz */ case 0x3c: /* Haswell BCLK fixed at 100MHz */ case 0x45: /* Haswell-ULT BCLK fixed at 100MHz */ + case 0x4d: /* Rangeley BCLK fixed at 100MHz */ ret = 100; break; } diff --git a/src/cpu/intel/haswell/Makefile.inc b/src/cpu/intel/haswell/Makefile.inc index f83d5db970..72f66ef7b8 100644 --- a/src/cpu/intel/haswell/Makefile.inc +++ b/src/cpu/intel/haswell/Makefile.inc @@ -17,6 +17,9 @@ smm-$(CONFIG_HAVE_SMI_HANDLER) += finalize.c smm-$(CONFIG_HAVE_SMI_HANDLER) += tsc_freq.c ifneq ($(CONFIG_TSC_MONOTONIC_TIMER),y) +bootblock-y += monotonic_timer.c +romstage-y += monotonic_timer.c +postcar-y += monotonic_timer.c ramstage-y += monotonic_timer.c smm-y += monotonic_timer.c endif @@ -25,6 +28,7 @@ bootblock-y += ../car/non-evict/cache_as_ram.S bootblock-y += ../car/bootblock.c bootblock-y += ../../x86/early_reset.S bootblock-y += bootblock.c +bootblock-y += tsc_freq.c postcar-y += ../car/non-evict/exit_car.S @@ -39,5 +43,5 @@ subdirs-y += ../microcode subdirs-y += ../turbo subdirs-y += ../common -cpu_microcode_bins += 3rdparty/blobs/cpu/intel/model_306cx/microcode.bin -cpu_microcode_bins += 3rdparty/blobs/cpu/intel/model_4065x/microcode.bin +cpu_microcode_bins += $(wildcard 3rdparty/intel-microcode/intel-ucode/06-3c-*) +cpu_microcode_bins += $(wildcard 3rdparty/intel-microcode/intel-ucode/06-45-*) diff --git a/src/cpu/intel/haswell/finalize.c b/src/cpu/intel/haswell/finalize.c index cc2d1a4c36..16e54d746a 100644 --- a/src/cpu/intel/haswell/finalize.c +++ b/src/cpu/intel/haswell/finalize.c @@ -15,7 +15,6 @@ */ #include -#include #include #include #include "haswell.h" diff --git a/src/cpu/intel/haswell/haswell.h b/src/cpu/intel/haswell/haswell.h index 3dfdd8d071..4ebbe183b7 100644 --- a/src/cpu/intel/haswell/haswell.h +++ b/src/cpu/intel/haswell/haswell.h @@ -34,7 +34,7 @@ /* Haswell bus clock is fixed at 100MHz */ #define HASWELL_BCLK 100 -#define CORE_THREAD_COUNT_MSR 0x35 +#define MSR_CORE_THREAD_COUNT 0x35 #define MSR_FEATURE_CONFIG 0x13c #define MSR_FLEX_RATIO 0x194 #define FLEX_RATIO_LOCK (1 << 20) diff --git a/src/cpu/intel/haswell/haswell_init.c b/src/cpu/intel/haswell/haswell_init.c index 25cf243aca..95d719c2f1 100644 --- a/src/cpu/intel/haswell/haswell_init.c +++ b/src/cpu/intel/haswell/haswell_init.c @@ -732,7 +732,7 @@ static int get_cpu_count(void) int num_threads; int num_cores; - msr = rdmsr(CORE_THREAD_COUNT_MSR); + msr = rdmsr(MSR_CORE_THREAD_COUNT); num_threads = (msr.lo >> 0) & 0xffff; num_cores = (msr.lo >> 16) & 0xffff; printk(BIOS_DEBUG, "CPU has %u cores, %u threads enabled.\n", diff --git a/src/cpu/intel/haswell/romstage.c b/src/cpu/intel/haswell/romstage.c index 0426bb4cea..3cbdf44c1d 100644 --- a/src/cpu/intel/haswell/romstage.c +++ b/src/cpu/intel/haswell/romstage.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include diff --git a/src/cpu/intel/model_1067x/Makefile.inc b/src/cpu/intel/model_1067x/Makefile.inc index 451df6ef35..caeab563a4 100644 --- a/src/cpu/intel/model_1067x/Makefile.inc +++ b/src/cpu/intel/model_1067x/Makefile.inc @@ -4,4 +4,4 @@ subdirs-y += ../../x86/name subdirs-y += ../common subdirs-$(CONFIG_SMM_TSEG) += ../smm/gen1 -cpu_microcode_bins += 3rdparty/blobs/cpu/intel/model_1067x/microcode.bin +cpu_microcode_bins += $(wildcard 3rdparty/intel-microcode/intel-ucode/06-17-*) diff --git a/src/cpu/intel/model_106cx/Makefile.inc b/src/cpu/intel/model_106cx/Makefile.inc index eec544d79a..a1f2d0d1f0 100644 --- a/src/cpu/intel/model_106cx/Makefile.inc +++ b/src/cpu/intel/model_106cx/Makefile.inc @@ -4,4 +4,4 @@ subdirs-y += ../common subdirs-$(CONFIG_SMM_TSEG) += ../smm/gen1 ramstage-$(CONFIG_PARALLEL_MP) += ../model_1067x/mp_init.c -cpu_microcode_bins += 3rdparty/blobs/cpu/intel/model_106cx/microcode.bin +cpu_microcode_bins += $(wildcard 3rdparty/intel-microcode/intel-ucode/06-1c-*) diff --git a/src/cpu/intel/model_2065x/Makefile.inc b/src/cpu/intel/model_2065x/Makefile.inc index 39246c0708..f494e9b049 100644 --- a/src/cpu/intel/model_2065x/Makefile.inc +++ b/src/cpu/intel/model_2065x/Makefile.inc @@ -23,7 +23,7 @@ romstage-y += stage_cache.c ramstage-y += stage_cache.c postcar-y += stage_cache.c -cpu_microcode_bins += 3rdparty/blobs/cpu/intel/model_2065x/microcode.bin +cpu_microcode_bins += $(wildcard 3rdparty/intel-microcode/intel-ucode/06-25-*) cpu_incs-y += $(src)/cpu/intel/car/non-evict/cache_as_ram.S postcar-y += ../car/non-evict/exit_car.S diff --git a/src/cpu/intel/model_2065x/finalize.c b/src/cpu/intel/model_2065x/finalize.c index 5b85601182..724e09ca20 100644 --- a/src/cpu/intel/model_2065x/finalize.c +++ b/src/cpu/intel/model_2065x/finalize.c @@ -15,7 +15,6 @@ */ #include -#include #include #include #include diff --git a/src/cpu/intel/model_2065x/model_2065x.h b/src/cpu/intel/model_2065x/model_2065x.h index e7ba2a771b..eab2dd5c50 100644 --- a/src/cpu/intel/model_2065x/model_2065x.h +++ b/src/cpu/intel/model_2065x/model_2065x.h @@ -20,7 +20,7 @@ /* Nehalem bus clock is fixed at 133MHz */ #define NEHALEM_BCLK 133 -#define CORE_THREAD_COUNT_MSR 0x35 +#define MSR_CORE_THREAD_COUNT 0x35 #define MSR_FEATURE_CONFIG 0x13c #define MSR_FLEX_RATIO 0x194 #define FLEX_RATIO_LOCK (1 << 20) diff --git a/src/cpu/intel/model_2065x/model_2065x_init.c b/src/cpu/intel/model_2065x/model_2065x_init.c index d8de7c055f..289d4471e6 100644 --- a/src/cpu/intel/model_2065x/model_2065x_init.c +++ b/src/cpu/intel/model_2065x/model_2065x_init.c @@ -287,7 +287,7 @@ static int get_cpu_count(void) int num_threads; int num_cores; - msr = rdmsr(CORE_THREAD_COUNT_MSR); + msr = rdmsr(MSR_CORE_THREAD_COUNT); num_threads = (msr.lo >> 0) & 0xffff; num_cores = (msr.lo >> 16) & 0xffff; printk(BIOS_DEBUG, "CPU has %u cores, %u threads enabled.\n", diff --git a/src/cpu/intel/model_206ax/Makefile.inc b/src/cpu/intel/model_206ax/Makefile.inc index e1fa87989c..78a6283a5d 100644 --- a/src/cpu/intel/model_206ax/Makefile.inc +++ b/src/cpu/intel/model_206ax/Makefile.inc @@ -28,8 +28,8 @@ 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 += 3rdparty/blobs/cpu/intel/model_206ax/microcode.bin -cpu_microcode_bins += 3rdparty/blobs/cpu/intel/model_306ax/microcode.bin +cpu_microcode_bins += $(wildcard 3rdparty/intel-microcode/intel-ucode/06-2a-*) +cpu_microcode_bins += $(wildcard 3rdparty/intel-microcode/intel-ucode/06-3a-*) cpu_incs-y += $(src)/cpu/intel/car/non-evict/cache_as_ram.S postcar-y += ../car/non-evict/exit_car.S diff --git a/src/cpu/intel/model_206ax/finalize.c b/src/cpu/intel/model_206ax/finalize.c index 30b00bbaf1..98ce5552da 100644 --- a/src/cpu/intel/model_206ax/finalize.c +++ b/src/cpu/intel/model_206ax/finalize.c @@ -15,7 +15,6 @@ */ #include -#include #include #include #include diff --git a/src/cpu/intel/model_206ax/model_206ax.h b/src/cpu/intel/model_206ax/model_206ax.h index f4c5d9323a..c0d2434fe6 100644 --- a/src/cpu/intel/model_206ax/model_206ax.h +++ b/src/cpu/intel/model_206ax/model_206ax.h @@ -22,7 +22,7 @@ /* SandyBridge/IvyBridge bus clock is fixed at 100MHz */ #define SANDYBRIDGE_BCLK 100 -#define CORE_THREAD_COUNT_MSR 0x35 +#define MSR_CORE_THREAD_COUNT 0x35 #define MSR_FEATURE_CONFIG 0x13c #define MSR_FLEX_RATIO 0x194 #define FLEX_RATIO_LOCK (1 << 20) diff --git a/src/cpu/intel/model_206ax/model_206ax_init.c b/src/cpu/intel/model_206ax/model_206ax_init.c index 524e49c5c6..80d85f3347 100644 --- a/src/cpu/intel/model_206ax/model_206ax_init.c +++ b/src/cpu/intel/model_206ax/model_206ax_init.c @@ -513,7 +513,7 @@ static int get_cpu_count(void) int num_threads; int num_cores; - msr = rdmsr(CORE_THREAD_COUNT_MSR); + msr = rdmsr(MSR_CORE_THREAD_COUNT); num_threads = (msr.lo >> 0) & 0xffff; num_cores = (msr.lo >> 16) & 0xffff; printk(BIOS_DEBUG, "CPU has %u cores, %u threads enabled.\n", diff --git a/src/cpu/intel/model_65x/Makefile.inc b/src/cpu/intel/model_65x/Makefile.inc index 05ea68e126..c1f471c33a 100644 --- a/src/cpu/intel/model_65x/Makefile.inc +++ b/src/cpu/intel/model_65x/Makefile.inc @@ -16,4 +16,4 @@ ramstage-y += model_65x_init.c -cpu_microcode_bins += 3rdparty/blobs/cpu/intel/model_65x/microcode.bin +cpu_microcode_bins += $(wildcard 3rdparty/intel-microcode/intel-ucode/06-05-*) diff --git a/src/cpu/intel/model_67x/Makefile.inc b/src/cpu/intel/model_67x/Makefile.inc index 219a0d24ee..ef68df4346 100644 --- a/src/cpu/intel/model_67x/Makefile.inc +++ b/src/cpu/intel/model_67x/Makefile.inc @@ -16,4 +16,4 @@ ramstage-y += model_67x_init.c -cpu_microcode_bins += 3rdparty/blobs/cpu/intel/model_67x/microcode.bin +cpu_microcode_bins += $(wildcard 3rdparty/intel-microcode/intel-ucode/06-07-*) diff --git a/src/cpu/intel/model_68x/Makefile.inc b/src/cpu/intel/model_68x/Makefile.inc index 7e09dc6b86..95aacb3fa6 100644 --- a/src/cpu/intel/model_68x/Makefile.inc +++ b/src/cpu/intel/model_68x/Makefile.inc @@ -17,4 +17,4 @@ ramstage-y += model_68x_init.c subdirs-y += ../../x86/name -cpu_microcode_bins += 3rdparty/blobs/cpu/intel/model_68x/microcode.bin +cpu_microcode_bins += $(wildcard 3rdparty/intel-microcode/intel-ucode/06-08-*) diff --git a/src/cpu/intel/model_6bx/Makefile.inc b/src/cpu/intel/model_6bx/Makefile.inc index 81e64e3292..84f4ff02db 100644 --- a/src/cpu/intel/model_6bx/Makefile.inc +++ b/src/cpu/intel/model_6bx/Makefile.inc @@ -1,4 +1,4 @@ ramstage-y += model_6bx_init.c subdirs-y += ../../x86/name -cpu_microcode_bins += 3rdparty/blobs/cpu/intel/model_6bx/microcode.bin +cpu_microcode_bins += $(wildcard 3rdparty/intel-microcode/intel-ucode/06-0b-*) diff --git a/src/cpu/intel/model_6ex/Makefile.inc b/src/cpu/intel/model_6ex/Makefile.inc index 46ae7c7be2..cef2b0be86 100644 --- a/src/cpu/intel/model_6ex/Makefile.inc +++ b/src/cpu/intel/model_6ex/Makefile.inc @@ -4,4 +4,4 @@ subdirs-y += ../common subdirs-$(CONFIG_SMM_TSEG) += ../smm/gen1 ramstage-y += ../model_1067x/mp_init.c -cpu_microcode_bins += 3rdparty/blobs/cpu/intel/model_6ex/microcode.bin +cpu_microcode_bins += $(wildcard 3rdparty/intel-microcode/intel-ucode/06-0e-*) diff --git a/src/cpu/intel/model_6fx/Makefile.inc b/src/cpu/intel/model_6fx/Makefile.inc index 9564bf950e..9121e3b64a 100644 --- a/src/cpu/intel/model_6fx/Makefile.inc +++ b/src/cpu/intel/model_6fx/Makefile.inc @@ -4,4 +4,4 @@ subdirs-y += ../common ramstage-$(CONFIG_PARALLEL_MP) += ../model_1067x/mp_init.c subdirs-$(CONFIG_SMM_TSEG) += ../smm/gen1 -cpu_microcode_bins += 3rdparty/blobs/cpu/intel/model_6fx/microcode.bin +cpu_microcode_bins += $(wildcard 3rdparty/intel-microcode/intel-ucode/06-0f-*) diff --git a/src/cpu/intel/model_6xx/Makefile.inc b/src/cpu/intel/model_6xx/Makefile.inc index 3ac510fa44..b2f87abfbf 100644 --- a/src/cpu/intel/model_6xx/Makefile.inc +++ b/src/cpu/intel/model_6xx/Makefile.inc @@ -1,3 +1,3 @@ ramstage-y += model_6xx_init.c -cpu_microcode_bins += 3rdparty/blobs/cpu/intel/model_66x/microcode.bin +cpu_microcode_bins += $(wildcard 3rdparty/intel-microcode/intel-ucode/06-06-*) diff --git a/src/cpu/intel/model_f2x/Makefile.inc b/src/cpu/intel/model_f2x/Makefile.inc index 589e49e4b5..9bb5dca626 100644 --- a/src/cpu/intel/model_f2x/Makefile.inc +++ b/src/cpu/intel/model_f2x/Makefile.inc @@ -1,3 +1,3 @@ ramstage-y += model_f2x_init.c -cpu_microcode_bins += 3rdparty/blobs/cpu/intel/model_f2x/microcode.bin +cpu_microcode_bins += $(wildcard 3rdparty/intel-microcode/intel-ucode/0f-02-*) diff --git a/src/cpu/intel/model_f3x/Makefile.inc b/src/cpu/intel/model_f3x/Makefile.inc index 19b2e9302b..ed1eb5f7d8 100644 --- a/src/cpu/intel/model_f3x/Makefile.inc +++ b/src/cpu/intel/model_f3x/Makefile.inc @@ -2,4 +2,4 @@ ramstage-y += model_f3x_init.c subdirs-$(CONFIG_SMM_TSEG) += ../smm/gen1 ramstage-$(CONFIG_PARALLEL_MP) += ../model_1067x/mp_init.c -cpu_microcode_bins += 3rdparty/blobs/cpu/intel/model_f3x/microcode.bin +cpu_microcode_bins += $(wildcard 3rdparty/intel-microcode/intel-ucode/0f-03-*) diff --git a/src/cpu/intel/model_f4x/Makefile.inc b/src/cpu/intel/model_f4x/Makefile.inc index 6fbc9ae2ae..196d63e462 100644 --- a/src/cpu/intel/model_f4x/Makefile.inc +++ b/src/cpu/intel/model_f4x/Makefile.inc @@ -2,4 +2,4 @@ ramstage-y += model_f4x_init.c subdirs-$(CONFIG_SMM_TSEG) += ../smm/gen1 ramstage-$(CONFIG_PARALLEL_MP) += ../model_1067x/mp_init.c -cpu_microcode_bins += 3rdparty/blobs/cpu/intel/model_f4x/microcode.bin +cpu_microcode_bins += $(wildcard 3rdparty/intel-microcode/intel-ucode/0f-04-*) diff --git a/src/cpu/intel/smm/gen1/smmrelocate.c b/src/cpu/intel/smm/gen1/smmrelocate.c index f3192bcd55..d52043f047 100644 --- a/src/cpu/intel/smm/gen1/smmrelocate.c +++ b/src/cpu/intel/smm/gen1/smmrelocate.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include diff --git a/src/cpu/ti/am335x/gpio.c b/src/cpu/ti/am335x/gpio.c index 2685839b23..8660f2ca91 100644 --- a/src/cpu/ti/am335x/gpio.c +++ b/src/cpu/ti/am335x/gpio.c @@ -16,7 +16,6 @@ #include #include #include -#include static struct am335x_gpio_regs *gpio_regs_and_bit(unsigned int gpio, uint32_t *bit) diff --git a/src/cpu/ti/am335x/uart.c b/src/cpu/ti/am335x/uart.c index c482a85d74..4e9d012037 100644 --- a/src/cpu/ti/am335x/uart.c +++ b/src/cpu/ti/am335x/uart.c @@ -12,7 +12,6 @@ * GNU General Public License for more details. */ -#include #include #include #include diff --git a/src/cpu/x86/mirror_payload.c b/src/cpu/x86/mirror_payload.c index 5f0493a510..88c5e8183f 100644 --- a/src/cpu/x86/mirror_payload.c +++ b/src/cpu/x86/mirror_payload.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -42,7 +43,7 @@ void mirror_payload(struct prog *payload) alignment_diff = (intra_cacheline_mask & (uintptr_t)src); size += alignment_diff; - size = ALIGN(size, cacheline_size); + size = ALIGN_UP(size, cacheline_size); printk(BIOS_DEBUG, "Payload aligned size: 0x%zx\n", size); diff --git a/src/cpu/x86/mp_init.c b/src/cpu/x86/mp_init.c index b7b8fe2afa..9528149627 100644 --- a/src/cpu/x86/mp_init.c +++ b/src/cpu/x86/mp_init.c @@ -321,7 +321,7 @@ static atomic_t *load_sipi_vector(struct mp_params *mp_params) module_size = rmodule_memory_size(&sipi_mod); /* Align to 4 bytes. */ - module_size = ALIGN(module_size, 4); + module_size = ALIGN_UP(module_size, 4); if (module_size > loc_size) { printk(BIOS_CRIT, "SIPI module size (%d) > region size (%d).\n", diff --git a/src/cpu/x86/mtrr/mtrr.c b/src/cpu/x86/mtrr/mtrr.c index 60eee319ce..98449d5542 100644 --- a/src/cpu/x86/mtrr/mtrr.c +++ b/src/cpu/x86/mtrr/mtrr.c @@ -22,9 +22,9 @@ */ #include -#include #include #include +#include #include #include #include diff --git a/src/cpu/x86/smm/Makefile.inc b/src/cpu/x86/smm/Makefile.inc index 32f5ea713d..e6add1d0d0 100644 --- a/src/cpu/x86/smm/Makefile.inc +++ b/src/cpu/x86/smm/Makefile.inc @@ -47,8 +47,8 @@ ramstage-srcs += $(obj)/cpu/x86/smm/smmstub.manual # SMM Stub Module. The stub is used as a trampoline for relocation and normal # SMM handling. -$(obj)/smmstub/smmstub.o: $$(smmstub-objs) - $(CC_smmstub) $(CFLAGS_smmstub) -nostdlib -r -o $@ $^ +$(obj)/smmstub/smmstub.o: $$(smmstub-objs) $(COMPILER_RT_smmstub) + $(LD_smmstub) -nostdlib -r -o $@ $(COMPILER_RT_FLAGS_smmstub) --whole-archive --start-group $(smmstub-objs) --no-whole-archive $(COMPILER_RT_smmstub) --end-group # Link the SMM stub module with a 0-byte heap. ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y) diff --git a/src/cpu/x86/smm/smm_module_loader.c b/src/cpu/x86/smm/smm_module_loader.c index 80b2c27c79..b3ffb3d318 100644 --- a/src/cpu/x86/smm/smm_module_loader.c +++ b/src/cpu/x86/smm/smm_module_loader.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #define FXSAVE_SIZE 512 diff --git a/src/device/cpu_device.c b/src/device/cpu_device.c index b07b555b52..f59cce3573 100644 --- a/src/device/cpu_device.c +++ b/src/device/cpu_device.c @@ -17,7 +17,7 @@ #include #include -struct device *add_cpu_device(struct bus *cpu_bus, unsigned apic_id, +struct device *add_cpu_device(struct bus *cpu_bus, unsigned int apic_id, int enabled) { struct device_path cpu_path; @@ -42,8 +42,9 @@ struct device *add_cpu_device(struct bus *cpu_bus, unsigned apic_id, return cpu; } -void set_cpu_topology(struct device *cpu, unsigned node, unsigned package, - unsigned core, unsigned thread) +void set_cpu_topology(struct device *cpu, unsigned int node, + unsigned int package, unsigned int core, + unsigned int thread) { cpu->path.apic.node_id = node; cpu->path.apic.package_id = package; diff --git a/src/device/device_util.c b/src/device/device_util.c index 47df3052e2..11954a1982 100644 --- a/src/device/device_util.c +++ b/src/device/device_util.c @@ -654,6 +654,53 @@ bool dev_is_active_bridge(struct device *dev) return 0; } +/** + * Ensure the device has a minimum number of bus links. + * + * @param dev The device to add links to. + * @param total_links The minimum number of links to have. + */ +void add_more_links(struct device *dev, unsigned int total_links) +{ + struct bus *link, *last = NULL; + int link_num = -1; + + for (link = dev->link_list; link; link = link->next) { + if (link_num < link->link_num) + link_num = link->link_num; + last = link; + } + + if (last) { + int links = total_links - (link_num + 1); + if (links > 0) { + link = malloc(links * sizeof(*link)); + if (!link) + die("Couldn't allocate more links!\n"); + memset(link, 0, links * sizeof(*link)); + last->next = link; + } else { + /* No more links to add */ + return; + } + } else { + link = malloc(total_links * sizeof(*link)); + if (!link) + die("Couldn't allocate more links!\n"); + memset(link, 0, total_links * sizeof(*link)); + dev->link_list = link; + } + + for (link_num = link_num + 1; link_num < total_links; link_num++) { + link->link_num = link_num; + link->dev = dev; + link->next = link + 1; + last = link; + link = link->next; + } + last->next = NULL; +} + static void resource_tree(const struct device *root, int debug_level, int depth) { int i = 0; diff --git a/src/device/dram/ddr3.c b/src/device/dram/ddr3.c index 3272dac6d7..834dc83db6 100644 --- a/src/device/dram/ddr3.c +++ b/src/device/dram/ddr3.c @@ -382,8 +382,7 @@ int spd_decode_ddr3(dimm_attr * dimm, spd_raw_data spd) dimm->flags.therm_sensor ? "yes" : "no"); /* SDRAM Device Type */ - reg8 = spd[33]; - printram(" Standard SDRAM : %s\n", (reg8 & 0x80) ? "no" : "yes"); + printram(" Standard SDRAM : %s\n", (spd[33] & 0x80) ? "no" : "yes"); if (spd[63] & 0x01) { dimm->flags.pins_mirrored = 1; diff --git a/src/device/pci_rom.c b/src/device/pci_rom.c index 2dbfb51b5f..3160c2041b 100644 --- a/src/device/pci_rom.c +++ b/src/device/pci_rom.c @@ -257,7 +257,7 @@ pci_rom_write_acpi_tables(struct device *device, unsigned long current, /* AMD/ATI uses VFCT */ if (device->vendor == PCI_VENDOR_ID_ATI) { - current = ALIGN(current, 8); + current = ALIGN_UP(current, 8); printk(BIOS_DEBUG, "ACPI: * VFCT at %lx\n", current); vfct = (struct acpi_vfct *)current; acpi_create_vfct(device, vfct, pci_rom_acpi_fill_vfct); diff --git a/src/drivers/amd/agesa/mtrr_fixme.c b/src/drivers/amd/agesa/mtrr_fixme.c index 1fbb55318d..fcb353c601 100644 --- a/src/drivers/amd/agesa/mtrr_fixme.c +++ b/src/drivers/amd/agesa/mtrr_fixme.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include diff --git a/src/drivers/amd/agesa/state_machine.c b/src/drivers/amd/agesa/state_machine.c index c8529c5e04..750d192325 100644 --- a/src/drivers/amd/agesa/state_machine.c +++ b/src/drivers/amd/agesa/state_machine.c @@ -272,7 +272,7 @@ int agesa_execute_state(struct sysinfo *cb, AGESA_STRUCT_NAME func) /* Must call the function buffer was allocated for.*/ AMD_CONFIG_PARAMS *StdHeader = aip.NewStructPtr; - ASSERT(StdHeader->Func == func); + ASSERT(StdHeader != NULL && StdHeader->Func == func); if (CONFIG(AGESA_EXTRA_TIMESTAMPS) && task.ts_entry_id) timestamp_add_now(task.ts_entry_id); diff --git a/src/drivers/elog/elog.c b/src/drivers/elog/elog.c index e41b55bba5..9ac2d3c095 100644 --- a/src/drivers/elog/elog.c +++ b/src/drivers/elog/elog.c @@ -859,7 +859,7 @@ int elog_init(void) " shrink size %d\n", region_device_sz(&es->nv_dev), es->full_threshold, es->shrink_size); - if (ENV_RAMSTAGE) + if (ENV_PAYLOAD_LOADER) elog_add_boot_count(); return 0; } diff --git a/src/drivers/i2c/sx9310/sx9310.c b/src/drivers/i2c/sx9310/sx9310.c index aafd7c7cc8..8157874d07 100644 --- a/src/drivers/i2c/sx9310/sx9310.c +++ b/src/drivers/i2c/sx9310/sx9310.c @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -74,6 +75,9 @@ static void i2c_sx9310_fill_ssdt(struct device *dev) acpigen_pop_len(); /* Device */ acpigen_pop_len(); /* Scope */ + + printk(BIOS_INFO, "%s: %s at %s\n", acpi_device_path(dev), + config->desc ? : dev->chip_ops->name, dev_path(dev)); } #undef REGISTER diff --git a/src/drivers/intel/fsp1_0/Kconfig b/src/drivers/intel/fsp1_0/Kconfig index 361dd5ea85..d72d331a96 100644 --- a/src/drivers/intel/fsp1_0/Kconfig +++ b/src/drivers/intel/fsp1_0/Kconfig @@ -88,10 +88,11 @@ config ENABLE_MRC_CACHE config MRC_CACHE_FMAP bool "Use MRC Cache in FMAP" depends on ENABLE_MRC_CACHE + select CACHE_MRC_SETTINGS default n help Use the region "RW_MRC_CACHE" in FMAP instead of "mrc.cache" in CBFS. - You must define a region in your FMAP named "RW_MRC_CACHE". + Your FMAP must contain a region named "RW_MRC_CACHE". config MRC_CACHE_SIZE hex "Fast Boot Data Cache Size" diff --git a/src/drivers/intel/fsp1_0/fastboot_cache.c b/src/drivers/intel/fsp1_0/fastboot_cache.c index 088c292e8d..34761a05be 100644 --- a/src/drivers/intel/fsp1_0/fastboot_cache.c +++ b/src/drivers/intel/fsp1_0/fastboot_cache.c @@ -65,13 +65,12 @@ static u32 get_mrc_cache_region(struct mrc_data_container **mrc_region_ptr) } *mrc_region_ptr = NULL; return 0; - } else { - *mrc_region_ptr = cbfs_boot_map_with_leak("mrc.cache", - CBFS_TYPE_MRC_CACHE, - ®ion_size); - - return region_size; } + *mrc_region_ptr = cbfs_boot_map_with_leak("mrc.cache", + CBFS_TYPE_MRC_CACHE, + ®ion_size); + + return region_size; } /* diff --git a/src/drivers/intel/fsp1_0/fsp_util.c b/src/drivers/intel/fsp1_0/fsp_util.c index 4e50abae4e..d787c7beca 100644 --- a/src/drivers/intel/fsp1_0/fsp_util.c +++ b/src/drivers/intel/fsp1_0/fsp_util.c @@ -275,7 +275,7 @@ int save_mrc_data(void *hob_start) printk(BIOS_DEBUG, "Memory Configure Data Hob at %p (size = 0x%x).\n", (void *)mrc_hob_data, mrc_hob_size); - output_len = ALIGN(mrc_hob_size, 16); + output_len = ALIGN_UP(mrc_hob_size, 16); /* Save the MRC S3/fast boot/ADR restore data to cbmem */ mrc_data = cbmem_add (CBMEM_ID_MRCDATA, diff --git a/src/drivers/intel/fsp1_1/car.c b/src/drivers/intel/fsp1_1/car.c index 67ed099695..bd3f4787a0 100644 --- a/src/drivers/intel/fsp1_1/car.c +++ b/src/drivers/intel/fsp1_1/car.c @@ -15,6 +15,7 @@ #include #include +#include #include #include #include diff --git a/src/drivers/intel/fsp1_1/fsp_util.c b/src/drivers/intel/fsp1_1/fsp_util.c index 2702b5a6eb..ab9f28f93f 100644 --- a/src/drivers/intel/fsp1_1/fsp_util.c +++ b/src/drivers/intel/fsp1_1/fsp_util.c @@ -16,6 +16,7 @@ #include #include +#include #include #include #include diff --git a/src/drivers/intel/fsp1_1/raminit.c b/src/drivers/intel/fsp1_1/raminit.c index eff011aa62..7c20b258e2 100644 --- a/src/drivers/intel/fsp1_1/raminit.c +++ b/src/drivers/intel/fsp1_1/raminit.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -297,7 +298,7 @@ void raminit(struct romstage_params *params) else if (!vboot_recovery_mode_enabled()) { /* Do not save MRC data in recovery path */ params->data_to_save = GET_GUID_HOB_DATA(mrc_hob); - params->data_to_save_size = ALIGN( + params->data_to_save_size = ALIGN_UP( ((u32)GET_HOB_LENGTH(mrc_hob)), 16); } } diff --git a/src/drivers/ipmi/Makefile.inc b/src/drivers/ipmi/Makefile.inc index e9e7ff3bca..a29c2e2d0e 100644 --- a/src/drivers/ipmi/Makefile.inc +++ b/src/drivers/ipmi/Makefile.inc @@ -1 +1,2 @@ ramstage-$(CONFIG_IPMI_KCS) += ipmi_kcs.c +ramstage-$(CONFIG_IPMI_KCS) += ipmi_kcs_ops.c diff --git a/src/drivers/ipmi/chip.h b/src/drivers/ipmi/chip.h new file mode 100644 index 0000000000..eb8b4e6d34 --- /dev/null +++ b/src/drivers/ipmi/chip.h @@ -0,0 +1,29 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2017 Patrick Rudolph + * + * 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 _IMPI_CHIP_H_ +#define _IPMI_CHIP_H_ + +struct drivers_ipmi_config { + u8 bmc_i2c_address; + u8 have_nv_storage; + u8 nv_storage_device_address; + u8 have_gpe; + u8 gpe_interrupt; + u8 have_apic; + u32 apic_interrupt; +}; + +#endif /* _IMPI_CHIP_H_ */ diff --git a/src/drivers/ipmi/ipmi_kcs.c b/src/drivers/ipmi/ipmi_kcs.c index 8d106837f9..397a800df3 100644 --- a/src/drivers/ipmi/ipmi_kcs.c +++ b/src/drivers/ipmi/ipmi_kcs.c @@ -22,7 +22,7 @@ #define IPMI_KCS_STATE(_x) ((_x) >> 6) -#define IPMI_KCS_GET_STATUS_ABORT +#define IPMI_KCS_GET_STATUS_ABORT 0x60 #define IPMI_KCS_START_WRITE 0x61 #define IPMI_KCS_END_WRITE 0x62 #define IPMI_KCS_READ_BYTE 0x68 @@ -43,7 +43,7 @@ static unsigned char ipmi_kcs_status(int port) { unsigned char status = inb(IPMI_STAT(port)); - printk(BIOS_DEBUG, "%s: 0x%02x\n", __func__, status); + printk(BIOS_SPEW, "%s: 0x%02x\n", __func__, status); return status; } @@ -77,7 +77,7 @@ static int ipmi_kcs_send_data_byte(int port, const unsigned char byte) { unsigned char status; - printk(BIOS_DEBUG, "%s: %02x\n", __func__, byte); + printk(BIOS_SPEW, "%s: 0x%02x\n", __func__, byte); outb(byte, IPMI_DATA(port)); @@ -100,7 +100,7 @@ static int ipmi_kcs_send_last_data_byte(int port, const unsigned char byte) { unsigned char status; - printk(BIOS_DEBUG, "%s: %02x\n", __func__, byte); + printk(BIOS_SPEW, "%s: 0x%02x\n", __func__, byte); if (wait_ibf_timeout(port)) return 1; @@ -121,7 +121,7 @@ static int ipmi_kcs_send_last_data_byte(int port, const unsigned char byte) static int ipmi_kcs_send_cmd_byte(int port, const unsigned char byte) { - printk(BIOS_DEBUG, "%s: 0x%02x\n", __func__, byte); + printk(BIOS_SPEW, "%s: 0x%02x\n", __func__, byte); if (wait_ibf_timeout(port)) return 1; @@ -144,37 +144,59 @@ static int ipmi_kcs_send_message(int port, int netfn, int lun, int cmd, { int ret; - if ((ret = ipmi_kcs_send_cmd_byte(port, IPMI_KCS_START_WRITE))) { + ret = ipmi_kcs_send_cmd_byte(port, IPMI_KCS_START_WRITE); + if (ret) { printk(BIOS_ERR, "IPMI START WRITE failed\n"); return ret; } - if ((ret = ipmi_kcs_send_data_byte(port, (netfn << 2) | (lun & 3)))) { + ret = ipmi_kcs_send_data_byte(port, (netfn << 2) | (lun & 3)); + if (ret) { printk(BIOS_ERR, "IPMI NETFN failed\n"); return ret; } - if ((ret = ipmi_kcs_send_data_byte(port, cmd))) { - printk(BIOS_ERR, "IPMI CMD failed\n"); - return ret; - } + if (!len) { + ret = ipmi_kcs_send_cmd_byte(port, IPMI_KCS_END_WRITE); + if (ret) { + printk(BIOS_ERR, "IPMI END WRITE failed\n"); + return ret; + } - while (len-- > 1) { - if ((ret = ipmi_kcs_send_data_byte(port, *msg++))) { + ret = ipmi_kcs_send_last_data_byte(port, cmd); + if (ret) { + printk(BIOS_ERR, "IPMI BYTE WRITE failed\n"); + return ret; + } + } else { + ret = ipmi_kcs_send_data_byte(port, cmd); + if (ret) { + printk(BIOS_ERR, "IPMI CMD failed\n"); + return ret; + } + + while (len > 1) { + ret = ipmi_kcs_send_data_byte(port, *msg++); + if (ret) { + printk(BIOS_ERR, "IPMI BYTE WRITE failed\n"); + return ret; + } + len--; + } + + ret = ipmi_kcs_send_cmd_byte(port, IPMI_KCS_END_WRITE); + if (ret) { + printk(BIOS_ERR, "IPMI END WRITE failed\n"); + return ret; + } + + ret = ipmi_kcs_send_last_data_byte(port, *msg); + if (ret) { printk(BIOS_ERR, "IPMI BYTE WRITE failed\n"); return ret; } } - if ((ret = ipmi_kcs_send_cmd_byte(port, IPMI_KCS_END_WRITE))) { - printk(BIOS_ERR, "IPMI END WRITE failed\n"); - return ret; - } - - if ((ret = ipmi_kcs_send_last_data_byte(port, *msg++))) { - printk(BIOS_ERR, "IPMI BYTE WRITE failed\n"); - return ret; - } return 0; } @@ -182,9 +204,6 @@ static int ipmi_kcs_read_message(int port, unsigned char *msg, int len) { int status, ret = 0; - if (!msg) - return 0; - if (wait_ibf_timeout(port)) return 1; @@ -195,15 +214,18 @@ static int ipmi_kcs_read_message(int port, unsigned char *msg, int len) return ret; if (IPMI_KCS_STATE(status) != IPMI_KCS_STATE_READ) { - printk(BIOS_ERR, "%s: wrong state: 0x%02x\n", __func__, status); + printk(BIOS_ERR, "%s: wrong state: 0x%02x\n", __func__, + status); return -1; } if (wait_obf_timeout(port)) return -1; - *msg++ = inb(IPMI_DATA(port)); - ret++; + if (msg && (ret < len)) { + *msg++ = inb(IPMI_DATA(port)); + ret++; + } if (wait_ibf_timeout(port)) return -1; diff --git a/src/drivers/ipmi/ipmi_kcs.h b/src/drivers/ipmi/ipmi_kcs.h index 3cd7609039..a194dd22e9 100644 --- a/src/drivers/ipmi/ipmi_kcs.h +++ b/src/drivers/ipmi/ipmi_kcs.h @@ -20,6 +20,10 @@ #define IPMI_NETFN_BRIDGE 0x02 #define IPMI_NETFN_SENSOREVENT 0x04 #define IPMI_NETFN_APPLICATION 0x06 +#define IPMI_BMC_GET_DEVICE_ID 0x01 +#define IPMI_IPMI_VERSION_MINOR(x) ((x) >> 4) +#define IPMI_IPMI_VERSION_MAJOR(x) ((x) & 0xf) + #define IPMI_NETFN_FIRMWARE 0x08 #define IPMI_NETFN_STORAGE 0x0a #define IPMI_NETFN_TRANSPORT 0x0c @@ -29,4 +33,24 @@ extern int ipmi_kcs_message(int port, int netfn, int lun, int cmd, const unsigned char *inmsg, int inlen, unsigned char *outmsg, int outlen); + +struct ipmi_rsp { + uint8_t lun; + uint8_t cmd; + uint8_t completion_code; +} __packed; + +/* Get Device ID */ +struct ipmi_devid_rsp { + struct ipmi_rsp resp; + uint8_t device_id; + uint8_t device_revision; + uint8_t fw_rev1; + uint8_t fw_rev2; + uint8_t ipmi_version; + uint8_t additional_device_support; + uint8_t manufacturer_id[3]; + uint8_t product_id[2]; +} __packed; + #endif diff --git a/src/drivers/ipmi/ipmi_kcs_ops.c b/src/drivers/ipmi/ipmi_kcs_ops.c new file mode 100644 index 0000000000..0cc4e0a965 --- /dev/null +++ b/src/drivers/ipmi/ipmi_kcs_ops.c @@ -0,0 +1,267 @@ +/* + * 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. + * + * Place in devicetree.cb: + * + * chip drivers/ipmi + * device pnp ca2.0 on end # IPMI KCS + * end + */ + +#include +#include +#include +#if CONFIG(HAVE_ACPI_TABLES) +#include +#include +#endif +#if CONFIG(GENERATE_SMBIOS_TABLES) +#include +#endif +#include +#include +#include "ipmi_kcs.h" +#include "chip.h" + +/* 4 bit encoding */ +static u8 ipmi_revision_major = 0x1; +static u8 ipmi_revision_minor = 0x0; + +static int ipmi_get_device_id(struct device *dev, struct ipmi_devid_rsp *rsp) +{ + int ret; + + ret = ipmi_kcs_message(dev->path.pnp.port, IPMI_NETFN_APPLICATION, 0, + IPMI_BMC_GET_DEVICE_ID, NULL, 0, (u8 *)rsp, + sizeof(*rsp)); + if (ret < sizeof(struct ipmi_rsp) || rsp->resp.completion_code) { + printk(BIOS_ERR, "IPMI: %s command failed (ret=%d resp=0x%x)\n", + __func__, ret, rsp->resp.completion_code); + return 1; + } + if (ret != sizeof(*rsp)) { + printk(BIOS_ERR, "IPMI: %s response truncated\n", __func__); + return 1; + } + return 0; +} + +static void ipmi_kcs_init(struct device *dev) +{ + struct ipmi_devid_rsp rsp; + uint32_t man_id = 0, prod_id = 0; + + if (!dev->enabled) + return; + + /* Get IPMI version for ACPI and SMBIOS */ + if (!ipmi_get_device_id(dev, &rsp)) { + ipmi_revision_minor = IPMI_IPMI_VERSION_MINOR(rsp.ipmi_version); + ipmi_revision_major = IPMI_IPMI_VERSION_MAJOR(rsp.ipmi_version); + + memcpy(&man_id, rsp.manufacturer_id, + sizeof(rsp.manufacturer_id)); + + memcpy(&prod_id, rsp.product_id, sizeof(rsp.product_id)); + + printk(BIOS_INFO, "IPMI: Found man_id 0x%06x, prod_id 0x%04x\n", + man_id, prod_id); + + printk(BIOS_INFO, "IPMI: Version %01x.%01x\n", + ipmi_revision_major, ipmi_revision_minor); + } else { + /* Don't write tables if communication failed */ + dev->enabled = 0; + } +} + +#if CONFIG(HAVE_ACPI_TABLES) +static uint32_t uid_cnt = 0; + +static unsigned long +ipmi_write_acpi_tables(struct device *dev, unsigned long current, + struct acpi_rsdp *rsdp) +{ + struct drivers_ipmi_config *conf = NULL; + struct acpi_spmi *spmi; + s8 gpe_interrupt = -1; + u32 apic_interrupt = 0; + acpi_addr_t addr = { + .space_id = ACPI_ADDRESS_SPACE_IO, + .access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS, + .addrl = dev->path.pnp.port, + }; + + current = ALIGN_UP(current, 8); + printk(BIOS_DEBUG, "ACPI: * SPMI at %lx\n", current); + spmi = (struct acpi_spmi *)current; + + if (dev->chip_info) + conf = dev->chip_info; + + if (conf) { + if (conf->have_gpe) + gpe_interrupt = conf->gpe_interrupt; + if (conf->have_apic) + apic_interrupt = conf->apic_interrupt; + } + + /* Use command to get UID from ipmi_ssdt */ + acpi_create_ipmi(dev, spmi, (ipmi_revision_major << 8) | + (ipmi_revision_minor << 4), &addr, + IPMI_INTERFACE_KCS, gpe_interrupt, apic_interrupt, + dev->command); + + acpi_add_table(rsdp, spmi); + + current += spmi->header.length; + + return current; +} + +static void ipmi_ssdt(struct device *dev) +{ + const char *scope = acpi_device_scope(dev); + struct drivers_ipmi_config *conf = NULL; + + if (!scope) { + printk(BIOS_ERR, "IPMI: Missing ACPI scope for %s\n", + dev_path(dev)); + return; + } + + if (dev->chip_info) + conf = dev->chip_info; + + /* Use command to pass UID to ipmi_write_acpi_tables */ + dev->command = uid_cnt++; + + /* write SPMI device */ + acpigen_write_scope(scope); + acpigen_write_device("SPMI"); + acpigen_write_name_string("_HID", "IPI0001"); + acpigen_write_name_string("_STR", "IPMI_KCS"); + acpigen_write_name_byte("_UID", dev->command); + acpigen_write_STA(0xf); + acpigen_write_name("_CRS"); + acpigen_write_resourcetemplate_header(); + acpigen_write_io16(dev->path.pnp.port, dev->path.pnp.port, 1, 2, 1); + + if (conf) { + // FIXME: is that correct? + if (conf->have_apic) + acpigen_write_irq(1 << conf->apic_interrupt); + } + + acpigen_write_resourcetemplate_footer(); + + acpigen_write_method("_IFT", 0); + acpigen_write_return_byte(1); // KCS + acpigen_pop_len(); + + acpigen_write_method("_SRV", 0); + acpigen_write_return_integer((ipmi_revision_major << 8) | + (ipmi_revision_minor << 4)); + acpigen_pop_len(); + + acpigen_pop_len(); /* pop device */ + acpigen_pop_len(); /* pop scope */ +} +#endif + +#if CONFIG(GENERATE_SMBIOS_TABLES) +static int ipmi_smbios_data(struct device *dev, int *handle, + unsigned long *current) +{ + struct drivers_ipmi_config *conf = NULL; + u8 nv_storage = 0xff; + u8 i2c_address = 0; + int len = 0; + + if (dev->chip_info) + conf = dev->chip_info; + + if (conf) { + if (conf->have_nv_storage) + nv_storage = conf->nv_storage_device_address; + i2c_address = conf->bmc_i2c_address; + } + + // add IPMI Device Information + len += smbios_write_type38( + current, handle, + SMBIOS_BMC_INTERFACE_KCS, + ipmi_revision_minor | (ipmi_revision_major << 4), + i2c_address, // I2C address + nv_storage, // NV storage + dev->path.pnp.port | 1, // IO interface + 0, + 0); // no IRQ + + return len; +} +#endif + +static void ipmi_set_resources(struct device *dev) +{ + struct resource *res; + + for (res = dev->resource_list; res; res = res->next) { + if (!(res->flags & IORESOURCE_ASSIGNED)) + continue; + + res->flags |= IORESOURCE_STORED; + report_resource_stored(dev, res, ""); + } +} + +static void ipmi_read_resources(struct device *dev) +{ + struct resource *res = new_resource(dev, 0); + res->base = dev->path.pnp.port; + res->size = 2; + res->flags = IORESOURCE_IO | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; +} + +static struct device_operations ops = { + .read_resources = ipmi_read_resources, + .set_resources = ipmi_set_resources, + .enable_resources = DEVICE_NOOP, + .init = ipmi_kcs_init, +#if CONFIG(HAVE_ACPI_TABLES) + .write_acpi_tables = ipmi_write_acpi_tables, + .acpi_fill_ssdt_generator = ipmi_ssdt, +#endif +#if CONFIG(GENERATE_SMBIOS_TABLES) + .get_smbios_data = ipmi_smbios_data, +#endif +}; + +static void enable_dev(struct device *dev) +{ + if (dev->path.type != DEVICE_PATH_PNP) + printk(BIOS_ERR, "%s: Unsupported device type\n", + dev_path(dev)); + else if (dev->path.pnp.port & 1) + printk(BIOS_ERR, "%s: Base address needs to be aligned to 2\n", + dev_path(dev)); + else + dev->ops = &ops; +} + +struct chip_operations drivers_ipmi_ops = { + CHIP_NAME("IPMI KCS") + .enable_dev = enable_dev, +}; diff --git a/src/drivers/pc80/tpm/tis.c b/src/drivers/pc80/tpm/tis.c index e10332ba0a..23de003b47 100644 --- a/src/drivers/pc80/tpm/tis.c +++ b/src/drivers/pc80/tpm/tis.c @@ -146,10 +146,18 @@ static const struct device_name stmicro_devices[] = { {0xffff} }; +static const struct device_name swtpm_devices[] = { +#if CONFIG(TPM2) + {0x0001, "SwTPM 2.0" }, +#endif + {0xffff} +}; + static const struct vendor_name vendor_names[] = { {0x1114, "Atmel", atmel_devices}, {0x15d1, "Infineon", infineon_devices}, {0x1050, "Nuvoton", nuvoton_devices}, + {0x1014, "TPM Emulator", swtpm_devices}, {0x104a, "ST Microelectronics", stmicro_devices}, }; diff --git a/src/drivers/smmstore/store.c b/src/drivers/smmstore/store.c index 36fd4b8c50..882d245ea1 100644 --- a/src/drivers/smmstore/store.c +++ b/src/drivers/smmstore/store.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include diff --git a/src/drivers/vpd/vpd_decode.c b/src/drivers/vpd/vpd_decode.c index 0eab704ca8..527c50818e 100644 --- a/src/drivers/vpd/vpd_decode.c +++ b/src/drivers/vpd/vpd_decode.c @@ -8,7 +8,7 @@ */ #include "vpd_decode.h" -int vpd_decode_len( +static int vpd_decode_len( const u32 max_len, const u8 *in, u32 *length, u32 *decoded_len) { u8 more; @@ -32,15 +32,36 @@ int vpd_decode_len( return VPD_DECODE_OK; } +static int vpd_decode_entry( + const u32 max_len, const u8 *input_buf, u32 *consumed, + const u8 **entry, u32 *entry_len) +{ + u32 decoded_len; + + if (vpd_decode_len(max_len - *consumed, &input_buf[*consumed], + entry_len, &decoded_len) != VPD_DECODE_OK) + return VPD_DECODE_FAIL; + if (max_len - *consumed < decoded_len) + return VPD_DECODE_FAIL; + + *consumed += decoded_len; + *entry = input_buf + *consumed; + + /* entry_len is untrusted data and must be checked again. */ + if (max_len - *consumed < *entry_len) + return VPD_DECODE_FAIL; + + *consumed += *entry_len; + return VPD_DECODE_OK; +} + int vpd_decode_string( const u32 max_len, const u8 *input_buf, u32 *consumed, vpd_decode_callback callback, void *callback_arg) { int type; - int res; u32 key_len; u32 value_len; - u32 decoded_len; const u8 *key; const u8 *value; @@ -55,30 +76,14 @@ int vpd_decode_string( case VPD_TYPE_STRING: (*consumed)++; - /* key */ - res = vpd_decode_len(max_len - *consumed, &input_buf[*consumed], - &key_len, &decoded_len); - /* key name cannot be empty, and must be followed by value. */ - if (res != VPD_DECODE_OK || key_len < 1 || - *consumed + decoded_len + key_len >= max_len) + if (vpd_decode_entry(max_len, input_buf, consumed, &key, + &key_len) != VPD_DECODE_OK) return VPD_DECODE_FAIL; - *consumed += decoded_len; - key = &input_buf[*consumed]; - *consumed += key_len; - - /* value */ - res = vpd_decode_len(max_len - *consumed, &input_buf[*consumed], - &value_len, &decoded_len); - /* value can be empty (value_len = 0). */ - if (res != VPD_DECODE_OK || - *consumed + decoded_len + value_len > max_len) + if (vpd_decode_entry(max_len, input_buf, consumed, &value, + &value_len) != VPD_DECODE_OK) return VPD_DECODE_FAIL; - *consumed += decoded_len; - value = &input_buf[*consumed]; - *consumed += value_len; - if (type == VPD_TYPE_STRING) return callback(key, key_len, value, value_len, callback_arg); diff --git a/src/drivers/vpd/vpd_decode.h b/src/drivers/vpd/vpd_decode.h index 99ca7efa81..5d595f367f 100644 --- a/src/drivers/vpd/vpd_decode.h +++ b/src/drivers/vpd/vpd_decode.h @@ -29,29 +29,12 @@ typedef int vpd_decode_callback( const u8 *key, u32 key_len, const u8 *value, u32 value_len, void *arg); -/* - * vpd_decode_len - * - * Given an encoded string, this function extracts the length of content - * (either key or value). The *consumed will contain the number of bytes - * consumed. - * - * The input_buf points to the first byte of the input buffer. - * - * The *consumed starts from 0, which is actually the next byte to be decoded. - * It can be non-zero to be used in multiple calls. - * - * Returns VPD_DECODE_OK on success, otherwise VPD_DECODE_FAIL. - */ -int vpd_decode_len( - const u32 max_len, const u8 *in, u32 *length, u32 *decoded_len); - /* * vpd_decode_string * * Given the encoded string, this function invokes callback with extracted - * (key, value). The *consumed will be plused the number of bytes consumed in - * this function. + * (key, value). The *consumed will be incremented by the number of bytes + * consumed in this function. * * The input_buf points to the first byte of the input buffer. * diff --git a/src/ec/compal/ene932/ec.c b/src/ec/compal/ene932/ec.c index 7d8880c185..cfabd8d12a 100644 --- a/src/ec/compal/ene932/ec.c +++ b/src/ec/compal/ene932/ec.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include diff --git a/src/ec/google/chromeec/ec_lpc.c b/src/ec/google/chromeec/ec_lpc.c index 7293cffcd3..b7d183ebb0 100644 --- a/src/ec/google/chromeec/ec_lpc.c +++ b/src/ec/google/chromeec/ec_lpc.c @@ -188,11 +188,9 @@ static int google_chromeec_command_version(void) return EC_HOST_CMD_FLAG_VERSION_3; } else if (flags & EC_HOST_CMD_FLAG_LPC_ARGS_SUPPORTED) { return EC_HOST_CMD_FLAG_LPC_ARGS_SUPPORTED; - } else { - printk(BIOS_ERR, - "Chromium EC command version unsupported\n"); - return -1; } + printk(BIOS_ERR, "Chromium EC command version unsupported\n"); + return -1; } static int google_chromeec_command_v3(struct chromeec_command *cec_command) diff --git a/src/ec/google/wilco/acpi/ec.asl b/src/ec/google/wilco/acpi/ec.asl index 4fa887b1b4..532f421780 100644 --- a/src/ec/google/wilco/acpi/ec.asl +++ b/src/ec/google/wilco/acpi/ec.asl @@ -154,6 +154,12 @@ Device (EC0) If (Arg0) { Printf ("EC Enter S0ix") W (CSEX, One) + + /* + * Read back from EC RAM after enabling S0ix + * to prevent EC from aborting S0ix entry. + */ + R (EVT1) } Else { Printf ("EC Exit S0ix") W (CSEX, Zero) diff --git a/src/ec/google/wilco/mailbox.c b/src/ec/google/wilco/mailbox.c index d47290ccaf..3414c4af14 100644 --- a/src/ec/google/wilco/mailbox.c +++ b/src/ec/google/wilco/mailbox.c @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include diff --git a/src/ec/kontron/it8516e/ec.c b/src/ec/kontron/it8516e/ec.c index 5565382109..c0042fc729 100644 --- a/src/ec/kontron/it8516e/ec.c +++ b/src/ec/kontron/it8516e/ec.c @@ -13,7 +13,6 @@ * GNU General Public License for more details. */ -#include #include #include #include diff --git a/src/ec/kontron/kempld/kempld_i2c.c b/src/ec/kontron/kempld/kempld_i2c.c index fdc0b50dfc..ab41097782 100644 --- a/src/ec/kontron/kempld/kempld_i2c.c +++ b/src/ec/kontron/kempld/kempld_i2c.c @@ -166,10 +166,9 @@ static int kempld_i2c_process(struct kempld_i2c_data *const i2c) if (!(msg->flags & I2C_M_NOSTART)) { i2c->state = STATE_ADDR; return 0; - } else { - i2c->state = (msg->flags & I2C_M_RD) - ? STATE_READ : STATE_WRITE; } + i2c->state = (msg->flags & I2C_M_RD) + ? STATE_READ : STATE_WRITE; } else { i2c->state = STATE_DONE; kempld_write8(KEMPLD_I2C_CMD, I2C_CMD_STOP); diff --git a/src/ec/lenovo/h8/h8.c b/src/ec/lenovo/h8/h8.c index f707014c31..2b959ceea1 100644 --- a/src/ec/lenovo/h8/h8.c +++ b/src/ec/lenovo/h8/h8.c @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include diff --git a/src/ec/lenovo/pmh7/pmh7.c b/src/ec/lenovo/pmh7/pmh7.c index ef505cd164..30de6fe949 100644 --- a/src/ec/lenovo/pmh7/pmh7.c +++ b/src/ec/lenovo/pmh7/pmh7.c @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include diff --git a/src/ec/quanta/ene_kb3940q/ec.c b/src/ec/quanta/ene_kb3940q/ec.c index af2d3782a2..1f8e36c661 100644 --- a/src/ec/quanta/ene_kb3940q/ec.c +++ b/src/ec/quanta/ene_kb3940q/ec.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include "ec.h" diff --git a/src/ec/quanta/it8518/ec.c b/src/ec/quanta/it8518/ec.c index e293f7cb6a..5b9ba9f9bd 100644 --- a/src/ec/quanta/it8518/ec.c +++ b/src/ec/quanta/it8518/ec.c @@ -20,7 +20,6 @@ #include #include #include -#include #include "ec.h" #include "chip.h" diff --git a/src/ec/roda/it8518/ec.c b/src/ec/roda/it8518/ec.c index 4e69d116ab..09ff480a99 100644 --- a/src/ec/roda/it8518/ec.c +++ b/src/ec/roda/it8518/ec.c @@ -18,7 +18,6 @@ #include #include #include -#include #include #include "chip.h" diff --git a/src/include/cpu/x86/msr.h b/src/include/cpu/x86/msr.h index 5c6cae3a0e..8c558ce8ac 100644 --- a/src/include/cpu/x86/msr.h +++ b/src/include/cpu/x86/msr.h @@ -37,6 +37,8 @@ #define IA32_PERF_CTL 0x199 #define IA32_THERM_INTERRUPT 0x19b #define IA32_MISC_ENABLE 0x1a0 +#define FAST_STRINGS_ENABLE_BIT (1 << 0) +#define SPEED_STEP_ENABLE_BIT (1 << 16) #define IA32_ENERGY_PERF_BIAS 0x1b0 #define ENERGY_POLICY_PERFORMANCE 0 #define ENERGY_POLICY_NORMAL 6 diff --git a/src/include/ctype.h b/src/include/ctype.h new file mode 100644 index 0000000000..b4684af768 --- /dev/null +++ b/src/include/ctype.h @@ -0,0 +1,56 @@ +#ifndef CTYPE_H +#define CTYPE_H + +static inline int isspace(int c) +{ + switch (c) { + case ' ': case '\f': case '\n': + case '\r': case '\t': case '\v': + return 1; + default: + return 0; + } +} + +static inline int isprint(int c) +{ + return c >= ' ' && c <= '~'; +} + +static inline int isdigit(int c) +{ + return (c >= '0' && c <= '9'); +} + +static inline int isxdigit(int c) +{ + return ((c >= '0' && c <= '9') || + (c >= 'a' && c <= 'f') || + (c >= 'A' && c <= 'F')); +} + +static inline int isupper(int c) +{ + return (c >= 'A' && c <= 'Z'); +} + +static inline int islower(int c) +{ + return (c >= 'a' && c <= 'z'); +} + +static inline int toupper(int c) +{ + if (islower(c)) + c -= 'a'-'A'; + return c; +} + +static inline int tolower(int c) +{ + if (isupper(c)) + c -= 'A'-'a'; + return c; +} + +#endif /* CTYPE_H */ diff --git a/src/include/device/device.h b/src/include/device/device.h index 32cf07282b..8e9454c4e1 100644 --- a/src/include/device/device.h +++ b/src/include/device/device.h @@ -191,6 +191,7 @@ const char *bus_path(struct bus *bus); void dev_set_enabled(struct device *dev, int enable); void disable_children(struct bus *bus); bool dev_is_active_bridge(struct device *dev); +void add_more_links(struct device *dev, unsigned int total_links); /* Option ROM helper functions */ void run_bios(struct device *dev, unsigned long addr); diff --git a/src/include/device/pci_ids.h b/src/include/device/pci_ids.h index 2c8fadcc6f..35c457a636 100644 --- a/src/include/device/pci_ids.h +++ b/src/include/device/pci_ids.h @@ -304,6 +304,7 @@ #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_17H_MODEL_101F_NB_IOMMU 0x15d1 #define PCI_DEVICE_ID_ATI_SB600_LPC 0x438D #define PCI_DEVICE_ID_ATI_SB600_SATA 0x4380 @@ -451,6 +452,12 @@ #define PCI_DEVICE_ID_AMD_CZ_USB3_0 0x7914 #define PCI_DEVICE_ID_AMD_CZ_SMBUS 0x790B +#define PCI_DEVICE_ID_AMD_PCO_LPC 0x790e +#define PCI_DEVICE_ID_AMD_PCO_HDA0 0x15de +#define PCI_DEVICE_ID_AMD_PCO_HDA1 0x15e3 +#define PCI_DEVICE_ID_AMD_PCO_XHCI0 0x15e0 +#define PCI_DEVICE_ID_AMD_PCO_XHCI1 0x15e1 + #define PCI_VENDOR_ID_VLSI 0x1004 #define PCI_DEVICE_ID_VLSI_82C592 0x0005 #define PCI_DEVICE_ID_VLSI_82C593 0x0006 diff --git a/src/include/device_tree.h b/src/include/device_tree.h index d9d9613f96..56a9361bd8 100644 --- a/src/include/device_tree.h +++ b/src/include/device_tree.h @@ -74,9 +74,9 @@ struct device_tree_node const char *name; uint32_t phandle; - // List of struct device_tree_property-s. + /* List of struct device_tree_property-s. */ struct list_node properties; - // List of struct device_tree_nodes. + /* List of struct device_tree_nodes. */ struct list_node children; struct list_node list_node; @@ -108,18 +108,18 @@ struct device_tree * which were consumed reading the requested value. */ -// Read the property, if any, at offset offset. +/* Read the property, if any, at offset offset. */ int fdt_next_property(const void *blob, uint32_t offset, struct fdt_property *prop); -// Read the name of the node, if any, at offset offset. +/* Read the name of the node, if any, at offset offset. */ int fdt_node_name(const void *blob, uint32_t offset, const char **name); void fdt_print_node(const void *blob, uint32_t offset); int fdt_skip_node(const void *blob, uint32_t offset); -// Read a flattened device tree into a heirarchical structure which refers to -// the contents of the flattened tree in place. Modifying the flat tree -// invalidates the unflattened one. +/* Read a flattened device tree into a heirarchical structure which refers to + the contents of the flattened tree in place. Modifying the flat tree + invalidates the unflattened one. */ struct device_tree *fdt_unflatten(const void *blob); @@ -128,42 +128,42 @@ struct device_tree *fdt_unflatten(const void *blob); * Unflattened device tree functions. */ -// Figure out how big a device tree would be if it were flattened. +/* Figure out how big a device tree would be if it were flattened. */ uint32_t dt_flat_size(const struct device_tree *tree); -// Flatten a device tree into the buffer pointed to by dest. +/* Flatten a device tree into the buffer pointed to by dest. */ void dt_flatten(const struct device_tree *tree, void *dest); void dt_print_node(const struct device_tree_node *node); -// Read #address-cells and #size-cells properties from a node. +/* Read #address-cells and #size-cells properties from a node. */ void dt_read_cell_props(const struct device_tree_node *node, u32 *addrcp, u32 *sizecp); -// Look up or create a node relative to a parent node, through its path -// represented as an array of strings. +/* Look up or create a node relative to a parent node, through its path + represented as an array of strings. */ struct device_tree_node *dt_find_node(struct device_tree_node *parent, const char **path, u32 *addrcp, u32 *sizecp, int create); struct device_tree_node *dt_find_node_by_phandle(struct device_tree_node *root, uint32_t phandle); -// Look up or create a node in the tree, through its path -// represented as a string of '/' separated node names. +/* Look up or create a node in the tree, through its path + represented as a string of '/' separated node names. */ struct device_tree_node *dt_find_node_by_path(struct device_tree *tree, const char *path, u32 *addrcp, u32 *sizecp, int create); -// Look up a node through an alias. +/* Look up a node through an alias. */ struct device_tree_node *dt_find_node_by_alias(struct device_tree *tree, const char *alias); -// Look up a node relative to a parent node, through its compatible string. +/* Look up a node relative to a parent node, through its compatible string. */ struct device_tree_node *dt_find_compat(struct device_tree_node *parent, const char *compatible); -// Look up the next child of a parent node, through its compatible string. It -// uses child pointer as the marker to find next. +/* Look up the next child of a parent node, through its compatible string. It + uses child pointer as the marker to find next. */ struct device_tree_node *dt_find_next_compat_child(struct device_tree_node *parent, struct device_tree_node *child, const char *compat); -// Look up a node relative to a parent node, through its property value. +/* Look up a node relative to a parent node, through its property value. */ struct device_tree_node *dt_find_prop_value(struct device_tree_node *parent, const char *name, void *data, size_t size); -// Write src into *dest as a 'length'-byte big-endian integer. +/* Write src into *dest as a 'length'-byte big-endian integer. */ void dt_write_int(u8 *dest, u64 src, size_t length); -// Delete a property +/* Delete a property */ void dt_delete_prop(struct device_tree_node *node, const char *name); -// Add different kinds of properties to a node, or update existing ones. +/* Add different kinds of properties to a node, or update existing ones. */ void dt_add_bin_prop(struct device_tree_node *node, const char *name, void *data, size_t size); void dt_add_string_prop(struct device_tree_node *node, const char *name, @@ -180,6 +180,10 @@ void dt_find_bin_prop(const struct device_tree_node *node, const char *name, const char *dt_find_string_prop(const struct device_tree_node *node, const char *name); +/* Apply an overlay to a base device tree. Ownership of the overlay data passes + to the newly combined base tree -- do not free() or access it afterwards! */ +int dt_apply_overlay(struct device_tree *tree, struct device_tree *overlay); + /* * Fixups to apply to a kernel's device tree before booting it. */ diff --git a/src/include/fit.h b/src/include/fit.h index 6e0667f6cf..1c90aca1ff 100644 --- a/src/include/fit.h +++ b/src/include/fit.h @@ -24,25 +24,21 @@ #include #include -struct fit_image_node -{ +struct fit_image_node { const char *name; - const void *data; + void *data; uint32_t size; int compression; struct list_node list_node; }; -struct fit_config_node -{ +struct fit_config_node { const char *name; - const char *kernel; - struct fit_image_node *kernel_node; - const char *fdt; - struct fit_image_node *fdt_node; - const char *ramdisk; - struct fit_image_node *ramdisk_node; + struct fit_image_node *kernel; + struct fit_image_node *fdt; + struct list_node overlays; + struct fit_image_node *ramdisk; struct fdt_property compat; int compat_rank; int compat_pos; @@ -51,6 +47,11 @@ struct fit_config_node struct list_node list_node; }; +struct fit_overlay_chain { + struct fit_image_node *overlay; + struct list_node list_node; +}; + /* * Updates the cmdline in the devicetree. */ diff --git a/src/include/memlayout.h b/src/include/memlayout.h index 273a80d240..1ed87b61c9 100644 --- a/src/include/memlayout.h +++ b/src/include/memlayout.h @@ -39,9 +39,13 @@ #define ARCH_STAGE_HAS_BSS_SECTION 1 #endif -/* Default is that currently ramstage, smm, and rmodules have a heap. */ +/* + * Default is that currently ENV_PAYLOAD_LOADER enable stage, smm, + * and rmodules have a heap. + */ #ifndef ARCH_STAGE_HAS_HEAP_SECTION -#define ARCH_STAGE_HAS_HEAP_SECTION (ENV_RAMSTAGE || ENV_SMM || ENV_RMODULE) +#define ARCH_STAGE_HAS_HEAP_SECTION (ENV_PAYLOAD_LOADER || ENV_SMM || \ + ENV_RMODULE) #endif #define STR(x) #x diff --git a/src/include/rules.h b/src/include/rules.h index fcb827df90..d8f6e7438b 100644 --- a/src/include/rules.h +++ b/src/include/rules.h @@ -277,7 +277,7 @@ * be built with simple device model. */ -#if (defined(__PRE_RAM__) || ENV_SMM || ENV_POSTCAR) +#if (defined(__PRE_RAM__) || ENV_SMM || !ENV_PAYLOAD_LOADER) #define __SIMPLE_DEVICE__ #endif diff --git a/src/include/stddef.h b/src/include/stddef.h index 993d5f09cc..7cae2e6dc8 100644 --- a/src/include/stddef.h +++ b/src/include/stddef.h @@ -23,7 +23,7 @@ typedef unsigned int wint_t; /* The devicetree data structures are only mutable in ramstage. All other stages have a constant devicetree. */ -#if !ENV_RAMSTAGE +#if !ENV_PAYLOAD_LOADER #define DEVTREE_EARLY 1 #else #define DEVTREE_EARLY 0 diff --git a/src/include/string.h b/src/include/string.h index d164f32b83..30241303eb 100644 --- a/src/include/string.h +++ b/src/include/string.h @@ -50,56 +50,4 @@ char *strrchr(const char *s, int c); */ unsigned int skip_atoi(char **s); -static inline int isspace(int c) -{ - switch (c) { - case ' ': case '\f': case '\n': - case '\r': case '\t': case '\v': - return 1; - default: - return 0; - } -} - -static inline int isprint(int c) -{ - return c >= ' ' && c <= '~'; -} - -static inline int isdigit(int c) -{ - return (c >= '0' && c <= '9'); -} - -static inline int isxdigit(int c) -{ - return ((c >= '0' && c <= '9') || - (c >= 'a' && c <= 'f') || - (c >= 'A' && c <= 'F')); -} - -static inline int isupper(int c) -{ - return (c >= 'A' && c <= 'Z'); -} - -static inline int islower(int c) -{ - return (c >= 'a' && c <= 'z'); -} - -static inline int toupper(int c) -{ - if (islower(c)) - c -= 'a'-'A'; - return c; -} - -static inline int tolower(int c) -{ - if (isupper(c)) - c -= 'A'-'a'; - return c; -} - #endif /* STRING_H */ diff --git a/src/lib/device_tree.c b/src/lib/device_tree.c index a5021ca8fd..b8faab53b8 100644 --- a/src/lib/device_tree.c +++ b/src/lib/device_tree.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -133,7 +134,7 @@ static int print_flat_node(const void *blob, uint32_t start_offset, int depth) offset += size; } - printk(BIOS_DEBUG, "\n"); // empty line between props and nodes + printk(BIOS_DEBUG, "\n"); /* empty line between props and nodes */ while ((size = print_flat_node(blob, offset, depth + 1))) offset += size; @@ -259,11 +260,13 @@ struct device_tree *fdt_unflatten(const void *blob) if (magic != FDT_HEADER_MAGIC) { printk(BIOS_DEBUG, "Invalid device tree magic %#.8x!\n", magic); + free(tree); return NULL; } if (last_comp_version > FDT_SUPPORTED_VERSION) { printk(BIOS_DEBUG, "Unsupported device tree version %u(>=%u)\n", version, last_comp_version); + free(tree); return NULL; } if (version > FDT_SUPPORTED_VERSION) @@ -277,9 +280,9 @@ struct device_tree *fdt_unflatten(const void *blob) uint32_t min_offset = 0; min_offset = MIN(struct_offset, strings_offset); min_offset = MIN(min_offset, reserve_offset); - // Assume everything up to the first non-header component is part of - // the header and needs to be preserved. This will protect us against - // new elements being added in the future. + /* Assume everything up to the first non-header component is part of + the header and needs to be preserved. This will protect us against + new elements being added in the future. */ tree->header_size = min_offset; struct device_tree_reserve_map_entry *entry; @@ -307,25 +310,25 @@ struct device_tree *fdt_unflatten(const void *blob) static void dt_flat_prop_size(struct device_tree_property *prop, uint32_t *struct_size, uint32_t *strings_size) { - // Starting token. + /* Starting token. */ *struct_size += sizeof(uint32_t); - // Size. + /* Size. */ *struct_size += sizeof(uint32_t); - // Name offset. + /* Name offset. */ *struct_size += sizeof(uint32_t); - // Property value. + /* Property value. */ *struct_size += ALIGN_UP(prop->prop.size, sizeof(uint32_t)); - // Property name. + /* Property name. */ *strings_size += strlen(prop->prop.name) + 1; } static void dt_flat_node_size(struct device_tree_node *node, uint32_t *struct_size, uint32_t *strings_size) { - // Starting token. + /* Starting token. */ *struct_size += sizeof(uint32_t); - // Node name. + /* Node name. */ *struct_size += ALIGN_UP(strlen(node->name) + 1, sizeof(uint32_t)); struct device_tree_property *prop; @@ -336,7 +339,7 @@ static void dt_flat_node_size(struct device_tree_node *node, list_for_each(child, node->children, list_node) dt_flat_node_size(child, struct_size, strings_size); - // End token. + /* End token. */ *struct_size += sizeof(uint32_t); } @@ -353,7 +356,7 @@ uint32_t dt_flat_size(const struct device_tree *tree) dt_flat_node_size(tree->root, &struct_size, &strings_size); size += struct_size; - // End token. + /* End token. */ size += sizeof(uint32_t); size += strings_size; @@ -478,7 +481,7 @@ void dt_flatten(const struct device_tree *tree, void *start_dest) static void print_node(const struct device_tree_node *node, int depth) { print_indent(depth); - if (depth == 0) // root node has no name, print a starting slash + if (depth == 0) /* root node has no name, print a starting slash */ printk(BIOS_DEBUG, "/"); printk(BIOS_DEBUG, "%s {\n", node->name); @@ -486,7 +489,7 @@ static void print_node(const struct device_tree_node *node, int depth) list_for_each(prop, node->properties, list_node) print_property(&prop->prop, depth + 1); - printk(BIOS_DEBUG, "\n"); // empty line between props and nodes + printk(BIOS_DEBUG, "\n"); /* empty line between props and nodes */ struct device_tree_node *child; list_for_each(child, node->children, list_node) @@ -546,13 +549,13 @@ struct device_tree_node *dt_find_node(struct device_tree_node *parent, { struct device_tree_node *node, *found = NULL; - // Update #address-cells and #size-cells for this level. + /* Update #address-cells and #size-cells for this level. */ dt_read_cell_props(parent, addrcp, sizecp); if (!*path) return parent; - // Find the next node in the path, if it exists. + /* Find the next node in the path, if it exists. */ list_for_each(node, parent->children, list_node) { if (!strcmp(node->name, *path)) { found = node; @@ -560,7 +563,7 @@ struct device_tree_node *dt_find_node(struct device_tree_node *parent, } } - // Otherwise create it or return NULL. + /* Otherwise create it or return NULL. */ if (!found) { if (!create) return NULL; @@ -607,8 +610,8 @@ struct device_tree_node *dt_find_node_by_path(struct device_tree *tree, int i; struct device_tree_node *node = NULL; - if (path[0] == '/') { // regular path - if (path[1] == '\0') { // special case: "/" is root node + if (path[0] == '/') { /* regular path */ + if (path[1] == '\0') { /* special case: "/" is root node */ dt_read_cell_props(tree->root, addrcp, sizecp); return tree->root; } @@ -618,7 +621,7 @@ struct device_tree_node *dt_find_node_by_path(struct device_tree *tree, return NULL; parent = tree->root; - } else { // alias + } else { /* alias */ char *alias; alias = duped_str = strdup(path); @@ -639,7 +642,7 @@ struct device_tree_node *dt_find_node_by_path(struct device_tree *tree, } if (!sub_path) { - // it's just the alias, no sub-path + /* it's just the alias, no sub-path */ free(duped_str); return parent; } @@ -754,7 +757,7 @@ static int dt_check_compat_match(struct device_tree_node *node, struct device_tree_node *dt_find_compat(struct device_tree_node *parent, const char *compat) { - // Check if the parent node itself is compatible. + /* Check if the parent node itself is compatible. */ if (dt_check_compat_match(parent, compat)) return parent; @@ -1089,12 +1092,493 @@ struct device_tree_node *dt_init_reserved_memory_node(struct device_tree *tree) if (!reserved) return NULL; - // Binding doc says this should have the same #{address,size}-cells as - // the root. + /* Binding doc says this should have the same #{address,size}-cells as + the root. */ dt_add_u32_prop(reserved, "#address-cells", addr); dt_add_u32_prop(reserved, "#size-cells", size); - // Binding doc says this should be empty (i.e., 1:1 mapping from root). + /* Binding doc says this should be empty (1:1 mapping from root). */ dt_add_bin_prop(reserved, "ranges", NULL, 0); return reserved; } + +/* + * Increment a single phandle in prop at a given offset by a given adjustment. + * + * @param prop Property whose phandle should be adjusted. + * @param adjustment Value that should be added to the existing phandle. + * @param offset Byte offset of the phandle in the property data. + * + * @return New phandle value, or 0 on error. + */ +static uint32_t dt_adjust_phandle(struct device_tree_property *prop, + uint32_t adjustment, uint32_t offset) +{ + if (offset + 4 > prop->prop.size) + return 0; + + uint32_t phandle = be32dec(prop->prop.data + offset); + if (phandle == 0 || + phandle == FDT_PHANDLE_ILLEGAL || + phandle == 0xffffffff) + return 0; + + phandle += adjustment; + if (phandle >= FDT_PHANDLE_ILLEGAL) + return 0; + + be32enc(prop->prop.data + offset, phandle); + return phandle; +} + +/* + * Adjust all phandles in subtree by adding a new base offset. + * + * @param node Root node of the subtree to work on. + * @param base New phandle base to be added to all phandles. + * + * @return New highest phandle in the subtree, or 0 on error. + */ +static uint32_t dt_adjust_all_phandles(struct device_tree_node *node, + uint32_t base) +{ + uint32_t new_max = MAX(base, 1); /* make sure we don't return 0 */ + struct device_tree_property *prop; + struct device_tree_node *child; + + if (!node) + return new_max; + + list_for_each(prop, node->properties, list_node) + if (dt_prop_is_phandle(prop)) { + node->phandle = dt_adjust_phandle(prop, base, 0); + if (!node->phandle) + return 0; + new_max = MAX(new_max, node->phandle); + } /* no break -- can have more than one phandle prop */ + + list_for_each(child, node->children, list_node) + new_max = MAX(new_max, dt_adjust_all_phandles(child, base)); + + return new_max; +} + +/* + * Apply a /__local_fixup__ subtree to the corresponding overlay subtree. + * + * @param node Root node of the overlay subtree to fix up. + * @param node Root node of the /__local_fixup__ subtree. + * @param base Adjustment that was added to phandles in the overlay. + * + * @return 0 on success, -1 on error. + */ +static int dt_fixup_locals(struct device_tree_node *node, + struct device_tree_node *fixup, uint32_t base) +{ + struct device_tree_property *prop; + struct device_tree_property *fixup_prop; + struct device_tree_node *child; + struct device_tree_node *fixup_child; + int i; + + /* + * For local fixups the /__local_fixup__ subtree contains the same node + * hierarchy as the main tree we're fixing up. Each property contains + * the fixup offsets for the respective property in the main tree. For + * each property in the fixup node, find the corresponding property in + * the base node and apply fixups to all offsets it specifies. + */ + list_for_each(fixup_prop, fixup->properties, list_node) { + struct device_tree_property *base_prop = NULL; + list_for_each(prop, node->properties, list_node) + if (!strcmp(prop->prop.name, fixup_prop->prop.name)) { + base_prop = prop; + break; + } + + /* We should always find a corresponding base prop for a fixup, + and fixup props contain a list of 32-bit fixup offsets. */ + if (!base_prop || fixup_prop->prop.size % sizeof(uint32_t)) + return -1; + + for (i = 0; i < fixup_prop->prop.size; i += sizeof(uint32_t)) + if (!dt_adjust_phandle(base_prop, base, be32dec( + fixup_prop->prop.data + i))) + return -1; + } + + /* Now recursively descend both the base tree and the /__local_fixups__ + subtree in sync to apply all fixups. */ + list_for_each(fixup_child, fixup->children, list_node) { + struct device_tree_node *base_child = NULL; + list_for_each(child, node->children, list_node) + if (!strcmp(child->name, fixup_child->name)) { + base_child = child; + break; + } + + /* All fixup nodes should have a corresponding base node. */ + if (!base_child) + return -1; + + if (dt_fixup_locals(base_child, fixup_child, base) < 0) + return -1; + } + + return 0; +} + +/* + * Update all /__symbols__ properties in an overlay that start with + * "/fragment@X/__overlay__" with corresponding path prefix in the base tree. + * + * @param symbols /__symbols__ done to update. + * @param fragment /fragment@X node that references to should be updated. + * @param base_path Path of base tree node that the fragment overlaid. + */ +static void dt_fix_symbols(struct device_tree_node *symbols, + struct device_tree_node *fragment, + const char *base_path) +{ + struct device_tree_property *prop; + char buf[512]; /* Should be enough for maximum DT path length? */ + char node_path[64]; /* easily enough for /fragment@XXXX/__overlay__ */ + + if (!symbols) /* If the overlay has no /__symbols__ node, we're done! */ + return; + + int len = snprintf(node_path, sizeof(node_path), "/%s/__overlay__", + fragment->name); + + list_for_each(prop, symbols->properties, list_node) + if (!strncmp(prop->prop.data, node_path, len)) { + prop->prop.size = snprintf(buf, sizeof(buf), "%s%s", + base_path, (char *)prop->prop.data + len) + 1; + free(prop->prop.data); + prop->prop.data = strdup(buf); + } +} + +/* + * Fix up overlay according to a property in /__fixup__. If the fixed property + * is a /fragment@X:target, also update /__symbols__ references to fragment. + * + * @params overlay Overlay to fix up. + * @params fixup /__fixup__ property. + * @params phandle phandle value to insert where the fixup points to. + * @params base_path Path to the base DT node that the fixup points to. + * @params overlay_symbols /__symbols__ node of the overlay. + * + * @return 0 on success, -1 on error. + */ +static int dt_fixup_external(struct device_tree *overlay, + struct device_tree_property *fixup, + uint32_t phandle, const char *base_path, + struct device_tree_node *overlay_symbols) +{ + struct device_tree_property *prop; + + /* External fixup properties are encoded as "::". */ + char *entry = fixup->prop.data; + while ((void *)entry < fixup->prop.data + fixup->prop.size) { + /* okay to destroy fixup property value, won't need it again */ + char *node_path = entry; + entry = strchr(node_path, ':'); + if (!entry) + return -1; + *entry++ = '\0'; + + char *prop_name = entry; + entry = strchr(prop_name, ':'); + if (!entry) + return -1; + *entry++ = '\0'; + + struct device_tree_node *ovl_node = dt_find_node_by_path( + overlay, node_path, NULL, NULL, 0); + if (!ovl_node || !isdigit(*entry)) + return -1; + + struct device_tree_property *ovl_prop = NULL; + list_for_each(prop, ovl_node->properties, list_node) + if (!strcmp(prop->prop.name, prop_name)) { + ovl_prop = prop; + break; + } + + /* Move entry to first char after number, must be a '\0'. */ + uint32_t offset = skip_atoi(&entry); + if (!ovl_prop || offset + 4 > ovl_prop->prop.size || entry[0]) + return -1; + entry++; /* jump over '\0' to potential next fixup */ + + be32enc(ovl_prop->prop.data + offset, phandle); + + /* If this is a /fragment@X:target property, update references + to this fragment in the overlay __symbols__ now. */ + if (offset == 0 && !strcmp(prop_name, "target") && + !strchr(node_path + 1, '/')) /* only toplevel nodes */ + dt_fix_symbols(overlay_symbols, ovl_node, base_path); + } + + return 0; +} + +/* + * Apply all /__fixup__ properties in the overlay. This will destroy the + * property data in /__fixup__ and it should not be accessed again. + * + * @params tree Base device tree that the overlay updates. + * @params symbols /__symbols__ node of the base device tree. + * @params overlay Overlay to fix up. + * @params fixups /__fixup__ node in the overlay. + * @params overlay_symbols /__symbols__ node of the overlay. + * + * @return 0 on success, -1 on error. + */ +static int dt_fixup_all_externals(struct device_tree *tree, + struct device_tree_node *symbols, + struct device_tree *overlay, + struct device_tree_node *fixups, + struct device_tree_node *overlay_symbols) +{ + struct device_tree_property *fix; + + /* If we have any external fixups, base tree must have /__symbols__. */ + if (!symbols) + return -1; + + /* + * Unlike /__local_fixups__, /__fixups__ is not a whole subtree that + * mirrors the node hierarchy. It's just a directory of fixup properties + * that each directly contain all information necessary to apply them. + */ + list_for_each(fix, fixups->properties, list_node) { + /* The name of a fixup property is the label of the node we want + a property to phandle-reference. Look up in /__symbols__. */ + const char *path = dt_find_string_prop(symbols, fix->prop.name); + if (!path) + return -1; + + /* Find node the label pointed to to figure out its phandle. */ + struct device_tree_node *node = dt_find_node_by_path(tree, path, + NULL, NULL, 0); + if (!node) + return -1; + + /* Write into the overlay property(s) pointing to that node. */ + if (dt_fixup_external(overlay, fix, node->phandle, + path, overlay_symbols) < 0) + return -1; + } + + return 0; +} + +/* + * Copy all nodes and properties from one DT subtree into another. This is a + * shallow copy so both trees will point to the same property data afterwards. + * + * @params dst Destination subtree to copy into. + * @params src Source subtree to copy from. + * @params upd 1 to overwrite same-name properties, 0 to discard them. + */ +static void dt_copy_subtree(struct device_tree_node *dst, + struct device_tree_node *src, int upd) +{ + struct device_tree_property *prop; + struct device_tree_property *src_prop; + list_for_each(src_prop, src->properties, list_node) { + if (dt_prop_is_phandle(src_prop) || + !strcmp(src_prop->prop.name, "name")) { + printk(BIOS_DEBUG, + "WARNING: ignoring illegal overlay prop '%s'\n", + src_prop->prop.name); + continue; + } + + struct device_tree_property *dst_prop = NULL; + list_for_each(prop, dst->properties, list_node) + if (!strcmp(prop->prop.name, src_prop->prop.name)) { + dst_prop = prop; + break; + } + + if (dst_prop) { + if (!upd) { + printk(BIOS_DEBUG, + "WARNING: ignoring prop update '%s'\n", + src_prop->prop.name); + continue; + } + } else { + dst_prop = xzalloc(sizeof(*dst_prop)); + list_insert_after(&dst_prop->list_node, + &dst->properties); + } + + dst_prop->prop = src_prop->prop; + } + + struct device_tree_node *node; + struct device_tree_node *src_node; + list_for_each(src_node, src->children, list_node) { + struct device_tree_node *dst_node = NULL; + list_for_each(node, dst->children, list_node) + if (!strcmp(node->name, src_node->name)) { + dst_node = node; + break; + } + + if (!dst_node) { + dst_node = xzalloc(sizeof(*dst_node)); + *dst_node = *src_node; + list_insert_after(&dst_node->list_node, &dst->children); + } else { + dt_copy_subtree(dst_node, src_node, upd); + } + } +} + +/* + * Apply an overlay /fragment@X node to a base device tree. + * + * @param tree Base device tree. + * @param fragment /fragment@X node. + * @params overlay_symbols /__symbols__ node of the overlay. + * + * @return 0 on success, -1 on error. + */ +static int dt_import_fragment(struct device_tree *tree, + struct device_tree_node *fragment, + struct device_tree_node *overlay_symbols) +{ + /* The actual overlaid nodes/props are in an __overlay__ child node. */ + static const char *overlay_path[] = { "__overlay__", NULL }; + struct device_tree_node *overlay = dt_find_node(fragment, overlay_path, + NULL, NULL, 0); + + /* If it doesn't have an __overlay__ child, it's not a fragment. */ + if (!overlay) + return 0; + + /* Target node of the fragment can be given by path or by phandle. */ + struct device_tree_property *prop; + struct device_tree_property *phandle = NULL; + struct device_tree_property *path = NULL; + list_for_each(prop, fragment->properties, list_node) { + if (!strcmp(prop->prop.name, "target")) { + phandle = prop; + break; /* phandle target has priority, stop looking */ + } + if (!strcmp(prop->prop.name, "target-path")) + path = prop; + } + + struct device_tree_node *target = NULL; + if (phandle) { + if (phandle->prop.size != sizeof(uint32_t)) + return -1; + target = dt_find_node_by_phandle(tree->root, + be32dec(phandle->prop.data)); + /* Symbols already updated as part of dt_fixup_external(). */ + } else if (path) { + target = dt_find_node_by_path(tree, path->prop.data, + NULL, NULL, 0); + dt_fix_symbols(overlay_symbols, fragment, path->prop.data); + } + if (!target) + return -1; + + dt_copy_subtree(target, overlay, 1); + return 0; +} + +/* + * Apply a device tree overlay to a base device tree. This will + * destroy/incorporate the overlay data, so it should not be freed or reused. + * See dtc.git/Documentation/dt-object-internal.txt for overlay format details. + * + * @param tree Unflattened base device tree to add the overlay into. + * @param overlay Unflattened overlay device tree to apply to the base. + * + * @return 0 on success, -1 on error. + */ +int dt_apply_overlay(struct device_tree *tree, struct device_tree *overlay) +{ + /* + * First, we need to make sure phandles inside the overlay don't clash + * with those in the base tree. We just define the highest phandle value + * in the base tree as the "phandle offset" for this overlay and + * increment all phandles in it by that value. + */ + uint32_t phandle_base = tree->max_phandle; + uint32_t new_max = dt_adjust_all_phandles(overlay->root, phandle_base); + if (!new_max) { + printk(BIOS_DEBUG, "ERROR: invalid phandles in overlay\n"); + return -1; + } + tree->max_phandle = new_max; + + /* Now that we changed phandles in the overlay, we need to update any + nodes referring to them. Those are listed in /__local_fixups__. */ + struct device_tree_node *local_fixups = dt_find_node_by_path(overlay, + "/__local_fixups__", NULL, NULL, 0); + if (local_fixups && dt_fixup_locals(overlay->root, local_fixups, + phandle_base) < 0) { + printk(BIOS_DEBUG, "ERROR: invalid local fixups in overlay\n"); + return -1; + } + + /* + * Besides local phandle references (from nodes within the overlay to + * other nodes within the overlay), the overlay may also contain phandle + * references to the base tree. These are stored with invalid values and + * must be updated now. /__symbols__ contains a list of all labels in + * the base tree, and /__fixups__ describes all nodes in the overlay + * that contain external phandle references. + * We also take this opportunity to update all /fragment@X/__overlay__/ + * prefixes in the overlay's /__symbols__ node to the correct path that + * the fragment will be placed in later, since this is the only step + * where we have all necessary information for that easily available. + */ + struct device_tree_node *symbols = dt_find_node_by_path(tree, + "/__symbols__", NULL, NULL, 0); + struct device_tree_node *fixups = dt_find_node_by_path(overlay, + "/__fixups__", NULL, NULL, 0); + struct device_tree_node *overlay_symbols = dt_find_node_by_path(overlay, + "/__symbols__", NULL, NULL, 0); + if (fixups && dt_fixup_all_externals(tree, symbols, overlay, + fixups, overlay_symbols) < 0) { + printk(BIOS_DEBUG, + "ERROR: cannot match external fixups from overlay\n"); + return -1; + } + + /* After all this fixing up, we can finally merge overlay into the tree + (one fragment at a time, because for some reason it's split up). */ + struct device_tree_node *fragment; + list_for_each(fragment, overlay->root->children, list_node) + if (dt_import_fragment(tree, fragment, overlay_symbols) < 0) { + printk(BIOS_DEBUG, "ERROR: bad DT fragment '%s'\n", + fragment->name); + return -1; + } + + /* + * We need to also update /__symbols__ to include labels from this + * overlay, in case we want to load further overlays with external + * phandle references to it. If the base tree already has a /__symbols__ + * we merge them together, otherwise we just insert the overlay's + * /__symbols__ node into the base tree root. + */ + if (overlay_symbols) { + if (symbols) + dt_copy_subtree(symbols, overlay_symbols, 0); + else + list_insert_after(&overlay_symbols->list_node, + &tree->root->children); + } + + return 0; +} diff --git a/src/lib/edid.c b/src/lib/edid.c index 3087172952..e2f213c5b0 100644 --- a/src/lib/edid.c +++ b/src/lib/edid.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include diff --git a/src/lib/fit.c b/src/lib/fit.c index c98ba2f802..f1052e8f23 100644 --- a/src/lib/fit.c +++ b/src/lib/fit.c @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -85,6 +86,42 @@ static void fit_add_default_compat_strings(void) fit_add_compat_string(compat_string); } +static struct fit_image_node *find_image(const char *name) +{ + struct fit_image_node *image; + list_for_each(image, image_nodes, list_node) { + if (!strcmp(image->name, name)) + return image; + } + printk(BIOS_ERR, "ERROR: Cannot find image node %s!\n", name); + return NULL; +} + +static struct fit_image_node *find_image_with_overlays(const char *name, + int bytes, struct list_node *prev) +{ + struct fit_image_node *base = find_image(name); + if (!base) + return NULL; + + int len = strnlen(name, bytes) + 1; + bytes -= len; + name += len; + while (bytes > 0) { + struct fit_overlay_chain *next = xzalloc(sizeof(*next)); + next->overlay = find_image(name); + if (!next->overlay) + return NULL; + list_insert_after(&next->list_node, prev); + prev = &next->list_node; + len = strnlen(name, bytes) + 1; + bytes -= len; + name += len; + } + + return base; +} + static void image_node(struct device_tree_node *node) { struct fit_image_node *image = xzalloc(sizeof(*image)); @@ -120,11 +157,14 @@ static void config_node(struct device_tree_node *node) struct device_tree_property *prop; list_for_each(prop, node->properties, list_node) { if (!strcmp("kernel", prop->prop.name)) - config->kernel = prop->prop.data; + config->kernel = find_image(prop->prop.data); else if (!strcmp("fdt", prop->prop.name)) - config->fdt = prop->prop.data; + config->fdt = find_image_with_overlays(prop->prop.data, + prop->prop.size, &config->overlays); else if (!strcmp("ramdisk", prop->prop.name)) - config->ramdisk = prop->prop.data; + config->ramdisk = find_image(prop->prop.data); + else if (!strcmp("compatible", prop->prop.name)) + config->compat = prop->prop; } list_insert_after(&config->list_node, &config_nodes); @@ -132,40 +172,22 @@ static void config_node(struct device_tree_node *node) static void fit_unpack(struct device_tree *tree, const char **default_config) { - assert(tree && tree->root); + struct device_tree_node *child; + struct device_tree_node *images = dt_find_node_by_path(tree, "/images", + NULL, NULL, 0); + if (images) + list_for_each(child, images->children, list_node) + image_node(child); - struct device_tree_node *top; - list_for_each(top, tree->root->children, list_node) { - struct device_tree_node *child; - if (!strcmp("images", top->name)) { - - list_for_each(child, top->children, list_node) - image_node(child); - - } else if (!strcmp("configurations", top->name)) { - struct device_tree_property *prop; - list_for_each(prop, top->properties, list_node) { - if (!strcmp("default", prop->prop.name) && - default_config) - *default_config = prop->prop.data; - } - - list_for_each(child, top->children, list_node) - config_node(child); - } + struct device_tree_node *configs = dt_find_node_by_path(tree, + "/configurations", NULL, NULL, 0); + if (configs) { + *default_config = dt_find_string_prop(configs, "default"); + list_for_each(child, configs->children, list_node) + config_node(child); } } -static struct fit_image_node *find_image(const char *name) -{ - struct fit_image_node *image; - list_for_each(image, image_nodes, list_node) { - if (!strcmp(image->name, name)) - return image; - } - return NULL; -} - static int fdt_find_compat(const void *blob, uint32_t start_offset, struct fdt_property *prop) { @@ -393,32 +415,60 @@ void fit_update_memory(struct device_tree *tree) /* * Finds a compat string and updates the compat position and rank. - * @param fdt_blob Pointer to FDT * @param config The current config node to operate on + * @return 0 if compat updated, -1 if this FDT cannot be used. */ -static void fit_update_compat(const void *fdt_blob, - struct fit_config_node *config) +static int fit_update_compat(struct fit_config_node *config) { - struct compat_string_entry *compat_node; - const struct fdt_header *fdt_header = - (const struct fdt_header *)fdt_blob; - uint32_t fdt_offset = be32_to_cpu(fdt_header->structure_offset); - size_t i = 0; + /* If there was no "compatible" property in config node, this is a + legacy FIT image. Must extract compat prop from FDT itself. */ + if (!config->compat.name) { + void *fdt_blob = config->fdt->data; + const struct fdt_header *fdt_header = fdt_blob; + uint32_t fdt_offset = be32_to_cpu(fdt_header->structure_offset); - if (!fdt_find_compat(fdt_blob, fdt_offset, &config->compat)) { - list_for_each(compat_node, compat_strings, list_node) { - int pos = fit_check_compat(&config->compat, - compat_node->compat_string); - if (pos >= 0) { - config->compat_pos = pos; - config->compat_rank = i; - config->compat_string = - compat_node->compat_string; - break; - } - i++; + if (config->fdt->compression != CBFS_COMPRESS_NONE) { + printk(BIOS_ERR, + "ERROR: config %s has a compressed FDT without " + "external compatible property, skipping.\n", + config->name); + return -1; + } + + /* FDT overlays are not supported in legacy FIT images. */ + if (config->overlays.next) { + printk(BIOS_ERR, + "ERROR: config %s has overlay but no compat!\n", + config->name); + return -1; + } + + if (fdt_find_compat(fdt_blob, fdt_offset, &config->compat)) { + printk(BIOS_ERR, + "ERROR: Can't find compat string in FDT %s " + "for config %s, skipping.\n", + config->fdt->name, config->name); + return -1; } } + + config->compat_pos = -1; + config->compat_rank = -1; + size_t i = 0; + struct compat_string_entry *compat_node; + list_for_each(compat_node, compat_strings, list_node) { + int pos = fit_check_compat(&config->compat, + compat_node->compat_string); + if (pos >= 0) { + config->compat_pos = pos; + config->compat_rank = i; + config->compat_string = + compat_node->compat_string; + } + i++; + } + + return 0; } struct fit_config_node *fit_load(void *fit) @@ -426,6 +476,7 @@ struct fit_config_node *fit_load(void *fit) struct fit_image_node *image; struct fit_config_node *config; struct compat_string_entry *compat_node; + struct fit_overlay_chain *overlay_chain; printk(BIOS_DEBUG, "FIT: Loading FIT from %p\n", fit); @@ -457,55 +508,43 @@ struct fit_config_node *fit_load(void *fit) printk(BIOS_DEBUG, "\n"); /* Process and list the configs. */ list_for_each(config, config_nodes, list_node) { - if (config->kernel) - config->kernel_node = find_image(config->kernel); - if (config->fdt) - config->fdt_node = find_image(config->fdt); - if (config->ramdisk) - config->ramdisk_node = find_image(config->ramdisk); + if (!config->kernel) { + printk(BIOS_ERR, + "ERROR: config %s has no kernel, skipping.\n", + config->name); + continue; + } + if (!config->fdt) { + printk(BIOS_ERR, + "ERROR: config %s has no FDT, skipping.\n", + config->name); + continue; + } - if (config->ramdisk_node && - config->ramdisk_node->compression < 0) { + if (config->ramdisk && + config->ramdisk->compression < 0) { printk(BIOS_WARNING, "WARN: Ramdisk is compressed with " "an unsupported algorithm, discarding config %s." "\n", config->name); - list_remove(&config->list_node); continue; } - if (!config->kernel_node || - (config->fdt && !config->fdt_node)) { - printk(BIOS_DEBUG, "FIT: Missing image, discarding " - "config %s.\n", config->name); - list_remove(&config->list_node); + if (fit_update_compat(config)) continue; - } - if (config->fdt_node) { - if (config->fdt_node->compression != - CBFS_COMPRESS_NONE) { - printk(BIOS_DEBUG, - "FIT: FDT compression not yet supported," - " skipping config %s.\n", config->name); - list_remove(&config->list_node); - continue; - } - - config->compat_pos = -1; - config->compat_rank = -1; - - fit_update_compat(config->fdt_node->data, config); - } printk(BIOS_DEBUG, "FIT: config %s", config->name); if (default_config_name && !strcmp(config->name, default_config_name)) { printk(BIOS_DEBUG, " (default)"); default_config = config; } - if (config->fdt) - printk(BIOS_DEBUG, ", fdt %s", config->fdt); + printk(BIOS_DEBUG, ", kernel %s", config->kernel->name); + printk(BIOS_DEBUG, ", fdt %s", config->fdt->name); + list_for_each(overlay_chain, config->overlays, list_node) + printk(BIOS_DEBUG, " %s", overlay_chain->overlay->name); if (config->ramdisk) - printk(BIOS_DEBUG, ", ramdisk %s", config->ramdisk); + printk(BIOS_DEBUG, ", ramdisk %s", + config->ramdisk->name); if (config->compat.name) { printk(BIOS_DEBUG, ", compat"); int bytes = config->compat.size; diff --git a/src/lib/fit_payload.c b/src/lib/fit_payload.c index e0158f2129..8e75915806 100644 --- a/src/lib/fit_payload.c +++ b/src/lib/fit_payload.c @@ -88,15 +88,32 @@ static bool extract(struct region *region, struct fit_image_node *node) } if (!true_size) { - printk(BIOS_ERR, "ERROR: %s node failed!\n", comp_name); + printk(BIOS_ERR, "ERROR: %s decompression failed!\n", + comp_name); return true; } - prog_segment_loaded(region->offset, true_size, 0); - return false; } +static struct device_tree *unpack_fdt(struct fit_image_node *image_node) +{ + void *data = image_node->data; + + if (image_node->compression != CBFS_COMPRESS_NONE) { + /* TODO: This is an ugly heuristic for how much the size will + expand on decompression, fix once FIT images support storing + the real uncompressed size. */ + struct region r = { .offset = 0, .size = image_node->size * 5 }; + data = malloc(r.size); + r.offset = (uintptr_t)data; + if (!data || extract(&r, image_node)) + return NULL; + } + + return fdt_unflatten(data); +} + /** * Add coreboot tables, CBMEM information and optional board specific strapping * IDs to the device tree loaded via FIT. @@ -176,37 +193,43 @@ void fit_payload(struct prog *payload) struct fit_config_node *config = fit_load(data); - if (!config || !config->kernel_node) { + if (!config) { printk(BIOS_ERR, "ERROR: Could not load FIT\n"); rdev_munmap(prog_rdev(payload), data); return; } - if (config->fdt_node) { - dt = fdt_unflatten(config->fdt_node->data); - if (!dt) { - printk(BIOS_ERR, - "ERROR: Failed to unflatten the FDT.\n"); - rdev_munmap(prog_rdev(payload), data); - return; - } - - dt_apply_fixups(dt); - - /* Insert coreboot specific information */ - add_cb_fdt_data(dt); - - /* Update device_tree */ -#if defined(CONFIG_LINUX_COMMAND_LINE) - fit_update_chosen(dt, (char *)CONFIG_LINUX_COMMAND_LINE); -#endif - fit_update_memory(dt); + dt = unpack_fdt(config->fdt); + if (!dt) { + printk(BIOS_ERR, "ERROR: Failed to unflatten the FDT.\n"); + rdev_munmap(prog_rdev(payload), data); + return; } + struct fit_overlay_chain *chain; + list_for_each(chain, config->overlays, list_node) { + struct device_tree *overlay = unpack_fdt(chain->overlay); + if (!overlay || dt_apply_overlay(dt, overlay)) { + printk(BIOS_ERR, "ERROR: Failed to apply overlay %s!\n", + chain->overlay->name); + } + } + + dt_apply_fixups(dt); + + /* Insert coreboot specific information */ + add_cb_fdt_data(dt); + + /* Update device_tree */ +#if defined(CONFIG_LINUX_COMMAND_LINE) + fit_update_chosen(dt, (char *)CONFIG_LINUX_COMMAND_LINE); +#endif + fit_update_memory(dt); + /* Collect infos for fit_payload_arch */ - kernel.size = config->kernel_node->size; + kernel.size = config->kernel->size; fdt.size = dt ? dt_flat_size(dt) : 0; - initrd.size = config->ramdisk_node ? config->ramdisk_node->size : 0; + initrd.size = config->ramdisk ? config->ramdisk->size : 0; /* Invoke arch specific payload placement and fixups */ if (!fit_payload_arch(payload, config, &kernel, &fdt, &initrd)) { @@ -216,17 +239,15 @@ void fit_payload(struct prog *payload) return; } - /* Load the images to given position */ - if (config->fdt_node) { - /* Update device_tree */ - if (config->ramdisk_node) - fit_add_ramdisk(dt, (void *)initrd.offset, initrd.size); + /* Update ramdisk location in FDT */ + if (config->ramdisk) + fit_add_ramdisk(dt, (void *)initrd.offset, initrd.size); - pack_fdt(&fdt, dt); - } + /* Repack FDT for handoff to kernel */ + pack_fdt(&fdt, dt); - if (config->ramdisk_node && - extract(&initrd, config->ramdisk_node)) { + if (config->ramdisk && + extract(&initrd, config->ramdisk)) { printk(BIOS_ERR, "ERROR: Failed to extract initrd\n"); prog_set_entry(payload, NULL, NULL); rdev_munmap(prog_rdev(payload), data); @@ -235,7 +256,7 @@ void fit_payload(struct prog *payload) timestamp_add_now(TS_KERNEL_DECOMPRESSION); - if (extract(&kernel, config->kernel_node)) { + if (extract(&kernel, config->kernel)) { printk(BIOS_ERR, "ERROR: Failed to extract kernel\n"); prog_set_entry(payload, NULL, NULL); rdev_munmap(prog_rdev(payload), data); diff --git a/src/lib/gnat/Makefile.inc b/src/lib/gnat/Makefile.inc index 3f22c0e8e1..ebd04862bf 100644 --- a/src/lib/gnat/Makefile.inc +++ b/src/lib/gnat/Makefile.inc @@ -24,7 +24,8 @@ ADAFLAGS_libgnat-$(1) := \ -gnatg \ -gnatpg \ -I$$(src)/lib/gnat/ \ - $$(GCC_CFLAGS_$(1)) \ + $$(GCC_ADAFLAGS_$(1)) \ + -Werror \ libgnat-$(1)-y += a-unccon.ads libgnat-$(1)-y += ada.ads diff --git a/src/lib/hexdump.c b/src/lib/hexdump.c index ca36ddee0e..1e689e3e53 100644 --- a/src/lib/hexdump.c +++ b/src/lib/hexdump.c @@ -13,6 +13,7 @@ */ #include +#include #include #include diff --git a/src/lib/hexstrtobin.c b/src/lib/hexstrtobin.c index ed2abc4e8b..61290b86d3 100644 --- a/src/lib/hexstrtobin.c +++ b/src/lib/hexstrtobin.c @@ -11,6 +11,7 @@ * GNU General Public License for more details. */ +#include #include #include diff --git a/src/lib/imd_cbmem.c b/src/lib/imd_cbmem.c index 1a67ad5be1..b1b63f68b3 100644 --- a/src/lib/imd_cbmem.c +++ b/src/lib/imd_cbmem.c @@ -307,7 +307,7 @@ void cbmem_get_region(void **baseptr, size_t *size) imd_region_used(cbmem_get_imd(), baseptr, size); } -#if ENV_RAMSTAGE || (CONFIG(EARLY_CBMEM_LIST) \ +#if ENV_PAYLOAD_LOADER || (CONFIG(EARLY_CBMEM_LIST) \ && (ENV_POSTCAR || ENV_ROMSTAGE)) /* * -fdata-sections doesn't work so well on read only strings. They all diff --git a/src/lib/memrange.c b/src/lib/memrange.c index 96d7524218..79a1b0ee49 100644 --- a/src/lib/memrange.c +++ b/src/lib/memrange.c @@ -47,7 +47,7 @@ static struct range_entry *alloc_range(struct memranges *ranges) range_entry_unlink(&ranges->free_list, r); return r; } - if (ENV_RAMSTAGE) + if (ENV_PAYLOAD_LOADER) return malloc(sizeof(struct range_entry)); return NULL; } diff --git a/src/lib/prog_loaders.c b/src/lib/prog_loaders.c index 81ec2ec3c4..dfabd31910 100644 --- a/src/lib/prog_loaders.c +++ b/src/lib/prog_loaders.c @@ -160,7 +160,7 @@ fail: die_with_post_code(POST_INVALID_ROM, "Ramstage was not loaded!\n"); } -#ifdef __RAMSTAGE__ // gc-sections should take care of this +#if ENV_PAYLOAD_LOADER // gc-sections should take care of this static struct prog global_payload = PROG_INIT(PROG_PAYLOAD, CONFIG_CBFS_PREFIX "/payload"); diff --git a/src/lib/spd_bin.c b/src/lib/spd_bin.c index b378d6377e..1598ff162f 100644 --- a/src/lib/spd_bin.c +++ b/src/lib/spd_bin.c @@ -13,7 +13,6 @@ * GNU General Public License for more details. */ -#include #include #include #include diff --git a/src/lib/string.c b/src/lib/string.c index a19f017852..eb6adb67c7 100644 --- a/src/lib/string.c +++ b/src/lib/string.c @@ -1,4 +1,5 @@ #include +#include #include #include #include diff --git a/src/lib/timestamp.c b/src/lib/timestamp.c index 38d0212845..adacf6b1b3 100644 --- a/src/lib/timestamp.c +++ b/src/lib/timestamp.c @@ -116,8 +116,11 @@ static struct timestamp_table *timestamp_alloc_cbmem_table(void) * based x86 platforms. */ static int timestamp_should_run(void) { - /* Only check boot_cpu() in other stages than ramstage on x86. */ - if ((!ENV_RAMSTAGE && CONFIG(ARCH_X86)) && !boot_cpu()) + /* + * Only check boot_cpu() in other stages than + * ENV_PAYLOAD_LOADER on x86. + */ + if ((!ENV_PAYLOAD_LOADER && CONFIG(ARCH_X86)) && !boot_cpu()) return 0; return 1; @@ -302,8 +305,8 @@ static void timestamp_sync_cache_to_cbmem(int is_recovery) if (ts_cbmem_table->base_time == 0) ts_cbmem_table->base_time = ts_cache_table->base_time; - /* Seed the timestamp tick frequency in ramstage. */ - if (ENV_RAMSTAGE) + /* Seed the timestamp tick frequency in ENV_PAYLOAD_LOADER. */ + if (ENV_PAYLOAD_LOADER) ts_cbmem_table->tick_freq_mhz = timestamp_tick_freq_mhz(); /* Cache no longer required. */ diff --git a/src/mainboard/amd/serengeti_cheetah_fam10/fadt.c b/src/mainboard/amd/serengeti_cheetah_fam10/fadt.c index 2067024088..845af71c92 100644 --- a/src/mainboard/amd/serengeti_cheetah_fam10/fadt.c +++ b/src/mainboard/amd/serengeti_cheetah_fam10/fadt.c @@ -36,7 +36,7 @@ void acpi_create_fadt(acpi_fadt_t *fadt,acpi_facs_t *facs,void *dsdt){ memset((void *)fadt,0,sizeof(acpi_fadt_t)); memcpy(header->signature,"FACP",4); header->length = 244; - header->revision = 3; + header->revision = get_acpi_table_revision(FADT); memcpy(header->oem_id,OEM_ID,6); memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); memcpy(header->asl_compiler_id,ASLC,4); diff --git a/src/mainboard/apple/macbook21/Kconfig b/src/mainboard/apple/macbook21/Kconfig index 6535f8f7e5..84c00cfa9c 100644 --- a/src/mainboard/apple/macbook21/Kconfig +++ b/src/mainboard/apple/macbook21/Kconfig @@ -13,7 +13,6 @@ config BOARD_SPECIFIC_OPTIONS select HAVE_CMOS_DEFAULT select HAVE_MP_TABLE select BOARD_ROMSIZE_KB_2048 - select CHANNEL_XOR_RANDOMIZATION select INTEL_INT15 select HAVE_ACPI_TABLES select HAVE_ACPI_RESUME diff --git a/src/mainboard/apple/macbook21/mptable.c b/src/mainboard/apple/macbook21/mptable.c index cbd30c726e..61296134a8 100644 --- a/src/mainboard/apple/macbook21/mptable.c +++ b/src/mainboard/apple/macbook21/mptable.c @@ -41,21 +41,21 @@ static void *smp_write_config_table(void *v) smp_write_intsrc(mc, mp_ExtINT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, isa_bus, 0x00, MP_APIC_ALL, 0x00); smp_write_intsrc(mc, mp_NMI, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT, isa_bus, 0x00, MP_APIC_ALL, 0x01); - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x01 << 2), 0x02, 0x10); /* PCIe root 0.02.0 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x02 << 2), 0x02, 0x10); /* VGA 0.02.0 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1b << 2), 0x02, 0x16); /* HD Audio 0:1b.0 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1c << 2), 0x02, 0x11); /* PCIe 0:1c.0 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1c << 2) | 0x01, 0x02, 0x10); /* PCIe 0:1c.1 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1c << 2) | 0x02, 0x02, 0x12); /* PCIe 0:1c.2 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1c << 2) | 0x03, 0x02, 0x13); /* PCIe 0:1c.3 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1d << 2) , 0x02, 0x15); /* USB 0:1d.0 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1d << 2) | 0x01, 0x02, 0x13); /* USB 0:1d.1 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1d << 2) | 0x02, 0x02, 0x12); /* USB 0:1d.2 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1d << 2) | 0x03, 0x02, 0x10); /* USB 0:1d.3 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1f << 2) , 0x02, 0x12); /* LPC 0:1f.0 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1f << 2) | 0x01, 0x02, 0x13); /* IDE 0:1f.1 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1f << 2) | 0x03, 0x02, 0x10); /* SATA 0:1f.3 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x03, (0x03 << 2) , 0x02, 0x13); /* Firewire 3:03.0 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x01, 0x00, 0x02, 0x10); /* PCIe root 0.01.0 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x02, 0x00, 0x02, 0x10); /* VGA 0.02.0 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1b, 0x00, 0x02, 0x16); /* HD Audio 0:1b.0 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1c, 0x00, 0x02, 0x11); /* PCIe 0:1c.0 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1c, 0x01, 0x02, 0x10); /* PCIe 0:1c.1 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1c, 0x02, 0x02, 0x12); /* PCIe 0:1c.2 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1c, 0x03, 0x02, 0x13); /* PCIe 0:1c.3 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1d, 0x00, 0x02, 0x15); /* USB 0:1d.0 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1d, 0x01, 0x02, 0x13); /* USB 0:1d.1 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1d, 0x02, 0x02, 0x12); /* USB 0:1d.2 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1d, 0x03, 0x02, 0x10); /* USB 0:1d.3 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1f, 0x00, 0x02, 0x12); /* LPC 0:1f.0 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1f, 0x01, 0x02, 0x13); /* IDE 0:1f.1 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1f, 0x03, 0x02, 0x10); /* SATA 0:1f.3 */ + smp_write_pci_intsrc(mc, mp_INT, 0x03, 0x03, 0x00, 0x02, 0x13); /* Firewire 3:03.0 */ mptable_lintsrc(mc, isa_bus); return mptable_finalize(mc); diff --git a/src/mainboard/apple/macbookair4_2/romstage.c b/src/mainboard/apple/macbookair4_2/romstage.c index 68556d96e6..d04582d1ed 100644 --- a/src/mainboard/apple/macbookair4_2/romstage.c +++ b/src/mainboard/apple/macbookair4_2/romstage.c @@ -13,7 +13,6 @@ #include #include -#include #include #include #include @@ -24,10 +23,6 @@ void pch_enable_lpc(void) { pci_write_config16(PCI_DEV(0, 0x1f, 0), 0x82, 0x3f0f); - pci_write_config32(PCI_DEV(0, 0x1f, 0), 0x84, 0x000c0681); - pci_write_config32(PCI_DEV(0, 0x1f, 0), 0x88, 0x000c1641); - pci_write_config32(PCI_DEV(0, 0x1f, 0), 0x8c, 0x001c0301); - pci_write_config32(PCI_DEV(0, 0x1f, 0), 0x90, 0x00fc0701); pci_write_config16(PCI_DEV(0, 0x1f, 0), 0x80, 0x0070); pci_write_config32(PCI_DEV(0, 0x1f, 0), 0xac, 0x80000000); } diff --git a/src/mainboard/asrock/h110m/Kconfig b/src/mainboard/asrock/h110m/Kconfig index 3d2111309e..eebce57d49 100644 --- a/src/mainboard/asrock/h110m/Kconfig +++ b/src/mainboard/asrock/h110m/Kconfig @@ -11,10 +11,9 @@ config BOARD_SPECIFIC_OPTIONS select INTEL_INT15 select SOC_INTEL_KABYLAKE select SKYLAKE_SOC_PCH_H - select MAINBOARD_USES_FSP2_0 select GENERIC_SPD_BIN select SUPERIO_NUVOTON_NCT6791D - select SUPERIO_NUVOTON_NCT6776_COM_A + select SUPERIO_NUVOTON_NCT6791D_COM_A select REALTEK_8168_RESET select RT8168_SET_LED_MODE diff --git a/src/mainboard/asrock/h110m/devicetree.cb b/src/mainboard/asrock/h110m/devicetree.cb index 158801f118..3067ffe53c 100644 --- a/src/mainboard/asrock/h110m/devicetree.cb +++ b/src/mainboard/asrock/h110m/devicetree.cb @@ -62,6 +62,9 @@ chip soc/intel/skylake register "pirqg_routing" = "PCH_IRQ11" register "pirqh_routing" = "PCH_IRQ11" + # Set LPC Serial IRQ mode + register "serirq_mode" = "SERIRQ_CONTINUOUS" + # Enabling SLP_S3#, SLP_S4#, SLP_SUS and SLP_A Stretch # SLP_S3 Minimum Assertion Width. Values 0: 60us, 1: 1ms, 2: 50ms, 3: 2s register "PmConfigSlpS3MinAssert" = "0x02" diff --git a/src/mainboard/asus/am1i-a/romstage.c b/src/mainboard/asus/am1i-a/romstage.c index 4b172eaad8..5e1218abd3 100644 --- a/src/mainboard/asus/am1i-a/romstage.c +++ b/src/mainboard/asus/am1i-a/romstage.c @@ -25,7 +25,15 @@ #include #define ITE_CONFIG_REG_CC 0x02 + +#if CONFIG_UART_FOR_CONSOLE == 0 +#define SERIAL_DEV PNP_DEV(0x2e, IT8623E_SP1) +#elif CONFIG_UART_FOR_CONSOLE == 1 #define SERIAL_DEV PNP_DEV(0x2e, IT8623E_SP2) +#else +#error "Invalid value for CONFIG_UART_FOR_CONSOLE" +#endif + #define GPIO_DEV PNP_DEV(0x2e, IT8623E_GPIO) #define CLKIN_DEV PNP_DEV(0x2e, IT8623E_GPIO) #define ENVC_DEV PNP_DEV(0x2e, IT8623E_EC) diff --git a/src/mainboard/asus/p5gc-mx/Kconfig b/src/mainboard/asus/p5gc-mx/Kconfig index 21e57bb6b2..193364ab72 100644 --- a/src/mainboard/asus/p5gc-mx/Kconfig +++ b/src/mainboard/asus/p5gc-mx/Kconfig @@ -29,7 +29,6 @@ config BOARD_SPECIFIC_OPTIONS select HAVE_ACPI_TABLES select HAVE_ACPI_RESUME select BOARD_ROMSIZE_KB_512 - select CHANNEL_XOR_RANDOMIZATION select MAINBOARD_HAS_NATIVE_VGA_INIT select INTEL_GMA_HAVE_VBT diff --git a/src/mainboard/asus/p8z77-m_pro/Kconfig b/src/mainboard/asus/p8z77-m_pro/Kconfig new file mode 100644 index 0000000000..8d29a9bc21 --- /dev/null +++ b/src/mainboard/asus/p8z77-m_pro/Kconfig @@ -0,0 +1,48 @@ +## +## This file is part of the coreboot project. +## +## Copyright (C) 2019 Vlado Cibic +## +## 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. +## + +if BOARD_ASUS_P8Z77_M_PRO + +config BOARD_SPECIFIC_OPTIONS + def_bool y + select BOARD_ROMSIZE_KB_8192 + select HAVE_ACPI_RESUME + select HAVE_ACPI_TABLES + select INTEL_INT15 + select NORTHBRIDGE_INTEL_SANDYBRIDGE + select SERIRQ_CONTINUOUS_MODE + select SOUTHBRIDGE_INTEL_C216 + select MAINBOARD_HAS_LPC_TPM + select MAINBOARD_HAS_TPM1 + select HAVE_OPTION_TABLE + select HAVE_CMOS_DEFAULT + select MAINBOARD_HAS_LIBGFXINIT + select INTEL_GMA_HAVE_VBT + select SUPERIO_NUVOTON_NCT6779D + select DRIVERS_ASMEDIA_ASPM_BLACKLIST # for ASM1061 eSATA + +config MAINBOARD_DIR + string + default "asus/p8z77-m_pro" + +config MAINBOARD_PART_NUMBER + string + default "P8Z77-M PRO" + +config MAX_CPUS + int + default 8 + +endif # BOARD_ASUS_P8Z77_M_PRO diff --git a/src/mainboard/asus/p8z77-m_pro/Kconfig.name b/src/mainboard/asus/p8z77-m_pro/Kconfig.name new file mode 100644 index 0000000000..c492094508 --- /dev/null +++ b/src/mainboard/asus/p8z77-m_pro/Kconfig.name @@ -0,0 +1,17 @@ +## +## This file is part of the coreboot project. +## +## Copyright (C) 2019 Vlado Cibic +## +## 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. +## + +config BOARD_ASUS_P8Z77_M_PRO + bool "P8Z77-M PRO" diff --git a/src/mainboard/asus/p8z77-m_pro/Makefile.inc b/src/mainboard/asus/p8z77-m_pro/Makefile.inc new file mode 100644 index 0000000000..0cc398a5e7 --- /dev/null +++ b/src/mainboard/asus/p8z77-m_pro/Makefile.inc @@ -0,0 +1,19 @@ +## +## This file is part of the coreboot project. +## +## Copyright (C) 2019 Vlado Cibic +## +## 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. +## + +romstage-y += gpio.c + +ramstage-$(CONFIG_MAINBOARD_USE_LIBGFXINIT) += gma-mainboard.ads diff --git a/src/mainboard/asus/p8z77-m_pro/acpi/ec.asl b/src/mainboard/asus/p8z77-m_pro/acpi/ec.asl new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/src/mainboard/asus/p8z77-m_pro/acpi/ec.asl @@ -0,0 +1 @@ + diff --git a/src/mainboard/asus/p8z77-m_pro/acpi/platform.asl b/src/mainboard/asus/p8z77-m_pro/acpi/platform.asl new file mode 100644 index 0000000000..3a696211c1 --- /dev/null +++ b/src/mainboard/asus/p8z77-m_pro/acpi/platform.asl @@ -0,0 +1,24 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2019 Vlado Cibic + * + * 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. + */ + +Method(_WAK,1) +{ + Return(Package(){0,0}) +} + +Method(_PTS,1) +{ +} diff --git a/src/mainboard/asus/p8z77-m_pro/acpi/superio.asl b/src/mainboard/asus/p8z77-m_pro/acpi/superio.asl new file mode 100644 index 0000000000..7f1d04c9ba --- /dev/null +++ b/src/mainboard/asus/p8z77-m_pro/acpi/superio.asl @@ -0,0 +1,17 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2019 Vlado Cibic + * + * 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 diff --git a/src/mainboard/asus/p8z77-m_pro/acpi_tables.c b/src/mainboard/asus/p8z77-m_pro/acpi_tables.c new file mode 100644 index 0000000000..2592c19a9e --- /dev/null +++ b/src/mainboard/asus/p8z77-m_pro/acpi_tables.c @@ -0,0 +1,35 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2019 Vlado Cibic + * + * 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 + +void acpi_create_gnvs(global_nvs_t *gnvs) +{ + /* Turn off power for USB ports in S3 by default */ + gnvs->s3u0 = 0; + gnvs->s3u1 = 0; + + /* Turn off power for USB ports in S5 by default */ + gnvs->s5u0 = 0; + gnvs->s5u1 = 0; + + /* critical temp that will shutdown the pc == 95C degrees */ + gnvs->tcrt = 95; + + /* temp to start throttling the cpu == 85C */ + gnvs->tpsv = 85; +} diff --git a/src/mainboard/asus/p8z77-m_pro/board_info.txt b/src/mainboard/asus/p8z77-m_pro/board_info.txt new file mode 100644 index 0000000000..66e6f0d6f9 --- /dev/null +++ b/src/mainboard/asus/p8z77-m_pro/board_info.txt @@ -0,0 +1,7 @@ +Category: desktop +Board URL: https://www.asus.com/Motherboards/P8Z77M_PRO/ +ROM package: DIP-8 +ROM protocol: SPI +ROM socketed: y +Flashrom support: y +Release year: 2013 diff --git a/src/mainboard/asus/p8z77-m_pro/cmos.default b/src/mainboard/asus/p8z77-m_pro/cmos.default new file mode 100644 index 0000000000..725ab9851d --- /dev/null +++ b/src/mainboard/asus/p8z77-m_pro/cmos.default @@ -0,0 +1,24 @@ +## +## This file is part of the coreboot project. +## +## Copyright (C) 2019 Vlado Cibic +## +## 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. +## + +boot_option=Fallback +debug_level=Debug +gfx_uma_size=224M +nmi=Enable +sata_mode=AHCI +#usb3_xxxx options are only used with MRC blob, ignored else +usb3_mode=Enable +usb3_drv=Enable +usb3_streams=Enable diff --git a/src/mainboard/asus/p8z77-m_pro/cmos.layout b/src/mainboard/asus/p8z77-m_pro/cmos.layout new file mode 100644 index 0000000000..da29d1c10e --- /dev/null +++ b/src/mainboard/asus/p8z77-m_pro/cmos.layout @@ -0,0 +1,185 @@ +## +## This file is part of the coreboot project. +## +## Copyright (C) 2019 Vlado Cibic +## +## 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. +## + +# ----------------------------------------------------------------- +entries + +# ----------------------------------------------------------------- +# Status Register A +# ----------------------------------------------------------------- +# Status Register B +# ----------------------------------------------------------------- +# Status Register C +#96 4 r 0 status_c_rsvd +#100 1 r 0 uf_flag +#101 1 r 0 af_flag +#102 1 r 0 pf_flag +#103 1 r 0 irqf_flag +# ----------------------------------------------------------------- +# Status Register D +#104 7 r 0 status_d_rsvd +#111 1 r 0 valid_cmos_ram +# ----------------------------------------------------------------- +# Diagnostic Status Register +#112 8 r 0 diag_rsvd1 + +# ----------------------------------------------------------------- +0 120 r 0 reserved_memory +#120 264 r 0 unused + +# ----------------------------------------------------------------- +# RTC_BOOT_BYTE (coreboot hardcoded) +384 1 e 3 boot_option +388 4 h 0 reboot_counter + +# ----------------------------------------------------------------- +# coreboot config options: console +#392 3 r 0 unused +395 4 e 4 debug_level +#399 1 r 0 unused +#400 8 r 0 reserved for century byte + +# ----------------------------------------------------------------- +# coreboot config options: southbridge + +# Non Maskable Interrupt(NMI) support, which is an interrupt that may +# occur on a RAM or unrecoverable error. +408 1 e 1 nmi + +409 2 e 5 power_on_after_fail +411 1 e 6 sata_mode + +# ----------------------------------------------------------------- +# coreboot config options: northbridge + +# gfx_uma_size +# Quantity of shared video memory the IGP can use +# +416 5 e 7 gfx_uma_size + +# ----------------------------------------------------------------- +# coreboot config options: usb3 + +# usb3_mode +# Controls how the motherboard's USB3 ports act at boot time +421 2 e 8 usb3_mode + +# usb3_drv +# Load (or not) pre-OS xHCI USB3 bios driver +# +423 1 e 1 usb3_drv + +# usb3_streams +# Streams can provide more speed (as they can use 64Kb packets), +# but they might cause incompatibilities with some devices. +# +424 1 e 1 usb3_streams + +# ----------------------------------------------------------------- +# Sandy/Ivy Bridge MRC Scrambler Seed values +# note: MUST NOT be covered by checksum! +464 32 r 0 mrc_scrambler_seed +496 32 r 0 mrc_scrambler_seed_s3 +528 16 r 0 mrc_scrambler_seed_chk + +# ----------------------------------------------------------------- +# coreboot config options: check sums +544 16 h 0 check_sum + +# ----------------------------------------------------------------- + +enumerations +#ID value text + +# Generic on/off enum +1 0 Disable +1 1 Enable + +# boot_option +3 0 Fallback +3 1 Normal + +# debug_level +4 0 Emergency +4 1 Alert +4 2 Critical +4 3 Error +4 4 Warning +4 5 Notice +4 6 Info +4 7 Debug +4 8 Spew + +# power_on_after_fail +5 0 Disable +5 1 Enable +5 2 Keep + +# sata_mode +6 0 AHCI +6 1 Compatible + +# gfx_uma_size (Intel IGP Video RAM size) +7 0 32M +7 1 64M +7 2 96M +7 3 128M +7 4 160M +7 5 192M +7 6 224M +7 7 256M +7 8 288M +7 9 320M +7 10 352M +7 11 384M +7 12 416M +7 13 448M +7 14 480M +7 15 512M +7 16 544M +7 17 576M +7 18 608M +7 19 640M +7 20 672M +7 21 704M +7 22 736M +7 23 768M +7 24 800M +7 25 832M +7 26 864M +7 27 896M +7 28 928M +7 29 960M +7 30 992M + +# usb3_mode +# Disable = Use the port always as USB 2.0 for compatibility +# Enable = Use the port always as USB 3.0 for speed +# Auto = Initialize the port as USB 2.0, until the OS loads +# xHCI USB 3.0 driver +# SmartAuto = Same as Auto but, if the OS loads the xHCI USB 3.0 driver +# and the computer is reset, keep the USB 3.0 mode. +# +8 0 Disable +8 1 Enable +8 2 Auto +8 3 SmartAuto + +# ----------------------------------------------------------------- +# +# +checksums + +checksum 392 431 544 diff --git a/src/mainboard/asus/p8z77-m_pro/data.vbt b/src/mainboard/asus/p8z77-m_pro/data.vbt new file mode 100644 index 0000000000..34679b36a9 Binary files /dev/null and b/src/mainboard/asus/p8z77-m_pro/data.vbt differ diff --git a/src/mainboard/asus/p8z77-m_pro/devicetree.cb b/src/mainboard/asus/p8z77-m_pro/devicetree.cb new file mode 100644 index 0000000000..4f5e5bf9bb --- /dev/null +++ b/src/mainboard/asus/p8z77-m_pro/devicetree.cb @@ -0,0 +1,109 @@ +## +## This file is part of the coreboot project. +## +## Copyright (C) 2019 Vlado Cibic +## +## 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. +## + +chip northbridge/intel/sandybridge + register "gfx.did" = "{ 0x80000100, 0x80000240, 0x80000410 }" + register "gfx.ndid" = "3" + device cpu_cluster 0x0 on + chip cpu/intel/model_206ax + register "c1_acpower" = "1" + register "c1_battery" = "1" + register "c2_acpower" = "3" + register "c2_battery" = "3" + register "c3_acpower" = "5" + register "c3_battery" = "5" + device lapic 0x0 on end + device lapic 0xacac off end + end + end + device domain 0x0 on + subsystemid 0x1043 0x84ca inherit + device pci 00.0 on end # Host bridge + device pci 01.0 on end # PCIe Bridge for discrete graphics + device pci 02.0 on end # Internal graphics VGA controller + chip southbridge/intel/bd82x6x # Intel Series 6 Cougar Point PCH + register "c2_latency" = "0x0065" + register "gen1_dec" = "0x000c0291" + register "gen4_dec" = "0x0000ff29" + register "pcie_port_coalesce" = "1" + register "sata_interface_speed_support" = "0x3" # 0x3=SATAIII + register "sata_port_map" = "0x3f" # Enable the six SATA ports + register "spi_lvscc" = "0x2005" + register "spi_uvscc" = "0x2005" + register "superspeed_capable_ports" = "0x0000000f" + register "xhci_overcurrent_mapping" = "0x00000c03" + register "xhci_switchable_ports" = "0x0000000f" # the 4 ports + device pci 14.0 on end # USB 3.0 Controller + device pci 16.0 on end # Management Engine Interface 1 + device pci 16.1 off end # Management Engine Interface 2 + device pci 16.2 off end # Management Engine IDE-R + device pci 16.3 off end # Management Engine KT + device pci 19.0 off end # Intel Gigabit Ethernet + device pci 1a.0 on end # USB2 EHCI 2 + device pci 1b.0 on end # High Definition Audio controller + device pci 1c.0 on end # PCIe Root Port 1 PCIEX_16_3 + device pci 1c.1 on end # PCIe Root Port 6 RTL8111F + device pci 1c.2 off end # PCIe Port 3 unused + device pci 1c.3 off end # PCIe Port 4 unused + device pci 1c.4 off end # PCIe Port 5 unused + device pci 1c.5 on end # PCIe Root Port 7 ASM1042 USB3 + device pci 1c.6 on end # PCIe Root Port 8 ASM1061 eSATA + device pci 1c.7 off end # PCIe Port 8 unused + device pci 1d.0 on end # USB2 EHCI 1 + device pci 1e.0 off end # PCI bridge + device pci 1f.0 on # LPC bridge + chip superio/nuvoton/nct6779d + device pnp 2e.1 off end # Parallel + device pnp 2e.2 off end # UART A + device pnp 2e.3 on # UART B, IR + io 0x60 = 0x2f8 # COM2 address + end + device pnp 2e.5 on # PS2 KBC + io 0x60 = 0x0060 # KBC1 base + io 0x62 = 0x0064 # KBC2 base + irq 0x70 = 1 # Keyboard IRQ + irq 0x72 = 12 # Mouse IRQ + + # KBC 12Mhz/A20 speed/sw KBRST + drq 0xf0 = 0x82 + end + device pnp 2e.6 off end # CIR + device pnp 2e.7 on end # GPIOs 6-8 + device pnp 2e.8 off end # WDT1 GPIO 0-1 + device pnp 2e.9 off end # GPIO 1-8 + device pnp 2e.a on # ACPI + drq 0xe4 = 0x10 # Enable 3VSBS to power RAM on S3 + drq 0xe7 = 0x10 # 0.5s S3 delay for compatibility + end + device pnp 2e.b off end # HWM, LED + device pnp 2e.d off end # WDT1 + device pnp 2e.e off end # CIR wake-up + device pnp 2e.f on # GPIO PP/OD + drq 0xe6 = 0x7f # GP7 PP + end + device pnp 2e.14 on end # Port 80 UART + device pnp 2e.16 off end # Deep sleep + end + chip drivers/pc80/tpm + device pnp 4e.0 on end # TPM module + end + end + device pci 1f.2 on end # SATA Controller 1 + device pci 1f.3 on end # SMBus + device pci 1f.5 off end # SATA Controller 2 + device pci 1f.6 off end # Thermal + end + end +end diff --git a/src/mainboard/asus/p8z77-m_pro/dsdt.asl b/src/mainboard/asus/p8z77-m_pro/dsdt.asl new file mode 100644 index 0000000000..89ad30c997 --- /dev/null +++ b/src/mainboard/asus/p8z77-m_pro/dsdt.asl @@ -0,0 +1,43 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2019 Vlado Cibic + * + * 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. + */ + +#define ACPI_VIDEO_DEVICE \_SB.PCI0.GFX0 + +#include +DefinitionBlock( + "dsdt.aml", + "DSDT", + 0x02, /* DSDT revision: ACPI 2.0 and up */ + OEM_ID, + ACPI_TABLE_CREATOR, + 0x20141018 /* OEM revision */ +) +{ + #include "acpi/platform.asl" + #include "acpi/superio.asl" + #include + #include + + #include + #include + + Device (\_SB.PCI0) + { + #include + #include + #include + } +} diff --git a/src/mainboard/asus/p8z77-m_pro/gma-mainboard.ads b/src/mainboard/asus/p8z77-m_pro/gma-mainboard.ads new file mode 100644 index 0000000000..f9dd430d24 --- /dev/null +++ b/src/mainboard/asus/p8z77-m_pro/gma-mainboard.ads @@ -0,0 +1,31 @@ +-- +-- This file is part of the coreboot project. +-- +-- Copyright (C) 2019 Vlado Cibic +-- +-- 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. +-- + +with HW.GFX.GMA; +with HW.GFX.GMA.Display_Probing; + +use HW.GFX.GMA; +use HW.GFX.GMA.Display_Probing; + +private package GMA.Mainboard is + + ports : constant Port_List := + (HDMI1, -- DVI-D port on rear + HDMI3, -- real HDMI port on rear + Analog, -- VGA port on rear + others => Disabled); + +end GMA.Mainboard; diff --git a/src/mainboard/asus/p8z77-m_pro/gpio.c b/src/mainboard/asus/p8z77-m_pro/gpio.c new file mode 100644 index 0000000000..c8842159d3 --- /dev/null +++ b/src/mainboard/asus/p8z77-m_pro/gpio.c @@ -0,0 +1,198 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2008-2009 coresystems GmbH + * Copyright (C) 2014 Vladimir Serbinenko + * Copyright (C) 2019 Vlado Cibic + * + * 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 + +static const struct pch_gpio_set1 pch_gpio_set1_mode = { + .gpio0 = GPIO_MODE_GPIO, + .gpio1 = GPIO_MODE_GPIO, + .gpio2 = GPIO_MODE_NATIVE, + .gpio3 = GPIO_MODE_NATIVE, + .gpio4 = GPIO_MODE_NATIVE, + .gpio5 = GPIO_MODE_NATIVE, + .gpio6 = GPIO_MODE_GPIO, + .gpio7 = GPIO_MODE_GPIO, + .gpio8 = GPIO_MODE_GPIO, + .gpio9 = GPIO_MODE_NATIVE, + .gpio10 = GPIO_MODE_NATIVE, + .gpio11 = GPIO_MODE_NATIVE, + .gpio12 = GPIO_MODE_GPIO, + .gpio13 = GPIO_MODE_GPIO, + .gpio14 = GPIO_MODE_NATIVE, + .gpio15 = GPIO_MODE_GPIO, + .gpio16 = GPIO_MODE_GPIO, + .gpio17 = GPIO_MODE_GPIO, + .gpio18 = GPIO_MODE_NATIVE, + .gpio19 = GPIO_MODE_NATIVE, + .gpio20 = GPIO_MODE_NATIVE, + .gpio21 = GPIO_MODE_GPIO, + .gpio22 = GPIO_MODE_NATIVE, + .gpio23 = GPIO_MODE_NATIVE, + .gpio24 = GPIO_MODE_GPIO, + .gpio25 = GPIO_MODE_NATIVE, + .gpio26 = GPIO_MODE_NATIVE, + .gpio27 = GPIO_MODE_GPIO, + .gpio28 = GPIO_MODE_GPIO, + .gpio29 = GPIO_MODE_GPIO, + .gpio30 = GPIO_MODE_NATIVE, + .gpio31 = GPIO_MODE_GPIO, +}; + +static const struct pch_gpio_set1 pch_gpio_set1_direction = { + .gpio0 = GPIO_DIR_INPUT, + .gpio1 = GPIO_DIR_INPUT, + .gpio6 = GPIO_DIR_INPUT, + .gpio7 = GPIO_DIR_INPUT, + .gpio8 = GPIO_DIR_OUTPUT, + .gpio12 = GPIO_DIR_OUTPUT, + .gpio13 = GPIO_DIR_INPUT, + .gpio15 = GPIO_DIR_OUTPUT, + .gpio16 = GPIO_DIR_INPUT, + .gpio17 = GPIO_DIR_INPUT, + .gpio21 = GPIO_DIR_INPUT, + .gpio24 = GPIO_DIR_OUTPUT, + .gpio27 = GPIO_DIR_INPUT, + .gpio28 = GPIO_DIR_OUTPUT, + .gpio29 = GPIO_DIR_OUTPUT, + .gpio31 = GPIO_DIR_OUTPUT, +}; + +static const struct pch_gpio_set1 pch_gpio_set1_level = { + .gpio8 = GPIO_LEVEL_HIGH, + .gpio12 = GPIO_LEVEL_LOW, + .gpio15 = GPIO_LEVEL_LOW, + .gpio24 = GPIO_LEVEL_LOW, + .gpio28 = GPIO_LEVEL_LOW, + .gpio29 = GPIO_LEVEL_HIGH, + .gpio31 = GPIO_LEVEL_HIGH, +}; + +static const struct pch_gpio_set1 pch_gpio_set1_reset = { +}; + +static const struct pch_gpio_set1 pch_gpio_set1_invert = { + .gpio1 = GPIO_INVERT, + .gpio13 = GPIO_INVERT, +}; + +static const struct pch_gpio_set1 pch_gpio_set1_blink = { +}; + +static const struct pch_gpio_set2 pch_gpio_set2_mode = { + .gpio32 = GPIO_MODE_GPIO, + .gpio33 = GPIO_MODE_GPIO, + .gpio34 = GPIO_MODE_GPIO, + .gpio35 = GPIO_MODE_NATIVE, + .gpio36 = GPIO_MODE_NATIVE, + .gpio37 = GPIO_MODE_NATIVE, + .gpio38 = GPIO_MODE_NATIVE, + .gpio39 = GPIO_MODE_NATIVE, + .gpio40 = GPIO_MODE_NATIVE, + .gpio41 = GPIO_MODE_NATIVE, + .gpio42 = GPIO_MODE_NATIVE, + .gpio43 = GPIO_MODE_NATIVE, + .gpio44 = GPIO_MODE_NATIVE, + .gpio45 = GPIO_MODE_GPIO, + .gpio46 = GPIO_MODE_GPIO, + .gpio47 = GPIO_MODE_NATIVE, + .gpio48 = GPIO_MODE_NATIVE, + .gpio49 = GPIO_MODE_GPIO, + .gpio50 = GPIO_MODE_NATIVE, + .gpio51 = GPIO_MODE_NATIVE, + .gpio52 = GPIO_MODE_NATIVE, + .gpio53 = GPIO_MODE_NATIVE, + .gpio54 = GPIO_MODE_NATIVE, + .gpio55 = GPIO_MODE_NATIVE, + .gpio56 = GPIO_MODE_NATIVE, + .gpio57 = GPIO_MODE_GPIO, + .gpio58 = GPIO_MODE_NATIVE, + .gpio59 = GPIO_MODE_NATIVE, + .gpio60 = GPIO_MODE_NATIVE, + .gpio61 = GPIO_MODE_NATIVE, + .gpio62 = GPIO_MODE_NATIVE, + .gpio63 = GPIO_MODE_NATIVE, +}; + +static const struct pch_gpio_set2 pch_gpio_set2_direction = { + .gpio32 = GPIO_DIR_OUTPUT, + .gpio33 = GPIO_DIR_OUTPUT, + .gpio34 = GPIO_DIR_INPUT, + .gpio45 = GPIO_DIR_INPUT, + .gpio46 = GPIO_DIR_INPUT, + .gpio49 = GPIO_DIR_INPUT, + .gpio57 = GPIO_DIR_OUTPUT, +}; + +static const struct pch_gpio_set2 pch_gpio_set2_level = { + .gpio32 = GPIO_LEVEL_HIGH, + .gpio33 = GPIO_LEVEL_HIGH, + .gpio57 = GPIO_LEVEL_LOW, +}; + +static const struct pch_gpio_set2 pch_gpio_set2_reset = { +}; + +static const struct pch_gpio_set3 pch_gpio_set3_mode = { + .gpio64 = GPIO_MODE_NATIVE, + .gpio65 = GPIO_MODE_NATIVE, + .gpio66 = GPIO_MODE_NATIVE, + .gpio67 = GPIO_MODE_NATIVE, + .gpio68 = GPIO_MODE_GPIO, + .gpio69 = GPIO_MODE_GPIO, + .gpio70 = GPIO_MODE_NATIVE, + .gpio71 = GPIO_MODE_NATIVE, + .gpio72 = GPIO_MODE_GPIO, + .gpio73 = GPIO_MODE_NATIVE, + .gpio74 = GPIO_MODE_NATIVE, + .gpio75 = GPIO_MODE_NATIVE, +}; + +static const struct pch_gpio_set3 pch_gpio_set3_direction = { + .gpio68 = GPIO_DIR_INPUT, + .gpio69 = GPIO_DIR_INPUT, + .gpio72 = GPIO_DIR_INPUT, +}; + +static const struct pch_gpio_set3 pch_gpio_set3_level = { +}; + +static const struct pch_gpio_set3 pch_gpio_set3_reset = { +}; + +const struct pch_gpio_map mainboard_gpio_map = { + .set1 = { + .mode = &pch_gpio_set1_mode, + .direction = &pch_gpio_set1_direction, + .level = &pch_gpio_set1_level, + .blink = &pch_gpio_set1_blink, + .invert = &pch_gpio_set1_invert, + .reset = &pch_gpio_set1_reset, + }, + .set2 = { + .mode = &pch_gpio_set2_mode, + .direction = &pch_gpio_set2_direction, + .level = &pch_gpio_set2_level, + .reset = &pch_gpio_set2_reset, + }, + .set3 = { + .mode = &pch_gpio_set3_mode, + .direction = &pch_gpio_set3_direction, + .level = &pch_gpio_set3_level, + .reset = &pch_gpio_set3_reset, + }, +}; diff --git a/src/mainboard/asus/p8z77-m_pro/hda_verb.c b/src/mainboard/asus/p8z77-m_pro/hda_verb.c new file mode 100644 index 0000000000..4fd3fcc5e3 --- /dev/null +++ b/src/mainboard/asus/p8z77-m_pro/hda_verb.c @@ -0,0 +1,57 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2008-2009 coresystems GmbH + * Copyright (C) 2014 Vladimir Serbinenko + * Copyright (C) 2019 Vlado Cibic + * + * 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 + +const u32 cim_verb_data[] = { + 0x10ec0892, /* Codec Vendor / Device ID: Realtek */ + 0x10438436, /* Subsystem ID */ + + 0x0000000f, /* Number of 4 dword sets */ + /* Subsystem ID */ + AZALIA_SUBVENDOR(0x0, 0x10438436), + + AZALIA_PIN_CFG(0x0, 0x11, 0x99430140), + AZALIA_PIN_CFG(0x0, 0x12, 0x411111f0), + AZALIA_PIN_CFG(0x0, 0x14, 0x01014010), + AZALIA_PIN_CFG(0x0, 0x15, 0x01011012), + AZALIA_PIN_CFG(0x0, 0x16, 0x01016011), + AZALIA_PIN_CFG(0x0, 0x17, 0x01012014), + AZALIA_PIN_CFG(0x0, 0x18, 0x01a19850), + AZALIA_PIN_CFG(0x0, 0x19, 0x02a19c60), + AZALIA_PIN_CFG(0x0, 0x1a, 0x0181305f), + AZALIA_PIN_CFG(0x0, 0x1b, 0x02214c20), + AZALIA_PIN_CFG(0x0, 0x1c, 0x411111f0), + AZALIA_PIN_CFG(0x0, 0x1d, 0x4005e601), + AZALIA_PIN_CFG(0x0, 0x1e, 0x01456130), + AZALIA_PIN_CFG(0x0, 0x1f, 0x411111f0), + 0x80862806, /* Codec Vendor / Device ID: Intel */ + 0x80860101, /* Subsystem ID */ + + 0x00000004, /* Number of 4 dword sets */ + /* Subsystem ID */ + AZALIA_SUBVENDOR(0x3, 0x80860101), + + AZALIA_PIN_CFG(0x3, 0x05, 0x58560010), + AZALIA_PIN_CFG(0x3, 0x06, 0x58560020), + AZALIA_PIN_CFG(0x3, 0x07, 0x18560030), +}; + +const u32 pc_beep_verbs[0] = {}; + +AZALIA_ARRAY_SIZES; diff --git a/src/mainboard/asus/p8z77-m_pro/mainboard.c b/src/mainboard/asus/p8z77-m_pro/mainboard.c new file mode 100644 index 0000000000..6cb41cc738 --- /dev/null +++ b/src/mainboard/asus/p8z77-m_pro/mainboard.c @@ -0,0 +1,30 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2019 Vlado Cibic + * + * 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 + +static void mainboard_enable(struct device *dev) +{ + install_intel_vga_int15_handler(GMA_INT15_ACTIVE_LFP_NONE, + GMA_INT15_PANEL_FIT_DEFAULT, + GMA_INT15_BOOT_DISPLAY_DEFAULT, + 0); +} + +struct chip_operations mainboard_ops = { + .enable_dev = mainboard_enable +}; diff --git a/src/mainboard/asus/p8z77-m_pro/romstage.c b/src/mainboard/asus/p8z77-m_pro/romstage.c new file mode 100644 index 0000000000..b5593ec23c --- /dev/null +++ b/src/mainboard/asus/p8z77-m_pro/romstage.c @@ -0,0 +1,193 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2019 Vlado Cibic + * + * 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 + +#include +#include +#include + +#define GLOBAL_DEV PNP_DEV(0x2e, 0) +#define SERIAL_DEV PNP_DEV(0x2e, NCT6779D_SP2) + +void pch_enable_lpc(void) +{ + pci_write_config16(PCH_LPC_DEV, LPC_EN, + CNF1_LPC_EN | CNF2_LPC_EN | + KBC_LPC_EN | COMB_LPC_EN); + + /* Set COMB/COM2 IO range to 2F8h-2FFh */ + pci_write_config16(PCH_LPC_DEV, LPC_IO_DEC, 0x10); +} + +void mainboard_rcba_config(void) +{ +} + +const struct southbridge_usb_port mainboard_usb_ports[] = { + /* {enable, current, oc_pin} */ + { 1, 2, 0 }, /* Port 0: USB3 front internal header, top */ + { 1, 2, 0 }, /* Port 1: USB3 front internal header, bottom */ + { 1, 2, 1 }, /* Port 2: USB3 rear, ETH top */ + { 1, 2, 1 }, /* Port 3: USB3 rear, ETH bottom */ + { 1, 2, 2 }, /* Port 4: USB2 rear, PS2 top */ + { 1, 2, 2 }, /* Port 5: USB2 rear, PS2 bottom */ + { 1, 2, 3 }, /* Port 6: USB2 internal header USB78, top */ + { 1, 2, 3 }, /* Port 7: USB2 internal header USB78, bottom */ + { 1, 2, 4 }, /* Port 8: USB2 internal header USB910, top */ + { 1, 2, 4 }, /* Port 9: USB2 internal header USB910, bottom */ + { 1, 2, 6 }, /* Port 10: USB2 internal header USB1112, top */ + { 1, 2, 5 }, /* Port 11: USB2 internal header USB1112, bottom */ + { 0, 2, 5 }, /* Port 12: Unused. Asus propietary DEBUG_PORT ??? */ + { 0, 2, 6 } /* Port 13: Unused. Asus propietary DEBUG_PORT ??? */ +}; + +void mainboard_early_init(int s3resume) +{ +} + +void mainboard_config_superio(void) +{ + /* Setup COM/UART */ + nuvoton_pnp_enter_conf_state(GLOBAL_DEV); + + /* TODO / FIXME: Setup Multifuncion/SIO pins for COM */ + + pnp_set_logical_device(SERIAL_DEV); + nuvoton_pnp_exit_conf_state(GLOBAL_DEV); + nuvoton_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE); +} + +void mainboard_get_spd(spd_raw_data *spd, bool id_only) +{ + read_spd(&spd[0], 0x50, id_only); + read_spd(&spd[1], 0x51, id_only); + read_spd(&spd[2], 0x52, id_only); + read_spd(&spd[3], 0x53, id_only); +} + +int mainboard_should_reset_usb(int s3resume) +{ + return !s3resume; +} + +void mainboard_fill_pei_data(struct pei_data *pei_data) +{ + /* + * USB3 mode: + * 0 = Disable: work always as USB 2.0(ehci) + * 1 = Enable: work always as USB 3.0(xhci) + * 2 = Auto: work as USB2.0(ehci) until OS loads USB3 xhci driver + * 3 = Smart Auto : same than Auto, but if OS loads USB3 driver + * and reboots, it will keep the USB3.0 speed + */ + int usb3_mode = 1; + get_option(&usb3_mode, "usb3_mode"); + usb3_mode &= 0x3; /* ensure it's 0/1/2/3 only */ + + /* Load USB3 pre-OS xHCI driver */ + int usb3_drv = 1; + get_option(&usb3_drv, "usb3_drv"); + usb3_drv &= 0x1; /* ensure it's 0/1 only */ + + /* Use USB3 xHCI streams */ + int usb3_streams = 1; + get_option(&usb3_streams, "usb3_streams"); + usb3_streams &= 0x1; /* ensure it's 0/1 only */ + + struct pei_data pd = { + .pei_version = PEI_VERSION, + .mchbar = (uintptr_t)DEFAULT_MCHBAR, + .dmibar = (uintptr_t)DEFAULT_DMIBAR, + .epbar = DEFAULT_EPBAR, + .pciexbar = CONFIG_MMCONF_BASE_ADDRESS, + .smbusbar = SMBUS_IO_BASE, + .wdbbar = 0x4000000, + .wdbsize = 0x1000, + .hpet_address = CONFIG_HPET_ADDRESS, + .rcba = (uintptr_t)DEFAULT_RCBABASE, + .pmbase = DEFAULT_PMBASE, + .gpiobase = DEFAULT_GPIOBASE, + .thermalbase = 0xfed08000, + .system_type = 1, /* 0=Mobile, 1=Desktop/Server */ + .tseg_size = CONFIG_SMM_TSEG_SIZE, + .spd_addresses = { 0xa0, 0xa2, 0xa4, 0xa6 }, /* SMBus mul 2 */ + .ts_addresses = { 0x00, 0x00, 0x00, 0x00 }, + .ec_present = 0, /* Asus 2203 bios shows XUECA016, but no EC */ + .gbe_enable = 0, /* Board uses no Intel GbE but a RTL8111F */ + .dimm_channel0_disabled = 0, /* Both DIMM enabled */ + .dimm_channel1_disabled = 0, /* Both DIMM enabled */ + .max_ddr3_freq = 1600, /* 1333=Sandy; 1600=Ivy */ + .usb_port_config = { + /* {enabled, oc_pin, cable len 0x0080=<8inches/20cm} */ + { 1, 0, 0x0080 }, /* USB3 front internal header */ + { 1, 0, 0x0080 }, /* USB3 front internal header */ + { 1, 1, 0x0080 }, /* USB3 ETH top connector */ + { 1, 1, 0x0080 }, /* USB3 ETH botton connector */ + { 1, 2, 0x0080 }, /* USB2 PS2 top connector */ + { 1, 2, 0x0080 }, /* USB2 PS2 botton connector */ + { 1, 3, 0x0080 }, /* USB2 internal header (USB78) */ + { 1, 3, 0x0080 }, /* USB2 internal header (USB78) */ + { 1, 4, 0x0080 }, /* USB2 internal header (USB910) */ + { 1, 4, 0x0080 }, /* USB2 internal header (USB910) */ + { 1, 6, 0x0080 }, /* USB2 internal header (USB1112) */ + { 1, 5, 0x0080 }, /* USB2 internal header (USB1112) */ + { 0, 5, 0x0080 }, /* Unused. Asus DEBUG_PORT ??? */ + { 0, 6, 0x0080 } /* Unused. Asus DEBUG_PORT ??? */ + }, + .usb3 = { + /* 0=Disable; 1=Enable (start at USB3 speed) + * 2=Auto (start as USB2 speed until OS loads) + * 3=Smart Auto (like Auto but keep speed on reboot) + */ + usb3_mode, + /* 4 bit switch mask. 0=not switchable, 1=switchable + * Means once it's loaded the OS, it can swap ports + * from/to EHCI/xHCI. Z77 has four USB3 ports, so 0xf + */ + 0xf, + usb3_drv, /* 1=Load xHCI pre-OS drv */ + /* 0=Don't use xHCI streams for better compatibility + * 1=use xHCI streams for better speed + */ + usb3_streams + }, + /* ASUS P8Z77-M Pro manual says 1.35v DIMMs are supported */ + .ddr3lv_support = 1, + /* PCIe 3.0 support. As we use Ivy Bridge, let's enable it, + * but might cause some system inestability ! + */ + .pcie_init = 1, + /* Command Rate. 0=Auto; 1=1N; 2=2N. + * Leave it always at Auto for compatibility & stability + */ + .nmode = 0, + /* DDR refresh rate. 0=Auto based on DRAM's temperature; + * 1=Normal rate for speed; 2=Double rate for stability + */ + .ddr_refresh_rate_config = 0 + }; + + /* copy the data to output PEI */ + *pei_data = pd; +} diff --git a/src/mainboard/compulab/intense_pc/romstage.c b/src/mainboard/compulab/intense_pc/romstage.c index 6d0b3af8c0..6c3d980b65 100644 --- a/src/mainboard/compulab/intense_pc/romstage.c +++ b/src/mainboard/compulab/intense_pc/romstage.c @@ -33,12 +33,6 @@ void pch_enable_lpc(void) u16 lpc_config = CNF1_LPC_EN | CNF2_LPC_EN; pci_write_config16(dev, LPC_EN, lpc_config); - /* Map 1 byte to the LPC bus. */ - pci_write_config32(dev, LPC_GEN1_DEC, 0x00164d); - - /* Map a range for the runtime_port registers to the LPC bus. */ - pci_write_config32(dev, LPC_GEN2_DEC, 0xc0181); - #if CONFIG(DRIVERS_UART_8250IO) /* Enable COM1 */ if (sio1007_enable_uart_at(SIO_PORT)) { diff --git a/src/mainboard/emulation/qemu-q35/acpi_tables.c b/src/mainboard/emulation/qemu-q35/acpi_tables.c index 2c6a2ecd25..a609b5df38 100644 --- a/src/mainboard/emulation/qemu-q35/acpi_tables.c +++ b/src/mainboard/emulation/qemu-q35/acpi_tables.c @@ -49,7 +49,7 @@ void acpi_create_fadt(acpi_fadt_t * fadt, acpi_facs_t * facs, void *dsdt) memset((void *) fadt, 0, sizeof(acpi_fadt_t)); memcpy(header->signature, "FACP", 4); header->length = sizeof(acpi_fadt_t); - header->revision = 3; + header->revision = get_acpi_table_revision(FADT); memcpy(header->oem_id, OEM_ID, 6); memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); memcpy(header->asl_compiler_id, ASLC, 4); diff --git a/src/mainboard/emulation/qemu-riscv/Kconfig b/src/mainboard/emulation/qemu-riscv/Kconfig index d15c99e966..f0f658d0d9 100644 --- a/src/mainboard/emulation/qemu-riscv/Kconfig +++ b/src/mainboard/emulation/qemu-riscv/Kconfig @@ -37,9 +37,9 @@ config BOARD_SPECIFIC_OPTIONS def_bool y select SOC_UCB_RISCV select BOARD_ROMSIZE_KB_4096 - select HAVE_UART_SPECIAL select BOOT_DEVICE_NOT_SPI_FLASH select MISSING_BOARD_RESET + select DRIVERS_UART_8250MEM config MAINBOARD_DIR string diff --git a/src/mainboard/emulation/qemu-riscv/memlayout.ld b/src/mainboard/emulation/qemu-riscv/memlayout.ld index 032fbddecf..7f8ec3dd6a 100644 --- a/src/mainboard/emulation/qemu-riscv/memlayout.ld +++ b/src/mainboard/emulation/qemu-riscv/memlayout.ld @@ -15,15 +15,18 @@ #include #include +#include -#define START 0x80000000 +//Stages start after CBFS in DRAM +#define STAGES_START (QEMU_VIRT_DRAM + CONFIG_ROM_SIZE) SECTIONS { - DRAM_START(START) - BOOTBLOCK(START, 64K) - STACK(START + 4M, 4K) - ROMSTAGE(START + 4M + 64K, 128K) - PRERAM_CBMEM_CONSOLE(START + 4M + 192K, 8K) - RAMSTAGE(START + 4M + 200K, 16M) + DRAM_START(QEMU_VIRT_DRAM) + BOOTBLOCK(QEMU_VIRT_DRAM, 64K) + // CBFS goes here + STACK(STAGES_START, 4K) + ROMSTAGE(STAGES_START + 64K, 128K) + PRERAM_CBMEM_CONSOLE(STAGES_START + 192K, 8K) + RAMSTAGE(STAGES_START + 200K, 16M) } diff --git a/src/mainboard/emulation/qemu-riscv/uart.c b/src/mainboard/emulation/qemu-riscv/uart.c index 021713a40a..271e994493 100644 --- a/src/mainboard/emulation/qemu-riscv/uart.c +++ b/src/mainboard/emulation/qemu-riscv/uart.c @@ -15,42 +15,9 @@ #include #include -#include #include -static uint8_t *buf = (void *)QEMU_VIRT_UART0; uintptr_t uart_platform_base(int idx) { - return (uintptr_t) buf; + return (uintptr_t) QEMU_VIRT_UART0; } - -void uart_init(int idx) -{ -} - -unsigned char uart_rx_byte(int idx) -{ - return *buf; -} - -void uart_tx_byte(int idx, unsigned char data) -{ - *buf = data; -} - -void uart_tx_flush(int idx) -{ -} - -#ifndef __PRE_RAM__ -void uart_fill_lb(void *data) -{ - struct lb_serial serial; - serial.type = LB_SERIAL_TYPE_MEMORY_MAPPED; - serial.baseaddr = QEMU_VIRT_UART0; - serial.baud = 115200; - serial.regwidth = 1; - lb_add_serial(&serial, data); - lb_add_console(LB_TAG_CONSOLE_SERIAL8250MEM, data); -} -#endif diff --git a/src/mainboard/facebook/fbg1701/Kconfig b/src/mainboard/facebook/fbg1701/Kconfig index 3f451945b4..95d8f6caae 100644 --- a/src/mainboard/facebook/fbg1701/Kconfig +++ b/src/mainboard/facebook/fbg1701/Kconfig @@ -54,7 +54,7 @@ config MAINBOARD_PART_NUMBER config CBFS_SIZE hex - default 0x00800000 + default 0x00600000 config CPU_MICROCODE_CBFS_LEN hex @@ -78,14 +78,6 @@ config FSP1_1_DISPLAY_LOGO bool default n -config BOOTBLOCK_LOC - hex - default 0xFFFF0000 - -config BOOTBLOCK_SIZE - hex - default 0x10000 - config SPI_FLASH_INCLUDE_ALL_DRIVERS bool default n diff --git a/src/mainboard/facebook/fbg1701/fadt.c b/src/mainboard/facebook/fbg1701/fadt.c index 73adfad94c..544d24ba55 100644 --- a/src/mainboard/facebook/fbg1701/fadt.c +++ b/src/mainboard/facebook/fbg1701/fadt.c @@ -16,6 +16,7 @@ */ #include +#include void acpi_create_fadt(acpi_fadt_t *fadt, acpi_facs_t *facs, void *dsdt) { @@ -24,11 +25,11 @@ void acpi_create_fadt(acpi_fadt_t *fadt, acpi_facs_t *facs, void *dsdt) memset((void *) fadt, 0, sizeof(acpi_fadt_t)); memcpy(header->signature, "FACP", 4); header->length = sizeof(acpi_fadt_t); - header->revision = 3; + header->revision = get_acpi_table_revision(FADT); memcpy(header->oem_id, OEM_ID, 6); memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); memcpy(header->asl_compiler_id, ASLC, 4); - header->asl_compiler_revision = 1; + header->asl_compiler_revision = asl_revision; fadt->firmware_ctrl = (unsigned long) facs; fadt->dsdt = (unsigned long) dsdt; diff --git a/src/mainboard/facebook/fbg1701/mainboard.c b/src/mainboard/facebook/fbg1701/mainboard.c index ff2564d67a..8524b24000 100644 --- a/src/mainboard/facebook/fbg1701/mainboard.c +++ b/src/mainboard/facebook/fbg1701/mainboard.c @@ -17,8 +17,6 @@ */ #include -#include "onboard.h" -#include "mainboard.h" /* * Declare the resources we are using diff --git a/src/mainboard/facebook/fbg1701/ramstage.c b/src/mainboard/facebook/fbg1701/ramstage.c index 91dfe3b2cf..5c78bccac5 100644 --- a/src/mainboard/facebook/fbg1701/ramstage.c +++ b/src/mainboard/facebook/fbg1701/ramstage.c @@ -1,6 +1,7 @@ /* * This file is part of the coreboot project. * + * Copyright (C) 2018-2019 Facebook, Inc * Copyright (C) 2018-2019 Eltan B.V. * * This program is free software; you can redistribute it and/or modify @@ -13,11 +14,353 @@ * GNU General Public License for more details. */ +#include +#include #include +#include #include "mainboard.h" +#include "onboard.h" + +struct edp_data { + u8 payload_length; + u8 address; + /* data: reg[15:8],reg[7:0], data bytes starting with data[7:0] */ + u8 data[6]; +} __packed; + +static const struct edp_data b101uan01_table[] = { + /* set eDP bridge to 1200x1920 */ + /* IO */ + { 6, 0x68, { 0x08, 0x00, 0x01, 0x00, 0x00, 0x00 } }, + /* Boot */ + { 6, 0x68, { 0x10, 0x00, 0x78, 0x69, 0x00, 0x00 } }, + { 6, 0x68, { 0x10, 0x04, 0x02, 0x08, 0x02, 0x00 } }, + { 6, 0x68, { 0x10, 0x08, 0x23, 0x00, 0x87, 0x02 } }, + { 6, 0x68, { 0x10, 0x0C, 0x19, 0x04, 0x00, 0x23 } }, + { 6, 0x68, { 0x10, 0x10, 0x06, 0x00, 0x67, 0x00 } }, + { 6, 0x68, { 0x10, 0x14, 0x01, 0x00, 0x00, 0x00 } }, + { 6, 0x68, { 0x10, 0x18, 0xFF, 0xFF, 0xFF, 0xFF } }, + /* Internal */ + { 3, 0x68, { 0xB0, 0x05, 0x0A, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB0, 0x06, 0x03, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB0, 0x07, 0x16, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB0, 0x08, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB0, 0x09, 0x21, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB0, 0x0A, 0x07, 0x00, 0x00, 0x00 } }, + { 6, 0x68, { 0x10, 0x14, 0x03, 0x00, 0x00, 0x00 } }, + { 6, 0x68, { 0x10, 0x18, 0xFF, 0xFF, 0xFF, 0xFF } }, + /* eDP */ + { 3, 0x68, { 0x80, 0x03, 0x41, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB4, 0x00, 0x0D, 0x00, 0x00, 0x00 } }, + /* DPRX */ + { 3, 0x68, { 0xB8, 0x8E, 0xFF, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x8F, 0xFF, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x9A, 0xFF, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x9B, 0xFF, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x00, 0x0E, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xBB, 0x26, 0x02, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xBB, 0x01, 0x20, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0xC0, 0xF1, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0xC1, 0xF1, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0xC2, 0xF0, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0xC3, 0xF0, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0xC4, 0xF0, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0xC5, 0xF0, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0xC6, 0xF0, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0xC7, 0xF0, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x0B, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x33, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x5B, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x10, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x38, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x60, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x15, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x3D, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x65, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x1A, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x42, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x6A, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x1F, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x47, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x6F, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x24, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x4C, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x74, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x29, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x51, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x79, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x2E, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x56, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x7E, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xBB, 0x90, 0x10, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xBB, 0x91, 0x0F, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xBB, 0x92, 0xF6, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xBB, 0x93, 0x10, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xBB, 0x94, 0x0F, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xBB, 0x95, 0xF6, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xBB, 0x96, 0x10, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xBB, 0x97, 0x0F, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xBB, 0x98, 0xF6, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xBB, 0x99, 0x10, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xBB, 0x9A, 0x0F, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xBB, 0x9B, 0xF6, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x8A, 0x03, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x96, 0x03, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xBB, 0xD1, 0x07, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xBB, 0xB0, 0x07, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x8B, 0x04, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x8C, 0x45, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x8D, 0x05, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x97, 0x04, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x98, 0xE0, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x99, 0x2E, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0x80, 0x0E, 0x00, 0x00, 0x00, 0x00 } }, + { 6, 0x68, { 0x10, 0x14, 0x07, 0x00, 0x00, 0x00 } }, + { 6, 0x68, { 0x10, 0x18, 0xFF, 0xFF, 0xFF, 0xFF } }, + /* Video size */ + { 6, 0x68, { 0x01, 0x48, 0xB0, 0x04, 0x00, 0x00 } }, + { 6, 0x68, { 0x29, 0x20, 0x10, 0x0E, 0x0B, 0x3E } }, + /* eDP */ + { 3, 0x68, { 0xB6, 0x31, 0xFF, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0x80, 0x01, 0x14, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0x80, 0x02, 0x02, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB6, 0x08, 0x0B, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x00, 0x1E, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0x87, 0x00, 0x00, 0x00, 0x00, 0x00 } }, + { 6, 0x68, { 0x50, 0x10, 0x00, 0x00, 0x9D, 0x00 } }, + { 6, 0x68, { 0x00, 0x8C, 0x40, 0x00, 0x00, 0x00 } }, + { 6, 0x68, { 0x00, 0x80, 0x02, 0x00, 0x00, 0x00 } }, + /* Link Training */ + { 3, 0x68, { 0x82, 0x02, 0xFF, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0x82, 0x03, 0xFF, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0x82, 0x04, 0xFF, 0x00, 0x00, 0x00 } }, + { 6, 0x68, { 0x21, 0x58, 0x09, 0x00, 0x28, 0x00 } }, + { 6, 0x68, { 0x21, 0x60, 0x07, 0x00, 0x0F, 0x00 } }, + { 6, 0x68, { 0x21, 0x64, 0x28, 0x23, 0x00, 0x00 } }, + { 6, 0x68, { 0x21, 0x68, 0x0E, 0x00, 0x00, 0x00 } }, + /* DSI */ + { 6, 0x68, { 0x20, 0x7C, 0x81, 0x00, 0x00, 0x00 } }, + { 6, 0x68, { 0x20, 0x50, 0x00, 0x00, 0x00, 0x00 } }, + { 6, 0x68, { 0x20, 0x1C, 0x01, 0x00, 0x00, 0x00 } }, + { 6, 0x68, { 0x20, 0x60, 0xFF, 0xFF, 0xFF, 0xFF } }, + /* GPIO */ + { 6, 0x68, { 0x08, 0x04, 0x00, 0x00, 0x00, 0x00 } }, + { 6, 0x68, { 0x00, 0x80, 0x0F, 0x00, 0x00, 0x00 } }, + { 6, 0x68, { 0x00, 0x84, 0x0F, 0x00, 0x00, 0x00 } }, + { 6, 0x68, { 0x00, 0x84, 0x00, 0x00, 0x00, 0x00 } }, + { 6, 0x68, { 0x00, 0x84, 0x0F, 0x00, 0x00, 0x00 } }, + /* DSI clock */ + { 6, 0x68, { 0x20, 0x50, 0x20, 0x00, 0x00, 0x00 } }, + /* LCD init */ + { 6, 0x68, { 0x22, 0xFC, 0x15, 0x01, 0x00, 0x81 } }, + { 6, 0x68, { 0x22, 0xFC, 0x15, 0x8C, 0x80, 0x81 } }, + { 6, 0x68, { 0x22, 0xFC, 0x15, 0xC7, 0x50, 0x81 } }, + { 6, 0x68, { 0x22, 0xFC, 0x15, 0xC5, 0x50, 0x81 } }, + { 6, 0x68, { 0x22, 0xFC, 0x15, 0x85, 0x04, 0x81 } }, + { 6, 0x68, { 0x22, 0xFC, 0x15, 0x86, 0x08, 0x81 } }, + { 6, 0x68, { 0x22, 0xFC, 0x15, 0x83, 0xAA, 0x81 } }, + { 6, 0x68, { 0x22, 0xFC, 0x15, 0x84, 0x11, 0x81 } }, + { 6, 0x68, { 0x22, 0xFC, 0x15, 0x9C, 0x10, 0x81 } }, + { 6, 0x68, { 0x22, 0xFC, 0x15, 0xA9, 0x4B, 0x81 } }, + { 6, 0x68, { 0x22, 0xFC, 0x05, 0x11, 0x00, 0x81 } }, + { 6, 0x68, { 0x22, 0xFC, 0x05, 0x29, 0x00, 0x81 } }, + { 6, 0x68, { 0x2A, 0x10, 0x10, 0x00, 0x04, 0x80 } }, + { 6, 0x68, { 0x2A, 0x04, 0x01, 0x00, 0x00, 0x00 } }, + /* Check Video */ + { 6, 0x68, { 0x01, 0x54, 0x01, 0x00, 0x00, 0x00 } }, + /* End of table */ + { 0, 0x00, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }, +}; + +static const struct edp_data b101uan08_table[] = { + /* set eDP bridge to 1200x1920 */ + /* IO Voltage Setting */ + { 6, 0x68, { 0x08, 0x00, 0x01, 0x00, 0x00, 0x00 } }, + /* Boot Settings */ + { 6, 0x68, { 0x10, 0x00, 0x78, 0x69, 0x00, 0x00 } }, + { 6, 0x68, { 0x10, 0x04, 0x02, 0x08, 0x02, 0x00 } }, + { 6, 0x68, { 0x10, 0x08, 0x22, 0x00, 0xA0, 0x02 } }, + { 6, 0x68, { 0x10, 0x0C, 0x50, 0x04, 0x00, 0x03 } }, + { 6, 0x68, { 0x10, 0x10, 0x10, 0x0D, 0x06, 0x01 } }, + { 6, 0x68, { 0x10, 0x14, 0x01, 0x00, 0x00, 0x00 } }, + { 6, 0x68, { 0x10, 0x18, 0xFF, 0xFF, 0xFF, 0xFF } }, + /* Internal PCLK settings for Non Present or REFCLK=26MHz */ + { 3, 0x68, { 0xB0, 0x05, 0x0A, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB0, 0x06, 0x03, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB0, 0x07, 0x16, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB0, 0x08, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB0, 0x09, 0x21, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB0, 0x0A, 0x07, 0x00, 0x00, 0x00 } }, + /* DSI Clock setting for Non Preset or REFCLK=26MHz */ + { 6, 0x68, { 0x41, 0xB0, 0xC1, 0x22, 0x04, 0x00 } }, + { 6, 0x68, { 0x41, 0xBC, 0x01, 0x0E, 0x00, 0x00 } }, + { 6, 0x68, { 0x41, 0xC0, 0x30, 0x00, 0x00, 0x00 } }, + { 6, 0x68, { 0x10, 0x14, 0x03, 0x00, 0x00, 0x00 } }, + { 6, 0x68, { 0x10, 0x18, 0xFF, 0xFF, 0xFF, 0xFF } }, + /* Additional Settng for eDP */ + { 3, 0x68, { 0x80, 0x03, 0x41, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB4, 0x00, 0x0D, 0x00, 0x00, 0x00 } }, + /* DPRX CAD Register Setting */ + { 3, 0x68, { 0xB8, 0x8E, 0xFF, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x8F, 0xFF, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x9A, 0xFF, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x9B, 0xFF, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x00, 0x0E, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xBB, 0x26, 0x02, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xBB, 0x01, 0x20, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0xC0, 0xF1, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0xC1, 0xF1, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0xC2, 0xF0, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0xC3, 0xF0, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0xC4, 0xF0, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0xC5, 0xF0, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0xC6, 0xF0, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0xC7, 0xF0, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x0B, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x33, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x5B, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x10, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x38, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x60, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x15, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x3D, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x65, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x1A, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x42, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x6A, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x1F, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x47, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x6F, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x24, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x4C, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x74, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x29, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x51, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x79, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x2E, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x56, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x7E, 0x00, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xBB, 0x90, 0x10, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xBB, 0x91, 0x0F, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xBB, 0x92, 0xF6, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xBB, 0x93, 0x10, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xBB, 0x94, 0x0F, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xBB, 0x95, 0xF6, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xBB, 0x96, 0x10, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xBB, 0x97, 0x0F, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xBB, 0x98, 0xF6, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xBB, 0x99, 0x10, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xBB, 0x9A, 0x0F, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xBB, 0x9B, 0xF6, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x8A, 0x03, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x96, 0x03, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xBB, 0xD1, 0x07, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xBB, 0xB0, 0x07, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x8B, 0x04, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x8C, 0x45, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x8D, 0x05, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x97, 0x04, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x98, 0xE0, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x99, 0x2E, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0x80, 0x0E, 0x00, 0x00, 0x00, 0x00 } }, + { 6, 0x68, { 0x10, 0x14, 0x07, 0x00, 0x00, 0x00 } }, + { 6, 0x68, { 0x10, 0x18, 0xFF, 0xFF, 0xFF, 0xFF } }, + /* Video size Related Settings for Non Present */ + { 6, 0x68, { 0x01, 0x48, 0xB0, 0x04, 0x00, 0x00 } }, + { 6, 0x68, { 0x29, 0x20, 0x10, 0x0E, 0x0B, 0x3E } }, + /* eDP Settings for Link Training*/ + { 3, 0x68, { 0xB6, 0x31, 0xFF, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0x80, 0x01, 0x14, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0x80, 0x02, 0x02, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB6, 0x08, 0x0B, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0xB8, 0x00, 0x1E, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0x87, 0x00, 0x00, 0x00, 0x00, 0x00 } }, + { 6, 0x68, { 0x50, 0x10, 0x00, 0x00, 0x9D, 0x00 } }, + { 6, 0x68, { 0x00, 0x8C, 0x40, 0x00, 0x00, 0x00 } }, + { 6, 0x68, { 0x00, 0x80, 0x02, 0x00, 0x00, 0x00 } }, + /* Link Training */ + { 3, 0x68, { 0x82, 0x02, 0xFF, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0x82, 0x03, 0xFF, 0x00, 0x00, 0x00 } }, + { 3, 0x68, { 0x82, 0x04, 0xFF, 0x00, 0x00, 0x00 } }, + /* DSI Transition Time Setting for Non Preset */ + { 6, 0x68, { 0x21, 0x54, 0x0D, 0x00, 0x00, 0x00 } }, + { 6, 0x68, { 0x21, 0x58, 0x06, 0x00, 0x2A, 0x00 } }, + { 6, 0x68, { 0x21, 0x5C, 0x07, 0x00, 0x0E, 0x00 } }, + { 6, 0x68, { 0x21, 0x60, 0x07, 0x00, 0x10, 0x00 } }, + { 6, 0x68, { 0x21, 0x64, 0x10, 0x27, 0x00, 0x00 } }, + { 6, 0x68, { 0x21, 0x68, 0x0E, 0x00, 0x00, 0x00 } }, + { 6, 0x68, { 0x21, 0x6C, 0x0A, 0x00, 0x0E, 0x00 } }, + { 6, 0x68, { 0x21, 0x78, 0x0E, 0x00, 0x0D, 0x00 } }, + /* DSI Start */ + { 6, 0x68, { 0x20, 0x7C, 0x81, 0x00, 0x00, 0x00 } }, + { 6, 0x68, { 0x20, 0x50, 0x00, 0x00, 0x00, 0x00 } }, + { 6, 0x68, { 0x20, 0x1C, 0x01, 0x00, 0x00, 0x00 } }, + { 6, 0x68, { 0x20, 0x60, 0xFF, 0xFF, 0xFF, 0xFF } }, + /* GPIO for LCD control*/ + { 6, 0x68, { 0x08, 0x04, 0x00, 0x00, 0x00, 0x00 } }, + { 6, 0x68, { 0x00, 0x80, 0x0F, 0x00, 0x00, 0x00 } }, + { 6, 0x68, { 0x00, 0x84, 0x0F, 0x00, 0x00, 0x00 } }, + { 6, 0x68, { 0x00, 0x84, 0x00, 0x00, 0x00, 0x00 } }, + { 6, 0x68, { 0x00, 0x84, 0x0F, 0x00, 0x00, 0x00 } }, + /* DSI Hs Clock Mode */ + { 6, 0x68, { 0x20, 0x50, 0x20, 0x00, 0x00, 0x00 } }, + /* LCD Initialization */ + { 6, 0x68, { 0x22, 0xFC, 0x15, 0xBF, 0xA5, 0x81 } }, + { 6, 0x68, { 0x22, 0xFC, 0x15, 0x01, 0x00, 0x81 } }, + { 6, 0x68, { 0x22, 0xFC, 0x15, 0x8F, 0xA5, 0x81 } }, + { 6, 0x68, { 0x22, 0xFC, 0x15, 0x83, 0xAA, 0x81 } }, + { 6, 0x68, { 0x22, 0xFC, 0x15, 0x84, 0x11, 0x81 } }, + { 6, 0x68, { 0x22, 0xFC, 0x15, 0xA9, 0x48, 0x81 } }, + { 6, 0x68, { 0x22, 0xFC, 0x15, 0x83, 0x00, 0x81 } }, + { 6, 0x68, { 0x22, 0xFC, 0x15, 0x84, 0x00, 0x81 } }, + { 6, 0x68, { 0x22, 0xFC, 0x15, 0x8F, 0x00, 0x81 } }, + { 6, 0x68, { 0x2A, 0x10, 0x10, 0x00, 0x04, 0x80 } }, + { 6, 0x68, { 0x2A, 0x04, 0x01, 0x00, 0x00, 0x00 } }, + /* Check if eDP video is coming */ + { 6, 0x68, { 0x01, 0x54, 0x01, 0x00, 0x00, 0x00 } }, + /* End of table */ + { 0, 0x00, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }, +}; + +static void mainboard_configure_edp_bridge(void) +{ + u8 cpld_version; + const struct edp_data *edptable; + unsigned int loops; + int status; + + cpld_version = (inb(CPLD_PCB_VERSION_PORT) & CPLD_PCB_VERSION_MASK) >> + CPLD_PCB_VERSION_BIT; + printk(BIOS_DEBUG, "CPLD version: %x\n", cpld_version); + if (cpld_version < 7) + edptable = b101uan01_table; + else + edptable = b101uan08_table; + + /* reset bridge */ + outb(CPLD_CMD_RESET_DSI_BRIDGE_ACTIVE, CPLD_RESET_PORT); + outb(CPLD_CMD_RESET_DSI_BRIDGE_INACTIVE, CPLD_RESET_PORT); + + while (edptable->payload_length) { + loops = 5; + do { + status = smbus_i2c_block_write(edptable->address, + edptable->payload_length, + (u8 *)&edptable->data[0]); + } while (--loops && (status < 0)); + + if (loops == 0) { + printk(BIOS_ERR, "Writing eDP bridge failed!\n"); + return; + } + edptable++; + }; +} void mainboard_silicon_init_params(SILICON_INIT_UPD *params) { + mainboard_configure_edp_bridge(); + if (CONFIG(FSP1_1_DISPLAY_LOGO)) { size_t logo_len; void *logo = NULL; diff --git a/src/mainboard/getac/p470/Kconfig b/src/mainboard/getac/p470/Kconfig index a5eed1a659..9fe40bcb8f 100644 --- a/src/mainboard/getac/p470/Kconfig +++ b/src/mainboard/getac/p470/Kconfig @@ -32,7 +32,6 @@ config BOARD_SPECIFIC_OPTIONS select HAVE_ACPI_RESUME select UDELAY_LAPIC select BOARD_ROMSIZE_KB_1024 - select CHANNEL_XOR_RANDOMIZATION select INTEL_INT15 select I945_LVDS diff --git a/src/mainboard/gigabyte/ga-945gcm-s2l/Kconfig b/src/mainboard/gigabyte/ga-945gcm-s2l/Kconfig index ea3142a087..e9ed54d828 100644 --- a/src/mainboard/gigabyte/ga-945gcm-s2l/Kconfig +++ b/src/mainboard/gigabyte/ga-945gcm-s2l/Kconfig @@ -29,7 +29,6 @@ config BOARD_SPECIFIC_OPTIONS select HAVE_ACPI_TABLES select HAVE_ACPI_RESUME select BOARD_ROMSIZE_KB_512 - select CHANNEL_XOR_RANDOMIZATION select MAINBOARD_HAS_NATIVE_VGA_INIT select REALTEK_8168_RESET if BOARD_GIGABYTE_GA_945GCM_S2L select INTEL_GMA_HAVE_VBT diff --git a/src/mainboard/gigabyte/ga-b75m-d3h/romstage.c b/src/mainboard/gigabyte/ga-b75m-d3h/romstage.c index 67bcbcb8c9..b35a8b4af9 100644 --- a/src/mainboard/gigabyte/ga-b75m-d3h/romstage.c +++ b/src/mainboard/gigabyte/ga-b75m-d3h/romstage.c @@ -30,7 +30,6 @@ void pch_enable_lpc(void) pci_write_config16(PCH_LPC_DEV, LPC_EN, KBC_LPC_EN | CNF1_LPC_EN | CNF2_LPC_EN | COMA_LPC_EN); - pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, 0x3c0a01); pci_write_config16(PCH_LPC_DEV, LPC_IO_DEC, 0x10); pci_write_config32(PCH_LPC_DEV, ETR3, 0x10000); diff --git a/src/mainboard/gigabyte/ga-h61m-s2pv/Kconfig b/src/mainboard/gigabyte/ga-h61m-s2pv/Kconfig index 5e46365bba..62d7f40117 100644 --- a/src/mainboard/gigabyte/ga-h61m-s2pv/Kconfig +++ b/src/mainboard/gigabyte/ga-h61m-s2pv/Kconfig @@ -13,7 +13,7 @@ ## GNU General Public License for more details. ## -if BOARD_GIGABYTE_GA_H61M_S2PV +if BOARD_GIGABYTE_GA_H61M_S2PV || BOARD_GIGABYTE_GA_H61MA_D3V config BOARD_SPECIFIC_OPTIONS def_bool y @@ -31,21 +31,36 @@ config BOARD_SPECIFIC_OPTIONS select INTEL_GMA_HAVE_VBT select HAVE_OPTION_TABLE select HAVE_CMOS_DEFAULT + select NO_UART_ON_SUPERIO if BOARD_GIGABYTE_GA_H61MA_D3V config MAINBOARD_DIR string default "gigabyte/ga-h61m-s2pv" +config VARIANT_DIR + string + default "ga-h61m-s2pv" if BOARD_GIGABYTE_GA_H61M_S2PV + default "ga-h61ma-d3v" if BOARD_GIGABYTE_GA_H61MA_D3V + config MAINBOARD_PART_NUMBER string - default "GA-H61M-S2PV" + default "GA-H61M-S2PV" if BOARD_GIGABYTE_GA_H61M_S2PV + default "GA-H61MA-D3V" if BOARD_GIGABYTE_GA_H61MA_D3V + +config DEVICETREE + string + default "variants/$(CONFIG_VARIANT_DIR)/devicetree.cb" config MAX_CPUS int default 8 +# Override the default variant behavior, since the data.vbt is the same +config INTEL_GMA_VBT_FILE + default "src/mainboard/$(MAINBOARDDIR)/data.vbt" + config USBDEBUG_HCD_INDEX # Bottom left port seen from rear int default 2 -endif # BOARD_GIGABYTE_GA_H61M_S2PV +endif # BOARD_GIGABYTE_GA_H61M_S2PV || BOARD_GIGABYTE_GA_H61MA_D3V diff --git a/src/mainboard/gigabyte/ga-h61m-s2pv/Kconfig.name b/src/mainboard/gigabyte/ga-h61m-s2pv/Kconfig.name index 04da3f01cf..83b5803d5f 100644 --- a/src/mainboard/gigabyte/ga-h61m-s2pv/Kconfig.name +++ b/src/mainboard/gigabyte/ga-h61m-s2pv/Kconfig.name @@ -1,2 +1,5 @@ config BOARD_GIGABYTE_GA_H61M_S2PV bool "GA-H61M-S2PV" + +config BOARD_GIGABYTE_GA_H61MA_D3V + bool "GA-H61MA-D3V" diff --git a/src/mainboard/gigabyte/ga-h61m-s2pv/Makefile.inc b/src/mainboard/gigabyte/ga-h61m-s2pv/Makefile.inc index ea035d3876..fe7cc81bb9 100644 --- a/src/mainboard/gigabyte/ga-h61m-s2pv/Makefile.inc +++ b/src/mainboard/gigabyte/ga-h61m-s2pv/Makefile.inc @@ -1,3 +1,4 @@ -romstage-y += gpio.c +romstage-y += variants/$(VARIANT_DIR)/gpio.c +ramstage-y += variants/$(VARIANT_DIR)/hda_verb.c ramstage-$(CONFIG_MAINBOARD_USE_LIBGFXINIT) += gma-mainboard.ads diff --git a/src/mainboard/gigabyte/ga-h61m-s2pv/hda_verb.c b/src/mainboard/gigabyte/ga-h61m-s2pv/hda_verb.c index 15a2b0159c..e69de29bb2 100644 --- a/src/mainboard/gigabyte/ga-h61m-s2pv/hda_verb.c +++ b/src/mainboard/gigabyte/ga-h61m-s2pv/hda_verb.c @@ -1,71 +0,0 @@ -/* - * This file is part of the coreboot project. - * - * Copyright (C) 2018 Angel Pons - * - * 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 - -const u32 cim_verb_data[] = { - 0x10ec0887, /* Codec Vendor / Device ID: Realtek */ - 0x1458a002, /* Subsystem ID */ - - 0x0000000f, /* Number of 4 dword sets */ - /* NID 0x01: Subsystem ID. */ - AZALIA_SUBVENDOR(0x2, 0x1458a002), - - /* NID 0x11. */ - AZALIA_PIN_CFG(0x2, 0x11, 0x411111f0), - - /* NID 0x12. */ - AZALIA_PIN_CFG(0x2, 0x12, 0x411111f0), - - /* NID 0x14. */ - AZALIA_PIN_CFG(0x2, 0x14, 0x01014410), - - /* NID 0x15. */ - AZALIA_PIN_CFG(0x2, 0x15, 0x411111f0), - - /* NID 0x16. */ - AZALIA_PIN_CFG(0x2, 0x16, 0x411111f0), - - /* NID 0x17. */ - AZALIA_PIN_CFG(0x2, 0x17, 0x411111f0), - - /* NID 0x18. */ - AZALIA_PIN_CFG(0x2, 0x18, 0x01a19c50), - - /* NID 0x19. */ - AZALIA_PIN_CFG(0x2, 0x19, 0x02a19c60), - - /* NID 0x1a. */ - AZALIA_PIN_CFG(0x2, 0x1a, 0x0181345f), - - /* NID 0x1b. */ - AZALIA_PIN_CFG(0x2, 0x1b, 0x02214c20), - - /* NID 0x1c. */ - AZALIA_PIN_CFG(0x2, 0x1c, 0x411111f0), - - /* NID 0x1d. */ - AZALIA_PIN_CFG(0x2, 0x1d, 0x4004c601), - - /* NID 0x1e. */ - AZALIA_PIN_CFG(0x2, 0x1e, 0x411111f0), - - /* NID 0x1f. */ - AZALIA_PIN_CFG(0x2, 0x1f, 0x411111f0), -}; - -const u32 pc_beep_verbs[0] = {}; - -AZALIA_ARRAY_SIZES; diff --git a/src/mainboard/gigabyte/ga-h61m-s2pv/romstage.c b/src/mainboard/gigabyte/ga-h61m-s2pv/romstage.c index 7154cc9d22..27fbb2ccc7 100644 --- a/src/mainboard/gigabyte/ga-h61m-s2pv/romstage.c +++ b/src/mainboard/gigabyte/ga-h61m-s2pv/romstage.c @@ -25,10 +25,15 @@ void pch_enable_lpc(void) { - pci_write_config16(PCH_LPC_DEV, LPC_EN, KBC_LPC_EN | - CNF1_LPC_EN | CNF2_LPC_EN | COMA_LPC_EN); + if (CONFIG(BOARD_GIGABYTE_GA_H61M_S2PV)) { + pci_write_config16(PCH_LPC_DEV, LPC_EN, KBC_LPC_EN | + CNF1_LPC_EN | CNF2_LPC_EN | COMA_LPC_EN); + pci_write_config16(PCH_LPC_DEV, LPC_IO_DEC, 0x10); - pci_write_config16(PCH_LPC_DEV, LPC_IO_DEC, 0x10); + } else if (CONFIG(BOARD_GIGABYTE_GA_H61MA_D3V)) { + pci_write_config16(PCH_LPC_DEV, LPC_EN, KBC_LPC_EN | + CNF1_LPC_EN); + } } void mainboard_rcba_config(void) @@ -58,8 +63,10 @@ void mainboard_early_init(int s3resume) void mainboard_config_superio(void) { - /* Enable serial port */ - ite_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE); + if (!CONFIG(NO_UART_ON_SUPERIO)) { + /* Enable serial port */ + ite_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE); + } /* Disable SIO WDT which kicks in DualBIOS */ ite_reg_write(SUPERIO_GPIO, 0xEF, 0x7E); diff --git a/src/mainboard/gigabyte/ga-h61m-s2pv/devicetree.cb b/src/mainboard/gigabyte/ga-h61m-s2pv/variants/ga-h61m-s2pv/devicetree.cb similarity index 92% rename from src/mainboard/gigabyte/ga-h61m-s2pv/devicetree.cb rename to src/mainboard/gigabyte/ga-h61m-s2pv/variants/ga-h61m-s2pv/devicetree.cb index e382cbde7f..e4ec810d45 100644 --- a/src/mainboard/gigabyte/ga-h61m-s2pv/devicetree.cb +++ b/src/mainboard/gigabyte/ga-h61m-s2pv/variants/ga-h61m-s2pv/devicetree.cb @@ -30,6 +30,7 @@ chip northbridge/intel/sandybridge end register "pci_mmio_size" = "2048" device domain 0x0 on + subsystemid 0x1458 0x5000 inherit device pci 00.0 on end # Host bridge device pci 01.0 on end # PCIe Bridge for discrete graphics (PCIEX16) device pci 02.0 on end # Internal graphics VGA controller @@ -57,7 +58,7 @@ chip northbridge/intel/sandybridge device pci 1c.6 off end # Unused PCIe Port device pci 1c.7 off end # Unused PCIe Port device pci 1d.0 on end # USB2 EHCI #1 - device pci 1e.0 on end # PCI bridge + device pci 1e.0 off end # PCI bridge device pci 1f.0 on # LPC bridge chip superio/ite/it8728f device pnp 2e.0 off end # Floppy, not routed. @@ -84,13 +85,15 @@ chip northbridge/intel/sandybridge device pnp 2e.6 on # Mouse irq 0x70 = 12 end - device pnp 2e.7 off # GPIO - io 0x25 = 0x40 - io 0x27 = 0x10 - io 0x2c = 0x80 + device pnp 2e.7 on # GPIO + irq 0x25 = 0x40 + irq 0x27 = 0x10 + irq 0x2c = 0x80 + io 0x60 = 0x0000 io 0x62 = 0x0a00 - io 0xcb = 0x00 - io 0xf1 = 0x40 + io 0x64 = 0x0000 + irq 0xcb = 0x00 + irq 0xf1 = 0x40 end device pnp 2e.a off end # CIR, not routed. end diff --git a/src/mainboard/gigabyte/ga-h61m-s2pv/gpio.c b/src/mainboard/gigabyte/ga-h61m-s2pv/variants/ga-h61m-s2pv/gpio.c similarity index 100% rename from src/mainboard/gigabyte/ga-h61m-s2pv/gpio.c rename to src/mainboard/gigabyte/ga-h61m-s2pv/variants/ga-h61m-s2pv/gpio.c diff --git a/src/mainboard/gigabyte/ga-h61m-s2pv/variants/ga-h61m-s2pv/hda_verb.c b/src/mainboard/gigabyte/ga-h61m-s2pv/variants/ga-h61m-s2pv/hda_verb.c new file mode 100644 index 0000000000..93c7e11618 --- /dev/null +++ b/src/mainboard/gigabyte/ga-h61m-s2pv/variants/ga-h61m-s2pv/hda_verb.c @@ -0,0 +1,42 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2018 Angel Pons + * + * 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 + +const u32 cim_verb_data[] = { + 0x10ec0887, /* Realtek ALC887 */ + 0x1458a002, /* Subsystem ID */ + 0x0000000f, /* Number of 4 dword sets */ + AZALIA_SUBVENDOR(0x2, 0x1458a002), + AZALIA_PIN_CFG(0x2, 0x11, 0x411111f0), + AZALIA_PIN_CFG(0x2, 0x12, 0x411111f0), + AZALIA_PIN_CFG(0x2, 0x14, 0x01014410), + AZALIA_PIN_CFG(0x2, 0x15, 0x411111f0), + AZALIA_PIN_CFG(0x2, 0x16, 0x411111f0), + AZALIA_PIN_CFG(0x2, 0x17, 0x411111f0), + AZALIA_PIN_CFG(0x2, 0x18, 0x01a19c50), + AZALIA_PIN_CFG(0x2, 0x19, 0x02a19c60), + AZALIA_PIN_CFG(0x2, 0x1a, 0x0181345f), + AZALIA_PIN_CFG(0x2, 0x1b, 0x02214c20), + AZALIA_PIN_CFG(0x2, 0x1c, 0x411111f0), + AZALIA_PIN_CFG(0x2, 0x1d, 0x4004c601), + AZALIA_PIN_CFG(0x2, 0x1e, 0x411111f0), + AZALIA_PIN_CFG(0x2, 0x1f, 0x411111f0), +}; + +const u32 pc_beep_verbs[0] = {}; + +AZALIA_ARRAY_SIZES; diff --git a/src/mainboard/gigabyte/ga-h61m-s2pv/variants/ga-h61ma-d3v/devicetree.cb b/src/mainboard/gigabyte/ga-h61m-s2pv/variants/ga-h61ma-d3v/devicetree.cb new file mode 100644 index 0000000000..22d483e12a --- /dev/null +++ b/src/mainboard/gigabyte/ga-h61m-s2pv/variants/ga-h61ma-d3v/devicetree.cb @@ -0,0 +1,101 @@ +## +## This file is part of the coreboot project. +## +## Copyright (C) 2019 Angel Pons +## +## 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. +## + +chip northbridge/intel/sandybridge + register "gfx.did" = "{ 0x80000100, 0x80000240, 0x80000410 }" + register "gfx.ndid" = "3" + device cpu_cluster 0x0 on + chip cpu/intel/model_206ax + register "c1_acpower" = "1" + register "c1_battery" = "1" + register "c2_acpower" = "3" + register "c2_battery" = "3" + register "c3_acpower" = "5" + register "c3_battery" = "5" + device lapic 0x0 on end + device lapic 0xacac off end + end + end + register "pci_mmio_size" = "2048" + device domain 0x0 on + subsystemid 0x1458 0x5001 inherit + device pci 00.0 on end # Host bridge + device pci 01.0 on end # PCIe Bridge for discrete graphics + device pci 02.0 on end # Internal graphics + chip southbridge/intel/bd82x6x # Intel Series 6 Cougar Point PCH + register "c2_latency" = "0x0065" + register "gen1_dec" = "0x003c0a01" + register "pcie_port_coalesce" = "1" + register "sata_interface_speed_support" = "0x3" + register "sata_port_map" = "0x33" + register "spi_lvscc" = "0x2005" + register "spi_uvscc" = "0x2005" + device pci 16.0 on end # Management Engine Interface 1 + device pci 16.1 off end # Management Engine Interface 2 + device pci 1a.0 on end # USB2 EHCI #2 + device pci 1b.0 on end # High Definition Audio Audio controller + device pci 1c.0 on end # PCIe Port #1 + device pci 1c.1 on end # PCIe Port #2 + device pci 1c.2 on end # PCIe Port #3 + device pci 1c.3 on end # PCIe Port #4 + device pci 1c.4 on end # PCIe Port #5 + device pci 1c.5 on end # PCIe Port #6 + device pci 1d.0 on end # USB2 EHCI #1 + device pci 1e.0 off end # PCI bridge + device pci 1f.0 on # LPC bridge + chip superio/ite/it8728f + device pnp 2e.0 off end # Floppy + device pnp 2e.1 off end # COM1 + device pnp 2e.2 off end # COM2 + device pnp 2e.3 off end # Parallel port + device pnp 2e.4 on # Environment Controller + io 0x60 = 0x0a30 + io 0x62 = 0x0a20 + irq 0x70 = 9 + irq 0xf2 = 0x40 + end + device pnp 2e.5 on # Keyboard + io 0x60 = 0x60 + io 0x62 = 0x64 + irq 0x70 = 1 + irq 0xf0 = 0x08 + end + device pnp 2e.6 on # Mouse + irq 0x70 = 12 + end + device pnp 2e.7 on # GPIO + irq 0x25 = 0x40 + irq 0x26 = 0xf7 + irq 0x27 = 0x10 + irq 0x2c = 0x80 + io 0x60 = 0x0000 + io 0x62 = 0x0a00 + io 0x64 = 0x0000 + irq 0x73 = 0x00 + irq 0xcb = 0x00 + irq 0xf0 = 0x10 + irq 0xf1 = 0x40 + irq 0xf6 = 0x1c + end + device pnp 2e.a off end # CIR + end + end + device pci 1f.2 on end # SATA Controller 1 + device pci 1f.3 on end # SMBus + device pci 1f.5 off end # SATA Controller 2 + device pci 1f.6 on end # Thermal + end + end +end diff --git a/src/mainboard/gigabyte/ga-h61m-s2pv/variants/ga-h61ma-d3v/gpio.c b/src/mainboard/gigabyte/ga-h61m-s2pv/variants/ga-h61ma-d3v/gpio.c new file mode 100644 index 0000000000..b7173749d1 --- /dev/null +++ b/src/mainboard/gigabyte/ga-h61m-s2pv/variants/ga-h61ma-d3v/gpio.c @@ -0,0 +1,205 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2008-2009 coresystems GmbH + * Copyright (C) 2014 Vladimir Serbinenko + * + * 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 + +static const struct pch_gpio_set1 pch_gpio_set1_mode = { + .gpio0 = GPIO_MODE_GPIO, + .gpio1 = GPIO_MODE_GPIO, + .gpio2 = GPIO_MODE_GPIO, + .gpio3 = GPIO_MODE_GPIO, + .gpio4 = GPIO_MODE_GPIO, + .gpio5 = GPIO_MODE_GPIO, + .gpio6 = GPIO_MODE_GPIO, + .gpio7 = GPIO_MODE_GPIO, + .gpio8 = GPIO_MODE_GPIO, + .gpio9 = GPIO_MODE_NATIVE, + .gpio10 = GPIO_MODE_NATIVE, + .gpio11 = GPIO_MODE_NATIVE, + .gpio12 = GPIO_MODE_GPIO, + .gpio13 = GPIO_MODE_GPIO, + .gpio14 = GPIO_MODE_NATIVE, + .gpio15 = GPIO_MODE_GPIO, + .gpio16 = GPIO_MODE_GPIO, + .gpio17 = GPIO_MODE_GPIO, + .gpio18 = GPIO_MODE_NATIVE, + .gpio19 = GPIO_MODE_GPIO, + .gpio20 = GPIO_MODE_NATIVE, + .gpio21 = GPIO_MODE_GPIO, + .gpio22 = GPIO_MODE_GPIO, + .gpio23 = GPIO_MODE_NATIVE, + .gpio24 = GPIO_MODE_GPIO, + .gpio25 = GPIO_MODE_NATIVE, + .gpio26 = GPIO_MODE_NATIVE, + .gpio27 = GPIO_MODE_GPIO, + .gpio28 = GPIO_MODE_GPIO, + .gpio29 = GPIO_MODE_GPIO, + .gpio30 = GPIO_MODE_NATIVE, + .gpio31 = GPIO_MODE_GPIO, +}; + +static const struct pch_gpio_set1 pch_gpio_set1_direction = { + .gpio0 = GPIO_DIR_INPUT, + .gpio1 = GPIO_DIR_INPUT, + .gpio2 = GPIO_DIR_INPUT, + .gpio3 = GPIO_DIR_INPUT, + .gpio4 = GPIO_DIR_INPUT, + .gpio5 = GPIO_DIR_INPUT, + .gpio6 = GPIO_DIR_INPUT, + .gpio7 = GPIO_DIR_INPUT, + .gpio8 = GPIO_DIR_OUTPUT, + .gpio12 = GPIO_DIR_OUTPUT, + .gpio13 = GPIO_DIR_INPUT, + .gpio15 = GPIO_DIR_OUTPUT, + .gpio16 = GPIO_DIR_INPUT, + .gpio17 = GPIO_DIR_INPUT, + .gpio19 = GPIO_DIR_INPUT, + .gpio21 = GPIO_DIR_INPUT, + .gpio22 = GPIO_DIR_INPUT, + .gpio24 = GPIO_DIR_OUTPUT, + .gpio27 = GPIO_DIR_INPUT, + .gpio28 = GPIO_DIR_OUTPUT, + .gpio29 = GPIO_DIR_INPUT, + .gpio31 = GPIO_DIR_INPUT, +}; + +static const struct pch_gpio_set1 pch_gpio_set1_level = { + .gpio8 = GPIO_LEVEL_HIGH, + .gpio12 = GPIO_LEVEL_HIGH, + .gpio15 = GPIO_LEVEL_LOW, + .gpio24 = GPIO_LEVEL_LOW, + .gpio28 = GPIO_LEVEL_LOW, +}; + +static const struct pch_gpio_set1 pch_gpio_set1_reset = { + .gpio24 = GPIO_RESET_RSMRST, +}; + +static const struct pch_gpio_set1 pch_gpio_set1_invert = { + .gpio13 = GPIO_INVERT, +}; + +static const struct pch_gpio_set1 pch_gpio_set1_blink = { +}; + +static const struct pch_gpio_set2 pch_gpio_set2_mode = { + .gpio32 = GPIO_MODE_GPIO, + .gpio33 = GPIO_MODE_GPIO, + .gpio34 = GPIO_MODE_GPIO, + .gpio35 = GPIO_MODE_GPIO, + .gpio36 = GPIO_MODE_GPIO, + .gpio37 = GPIO_MODE_GPIO, + .gpio38 = GPIO_MODE_GPIO, + .gpio39 = GPIO_MODE_GPIO, + .gpio40 = GPIO_MODE_NATIVE, + .gpio41 = GPIO_MODE_NATIVE, + .gpio42 = GPIO_MODE_NATIVE, + .gpio43 = GPIO_MODE_NATIVE, + .gpio44 = GPIO_MODE_NATIVE, + .gpio45 = GPIO_MODE_NATIVE, + .gpio46 = GPIO_MODE_NATIVE, + .gpio47 = GPIO_MODE_NATIVE, + .gpio48 = GPIO_MODE_GPIO, + .gpio49 = GPIO_MODE_GPIO, + .gpio50 = GPIO_MODE_NATIVE, + .gpio51 = GPIO_MODE_NATIVE, + .gpio52 = GPIO_MODE_NATIVE, + .gpio53 = GPIO_MODE_NATIVE, + .gpio54 = GPIO_MODE_NATIVE, + .gpio55 = GPIO_MODE_NATIVE, + .gpio56 = GPIO_MODE_NATIVE, + .gpio57 = GPIO_MODE_GPIO, + .gpio58 = GPIO_MODE_NATIVE, + .gpio59 = GPIO_MODE_NATIVE, + .gpio60 = GPIO_MODE_NATIVE, + .gpio61 = GPIO_MODE_NATIVE, + .gpio62 = GPIO_MODE_NATIVE, + .gpio63 = GPIO_MODE_NATIVE, +}; + +static const struct pch_gpio_set2 pch_gpio_set2_direction = { + .gpio32 = GPIO_DIR_OUTPUT, + .gpio33 = GPIO_DIR_OUTPUT, + .gpio34 = GPIO_DIR_INPUT, + .gpio35 = GPIO_DIR_OUTPUT, + .gpio36 = GPIO_DIR_INPUT, + .gpio37 = GPIO_DIR_INPUT, + .gpio38 = GPIO_DIR_INPUT, + .gpio39 = GPIO_DIR_INPUT, + .gpio48 = GPIO_DIR_INPUT, + .gpio49 = GPIO_DIR_INPUT, + .gpio57 = GPIO_DIR_INPUT, +}; + +static const struct pch_gpio_set2 pch_gpio_set2_level = { + .gpio32 = GPIO_LEVEL_HIGH, + .gpio33 = GPIO_LEVEL_HIGH, + .gpio35 = GPIO_LEVEL_LOW, +}; + +static const struct pch_gpio_set2 pch_gpio_set2_reset = { +}; + +static const struct pch_gpio_set3 pch_gpio_set3_mode = { + .gpio64 = GPIO_MODE_NATIVE, + .gpio65 = GPIO_MODE_NATIVE, + .gpio66 = GPIO_MODE_NATIVE, + .gpio67 = GPIO_MODE_NATIVE, + .gpio68 = GPIO_MODE_GPIO, + .gpio69 = GPIO_MODE_GPIO, + .gpio70 = GPIO_MODE_NATIVE, + .gpio71 = GPIO_MODE_NATIVE, + .gpio72 = GPIO_MODE_GPIO, + .gpio73 = GPIO_MODE_NATIVE, + .gpio74 = GPIO_MODE_NATIVE, + .gpio75 = GPIO_MODE_NATIVE, +}; + +static const struct pch_gpio_set3 pch_gpio_set3_direction = { + .gpio68 = GPIO_DIR_INPUT, + .gpio69 = GPIO_DIR_INPUT, + .gpio72 = GPIO_DIR_INPUT, +}; + +static const struct pch_gpio_set3 pch_gpio_set3_level = { +}; + +static const struct pch_gpio_set3 pch_gpio_set3_reset = { +}; + +const struct pch_gpio_map mainboard_gpio_map = { + .set1 = { + .mode = &pch_gpio_set1_mode, + .direction = &pch_gpio_set1_direction, + .level = &pch_gpio_set1_level, + .blink = &pch_gpio_set1_blink, + .invert = &pch_gpio_set1_invert, + .reset = &pch_gpio_set1_reset, + }, + .set2 = { + .mode = &pch_gpio_set2_mode, + .direction = &pch_gpio_set2_direction, + .level = &pch_gpio_set2_level, + .reset = &pch_gpio_set2_reset, + }, + .set3 = { + .mode = &pch_gpio_set3_mode, + .direction = &pch_gpio_set3_direction, + .level = &pch_gpio_set3_level, + .reset = &pch_gpio_set3_reset, + }, +}; diff --git a/src/mainboard/gigabyte/ga-h61m-s2pv/variants/ga-h61ma-d3v/hda_verb.c b/src/mainboard/gigabyte/ga-h61m-s2pv/variants/ga-h61ma-d3v/hda_verb.c new file mode 100644 index 0000000000..e160538d9f --- /dev/null +++ b/src/mainboard/gigabyte/ga-h61m-s2pv/variants/ga-h61ma-d3v/hda_verb.c @@ -0,0 +1,42 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2019 Angel Pons + * + * 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 + +const u32 cim_verb_data[] = { + 0x10ec0887, /* Realtek ALC887 */ + 0x1458a002, /* Subsystem ID */ + 0x0000000f, /* Number of 4 dword sets */ + AZALIA_SUBVENDOR(0x2, 0x1458a002), + AZALIA_PIN_CFG(0x2, 0x11, 0x411110f0), + AZALIA_PIN_CFG(0x2, 0x12, 0x411111f0), + AZALIA_PIN_CFG(0x2, 0x14, 0x01014410), + AZALIA_PIN_CFG(0x2, 0x15, 0x411111f0), + AZALIA_PIN_CFG(0x2, 0x16, 0x411111f0), + AZALIA_PIN_CFG(0x2, 0x17, 0x411111f0), + AZALIA_PIN_CFG(0x2, 0x18, 0x01a19c50), + AZALIA_PIN_CFG(0x2, 0x19, 0x02a19c60), + AZALIA_PIN_CFG(0x2, 0x1a, 0x0181345f), + AZALIA_PIN_CFG(0x2, 0x1b, 0x02214c20), + AZALIA_PIN_CFG(0x2, 0x1c, 0x411111f0), + AZALIA_PIN_CFG(0x2, 0x1d, 0x4004c601), + AZALIA_PIN_CFG(0x2, 0x1e, 0x411111f0), + AZALIA_PIN_CFG(0x2, 0x1f, 0x41c46060), +}; + +const u32 pc_beep_verbs[0] = {}; + +AZALIA_ARRAY_SIZES; diff --git a/src/mainboard/google/butterfly/romstage.c b/src/mainboard/google/butterfly/romstage.c index d34b1e4574..844f754cfc 100644 --- a/src/mainboard/google/butterfly/romstage.c +++ b/src/mainboard/google/butterfly/romstage.c @@ -33,13 +33,6 @@ void pch_enable_lpc(void) /* EC Decode Range Port60/64 and Port62/66 */ /* Enable EC and PS/2 Keyboard/Mouse*/ pci_write_config16(PCH_LPC_DEV, LPC_EN, KBC_LPC_EN | MC_LPC_EN); - - /* EC Decode Range Port68/6C */ - pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, (0x68 & ~3) | 0x40001); - - /* EC Decode Range Port 380-387 */ - pci_write_config32(PCH_LPC_DEV, LPC_GEN2_DEC, 0x380 | 0x40001); - } void mainboard_rcba_config(void) diff --git a/src/mainboard/google/eve/Kconfig b/src/mainboard/google/eve/Kconfig index f7fb9c6516..022493c35f 100644 --- a/src/mainboard/google/eve/Kconfig +++ b/src/mainboard/google/eve/Kconfig @@ -19,7 +19,6 @@ config BOARD_SPECIFIC_OPTIONS select MAINBOARD_HAS_CHROMEOS select MAINBOARD_HAS_I2C_TPM_CR50 select MAINBOARD_HAS_TPM2 - select MAINBOARD_USES_FSP2_0 select SOC_INTEL_KABYLAKE config VBOOT diff --git a/src/mainboard/google/eve/spd/spd.c b/src/mainboard/google/eve/spd/spd.c index 077bed4bf1..fca670cbb9 100644 --- a/src/mainboard/google/eve/spd/spd.c +++ b/src/mainboard/google/eve/spd/spd.c @@ -14,7 +14,6 @@ * GNU General Public License for more details. */ -#include #include #include #include diff --git a/src/mainboard/google/fizz/Kconfig b/src/mainboard/google/fizz/Kconfig index acaf8a6dc2..b05cb6c16d 100644 --- a/src/mainboard/google/fizz/Kconfig +++ b/src/mainboard/google/fizz/Kconfig @@ -17,7 +17,6 @@ config BOARD_GOOGLE_BASEBOARD_FIZZ select INTEL_GMA_HAVE_VBT select INTEL_LPSS_UART_FOR_CONSOLE select MAINBOARD_HAS_CHROMEOS - select MAINBOARD_USES_FSP2_0 select NO_FADT_8042 select SOC_INTEL_KABYLAKE select MAINBOARD_HAS_SPI_TPM_CR50 diff --git a/src/mainboard/google/glados/spd/spd.c b/src/mainboard/google/glados/spd/spd.c index b3cf3f9416..9503582c9a 100644 --- a/src/mainboard/google/glados/spd/spd.c +++ b/src/mainboard/google/glados/spd/spd.c @@ -14,7 +14,6 @@ * GNU General Public License for more details. */ -#include #include #include #include diff --git a/src/mainboard/google/hatch/romstage.c b/src/mainboard/google/hatch/romstage.c index 2c630a8ce8..69fee28025 100644 --- a/src/mainboard/google/hatch/romstage.c +++ b/src/mainboard/google/hatch/romstage.c @@ -21,12 +21,7 @@ #include #include #include - -/* Memory configuration board straps */ -#define GPIO_MEM_CONFIG_0 GPP_F20 -#define GPIO_MEM_CONFIG_1 GPP_F21 -#define GPIO_MEM_CONFIG_2 GPP_F11 -#define GPIO_MEM_CONFIG_3 GPP_F22 +#include /* * GPIO_MEM_CH_SEL is set to 1 for single channel skus diff --git a/src/mainboard/google/hatch/variants/baseboard/devicetree.cb b/src/mainboard/google/hatch/variants/baseboard/devicetree.cb index 112c279fcb..9a9125396c 100644 --- a/src/mainboard/google/hatch/variants/baseboard/devicetree.cb +++ b/src/mainboard/google/hatch/variants/baseboard/devicetree.cb @@ -36,7 +36,7 @@ chip soc/intel/cannonlake # Enable DPTF register "dptf_enable" = "1" register "tdp_pl1_override" = "15" - register "tdp_pl2_override" = "44" + register "tdp_pl2_override" = "64" register "Device4Enable" = "1" # Enable eDP device register "DdiPortEdp" = "1" @@ -56,12 +56,12 @@ chip soc/intel/cannonlake register "usb2_ports[1]" = "USB2_PORT_TYPE_C(OC2)" # Type-C Port 1 register "usb2_ports[2]" = "USB2_PORT_SHORT(OC3)" # Type-A Port 0 register "usb2_ports[3]" = "USB2_PORT_LONG(OC3)" # Type-A Port 1 - register "usb2_ports[4]" = "USB2_PORT_MID(OC_SKIP)" # BT + register "usb2_ports[4]" = "USB2_PORT_EMPTY" register "usb2_ports[5]" = "USB2_PORT_MID(OC_SKIP)" # WWAN register "usb2_ports[6]" = "USB2_PORT_LONG(OC_SKIP)" # Camera register "usb2_ports[7]" = "USB2_PORT_EMPTY" register "usb2_ports[8]" = "USB2_PORT_EMPTY" - register "usb2_ports[9]" = "USB2_PORT_MID(OC_SKIP)" # CnVi BT + register "usb2_ports[9]" = "USB2_PORT_MID(OC_SKIP)" # BT register "usb3_ports[0]" = "USB3_PORT_DEFAULT(OC2)" # Type-C Port 0 register "usb3_ports[1]" = "USB3_PORT_DEFAULT(OC2)" # Type-C Port 1 @@ -144,12 +144,6 @@ chip soc/intel/cannonlake register "group" = "ACPI_PLD_GROUP(2, 2)" device usb 2.3 on end end - chip drivers/usb/acpi - register "desc" = ""Discrete bluetooth"" - register "type" = "UPC_TYPE_INTERNAL" - register "reset_gpio" = "ACPI_GPIO_OUTPUT_ACTIVE_LOW(GPP_C14)" - device usb 2.4 on end - end chip drivers/usb/acpi register "desc" = ""WWAN"" register "type" = "UPC_TYPE_INTERNAL" @@ -161,7 +155,7 @@ chip soc/intel/cannonlake device usb 2.6 on end end chip drivers/usb/acpi - register "desc" = ""Integrated CnVi bluetooth"" + register "desc" = ""Bluetooth"" register "type" = "UPC_TYPE_INTERNAL" register "reset_gpio" = "ACPI_GPIO_OUTPUT_ACTIVE_LOW(GPP_C14)" device usb 2.9 on end diff --git a/src/mainboard/google/hatch/variants/baseboard/gpio.c b/src/mainboard/google/hatch/variants/baseboard/gpio.c index 0b6607595d..9529cc750a 100644 --- a/src/mainboard/google/hatch/variants/baseboard/gpio.c +++ b/src/mainboard/google/hatch/variants/baseboard/gpio.c @@ -138,9 +138,9 @@ static const struct pad_config gpio_table[] = { /* C9 : UART_PCH_TX_DEBUG_RX */ PAD_CFG_NF(GPP_C9, NONE, DEEP, NF1), /* C10 : GPP_10 ==> GPP_C10_TP */ - PAD_NC(GPP_C10, DN_20K), - /* C11 : GPP_11 ==> GPP_C11_TP */ - PAD_NC(GPP_C11, DN_20K), + PAD_NC(GPP_C10, NONE), + /* C11 : GPP_11 ==> EN_FP_RAILS */ + PAD_CFG_GPO(GPP_C11, 1, DEEP), /* C12 : GPP_C12 ==> NC */ PAD_NC(GPP_C12, NONE), /* C13 : EC_PCH_INT_L @@ -284,7 +284,7 @@ static const struct pad_config gpio_table[] = { /* F1 : WWAN_RESET_1V8_ODL */ PAD_CFG_GPO(GPP_F1, 1, DEEP), /* F2 : MEM_CH_SEL */ - PAD_CFG_GPI(GPP_F2, DN_20K, PLTRST), + PAD_CFG_GPI(GPP_F2, NONE, PLTRST), /* F3 : GPP_F3 ==> NC */ PAD_NC(GPP_F3, NONE), /* F4 : CNV_BRI_DT */ @@ -343,7 +343,7 @@ static const struct pad_config gpio_table[] = { /* G6 : SD_CLK */ PAD_CFG_NF(GPP_G6, NONE, DEEP, NF1), /* G7 : SD_WP => NC */ - PAD_NC(GPP_G7, DN_20K), + PAD_NC(GPP_G7, NONE), /* * H0 : HP_INT_L */ @@ -460,7 +460,7 @@ static const struct pad_config early_gpio_table[] = { /* C23 : WLAN_PE_RST# */ PAD_CFG_GPO(GPP_C23, 1, DEEP), /* F2 : MEM_CH_SEL */ - PAD_CFG_GPI(GPP_F2, DN_20K, PLTRST), + PAD_CFG_GPI(GPP_F2, NONE, PLTRST), /* F11 : PCH_MEM_STRAP2 */ PAD_CFG_GPI(GPP_F11, NONE, PLTRST), /* F20 : PCH_MEM_STRAP0 */ diff --git a/src/mainboard/google/hatch/variants/baseboard/include/baseboard/acpi/dptf.asl b/src/mainboard/google/hatch/variants/baseboard/include/baseboard/acpi/dptf.asl index ff7db49334..b18932ec6c 100644 --- a/src/mainboard/google/hatch/variants/baseboard/include/baseboard/acpi/dptf.asl +++ b/src/mainboard/google/hatch/variants/baseboard/include/baseboard/acpi/dptf.asl @@ -118,7 +118,7 @@ Name (MPPC, Package () Package () { /* Power Limit 2 */ 1, /* PowerLimitIndex, 1 for Power Limit 2 */ 15000, /* PowerLimitMinimum */ - 44000, /* PowerLimitMaximum */ + 64000, /* PowerLimitMaximum */ 28000, /* TimeWindowMinimum */ 32000, /* TimeWindowMaximum */ 1000 /* StepSize */ diff --git a/src/mainboard/google/hatch/variants/hatch/include/variant/gpio.h b/src/mainboard/google/hatch/variants/hatch/include/variant/gpio.h index 5d69eeddbc..e7d8a75937 100644 --- a/src/mainboard/google/hatch/variants/hatch/include/variant/gpio.h +++ b/src/mainboard/google/hatch/variants/hatch/include/variant/gpio.h @@ -18,4 +18,10 @@ #include +/* Memory configuration board straps */ +#define GPIO_MEM_CONFIG_0 GPP_F20 +#define GPIO_MEM_CONFIG_1 GPP_F21 +#define GPIO_MEM_CONFIG_2 GPP_F11 +#define GPIO_MEM_CONFIG_3 GPP_F22 + #endif diff --git a/src/mainboard/google/hatch/variants/hatch/overridetree.cb b/src/mainboard/google/hatch/variants/hatch/overridetree.cb index 562bb8b229..d676843720 100644 --- a/src/mainboard/google/hatch/variants/hatch/overridetree.cb +++ b/src/mainboard/google/hatch/variants/hatch/overridetree.cb @@ -35,12 +35,23 @@ chip soc/intel/cannonlake }, .i2c[0] = { .speed = I2C_SPEED_FAST, + .rise_time_ns = 50, + .fall_time_ns = 15, }, .i2c[1] = { .speed = I2C_SPEED_FAST, + .rise_time_ns = 60, + .fall_time_ns = 25, + }, + .i2c[3] = { + .speed = I2C_SPEED_FAST, + .rise_time_ns = 150, + .fall_time_ns = 150, }, .i2c[4] = { .speed = I2C_SPEED_FAST, + .rise_time_ns = 120, + .fall_time_ns = 120, }, }" @@ -88,7 +99,7 @@ chip soc/intel/cannonlake register "name" = ""PENH"" register "gpio" = "ACPI_GPIO_IRQ_EDGE_BOTH(GPP_A8)" register "key.wake" = "GPE0_DW0_08" - register "key.wakeup_event_action" = "EV_ACT_ASSERTED" + register "key.wakeup_event_action" = "EV_ACT_DEASSERTED" register "key.dev_name" = ""EJCT"" register "key.linux_code" = "SW_PEN_INSERTED" register "key.linux_input_type" = "EV_SW" diff --git a/src/mainboard/google/hatch/variants/hatch_whl/include/variant/gpio.h b/src/mainboard/google/hatch/variants/hatch_whl/include/variant/gpio.h index d99e2bbd65..29e590422f 100644 --- a/src/mainboard/google/hatch/variants/hatch_whl/include/variant/gpio.h +++ b/src/mainboard/google/hatch/variants/hatch_whl/include/variant/gpio.h @@ -18,4 +18,10 @@ #include +/* Memory configuration board straps */ +#define GPIO_MEM_CONFIG_0 GPP_F20 +#define GPIO_MEM_CONFIG_1 GPP_F21 +#define GPIO_MEM_CONFIG_2 GPP_F11 +#define GPIO_MEM_CONFIG_3 GPP_F22 + #endif diff --git a/src/mainboard/google/hatch/variants/hatch_whl/overridetree.cb b/src/mainboard/google/hatch/variants/hatch_whl/overridetree.cb index eec7880752..373438cf8a 100644 --- a/src/mainboard/google/hatch/variants/hatch_whl/overridetree.cb +++ b/src/mainboard/google/hatch/variants/hatch_whl/overridetree.cb @@ -32,7 +32,24 @@ chip soc/intel/cannonlake # GPIO for SD card detect register "sdcard_cd_gpio" = "vSD3_CD_B" + # USB configuration + register "usb2_ports[4]" = "USB2_PORT_MID(OC_SKIP)" # Discrete BT + device domain 0 on + device pci 14.0 on + chip drivers/usb/acpi + register "desc" = ""Root Hub"" + register "type" = "UPC_TYPE_HUB" + device usb 0.0 on + chip drivers/usb/acpi + register "desc" = ""Discrete bluetooth"" + register "type" = "UPC_TYPE_INTERNAL" + register "reset_gpio" = "ACPI_GPIO_OUTPUT_ACTIVE_LOW(GPP_C14)" + device usb 2.4 on end + end + end + end + end # USB xHCI device pci 15.0 on chip drivers/i2c/generic register "hid" = ""ELAN0000"" @@ -73,7 +90,7 @@ chip soc/intel/cannonlake register "name" = ""PENH"" register "gpio" = "ACPI_GPIO_IRQ_EDGE_BOTH(GPP_A8)" register "key.wake" = "GPE0_DW0_08" - register "key.wakeup_event_action" = "EV_ACT_ASSERTED" + register "key.wakeup_event_action" = "EV_ACT_DEASSERTED" register "key.dev_name" = ""EJCT"" register "key.linux_code" = "SW_PEN_INSERTED" register "key.linux_input_type" = "EV_SW" diff --git a/src/mainboard/google/hatch/variants/helios/Makefile.inc b/src/mainboard/google/hatch/variants/helios/Makefile.inc index cf6ee5ac97..fbd69c40a9 100644 --- a/src/mainboard/google/hatch/variants/helios/Makefile.inc +++ b/src/mainboard/google/hatch/variants/helios/Makefile.inc @@ -12,9 +12,9 @@ ## GNU General Public License for more details. ## -SPD_SOURCES = 4G_2400 # 0b000 -SPD_SOURCES += empty_ddr4 # 0b001 -SPD_SOURCES += 8G_2400 # 0b010 -SPD_SOURCES += 8G_2666 # 0b011 -SPD_SOURCES += 16G_2400 # 0b100 -SPD_SOURCES += 16G_2666 # 0b101 +SPD_SOURCES = LP_8G_2133 # 0b0000 +SPD_SOURCES += LP_16G_2133 # 0b0001 + +romstage-y += memory.c +bootblock-y += gpio.c +ramstage-y += gpio.c diff --git a/src/mainboard/google/hatch/variants/helios/gpio.c b/src/mainboard/google/hatch/variants/helios/gpio.c new file mode 100644 index 0000000000..4353fc0a91 --- /dev/null +++ b/src/mainboard/google/hatch/variants/helios/gpio.c @@ -0,0 +1,128 @@ +/* + * This file is part of the coreboot project. + * + * Copyright 2019 Google LLC + * + * 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 + +static const struct pad_config gpio_table[] = { + /* A0 : RCIN# ==> NC */ + PAD_NC(GPP_A0, NONE), + /* A6 : SERIRQ ==> NC */ + PAD_NC(GPP_A6, NONE), + /* A18 : ISH_GP0 ==> NC */ + PAD_NC(GPP_A18, NONE), + /* A19 : ISH_GP1 ==> NC */ + PAD_NC(GPP_A19, NONE), + /* A20 : ISH_GP2 ==> NC */ + PAD_NC(GPP_A20, NONE), + /* B19 : GSPI1_CS0# ==> NC */ + PAD_NC(GPP_B19, NONE), + /* C1 : SMBDATA ==> NC */ + PAD_NC(GPP_C1, NONE), + /* C6 : GPP_C6 ==> NC */ + PAD_NC(GPP_C6, NONE), + /* C7 : GPP_C7 ==> NC */ + PAD_NC(GPP_C7, NONE), + /* C15 : UART1_CTS# ==> NC */ + PAD_NC(GPP_C15, NONE), + /* C23 : UART2_CTS# ==> NC */ + PAD_NC(GPP_C23, NONE), + /* D5 : ISH_I2C0_SDA ==> NC */ + PAD_NC(GPP_D5, NONE), + /* D6 : ISH_I2C0_SCL ==> NC */ + PAD_NC(GPP_D6, NONE), + /* D7 : ISH_I2C1_SDA ==> NC */ + PAD_NC(GPP_D7, NONE), + /* D8 : ISH_I2C1_SCL ==> NC */ + PAD_NC(GPP_D8, NONE), + /* D10 : ISH_SPI_CLK ==> EN_PP3300_PP1800_FP */ + PAD_CFG_GPO(GPP_D10, 0, DEEP), + /* D21 : SPI1_IO2 ==> NC */ + PAD_NC(GPP_D21, NONE), + /* F0 : GPP_F0 ==> NC */ + PAD_NC(GPP_F0, NONE), + /* F1 : GPP_F1 ==> NC */ + PAD_NC(GPP_F1, NONE), + /* F3 : GPP_F3 ==> MEM_STRAP_3 */ + PAD_CFG_GPI(GPP_F3, NONE, PLTRST), + /* F10 : GPP_F10 ==> MEM_STRAP_2 */ + PAD_CFG_GPI(GPP_F10, NONE, PLTRST), + /* F11 : EMMC_CMD ==> NC */ + PAD_NC(GPP_F11, NONE), + /* F20 : EMMC_RCLK ==> NC */ + PAD_NC(GPP_F20, NONE), + /* F21 : EMMC_CLK ==> NC */ + PAD_NC(GPP_F21, NONE), + /* F22 : EMMC_RESET# ==> NC */ + PAD_NC(GPP_F22, NONE), + /* G0 : GPP_G0 ==> NC */ + PAD_NC(GPP_G0, NONE), + /* G1 : GPP_G1 ==> NC */ + PAD_NC(GPP_G1, NONE), + /* G2 : GPP_G2 ==> NC */ + PAD_NC(GPP_G2, NONE), + /* G3 : GPP_G3 ==> NC */ + PAD_NC(GPP_G3, NONE), + /* G4 : GPP_G4 ==> NC */ + PAD_NC(GPP_G4, NONE), + /* G5 : GPP_G5 ==> NC */ + PAD_NC(GPP_G5, NONE), + /* G6 : GPP_G6 ==> NC */ + PAD_NC(GPP_G6, NONE), + /* H4 : I2C2_SDA ==> NC */ + PAD_NC(GPP_H4, NONE), + /* H5 : I2C2_SCL ==> NC */ + PAD_NC(GPP_H5, NONE), + /* H13 : M2_SKT2_CFG1 ==> SPKR_RST_L */ + PAD_CFG_GPO(GPP_H13, 0, PLTRST), + /* H14 : M2_SKT2_CFG2 ==> TOUCHSCREEN_STOP_L */ + PAD_CFG_GPO(GPP_H14, 0, PLTRST), + /* H19 : TIMESYNC[0] ==> MEM_STRAP_0 */ + PAD_CFG_GPI(GPP_H19, NONE, PLTRST), + /* H22 : MEM_STRAP_1 */ + PAD_CFG_GPI(GPP_H22, NONE, PLTRST), +}; + +const struct pad_config *override_gpio_table(size_t *num) +{ + *num = ARRAY_SIZE(gpio_table); + return gpio_table; +} + +/* GPIOs configured before ramstage */ +static const struct pad_config early_gpio_table[] = { + PAD_NC(GPP_C23, NONE), +}; + +const struct pad_config *override_early_gpio_table(size_t *num) +{ + *num = ARRAY_SIZE(early_gpio_table); + return early_gpio_table; +} + +/* + * GPIO settings before entering all sleep states + */ +static const struct pad_config sleep_gpio_table[] = { + PAD_CFG_GPO(GPP_A12, 1, DEEP), /* FPMCU_RST_ODL */ +}; + +const struct pad_config *variant_sleep_gpio_table(u8 slp_typ, size_t *num) +{ + *num = ARRAY_SIZE(sleep_gpio_table); + return sleep_gpio_table; +} diff --git a/src/mainboard/google/hatch/variants/helios/include/variant/gpio.h b/src/mainboard/google/hatch/variants/helios/include/variant/gpio.h index d99e2bbd65..92f9d412fd 100644 --- a/src/mainboard/google/hatch/variants/helios/include/variant/gpio.h +++ b/src/mainboard/google/hatch/variants/helios/include/variant/gpio.h @@ -18,4 +18,10 @@ #include +/* Memory configuration board straps */ +#define GPIO_MEM_CONFIG_0 GPP_H19 +#define GPIO_MEM_CONFIG_1 GPP_H22 +#define GPIO_MEM_CONFIG_2 GPP_F10 +#define GPIO_MEM_CONFIG_3 GPP_F3 + #endif diff --git a/src/mainboard/google/hatch/variants/helios/memory.c b/src/mainboard/google/hatch/variants/helios/memory.c new file mode 100644 index 0000000000..64b4cac8d0 --- /dev/null +++ b/src/mainboard/google/hatch/variants/helios/memory.c @@ -0,0 +1,68 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2018 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. + */ + +#include +#include +#include +#include + +static const struct cnl_mb_cfg baseboard_memcfg = { + /* + * The dqs_map arrays map the SoC pins to the lpddr3 pins + * for both channels. + * + * "The index of the array is CPU byte number, the values are DRAM byte + * numbers." - doc #573387 + * + * the index = pin number on SoC + * the value = pin number on lpddr3 part + */ + .dqs_map[DDR_CH0] = {4, 7, 5, 6, 0, 3, 2, 1}, + .dqs_map[DDR_CH1] = {0, 3, 2, 1, 4, 7, 6, 5}, + + .dq_map[DDR_CH0] = { + {0xf0, 0xf}, + {0x0, 0xf}, + {0xf0, 0xf}, + {0xf0, 0x0}, + {0xff, 0x0}, + {0xff, 0x0} + }, + .dq_map[DDR_CH1] = { + {0xf, 0xf0}, + {0x0, 0xf0}, + {0xf, 0xf0}, + {0xf, 0x0}, + {0xff, 0x0}, + {0xff, 0x0} + }, + + /* Helios uses 200, 80.6 and 162 rcomp resistors */ + .rcomp_resistor = {200, 81, 162}, + + /* Helios Rcomp target values */ + .rcomp_targets = {100, 40, 40, 23, 40}, + + /* Set CaVref config to 0 for LPDDR3 */ + .vref_ca_config = 0, + + /* Disable Early Command Training */ + .ect = 0, +}; + +void variant_memory_params(struct cnl_mb_cfg *bcfg) +{ + memcpy(bcfg, &baseboard_memcfg, sizeof(baseboard_memcfg)); +} diff --git a/src/mainboard/google/hatch/variants/helios/overridetree.cb b/src/mainboard/google/hatch/variants/helios/overridetree.cb index 84f0e29afa..405f85f210 100644 --- a/src/mainboard/google/hatch/variants/helios/overridetree.cb +++ b/src/mainboard/google/hatch/variants/helios/overridetree.cb @@ -14,13 +14,15 @@ chip soc/intel/cannonlake [PchSerialIoIndexUART2] = PchSerialIoDisabled, }" + # No PCIe WiFi + register "PcieRpEnable[13]" = "0" + # Intel Common SoC Config #+-------------------+---------------------------+ #| Field | Value | #+-------------------+---------------------------+ #| I2C0 | Trackpad | #| I2C1 | Touchscreen | - #| I2C2 | Digitizer | #| I2C4 | Audio | #+-------------------+---------------------------+ register "common_soc_config" = "{ @@ -30,9 +32,6 @@ chip soc/intel/cannonlake .i2c[1] = { .speed = I2C_SPEED_FAST, }, - .i2c[2] = { - .speed = I2C_SPEED_FAST, - }, .i2c[4] = { .speed = I2C_SPEED_FAST, }, @@ -42,5 +41,89 @@ chip soc/intel/cannonlake }, }" - device domain 0 on end + device domain 0 on + device pci 14.0 on + chip drivers/usb/acpi + device usb 0.0 on + chip drivers/usb/acpi + # No Type-A port + device usb 2.2 off end + end + chip drivers/usb/acpi + # No Type-A Port + device usb 2.3 off end + end + chip drivers/usb/acpi + # No WWAN + device usb 2.5 off end + end + chip drivers/usb/acpi + # No WWAN + device usb 3.4 off end + end + end + end + end + + # Native SD Card interface unused + device pci 14.5 off end + + device pci 15.0 on + chip drivers/i2c/generic + register "hid" = ""ELAN0000"" + register "desc" = ""ELAN Touchpad"" + register "irq" = "ACPI_IRQ_EDGE_LOW(GPP_A20_IRQ)" + register "wake" = "GPE0_DW0_21" + device i2c 15 on end + end + end + + device pci 15.1 on + chip drivers/i2c/hid + register "generic.hid" = ""GDIX0000"" + register "generic.desc" = ""Goodix Touchscreen"" + register "generic.irq" = "ACPI_IRQ_EDGE_LOW(GPP_D16_IRQ)" + register "generic.probed" = "1" + register "generic.reset_gpio" = + "ACPI_GPIO_OUTPUT_ACTIVE_LOW(GPP_D15)" + register "generic.reset_delay_ms" = "10" + register "generic.reset_off_delay_ms" = "1" + register "generic.has_power_resource" = "1" + register "hid_desc_reg_offset" = "0x01" + device i2c 5d on end + end + chip drivers/generic/gpio_keys + register "name" = ""PENH"" + register "gpio" = "ACPI_GPIO_IRQ_EDGE_BOTH(GPP_A8)" + register "key.wake" = "GPE0_DW0_08" + register "key.wakeup_event_action" = "EV_ACT_ASSERTED" + register "key.dev_name" = ""EJCT"" + register "key.linux_code" = "SW_PEN_INSERTED" + register "key.linux_input_type" = "EV_SW" + register "key.label" = ""pen_eject"" + device generic 0 on end + end + end # I2C 1 + + # I2C #2 unused + device pci 15.2 off end + + # I2C #3 unused + device pci 15.3 off end + + device pci 19.0 on + chip drivers/i2c/generic + register "hid" = ""10EC5682"" + register "name" = ""RT58"" + register "desc" = ""Realtek RT5682"" + register "irq_gpio" = "ACPI_GPIO_IRQ_EDGE_BOTH(GPP_H0)" + register "property_count" = "1" + # Set the jd_src to RT5668_JD1 for jack detection + register "property_list[0].type" = "ACPI_DP_TYPE_INTEGER" + register "property_list[0].name" = ""realtek,jd-src"" + register "property_list[0].integer" = "1" + device i2c 1a on end + end + end #I2C #4 + end end diff --git a/src/mainboard/google/hatch/variants/kindred/Makefile.inc b/src/mainboard/google/hatch/variants/kindred/Makefile.inc index 8173ca4389..563275dd19 100644 --- a/src/mainboard/google/hatch/variants/kindred/Makefile.inc +++ b/src/mainboard/google/hatch/variants/kindred/Makefile.inc @@ -18,3 +18,6 @@ SPD_SOURCES += 8G_2400 # 0b010 SPD_SOURCES += 8G_2666 # 0b011 SPD_SOURCES += 16G_2400 # 0b100 SPD_SOURCES += 16G_2666 # 0b101 + +bootblock-y += gpio.c +ramstage-y += gpio.c diff --git a/src/mainboard/google/hatch/variants/kindred/gpio.c b/src/mainboard/google/hatch/variants/kindred/gpio.c new file mode 100644 index 0000000000..43948a35f8 --- /dev/null +++ b/src/mainboard/google/hatch/variants/kindred/gpio.c @@ -0,0 +1,54 @@ +/* + * This file is part of the coreboot project. + * + * Copyright 2019 Google LLC + * + * 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 + +static const struct pad_config gpio_table[] = { + /* F3 : MEM_STRAP_3 */ + PAD_CFG_GPI(GPP_F3, NONE, PLTRST), + /* F10 : MEM_STRAP_2 */ + PAD_CFG_GPI(GPP_F10, NONE, PLTRST), + /* H19 : MEM_STRAP_0 */ + PAD_CFG_GPI(GPP_H19, NONE, PLTRST), + /* H22 : MEM_STRAP_1 */ + PAD_CFG_GPI(GPP_H22, NONE, PLTRST), +}; + +const struct pad_config *override_gpio_table(size_t *num) +{ + *num = ARRAY_SIZE(gpio_table); + return gpio_table; +} + +/* GPIOs configured before ramstage */ +static const struct pad_config early_gpio_table[] = { + /* F3 : MEM_STRAP_3 */ + PAD_CFG_GPI(GPP_F3, NONE, PLTRST), + /* F10 : MEM_STRAP_2 */ + PAD_CFG_GPI(GPP_F10, NONE, PLTRST), + /* H19 : MEM_STRAP_0 */ + PAD_CFG_GPI(GPP_H19, NONE, PLTRST), + /* H22 : MEM_STRAP_1 */ + PAD_CFG_GPI(GPP_H22, NONE, PLTRST), +}; + +const struct pad_config *override_early_gpio_table(size_t *num) +{ + *num = ARRAY_SIZE(early_gpio_table); + return early_gpio_table; +} diff --git a/src/mainboard/google/hatch/variants/kindred/include/variant/gpio.h b/src/mainboard/google/hatch/variants/kindred/include/variant/gpio.h index d99e2bbd65..92f9d412fd 100644 --- a/src/mainboard/google/hatch/variants/kindred/include/variant/gpio.h +++ b/src/mainboard/google/hatch/variants/kindred/include/variant/gpio.h @@ -18,4 +18,10 @@ #include +/* Memory configuration board straps */ +#define GPIO_MEM_CONFIG_0 GPP_H19 +#define GPIO_MEM_CONFIG_1 GPP_H22 +#define GPIO_MEM_CONFIG_2 GPP_F10 +#define GPIO_MEM_CONFIG_3 GPP_F3 + #endif diff --git a/src/mainboard/google/hatch/variants/kohaku/include/variant/gpio.h b/src/mainboard/google/hatch/variants/kohaku/include/variant/gpio.h index d99e2bbd65..29e590422f 100644 --- a/src/mainboard/google/hatch/variants/kohaku/include/variant/gpio.h +++ b/src/mainboard/google/hatch/variants/kohaku/include/variant/gpio.h @@ -18,4 +18,10 @@ #include +/* Memory configuration board straps */ +#define GPIO_MEM_CONFIG_0 GPP_F20 +#define GPIO_MEM_CONFIG_1 GPP_F21 +#define GPIO_MEM_CONFIG_2 GPP_F11 +#define GPIO_MEM_CONFIG_3 GPP_F22 + #endif diff --git a/src/mainboard/google/hatch/variants/kohaku/overridetree.cb b/src/mainboard/google/hatch/variants/kohaku/overridetree.cb index 69875bdde2..cf422ed01d 100644 --- a/src/mainboard/google/hatch/variants/kohaku/overridetree.cb +++ b/src/mainboard/google/hatch/variants/kohaku/overridetree.cb @@ -70,7 +70,7 @@ chip soc/intel/cannonlake register "generic.irq" = "ACPI_IRQ_EDGE_LOW(GPP_D21_IRQ)" register "generic.probed" = "1" register "hid_desc_reg_offset" = "0x20" - device i2c 0x2c on end + device i2c 0x20 on end end end # I2C 0 diff --git a/src/mainboard/google/kahlee/variants/baseboard/mainboard.c b/src/mainboard/google/kahlee/variants/baseboard/mainboard.c index 996e6102fc..95274eb85d 100644 --- a/src/mainboard/google/kahlee/variants/baseboard/mainboard.c +++ b/src/mainboard/google/kahlee/variants/baseboard/mainboard.c @@ -61,12 +61,22 @@ void board_bh720(struct device *dev) write32((void *)(sdbar + BH720_MEM_RW_ADR), BH720_MEM_RW_WRITE | BH720_PCR_EMMC_SETTING); - /* Set Bayhub SD base CLK 50MHz: case#1 PCR 0x3E4[22] = 0 */ + /* Set Base clock to 200MHz(PCR 0x304[31:16] = 0x2510) */ + write32((void *)(sdbar + BH720_MEM_RW_ADR), + BH720_MEM_RW_READ | BH720_PCR_DrvStrength_PLL); + bh720_pcr_data = read32((void *)(sdbar + BH720_MEM_RW_DATA)); + bh720_pcr_data &= 0x0000FFFF; + bh720_pcr_data |= 0x2510 << 16; + write32((void *)(sdbar + BH720_MEM_RW_DATA), bh720_pcr_data); + write32((void *)(sdbar + BH720_MEM_RW_ADR), + BH720_MEM_RW_WRITE | BH720_PCR_DrvStrength_PLL); + + /* Use PLL Base clock PCR 0x3E4[22] = 1 */ write32((void *)(sdbar + BH720_MEM_RW_ADR), BH720_MEM_RW_READ | BH720_PCR_CSR); bh720_pcr_data = read32((void *)(sdbar + BH720_MEM_RW_DATA)); write32((void *)(sdbar + BH720_MEM_RW_DATA), - bh720_pcr_data & ~BH720_PCR_CSR_EMMC_MODE_SEL); + bh720_pcr_data | BH720_PCR_CSR_EMMC_MODE_SEL); write32((void *)(sdbar + BH720_MEM_RW_ADR), BH720_MEM_RW_WRITE | BH720_PCR_CSR); diff --git a/src/mainboard/google/kukui/Kconfig b/src/mainboard/google/kukui/Kconfig index 6831d1e729..7719506421 100644 --- a/src/mainboard/google/kukui/Kconfig +++ b/src/mainboard/google/kukui/Kconfig @@ -25,6 +25,7 @@ config VBOOT config BOARD_SPECIFIC_OPTIONS def_bool y + select RTC select SOC_MEDIATEK_MT8183 select BOARD_ROMSIZE_KB_8192 select MAINBOARD_HAS_CHROMEOS diff --git a/src/mainboard/google/kukui/bootblock.c b/src/mainboard/google/kukui/bootblock.c index 9d6c38ba64..61f30aff44 100644 --- a/src/mainboard/google/kukui/bootblock.c +++ b/src/mainboard/google/kukui/bootblock.c @@ -15,9 +15,15 @@ #include #include +#include void bootblock_mainboard_init(void) { - mtk_spi_init(CONFIG_EC_GOOGLE_CHROMEEC_SPI_BUS, SPI_PAD0_MASK, 6 * MHz); - mtk_spi_init(CONFIG_BOOT_DEVICE_SPI_FLASH_BUS, SPI_PAD0_MASK, 26 * MHz); + mtk_spi_init(CONFIG_EC_GOOGLE_CHROMEEC_SPI_BUS, SPI_PAD0_MASK, 6 * MHz, + 0); + mtk_spi_init(CONFIG_BOOT_DEVICE_SPI_FLASH_BUS, SPI_PAD0_MASK, 56 * MHz, + 2); + gpio_set_spi_driving(CONFIG_BOOT_DEVICE_SPI_FLASH_BUS, SPI_PAD0_MASK, + 10); + } diff --git a/src/mainboard/google/kukui/chromeos.fmd b/src/mainboard/google/kukui/chromeos.fmd index 23e55766c6..d183273549 100644 --- a/src/mainboard/google/kukui/chromeos.fmd +++ b/src/mainboard/google/kukui/chromeos.fmd @@ -1,30 +1,30 @@ FLASH@0x0 0x800000 { WP_RO@0x0 0x200000 { - RO_SECTION@0x0 0x1f0000 { + RO_SECTION@0x0 0x1f8000 { BOOTBLOCK@0 32K FMAP@0x8000 0x1000 - COREBOOT(CBFS)@0x9000 0x1e4000 - GBB@0x1ed000 0x2f00 - RO_FRID@0x1eff00 0x100 + COREBOOT(CBFS)@0x9000 0x1ec000 + GBB 0x2f00 + RO_FRID 0x100 } - RO_VPD(PRESERVE)@0x1f0000 0x10000 + RO_VPD(PRESERVE)@0x1f8000 0x8000 } - RW_SECTION_A@0x200000 0x78000 { + RW_SECTION_A@0x200000 0x7c000 { VBLOCK_A@0x0 0x2000 - FW_MAIN_A(CBFS)@0x2000 0x75f00 - RW_FWID_A@0x77f00 0x100 + FW_MAIN_A(CBFS) 0x79f00 + RW_FWID_A 0x100 } - RW_SHARED@0x278000 0x2000 { - SHARED_DATA@0x0 0x2000 + RW_SHARED@0x27c000 0x1000 { + SHARED_DATA@0x0 0x1000 } - RW_NVRAM(PRESERVE)@0x27a000 0x2000 - RW_ELOG(PRESERVE)@0x27c000 0x4000 - RW_SECTION_B@0x280000 0x78000 { + RW_NVRAM(PRESERVE)@0x27d000 0x2000 + # ELOG driver has hard-coded the size to 4k. + RW_ELOG(PRESERVE)@0x27f000 0x1000 + RW_SECTION_B@0x280000 0x7c000 { VBLOCK_B@0x0 0x2000 - FW_MAIN_B(CBFS)@0x2000 0x75f00 - RW_FWID_B@0x77f00 0x100 + FW_MAIN_B(CBFS) 0x79f00 + RW_FWID_B 0x100 } - RW_VPD(PRESERVE)@0x2f8000 0x8000 - SMMSTORE(PRESERVE)@0x300000 0x20000 - RW_LEGACY(CBFS)@0x320000 0xe0000 + RW_VPD(PRESERVE)@0x2fc000 0x4000 + RW_LEGACY(CBFS)@0x300000 0x100000 } diff --git a/src/mainboard/google/kukui/early_init.c b/src/mainboard/google/kukui/early_init.c index 1193bb3fe9..7eee080412 100644 --- a/src/mainboard/google/kukui/early_init.c +++ b/src/mainboard/google/kukui/early_init.c @@ -34,6 +34,6 @@ void mainboard_early_init(void) gpio_set_mode(AP_IN_SLEEP_L, PAD_SRCLKENA0_FUNC_SRCLKENA0); - mtk_spi_init(CONFIG_DRIVER_TPM_SPI_BUS, SPI_PAD0_MASK, 1 * MHz); + mtk_spi_init(CONFIG_DRIVER_TPM_SPI_BUS, SPI_PAD0_MASK, 1 * MHz, 0); gpio_eint_configure(CR50_IRQ, IRQ_TYPE_EDGE_RISING); } diff --git a/src/mainboard/google/kukui/romstage.c b/src/mainboard/google/kukui/romstage.c index baaca43b90..1465243f07 100644 --- a/src/mainboard/google/kukui/romstage.c +++ b/src/mainboard/google/kukui/romstage.c @@ -29,6 +29,8 @@ void platform_romstage_main(void) mainboard_early_init(); mt6358_init(); + /* Adjust VSIM2 down to 2.7V because it is shared with IT6505. */ + pmic_set_vsim2_cali(2700); mt_pll_raise_ca53_freq(1989 * MHz); rtc_boot(); mt_mem_init(get_sdram_config()); diff --git a/src/mainboard/google/kukui/sdram_configs.c b/src/mainboard/google/kukui/sdram_configs.c index cbfb08d5ce..5931c79ecd 100644 --- a/src/mainboard/google/kukui/sdram_configs.c +++ b/src/mainboard/google/kukui/sdram_configs.c @@ -21,6 +21,8 @@ static const char *const sdram_configs[] = { [1] = "sdram-lpddr4x-H9HCNNNCPMALHR-4GB", [2] = "sdram-lpddr4x-MT53E1G32D4NQ-4GB", + [3] = "sdram-lpddr4x-KMDP6001DA-B425-4GB", + [5] = "sdram-lpddr4x-MT29VZZZAD8DQKSL-4GB", }; static struct sdram_params params; diff --git a/src/mainboard/google/kukui/sdram_params/Makefile.inc b/src/mainboard/google/kukui/sdram_params/Makefile.inc index 1e11140873..77158a5c59 100644 --- a/src/mainboard/google/kukui/sdram_params/Makefile.inc +++ b/src/mainboard/google/kukui/sdram_params/Makefile.inc @@ -1,6 +1,8 @@ sdram-params := sdram-params += sdram-lpddr4x-H9HCNNNCPMALHR-4GB sdram-params += sdram-lpddr4x-MT53E1G32D4NQ-4GB +sdram-params += sdram-lpddr4x-KMDP6001DA-B425-4GB +sdram-params += sdram-lpddr4x-MT29VZZZAD8DQKSL-4GB $(foreach params,$(sdram-params), \ $(eval cbfs-files-y += $(params)) \ diff --git a/src/mainboard/google/kukui/sdram_params/sdram-lpddr4x-KMDP6001DA-B425-4GB.c b/src/mainboard/google/kukui/sdram_params/sdram-lpddr4x-KMDP6001DA-B425-4GB.c new file mode 100644 index 0000000000..1e0c3628fd --- /dev/null +++ b/src/mainboard/google/kukui/sdram_params/sdram-lpddr4x-KMDP6001DA-B425-4GB.c @@ -0,0 +1,41 @@ +/* + * This file is part of the coreboot project. + * + * Copyright 2018 MediaTek 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 + +struct sdram_params params = { + .impedance = { + [ODT_OFF] = {0x9, 0x7, 0x0, 0xF}, + [ODT_ON] = {0xA, 0x9, 0x0, 0xE} + }, + .wr_level = { + [CHANNEL_A] = { {0x21, 0x21}, {0x20, 0x20} }, + [CHANNEL_B] = { {0x1E, 0x1F}, {0x1D, 0x1E} } + }, + .cbt_cs = { + [CHANNEL_A] = {0x1, 0x1}, + [CHANNEL_B] = {0x2, 0x2} + }, + .cbt_mr12 = { + [CHANNEL_A] = {0x56, 0x56}, + [CHANNEL_B] = {0x58, 0x5C} + }, + .emi_cona_val = 0xF053F154, + .emi_conh_val = 0x44440003, + .emi_conf_val = 0x00421000, + .chn_emi_cona_val = {0x0444F051, 0x0444F051}, + .cbt_mode_extern = CBT_NORMAL_MODE, + .delay_cell_unit = 868, +}; diff --git a/src/mainboard/google/kukui/sdram_params/sdram-lpddr4x-MT29VZZZAD8DQKSL-4GB.c b/src/mainboard/google/kukui/sdram_params/sdram-lpddr4x-MT29VZZZAD8DQKSL-4GB.c new file mode 100644 index 0000000000..512023b35e --- /dev/null +++ b/src/mainboard/google/kukui/sdram_params/sdram-lpddr4x-MT29VZZZAD8DQKSL-4GB.c @@ -0,0 +1,41 @@ +/* + * This file is part of the coreboot project. + * + * Copyright 2018 MediaTek 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 + +struct sdram_params params = { + .impedance = { + [ODT_OFF] = {0x9, 0x7, 0x0, 0xF}, + [ODT_ON] = {0xA, 0x9, 0x0, 0xE} + }, + .wr_level = { + [CHANNEL_A] = { {0x21, 0x21}, {0x20, 0x20} }, + [CHANNEL_B] = { {0x21, 0x28}, {0x21, 0x29} } + }, + .cbt_cs = { + [CHANNEL_A] = {0x2, 0x2}, + [CHANNEL_B] = {0x2, 0x2} + }, + .cbt_mr12 = { + [CHANNEL_A] = {0x5E, 0x5E}, + [CHANNEL_B] = {0x5E, 0x5C} + }, + .emi_cona_val = 0xF053F154, + .emi_conh_val = 0x44440003, + .emi_conf_val = 0x00421000, + .chn_emi_cona_val = {0x0444F051, 0x0444F051}, + .cbt_mode_extern = CBT_NORMAL_MODE, + .delay_cell_unit = 868, +}; diff --git a/src/mainboard/google/link/romstage.c b/src/mainboard/google/link/romstage.c index 8da13080b3..2f3f07cdce 100644 --- a/src/mainboard/google/link/romstage.c +++ b/src/mainboard/google/link/romstage.c @@ -34,28 +34,12 @@ void pch_enable_lpc(void) { - const struct device *lpc; - const struct southbridge_intel_bd82x6x_config *config = NULL; - - lpc = pcidev_on_root(0x1f, 0); - if (!lpc) - return; - if (lpc->chip_info) - config = lpc->chip_info; - if (!config) - return; - /* Set COM1/COM2 decode range */ pci_write_config16(PCH_LPC_DEV, LPC_IO_DEC, 0x0010); /* Enable PS/2 Keyboard/Mouse, EC areas and COM1 */ pci_write_config16(PCH_LPC_DEV, LPC_EN, KBC_LPC_EN | MC_LPC_EN | \ GAMEL_LPC_EN | COMA_LPC_EN); - - pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, config->gen1_dec); - pci_write_config32(PCH_LPC_DEV, LPC_GEN2_DEC, config->gen2_dec); - pci_write_config32(PCH_LPC_DEV, LPC_GEN3_DEC, config->gen3_dec); - pci_write_config32(PCH_LPC_DEV, LPC_GEN4_DEC, config->gen4_dec); } void mainboard_rcba_config(void) diff --git a/src/mainboard/google/mistral/chromeos.fmd b/src/mainboard/google/mistral/chromeos.fmd index 76cdd50d91..4d5f666ce8 100644 --- a/src/mainboard/google/mistral/chromeos.fmd +++ b/src/mainboard/google/mistral/chromeos.fmd @@ -16,7 +16,7 @@ FLASH@0x0 8M { WP_RO 4M { RO_SECTION 0x204000 { - BOOTBLOCK 96K + BOOTBLOCK 128K COREBOOT(CBFS) FMAP@0x200000 0x1000 GBB 0x2f00 diff --git a/src/mainboard/google/oak/bootblock.c b/src/mainboard/google/oak/bootblock.c index 3c50389914..89169ef0bf 100644 --- a/src/mainboard/google/oak/bootblock.c +++ b/src/mainboard/google/oak/bootblock.c @@ -89,7 +89,8 @@ void bootblock_mainboard_init(void) if (CONFIG(OAK_HAS_TPM2)) gpio_eint_configure(CR50_IRQ, IRQ_TYPE_EDGE_RISING); - mtk_spi_init(CONFIG_EC_GOOGLE_CHROMEEC_SPI_BUS, SPI_PAD1_MASK, 6*MHz); + mtk_spi_init(CONFIG_EC_GOOGLE_CHROMEEC_SPI_BUS, SPI_PAD1_MASK, 6*MHz, + 0); setup_chromeos_gpios(); diff --git a/src/mainboard/google/octopus/mainboard.c b/src/mainboard/google/octopus/mainboard.c index 4316ffed23..91cf1e4b70 100644 --- a/src/mainboard/google/octopus/mainboard.c +++ b/src/mainboard/google/octopus/mainboard.c @@ -118,7 +118,7 @@ struct chip_operations mainboard_ops = { #define SKU_UNKNOWN 0xFFFFFFFF #define SKU_MAX 255 -static uint32_t get_board_sku(void) +uint32_t get_board_sku(void) { static uint32_t sku_id = SKU_UNKNOWN; diff --git a/src/mainboard/google/octopus/variants/baseboard/include/baseboard/variants.h b/src/mainboard/google/octopus/variants/baseboard/include/baseboard/variants.h index 96381183b8..5374ace795 100644 --- a/src/mainboard/google/octopus/variants/baseboard/include/baseboard/variants.h +++ b/src/mainboard/google/octopus/variants/baseboard/include/baseboard/variants.h @@ -34,7 +34,8 @@ extern const struct lpddr4_swizzle_cfg baseboard_lpddr4_swizzle; const struct lpddr4_cfg *variant_lpddr4_config(void); /* Return memory SKU for the board. */ size_t variant_memory_sku(void); - +/* Return board SKU */ +uint32_t get_board_sku(void); /* Return ChromeOS gpio table and fill in number of entries. */ const struct cros_gpio *variant_cros_gpios(size_t *num); diff --git a/src/mainboard/google/octopus/variants/bloog/overridetree.cb b/src/mainboard/google/octopus/variants/bloog/overridetree.cb index cf70bb3108..6c64ba78e0 100644 --- a/src/mainboard/google/octopus/variants/bloog/overridetree.cb +++ b/src/mainboard/google/octopus/variants/bloog/overridetree.cb @@ -53,6 +53,9 @@ chip soc/intel/apollolake #| I2C6 | Trackpad | #| I2C7 | Touchscreen | #+-------------------+---------------------------+ + + register "tcc_offset" = "10" + register "common_soc_config" = "{ .gspi[0] = { .speed_mhz = 1, diff --git a/src/mainboard/google/octopus/variants/garg/Makefile.inc b/src/mainboard/google/octopus/variants/garg/Makefile.inc index 9fb63f5f43..ba865e9f82 100644 --- a/src/mainboard/google/octopus/variants/garg/Makefile.inc +++ b/src/mainboard/google/octopus/variants/garg/Makefile.inc @@ -1,3 +1,4 @@ bootblock-y += gpio.c ramstage-y += gpio.c +ramstage-y += variant.c diff --git a/src/mainboard/google/octopus/variants/garg/variant.c b/src/mainboard/google/octopus/variants/garg/variant.c new file mode 100644 index 0000000000..a3efe3f802 --- /dev/null +++ b/src/mainboard/google/octopus/variants/garg/variant.c @@ -0,0 +1,39 @@ +/* + * This file is part of the coreboot project. + * + * Copyright 2019 Google LLC + * + * 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 + +enum { + SKU_1_2A2C = 1, + SKU_9_HDMI = 9, + SKU_17_LTE = 17, +}; + +const char *mainboard_vbt_filename(void) +{ + uint32_t sku_id; + + sku_id = get_board_sku(); + + switch (sku_id) { + case SKU_9_HDMI: + return "vbt_garg_hdmi.bin"; + default: + return "vbt.bin"; + } +} diff --git a/src/mainboard/google/parrot/romstage.c b/src/mainboard/google/parrot/romstage.c index 76a4b4b677..ac06fbc83e 100644 --- a/src/mainboard/google/parrot/romstage.c +++ b/src/mainboard/google/parrot/romstage.c @@ -31,12 +31,6 @@ void pch_enable_lpc(void) /* Parrot EC Decode Range Port60/64, Port62/66 */ /* Enable EC, PS/2 Keyboard/Mouse */ pci_write_config16(PCH_LPC_DEV, LPC_EN, KBC_LPC_EN | MC_LPC_EN); - - /* Map EC_IO decode to the LPC bus */ - pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, (EC_IO & ~3) | 0x00040001); - - /* Map EC registers 68/6C decode to the LPC bus */ - pci_write_config32(PCH_LPC_DEV, LPC_GEN2_DEC, (68 & ~3) | 0x00040001); } void mainboard_rcba_config(void) diff --git a/src/mainboard/google/poppy/Kconfig b/src/mainboard/google/poppy/Kconfig index 6bc8269aa7..fda8c9e8b8 100644 --- a/src/mainboard/google/poppy/Kconfig +++ b/src/mainboard/google/poppy/Kconfig @@ -13,7 +13,6 @@ config BOARD_GOOGLE_BASEBOARD_POPPY select INTEL_GMA_HAVE_VBT if BOARD_GOOGLE_NAMI select INTEL_LPSS_UART_FOR_CONSOLE select MAINBOARD_HAS_CHROMEOS - select MAINBOARD_USES_FSP2_0 select SOC_INTEL_KABYLAKE select MAINBOARD_HAS_TPM2 @@ -156,6 +155,7 @@ config VARIANT_SPECIFIC_OPTIONS_ATLAS select EXCLUDE_NATIVE_SD_INTERFACE select MAINBOARD_HAS_SPI_TPM_CR50 select VARIANT_HAS_CAMERA_ACPI + select GEO_SAR_ENABLE if CHROMEOS_WIFI_SAR config VARIANT_SPECIFIC_OPTIONS_POPPY def_bool n diff --git a/src/mainboard/google/poppy/variants/atlas/include/variant/acpi/dptf.asl b/src/mainboard/google/poppy/variants/atlas/include/variant/acpi/dptf.asl index 570fbbbdfa..68633723ea 100644 --- a/src/mainboard/google/poppy/variants/atlas/include/variant/acpi/dptf.asl +++ b/src/mainboard/google/poppy/variants/atlas/include/variant/acpi/dptf.asl @@ -29,12 +29,12 @@ #define DPTF_TSR2_SENSOR_ID 3 #define DPTF_TSR2_SENSOR_NAME "DRAM" -#define DPTF_TSR2_PASSIVE 55 +#define DPTF_TSR2_PASSIVE 53 #define DPTF_TSR2_CRITICAL 75 #define DPTF_TSR3_SENSOR_ID 4 #define DPTF_TSR3_SENSOR_NAME "eMMC" -#define DPTF_TSR3_PASSIVE 52 +#define DPTF_TSR3_PASSIVE 50 #define DPTF_TSR3_CRITICAL 75 #undef DPTF_ENABLE_FAN_CONTROL diff --git a/src/mainboard/google/poppy/variants/nami/memory.c b/src/mainboard/google/poppy/variants/nami/memory.c index b7f51851c7..b6e3d2cd08 100644 --- a/src/mainboard/google/poppy/variants/nami/memory.c +++ b/src/mainboard/google/poppy/variants/nami/memory.c @@ -66,8 +66,12 @@ static void fill_ddr4_memory_params(struct memory_params *p) p->type = MEMORY_DDR4; p->use_sec_spd = 0; + int spd_index = variant_memory_sku(); + if (spd_index == 0) + die("SPD index is 0\n"); + /* Rcomp resistor values are different for SDP and DDP. */ - if (ddp_bitmap & MEM_ID(variant_memory_sku())) { + if (ddp_bitmap & MEM_ID(spd_index)) { p->rcomp_resistor = rcomp_resistor_ddp; p->rcomp_resistor_size = sizeof(rcomp_resistor_ddp); } else { diff --git a/src/mainboard/google/reef/variants/snappy/mainboard.c b/src/mainboard/google/reef/variants/snappy/mainboard.c index 950a029459..b34b8e2c92 100644 --- a/src/mainboard/google/reef/variants/snappy/mainboard.c +++ b/src/mainboard/google/reef/variants/snappy/mainboard.c @@ -70,8 +70,8 @@ uint8_t variant_board_sku(void) if ((ch < '0') || (ch > '9')) { vpd_sku_num = -1; break; - } else - vpd_sku_num = vpd_sku_num * 10 + (ch - '0'); + } + vpd_sku_num = vpd_sku_num * 10 + (ch - '0'); } if (vpd_sku_num != -1) diff --git a/src/mainboard/google/sarien/ramstage.c b/src/mainboard/google/sarien/ramstage.c index 1d220461cf..811afa1b16 100644 --- a/src/mainboard/google/sarien/ramstage.c +++ b/src/mainboard/google/sarien/ramstage.c @@ -14,6 +14,7 @@ */ #include +#include #include #include #include @@ -60,6 +61,13 @@ void smbios_fill_dimm_locator(const struct dimm_info *dimm, } #endif +static const struct pad_config gpio_unused[] = { +/* SUSWARN# */ PAD_NC(GPP_A13, NONE), +/* SUSACK# */ PAD_NC(GPP_A15, NONE), +/* M2_SKT2_CFG0 */ PAD_NC(GPP_H12, NONE), +/* M2_SKT2_CFG1 */ PAD_NC(GPP_H13, NONE), +}; + void mainboard_silicon_init_params(FSP_S_CONFIG *params) { const struct pad_config *gpio_table; @@ -67,6 +75,10 @@ void mainboard_silicon_init_params(FSP_S_CONFIG *params) gpio_table = variant_gpio_table(&num_gpios); cnl_configure_pads(gpio_table, num_gpios); + + /* Disable unused pads for devices with board ID > 2 */ + if (board_id() > 2) + gpio_configure_pads(gpio_unused, ARRAY_SIZE(gpio_unused)); } static void mainboard_enable(struct device *dev) diff --git a/src/mainboard/google/sarien/variants/arcada/include/variant/acpi/mainboard.asl b/src/mainboard/google/sarien/variants/arcada/include/variant/acpi/mainboard.asl index 4b05ba8e90..41121d28fe 100644 --- a/src/mainboard/google/sarien/variants/arcada/include/variant/acpi/mainboard.asl +++ b/src/mainboard/google/sarien/variants/arcada/include/variant/acpi/mainboard.asl @@ -15,8 +15,6 @@ #define CAM_EN GPP_B11 /* Active low */ #define TS_PD GPP_E7 -#define SSD_EN GPP_H13 -#define SSD_RST GPP_H12 /* Method called from LPIT prior to enter s0ix state */ Method (MS0X, 1) @@ -37,13 +35,6 @@ Method (MPTS, 1) /* Clear touch screen pd pin to avoid leakage */ \_SB.PCI0.CTXS (TS_PD) - - /* Clear SSD EN adn RST pin to avoid leakage */ - If (Arg0 == 5) { - \_SB.PCI0.CTXS (SSD_RST) - Sleep(1) - \_SB.PCI0.CTXS (SSD_EN) - } } /* Method called from _WAK prior to wakeup */ diff --git a/src/mainboard/google/sarien/variants/sarien/include/variant/acpi/mainboard.asl b/src/mainboard/google/sarien/variants/sarien/include/variant/acpi/mainboard.asl index 4b05ba8e90..41121d28fe 100644 --- a/src/mainboard/google/sarien/variants/sarien/include/variant/acpi/mainboard.asl +++ b/src/mainboard/google/sarien/variants/sarien/include/variant/acpi/mainboard.asl @@ -15,8 +15,6 @@ #define CAM_EN GPP_B11 /* Active low */ #define TS_PD GPP_E7 -#define SSD_EN GPP_H13 -#define SSD_RST GPP_H12 /* Method called from LPIT prior to enter s0ix state */ Method (MS0X, 1) @@ -37,13 +35,6 @@ Method (MPTS, 1) /* Clear touch screen pd pin to avoid leakage */ \_SB.PCI0.CTXS (TS_PD) - - /* Clear SSD EN adn RST pin to avoid leakage */ - If (Arg0 == 5) { - \_SB.PCI0.CTXS (SSD_RST) - Sleep(1) - \_SB.PCI0.CTXS (SSD_EN) - } } /* Method called from _WAK prior to wakeup */ diff --git a/src/mainboard/google/stout/romstage.c b/src/mainboard/google/stout/romstage.c index 7539dd7f51..6690c6863c 100644 --- a/src/mainboard/google/stout/romstage.c +++ b/src/mainboard/google/stout/romstage.c @@ -41,9 +41,6 @@ void pch_enable_lpc(void) */ pci_write_config16(PCH_LPC_DEV, LPC_EN, KBC_LPC_EN | MC_LPC_EN | CNF1_LPC_EN | FDD_LPC_EN); - - /* Stout EC Decode Range Port68/6C */ - pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, (0x68 | 0x40001)); } void mainboard_rcba_config(void) diff --git a/src/mainboard/hp/2570p/devicetree.cb b/src/mainboard/hp/2570p/devicetree.cb index 585d61d134..79a84b73c2 100644 --- a/src/mainboard/hp/2570p/devicetree.cb +++ b/src/mainboard/hp/2570p/devicetree.cb @@ -46,6 +46,7 @@ chip northbridge/intel/sandybridge chip southbridge/intel/bd82x6x # Intel Series 6 Cougar Point PCH register "c2_latency" = "0x0065" register "docking_supported" = "0" + # mailbox at 0x200/0x201 and PM1 at 0x220 register "gen1_dec" = "0x007c0201" register "gen2_dec" = "0x000c0101" register "gen3_dec" = "0x00fcfe01" diff --git a/src/mainboard/hp/2570p/romstage.c b/src/mainboard/hp/2570p/romstage.c index 21e3ceaa3d..6401909dd5 100644 --- a/src/mainboard/hp/2570p/romstage.c +++ b/src/mainboard/hp/2570p/romstage.c @@ -28,8 +28,6 @@ void pch_enable_lpc(void) */ pci_write_config16(PCH_LPC_DEV, LPC_EN, CNF2_LPC_EN | CNF1_LPC_EN | MC_LPC_EN | KBC_LPC_EN); - /* Enable mailbox at 0x200/0x201 and PM1 at 0x220 */ - pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, 0x007c0201); } void mainboard_rcba_config(void) diff --git a/src/mainboard/hp/2760p/devicetree.cb b/src/mainboard/hp/2760p/devicetree.cb index 515d20f761..a301857b7a 100644 --- a/src/mainboard/hp/2760p/devicetree.cb +++ b/src/mainboard/hp/2760p/devicetree.cb @@ -55,6 +55,7 @@ chip northbridge/intel/sandybridge chip southbridge/intel/bd82x6x # Intel Series 6 Cougar Point PCH register "c2_latency" = "0x0065" register "docking_supported" = "0" + # mailbox at 0x200/0x201 and PM1 at 0x220 register "gen1_dec" = "0x007c0201" register "gen2_dec" = "0x000c0101" register "gen3_dec" = "0x00fcfe01" diff --git a/src/mainboard/hp/2760p/romstage.c b/src/mainboard/hp/2760p/romstage.c index 68af61ba22..ba6f9566cf 100644 --- a/src/mainboard/hp/2760p/romstage.c +++ b/src/mainboard/hp/2760p/romstage.c @@ -27,8 +27,6 @@ void pch_enable_lpc(void) */ pci_write_config16(PCH_LPC_DEV, LPC_EN, CNF2_LPC_EN | CNF1_LPC_EN | MC_LPC_EN | KBC_LPC_EN); - /* Enable mailbox at 0x200/0x201 and PM1 at 0x220 */ - pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, 0x007c0201); } void mainboard_rcba_config(void) diff --git a/src/mainboard/hp/8460p/devicetree.cb b/src/mainboard/hp/8460p/devicetree.cb index 79259b4def..a06aea9669 100644 --- a/src/mainboard/hp/8460p/devicetree.cb +++ b/src/mainboard/hp/8460p/devicetree.cb @@ -54,6 +54,7 @@ chip northbridge/intel/sandybridge chip southbridge/intel/bd82x6x # Intel Series 6 Cougar Point PCH register "c2_latency" = "0x0065" register "docking_supported" = "0" + # mailbox at 0x200/0x201 and PM1 at 0x220 register "gen1_dec" = "0x007c0201" register "gen2_dec" = "0x000c0101" register "gen3_dec" = "0x00fcfe01" diff --git a/src/mainboard/hp/8460p/romstage.c b/src/mainboard/hp/8460p/romstage.c index a3fb5f095f..f30c3a8d27 100644 --- a/src/mainboard/hp/8460p/romstage.c +++ b/src/mainboard/hp/8460p/romstage.c @@ -34,8 +34,6 @@ void pch_enable_lpc(void) CNF2_LPC_EN | CNF1_LPC_EN | MC_LPC_EN | KBC_LPC_EN | LPT_LPC_EN | COMA_LPC_EN); pci_write_config16(PCH_LPC_DEV, LPC_IO_DEC, 0x0010); - /* Enable mailbox at 0x200/0x201 and PM1 at 0x220 */ - pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, 0x007c0201); } void mainboard_rcba_config(void) diff --git a/src/mainboard/hp/8470p/devicetree.cb b/src/mainboard/hp/8470p/devicetree.cb index 2a115cc62a..471537218e 100644 --- a/src/mainboard/hp/8470p/devicetree.cb +++ b/src/mainboard/hp/8470p/devicetree.cb @@ -55,6 +55,7 @@ chip northbridge/intel/sandybridge chip southbridge/intel/bd82x6x # Intel Series 6 Cougar Point PCH register "c2_latency" = "0x0065" register "docking_supported" = "0" + # mailbox at 0x200/0x201 and PM1 at 0x220 register "gen1_dec" = "0x007c0201" register "gen2_dec" = "0x000c0101" register "gen3_dec" = "0x00fcfe01" diff --git a/src/mainboard/hp/8470p/romstage.c b/src/mainboard/hp/8470p/romstage.c index a8761739d5..b1375e815b 100644 --- a/src/mainboard/hp/8470p/romstage.c +++ b/src/mainboard/hp/8470p/romstage.c @@ -33,8 +33,6 @@ void pch_enable_lpc(void) CNF2_LPC_EN | CNF1_LPC_EN | MC_LPC_EN | KBC_LPC_EN | LPT_LPC_EN | COMA_LPC_EN); pci_write_config16(PCH_LPC_DEV, LPC_IO_DEC, 0x0010); - /* Enable mailbox at 0x200/0x201 and PM1 at 0x220 */ - pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, 0x007c0201); } void mainboard_rcba_config(void) diff --git a/src/mainboard/hp/8770w/devicetree.cb b/src/mainboard/hp/8770w/devicetree.cb index 7d74c940de..d98402c540 100644 --- a/src/mainboard/hp/8770w/devicetree.cb +++ b/src/mainboard/hp/8770w/devicetree.cb @@ -43,6 +43,7 @@ chip northbridge/intel/sandybridge chip southbridge/intel/bd82x6x # Intel Series 7 Panther Point PCH register "c2_latency" = "0x0065" register "docking_supported" = "0" + # mailbox at 0x200/0x201 and PM1 at 0x220 register "gen1_dec" = "0x007c0201" register "gen2_dec" = "0x000c0101" register "gen3_dec" = "0x00fcfe01" diff --git a/src/mainboard/hp/8770w/romstage.c b/src/mainboard/hp/8770w/romstage.c index a7f6b22aa3..8956b08b7b 100644 --- a/src/mainboard/hp/8770w/romstage.c +++ b/src/mainboard/hp/8770w/romstage.c @@ -34,8 +34,6 @@ void pch_enable_lpc(void) CNF2_LPC_EN | CNF1_LPC_EN | MC_LPC_EN | KBC_LPC_EN | LPT_LPC_EN | COMA_LPC_EN); pci_write_config16(PCH_LPC_DEV, LPC_IO_DEC, 0x0010); - /* Enable mailbox at 0x200/0x201 and PM1 at 0x220 */ - pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, 0x007c0201); } void mainboard_rcba_config(void) diff --git a/src/mainboard/hp/compaq_8200_elite_sff/romstage.c b/src/mainboard/hp/compaq_8200_elite_sff/romstage.c index 4b640689b7..3c388776c3 100644 --- a/src/mainboard/hp/compaq_8200_elite_sff/romstage.c +++ b/src/mainboard/hp/compaq_8200_elite_sff/romstage.c @@ -17,7 +17,6 @@ */ #include -#include #include #include #include diff --git a/src/mainboard/hp/folio_9470m/devicetree.cb b/src/mainboard/hp/folio_9470m/devicetree.cb index 5d4e5b8ea2..d626934343 100644 --- a/src/mainboard/hp/folio_9470m/devicetree.cb +++ b/src/mainboard/hp/folio_9470m/devicetree.cb @@ -46,6 +46,7 @@ chip northbridge/intel/sandybridge # FIXME: check gfx.ndid and gfx.did chip southbridge/intel/bd82x6x # Intel Series 6 Cougar Point PCH register "c2_latency" = "0x0065" register "docking_supported" = "0" + # mailbox at 0x200/0x201 and PM1 at 0x220 register "gen1_dec" = "0x007c0201" register "gen2_dec" = "0x000c0101" register "gen3_dec" = "0x00fcfe01" diff --git a/src/mainboard/hp/folio_9470m/romstage.c b/src/mainboard/hp/folio_9470m/romstage.c index db3296c457..8ff7813cd9 100644 --- a/src/mainboard/hp/folio_9470m/romstage.c +++ b/src/mainboard/hp/folio_9470m/romstage.c @@ -30,8 +30,6 @@ void pch_enable_lpc(void) pci_write_config16(PCH_LPC_DEV, LPC_EN, CNF2_LPC_EN | CNF1_LPC_EN | MC_LPC_EN | KBC_LPC_EN); pci_write_config16(PCH_LPC_DEV, LPC_IO_DEC, 0x0010); - /* Enable mailbox at 0x200/0x201 and PM1 at 0x220 */ - pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, 0x007c0201); } void mainboard_rcba_config(void) diff --git a/src/mainboard/hp/revolve_810_g1/devicetree.cb b/src/mainboard/hp/revolve_810_g1/devicetree.cb index 4d0d6395eb..ad69ca27e4 100644 --- a/src/mainboard/hp/revolve_810_g1/devicetree.cb +++ b/src/mainboard/hp/revolve_810_g1/devicetree.cb @@ -46,6 +46,7 @@ chip northbridge/intel/sandybridge # FIXME: check gfx.ndid and gfx.did chip southbridge/intel/bd82x6x # Intel Series 6 Cougar Point PCH register "c2_latency" = "0x0065" register "docking_supported" = "0" + # mailbox at 0x200/0x201 and PM1 at 0x220 register "gen1_dec" = "0x007c0201" register "gen2_dec" = "0x000c0101" register "gen3_dec" = "0x00fcfe01" diff --git a/src/mainboard/hp/revolve_810_g1/romstage.c b/src/mainboard/hp/revolve_810_g1/romstage.c index f62024c3e6..5f8df63f5c 100644 --- a/src/mainboard/hp/revolve_810_g1/romstage.c +++ b/src/mainboard/hp/revolve_810_g1/romstage.c @@ -33,8 +33,6 @@ void pch_enable_lpc(void) pci_write_config16(PCH_LPC_DEV, LPC_EN, CNF2_LPC_EN | CNF1_LPC_EN | MC_LPC_EN | KBC_LPC_EN); pci_write_config16(PCH_LPC_DEV, LPC_IO_DEC, 0x0010); - /* Enable mailbox at 0x200/0x201 and PM1 at 0x220 */ - pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, 0x007c0201); } void mainboard_rcba_config(void) diff --git a/src/mainboard/hp/z220_sff_workstation/romstage.c b/src/mainboard/hp/z220_sff_workstation/romstage.c index 0804dd0c7a..9883879bae 100644 --- a/src/mainboard/hp/z220_sff_workstation/romstage.c +++ b/src/mainboard/hp/z220_sff_workstation/romstage.c @@ -17,7 +17,6 @@ */ #include -#include #include #include #include diff --git a/src/mainboard/ibase/mb899/Kconfig b/src/mainboard/ibase/mb899/Kconfig index 621395daac..fcc2e38751 100644 --- a/src/mainboard/ibase/mb899/Kconfig +++ b/src/mainboard/ibase/mb899/Kconfig @@ -14,7 +14,6 @@ config BOARD_SPECIFIC_OPTIONS select HAVE_OPTION_TABLE select HAVE_ACPI_RESUME select BOARD_ROMSIZE_KB_512 - select CHANNEL_XOR_RANDOMIZATION select INTEL_INT15 config MAINBOARD_DIR diff --git a/src/mainboard/intel/cannonlake_rvp/romstage_fsp_params.c b/src/mainboard/intel/cannonlake_rvp/romstage_fsp_params.c index 2396505906..edb5894ba5 100644 --- a/src/mainboard/intel/cannonlake_rvp/romstage_fsp_params.c +++ b/src/mainboard/intel/cannonlake_rvp/romstage_fsp_params.c @@ -13,7 +13,6 @@ * GNU General Public License for more details. */ -#include #include #include #include diff --git a/src/mainboard/intel/cannonlake_rvp/spd/spd_util.c b/src/mainboard/intel/cannonlake_rvp/spd/spd_util.c index dd209dce55..0c2f74781b 100644 --- a/src/mainboard/intel/cannonlake_rvp/spd/spd_util.c +++ b/src/mainboard/intel/cannonlake_rvp/spd/spd_util.c @@ -13,7 +13,6 @@ * GNU General Public License for more details. */ -#include #include #include diff --git a/src/mainboard/intel/coffeelake_rvp/variants/whl_u/devicetree.cb b/src/mainboard/intel/coffeelake_rvp/variants/whl_u/devicetree.cb index e30da3af4d..429d5daca8 100644 --- a/src/mainboard/intel/coffeelake_rvp/variants/whl_u/devicetree.cb +++ b/src/mainboard/intel/coffeelake_rvp/variants/whl_u/devicetree.cb @@ -9,6 +9,19 @@ chip soc/intel/cannonlake register "ScsEmmcHs400Enabled" = "1" register "HeciEnabled" = "1" + # Enable eDP device + register "DdiPortEdp" = "1" + # Enable HPD for DDI ports B/C/D/F + register "DdiPortBHpd" = "1" + register "DdiPortCHpd" = "1" + register "DdiPortDHpd" = "1" + register "DdiPortFHpd" = "1" + # Enable DDC for DDI ports B/C/D/F + register "DdiPortBDdc" = "1" + register "DdiPortCDdc" = "1" + register "DdiPortDDdc" = "1" + register "DdiPortFDdc" = "1" + register "usb2_ports[0]" = "USB2_PORT_TYPE_C(OC0)" register "usb2_ports[1]" = "USB2_PORT_MID(OC0)" register "usb2_ports[2]" = "USB2_PORT_MID(OC0)" diff --git a/src/mainboard/intel/d945gclf/Kconfig b/src/mainboard/intel/d945gclf/Kconfig index 70fa848bed..46d82ec5f7 100644 --- a/src/mainboard/intel/d945gclf/Kconfig +++ b/src/mainboard/intel/d945gclf/Kconfig @@ -28,7 +28,6 @@ config BOARD_SPECIFIC_OPTIONS select HAVE_ACPI_TABLES select HAVE_ACPI_RESUME select BOARD_ROMSIZE_KB_512 - select CHANNEL_XOR_RANDOMIZATION select MAINBOARD_HAS_NATIVE_VGA_INIT select INTEL_GMA_HAVE_VBT diff --git a/src/mainboard/intel/emeraldlake2/devicetree.cb b/src/mainboard/intel/emeraldlake2/devicetree.cb index 60072b0995..4ed1f3c694 100644 --- a/src/mainboard/intel/emeraldlake2/devicetree.cb +++ b/src/mainboard/intel/emeraldlake2/devicetree.cb @@ -44,8 +44,11 @@ chip northbridge/intel/sandybridge register "sata_port_map" = "0x3f" + register "gen1_dec" = "0x00fc1601" + # runtime_port registers + register "gen2_dec" = "0x000c0181" # SuperIO range is 0x700-0x73f - register "gen2_dec" = "0x003c0701" + register "gen3_dec" = "0x003c0701" register "c2_latency" = "1" register "p_cnt_throttling_supported" = "0" diff --git a/src/mainboard/intel/emeraldlake2/romstage.c b/src/mainboard/intel/emeraldlake2/romstage.c index 9a9fc24677..a28ae78f28 100644 --- a/src/mainboard/intel/emeraldlake2/romstage.c +++ b/src/mainboard/intel/emeraldlake2/romstage.c @@ -39,12 +39,6 @@ void pch_enable_lpc(void) u16 lpc_config = CNF1_LPC_EN | CNF2_LPC_EN | KBC_LPC_EN; pci_write_config16(dev, LPC_EN, lpc_config); - /* Map 256 bytes at 0x1600 to the LPC bus. */ - pci_write_config32(dev, LPC_GEN1_DEC, 0xfc1601); - - /* Map a range for the runtime_port registers to the LPC bus. */ - pci_write_config32(dev, LPC_GEN2_DEC, 0xc0181); - /* Enable COM1 */ if (sio1007_enable_uart_at(SIO_PORT)) { pci_write_config16(dev, LPC_EN, diff --git a/src/mainboard/intel/harcuvar/spd/spd.c b/src/mainboard/intel/harcuvar/spd/spd.c index 914e4fd14c..61bf2e589b 100644 --- a/src/mainboard/intel/harcuvar/spd/spd.c +++ b/src/mainboard/intel/harcuvar/spd/spd.c @@ -15,7 +15,6 @@ * */ -#include #include #include diff --git a/src/mainboard/intel/icelake_rvp/romstage_fsp_params.c b/src/mainboard/intel/icelake_rvp/romstage_fsp_params.c index fd1638bfab..5a4d6814c4 100644 --- a/src/mainboard/intel/icelake_rvp/romstage_fsp_params.c +++ b/src/mainboard/intel/icelake_rvp/romstage_fsp_params.c @@ -13,7 +13,6 @@ * GNU General Public License for more details. */ -#include #include #include #include diff --git a/src/mainboard/intel/icelake_rvp/spd/spd_util.c b/src/mainboard/intel/icelake_rvp/spd/spd_util.c index 8d7eaf69ce..d7babbd082 100644 --- a/src/mainboard/intel/icelake_rvp/spd/spd_util.c +++ b/src/mainboard/intel/icelake_rvp/spd/spd_util.c @@ -13,7 +13,6 @@ * GNU General Public License for more details. */ -#include #include #include #include diff --git a/src/mainboard/intel/kblrvp/Kconfig b/src/mainboard/intel/kblrvp/Kconfig index 52cee2dfd3..c0737cbce6 100644 --- a/src/mainboard/intel/kblrvp/Kconfig +++ b/src/mainboard/intel/kblrvp/Kconfig @@ -9,9 +9,8 @@ config BOARD_SPECIFIC_OPTIONS select HAVE_ACPI_TABLES select HAVE_OPTION_TABLE select SOC_INTEL_COMMON_BLOCK_HDA_VERB if !BOARD_INTEL_KBLRVP8 - select SOC_INTEL_SKYLAKE + select SOC_INTEL_KABYLAKE select SKYLAKE_SOC_PCH_H if BOARD_INTEL_KBLRVP8 || BOARD_INTEL_KBLRVP11 - select MAINBOARD_USES_FSP2_0 select MAINBOARD_HAS_CHROMEOS select GENERIC_SPD_BIN select MAINBOARD_HAS_LPC_TPM diff --git a/src/mainboard/intel/kblrvp/romstage.c b/src/mainboard/intel/kblrvp/romstage.c index 1a483bda45..0385e29eac 100644 --- a/src/mainboard/intel/kblrvp/romstage.c +++ b/src/mainboard/intel/kblrvp/romstage.c @@ -13,7 +13,6 @@ * GNU General Public License for more details. */ -#include #include #include #include diff --git a/src/mainboard/intel/kblrvp/spd/spd_util.c b/src/mainboard/intel/kblrvp/spd/spd_util.c index f22dcaa3b7..9318c3975d 100644 --- a/src/mainboard/intel/kblrvp/spd/spd_util.c +++ b/src/mainboard/intel/kblrvp/spd/spd_util.c @@ -13,7 +13,6 @@ * GNU General Public License for more details. */ -#include #include #include diff --git a/src/mainboard/intel/kunimitsu/romstage_fsp20.c b/src/mainboard/intel/kunimitsu/romstage_fsp20.c index ee1ddd58cb..536469339d 100644 --- a/src/mainboard/intel/kunimitsu/romstage_fsp20.c +++ b/src/mainboard/intel/kunimitsu/romstage_fsp20.c @@ -13,7 +13,6 @@ * GNU General Public License for more details. */ -#include #include #include #include "gpio.h" diff --git a/src/mainboard/intel/kunimitsu/spd/spd.c b/src/mainboard/intel/kunimitsu/spd/spd.c index bebb544a4d..db5e24e927 100644 --- a/src/mainboard/intel/kunimitsu/spd/spd.c +++ b/src/mainboard/intel/kunimitsu/spd/spd.c @@ -14,7 +14,6 @@ * GNU General Public License for more details. */ -#include #include #include #include diff --git a/src/mainboard/intel/kunimitsu/spd/spd_util.c b/src/mainboard/intel/kunimitsu/spd/spd_util.c index b173628e29..288ee1e7ee 100644 --- a/src/mainboard/intel/kunimitsu/spd/spd_util.c +++ b/src/mainboard/intel/kunimitsu/spd/spd_util.c @@ -12,7 +12,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ -#include #include #include #include diff --git a/src/mainboard/intel/saddlebrook/Kconfig b/src/mainboard/intel/saddlebrook/Kconfig index f2b7344aaa..934c15affd 100644 --- a/src/mainboard/intel/saddlebrook/Kconfig +++ b/src/mainboard/intel/saddlebrook/Kconfig @@ -29,14 +29,10 @@ config BOARD_SPECIFIC_OPTIONS select SOC_INTEL_SKYLAKE select SUPERIO_NUVOTON_NCT6776 select SUPERIO_NUVOTON_NCT6776_COM_A - select SADDLEBROOK_USES_FSP1_1 select HAVE_CMOS_DEFAULT select MAINBOARD_USES_IFD_GBE_REGION select USE_INTEL_FSP_MP_INIT -config SADDLEBROOK_USES_FSP1_1 - bool "FSP driver 1.1" - config IRQ_SLOT_COUNT int default 18 diff --git a/src/mainboard/intel/strago/fadt.c b/src/mainboard/intel/strago/fadt.c index 9814d1e667..2a54254aa1 100644 --- a/src/mainboard/intel/strago/fadt.c +++ b/src/mainboard/intel/strago/fadt.c @@ -25,7 +25,7 @@ void acpi_create_fadt(acpi_fadt_t *fadt, acpi_facs_t *facs, void *dsdt) memset((void *) fadt, 0, sizeof(acpi_fadt_t)); memcpy(header->signature, "FACP", 4); header->length = sizeof(acpi_fadt_t); - header->revision = 3; + header->revision = get_acpi_table_revision(FADT); memcpy(header->oem_id, OEM_ID, 6); memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); memcpy(header->asl_compiler_id, ASLC, 4); diff --git a/src/mainboard/kontron/986lcd-m/Kconfig b/src/mainboard/kontron/986lcd-m/Kconfig index 43bdf14501..9dadd55cbe 100644 --- a/src/mainboard/kontron/986lcd-m/Kconfig +++ b/src/mainboard/kontron/986lcd-m/Kconfig @@ -14,7 +14,6 @@ config BOARD_SPECIFIC_OPTIONS select HAVE_OPTION_TABLE select HAVE_ACPI_RESUME select BOARD_ROMSIZE_KB_1024 - select CHANNEL_XOR_RANDOMIZATION select INTEL_INT15 select OVERRIDE_CLOCK_DISABLE diff --git a/src/mainboard/lenovo/l520/romstage.c b/src/mainboard/lenovo/l520/romstage.c index c8003ae0a6..426ac4e6fa 100644 --- a/src/mainboard/lenovo/l520/romstage.c +++ b/src/mainboard/lenovo/l520/romstage.c @@ -29,10 +29,6 @@ void pch_enable_lpc(void) pci_write_config16(PCH_LPC_DEV, LPC_EN, CNF2_LPC_EN | CNF1_LPC_EN | MC_LPC_EN | KBC_LPC_EN | LPT_LPC_EN); - - pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, 0x7c1611); - pci_write_config32(PCH_LPC_DEV, LPC_GEN2_DEC, 0x040069); - pci_write_config32(PCH_LPC_DEV, LPC_GEN3_DEC, 0x0c0701); } void mainboard_rcba_config(void) diff --git a/src/mainboard/lenovo/s230u/romstage.c b/src/mainboard/lenovo/s230u/romstage.c index 03ee4dba06..dd8fc17268 100644 --- a/src/mainboard/lenovo/s230u/romstage.c +++ b/src/mainboard/lenovo/s230u/romstage.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -31,9 +30,6 @@ void pch_enable_lpc(void) { pci_write_config16(PCH_LPC_DEV, LPC_EN, MC_LPC_EN | KBC_LPC_EN); - pci_write_config32(PCH_LPC_DEV, LPC_GEN2_DEC, 0xc0701); - pci_write_config32(PCH_LPC_DEV, LPC_GEN3_DEC, 0xc0069); - pci_write_config32(PCH_LPC_DEV, LPC_GEN4_DEC, 0xc06a1); pci_write_config32(PCH_LPC_DEV, ETR3, 0x10000); /* Memory map KB9012 EC registers */ diff --git a/src/mainboard/lenovo/t400/fadt.c b/src/mainboard/lenovo/t400/fadt.c index 673791f99c..e335787100 100644 --- a/src/mainboard/lenovo/t400/fadt.c +++ b/src/mainboard/lenovo/t400/fadt.c @@ -29,7 +29,7 @@ void acpi_create_fadt(acpi_fadt_t * fadt, acpi_facs_t * facs, void *dsdt) memset((void *) fadt, 0, sizeof(acpi_fadt_t)); memcpy(header->signature, "FACP", 4); header->length = sizeof(acpi_fadt_t); - header->revision = 3; + header->revision = get_acpi_table_revision(FADT); memcpy(header->oem_id, OEM_ID, 6); memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); memcpy(header->asl_compiler_id, ASLC, 4); diff --git a/src/mainboard/lenovo/t420/romstage.c b/src/mainboard/lenovo/t420/romstage.c index 806c72a3be..ebf5aed0f1 100644 --- a/src/mainboard/lenovo/t420/romstage.c +++ b/src/mainboard/lenovo/t420/romstage.c @@ -56,10 +56,6 @@ void pch_enable_lpc(void) pci_write_config16(PCH_LPC_DEV, LPC_EN, CNF2_LPC_EN | CNF1_LPC_EN | MC_LPC_EN | KBC_LPC_EN); - pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, 0x7c1601); - pci_write_config32(PCH_LPC_DEV, LPC_GEN2_DEC, 0xc15e1); - pci_write_config32(PCH_LPC_DEV, LPC_GEN4_DEC, 0x0c06a1); - pci_write_config32(PCH_LPC_DEV, ETR3, 0x10000); } diff --git a/src/mainboard/lenovo/t420s/romstage.c b/src/mainboard/lenovo/t420s/romstage.c index c42d165643..49de58d8d1 100644 --- a/src/mainboard/lenovo/t420s/romstage.c +++ b/src/mainboard/lenovo/t420s/romstage.c @@ -15,7 +15,6 @@ * GNU General Public License for more details. */ -#include #include #include #include @@ -57,10 +56,6 @@ void pch_enable_lpc(void) pci_write_config16(PCH_LPC_DEV, LPC_EN, CNF2_LPC_EN | CNF1_LPC_EN | MC_LPC_EN | KBC_LPC_EN); - pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, 0x7c1601); - pci_write_config32(PCH_LPC_DEV, LPC_GEN2_DEC, 0xc15e1); - pci_write_config32(PCH_LPC_DEV, LPC_GEN4_DEC, 0x0c06a1); - pci_write_config32(PCH_LPC_DEV, ETR3, 0x10000); } diff --git a/src/mainboard/lenovo/t420s/smihandler.c b/src/mainboard/lenovo/t420s/smihandler.c index 2713725b36..bc72a12e23 100644 --- a/src/mainboard/lenovo/t420s/smihandler.c +++ b/src/mainboard/lenovo/t420s/smihandler.c @@ -16,7 +16,6 @@ */ #include -#include #include #include #include diff --git a/src/mainboard/lenovo/t430/romstage.c b/src/mainboard/lenovo/t430/romstage.c index db50bb3017..1f4b90d7f9 100644 --- a/src/mainboard/lenovo/t430/romstage.c +++ b/src/mainboard/lenovo/t430/romstage.c @@ -55,9 +55,6 @@ void pch_enable_lpc(void) /* Enable TPM, EC, PS/2 Keyboard/Mouse */ pci_write_config16(PCH_LPC_DEV, LPC_EN, CNF2_LPC_EN | MC_LPC_EN | KBC_LPC_EN); - - pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, - (0x0c << 16) | EC_LENOVO_PMH7_BASE | 1); } void mainboard_rcba_config(void) diff --git a/src/mainboard/lenovo/t430s/romstage.c b/src/mainboard/lenovo/t430s/romstage.c index 4edd5c6131..e590bb6c67 100644 --- a/src/mainboard/lenovo/t430s/romstage.c +++ b/src/mainboard/lenovo/t430s/romstage.c @@ -26,10 +26,6 @@ void pch_enable_lpc(void) pci_write_config16(PCH_LPC_DEV, LPC_EN, CNF2_LPC_EN | CNF1_LPC_EN | MC_LPC_EN | KBC_LPC_EN); - pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, 0x7c1601); - pci_write_config32(PCH_LPC_DEV, LPC_GEN2_DEC, 0xc15e1); - pci_write_config32(PCH_LPC_DEV, LPC_GEN4_DEC, 0x0c06a1); - pci_write_config32(PCH_LPC_DEV, ETR3, 0x10000); } diff --git a/src/mainboard/lenovo/t430s/smihandler.c b/src/mainboard/lenovo/t430s/smihandler.c index 2810e5ae91..f06eaf717f 100644 --- a/src/mainboard/lenovo/t430s/smihandler.c +++ b/src/mainboard/lenovo/t430s/smihandler.c @@ -16,7 +16,6 @@ */ #include -#include #include #include #include diff --git a/src/mainboard/lenovo/t430s/variants/t430s/romstage.c b/src/mainboard/lenovo/t430s/variants/t430s/romstage.c index 5bc7b80961..84bd447ab2 100644 --- a/src/mainboard/lenovo/t430s/variants/t430s/romstage.c +++ b/src/mainboard/lenovo/t430s/variants/t430s/romstage.c @@ -16,7 +16,6 @@ */ #include -#include #include #include #include diff --git a/src/mainboard/lenovo/t430s/variants/t431s/romstage.c b/src/mainboard/lenovo/t430s/variants/t431s/romstage.c index 7591f8b873..e7b43db487 100644 --- a/src/mainboard/lenovo/t430s/variants/t431s/romstage.c +++ b/src/mainboard/lenovo/t430s/variants/t431s/romstage.c @@ -16,7 +16,6 @@ */ #include -#include #include #include #include diff --git a/src/mainboard/lenovo/t520/romstage.c b/src/mainboard/lenovo/t520/romstage.c index 96d07feac2..5c23b8e06f 100644 --- a/src/mainboard/lenovo/t520/romstage.c +++ b/src/mainboard/lenovo/t520/romstage.c @@ -16,7 +16,6 @@ */ #include -#include #include #include #include @@ -59,10 +58,6 @@ void pch_enable_lpc(void) pci_write_config16(PCH_LPC_DEV, LPC_EN, CNF2_LPC_EN | CNF1_LPC_EN | MC_LPC_EN | KBC_LPC_EN); - pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, 0x7c1601); - pci_write_config32(PCH_LPC_DEV, LPC_GEN2_DEC, 0xc15e1); - pci_write_config32(PCH_LPC_DEV, LPC_GEN4_DEC, 0x0c06a1); - pci_write_config32(PCH_LPC_DEV, ETR3, 0x10000); } diff --git a/src/mainboard/lenovo/t520/smihandler.c b/src/mainboard/lenovo/t520/smihandler.c index 46ad664c3c..35a26c0ebd 100644 --- a/src/mainboard/lenovo/t520/smihandler.c +++ b/src/mainboard/lenovo/t520/smihandler.c @@ -16,7 +16,6 @@ */ #include -#include #include #include #include diff --git a/src/mainboard/lenovo/t530/romstage.c b/src/mainboard/lenovo/t530/romstage.c index 2b850a20b1..67cf97c486 100644 --- a/src/mainboard/lenovo/t530/romstage.c +++ b/src/mainboard/lenovo/t530/romstage.c @@ -16,7 +16,6 @@ */ #include -#include #include #include #include @@ -59,10 +58,6 @@ void pch_enable_lpc(void) pci_write_config16(PCH_LPC_DEV, LPC_EN, CNF2_LPC_EN | CNF1_LPC_EN | MC_LPC_EN | KBC_LPC_EN); - pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, 0x7c1601); - pci_write_config32(PCH_LPC_DEV, LPC_GEN2_DEC, 0xc15e1); - pci_write_config32(PCH_LPC_DEV, LPC_GEN4_DEC, 0x0c06a1); - pci_write_config32(PCH_LPC_DEV, ETR3, 0x10000); } diff --git a/src/mainboard/lenovo/t530/smihandler.c b/src/mainboard/lenovo/t530/smihandler.c index 46ad664c3c..35a26c0ebd 100644 --- a/src/mainboard/lenovo/t530/smihandler.c +++ b/src/mainboard/lenovo/t530/smihandler.c @@ -16,7 +16,6 @@ */ #include -#include #include #include #include diff --git a/src/mainboard/lenovo/t60/Kconfig b/src/mainboard/lenovo/t60/Kconfig index a6a88b37d3..e4e87c93ef 100644 --- a/src/mainboard/lenovo/t60/Kconfig +++ b/src/mainboard/lenovo/t60/Kconfig @@ -17,7 +17,6 @@ config BOARD_SPECIFIC_OPTIONS select INTEL_INT15 select HAVE_MP_TABLE select BOARD_ROMSIZE_KB_2048 - select CHANNEL_XOR_RANDOMIZATION select HAVE_ACPI_TABLES select HAVE_ACPI_RESUME select H8_DOCK_EARLY_INIT diff --git a/src/mainboard/lenovo/t60/mptable.c b/src/mainboard/lenovo/t60/mptable.c index 838757e0c6..165b725ac6 100644 --- a/src/mainboard/lenovo/t60/mptable.c +++ b/src/mainboard/lenovo/t60/mptable.c @@ -41,21 +41,21 @@ static void *smp_write_config_table(void *v) smp_write_intsrc(mc, mp_ExtINT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, isa_bus, 0x00, MP_APIC_ALL, 0x00); smp_write_intsrc(mc, mp_NMI, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT, isa_bus, 0x00, MP_APIC_ALL, 0x01); - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x01 << 2), 0x02, 0x10); /* PCIe root 0.02.0 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x02 << 2), 0x02, 0x10); /* VGA 0.02.0 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1b << 2), 0x02, 0x11); /* HD Audio 0:1b.0 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1c << 2), 0x02, 0x14); /* PCIe 0:1c.0 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1c << 2) | 0x01, 0x02, 0x15); /* PCIe 0:1c.1 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1c << 2) | 0x02, 0x02, 0x16); /* PCIe 0:1c.2 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1c << 2) | 0x03, 0x02, 0x17); /* PCIe 0:1c.3 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1d << 2) , 0x02, 0x10); /* USB 0:1d.0 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1d << 2) | 0x01, 0x02, 0x11); /* USB 0:1d.1 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1d << 2) | 0x02, 0x02, 0x12); /* USB 0:1d.2 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1d << 2) | 0x03, 0x02, 0x13); /* USB 0:1d.3 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1f << 2) , 0x02, 0x17); /* LPC 0:1f.0 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1f << 2) | 0x01, 0x02, 0x10); /* IDE 0:1f.1 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1f << 2) | 0x02, 0x02, 0x10); /* SATA 0:1f.2 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x06, (0x00 << 2) | 0x00, 0x02, 0x10); /* Cardbus 6:00.0 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x01, 0x00, 0x02, 0x10); /* PCIe root 0.01.0 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x02, 0x00, 0x02, 0x10); /* VGA 0.02.0 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1b, 0x00, 0x02, 0x11); /* HD Audio 0:1b.0 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1c, 0x00, 0x02, 0x14); /* PCIe 0:1c.0 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1c, 0x01, 0x02, 0x15); /* PCIe 0:1c.1 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1c, 0x02, 0x02, 0x16); /* PCIe 0:1c.2 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1c, 0x03, 0x02, 0x17); /* PCIe 0:1c.3 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1d, 0x00, 0x02, 0x10); /* USB 0:1d.0 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1d, 0x01, 0x02, 0x11); /* USB 0:1d.1 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1d, 0x02, 0x02, 0x12); /* USB 0:1d.2 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1d, 0x03, 0x02, 0x13); /* USB 0:1d.3 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1f, 0x00, 0x02, 0x17); /* LPC 0:1f.0 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1f, 0x01, 0x02, 0x10); /* IDE 0:1f.1 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1f, 0x02, 0x02, 0x10); /* SATA 0:1f.2 */ + smp_write_pci_intsrc(mc, mp_INT, 0x06, 0x00, 0x00, 0x02, 0x10); /* Cardbus 6:00.0 */ mptable_lintsrc(mc, isa_bus); return mptable_finalize(mc); diff --git a/src/mainboard/lenovo/t60/romstage.c b/src/mainboard/lenovo/t60/romstage.c index 0c7c0cfb2d..820cd5265e 100644 --- a/src/mainboard/lenovo/t60/romstage.c +++ b/src/mainboard/lenovo/t60/romstage.c @@ -18,7 +18,6 @@ // __PRE_RAM__ means: use "unsigned" for device, not a struct. #include -#include #include #include #include diff --git a/src/mainboard/lenovo/x131e/romstage.c b/src/mainboard/lenovo/x131e/romstage.c index ea550aa143..79a2276fd0 100644 --- a/src/mainboard/lenovo/x131e/romstage.c +++ b/src/mainboard/lenovo/x131e/romstage.c @@ -26,11 +26,6 @@ void pch_enable_lpc(void) /* Enable TPM, EC, PS/2 Keyboard/Mouse */ pci_write_config16(PCH_LPC_DEV, LPC_EN, CNF2_LPC_EN | CNF1_LPC_EN | MC_LPC_EN | KBC_LPC_EN); - - pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, 0x007c1611); - pci_write_config32(PCH_LPC_DEV, LPC_GEN2_DEC, 0x00040069); - pci_write_config32(PCH_LPC_DEV, LPC_GEN3_DEC, 0x000c0701); - pci_write_config32(PCH_LPC_DEV, LPC_GEN4_DEC, 0x000c06a1); } void mainboard_rcba_config(void) diff --git a/src/mainboard/lenovo/x1_carbon_gen1/romstage.c b/src/mainboard/lenovo/x1_carbon_gen1/romstage.c index c65060f9f9..f666671dd6 100644 --- a/src/mainboard/lenovo/x1_carbon_gen1/romstage.c +++ b/src/mainboard/lenovo/x1_carbon_gen1/romstage.c @@ -18,7 +18,6 @@ #include #include -#include #include #include #include @@ -36,10 +35,6 @@ void pch_enable_lpc(void) pci_write_config16(PCH_LPC_DEV, LPC_EN, CNF2_LPC_EN | CNF1_LPC_EN | MC_LPC_EN | KBC_LPC_EN); - pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, 0x7c1601); - pci_write_config32(PCH_LPC_DEV, LPC_GEN2_DEC, 0xc15e1); - pci_write_config32(PCH_LPC_DEV, LPC_GEN4_DEC, 0x0c06a1); - pci_write_config32(PCH_LPC_DEV, ETR3, 0x10000); } diff --git a/src/mainboard/lenovo/x200/fadt.c b/src/mainboard/lenovo/x200/fadt.c index 673791f99c..e335787100 100644 --- a/src/mainboard/lenovo/x200/fadt.c +++ b/src/mainboard/lenovo/x200/fadt.c @@ -29,7 +29,7 @@ void acpi_create_fadt(acpi_fadt_t * fadt, acpi_facs_t * facs, void *dsdt) memset((void *) fadt, 0, sizeof(acpi_fadt_t)); memcpy(header->signature, "FACP", 4); header->length = sizeof(acpi_fadt_t); - header->revision = 3; + header->revision = get_acpi_table_revision(FADT); memcpy(header->oem_id, OEM_ID, 6); memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); memcpy(header->asl_compiler_id, ASLC, 4); diff --git a/src/mainboard/lenovo/x201/acpi_tables.c b/src/mainboard/lenovo/x201/acpi_tables.c index 82991b267b..6fd47d7276 100644 --- a/src/mainboard/lenovo/x201/acpi_tables.c +++ b/src/mainboard/lenovo/x201/acpi_tables.c @@ -15,7 +15,6 @@ * GNU General Public License for more details. */ -#include #include #include "thermal.h" diff --git a/src/mainboard/lenovo/x201/mainboard.c b/src/mainboard/lenovo/x201/mainboard.c index b8129ad294..70b393cc18 100644 --- a/src/mainboard/lenovo/x201/mainboard.c +++ b/src/mainboard/lenovo/x201/mainboard.c @@ -23,25 +23,10 @@ #include #include #include - #include "dock.h" #include #include -#include #include -#include - -static acpi_cstate_t cst_entries[] = { - {1, 1, 1000, {0x7f, 1, 2, 0, 1, 0} }, - {2, 1, 500, {0x01, 8, 0, 0, DEFAULT_PMBASE + LV2, 0} }, - {2, 17, 250, {0x01, 8, 0, 0, DEFAULT_PMBASE + LV3, 0} }, -}; - -int get_cst_entries(acpi_cstate_t **entries) -{ - *entries = cst_entries; - return ARRAY_SIZE(cst_entries); -} static void mainboard_init(struct device *dev) { diff --git a/src/mainboard/lenovo/x201/smihandler.c b/src/mainboard/lenovo/x201/smihandler.c index fc6a0e9670..e80782acf6 100644 --- a/src/mainboard/lenovo/x201/smihandler.c +++ b/src/mainboard/lenovo/x201/smihandler.c @@ -15,15 +15,11 @@ */ #include -#include #include #include #include #include -#include -#include #include -#include #include #include #include @@ -74,23 +70,6 @@ int mainboard_io_trap_handler(int smif) return 1; } -static void mainboard_smi_brightness_up(void) -{ - u8 value; - - if ((value = pci_read_config8(PCI_DEV(0, 2, 1), 0xf4)) < 0xf0) - pci_write_config8(PCI_DEV(0, 2, 1), 0xf4, (value + 0x10) | 0xf); -} - -static void mainboard_smi_brightness_down(void) -{ - u8 value; - - if ((value = pci_read_config8(PCI_DEV(0, 2, 1), 0xf4)) > 0x10) - pci_write_config8(PCI_DEV(0, 2, 1), 0xf4, - (value - 0x10) & 0xf0); -} - static void mainboard_smi_handle_ec_sci(void) { u8 status = inb(EC_SC); @@ -103,14 +82,6 @@ static void mainboard_smi_handle_ec_sci(void) printk(BIOS_DEBUG, "EC event %02x\n", event); switch (event) { - case 0x14: - /* brightness up */ - mainboard_smi_brightness_up(); - break; - case 0x15: - /* brightness down */ - mainboard_smi_brightness_down(); - break; case 0x18: /* Fn-F9 key */ case 0x27: @@ -135,25 +106,9 @@ void mainboard_smi_gpi(u32 gpi_sts) mainboard_smi_handle_ec_sci(); } -static int mainboard_finalized = 0; - int mainboard_smi_apmc(u8 data) { switch (data) { - case APM_CNT_FINALIZE: - printk(BIOS_DEBUG, "APMC: FINALIZE\n"); - if (mainboard_finalized) { - printk(BIOS_DEBUG, "APMC#: Already finalized\n"); - return 0; - } - - intel_me_finalize_smm(); - intel_pch_finalize_smm(); - intel_nehalem_finalize_smm(); - intel_model_2065x_finalize_smm(); - - mainboard_finalized = 1; - break; case APM_CNT_ACPI_ENABLE: /* use 0x1600/0x1604 to prevent races with userspace */ ec_set_ports(0x1604, 0x1600); diff --git a/src/mainboard/lenovo/x220/romstage.c b/src/mainboard/lenovo/x220/romstage.c index a5b0c8189b..9ecb8a3e1e 100644 --- a/src/mainboard/lenovo/x220/romstage.c +++ b/src/mainboard/lenovo/x220/romstage.c @@ -16,7 +16,6 @@ */ #include -#include #include #include #include @@ -35,10 +34,6 @@ void pch_enable_lpc(void) pci_write_config16(PCH_LPC_DEV, LPC_EN, CNF2_LPC_EN | CNF1_LPC_EN | MC_LPC_EN | KBC_LPC_EN); - pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, 0x7c1601); - pci_write_config32(PCH_LPC_DEV, LPC_GEN2_DEC, 0xc15e1); - pci_write_config32(PCH_LPC_DEV, LPC_GEN4_DEC, 0x0c06a1); - pci_write_config32(PCH_LPC_DEV, ETR3, 0x10000); } diff --git a/src/mainboard/lenovo/x220/smihandler.c b/src/mainboard/lenovo/x220/smihandler.c index 46ad664c3c..35a26c0ebd 100644 --- a/src/mainboard/lenovo/x220/smihandler.c +++ b/src/mainboard/lenovo/x220/smihandler.c @@ -16,7 +16,6 @@ */ #include -#include #include #include #include diff --git a/src/mainboard/lenovo/x230/romstage.c b/src/mainboard/lenovo/x230/romstage.c index f97c3f503c..10cddebda3 100644 --- a/src/mainboard/lenovo/x230/romstage.c +++ b/src/mainboard/lenovo/x230/romstage.c @@ -16,7 +16,6 @@ */ #include -#include #include #include #include @@ -32,10 +31,6 @@ void pch_enable_lpc(void) pci_write_config16(PCH_LPC_DEV, LPC_EN, CNF2_LPC_EN | CNF1_LPC_EN | MC_LPC_EN | KBC_LPC_EN); - pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, 0x7c1601); - pci_write_config32(PCH_LPC_DEV, LPC_GEN2_DEC, 0xc15e1); - pci_write_config32(PCH_LPC_DEV, LPC_GEN4_DEC, 0x0c06a1); - pci_write_config32(PCH_LPC_DEV, ETR3, 0x10000); } diff --git a/src/mainboard/lenovo/x60/Kconfig b/src/mainboard/lenovo/x60/Kconfig index 6db7f11259..e3aabf3485 100644 --- a/src/mainboard/lenovo/x60/Kconfig +++ b/src/mainboard/lenovo/x60/Kconfig @@ -19,7 +19,6 @@ config BOARD_SPECIFIC_OPTIONS select HAVE_PIRQ_TABLE select HAVE_MP_TABLE select BOARD_ROMSIZE_KB_2048 - select CHANNEL_XOR_RANDOMIZATION select HAVE_ACPI_TABLES select HAVE_ACPI_RESUME select USE_OPTION_TABLE diff --git a/src/mainboard/lenovo/x60/mptable.c b/src/mainboard/lenovo/x60/mptable.c index 0118ba002f..886f72da37 100644 --- a/src/mainboard/lenovo/x60/mptable.c +++ b/src/mainboard/lenovo/x60/mptable.c @@ -41,23 +41,23 @@ static void *smp_write_config_table(void *v) smp_write_intsrc(mc, mp_ExtINT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, isa_bus, 0x00, MP_APIC_ALL, 0x00); smp_write_intsrc(mc, mp_NMI, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT, isa_bus, 0x00, MP_APIC_ALL, 0x01); - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x01 << 2), 0x02, 0x10); /* PCIe root 0.02.0 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x02 << 2), 0x02, 0x10); /* VGA 0.02.0 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1b << 2), 0x02, 0x11); /* HD Audio 0:1b.0 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1c << 2), 0x02, 0x14); /* PCIe 0:1c.0 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1c << 2) | 0x01, 0x02, 0x15); /* PCIe 0:1c.1 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1c << 2) | 0x02, 0x02, 0x16); /* PCIe 0:1c.2 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1c << 2) | 0x03, 0x02, 0x17); /* PCIe 0:1c.3 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1d << 2) , 0x02, 0x10); /* USB 0:1d.0 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1d << 2) | 0x01, 0x02, 0x11); /* USB 0:1d.1 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1d << 2) | 0x02, 0x02, 0x12); /* USB 0:1d.2 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1d << 2) | 0x03, 0x02, 0x13); /* USB 0:1d.3 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1f << 2) , 0x02, 0x17); /* LPC 0:1f.0 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1f << 2) | 0x01, 0x02, 0x10); /* IDE 0:1f.1 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1f << 2) | 0x02, 0x02, 0x10); /* SATA 0:1f.2 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x05, (0x00 << 2) | 0x00, 0x02, 0x10); /* Cardbus 5:00.0 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x05, (0x00 << 2) | 0x01, 0x02, 0x11); /* Firewire 5:00.1 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x05, (0x00 << 2) | 0x02, 0x02, 0x12); /* SDHC 5:00.2 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x01, 0x00, 0x02, 0x10); /* PCIe root 0.01.0 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x02, 0x00, 0x02, 0x10); /* VGA 0.02.0 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1b, 0x00, 0x02, 0x11); /* HD Audio 0:1b.0 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1c, 0x00, 0x02, 0x14); /* PCIe 0:1c.0 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1c, 0x01, 0x02, 0x15); /* PCIe 0:1c.1 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1c, 0x02, 0x02, 0x16); /* PCIe 0:1c.2 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1c, 0x03, 0x02, 0x17); /* PCIe 0:1c.3 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1d, 0x00, 0x02, 0x10); /* USB 0:1d.0 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1d, 0x01, 0x02, 0x11); /* USB 0:1d.1 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1d, 0x02, 0x02, 0x12); /* USB 0:1d.2 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1d, 0x03, 0x02, 0x13); /* USB 0:1d.3 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1f, 0x00, 0x02, 0x17); /* LPC 0:1f.0 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1f, 0x01, 0x02, 0x10); /* IDE 0:1f.1 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1f, 0x02, 0x02, 0x10); /* SATA 0:1f.2 */ + smp_write_pci_intsrc(mc, mp_INT, 0x05, 0x00, 0x00, 0x02, 0x10); /* Cardbus 5:00.0 */ + smp_write_pci_intsrc(mc, mp_INT, 0x05, 0x00, 0x01, 0x02, 0x11); /* Firewire 5:00.1 */ + smp_write_pci_intsrc(mc, mp_INT, 0x05, 0x00, 0x02, 0x02, 0x12); /* SDHC 5:00.2 */ mptable_lintsrc(mc, isa_bus); return mptable_finalize(mc); diff --git a/src/mainboard/lenovo/z61t/Kconfig b/src/mainboard/lenovo/z61t/Kconfig index a22307712b..de48d95050 100644 --- a/src/mainboard/lenovo/z61t/Kconfig +++ b/src/mainboard/lenovo/z61t/Kconfig @@ -17,7 +17,6 @@ config BOARD_SPECIFIC_OPTIONS select INTEL_INT15 select HAVE_MP_TABLE select BOARD_ROMSIZE_KB_2048 - select CHANNEL_XOR_RANDOMIZATION select HAVE_ACPI_TABLES select HAVE_ACPI_RESUME select H8_DOCK_EARLY_INIT diff --git a/src/mainboard/lenovo/z61t/cmos.layout b/src/mainboard/lenovo/z61t/cmos.layout index b9e2b4494a..75ad42760c 100644 --- a/src/mainboard/lenovo/z61t/cmos.layout +++ b/src/mainboard/lenovo/z61t/cmos.layout @@ -78,7 +78,7 @@ entries 952 8 h 0 volume 960 1 e 9 first_battery 961 1 e 1 trackpoint -962 1 e 1 fn_ctrl_swap +#962 1 r 0 unused 963 1 e 1 sticky_fn 964 1 e 1 power_management_beeps 965 1 e 1 low_battery_beep diff --git a/src/mainboard/lenovo/z61t/mptable.c b/src/mainboard/lenovo/z61t/mptable.c index 838757e0c6..165b725ac6 100644 --- a/src/mainboard/lenovo/z61t/mptable.c +++ b/src/mainboard/lenovo/z61t/mptable.c @@ -41,21 +41,21 @@ static void *smp_write_config_table(void *v) smp_write_intsrc(mc, mp_ExtINT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, isa_bus, 0x00, MP_APIC_ALL, 0x00); smp_write_intsrc(mc, mp_NMI, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT, isa_bus, 0x00, MP_APIC_ALL, 0x01); - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x01 << 2), 0x02, 0x10); /* PCIe root 0.02.0 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x02 << 2), 0x02, 0x10); /* VGA 0.02.0 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1b << 2), 0x02, 0x11); /* HD Audio 0:1b.0 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1c << 2), 0x02, 0x14); /* PCIe 0:1c.0 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1c << 2) | 0x01, 0x02, 0x15); /* PCIe 0:1c.1 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1c << 2) | 0x02, 0x02, 0x16); /* PCIe 0:1c.2 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1c << 2) | 0x03, 0x02, 0x17); /* PCIe 0:1c.3 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1d << 2) , 0x02, 0x10); /* USB 0:1d.0 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1d << 2) | 0x01, 0x02, 0x11); /* USB 0:1d.1 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1d << 2) | 0x02, 0x02, 0x12); /* USB 0:1d.2 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1d << 2) | 0x03, 0x02, 0x13); /* USB 0:1d.3 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1f << 2) , 0x02, 0x17); /* LPC 0:1f.0 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1f << 2) | 0x01, 0x02, 0x10); /* IDE 0:1f.1 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x00, (0x1f << 2) | 0x02, 0x02, 0x10); /* SATA 0:1f.2 */ - smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x06, (0x00 << 2) | 0x00, 0x02, 0x10); /* Cardbus 6:00.0 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x01, 0x00, 0x02, 0x10); /* PCIe root 0.01.0 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x02, 0x00, 0x02, 0x10); /* VGA 0.02.0 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1b, 0x00, 0x02, 0x11); /* HD Audio 0:1b.0 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1c, 0x00, 0x02, 0x14); /* PCIe 0:1c.0 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1c, 0x01, 0x02, 0x15); /* PCIe 0:1c.1 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1c, 0x02, 0x02, 0x16); /* PCIe 0:1c.2 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1c, 0x03, 0x02, 0x17); /* PCIe 0:1c.3 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1d, 0x00, 0x02, 0x10); /* USB 0:1d.0 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1d, 0x01, 0x02, 0x11); /* USB 0:1d.1 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1d, 0x02, 0x02, 0x12); /* USB 0:1d.2 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1d, 0x03, 0x02, 0x13); /* USB 0:1d.3 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1f, 0x00, 0x02, 0x17); /* LPC 0:1f.0 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1f, 0x01, 0x02, 0x10); /* IDE 0:1f.1 */ + smp_write_pci_intsrc(mc, mp_INT, 0x00, 0x1f, 0x02, 0x02, 0x10); /* SATA 0:1f.2 */ + smp_write_pci_intsrc(mc, mp_INT, 0x06, 0x00, 0x00, 0x02, 0x10); /* Cardbus 6:00.0 */ mptable_lintsrc(mc, isa_bus); return mptable_finalize(mc); diff --git a/src/mainboard/lenovo/z61t/romstage.c b/src/mainboard/lenovo/z61t/romstage.c index 502eac39d5..716be16dad 100644 --- a/src/mainboard/lenovo/z61t/romstage.c +++ b/src/mainboard/lenovo/z61t/romstage.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include diff --git a/src/mainboard/ocp/wedge100s/Kconfig b/src/mainboard/ocp/wedge100s/Kconfig index bd5e6655af..491829a084 100644 --- a/src/mainboard/ocp/wedge100s/Kconfig +++ b/src/mainboard/ocp/wedge100s/Kconfig @@ -16,6 +16,7 @@ config BOARD_SPECIFIC_OPTIONS select MAINBOARD_HAS_TPM1 select DRIVERS_UART_8250IO select SUPERIO_ITE_IT8528E + select IPMI_KCS config VBOOT select VBOOT_VBNV_CMOS diff --git a/src/mainboard/ocp/wedge100s/devicetree.cb b/src/mainboard/ocp/wedge100s/devicetree.cb index 48410bae08..3552a6db1b 100644 --- a/src/mainboard/ocp/wedge100s/devicetree.cb +++ b/src/mainboard/ocp/wedge100s/devicetree.cb @@ -60,6 +60,9 @@ chip soc/intel/fsp_broadwell_de device pnp 6e.18 off end device pnp 6e.19 off end end #superio/ite/it8528e + chip drivers/ipmi + device pnp ca2.0 on end # IPMI KCS + end end # LPC Bridge device pci 1f.2 on end # SATA Controller device pci 1f.3 on end # SMBus Controller diff --git a/src/mainboard/ocp/wedge100s/romstage.c b/src/mainboard/ocp/wedge100s/romstage.c index 7fdc981915..108d7a1c4d 100644 --- a/src/mainboard/ocp/wedge100s/romstage.c +++ b/src/mainboard/ocp/wedge100s/romstage.c @@ -38,6 +38,10 @@ void early_mainboard_romstage_entry(void) pci_write_config32(PCI_DEV(0x0, LPC_DEV, LPC_FUNC), LPC_GEN1_DEC, (0 << 16) | ALIGN_DOWN(SUPERIO_DEV, 4) | 1); + /* Decode IPMI KCS */ + pci_write_config32(PCI_DEV(0x0, LPC_DEV, LPC_FUNC), LPC_GEN2_DEC, + (0 << 16) | ALIGN_DOWN(0xca2, 4) | 1); + if (CONFIG(CONSOLE_SERIAL)) ite_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE); diff --git a/src/mainboard/packardbell/ms2290/Kconfig b/src/mainboard/packardbell/ms2290/Kconfig index c6a1e1256a..631559157f 100644 --- a/src/mainboard/packardbell/ms2290/Kconfig +++ b/src/mainboard/packardbell/ms2290/Kconfig @@ -3,9 +3,6 @@ if BOARD_PACKARDBELL_MS2290 config BOARD_SPECIFIC_OPTIONS def_bool y select SYSTEM_TYPE_LAPTOP - select ARCH_BOOTBLOCK_X86_32 - select ARCH_ROMSTAGE_X86_32 - select ARCH_RAMSTAGE_X86_32 select NORTHBRIDGE_INTEL_NEHALEM select SOUTHBRIDGE_INTEL_IBEXPEAK select HAVE_OPTION_TABLE diff --git a/src/mainboard/packardbell/ms2290/mainboard.c b/src/mainboard/packardbell/ms2290/mainboard.c index 09310aef72..28d3bb0958 100644 --- a/src/mainboard/packardbell/ms2290/mainboard.c +++ b/src/mainboard/packardbell/ms2290/mainboard.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -32,20 +31,6 @@ #include #include -static acpi_cstate_t cst_entries[] = { - {1, 1, 1000, {0x7f, 1, 2, 0, 1, 0} }, - {2, 1, 500, {0x01, 8, 0, 0, DEFAULT_PMBASE + LV2, 0} }, - {2, 17, 250, {0x01, 8, 0, 0, DEFAULT_PMBASE + LV3, 0} }, -}; - -int get_cst_entries(acpi_cstate_t ** entries) -{ - *entries = cst_entries; - return ARRAY_SIZE(cst_entries); -} - - - static void mainboard_enable(struct device *dev) { u16 pmbase; diff --git a/src/mainboard/packardbell/ms2290/smihandler.c b/src/mainboard/packardbell/ms2290/smihandler.c index 83562be921..dfc66f98cf 100644 --- a/src/mainboard/packardbell/ms2290/smihandler.c +++ b/src/mainboard/packardbell/ms2290/smihandler.c @@ -18,11 +18,8 @@ #include #include #include -#include -#include #include #include -#include #include static void mainboard_smm_init(void) @@ -54,26 +51,10 @@ void mainboard_smi_gpi(u32 gpi_sts) { } -static int mainboard_finalized = 0; - int mainboard_smi_apmc(u8 data) { u8 tmp; switch (data) { - case APM_CNT_FINALIZE: - printk(BIOS_DEBUG, "APMC: FINALIZE\n"); - if (mainboard_finalized) { - printk(BIOS_DEBUG, "APMC#: Already finalized\n"); - return 0; - } - - intel_me_finalize_smm(); - intel_pch_finalize_smm(); - intel_nehalem_finalize_smm(); - intel_model_2065x_finalize_smm(); - - mainboard_finalized = 1; - break; case APM_CNT_ACPI_ENABLE: tmp = pci_read_config8(PCI_DEV(0, 0x1f, 0), 0xbb); tmp &= ~0x03; diff --git a/src/mainboard/roda/rk886ex/Kconfig b/src/mainboard/roda/rk886ex/Kconfig index 821a9a1b6a..9e97529dca 100644 --- a/src/mainboard/roda/rk886ex/Kconfig +++ b/src/mainboard/roda/rk886ex/Kconfig @@ -17,7 +17,6 @@ config BOARD_SPECIFIC_OPTIONS select HAVE_ACPI_TABLES select HAVE_ACPI_RESUME select BOARD_ROMSIZE_KB_1024 - select CHANNEL_XOR_RANDOMIZATION select INTEL_INT15 config MAINBOARD_DIR diff --git a/src/mainboard/roda/rk9/fadt.c b/src/mainboard/roda/rk9/fadt.c index 673791f99c..e335787100 100644 --- a/src/mainboard/roda/rk9/fadt.c +++ b/src/mainboard/roda/rk9/fadt.c @@ -29,7 +29,7 @@ void acpi_create_fadt(acpi_fadt_t * fadt, acpi_facs_t * facs, void *dsdt) memset((void *) fadt, 0, sizeof(acpi_fadt_t)); memcpy(header->signature, "FACP", 4); header->length = sizeof(acpi_fadt_t); - header->revision = 3; + header->revision = get_acpi_table_revision(FADT); memcpy(header->oem_id, OEM_ID, 6); memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); memcpy(header->asl_compiler_id, ASLC, 4); diff --git a/src/mainboard/samsung/lumpy/devicetree.cb b/src/mainboard/samsung/lumpy/devicetree.cb index 719947310b..feae5bf1e8 100644 --- a/src/mainboard/samsung/lumpy/devicetree.cb +++ b/src/mainboard/samsung/lumpy/devicetree.cb @@ -61,6 +61,7 @@ chip northbridge/intel/sandybridge # EC range is 0xa00-0xa3f register "gen1_dec" = "0x003c0a01" register "gen2_dec" = "0x003c0b01" + register "gen3_dec" = "0x00fc1601" register "c2_latency" = "1" register "p_cnt_throttling_supported" = "0" diff --git a/src/mainboard/samsung/lumpy/romstage.c b/src/mainboard/samsung/lumpy/romstage.c index a77149d927..d4b6dd834b 100644 --- a/src/mainboard/samsung/lumpy/romstage.c +++ b/src/mainboard/samsung/lumpy/romstage.c @@ -43,9 +43,6 @@ void pch_enable_lpc(void) pci_write_config16(PCH_LPC_DEV, LPC_EN, CNF1_LPC_EN | MC_LPC_EN | KBC_LPC_EN | CNF2_LPC_EN | COMA_LPC_EN); - /* map full 256 bytes at 0x1600 to the LPC bus */ - pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, 0xfc1601); - try_enabling_LPC47N207_uart(); #else /* Enable SuperIO + EC + KBC */ diff --git a/src/mainboard/samsung/stumpy/devicetree.cb b/src/mainboard/samsung/stumpy/devicetree.cb index 192e63d4d9..060fc40bb6 100644 --- a/src/mainboard/samsung/stumpy/devicetree.cb +++ b/src/mainboard/samsung/stumpy/devicetree.cb @@ -50,6 +50,7 @@ chip northbridge/intel/sandybridge register "c2_latency" = "1" register "p_cnt_throttling_supported" = "0" + register "gen1_dec" = "0x00fc1601" # SuperIO range is 0x700-0x73f register "gen2_dec" = "0x003c0701" diff --git a/src/mainboard/samsung/stumpy/romstage.c b/src/mainboard/samsung/stumpy/romstage.c index a8e28d67ac..77fd16016d 100644 --- a/src/mainboard/samsung/stumpy/romstage.c +++ b/src/mainboard/samsung/stumpy/romstage.c @@ -55,9 +55,6 @@ void pch_enable_lpc(void) pci_write_config16(PCH_LPC_DEV, LPC_EN, CNF1_LPC_EN | KBC_LPC_EN |\ CNF2_LPC_EN | COMA_LPC_EN); - /* map full 256 bytes at 0x1600 to the LPC bus */ - pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, 0xfc1601); - try_enabling_LPC47N207_uart(); #else /* Enable SuperIO + PS/2 Keyboard/Mouse */ diff --git a/src/mainboard/sapphire/pureplatinumh61/romstage.c b/src/mainboard/sapphire/pureplatinumh61/romstage.c index 296e8963c2..c7d8f0f724 100644 --- a/src/mainboard/sapphire/pureplatinumh61/romstage.c +++ b/src/mainboard/sapphire/pureplatinumh61/romstage.c @@ -15,7 +15,6 @@ */ #include -#include #include #include #include @@ -25,10 +24,6 @@ void pch_enable_lpc(void) { pci_write_config16(PCI_DEV(0, 0x1f, 0), 0x82, 0x2400); - pci_write_config32(PCI_DEV(0, 0x1f, 0), 0x84, 0x000c0291); - pci_write_config32(PCI_DEV(0, 0x1f, 0), 0x88, 0x000c0a01); - pci_write_config32(PCI_DEV(0, 0x1f, 0), 0x8c, 0x00000000); - pci_write_config32(PCI_DEV(0, 0x1f, 0), 0x90, 0x00000000); pci_write_config16(PCI_DEV(0, 0x1f, 0), 0x80, 0x0000); pci_write_config32(PCI_DEV(0, 0x1f, 0), 0xac, 0x00010000); } diff --git a/src/mainboard/siemens/mc_apl1/variants/mc_apl5/Kconfig b/src/mainboard/siemens/mc_apl1/variants/mc_apl5/Kconfig index 196176c4fd..4a4b6cc604 100644 --- a/src/mainboard/siemens/mc_apl1/variants/mc_apl5/Kconfig +++ b/src/mainboard/siemens/mc_apl1/variants/mc_apl5/Kconfig @@ -8,5 +8,8 @@ config BOARD_SPECIFIC_OPTIONS select DRIVER_SIEMENS_NC_FPGA select NC_FPGA_NOTIFY_CB_READY select APL_SKIP_SET_POWER_LIMITS + select MAINBOARD_HAS_TPM2 + select MAINBOARD_HAS_LPC_TPM + select TPM_ON_FAST_SPI endif # BOARD_SIEMENS_MC_APL5 diff --git a/src/mainboard/siemens/mc_apl1/variants/mc_apl5/devicetree.cb b/src/mainboard/siemens/mc_apl1/variants/mc_apl5/devicetree.cb index f1ed5d2e15..5f1c9857d4 100644 --- a/src/mainboard/siemens/mc_apl1/variants/mc_apl5/devicetree.cb +++ b/src/mainboard/siemens/mc_apl1/variants/mc_apl5/devicetree.cb @@ -104,7 +104,11 @@ chip soc/intel/apollolake device pci 1c.0 on end # - eMMC device pci 1d.0 off end # - UFS device pci 1e.0 off end # - SDIO - device pci 1f.0 on end # - LPC + device pci 1f.0 on # - LPC + chip drivers/pc80/tpm + device pnp 0c31.0 on end + end + end device pci 1f.1 on end # - SMBUS end end diff --git a/src/mainboard/siemens/mc_apl1/variants/mc_apl5/gpio.c b/src/mainboard/siemens/mc_apl1/variants/mc_apl5/gpio.c index 7a424d131e..f9b258d199 100644 --- a/src/mainboard/siemens/mc_apl1/variants/mc_apl5/gpio.c +++ b/src/mainboard/siemens/mc_apl1/variants/mc_apl5/gpio.c @@ -254,7 +254,7 @@ static const struct pad_config gpio_table[] = { /* SIO_SPI_0 -- unused */ PAD_CFG_GPI(GPIO_104, DN_20K, DEEP), /* GP_SSP_0_CLK */ PAD_CFG_GPI(GPIO_105, DN_20K, DEEP), /* GP_SSP_0_FS0 */ - PAD_CFG_GPI(GPIO_106, UP_20K, DEEP), /* GP_SSP_0_FS1 */ + PAD_CFG_NF(GPIO_106, NATIVE, DEEP, NF3), /* FST_SPI_CS2_N */ PAD_CFG_GPI(GPIO_109, DN_20K, DEEP), /* GP_SSP_0_RXD */ PAD_CFG_GPI(GPIO_110, DN_20K, DEEP), /* GP_SSP_0_TXD */ diff --git a/src/mainboard/siemens/mc_apl1/variants/mc_apl5/ptn3460.c b/src/mainboard/siemens/mc_apl1/variants/mc_apl5/ptn3460.c index c0770f3124..f6fed97551 100644 --- a/src/mainboard/siemens/mc_apl1/variants/mc_apl5/ptn3460.c +++ b/src/mainboard/siemens/mc_apl1/variants/mc_apl5/ptn3460.c @@ -76,7 +76,8 @@ int ptn3460_init(const char *hwi_block) return (PTN_BUS_ERROR | status); /* Set up configuration data according to the hwinfo block we get. */ cfg.dp_interface_ctrl = 0; - cfg.lvds_interface_ctrl1 = 0x00; + /* Drive LVDS clock for single mode on odd bus per default. */ + cfg.lvds_interface_ctrl1 = 0x01; if (disp_con == PF_DISPLCON_LVDS_DUAL) /* Turn on dual LVDS lane and clock. */ cfg.lvds_interface_ctrl1 |= 0x0b; diff --git a/src/mainboard/up/squared/Kconfig b/src/mainboard/up/squared/Kconfig index fd03b7a2ae..b9f5b27a6d 100644 --- a/src/mainboard/up/squared/Kconfig +++ b/src/mainboard/up/squared/Kconfig @@ -65,6 +65,10 @@ config MAX_CPUS int default 2 +config LINUX_COMMAND_LINE + string + default "console=ttyS4,115200 earlyprintk=ttyS4,115200,keep" if PAYLOAD_LINUXBOOT && UART_FOR_CONSOLE=0 + config UART_FOR_CONSOLE int default 0 diff --git a/src/mainboard/up/squared/ramstage.c b/src/mainboard/up/squared/ramstage.c index e9fcfb2da3..be70ea995a 100644 --- a/src/mainboard/up/squared/ramstage.c +++ b/src/mainboard/up/squared/ramstage.c @@ -29,7 +29,6 @@ void mainboard_silicon_init_params(FSP_S_CONFIG *silconfig) silconfig->CStateUnDemotion = 0x3; // 0x0 silconfig->PkgCStateDemotion = 0x1; // 0x0 silconfig->PkgCStateUnDemotion = 0x1; // 0x0 - silconfig->IpuEn = 0x0; // 0x1 silconfig->Pme = 0x1; // 0x0 silconfig->HdAudioIoBufferOwnership = 0x3; // 0x0 silconfig->DspEndpointDmic = 0x0; // 0x1 @@ -43,390 +42,53 @@ void mainboard_silicon_init_params(FSP_S_CONFIG *silconfig) silconfig->HpetDeviceNumber = 0xF; // 0x1f silconfig->IoApicBdfValid = 0x1; // 0x0 silconfig->IoApicDeviceNumber = 0x1F; // 0xf - silconfig->IshEnable = 0x0; // 0x1 - silconfig->SpiEiss = 0x0; // 0x1 silconfig->LPSS_S0ixEnable = 0x1; // 0x0 - silconfig->SdcardEnabled = 0x0; // 0x1 silconfig->eMMCHostMaxSpeed = 0x2; // 0x0 silconfig->Usb30Mode = 0x1; // 0x0 - silconfig->VtdEnable = 0x1; // 0x0 - silconfig->MonitorMwaitEnable = 0x0; // 0x1 - silconfig->HdAudioDspUaaCompliance = 0x1; // 0x0 - silconfig->InitS3Cpu = 0x1; // 0x0 + silconfig->HdAudioDspUaaCompliance = 0x1; // 0x0 + silconfig->InitS3Cpu = 0x1; // 0x0 - silconfig->PortUsb20PerPortTxPeHalf[0] = 0x0; - silconfig->PortUsb20PerPortPeTxiSet[0] = 0x7; - silconfig->PortUsb20PerPortTxiSet[0] = 0x0; - silconfig->PortUsb20HsSkewSel[0] = 0x0; - silconfig->PortUsb20IUsbTxEmphasisEn[0] = 0x3; - silconfig->PortUsb20PerPortRXISet[0] = 0x0; - silconfig->PortUsb20HsNpreDrvSel[0] = 0x0; + silconfig->PcieRpLtrMaxNonSnoopLatency[0] = 0x1003; // 0x0 + silconfig->PcieRpLtrMaxSnoopLatency[0] = 0x1003; // 0x0 - silconfig->PortUsb20PerPortTxPeHalf[1] = 0x0; - silconfig->PortUsb20PerPortPeTxiSet[1] = 0x6; - silconfig->PortUsb20PerPortTxiSet[1] = 0x0; - silconfig->PortUsb20HsSkewSel[1] = 0x0; - silconfig->PortUsb20IUsbTxEmphasisEn[1] = 0x3; - silconfig->PortUsb20PerPortRXISet[1] = 0x0; - silconfig->PortUsb20HsNpreDrvSel[1] = 0x0; + silconfig->PcieRpHotPlug[1] = 0x0; // 0x1 + silconfig->PcieRpPmSci[1] = 0x1; // 0x0 + silconfig->PcieRpTransmitterHalfSwing[1] = 0x0; // 0x1 + silconfig->PcieRpClkReqNumber[1] = 0x3; // 0x5 + silconfig->PcieRpLtrMaxNonSnoopLatency[1] = 0x1003; // 0x0 + silconfig->PcieRpLtrMaxSnoopLatency[1] = 0x1003; // 0x0 - silconfig->PortUsb20PerPortTxPeHalf[2] = 0x0; - silconfig->PortUsb20PerPortPeTxiSet[2] = 0x6; - silconfig->PortUsb20PerPortTxiSet[2] = 0x0; - silconfig->PortUsb20HsSkewSel[2] = 0x0; - silconfig->PortUsb20IUsbTxEmphasisEn[2] = 0x3; - silconfig->PortUsb20PerPortRXISet[2] = 0x0; - silconfig->PortUsb20HsNpreDrvSel[2] = 0x0; + silconfig->PcieRpHotPlug[2] = 0x0; // 0x1 + silconfig->PcieRpPmSci[2] = 0x1; // 0x0 + silconfig->PcieRpTransmitterHalfSwing[2] = 0x0; // 0x1 + silconfig->PcieRpLtrMaxNonSnoopLatency[2] = 0x1003; // 0x0 + silconfig->PcieRpLtrMaxSnoopLatency[2] = 0x1003; // 0x0 - silconfig->PortUsb20PerPortTxPeHalf[3] = 0x0; - silconfig->PortUsb20PerPortPeTxiSet[3] = 0x6; - silconfig->PortUsb20PerPortTxiSet[3] = 0x0; - silconfig->PortUsb20HsSkewSel[3] = 0x0; - silconfig->PortUsb20IUsbTxEmphasisEn[3] = 0x3; - silconfig->PortUsb20PerPortRXISet[3] = 0x0; - silconfig->PortUsb20HsNpreDrvSel[3] = 0x0; + silconfig->PcieRpHotPlug[3] = 0x0; // 0x1 + silconfig->PcieRpPmSci[3] = 0x1; // 0x0 + silconfig->PcieRpTransmitterHalfSwing[3] = 0x0; // 0x1 + silconfig->PcieRpLtrMaxNonSnoopLatency[3] = 0x1003; // 0x0 + silconfig->PcieRpLtrMaxSnoopLatency[3] = 0x1003; // 0x0 - silconfig->PortUsb20PerPortTxPeHalf[4] = 0x0; - silconfig->PortUsb20PerPortPeTxiSet[4] = 0x7; - silconfig->PortUsb20PerPortTxiSet[4] = 0x0; - silconfig->PortUsb20HsSkewSel[4] = 0x0; - silconfig->PortUsb20IUsbTxEmphasisEn[4] = 0x3; - silconfig->PortUsb20PerPortRXISet[4] = 0x0; - silconfig->PortUsb20HsNpreDrvSel[4] = 0x0; + silconfig->PcieRpHotPlug[4] = 0x0; // 0x1 + silconfig->PcieRpPmSci[4] = 0x1; // 0x0 + silconfig->PcieRpTransmitterHalfSwing[4] = 0x0; // 0x1 + silconfig->PcieRpLtrMaxNonSnoopLatency[4] = 0x1003; // 0x0 + silconfig->PcieRpLtrMaxSnoopLatency[4] = 0x1003; // 0x0 - silconfig->PortUsb20PerPortTxPeHalf[5] = 0x0; - silconfig->PortUsb20PerPortPeTxiSet[5] = 0x7; - silconfig->PortUsb20PerPortTxiSet[5] = 0x0; - silconfig->PortUsb20HsSkewSel[5] = 0x0; - silconfig->PortUsb20IUsbTxEmphasisEn[5] = 0x3; - silconfig->PortUsb20PerPortRXISet[5] = 0x0; - silconfig->PortUsb20HsNpreDrvSel[5] = 0x0; + silconfig->PcieRpHotPlug[5] = 0x0; // 0x1 + silconfig->PcieRpPmSci[5] = 0x1; // 0x0 + silconfig->PcieRpTransmitterHalfSwing[5] = 0x0; // 0x1 + silconfig->PcieRpLtrMaxNonSnoopLatency[5] = 0x1003; // 0x0 + silconfig->PcieRpLtrMaxSnoopLatency[5] = 0x1003; // 0x0 - silconfig->PortUsb20PerPortTxPeHalf[6] = 0x0; - silconfig->PortUsb20PerPortPeTxiSet[6] = 0x7; - silconfig->PortUsb20PerPortTxiSet[6] = 0x0; - silconfig->PortUsb20HsSkewSel[6] = 0x0; - silconfig->PortUsb20IUsbTxEmphasisEn[6] = 0x3; - silconfig->PortUsb20PerPortRXISet[6] = 0x0; - silconfig->PortUsb20HsNpreDrvSel[6] = 0x0; + silconfig->PortUs30bOverCurrentPin[0] = 0x0; // 0x1 - silconfig->PortUsb20PerPortTxPeHalf[7] = 0x0; - silconfig->PortUsb20PerPortPeTxiSet[7] = 0x1; - silconfig->PortUsb20PerPortTxiSet[7] = 0x3; - silconfig->PortUsb20HsSkewSel[7] = 0x1; - silconfig->PortUsb20IUsbTxEmphasisEn[7] = 0x1; - silconfig->PortUsb20PerPortRXISet[7] = 0x0; - silconfig->PortUsb20HsNpreDrvSel[7] = 0x3; - - - silconfig->WriteProtectionEnable[0] = 0x1; - silconfig->ReadProtectionEnable[0] = 0x1; - silconfig->ProtectedRangeLimit[0] = 0xFFF; - silconfig->ProtectedRangeBase[0] = 0x0; - - silconfig->IPC[0] = 0xFFFFEEF8; - silconfig->IPC[1] = 0xFFFFFFFF; - silconfig->IPC[2] = 0xFFFFFFFF; - silconfig->IPC[3] = 0xFFFFFFFF; - - silconfig->SataPortsDisableDynamicPg[0] = 0x0; - silconfig->SataPortsEnable[0] = 0x1; - silconfig->SataPortsDevSlp[0] = 0x0; - silconfig->SataPortsHotPlug[0] = 0x0; - silconfig->SataPortsInterlockSw[0] = 0x1; - silconfig->SataPortsExternal[0] = 0x0; - silconfig->SataPortsSpinUp[0] = 0x0; - silconfig->SataPortsSolidStateDrive[0] = 0x0; - silconfig->SataPortsEnableDitoConfig[0] = 0x0; - silconfig->SataPortsDmVal[0] = 0xF; - silconfig->SataPortsDitoVal[0] = 0x271; - - silconfig->SataPortsDisableDynamicPg[1] = 0x0; - silconfig->SataPortsEnable[1] = 0x1; - silconfig->SataPortsDevSlp[1] = 0x0; - silconfig->SataPortsHotPlug[1] = 0x0; - silconfig->SataPortsInterlockSw[1] = 0x1; - silconfig->SataPortsExternal[1] = 0x0; - silconfig->SataPortsSpinUp[1] = 0x0; - silconfig->SataPortsSolidStateDrive[1] = 0x0; - silconfig->SataPortsEnableDitoConfig[1] = 0x0; - silconfig->SataPortsDmVal[1] = 0xF; - silconfig->SataPortsDitoVal[1] = 0x271; - - - silconfig->PcieRootPortEn[0] = 0x1; - silconfig->PcieRpHide[0] = 0x0; - silconfig->PcieRpSlotImplemented[0] = 0x1; - silconfig->PcieRpHotPlug[0] = 0x0; - silconfig->PcieRpPmSci[0] = 0x1; - silconfig->PcieRpExtSync[0] = 0x1; - silconfig->PcieRpTransmitterHalfSwing[0] = 0x0; - silconfig->PcieRpAcsEnabled[0] = 0x1; - silconfig->PcieRpClkReqSupported[0] = 0x1; - silconfig->PcieRpClkReqNumber[0] = 0x2; - silconfig->PcieRpClkReqDetect[0] = 0x0; - silconfig->AdvancedErrorReporting[0] = 0x0; - silconfig->PmeInterrupt[0] = 0x0; - silconfig->UnsupportedRequestReport[0] = 0x0; - silconfig->FatalErrorReport[0] = 0x0; - silconfig->NoFatalErrorReport[0] = 0x0; - silconfig->CorrectableErrorReport[0] = 0x0; - silconfig->SystemErrorOnFatalError[0] = 0x0; - silconfig->SystemErrorOnNonFatalError[0] = 0x0; - silconfig->SystemErrorOnCorrectableError[0] = 0x0; - silconfig->PcieRpSpeed[0] = 0x0; - silconfig->PhysicalSlotNumber[0] = 0x0; - silconfig->PcieRpCompletionTimeout[0] = 0x0; - silconfig->PtmEnable[0] = 0x0; - silconfig->PcieRpAspm[0] = 0x4; - silconfig->PcieRpL1Substates[0] = 0x3; - silconfig->PcieRpLtrEnable[0] = 0x1; - silconfig->PcieRpLtrConfigLock[0] = 0x0; - silconfig->PcieRpSelectableDeemphasis[0] = 0x1; - silconfig->PcieRpNonSnoopLatencyOverrideValue[0] = 0x3C; - silconfig->PcieRpNonSnoopLatencyOverrideMultiplier[0] = 0x2; - silconfig->PcieRpSlotPowerLimitScale[0] = 0x0; - silconfig->PcieRpSlotPowerLimitValue[0] = 0x0; - silconfig->PcieRpLtrMaxNonSnoopLatency[0] = 0x1003; - silconfig->PcieRpNonSnoopLatencyOverrideMode[0] = 0x2; - silconfig->PcieRpLtrMaxSnoopLatency[0] = 0x1003; - silconfig->PcieRpSnoopLatencyOverrideMode[0] = 0x2; - silconfig->PcieRpSnoopLatencyOverrideValue[0] = 0x3C; - silconfig->PcieRpSnoopLatencyOverrideMultiplier[0] = 0x2; - - silconfig->PcieRootPortEn[1] = 0x1; - silconfig->PcieRpHide[1] = 0x0; - silconfig->PcieRpSlotImplemented[1] = 0x1; - silconfig->PcieRpHotPlug[1] = 0x0; - silconfig->PcieRpPmSci[1] = 0x1; - silconfig->PcieRpExtSync[1] = 0x1; - silconfig->PcieRpTransmitterHalfSwing[1] = 0x0; - silconfig->PcieRpAcsEnabled[1] = 0x1; - silconfig->PcieRpClkReqSupported[1] = 0x1; - silconfig->PcieRpClkReqNumber[1] = 0x3; - silconfig->PcieRpClkReqDetect[1] = 0x0; - silconfig->AdvancedErrorReporting[1] = 0x0; - silconfig->PmeInterrupt[1] = 0x0; - silconfig->UnsupportedRequestReport[1] = 0x0; - silconfig->FatalErrorReport[1] = 0x0; - silconfig->NoFatalErrorReport[1] = 0x0; - silconfig->CorrectableErrorReport[1] = 0x0; - silconfig->SystemErrorOnFatalError[1] = 0x0; - silconfig->SystemErrorOnNonFatalError[1] = 0x0; - silconfig->SystemErrorOnCorrectableError[1] = 0x0; - silconfig->PcieRpSpeed[1] = 0x0; - silconfig->PhysicalSlotNumber[1] = 0x1; - silconfig->PcieRpCompletionTimeout[1] = 0x0; - silconfig->PtmEnable[1] = 0x0; - silconfig->PcieRpAspm[1] = 0x4; - silconfig->PcieRpL1Substates[1] = 0x3; - silconfig->PcieRpLtrEnable[1] = 0x1; - silconfig->PcieRpLtrConfigLock[1] = 0x0; - silconfig->PcieRpSelectableDeemphasis[1] = 0x1; - silconfig->PcieRpNonSnoopLatencyOverrideValue[1] = 0x3C; - silconfig->PcieRpNonSnoopLatencyOverrideMultiplier[1] = 0x2; - silconfig->PcieRpSlotPowerLimitScale[1] = 0x0; - silconfig->PcieRpSlotPowerLimitValue[1] = 0x0; - silconfig->PcieRpLtrMaxNonSnoopLatency[1] = 0x1003; - silconfig->PcieRpNonSnoopLatencyOverrideMode[1] = 0x2; - silconfig->PcieRpLtrMaxSnoopLatency[1] = 0x1003; - silconfig->PcieRpSnoopLatencyOverrideMode[1] = 0x2; - silconfig->PcieRpSnoopLatencyOverrideValue[1] = 0x3C; - silconfig->PcieRpSnoopLatencyOverrideMultiplier[1] = 0x2; - - silconfig->PcieRootPortEn[2] = 0x1; - silconfig->PcieRpHide[2] = 0x0; - silconfig->PcieRpSlotImplemented[2] = 0x1; - silconfig->PcieRpHotPlug[2] = 0x0; - silconfig->PcieRpPmSci[2] = 0x1; - silconfig->PcieRpExtSync[2] = 0x1; - silconfig->PcieRpTransmitterHalfSwing[2] = 0x0; - silconfig->PcieRpAcsEnabled[2] = 0x1; - silconfig->PcieRpClkReqSupported[2] = 0x1; - silconfig->PcieRpClkReqNumber[2] = 0x0; - silconfig->PcieRpClkReqDetect[2] = 0x0; - silconfig->AdvancedErrorReporting[2] = 0x0; - silconfig->PmeInterrupt[2] = 0x0; - silconfig->UnsupportedRequestReport[2] = 0x0; - silconfig->FatalErrorReport[2] = 0x0; - silconfig->NoFatalErrorReport[2] = 0x0; - silconfig->CorrectableErrorReport[2] = 0x0; - silconfig->SystemErrorOnFatalError[2] = 0x0; - silconfig->SystemErrorOnNonFatalError[2] = 0x0; - silconfig->SystemErrorOnCorrectableError[2] = 0x0; - silconfig->PcieRpSpeed[2] = 0x0; - silconfig->PhysicalSlotNumber[2] = 0x2; - silconfig->PcieRpCompletionTimeout[2] = 0x0; - silconfig->PtmEnable[2] = 0x0; - silconfig->PcieRpAspm[2] = 0x4; - silconfig->PcieRpL1Substates[2] = 0x3; - silconfig->PcieRpLtrEnable[2] = 0x1; - silconfig->PcieRpLtrConfigLock[2] = 0x0; - silconfig->PcieRpSelectableDeemphasis[2] = 0x1; - silconfig->PcieRpNonSnoopLatencyOverrideValue[2] = 0x3C; - silconfig->PcieRpNonSnoopLatencyOverrideMultiplier[2] = 0x2; - silconfig->PcieRpSlotPowerLimitScale[2] = 0x0; - silconfig->PcieRpSlotPowerLimitValue[2] = 0x0; - silconfig->PcieRpLtrMaxNonSnoopLatency[2] = 0x1003; - silconfig->PcieRpNonSnoopLatencyOverrideMode[2] = 0x2; - silconfig->PcieRpLtrMaxSnoopLatency[2] = 0x1003; - silconfig->PcieRpSnoopLatencyOverrideMode[2] = 0x2; - silconfig->PcieRpSnoopLatencyOverrideValue[2] = 0x0; - silconfig->PcieRpSnoopLatencyOverrideMultiplier[2] = 0x2; - - silconfig->PcieRootPortEn[3] = 0x1; - silconfig->PcieRpHide[3] = 0x0; - silconfig->PcieRpSlotImplemented[3] = 0x1; - silconfig->PcieRpHotPlug[3] = 0x0; - silconfig->PcieRpPmSci[3] = 0x1; - silconfig->PcieRpExtSync[3] = 0x1; - silconfig->PcieRpTransmitterHalfSwing[3] = 0x0; - silconfig->PcieRpAcsEnabled[3] = 0x1; - silconfig->PcieRpClkReqSupported[3] = 0x1; - silconfig->PcieRpClkReqNumber[3] = 0x1; - silconfig->PcieRpClkReqDetect[3] = 0x0; - silconfig->AdvancedErrorReporting[3] = 0x0; - silconfig->PmeInterrupt[3] = 0x0; - silconfig->UnsupportedRequestReport[3] = 0x0; - silconfig->FatalErrorReport[3] = 0x0; - silconfig->NoFatalErrorReport[3] = 0x0; - silconfig->CorrectableErrorReport[3] = 0x0; - silconfig->SystemErrorOnFatalError[3] = 0x0; - silconfig->SystemErrorOnNonFatalError[3] = 0x0; - silconfig->SystemErrorOnCorrectableError[3] = 0x0; - silconfig->PcieRpSpeed[3] = 0x0; - silconfig->PhysicalSlotNumber[3] = 0x3; - silconfig->PcieRpCompletionTimeout[3] = 0x0; - silconfig->PtmEnable[3] = 0x0; - silconfig->PcieRpAspm[3] = 0x4; - silconfig->PcieRpL1Substates[3] = 0x3; - silconfig->PcieRpLtrEnable[3] = 0x1; - silconfig->PcieRpLtrConfigLock[3] = 0x0; - silconfig->PcieRpSelectableDeemphasis[3] = 0x1; - silconfig->PcieRpNonSnoopLatencyOverrideValue[3] = 0x3C; - silconfig->PcieRpNonSnoopLatencyOverrideMultiplier[3] = 0x2; - silconfig->PcieRpSlotPowerLimitScale[3] = 0x0; - silconfig->PcieRpSlotPowerLimitValue[3] = 0x0; - silconfig->PcieRpLtrMaxNonSnoopLatency[3] = 0x1003; - silconfig->PcieRpNonSnoopLatencyOverrideMode[3] = 0x2; - silconfig->PcieRpLtrMaxSnoopLatency[3] = 0x1003; - silconfig->PcieRpSnoopLatencyOverrideMode[3] = 0x2; - silconfig->PcieRpSnoopLatencyOverrideValue[3] = 0x3C; - silconfig->PcieRpSnoopLatencyOverrideMultiplier[3] = 0x2; - - silconfig->PcieRootPortEn[4] = 0x1; - silconfig->PcieRpHide[4] = 0x0; - silconfig->PcieRpSlotImplemented[4] = 0x1; - silconfig->PcieRpHotPlug[4] = 0x0; - silconfig->PcieRpPmSci[4] = 0x1; - silconfig->PcieRpExtSync[4] = 0x1; - silconfig->PcieRpTransmitterHalfSwing[4] = 0x0; - silconfig->PcieRpAcsEnabled[4] = 0x1; - silconfig->PcieRpClkReqSupported[4] = 0x1; - silconfig->PcieRpClkReqNumber[4] = 0x2; - silconfig->PcieRpClkReqDetect[4] = 0x0; - silconfig->AdvancedErrorReporting[4] = 0x0; - silconfig->PmeInterrupt[4] = 0x0; - silconfig->UnsupportedRequestReport[4] = 0x0; - silconfig->FatalErrorReport[4] = 0x0; - silconfig->NoFatalErrorReport[4] = 0x0; - silconfig->CorrectableErrorReport[4] = 0x0; - silconfig->SystemErrorOnFatalError[4] = 0x0; - silconfig->SystemErrorOnNonFatalError[4] = 0x0; - silconfig->SystemErrorOnCorrectableError[4] = 0x0; - silconfig->PcieRpSpeed[4] = 0x0; - silconfig->PhysicalSlotNumber[4] = 0x4; - silconfig->PcieRpCompletionTimeout[4] = 0x0; - silconfig->PtmEnable[4] = 0x0; - silconfig->PcieRpAspm[4] = 0x4; - silconfig->PcieRpL1Substates[4] = 0x3; - silconfig->PcieRpLtrEnable[4] = 0x1; - silconfig->PcieRpLtrConfigLock[4] = 0x0; - silconfig->PcieRpSelectableDeemphasis[4] = 0x1; - silconfig->PcieRpNonSnoopLatencyOverrideValue[4] = 0x3C; - silconfig->PcieRpNonSnoopLatencyOverrideMultiplier[4] = 0x2; - silconfig->PcieRpSlotPowerLimitScale[4] = 0x0; - silconfig->PcieRpSlotPowerLimitValue[4] = 0x0; - silconfig->PcieRpLtrMaxNonSnoopLatency[4] = 0x1003; - silconfig->PcieRpNonSnoopLatencyOverrideMode[4] = 0x2; - silconfig->PcieRpLtrMaxSnoopLatency[4] = 0x1003; - silconfig->PcieRpSnoopLatencyOverrideMode[4] = 0x2; - silconfig->PcieRpSnoopLatencyOverrideValue[4] = 0x3C; - silconfig->PcieRpSnoopLatencyOverrideMultiplier[4] = 0x2; - - silconfig->PcieRootPortEn[5] = 0x1; - silconfig->PcieRpHide[5] = 0x0; - silconfig->PcieRpSlotImplemented[5] = 0x1; - silconfig->PcieRpHotPlug[5] = 0x0; - silconfig->PcieRpPmSci[5] = 0x1; - silconfig->PcieRpExtSync[5] = 0x1; - silconfig->PcieRpTransmitterHalfSwing[5] = 0x0; - silconfig->PcieRpAcsEnabled[5] = 0x1; - silconfig->PcieRpClkReqSupported[5] = 0x1; - silconfig->PcieRpClkReqNumber[5] = 0x3; - silconfig->PcieRpClkReqDetect[5] = 0x0; - silconfig->AdvancedErrorReporting[5] = 0x0; - silconfig->PmeInterrupt[5] = 0x0; - silconfig->UnsupportedRequestReport[5] = 0x0; - silconfig->FatalErrorReport[5] = 0x0; - silconfig->NoFatalErrorReport[5] = 0x0; - silconfig->CorrectableErrorReport[5] = 0x0; - silconfig->SystemErrorOnFatalError[5] = 0x0; - silconfig->SystemErrorOnNonFatalError[5] = 0x0; - silconfig->SystemErrorOnCorrectableError[5] = 0x0; - silconfig->PcieRpSpeed[5] = 0x0; - silconfig->PhysicalSlotNumber[5] = 0x5; - silconfig->PcieRpCompletionTimeout[5] = 0x0; - silconfig->PtmEnable[5] = 0x0; - silconfig->PcieRpAspm[5] = 0x4; - silconfig->PcieRpL1Substates[5] = 0x3; - silconfig->PcieRpLtrEnable[5] = 0x1; - silconfig->PcieRpLtrConfigLock[5] = 0x0; - silconfig->PcieRpSelectableDeemphasis[5] = 0x1; - silconfig->PcieRpNonSnoopLatencyOverrideValue[5] = 0x3C; - silconfig->PcieRpNonSnoopLatencyOverrideMultiplier[5] = 0x2; - silconfig->PcieRpSlotPowerLimitScale[5] = 0x0; - silconfig->PcieRpSlotPowerLimitValue[5] = 0x0; - silconfig->PcieRpLtrMaxNonSnoopLatency[5] = 0x1003; - silconfig->PcieRpNonSnoopLatencyOverrideMode[5] = 0x2; - silconfig->PcieRpLtrMaxSnoopLatency[5] = 0x1003; - silconfig->PcieRpSnoopLatencyOverrideMode[5] = 0x2; - silconfig->PcieRpSnoopLatencyOverrideValue[5] = 0x3C; - silconfig->PcieRpSnoopLatencyOverrideMultiplier[5] = 0x2; - - - silconfig->SsicRate[0] = 0x1; - silconfig->SsicPortEnable[0] = 0x0; - silconfig->SsicRate[1] = 0x1; - silconfig->SsicPortEnable[1] = 0x0; - - silconfig->PortUsb30Enable[0] = 0x1; - silconfig->PortUs30bOverCurrentPin[0] = 0x0; - silconfig->PortUsb30Enable[1] = 0x1; - silconfig->PortUs30bOverCurrentPin[1] = 0x1; - silconfig->PortUsb30Enable[2] = 0x1; - silconfig->PortUs30bOverCurrentPin[2] = 0x1; - silconfig->PortUsb30Enable[3] = 0x1; - silconfig->PortUs30bOverCurrentPin[3] = 0x1; - silconfig->PortUsb30Enable[4] = 0x1; - silconfig->PortUs30bOverCurrentPin[4] = 0x1; - silconfig->PortUsb30Enable[5] = 0x1; - silconfig->PortUs30bOverCurrentPin[5] = 0x1; - - silconfig->PortUsb20Enable[0] = 0x1; - silconfig->PortUs20bOverCurrentPin[0] = 0x0; - silconfig->PortUsb20Enable[1] = 0x1; - silconfig->PortUs20bOverCurrentPin[1] = 0x1; - silconfig->PortUsb20Enable[2] = 0x1; - silconfig->PortUs20bOverCurrentPin[2] = 0x1; - silconfig->PortUsb20Enable[3] = 0x1; - silconfig->PortUs20bOverCurrentPin[3] = 0x1; - silconfig->PortUsb20Enable[4] = 0x1; - silconfig->PortUs20bOverCurrentPin[4] = 0x1; - silconfig->PortUsb20Enable[5] = 0x1; - silconfig->PortUs20bOverCurrentPin[5] = 0x1; - silconfig->PortUsb20Enable[6] = 0x1; - silconfig->PortUs20bOverCurrentPin[6] = 0x2; - silconfig->PortUsb20Enable[7] = 0x1; - silconfig->PortUs20bOverCurrentPin[7] = 0x2; + silconfig->PortUs20bOverCurrentPin[1] = 0x1; // 0x0 + silconfig->PortUs20bOverCurrentPin[2] = 0x1; // 0x0 + silconfig->PortUs20bOverCurrentPin[3] = 0x1; // 0x0 + silconfig->PortUs20bOverCurrentPin[4] = 0x1; // 0x0 + silconfig->PortUs20bOverCurrentPin[5] = 0x1; // 0x0 + silconfig->PortUs20bOverCurrentPin[6] = 0x2; // 0x0 + silconfig->PortUs20bOverCurrentPin[7] = 0x2; // 0x0 } diff --git a/src/mainboard/up/squared/upsquared.fmd b/src/mainboard/up/squared/upsquared.fmd index 4ea1375e10..891138ee63 100644 --- a/src/mainboard/up/squared/upsquared.fmd +++ b/src/mainboard/up/squared/upsquared.fmd @@ -3,14 +3,14 @@ FLASH 16M { SI_BIOS@0x1000 0xefe000 { IFWI@0x0 0x2ff000 OBB@0x2ff000 0xbff000 { - FMAP@0x0 0x800 - UNIFIED_MRC_CACHE@0x800 0x21000 { + FMAP@0x0 0x1000 + UNIFIED_MRC_CACHE@0x1000 0x21000 { RECOVERY_MRC_CACHE@0x0 0x10000 RW_MRC_CACHE@0x10000 0x10000 RW_VAR_MRC_CACHE@0x20000 0x1000 } - CONSOLE@0x21800 0x20000 - COREBOOT(CBFS)@0x41800 0xb7d800 + CONSOLE@0x22000 0x20000 + COREBOOT(CBFS)@0x42000 0xb7d000 BIOS_UNUSABLE@0xbbf000 0x40000 } } diff --git a/src/northbridge/amd/agesa/family15tn/northbridge.c b/src/northbridge/amd/agesa/family15tn/northbridge.c index d73ad72de0..c6457a3998 100644 --- a/src/northbridge/amd/agesa/family15tn/northbridge.c +++ b/src/northbridge/amd/agesa/family15tn/northbridge.c @@ -772,42 +772,6 @@ static void sysconf_init(struct device *dev) // first node node_nums = ((pci_read_config32(dev, 0x60)>>4) & 7) + 1; //NodeCnt[2:0] } -static void add_more_links(struct device *dev, unsigned int total_links) -{ - struct bus *link, *last = NULL; - int link_num; - - for (link = dev->link_list; link; link = link->next) - last = link; - - if (last) { - int links = total_links - last->link_num; - link_num = last->link_num; - if (links > 0) { - link = malloc(links*sizeof(*link)); - if (!link) - die("Couldn't allocate more links!\n"); - memset(link, 0, links*sizeof(*link)); - last->next = link; - } - } - else { - link_num = -1; - link = malloc(total_links*sizeof(*link)); - memset(link, 0, total_links*sizeof(*link)); - dev->link_list = link; - } - - for (link_num = link_num + 1; link_num < total_links; link_num++) { - link->link_num = link_num; - link->dev = dev; - link->next = link + 1; - last = link; - link = link->next; - } - last->next = NULL; -} - static void cpu_bus_scan(struct device *dev) { struct bus *cpu_bus; diff --git a/src/northbridge/amd/agesa/family16kb/northbridge.c b/src/northbridge/amd/agesa/family16kb/northbridge.c index 7ca5a6ed53..928d9d2e8a 100644 --- a/src/northbridge/amd/agesa/family16kb/northbridge.c +++ b/src/northbridge/amd/agesa/family16kb/northbridge.c @@ -798,42 +798,6 @@ static void sysconf_init(struct device *dev) // first node node_nums = ((pci_read_config32(dev, 0x60)>>4) & 7) + 1; //NodeCnt[2:0] } -static void add_more_links(struct device *dev, unsigned int total_links) -{ - struct bus *link, *last = NULL; - int link_num; - - for (link = dev->link_list; link; link = link->next) - last = link; - - if (last) { - int links = total_links - last->link_num; - link_num = last->link_num; - if (links > 0) { - link = malloc(links*sizeof(*link)); - if (!link) - die("Couldn't allocate more links!\n"); - memset(link, 0, links*sizeof(*link)); - last->next = link; - } - } - else { - link_num = -1; - link = malloc(total_links*sizeof(*link)); - memset(link, 0, total_links*sizeof(*link)); - dev->link_list = link; - } - - for (link_num = link_num + 1; link_num < total_links; link_num++) { - link->link_num = link_num; - link->dev = dev; - link->next = link + 1; - last = link; - link = link->next; - } - last->next = NULL; -} - static void cpu_bus_scan(struct device *dev) { struct bus *cpu_bus; diff --git a/src/northbridge/amd/amdfam10/ht_config.c b/src/northbridge/amd/amdfam10/ht_config.c index 4810b99b59..8499dbb623 100644 --- a/src/northbridge/amd/amdfam10/ht_config.c +++ b/src/northbridge/amd/amdfam10/ht_config.c @@ -14,6 +14,7 @@ */ #include +#include #include #include @@ -127,6 +128,10 @@ u32 get_io_addr_index(u32 nodeid, u32 linkn) u32 index; for (index = 0; index < 256; index++) { + + if (index + 4 >= ARRAY_SIZE(sysconf.conf_io_addrx)) + die("Error! Out of bounds read in %s:%s\n", __FILE__, __func__); + if (sysconf.conf_io_addrx[index+4] == 0) { sysconf.conf_io_addr[index+4] = (nodeid & 0x3f); sysconf.conf_io_addrx[index+4] = 1 | ((linkn & 0x7)<<4); @@ -142,6 +147,10 @@ u32 get_mmio_addr_index(u32 nodeid, u32 linkn) u32 index; for (index = 0; index < 64; index++) { + + if (index + 8 >= ARRAY_SIZE(sysconf.conf_mmio_addrx)) + die("Error! Out of bounds read in %s:%s\n", __FILE__, __func__); + if (sysconf.conf_mmio_addrx[index+8] == 0) { sysconf.conf_mmio_addr[index+8] = (nodeid & 0x3f); sysconf.conf_mmio_addrx[index+8] = 1 | ((linkn & 0x7)<<4); diff --git a/src/northbridge/amd/amdfam10/northbridge.c b/src/northbridge/amd/amdfam10/northbridge.c index a681961be2..79f43db387 100644 --- a/src/northbridge/amd/amdfam10/northbridge.c +++ b/src/northbridge/amd/amdfam10/northbridge.c @@ -209,15 +209,6 @@ static void amd_g34_fixup(struct bus *link, struct device *dev) */ f3xe8 = pci_read_config32(get_node_pci(nodeid, 3), 0xe8); uint8_t internal_node_number = ((f3xe8 & 0xc0000000) >> 30); - uint8_t defective_link_number_1; - uint8_t defective_link_number_2; - if (is_fam15h()) { - defective_link_number_1 = 4; /* Link 0 Sublink 1 */ - defective_link_number_2 = 7; /* Link 3 Sublink 1 */ - } else { - defective_link_number_1 = 6; /* Link 2 Sublink 1 */ - defective_link_number_2 = 5; /* Link 1 Sublink 1 */ - } if (internal_node_number == 0) { /* Node 0 */ if (link->link_num == 6) /* Link 2 Sublink 1 */ @@ -745,7 +736,6 @@ static void amdfam10_domain_read_resources(struct device *dev) uint8_t node; uint8_t interleaved; int8_t range; - int8_t max_range; uint8_t max_node; uint64_t max_range_limit; uint32_t dword; @@ -756,7 +746,6 @@ static void amdfam10_domain_read_resources(struct device *dev) /* Find highest DRAM range (DramLimitAddr) */ num_nodes = 0; max_node = 0; - max_range = -1; interleaved = 0; max_range_limit = 0; struct device *node_dev; @@ -782,7 +771,6 @@ static void amdfam10_domain_read_resources(struct device *dev) qword |= (((uint64_t)dword2) & 0xff) << 40; if (qword > max_range_limit) { - max_range = range; max_range_limit = qword; max_node = dword & 0x7; } @@ -791,7 +779,7 @@ static void amdfam10_domain_read_resources(struct device *dev) /* Calculate CC6 storage area size */ if (interleaved) - qword = (0x1000000 * num_nodes); + qword = (uint64_t)0x1000000 * num_nodes; else qword = 0x1000000; @@ -904,7 +892,6 @@ static void amdfam10_domain_set_resources(struct device *dev) struct bus *link; #if CONFIG_HW_MEM_HOLE_SIZEK != 0 struct hw_mem_hole_info mem_hole; - u32 reset_memhole = 1; #endif pci_tolm = 0xffffffffUL; @@ -935,7 +922,6 @@ static void amdfam10_domain_set_resources(struct device *dev) // Use hole_basek as mmio_basek, and we don't need to reset hole anymore if ((mem_hole.node_id != -1) && (mmio_basek > mem_hole.hole_startk)) { mmio_basek = mem_hole.hole_startk; - reset_memhole = 0; } #endif @@ -1375,42 +1361,6 @@ static void sysconf_init(struct device *dev) // first node #endif } -static void add_more_links(struct device *dev, unsigned total_links) -{ - struct bus *link, *last = NULL; - int link_num = -1; - - for (link = dev->link_list; link; link = link->next) { - if (link_num < link->link_num) - link_num = link->link_num; - last = link; - } - - if (last) { - int links = total_links - (link_num + 1); - if (links > 0) { - link = malloc(links*sizeof(*link)); - if (!link) - die("Couldn't allocate more links!\n"); - memset(link, 0, links*sizeof(*link)); - last->next = link; - } - } else { - link = malloc(total_links*sizeof(*link)); - memset(link, 0, total_links*sizeof(*link)); - dev->link_list = link; - } - - for (link_num = link_num + 1; link_num < total_links; link_num++) { - link->link_num = link_num; - link->dev = dev; - link->next = link + 1; - last = link; - link = link->next; - } - last->next = NULL; -} - static void remap_bsp_lapic(struct bus *cpu_bus) { struct device_path cpu_path; @@ -1542,7 +1492,6 @@ static void cpu_bus_scan(struct device *dev) uint8_t rev_gte_d = 0; uint8_t dual_node = 0; uint32_t f3xe8; - uint32_t family; uint32_t model; busn = CONFIG_CBB; @@ -1583,7 +1532,7 @@ static void cpu_bus_scan(struct device *dev) f3xe8 = pci_read_config32(get_node_pci(0, 3), 0xe8); - family = model = cpuid_eax(0x80000001); + model = cpuid_eax(0x80000001); model = ((model & 0xf0000) >> 12) | ((model & 0xf0) >> 4); if (is_fam15h()) { @@ -1691,17 +1640,14 @@ static void detect_and_enable_probe_filter(struct device *dev) uint8_t fam15h = 0; uint8_t rev_gte_d = 0; - unsigned nb_cfg_54; - uint32_t family; uint32_t model; - family = model = cpuid_eax(0x80000001); + model = cpuid_eax(0x80000001); model = ((model & 0xf0000) >> 12) | ((model & 0xf0) >> 4); if (is_fam15h()) { /* Family 15h or later */ fam15h = 1; - nb_cfg_54 = 1; } if ((model >= 0x8) || fam15h) @@ -1862,20 +1808,11 @@ static void detect_and_enable_cache_partitioning(struct device *dev) uint8_t cu_enabled; uint8_t compute_unit_count = 0; - uint32_t f3xe8; - uint8_t dual_node = 0; - for (i = 0; i < sysconf.nodes; i++) { struct device *f3x_dev = pcidev_on_root(0x18 + i, 3); struct device *f4x_dev = pcidev_on_root(0x18 + i, 4); struct device *f5x_dev = pcidev_on_root(0x18 + i, 5); - f3xe8 = pci_read_config32(f3x_dev, 0xe8); - - /* Check for dual node capability */ - if (f3xe8 & 0x20000000) - dual_node = 1; - /* Determine the number of active compute units on this node */ f5x80 = pci_read_config32(f5x_dev, 0x80); cu_enabled = f5x80 & 0xf; diff --git a/src/northbridge/amd/amdmct/mct/mctardk3.c b/src/northbridge/amd/amdmct/mct/mctardk3.c index ce79a5245b..4eac790d5c 100644 --- a/src/northbridge/amd/amdmct/mct/mctardk3.c +++ b/src/northbridge/amd/amdmct/mct/mctardk3.c @@ -90,21 +90,13 @@ void mctGet_PS_Cfg_D(struct MCTStatStruc *pMCTstat, valx &= 0xAA; valx >>= 1; } - if (mctGet_NVbits(NV_MAX_DIMMS) == 8) { - val &= valx; - if (val != 0) { + val &= valx; + if (val != 0) { + if (mctGet_NVbits(NV_MAX_DIMMS) == 8 || + pDCTstat->Speed == 3) { pDCTstat->CH_ADDR_TMG[dct] &= 0xFFFF00FF; pDCTstat->CH_ADDR_TMG[dct] |= 0x00002F00; } - } else { - val &= valx; - if (val != 0) { - if (pDCTstat->Speed == 3 || pDCTstat->Speed == 3) { - pDCTstat->CH_ADDR_TMG[dct] &= 0xFFFF00FF; - pDCTstat->CH_ADDR_TMG[dct] |= 0x00002F00; - } - } - } } } diff --git a/src/northbridge/amd/amdmct/mct/mctardk4.c b/src/northbridge/amd/amdmct/mct/mctardk4.c index d112c4664b..2e16a80002 100644 --- a/src/northbridge/amd/amdmct/mct/mctardk4.c +++ b/src/northbridge/amd/amdmct/mct/mctardk4.c @@ -128,8 +128,6 @@ static void Get_ChannelPS_Cfg0_D(u8 MAAdimms, u8 Speed, u8 MAAload, *AddrTmgCTL = 0x002F2F00; } else if (Speed == 1) { *AddrTmgCTL = 0x002F2F00; - } else if (Speed == 5) { - *AddrTmgCTL = 0x002F2020; } else { *AddrTmgCTL = 0x002F2F2F; } diff --git a/src/northbridge/amd/amdmct/mct_ddr3/mct_d.c b/src/northbridge/amd/amdmct/mct_ddr3/mct_d.c index 5be456695e..fa8c71447b 100644 --- a/src/northbridge/amd/amdmct/mct_ddr3/mct_d.c +++ b/src/northbridge/amd/amdmct/mct_ddr3/mct_d.c @@ -3071,11 +3071,6 @@ void fam15EnableTrainingMode(struct MCTStatStruc *pMCTstat, */ uint8_t dimm_event_l_pin_support = 0; - if (pDCTstat->DIMMValidDCT[dct] == 0) - ddr_voltage_index = 1; - else - ddr_voltage_index = dct_ddr_voltage_index(pDCTstat, dct); - ddr_voltage_index = dct_ddr_voltage_index(pDCTstat, dct); max_dimms_installable = mctGet_NVbits(NV_MAX_DIMMS_PER_CH); @@ -3090,12 +3085,6 @@ void fam15EnableTrainingMode(struct MCTStatStruc *pMCTstat, if (pDCTstat->DIMMValidDCT[0] && pDCTstat->DIMMValidDCT[1] && mctGet_NVbits(NV_Unganged)) interleave_channels = 1; - dword = (Get_NB32_DCT(dev, dct, 0x240) >> 4) & 0xf; - if (dword > 6) - read_odt_delay = dword - 6; - else - read_odt_delay = 0; - dword = Get_NB32_DCT(dev, dct, 0x240); delay = (dword >> 4) & 0xf; if (delay > 6) diff --git a/src/northbridge/amd/amdmct/mct_ddr3/mhwlc_d.c b/src/northbridge/amd/amdmct/mct_ddr3/mhwlc_d.c index ab16887f1d..42f313ab92 100644 --- a/src/northbridge/amd/amdmct/mct_ddr3/mhwlc_d.c +++ b/src/northbridge/amd/amdmct/mct_ddr3/mhwlc_d.c @@ -1213,13 +1213,6 @@ void procConfig(struct MCTStatStruc *pMCTstat, struct DCTStatStruc *pDCTstat, ui Seed_Fine = (SeedTotal[ByteLane] % 32) + 32; } - if (Seed_Gross == 0) - Seed_PreGross = 0; - else if (Seed_Gross & 0x1) - Seed_PreGross = 1; - else - Seed_PreGross = 2; - /* The BKDG-recommended algorithm causes problems with registered DIMMs on some systems * due to the long register delays causing premature total delay wrap-around. * Attempt to work around this... diff --git a/src/northbridge/amd/pi/00630F01/northbridge.c b/src/northbridge/amd/pi/00630F01/northbridge.c index 309a762840..518c6e2ab9 100644 --- a/src/northbridge/amd/pi/00630F01/northbridge.c +++ b/src/northbridge/amd/pi/00630F01/northbridge.c @@ -786,42 +786,6 @@ static void sysconf_init(struct device *dev) // first node node_nums = ((pci_read_config32(dev, 0x60)>>4) & 7) + 1; //NodeCnt[2:0] } -static void add_more_links(struct device *dev, unsigned total_links) -{ - struct bus *link, *last = NULL; - int link_num; - - for (link = dev->link_list; link; link = link->next) - last = link; - - if (last) { - int links = total_links - last->link_num; - link_num = last->link_num; - if (links > 0) { - link = malloc(links*sizeof(*link)); - if (!link) - die("Couldn't allocate more links!\n"); - memset(link, 0, links*sizeof(*link)); - last->next = link; - } - } - else { - link_num = -1; - link = malloc(total_links*sizeof(*link)); - memset(link, 0, total_links*sizeof(*link)); - dev->link_list = link; - } - - for (link_num = link_num + 1; link_num < total_links; link_num++) { - link->link_num = link_num; - link->dev = dev; - link->next = link + 1; - last = link; - link = link->next; - } - last->next = NULL; -} - static void cpu_bus_scan(struct device *dev) { struct bus *cpu_bus; diff --git a/src/northbridge/amd/pi/00660F01/northbridge.c b/src/northbridge/amd/pi/00660F01/northbridge.c index 41641ee65f..c67e5ff2ee 100644 --- a/src/northbridge/amd/pi/00660F01/northbridge.c +++ b/src/northbridge/amd/pi/00660F01/northbridge.c @@ -784,42 +784,6 @@ static void sysconf_init(struct device *dev) // first node node_nums = ((pci_read_config32(dev, 0x60)>>4) & 7) + 1; // NodeCnt[2:0] } -static void add_more_links(struct device *dev, unsigned total_links) -{ - struct bus *link, *last = NULL; - int link_num; - - for (link = dev->link_list; link; link = link->next) - last = link; - - if (last) { - int links = total_links - last->link_num; - link_num = last->link_num; - if (links > 0) { - link = malloc(links*sizeof(*link)); - if (!link) - die("Couldn't allocate more links!\n"); - memset(link, 0, links*sizeof(*link)); - last->next = link; - } - } - else { - link_num = -1; - link = malloc(total_links*sizeof(*link)); - memset(link, 0, total_links*sizeof(*link)); - dev->link_list = link; - } - - for (link_num = link_num + 1; link_num < total_links; link_num++) { - link->link_num = link_num; - link->dev = dev; - link->next = link + 1; - last = link; - link = link->next; - } - last->next = NULL; -} - static void cpu_bus_scan(struct device *dev) { struct bus *cpu_bus; diff --git a/src/northbridge/amd/pi/00730F01/northbridge.c b/src/northbridge/amd/pi/00730F01/northbridge.c index 2ca9d4efbd..377d91eeae 100644 --- a/src/northbridge/amd/pi/00730F01/northbridge.c +++ b/src/northbridge/amd/pi/00730F01/northbridge.c @@ -1025,42 +1025,6 @@ static void sysconf_init(struct device *dev) // first node node_nums = ((pci_read_config32(dev, 0x60)>>4) & 7) + 1; //NodeCnt[2:0] } -static void add_more_links(struct device *dev, unsigned int total_links) -{ - struct bus *link, *last = NULL; - int link_num; - - for (link = dev->link_list; link; link = link->next) - last = link; - - if (last) { - int links = total_links - last->link_num; - link_num = last->link_num; - if (links > 0) { - link = malloc(links*sizeof(*link)); - if (!link) - die("Couldn't allocate more links!\n"); - memset(link, 0, links*sizeof(*link)); - last->next = link; - } - } - else { - link_num = -1; - link = malloc(total_links*sizeof(*link)); - memset(link, 0, total_links*sizeof(*link)); - dev->link_list = link; - } - - for (link_num = link_num + 1; link_num < total_links; link_num++) { - link->link_num = link_num; - link->dev = dev; - link->next = link + 1; - last = link; - link = link->next; - } - last->next = NULL; -} - static void cpu_bus_scan(struct device *dev) { struct bus *cpu_bus; diff --git a/src/northbridge/intel/haswell/Kconfig b/src/northbridge/intel/haswell/Kconfig index e1067c5949..3678cb803d 100644 --- a/src/northbridge/intel/haswell/Kconfig +++ b/src/northbridge/intel/haswell/Kconfig @@ -55,10 +55,6 @@ config MMCONF_BASE_ADDRESS hex default 0xf0000000 -config CACHE_MRC_SIZE_KB - int - default 512 - config DCACHE_RAM_BASE hex default 0xff7c0000 diff --git a/src/northbridge/intel/i945/Kconfig b/src/northbridge/intel/i945/Kconfig index 2c21420088..93251965c1 100644 --- a/src/northbridge/intel/i945/Kconfig +++ b/src/northbridge/intel/i945/Kconfig @@ -56,10 +56,6 @@ config I945_LVDS for the LVDS port. A linear framebuffer is only supported for LVDS. -config CHANNEL_XOR_RANDOMIZATION - bool - default n - config MMCONF_BASE_ADDRESS hex default 0xf0000000 diff --git a/src/northbridge/intel/i945/raminit.c b/src/northbridge/intel/i945/raminit.c index 797ea1229d..281e7b2679 100644 --- a/src/northbridge/intel/i945/raminit.c +++ b/src/northbridge/intel/i945/raminit.c @@ -2112,12 +2112,8 @@ static void sdram_post_jedec_initialization(struct sys_info *sysinfo) if (sysinfo->interleaved) { reg32 = MCHBAR32(DCC); -#if CONFIG(CHANNEL_XOR_RANDOMIZATION) reg32 &= ~(1 << 10); reg32 |= (1 << 9); -#else - reg32 &= ~(1 << 9); -#endif MCHBAR32(DCC) = reg32; } diff --git a/src/northbridge/intel/nehalem/raminit.c b/src/northbridge/intel/nehalem/raminit.c index 15d6abb67b..2b71c81825 100644 --- a/src/northbridge/intel/nehalem/raminit.c +++ b/src/northbridge/intel/nehalem/raminit.c @@ -2235,26 +2235,11 @@ train_ram_at_178(struct raminfo *info, u8 channel, int slot, int rank, u8 lower_usable[8]; u8 upper_usable[8]; unsigned short num_successfully_checked[8]; - u8 secondary_total_rank; u8 reg1b3; + int i; - if (info->populated_ranks_mask[1]) { - if (channel == 1) - secondary_total_rank = - info->populated_ranks[1][0][0] + - info->populated_ranks[1][0][1] - + info->populated_ranks[1][1][0] + - info->populated_ranks[1][1][1]; - else - secondary_total_rank = 0; - } else - secondary_total_rank = total_rank; - - { - int i; - for (i = 0; i < 8; i++) - state[i] = BEFORE_USABLE; - } + for (i = 0; i < 8; i++) + state[i] = BEFORE_USABLE; if (!first_run) { int is_all_ok = 1; @@ -2270,7 +2255,6 @@ train_ram_at_178(struct raminfo *info, u8 channel, int slot, int rank, is_all_ok = 0; } if (is_all_ok) { - int i; for (i = 0; i < 8; i++) state[i] = COMPLETE; } @@ -2336,7 +2320,6 @@ train_ram_at_178(struct raminfo *info, u8 channel, int slot, int rank, do { u8 failmask = 0; - int i; for (i = 0; i < niter; i++) { if (failmask == 0xFF) break; @@ -2437,7 +2420,6 @@ train_ram_at_178(struct raminfo *info, u8 channel, int slot, int rank, do { int failmask = 0; - int i; for (i = 0; i < niter; i++) { if (failmask == 0xFF) break; @@ -3740,11 +3722,6 @@ void raminit(const int s3resume, const u8 *spd_addrmap) u16 deven; int cbmem_wasnot_inited; - /* only used for dummy reads */ - volatile u8 tmp8; - volatile u16 tmp16; - volatile u32 tmp32; - x2ca8 = MCHBAR8(0x2ca8); deven = pci_read_config16(NORTHBRIDGE, D0F0_DEVEN); @@ -4058,10 +4035,10 @@ void raminit(const int s3resume, const u8 *spd_addrmap) pci_read_config8(PCI_DEV (0, 0x2, 0x0), 0x4c); pci_read_config8(PCI_DEV (0, 0x2, 0x0), 0x4e); - tmp8 = MCHBAR8(0x1150); - tmp8 = MCHBAR8(0x1151); - tmp8 = MCHBAR8(0x1022); - tmp8 = MCHBAR8(0x16d0); + MCHBAR8(0x1150); + MCHBAR8(0x1151); + MCHBAR8(0x1022); + MCHBAR8(0x16d0); MCHBAR32(0x1300) = 0x60606060; MCHBAR32(0x1304) = 0x60606060; MCHBAR32(0x1308) = 0x78797a7b; @@ -4249,10 +4226,10 @@ void raminit(const int s3resume, const u8 *spd_addrmap) } MCHBAR32_AND_OR(0x2c80, 0, 0x1053688); // !!!! - tmp32 = MCHBAR32(0x1c04); // !!!! + MCHBAR32(0x1c04); // !!!! MCHBAR32(0x1804) = 0x406080; - tmp8 = MCHBAR8(0x2ca8); + MCHBAR8(0x2ca8); if (x2ca8 == 0) { MCHBAR8_AND(0x2ca8, ~3); @@ -4264,9 +4241,9 @@ void raminit(const int s3resume, const u8 *spd_addrmap) MCHBAR8(0x2ca8) = MCHBAR8(0x2ca8); MCHBAR32_AND_OR(0x2c80, 0, 0x53688); // !!!! pci_write_config32(PCI_DEV (0xff, 0, 0), 0x60, 0x20220); - tmp16 = MCHBAR16(0x2c20); // !!!! - tmp16 = MCHBAR16(0x2c10); // !!!! - tmp16 = MCHBAR16(0x2c00); // !!!! + MCHBAR16(0x2c20); // !!!! + MCHBAR16(0x2c10); // !!!! + MCHBAR16(0x2c00); // !!!! MCHBAR16(0x2c00) = 0x8c0; udelay(1000); write_1d0(0, 0x33d, 0, 0); @@ -4372,7 +4349,7 @@ void raminit(const int s3resume, const u8 *spd_addrmap) MCHBAR32_AND_OR(0x1f4, 0, 0x20000); // !!!! MCHBAR32(0x1f0) = 0x1d000200; MCHBAR8_AND_OR(0x1f0, 0, 0x1); // !!!! - tmp8 = MCHBAR8(0x1f0); // !!!! + MCHBAR8(0x1f0); // !!!! program_board_delay(&info); @@ -4431,7 +4408,7 @@ void raminit(const int s3resume, const u8 *spd_addrmap) info.populated_ranks[channel][0][0] ? 9 : 1); rmw_1d0(0x116, 0xe, 1, 4, 1); // = 0x4040432 // !!!! - tmp32 = MCHBAR32(0x144); // !!!! + MCHBAR32(0x144); // !!!! write_1d0(2, 0xae, 6, 1); write_1d0(2, 0x300, 6, 1); write_1d0(2, 0x121, 3, 1); @@ -4681,7 +4658,7 @@ void raminit(const int s3resume, const u8 *spd_addrmap) reg1c = read32p(DEFAULT_EPBAR | 0x01c); // = 0x8001 // OK pci_read_config32(NORTHBRIDGE, 0x40); // = DEFAULT_EPBAR | 0x001 // OK write32p(DEFAULT_EPBAR | 0x01c, reg1c); // OK - tmp8 = MCHBAR8(0xe08); // = 0x0 + MCHBAR8(0xe08); // = 0x0 pci_read_config32(NORTHBRIDGE, 0xe4); // = 0x316126 MCHBAR8_OR(0x1210, 2); MCHBAR32(0x1200) = 0x8800440; diff --git a/src/northbridge/intel/pineview/raminit.c b/src/northbridge/intel/pineview/raminit.c index 72063cbdad..1d24ea2217 100644 --- a/src/northbridge/intel/pineview/raminit.c +++ b/src/northbridge/intel/pineview/raminit.c @@ -1141,16 +1141,7 @@ static void sdram_dlltiming(struct sysinfo *s) MCHBAR8(0x1a8) = MCHBAR8(0x1a8) | 1; MCHBAR32(0x1a0) = 0x551803; - if (ONLY_DIMMA_IS_POPULATED(s->dimms, 0)) { - reg8 = 0x3c; - } else if (ONLY_DIMMB_IS_POPULATED(s->dimms, 0)) { - reg8 = 0x27; - } else if (BOTH_DIMMS_ARE_POPULATED(s->dimms, 0)) { - reg8 = 0x24; - } else { - // None - reg8 = 0x3f; - } + reg8 = 0x00; //switch all clocks on anyway MCHBAR32(0x5a0) = (MCHBAR32(0x5a0) & ~0x3f000000) | (reg8 << 24); diff --git a/src/northbridge/intel/sandybridge/Kconfig b/src/northbridge/intel/sandybridge/Kconfig index 4f9da000a4..53725cafb4 100644 --- a/src/northbridge/intel/sandybridge/Kconfig +++ b/src/northbridge/intel/sandybridge/Kconfig @@ -64,10 +64,6 @@ config VGA_BIOS_ID string default "8086,0106" -config CACHE_MRC_SIZE_KB - int - default 512 - config BOOTBLOCK_NORTHBRIDGE_INIT string default "northbridge/intel/sandybridge/bootblock.c" @@ -78,12 +74,13 @@ config MMCONF_BASE_ADDRESS help The MRC blob requires it to be at 0xf0000000. -if USE_NATIVE_RAMINIT - config DCACHE_RAM_BASE hex default 0xfefe0000 + +if USE_NATIVE_RAMINIT + config DCACHE_RAM_SIZE hex default 0x20000 @@ -96,17 +93,13 @@ endif # USE_NATIVE_RAMINIT if !USE_NATIVE_RAMINIT -config DCACHE_RAM_BASE - hex - default 0xff7e0000 - config DCACHE_RAM_SIZE hex - default 0x1c000 + default 0x17000 config DCACHE_RAM_MRC_VAR_SIZE hex - default 0x4000 + default 0x9000 config MRC_FILE string "Intel System Agent path and filename" diff --git a/src/northbridge/intel/sandybridge/raminit_mrc.c b/src/northbridge/intel/sandybridge/raminit_mrc.c index e88d356593..a8acfbf980 100644 --- a/src/northbridge/intel/sandybridge/raminit_mrc.c +++ b/src/northbridge/intel/sandybridge/raminit_mrc.c @@ -265,9 +265,31 @@ void sdram_initialize(struct pei_data *pei_data) report_memory_config(); } -/* These are the location and structure of MRC_VAR data in CAR. */ +/* These are the location and structure of MRC_VAR data in CAR. + The CAR region looks like this: + +------------------+ -> DCACHE_RAM_BASE + | | + | | + | COREBOOT STACK | + | | + | | + +------------------+ -> DCACHE_RAM_BASE + DCACHE_RAM_SIZE + | | + | MRC HEAP | + | size = 0x5000 | + | | + +------------------+ + | | + | MRC VAR | + | size = 0x4000 | + | | + +------------------+ -> DACHE_RAM_BASE + DACHE_RAM_SIZE + + DCACHE_RAM_MRC_VAR_SIZE + + */ #define DCACHE_RAM_MRC_VAR_BASE \ - (CONFIG_DCACHE_RAM_BASE + CONFIG_DCACHE_RAM_SIZE) + (CONFIG_DCACHE_RAM_BASE + CONFIG_DCACHE_RAM_SIZE + \ + CONFIG_DCACHE_RAM_MRC_VAR_SIZE - 0x4000) struct mrc_var_data { u32 acpi_timer_flag; diff --git a/src/northbridge/intel/x4x/raminit.c b/src/northbridge/intel/x4x/raminit.c index bd6536ab6f..8013af9d51 100644 --- a/src/northbridge/intel/x4x/raminit.c +++ b/src/northbridge/intel/x4x/raminit.c @@ -461,9 +461,9 @@ static void print_selected_timings(struct sysinfo *s) { printk(BIOS_DEBUG, "Selected timings:\n"); printk(BIOS_DEBUG, "\tFSB: %dMHz\n", - fsb2mhz(s->selected_timings.fsb_clk)); + fsb_to_mhz(s->selected_timings.fsb_clk)); printk(BIOS_DEBUG, "\tDDR: %dMHz\n", - ddr2mhz(s->selected_timings.mem_clk)); + ddr_to_mhz(s->selected_timings.mem_clk)); printk(BIOS_DEBUG, "\tCAS: %d\n", s->selected_timings.CAS); printk(BIOS_DEBUG, "\ttRAS: %d\n", s->selected_timings.tRAS); diff --git a/src/northbridge/intel/x4x/raminit_ddr23.c b/src/northbridge/intel/x4x/raminit_ddr23.c index 422b0ffa16..32618e8c88 100644 --- a/src/northbridge/intel/x4x/raminit_ddr23.c +++ b/src/northbridge/intel/x4x/raminit_ddr23.c @@ -32,12 +32,12 @@ #define ME_UMA_SIZEMB 0 -u32 fsb2mhz(u32 speed) +u32 fsb_to_mhz(u32 speed) { return (speed * 267) + 800; } -u32 ddr2mhz(u32 speed) +u32 ddr_to_mhz(u32 speed) { static const u16 mhz[] = { 0, 0, 667, 800, 1067, 1333 }; @@ -413,13 +413,13 @@ static void program_timings(struct sysinfo *s) adjusted_cas = s->selected_timings.CAS - 3; - u16 fsb2ps[3] = { + u16 fsb_to_ps[3] = { 5000, // 800 3750, // 1067 3000 // 1333 }; - u16 ddr2ps[6] = { + u16 ddr_to_ps[6] = { 5000, // 400 3750, // 533 3000, // 667 @@ -573,13 +573,13 @@ static void program_timings(struct sysinfo *s) MCHBAR8_AND_OR(0x400*i + 0x246, ~0x1f, (reg8 << 2) | 1); - fsb = fsb2ps[s->selected_timings.fsb_clk]; - ddr = ddr2ps[s->selected_timings.mem_clk]; + fsb = fsb_to_ps[s->selected_timings.fsb_clk]; + ddr = ddr_to_ps[s->selected_timings.mem_clk]; reg32 = (u32)((s->selected_timings.CAS + 7 + reg8) * ddr); reg32 = (u32)((reg32 / fsb) << 8); reg32 |= 0x0e000000; - if ((fsb2mhz(s->selected_timings.fsb_clk) / - ddr2mhz(s->selected_timings.mem_clk)) > 2) { + if ((fsb_to_mhz(s->selected_timings.fsb_clk) / + ddr_to_mhz(s->selected_timings.mem_clk)) > 2) { reg32 |= 1 << 24; } MCHBAR32_AND_OR(0x400*i + 0x248, ~0x0f001f00, reg32); @@ -671,7 +671,7 @@ static void program_timings(struct sysinfo *s) if (s->spd_type == DDR3) { MCHBAR8(0x114) = 0x42; reg16 = (512 - MAX(5, s->selected_timings.tRFC + 10000 - / ddr2ps[s->selected_timings.mem_clk])) + / ddr_to_ps[s->selected_timings.mem_clk])) / 2; reg16 &= 0x1ff; reg32 = (reg16 << 22) | (0x80 << 14) | (0xa << 9); diff --git a/src/northbridge/intel/x4x/x4x.h b/src/northbridge/intel/x4x/x4x.h index a7efb172c5..57723364ab 100644 --- a/src/northbridge/intel/x4x/x4x.h +++ b/src/northbridge/intel/x4x/x4x.h @@ -378,8 +378,8 @@ u8 decode_pciebar(u32 *const base, u32 *const len); void sdram_initialize(int boot_path, const u8 *spd_map); void do_raminit(struct sysinfo *, int fast_boot); void rcven(struct sysinfo *s); -u32 fsb2mhz(u32 speed); -u32 ddr2mhz(u32 speed); +u32 fsb_to_mhz(u32 speed); +u32 ddr_to_mhz(u32 speed); u32 test_address(int channel, int rank); void dqsset(u8 ch, u8 lane, const struct dll_setting *setting); void dqset(u8 ch, u8 lane, const struct dll_setting *setting); diff --git a/src/security/Kconfig b/src/security/Kconfig index 6a334ac09c..8a1531a08d 100644 --- a/src/security/Kconfig +++ b/src/security/Kconfig @@ -14,3 +14,4 @@ source "src/security/vboot/Kconfig" source "src/security/tpm/Kconfig" +source "src/security/memory/Kconfig" diff --git a/src/security/Makefile.inc b/src/security/Makefile.inc index a940b82613..f62413e059 100644 --- a/src/security/Makefile.inc +++ b/src/security/Makefile.inc @@ -1,2 +1,3 @@ subdirs-y += vboot subdirs-y += tpm +subdirs-y += memory diff --git a/src/security/memory/Kconfig b/src/security/memory/Kconfig new file mode 100644 index 0000000000..5436119ba5 --- /dev/null +++ b/src/security/memory/Kconfig @@ -0,0 +1,34 @@ +## This file is part of the coreboot project. +## +## Copyright (C) 2019 Facebook Inc. +## 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. +## + +menu "Memory initialization" + +config PLATFORM_HAS_DRAM_CLEAR + bool + default n + help + Selected by platforms that support clearing all DRAM + after DRAM initialization. + +config SECURITY_CLEAR_DRAM_ON_REGULAR_BOOT + depends on PLATFORM_HAS_DRAM_CLEAR + bool "Always clear all DRAM on regular boot" + help + Always clear the DRAM after DRAM initialization regardless + of additional security implementations in use. + This increases boot time depending on the amount of DRAM + installed. + +endmenu #Memory initialization diff --git a/src/security/memory/Makefile.inc b/src/security/memory/Makefile.inc new file mode 100644 index 0000000000..525c4dbb4d --- /dev/null +++ b/src/security/memory/Makefile.inc @@ -0,0 +1,3 @@ +romstage-$(CONFIG_PLATFORM_HAS_DRAM_CLEAR) += memory.c +postcar-$(CONFIG_PLATFORM_HAS_DRAM_CLEAR) += memory.c +ramstage-$(CONFIG_PLATFORM_HAS_DRAM_CLEAR) += memory.c diff --git a/src/security/memory/memory.c b/src/security/memory/memory.c new file mode 100644 index 0000000000..14f28578b5 --- /dev/null +++ b/src/security/memory/memory.c @@ -0,0 +1,33 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2019 9elements Agency GmbH + * Copyright (C) 2019 Facebook 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 "memory.h" + +/** + * To be called after DRAM init. + * Tells the caller if DRAM must be cleared as requested by the user, + * firmware or security framework. + */ +bool security_clear_dram_request(void) +{ + if (CONFIG(SECURITY_CLEAR_DRAM_ON_REGULAR_BOOT)) + return true; + + /* TODO: Add TEE environments here */ + + return false; +} diff --git a/src/security/memory/memory.h b/src/security/memory/memory.h new file mode 100644 index 0000000000..ccb07d76ad --- /dev/null +++ b/src/security/memory/memory.h @@ -0,0 +1,19 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2019 9elements Agency GmbH + * Copyright (C) 2019 Facebook 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 + +bool security_clear_dram_request(void); diff --git a/src/security/tpm/Makefile.inc b/src/security/tpm/Makefile.inc index c05fb55a88..a2d32cff89 100644 --- a/src/security/tpm/Makefile.inc +++ b/src/security/tpm/Makefile.inc @@ -36,8 +36,8 @@ romstage-y += tss/tcg-2.0/tss.c verstage-$(CONFIG_VBOOT) += tss/tcg-2.0/tss_marshaling.c verstage-$(CONFIG_VBOOT) += tss/tcg-2.0/tss.c -postcar-$(CONFIG_VBOOT) += tss/tcg-2.0/tss_marshaling.c -postcar-$(CONFIG_VBOOT) += tss/tcg-2.0/tss.c +postcar-y += tss/tcg-2.0/tss_marshaling.c +postcar-y += tss/tcg-2.0/tss.c ## TSPI diff --git a/src/security/tpm/tss/tcg-2.0/tss.c b/src/security/tpm/tss/tcg-2.0/tss.c index e579bff78e..c4b553840f 100644 --- a/src/security/tpm/tss/tcg-2.0/tss.c +++ b/src/security/tpm/tss/tcg-2.0/tss.c @@ -181,10 +181,15 @@ uint32_t tlcl_lib_init(void) if (done) return VB2_SUCCESS; - if (tis_init()) + if (tis_init()) { + printk(BIOS_ERR, "%s: tis_init returned error\n", __func__); return VB2_ERROR_UNKNOWN; - if (tis_open()) + } + + if (tis_open()) { + printk(BIOS_ERR, "%s: tis_open returned error\n", __func__); return VB2_ERROR_UNKNOWN; + } car_set_var(tlcl_init_done, 1); diff --git a/src/security/vboot/Makefile.inc b/src/security/vboot/Makefile.inc index 9ce724ed54..6d195292e2 100644 --- a/src/security/vboot/Makefile.inc +++ b/src/security/vboot/Makefile.inc @@ -88,7 +88,8 @@ else verstage-y += secdata_tpm.c romstage-$(CONFIG_VBOOT_SEPARATE_VERSTAGE) += secdata_tpm.c endif -romstage-y += vboot_handoff.c common.c +romstage-y += vboot_logic.c +romstage-y += common.c ramstage-y += common.c postcar-y += common.c diff --git a/src/security/vboot/bootmode.c b/src/security/vboot/bootmode.c index 68749f008b..4d4dc0ddfd 100644 --- a/src/security/vboot/bootmode.c +++ b/src/security/vboot/bootmode.c @@ -26,10 +26,6 @@ static int vboot_get_recovery_reason_shared_data(void) { - /* Shared data does not exist for Ramstage and Post-CAR stage. */ - if (ENV_RAMSTAGE || ENV_POSTCAR) - return 0; - struct vb2_shared_data *sd = vboot_get_shared_data(); assert(sd); return sd->recovery_reason; @@ -96,11 +92,10 @@ static int vboot_possibly_executed(void) * VB2_RECOVERY_RO_MANUAL. * 2. Checks if recovery request is present in VBNV and returns the code read * from it. - * 3. Checks recovery request in handoff for stages post-cbmem. - * 4. For non-CBMEM stages, check if vboot verification is done and look-up - * selected region to identify if vboot_reference library has requested recovery - * path. If yes, return the reason code from shared data. - * 5. If nothing applies, return 0 indicating no recovery request. + * 3. Checks if vboot verification is done and looks up selected region + * to identify if vboot_reference library has requested recovery path. + * If yes, return the reason code from shared data. + * 4. If nothing applies, return 0 indicating no recovery request. */ int vboot_check_recovery_request(void) { @@ -115,19 +110,8 @@ int vboot_check_recovery_request(void) return reason; /* - * Check recovery flag in vboot_handoff for stages post CBMEM coming - * online. Since for some stages there is no way to know if cbmem has - * already come online, try looking up handoff anyways. If it fails, - * flow will fallback to looking up shared data. - */ - if (cbmem_possibly_online() && - ((reason = vboot_handoff_get_recovery_reason()) != 0)) - return reason; - - /* - * For stages where CBMEM might not be online, identify if vboot - * verification is already complete and no slot was selected - * i.e. recovery path was requested. + * Identify if vboot verification is already complete and no slot + * was selected i.e. recovery path was requested. */ if (vboot_possibly_executed() && vboot_logic_executed() && !vboot_is_slot_selected()) diff --git a/src/security/vboot/common.c b/src/security/vboot/common.c index 8f8165a7c5..bd72683e00 100644 --- a/src/security/vboot/common.c +++ b/src/security/vboot/common.c @@ -24,7 +24,7 @@ #include #include -struct vboot_working_data * const vboot_get_working_data(void) +struct vboot_working_data *vboot_get_working_data(void) { struct vboot_working_data *wd = NULL; diff --git a/src/security/vboot/misc.h b/src/security/vboot/misc.h index acb6dbbd02..725f5fd436 100644 --- a/src/security/vboot/misc.h +++ b/src/security/vboot/misc.h @@ -53,7 +53,7 @@ struct vboot_working_data { /* * Source: security/vboot/common.c */ -struct vboot_working_data * const vboot_get_working_data(void); +struct vboot_working_data *vboot_get_working_data(void); void vboot_init_work_context(struct vb2_context *ctx); void vboot_finalize_work_context(struct vb2_context *ctx); struct vb2_shared_data *vboot_get_shared_data(void); diff --git a/src/security/vboot/vboot_common.c b/src/security/vboot/vboot_common.c index ff8e6c896c..8456dcfc22 100644 --- a/src/security/vboot/vboot_common.c +++ b/src/security/vboot/vboot_common.c @@ -75,37 +75,6 @@ int vboot_get_handoff_info(void **addr, uint32_t *size) return 0; } -static int vboot_get_handoff_flag(uint32_t flag) -{ - struct vboot_handoff *vbho; - - /* - * If vboot_handoff cannot be found, return default value of flag as 0. - */ - if (vboot_get_handoff_info((void **)&vbho, NULL)) - return 0; - - return !!(vbho->out_flags & flag); -} - -int vboot_handoff_check_recovery_flag(void) -{ - return vboot_get_handoff_flag(VB_INIT_OUT_ENABLE_RECOVERY); -} - -int vboot_handoff_get_recovery_reason(void) -{ - struct vboot_handoff *vbho; - VbSharedDataHeader *sd; - - if (vboot_get_handoff_info((void **)&vbho, NULL)) - return 0; - - sd = (VbSharedDataHeader *)vbho->shared_data; - - return sd->recovery_reason; -} - /* ============================ VBOOT REBOOT ============================== */ void __weak vboot_platform_prepare_reboot(void) { diff --git a/src/security/vboot/vboot_common.h b/src/security/vboot/vboot_common.h index a785a8ba34..241dc90e95 100644 --- a/src/security/vboot/vboot_common.h +++ b/src/security/vboot/vboot_common.h @@ -53,17 +53,6 @@ struct vboot_handoff { */ int vboot_get_handoff_info(void **addr, uint32_t *size); -/* - * The following functions read vboot_handoff structure to obtain requested - * information. If vboot handoff is not available, 0 is returned by default. - * If vboot handoff is available: - * Returns 1 for flag if true - * Returns 0 for flag if false - * Returns value read for other fields - */ -int vboot_handoff_check_recovery_flag(void); -int vboot_handoff_get_recovery_reason(void); - /* ============================ VBOOT REBOOT ============================== */ /* * vboot_reboot handles the reboot requests made by vboot_reference library. It diff --git a/src/security/vboot/vboot_handoff.c b/src/security/vboot/vboot_handoff.c deleted file mode 100644 index 8a6b3d61e8..0000000000 --- a/src/security/vboot/vboot_handoff.c +++ /dev/null @@ -1,154 +0,0 @@ -/* - * This file is part of the coreboot project. - * - * Copyright (C) 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 - * 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. - */ - -#define NEED_VB20_INTERNALS /* Peeking into vb2_shared_data */ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/** - * Sets vboot_handoff based on the information in vb2_shared_data - */ -static void fill_vboot_handoff(struct vboot_handoff *vboot_handoff, - struct vb2_shared_data *vb2_sd) -{ - VbSharedDataHeader *vb_sd = - (VbSharedDataHeader *)vboot_handoff->shared_data; - uint32_t *oflags = &vboot_handoff->out_flags; - - vb_sd->flags |= VBSD_BOOT_FIRMWARE_VBOOT2; - - vboot_handoff->selected_firmware = vb2_sd->fw_slot; - - vb_sd->firmware_index = vb2_sd->fw_slot; - - vb_sd->magic = VB_SHARED_DATA_MAGIC; - vb_sd->struct_version = VB_SHARED_DATA_VERSION; - vb_sd->struct_size = sizeof(VbSharedDataHeader); - vb_sd->data_size = VB_SHARED_DATA_MIN_SIZE; - vb_sd->data_used = sizeof(VbSharedDataHeader); - vb_sd->fw_version_tpm = vb2_sd->fw_version_secdata; - - if (vb2_sd->recovery_reason) { - vb_sd->firmware_index = 0xFF; - if (vb2_sd->flags & VB2_SD_FLAG_MANUAL_RECOVERY) - vb_sd->flags |= VBSD_BOOT_REC_SWITCH_ON; - *oflags |= VB_INIT_OUT_ENABLE_RECOVERY; - *oflags |= VB_INIT_OUT_CLEAR_RAM; - } - if (vb2_sd->flags & VB2_SD_FLAG_DEV_MODE_ENABLED) { - *oflags |= VB_INIT_OUT_ENABLE_DEVELOPER; - *oflags |= VB_INIT_OUT_CLEAR_RAM; - vb_sd->flags |= VBSD_BOOT_DEV_SWITCH_ON; - vb_sd->flags |= VBSD_LF_DEV_SWITCH_ON; - } - - /* In vboot1, VBSD_FWB_TRIED is - * set only if B is booted as explicitly requested. Therefore, if B is - * booted because A was found bad, the flag should not be set. It's - * better not to touch it if we can only ambiguously control it. */ - /* if (vb2_sd->fw_slot) - vb_sd->flags |= VBSD_FWB_TRIED; */ - - /* copy kernel subkey if it's found */ - if (vb2_sd->workbuf_preamble_size) { - struct vb2_fw_preamble *fp; - uintptr_t dst, src; - printk(BIOS_INFO, "Copying FW preamble\n"); - fp = (struct vb2_fw_preamble *)((uintptr_t)vb2_sd + - vb2_sd->workbuf_preamble_offset); - src = (uintptr_t)&fp->kernel_subkey + - fp->kernel_subkey.key_offset; - dst = (uintptr_t)vb_sd + sizeof(VbSharedDataHeader); - assert(dst + fp->kernel_subkey.key_size <= - (uintptr_t)vboot_handoff + sizeof(*vboot_handoff)); - memcpy((void *)dst, (void *)src, - fp->kernel_subkey.key_size); - vb_sd->data_used += fp->kernel_subkey.key_size; - vb_sd->kernel_subkey.key_offset = - dst - (uintptr_t)&vb_sd->kernel_subkey; - vb_sd->kernel_subkey.key_size = fp->kernel_subkey.key_size; - vb_sd->kernel_subkey.algorithm = fp->kernel_subkey.algorithm; - vb_sd->kernel_subkey.key_version = - fp->kernel_subkey.key_version; - } - - vb_sd->recovery_reason = vb2_sd->recovery_reason; -} - -void vboot_fill_handoff(void) -{ - struct vboot_handoff *vh; - struct vb2_shared_data *sd; - - sd = vboot_get_shared_data(); - sd->workbuf_hash_offset = 0; - sd->workbuf_hash_size = 0; - - printk(BIOS_INFO, "creating vboot_handoff structure\n"); - vh = cbmem_add(CBMEM_ID_VBOOT_HANDOFF, sizeof(*vh)); - if (vh == NULL) - /* we don't need to failover gracefully here because this - * shouldn't happen with the image that has passed QA. */ - die("failed to allocate vboot_handoff structure\n"); - - memset(vh, 0, sizeof(*vh)); - - /* needed until we finish transtion to vboot2 for kernel verification */ - fill_vboot_handoff(vh, sd); - - - /* Log the recovery mode switches if required, before clearing them. */ - log_recovery_mode_switch(); - - /* - * The recovery mode switch is cleared (typically backed by EC) here - * to allow multiple queries to get_recovery_mode_switch() and have - * them return consistent results during the verified boot path as well - * as dram initialization. x86 systems ignore the saved dram settings - * in the recovery path in order to start from a clean slate. Therefore - * clear the state here since this function is called when memory - * is known to be up. - */ - clear_recovery_mode_switch(); -} - -/* - * For platforms that employ VBOOT_STARTS_IN_ROMSTAGE, the vboot - * verification doesn't happen until after cbmem is brought online. - * Therefore, the vboot results would not be initialized so don't - * automatically add results when cbmem comes online. - */ -#if !CONFIG(VBOOT_STARTS_IN_ROMSTAGE) -static void vb2_fill_handoff_cbmem(int unused) -{ - vboot_fill_handoff(); -} -ROMSTAGE_CBMEM_INIT_HOOK(vb2_fill_handoff_cbmem) -#endif diff --git a/src/security/vboot/vboot_loader.c b/src/security/vboot/vboot_loader.c index 1350307425..9e2cd00404 100644 --- a/src/security/vboot/vboot_loader.c +++ b/src/security/vboot/vboot_loader.c @@ -73,17 +73,6 @@ static void vboot_prepare(void) car_set_var(vboot_executed, 1); } - - /* - * Fill in vboot cbmem objects before moving to ramstage so all - * downstream users have access to vboot results. This path only - * applies to platforms employing VBOOT_STARTS_IN_ROMSTAGE because - * cbmem comes online prior to vboot verification taking place. For - * other platforms the vboot cbmem objects are initialized when - * cbmem comes online. - */ - if (ENV_ROMSTAGE && CONFIG(VBOOT_STARTS_IN_ROMSTAGE)) - vboot_fill_handoff(); } static int vboot_locate(struct cbfs_props *props) diff --git a/src/security/vboot/vboot_logic.c b/src/security/vboot/vboot_logic.c index 7b98be28e4..62e033a0de 100644 --- a/src/security/vboot/vboot_logic.c +++ b/src/security/vboot/vboot_logic.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -281,6 +282,26 @@ static uint32_t extend_pcrs(struct vb2_context *ctx) vboot_extend_pcr(ctx, 1, HWID_DIGEST_PCR); } +static void vboot_log_and_clear_recovery_mode_switch(int unused) +{ + /* Log the recovery mode switches if required, before clearing them. */ + log_recovery_mode_switch(); + + /* + * The recovery mode switch is cleared (typically backed by EC) here + * to allow multiple queries to get_recovery_mode_switch() and have + * them return consistent results during the verified boot path as well + * as dram initialization. x86 systems ignore the saved dram settings + * in the recovery path in order to start from a clean slate. Therefore + * clear the state here since this function is called when memory + * is known to be up. + */ + clear_recovery_mode_switch(); +} +#if !CONFIG(VBOOT_STARTS_IN_ROMSTAGE) +ROMSTAGE_CBMEM_INIT_HOOK(vboot_log_and_clear_recovery_mode_switch) +#endif + /** * Verify and select the firmware in the RW image * @@ -448,6 +469,11 @@ void verstage_main(void) vboot_set_selected_region(region_device_region(&fw_main)); verstage_main_exit: + /* If CBMEM is not up yet, let the ROMSTAGE_CBMEM_INIT_HOOK take care + of running this function. */ + if (ENV_ROMSTAGE && CONFIG(VBOOT_STARTS_IN_ROMSTAGE)) + vboot_log_and_clear_recovery_mode_switch(0); + vboot_finalize_work_context(&ctx); timestamp_add_now(TS_END_VBOOT); } diff --git a/src/soc/intel/Kconfig b/src/soc/intel/Kconfig index c447046de6..b8befc0fd2 100644 --- a/src/soc/intel/Kconfig +++ b/src/soc/intel/Kconfig @@ -46,5 +46,5 @@ config INTEL_TOP_SWAP_FIT_ENTRY_FMAP_REG hold a microcode) whose address as the first entry in the topswap FIT. This is useful in creating a asymmetric FIT in top swap bootblock than the one in non-topswap bootblock. This string will be passed - onto cbfstool (-q option). cbfstool will not parse the region for MCU + onto ifittool (-A -n option). ifittool will not parse the region for MCU entries, and only locate the region and insert its address into FIT. diff --git a/src/soc/intel/apollolake/Makefile.inc b/src/soc/intel/apollolake/Makefile.inc index 1fd16038a7..4fc16d5891 100644 --- a/src/soc/intel/apollolake/Makefile.inc +++ b/src/soc/intel/apollolake/Makefile.inc @@ -177,10 +177,10 @@ $(RT5682_RENDER_CAPTURE)-type := raw ifeq ($(CONFIG_SOC_INTEL_GLK),y) # Gemini Lake B0 (706a1) only atm. -cpu_microcode_bins += 3rdparty/blobs/cpu/intel/model_706ax/microcode.bin +cpu_microcode_bins += $(wildcard 3rdparty/intel-microcode/intel-ucode/06-7a-*) else # Apollo Lake 506c2, B0 (506c9) and E0 (506ca) only atm. -cpu_microcode_bins += 3rdparty/blobs/cpu/intel/model_506cx/microcode.bin +cpu_microcode_bins += $(wildcard 3rdparty/intel-microcode/intel-ucode/06-5c-*) endif endif # if CONFIG_SOC_INTEL_APOLLOLAKE diff --git a/src/soc/intel/apollolake/meminit_util_apl.c b/src/soc/intel/apollolake/meminit_util_apl.c index 16d14d945f..1dc5ceeb2c 100644 --- a/src/soc/intel/apollolake/meminit_util_apl.c +++ b/src/soc/intel/apollolake/meminit_util_apl.c @@ -93,6 +93,8 @@ void save_lpddr4_dimm_info_part_num(const char *dram_part_num) NULL, /* SPD not available */ memory_info_hob->DataWidth, 0, + 0, + src_dimm->MfgId, 0); index++; } diff --git a/src/soc/intel/apollolake/meminit_util_glk.c b/src/soc/intel/apollolake/meminit_util_glk.c index 59e133076a..0fbab0b177 100644 --- a/src/soc/intel/apollolake/meminit_util_glk.c +++ b/src/soc/intel/apollolake/meminit_util_glk.c @@ -99,7 +99,9 @@ void save_lpddr4_dimm_info_part_num(const char *dram_part_num) src_dimm->SpdSave + SPD_SAVE_OFFSET_SERIAL, memory_info_hob->DataWidth, 0, - 0); + 0, + src_dimm->MfgId, + src_dimm->SpdModuleType); index++; } } diff --git a/src/soc/intel/braswell/Makefile.inc b/src/soc/intel/braswell/Makefile.inc index 1017d80c65..cc111da485 100644 --- a/src/soc/intel/braswell/Makefile.inc +++ b/src/soc/intel/braswell/Makefile.inc @@ -35,6 +35,7 @@ ramstage-$(CONFIG_ELOG) += elog.c ramstage-y += emmc.c ramstage-y += gpio.c ramstage-y += gfx.c +ramstage-y += smbus.c ramstage-y += gpio_support.c ramstage-y += iosf.c diff --git a/src/soc/intel/braswell/include/soc/smbus.h b/src/soc/intel/braswell/include/soc/smbus.h new file mode 100644 index 0000000000..8bc62f7eec --- /dev/null +++ b/src/soc/intel/braswell/include/soc/smbus.h @@ -0,0 +1,26 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2013 Google Inc. + * Copyright (C) 2015 Intel Corp. + * Copyright (C) 2019 Eltan B.V. + * + * 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 _SOC_SMBUS_H_ +#define _SOC_SMBUS_H_ + +/* PCI Configuration Space SMBus */ +#define HOSTC 0x40 +#define HOSTC_I2C_EN (1 << 2) + +int smbus_i2c_block_write(u8 addr, u8 bytes, u8 *buf); +#endif /* _SOC_SMBUS_H_ */ diff --git a/src/soc/intel/braswell/smbus.c b/src/soc/intel/braswell/smbus.c index 7e1b0dfbb0..1dfd4c7ecd 100644 --- a/src/soc/intel/braswell/smbus.c +++ b/src/soc/intel/braswell/smbus.c @@ -3,6 +3,7 @@ * * Copyright (C) 2017 Intel Corporation. * Copyright (C) 2019 3mdeb + * Copyright (C) 2019 Eltan B.V. * * 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 @@ -16,6 +17,11 @@ #include #include +#include +#include +#include +#include +#include #include u8 smbus_read_byte(u32 smbus_dev, u8 addr, u8 offset) @@ -27,3 +33,29 @@ u8 smbus_write_byte(u32 smbus_dev, u8 addr, u8 offset, u8 value) { return do_smbus_write_byte(SMBUS_BASE_ADDRESS, addr, offset, value); } + +int smbus_i2c_block_write(u8 addr, u8 bytes, u8 *buf) +{ +#ifdef __SIMPLE_DEVICE__ + pci_devfn_t dev = PCI_DEV(0, SMBUS_DEV, SMBUS_FUNC); +#else + struct device *dev = pcidev_on_root(SMBUS_DEV, SMBUS_FUNC); +#endif + u32 smbase; + u32 smb_ctrl_reg; + int status; + + /* SMBus I/O BAR */ + smbase = pci_read_config32(dev, PCI_BASE_ADDRESS_4) & 0xFFFFFFFE; + + /* Enable I2C_EN bit in HOSTC register */ + smb_ctrl_reg = pci_read_config32(dev, HOSTC); + pci_write_config32(dev, HOSTC, smb_ctrl_reg | HOSTC_I2C_EN); + + status = do_i2c_block_write(smbase, addr, bytes, buf); + + /* Restore I2C_EN bit */ + pci_write_config32(dev, HOSTC, smb_ctrl_reg); + + return status; +} diff --git a/src/soc/intel/broadwell/Kconfig b/src/soc/intel/broadwell/Kconfig index d81ab8ac95..801800c5f4 100644 --- a/src/soc/intel/broadwell/Kconfig +++ b/src/soc/intel/broadwell/Kconfig @@ -106,10 +106,6 @@ config VGA_BIOS_ID string default "8086,0406" -config CACHE_MRC_SIZE_KB - int - default 512 - config DCACHE_RAM_BASE hex default 0xff7c0000 diff --git a/src/soc/intel/cannonlake/Kconfig b/src/soc/intel/cannonlake/Kconfig index dac3522d0a..37e42f30e2 100644 --- a/src/soc/intel/cannonlake/Kconfig +++ b/src/soc/intel/cannonlake/Kconfig @@ -1,49 +1,50 @@ -config SOC_INTEL_CANNONLAKE +config SOC_INTEL_CANNONLAKE_BASE bool - help - Intel Cannonlake support -config SOC_INTEL_COMMON_CANNONLAKE_BASE +config SOC_INTEL_CANNONLAKE_ALTERNATE_HEADERS bool - default n - select SOC_INTEL_CANNONLAKE + default y if SOC_INTEL_CANNONLAKE_BASE && !SOC_INTEL_CANNONLAKE help Single Kconfig option to select common base Cannonlake support. This Kconfig will help to select majority of CNL SoC features. Major difference that exist today between - SOC_INTEL_COMMON_CANNONLAKE_BASE and SOC_INTEL_CANNONLAKE Kconfig + SOC_INTEL_CANNONLAKE_ALTERNATE_HEADERS and SOC_INTEL_CANNONLAKE Kconfig are in FSP Header Files. Hence this Kconfig might help to select required SoC support FSP headers. Any future Intel SoC would like to make use of CNL support might just select this Kconfig. +config SOC_INTEL_CANNONLAKE + bool + select SOC_INTEL_CANNONLAKE_BASE + select MICROCODE_BLOB_NOT_IN_BLOB_REPO + help + Intel Cannonlake support + config SOC_INTEL_COFFEELAKE bool - default n - select SOC_INTEL_COMMON_CANNONLAKE_BASE + select SOC_INTEL_CANNONLAKE_BASE help Intel Coffeelake support config SOC_INTEL_WHISKEYLAKE bool - default n - select SOC_INTEL_COMMON_CANNONLAKE_BASE + select SOC_INTEL_CANNONLAKE_BASE help Intel Whiskeylake support config SOC_INTEL_COMETLAKE bool - default n - select SOC_INTEL_COMMON_CANNONLAKE_BASE + select SOC_INTEL_CANNONLAKE_BASE + select MICROCODE_BLOB_UNDISCLOSED help Intel Cometlake support config SOC_INTEL_CANNONLAKE_PCH_H bool - default n help Choose this option if you have a PCH-H chipset. -if SOC_INTEL_CANNONLAKE +if SOC_INTEL_CANNONLAKE_BASE config CPU_SPECIFIC_OPTIONS def_bool y @@ -297,7 +298,7 @@ config FSP_HEADER_PATH string "Location of FSP headers" default "3rdparty/fsp/CoffeeLakeFspBinPkg/Include/" if SOC_INTEL_COFFEELAKE || SOC_INTEL_WHISKEYLAKE default "src/vendorcode/intel/fsp/fsp2_0/cometlake/" if SOC_INTEL_COMETLAKE - default "src/vendorcode/intel/fsp/fsp2_0/cannonlake/" + default "src/vendorcode/intel/fsp/fsp2_0/cannonlake/" if SOC_INTEL_CANNONLAKE config FSP_FD_PATH string @@ -315,4 +316,12 @@ config SOC_INTEL_CANNONLAKE_DEBUG_CONSENT Setting non-zero value will allow to use DBC or DCI to debug SOC. PlatformDebugConsent in FspmUpd.h has the details. +config USE_LEGACY_8254_TIMER + bool "Use Legacy 8254 Timer" + default y if PAYLOAD_SEABIOS + default n + help + This sets the Enable8254ClockGating UPD, which according to the FSP Integration + guide needs to be disabled in order to boot SeaBIOS, but should otherwise be enabled. + endif diff --git a/src/soc/intel/cannonlake/Makefile.inc b/src/soc/intel/cannonlake/Makefile.inc index 13289448b6..8a4a8b71f2 100644 --- a/src/soc/intel/cannonlake/Makefile.inc +++ b/src/soc/intel/cannonlake/Makefile.inc @@ -1,4 +1,4 @@ -ifeq ($(CONFIG_SOC_INTEL_CANNONLAKE),y) +ifeq ($(CONFIG_SOC_INTEL_CANNONLAKE_BASE),y) subdirs-y += romstage subdirs-y += ../../../cpu/intel/microcode @@ -90,10 +90,24 @@ smm-y += gpio.c verstage-y += gpio.c endif -# Coffeelake U43e D0 -cpu_microcode_bins += 3rdparty/blobs/cpu/intel/model_806ex/microcode.bin -# Coffeelake H/S/E3 B0 U0 -cpu_microcode_bins += 3rdparty/blobs/cpu/intel/model_906ex/microcode.bin +ifeq ($(CONFIG_SOC_INTEL_CANNONLAKE),y) +# Not yet in intel-microcode repo +#cpu_microcode_bins += $(wildcard 3rdparty/intel-microcode/intel-ucode/06-66-*) +else ifeq ($(CONFIG_SOC_INTEL_COFFEELAKE),y) +ifeq ($(CONFIG_SOC_INTEL_CANNONLAKE_PCH_H),y) +cpu_microcode_bins += 3rdparty/intel-microcode/intel-ucode/06-9e-0a +cpu_microcode_bins += 3rdparty/intel-microcode/intel-ucode/06-9e-0b +cpu_microcode_bins += 3rdparty/intel-microcode/intel-ucode/06-9e-0c +cpu_microcode_bins += 3rdparty/intel-microcode/intel-ucode/06-9e-0d +else +cpu_microcode_bins += 3rdparty/intel-microcode/intel-ucode/06-8e-0a +endif +else ifeq ($(CONFIG_SOC_INTEL_WHISKEYLAKE),y) +cpu_microcode_bins += 3rdparty/intel-microcode/intel-ucode/06-8e-0b +cpu_microcode_bins += 3rdparty/intel-microcode/intel-ucode/06-8e-0c +else ifeq ($(CONFIG_SOC_INTEL_COMETLAKE),y) +# TODO +endif CPPFLAGS_common += -I$(src)/soc/intel/cannonlake CPPFLAGS_common += -I$(src)/soc/intel/cannonlake/include diff --git a/src/soc/intel/cannonlake/chip.h b/src/soc/intel/cannonlake/chip.h index 82f9bb260f..cc2a2fb87d 100644 --- a/src/soc/intel/cannonlake/chip.h +++ b/src/soc/intel/cannonlake/chip.h @@ -111,7 +111,7 @@ struct soc_intel_cannonlake_config { enum { SaGv_Disabled, SaGv_FixedLow, -#if !CONFIG(SOC_INTEL_COMMON_CANNONLAKE_BASE) +#if !CONFIG(SOC_INTEL_CANNONLAKE_ALTERNATE_HEADERS) SaGv_FixedMid, #endif SaGv_FixedHigh, @@ -246,8 +246,6 @@ struct soc_intel_cannonlake_config { /* Enable/Disable EIST. 1b:Enabled, 0b:Disabled */ uint8_t eist_enable; - /* Statically clock gate 8254 PIT. */ - uint8_t clock_gate_8254; /* Enable C6 DRAM */ uint8_t enable_c6dram; /* diff --git a/src/soc/intel/cannonlake/cpu.c b/src/soc/intel/cannonlake/cpu.c index d98e2f5486..7dae615350 100644 --- a/src/soc/intel/cannonlake/cpu.c +++ b/src/soc/intel/cannonlake/cpu.c @@ -500,7 +500,7 @@ int soc_skip_ucode_update(u32 current_patch_id, u32 new_patch_id) * have this check, where CNL CPU die is not based on KBL CPU * so skip this check for CNL. */ - if (!CONFIG(SOC_INTEL_COMMON_CANNONLAKE_BASE)) + if (!CONFIG(SOC_INTEL_CANNONLAKE_ALTERNATE_HEADERS)) return 0; /* diff --git a/src/soc/intel/cannonlake/fsp_params.c b/src/soc/intel/cannonlake/fsp_params.c index 0016011c7b..f6bc9d85ad 100644 --- a/src/soc/intel/cannonlake/fsp_params.c +++ b/src/soc/intel/cannonlake/fsp_params.c @@ -248,6 +248,10 @@ void platform_fsp_silicon_init_params_cb(FSPS_UPD *supd) /* disable Legacy PME */ memset(params->PcieRpPmSci, 0, sizeof(params->PcieRpPmSci)); + /* Legacy 8254 timer support */ + params->Enable8254ClockGating = !CONFIG_USE_LEGACY_8254_TIMER; + params->Enable8254ClockGatingOnS3 = 1; + /* USB */ for (i = 0; i < ARRAY_SIZE(config->usb2_ports); i++) { params->PortUsb20Enable[i] = config->usb2_ports[i].enable; diff --git a/src/soc/intel/cannonlake/lpc.c b/src/soc/intel/cannonlake/lpc.c index e276e256c4..ad841bf112 100644 --- a/src/soc/intel/cannonlake/lpc.c +++ b/src/soc/intel/cannonlake/lpc.c @@ -207,16 +207,6 @@ static void pch_misc_init(void) outb((1 << 7), 0x70); }; -static void clock_gate_8254(const struct device *dev) -{ - const config_t *config = dev->chip_info; - - if (!config->clock_gate_8254) - return; - - itss_clock_gate_8254(); -} - void lpc_soc_init(struct device *dev) { const config_t *config = dev->chip_info; @@ -239,7 +229,6 @@ void lpc_soc_init(struct device *dev) soc_pch_pirq_init(dev); setup_i8259(); i8259_configure_irq_trigger(9, 1); - clock_gate_8254(dev); soc_mirror_dmi_pcr_io_dec(); } diff --git a/src/soc/intel/cannonlake/romstage/fsp_params.c b/src/soc/intel/cannonlake/romstage/fsp_params.c index 77bad8f627..a1e3d76b4a 100644 --- a/src/soc/intel/cannonlake/romstage/fsp_params.c +++ b/src/soc/intel/cannonlake/romstage/fsp_params.c @@ -69,7 +69,7 @@ static void soc_memory_init_params(FSP_M_CONFIG *m_cfg, const config_t *config) /* Change VmxEnable UPD value according to ENABLE_VMX Kconfig */ m_cfg->VmxEnable = CONFIG(ENABLE_VMX); -#if CONFIG(SOC_INTEL_COMMON_CANNONLAKE_BASE) +#if CONFIG(SOC_INTEL_CANNONLAKE_ALTERNATE_HEADERS) m_cfg->SkipMpInit = !CONFIG_USE_INTEL_FSP_MP_INIT; #endif diff --git a/src/soc/intel/cannonlake/romstage/romstage.c b/src/soc/intel/cannonlake/romstage/romstage.c index fa530a29a6..9dadb2d14e 100644 --- a/src/soc/intel/cannonlake/romstage/romstage.c +++ b/src/soc/intel/cannonlake/romstage/romstage.c @@ -116,7 +116,9 @@ static void save_dimm_info(void) src_dimm->SpdSave + SPD_SAVE_OFFSET_SERIAL, memory_info_hob->DataWidth, memory_info_hob->VddVoltage[memProfNum], - memory_info_hob->EccSupport); + memory_info_hob->EccSupport, + src_dimm->MfgId, + src_dimm->SpdModuleType); index++; } } diff --git a/src/soc/intel/common/block/fast_spi/fast_spi.c b/src/soc/intel/common/block/fast_spi/fast_spi.c index 58e7db75a1..e40b84493e 100644 --- a/src/soc/intel/common/block/fast_spi/fast_spi.c +++ b/src/soc/intel/common/block/fast_spi/fast_spi.c @@ -249,7 +249,7 @@ void fast_spi_cache_bios_region(void) bios_size = ALIGN_UP(bios_size, alignment); base = 4ULL*GiB - bios_size; - if (ENV_RAMSTAGE) { + if (ENV_PAYLOAD_LOADER) { mtrr_use_temp_range(base, bios_size, type); } else { int mtrr = get_free_var_mtrr(); diff --git a/src/soc/intel/common/block/graphics/graphics.c b/src/soc/intel/common/block/graphics/graphics.c index 4cea21b075..ed9ae00bf8 100644 --- a/src/soc/intel/common/block/graphics/graphics.c +++ b/src/soc/intel/common/block/graphics/graphics.c @@ -33,15 +33,18 @@ __weak void graphics_soc_init(struct device *dev) pci_dev_init(dev); } -static uintptr_t graphics_get_bar(unsigned long index) +static int is_graphics_disabled(struct device *dev) { - struct device *dev = SA_DEV_IGD; - struct resource *gm_res; - assert(dev != NULL); - /* Check if Graphics PCI device is disabled */ if (!dev || !dev->enabled) - return 0; + return 1; + + return 0; +} + +static uintptr_t graphics_get_bar(struct device *dev, unsigned long index) +{ + struct resource *gm_res; gm_res = find_resource(dev, index); if (!gm_res) @@ -52,11 +55,16 @@ static uintptr_t graphics_get_bar(unsigned long index) uintptr_t graphics_get_memory_base(void) { + uintptr_t memory_base; + struct device *dev = SA_DEV_IGD; + + if (is_graphics_disabled(dev)) + return 0; /* * GFX PCI config space offset 0x18 know as Graphics * Memory Range Address (GMADR) */ - uintptr_t memory_base = graphics_get_bar(PCI_BASE_ADDRESS_2); + memory_base = graphics_get_bar(dev, PCI_BASE_ADDRESS_2); if (!memory_base) die_with_post_code(POST_HW_INIT_FAILURE, "GMADR is not programmed!"); @@ -66,14 +74,18 @@ uintptr_t graphics_get_memory_base(void) static uintptr_t graphics_get_gtt_base(void) { + static uintptr_t gtt_base; + struct device *dev = SA_DEV_IGD; + + if (is_graphics_disabled(dev)) + die("IGD is disabled!"); /* * GFX PCI config space offset 0x10 know as Graphics * Translation Table Memory Mapped Range Address * (GTTMMADR) */ - static uintptr_t gtt_base; if (!gtt_base) { - gtt_base = graphics_get_bar(PCI_BASE_ADDRESS_0); + gtt_base = graphics_get_bar(dev, PCI_BASE_ADDRESS_0); if (!gtt_base) die_with_post_code(POST_HW_INIT_FAILURE, "GTTMMADR is not programmed!"); diff --git a/src/soc/intel/common/block/i2c/i2c.c b/src/soc/intel/common/block/i2c/i2c.c index a99dfea688..d551c51abf 100644 --- a/src/soc/intel/common/block/i2c/i2c.c +++ b/src/soc/intel/common/block/i2c/i2c.c @@ -47,7 +47,7 @@ uintptr_t dw_i2c_get_soc_early_base(unsigned int bus) return EARLY_I2C_BASE(bus); } -#if !ENV_RAMSTAGE +#if !ENV_PAYLOAD_LOADER static int lpss_i2c_early_init_bus(unsigned int bus) { const struct dw_i2c_bus_config *config; diff --git a/src/soc/intel/common/block/lpc/lpc_lib.c b/src/soc/intel/common/block/lpc/lpc_lib.c index c67c43532c..b31c799a6a 100644 --- a/src/soc/intel/common/block/lpc/lpc_lib.c +++ b/src/soc/intel/common/block/lpc/lpc_lib.c @@ -289,7 +289,7 @@ void pch_enable_lpc(void) soc_get_gen_io_dec_range(dev, gen_io_dec); lpc_set_gen_decode_range(gen_io_dec); soc_setup_dmi_pcr_io_dec(gen_io_dec); - if (ENV_RAMSTAGE) + if (ENV_PAYLOAD_LOADER) pch_lpc_interrupt_init(); } diff --git a/src/soc/intel/common/block/pcr/pcr.c b/src/soc/intel/common/block/pcr/pcr.c index 4a35a03ff1..f3971c238f 100644 --- a/src/soc/intel/common/block/pcr/pcr.c +++ b/src/soc/intel/common/block/pcr/pcr.c @@ -394,10 +394,9 @@ int pcr_execute_sideband_msg(struct pcr_sbi_msg *msg, uint32_t *data, break; } return 0; - } else { - printk(BIOS_ERR, "SBI Failure: Transaction Status = %x\n", - *response); - return -1; } + printk(BIOS_ERR, "SBI Failure: Transaction Status = %x\n", + *response); + return -1; } #endif diff --git a/src/soc/intel/common/smbios.c b/src/soc/intel/common/smbios.c index e3ed3a2e69..d315e15f28 100644 --- a/src/soc/intel/common/smbios.c +++ b/src/soc/intel/common/smbios.c @@ -17,14 +17,38 @@ #include "smbios.h" #include #include +#include /* Fill the SMBIOS memory information from FSP MEM_INFO_DATA_HOB in CBMEM.*/ void dimm_info_fill(struct dimm_info *dimm, u32 dimm_capacity, u8 ddr_type, u32 frequency, u8 rank_per_dimm, u8 channel_id, u8 dimm_id, const char *module_part_num, size_t module_part_number_size, const u8 *module_serial_num, u16 data_width, u32 vdd_voltage, - bool ecc_support) + bool ecc_support, u16 mod_id, u8 mod_type) { + dimm->mod_id = mod_id; + /* Translate to DDR2 module type field that SMBIOS code expects. */ + switch (mod_type) { + case SPD_DIMM_TYPE_SO_DIMM: + dimm->mod_type = SPD_SODIMM; + break; + case SPD_DIMM_TYPE_72B_SO_CDIMM: + dimm->mod_type = SPD_72B_SO_CDIMM; + break; + case SPD_DIMM_TYPE_72B_SO_RDIMM: + dimm->mod_type = SPD_72B_SO_RDIMM; + break; + case SPD_DIMM_TYPE_UDIMM: + dimm->mod_type = SPD_UDIMM; + break; + case SPD_DIMM_TYPE_RDIMM: + dimm->mod_type = SPD_RDIMM; + break; + case SPD_DIMM_TYPE_UNDEFINED: + default: + dimm->mod_type = SPD_UNDEFINED; + break; + } dimm->dimm_size = dimm_capacity; dimm->ddr_type = ddr_type; dimm->ddr_frequency = frequency; diff --git a/src/soc/intel/common/smbios.h b/src/soc/intel/common/smbios.h index 12b8da0d85..97437eef45 100644 --- a/src/soc/intel/common/smbios.h +++ b/src/soc/intel/common/smbios.h @@ -27,6 +27,6 @@ void dimm_info_fill(struct dimm_info *dimm, u32 dimm_capacity, u8 ddr_type, u32 frequency, u8 rank_per_dimm, u8 channel_id, u8 dimm_id, const char *module_part_num, size_t module_part_number_size, const u8 *module_serial_num, u16 data_width, u32 vdd_voltage, - bool ecc_support); + bool ecc_support, u16 mod_id, u8 mod_type); #endif /* _COMMON_SMBIOS_H_ */ diff --git a/src/soc/intel/denverton_ns/include/soc/gpio_defs.h b/src/soc/intel/denverton_ns/include/soc/gpio_defs.h index 43e0647bd0..ae61e6d7c4 100644 --- a/src/soc/intel/denverton_ns/include/soc/gpio_defs.h +++ b/src/soc/intel/denverton_ns/include/soc/gpio_defs.h @@ -182,7 +182,7 @@ #define V_PCH_GPIO_RX_APIC_ROUTE_EN 0x01 // GPIO Input Route SCI -#define B_PCH_GPIO_RX_SCI_ROUTE (1 << 10) +#define B_PCH_GPIO_RX_SCI_ROUTE (1 << 19) #define N_PCH_GPIO_RX_SCI_ROUTE 19 #define V_PCH_GPIO_RX_SCI_ROUTE_DIS 0x00 #define V_PCH_GPIO_RX_SCI_ROUTE_EN 0x01 diff --git a/src/soc/intel/denverton_ns/include/soc/msr.h b/src/soc/intel/denverton_ns/include/soc/msr.h index 1b27eefcaa..0d469c4871 100644 --- a/src/soc/intel/denverton_ns/include/soc/msr.h +++ b/src/soc/intel/denverton_ns/include/soc/msr.h @@ -96,10 +96,6 @@ #define SMRR_SUPPORTED (1 << 11) #define PRMRR_SUPPORTED (1 << 12) -/* IA32_MISC_ENABLE bits */ -#define FAST_STRINGS_ENABLE_BIT (1 << 0) -#define SPEED_STEP_ENABLE_BIT (1 << 16) - /* Read BCLK from MSR */ unsigned int bus_freq_khz(void); diff --git a/src/soc/intel/fsp_broadwell_de/Makefile.inc b/src/soc/intel/fsp_broadwell_de/Makefile.inc index 0a23170d0c..e8a31890ba 100644 --- a/src/soc/intel/fsp_broadwell_de/Makefile.inc +++ b/src/soc/intel/fsp_broadwell_de/Makefile.inc @@ -39,6 +39,6 @@ CPPFLAGS_common += -I$(src)/soc/intel/fsp_broadwell_de/include CPPFLAGS_common += -I$(src)/soc/intel/fsp_broadwell_de/fsp CPPFLAGS_common += -I$(src)/soc/intel/fsp_broadwell_de/ -cpu_microcode_bins += 3rdparty/blobs/cpu/intel/model_5066x/microcode.bin +cpu_microcode_bins += $(wildcard 3rdparty/intel-microcode/intel-ucode/06-56-*) endif # ifeq ($(CONFIG_SOC_INTEL_FSP_BROADWELL_DE),y) diff --git a/src/soc/intel/icelake/romstage/romstage.c b/src/soc/intel/icelake/romstage/romstage.c index a09641cf44..b0eeb2e959 100644 --- a/src/soc/intel/icelake/romstage/romstage.c +++ b/src/soc/intel/icelake/romstage/romstage.c @@ -101,7 +101,9 @@ static void save_dimm_info(void) src_dimm->SpdSave + SPD_SAVE_OFFSET_SERIAL, memory_info_hob->DataWidth, memory_info_hob->VddVoltage[memProfNum], - memory_info_hob->EccSupport); + memory_info_hob->EccSupport, + src_dimm->MfgId, + src_dimm->SpdModuleType); index++; } } diff --git a/src/soc/intel/skylake/Kconfig b/src/soc/intel/skylake/Kconfig index 626b5f80f0..fb455d2392 100644 --- a/src/soc/intel/skylake/Kconfig +++ b/src/soc/intel/skylake/Kconfig @@ -1,16 +1,20 @@ +config SOC_INTEL_COMMON_SKYLAKE_BASE + bool + config SOC_INTEL_SKYLAKE bool + select SOC_INTEL_COMMON_SKYLAKE_BASE help Intel Skylake support config SOC_INTEL_KABYLAKE bool - default n - select SOC_INTEL_SKYLAKE + select SOC_INTEL_COMMON_SKYLAKE_BASE + select MAINBOARD_USES_FSP2_0 help Intel Kabylake support -if SOC_INTEL_SKYLAKE +if SOC_INTEL_COMMON_SKYLAKE_BASE config CPU_SPECIFIC_OPTIONS def_bool y diff --git a/src/soc/intel/skylake/Makefile.inc b/src/soc/intel/skylake/Makefile.inc index e9f555f13c..25dce05226 100644 --- a/src/soc/intel/skylake/Makefile.inc +++ b/src/soc/intel/skylake/Makefile.inc @@ -1,4 +1,4 @@ -ifeq ($(CONFIG_SOC_INTEL_SKYLAKE),y) +ifeq ($(CONFIG_SOC_INTEL_COMMON_SKYLAKE_BASE),y) subdirs-y += nhlt subdirs-y += romstage @@ -81,15 +81,17 @@ postcar-y += spi.c postcar-y += i2c.c postcar-y += uart.c - -# Skylake D0 -cpu_microcode_bins += 3rdparty/blobs/cpu/intel/model_406ex/microcode.bin +ifeq ($(CONFIG_SKYLAKE_SOC_PCH_H),y) # Skylake H Q0 -cpu_microcode_bins += 3rdparty/blobs/cpu/intel/model_506ex/microcode.bin -# Kabylake H0, Y0 -cpu_microcode_bins += 3rdparty/blobs/cpu/intel/model_806ex/microcode.bin +cpu_microcode_bins += 3rdparty/intel-microcode/intel-ucode/06-5e-03 # Kabylake HB0 -cpu_microcode_bins += 3rdparty/blobs/cpu/intel/model_906ex/microcode.bin +cpu_microcode_bins += 3rdparty/intel-microcode/intel-ucode/06-9e-09 +else +# Skylake D0 +cpu_microcode_bins += 3rdparty/intel-microcode/intel-ucode/06-4e-03 +# Kabylake H0, Y0 +cpu_microcode_bins += 3rdparty/intel-microcode/intel-ucode/06-8e-09 +endif # Missing for Skylake C0 (0x406e2), Kabylake G0 (0x406e8), Kabylake HA0 (0x506e8) # since those are probably pre-release samples. @@ -106,6 +108,4 @@ endif # Currently used for microcode path. CPPFLAGS_common += -I3rdparty/blobs/mainboard/$(MAINBOARDDIR) -ROMCCFLAGS := -mcpu=p4 -fno-simplify-phi -O2 - endif diff --git a/src/soc/intel/skylake/romstage/romstage_fsp20.c b/src/soc/intel/skylake/romstage/romstage_fsp20.c index 2819c6f260..83fc27eaa5 100644 --- a/src/soc/intel/skylake/romstage/romstage_fsp20.c +++ b/src/soc/intel/skylake/romstage/romstage_fsp20.c @@ -129,7 +129,9 @@ static void save_dimm_info(void) src_dimm->SpdSave + SPD_SAVE_OFFSET_SERIAL, memory_info_hob->DataWidth, memory_info_hob->VddVoltage[memProfNum], - memory_info_hob->EccSupport); + memory_info_hob->EccSupport, + src_dimm->MfgId, + src_dimm->SpdModuleType); index++; } } @@ -156,7 +158,7 @@ asmlinkage void car_stage_entry(void) pmc_set_disb(); if (!s3wake) save_dimm_info(); - if (postcar_frame_init(&pcf, 1*KiB)) + if (postcar_frame_init(&pcf, 8*KiB)) die("Unable to initialize postcar frame.\n"); /* diff --git a/src/soc/mediatek/common/include/soc/spi_common.h b/src/soc/mediatek/common/include/soc/spi_common.h index 162db59f94..81a9098180 100644 --- a/src/soc/mediatek/common/include/soc/spi_common.h +++ b/src/soc/mediatek/common/include/soc/spi_common.h @@ -84,8 +84,9 @@ extern struct mtk_spi_bus spi_bus[]; void mtk_spi_set_gpio_pinmux(unsigned int bus, enum spi_pad_mask pad_select); -void mtk_spi_set_timing(struct mtk_spi_regs *regs, u32 sck_ticks, u32 cs_ticks); +void mtk_spi_set_timing(struct mtk_spi_regs *regs, u32 sck_ticks, u32 cs_ticks, + unsigned int tick_dly); void mtk_spi_init(unsigned int bus, enum spi_pad_mask pad_select, - unsigned int speed_hz); + unsigned int speed_hz, unsigned int tick_dly); #endif diff --git a/src/soc/mediatek/common/spi.c b/src/soc/mediatek/common/spi.c index 71ed95a228..1af6f105c3 100644 --- a/src/soc/mediatek/common/spi.c +++ b/src/soc/mediatek/common/spi.c @@ -53,7 +53,7 @@ static void spi_sw_reset(struct mtk_spi_regs *regs) } void mtk_spi_init(unsigned int bus, enum spi_pad_mask pad_select, - unsigned int speed_hz) + unsigned int speed_hz, unsigned int tick_dly) { u32 div, sck_ticks, cs_ticks; @@ -73,7 +73,7 @@ void mtk_spi_init(unsigned int bus, enum spi_pad_mask pad_select, printk(BIOS_DEBUG, "SPI%u(PAD%u) initialized at %u Hz\n", bus, pad_select, SPI_HZ / (sck_ticks * 2)); - mtk_spi_set_timing(regs, sck_ticks, cs_ticks); + mtk_spi_set_timing(regs, sck_ticks, cs_ticks, tick_dly); clrsetbits_le32(®s->spi_cmd_reg, (SPI_CMD_CPHA_EN | SPI_CMD_CPOL_EN | diff --git a/src/soc/mediatek/mt8173/include/soc/spi.h b/src/soc/mediatek/mt8173/include/soc/spi.h index aaef3aa25c..58bf517f9d 100644 --- a/src/soc/mediatek/mt8173/include/soc/spi.h +++ b/src/soc/mediatek/mt8173/include/soc/spi.h @@ -43,4 +43,9 @@ enum { SPI_CFG0_CS_SETUP_SHIFT = 24, }; +enum { + SPI_CFG1_TICK_DLY_SHIFT = 30, + SPI_CFG1_TICK_DLY_MASK = 0x3 << SPI_CFG1_TICK_DLY_SHIFT, +}; + #endif diff --git a/src/soc/mediatek/mt8173/spi.c b/src/soc/mediatek/mt8173/spi.c index 0cc8377ff4..d0094418b8 100644 --- a/src/soc/mediatek/mt8173/spi.c +++ b/src/soc/mediatek/mt8173/spi.c @@ -38,14 +38,17 @@ void mtk_spi_set_gpio_pinmux(unsigned int bus, gpio_set_mode(GPIO(MSDC2_CMD), PAD_MSDC2_CMD_FUNC_SPI_CS_1); } -void mtk_spi_set_timing(struct mtk_spi_regs *regs, u32 sck_ticks, u32 cs_ticks) +void mtk_spi_set_timing(struct mtk_spi_regs *regs, u32 sck_ticks, u32 cs_ticks, + unsigned int tick_dly) { write32(®s->spi_cfg0_reg, ((sck_ticks - 1) << SPI_CFG0_SCK_HIGH_SHIFT) | ((sck_ticks - 1) << SPI_CFG0_SCK_LOW_SHIFT) | ((cs_ticks - 1) << SPI_CFG0_CS_HOLD_SHIFT) | ((cs_ticks - 1) << SPI_CFG0_CS_SETUP_SHIFT)); - clrsetbits_le32(®s->spi_cfg1_reg, SPI_CFG1_CS_IDLE_MASK, + clrsetbits_le32(®s->spi_cfg1_reg, SPI_CFG1_CS_IDLE_MASK | + SPI_CFG1_TICK_DLY_MASK, + (tick_dly << SPI_CFG1_TICK_DLY_SHIFT) | ((cs_ticks - 1) << SPI_CFG1_CS_IDLE_SHIFT)); } diff --git a/src/soc/mediatek/mt8183/Makefile.inc b/src/soc/mediatek/mt8183/Makefile.inc index 5392a9e635..d35a07ed59 100644 --- a/src/soc/mediatek/mt8183/Makefile.inc +++ b/src/soc/mediatek/mt8183/Makefile.inc @@ -45,6 +45,8 @@ ramstage-y += ../common/cbmem.c emi.c ramstage-y += ../common/gpio.c gpio.c ramstage-y += ../common/mmu_operations.c mmu_operations.c ramstage-y += ../common/mtcmos.c mtcmos.c +ramstage-y += ../common/pmic_wrap.c +ramstage-y += ../common/rtc.c rtc.c ramstage-y += soc.c ramstage-$(CONFIG_SPI_FLASH) += ../common/spi.c spi.c ramstage-y += ../common/timer.c diff --git a/src/soc/mediatek/mt8183/auxadc.c b/src/soc/mediatek/mt8183/auxadc.c index a167d2b58e..5460486709 100644 --- a/src/soc/mediatek/mt8183/auxadc.c +++ b/src/soc/mediatek/mt8183/auxadc.c @@ -18,11 +18,37 @@ #include #include #include +#include #include #include static struct mtk_auxadc_regs *const mtk_auxadc = (void *)AUXADC_BASE; +#define ADC_GE_A_SHIFT 10 +#define ADC_GE_A_MASK (0x3ff << ADC_GE_A_SHIFT) +#define ADC_OE_A_SHIFT 0 +#define ADC_OE_A_MASK (0x3ff << ADC_OE_A_SHIFT) +#define ADC_CALI_EN_A_SHIFT 20 +#define ADC_CALI_EN_A_MASK (0x1 << ADC_CALI_EN_A_SHIFT) + +static int cali_oe; +static int cali_ge; +static int calibrated = 0; +static void mt_auxadc_update_cali(void) +{ + uint32_t cali_reg; + int cali_ge_a; + int cali_oe_a; + + cali_reg = read32(&mtk_efuse->adc_cali_reg); + + if ((cali_reg & ADC_CALI_EN_A_MASK) != 0) { + cali_oe_a = (cali_reg & ADC_OE_A_MASK) >> ADC_OE_A_SHIFT; + cali_ge_a = (cali_reg & ADC_GE_A_MASK) >> ADC_GE_A_SHIFT; + cali_ge = cali_ge_a - 512; + cali_oe = cali_oe_a - 512; + } +} static uint32_t auxadc_get_rawdata(int channel) { setbits_le32(&mt8183_infracfg->module_sw_cg_1_clr, 1 << 10); @@ -44,8 +70,17 @@ static uint32_t auxadc_get_rawdata(int channel) int auxadc_get_voltage(unsigned int channel) { + uint32_t raw_value; assert(channel < 16); + if (!calibrated) { + mt_auxadc_update_cali(); + calibrated = 1; + } + /* 1.5V in 4096 steps */ - return (int)((int64_t)auxadc_get_rawdata(channel) * 1500000 / 4096); + raw_value = auxadc_get_rawdata(channel); + + raw_value = raw_value - cali_oe; + return (int)((int64_t)raw_value * 1500000 / (4096 + cali_ge)); } diff --git a/src/soc/mediatek/mt8183/dramc_init_setting.c b/src/soc/mediatek/mt8183/dramc_init_setting.c index d275127978..09bec0108e 100644 --- a/src/soc/mediatek/mt8183/dramc_init_setting.c +++ b/src/soc/mediatek/mt8183/dramc_init_setting.c @@ -14,6 +14,7 @@ */ #include +#include #include #include #include @@ -24,7 +25,7 @@ struct reg_init_value { u32 value; }; -struct reg_init_value dramc_init_sequence[] = { +static struct reg_init_value dramc_init_sequence[] = { {&mt8183_infracfg->dramc_wbr, 0x00000000}, {&ch[0].ao.refctrl0, 0x20712000}, {&ch[1].ao.refctrl0, 0x20712000}, @@ -620,7 +621,52 @@ struct reg_init_value dramc_init_sequence[] = { {&ch[1].phy.shu[0].rk[1].b[1].dq[1], 0x22000000}, {&ch[1].phy.shu[0].b[0].dll[1], 0x00022501}, - /* dramc mode register init */ + /* update the ac timing */ + {&ch[0].ao.shu[0].actim[0], 0x06020c07}, + {&ch[0].ao.shu[0].actim[1], 0x10080501}, + {&ch[0].ao.shu[0].actim[2], 0x07070201}, + {&ch[0].ao.shu[0].actim[3], 0x6164002c}, + {&ch[0].ao.shu[0].actim[4], 0x22650077}, + {&ch[0].ao.shu[0].actim[5], 0x0a000c0b}, + {&ch[0].ao.shu[0].actim_xrt, 0x05030609}, + {&ch[0].ao.shu[0].ac_time_05t, 0x000106e1}, + {&ch[0].ao.catraining1, 0x0b000000}, + {&ch[0].ao.shu[0].rk[0].dqsctl, 0x00000004}, + {&ch[0].ao.shu[0].rk[1].dqsctl, 0x00000004}, + {&ch[0].ao.shu[0].odtctrl, 0xc001004f}, + {&ch[0].ao.shu[0].conf[1], 0x34000d0f}, + {&ch[0].ao.shu[0].conf[2], 0x9007640f}, + {&ch[0].ao.shu[0].scintv, 0x4e39eb36}, + {&ch[0].ao.shu[0].ckectrl, 0x33210000}, + {&ch[0].ao.ckectrl, 0x88d02440}, + {&ch[0].ao.shu[0].rankctl, 0x64300003}, + {&ch[0].ao.shu[0].rankctl, 0x64301203}, + {&ch[1].ao.shu[0].actim[0], 0x06020c07}, + {&ch[1].ao.shu[0].actim[1], 0x10080501}, + {&ch[1].ao.shu[0].actim[2], 0x07070201}, + {&ch[1].ao.shu[0].actim[3], 0x6164002c}, + {&ch[1].ao.shu[0].actim[4], 0x22650077}, + {&ch[1].ao.shu[0].actim[5], 0x0a000c0b}, + {&ch[1].ao.shu[0].actim_xrt, 0x05030609}, + {&ch[1].ao.shu[0].ac_time_05t, 0x000106e1}, + {&ch[1].ao.catraining1, 0x0b000000}, + {&ch[1].ao.shu[0].rk[0].dqsctl, 0x00000004}, + {&ch[1].ao.shu[0].rk[1].dqsctl, 0x00000004}, + {&ch[1].ao.shu[0].odtctrl, 0xc001004f}, + {&ch[1].ao.shu[0].conf[1], 0x34000d0f}, + {&ch[1].ao.shu[0].conf[2], 0x9007640f}, + {&ch[1].ao.shu[0].scintv, 0x4e39eb36}, + {&ch[1].ao.shu[0].ckectrl, 0x33210000}, + {&ch[1].ao.ckectrl, 0x88d02440}, + {&ch[1].ao.shu[0].rankctl, 0x64300003}, + {&ch[1].ao.shu[0].rankctl, 0x64301203}, + {&ch[0].ao.arbctl, 0x00000c80}, + {&ch[0].ao.rstmask, 0x00000000}, + {&ch[0].ao.arbctl, 0x00000c80}, +}; + +static struct reg_init_value dramc_mode_reg_init_sequence[] = { + /* dramc power on sequence */ {&ch[0].phy.misc_ctrl1, 0x8100908c}, {&ch[1].phy.misc_ctrl1, 0x8100908c}, {&ch[0].ao.ckectrl, 0x88d02480}, @@ -632,6 +678,8 @@ struct reg_init_value dramc_init_sequence[] = { {&ch[0].ao.ckectrl, 0x88d02440}, {&ch[1].ao.ckectrl, 0x88d02440}, {&ch[0].ao.mrs, 0x00000000}, + + /* CH0 dramc ZQ Calibration */ {&ch[0].ao.dramc_pd_ctrl, 0xc4000107}, {&ch[0].ao.ckectrl, 0x88d02440}, {&ch[0].ao.mrs, 0x00000000}, @@ -641,70 +689,104 @@ struct reg_init_value dramc_init_sequence[] = { {&ch[0].ao.mrs, 0x00000000}, {&ch[0].ao.dramc_pd_ctrl, 0xc4000107}, {&ch[0].ao.ckectrl, 0x88d02440}, + + /* MR13 */ {&ch[0].ao.mrs, 0x00000d18}, {&ch[0].ao.spcmd, 0x00000001}, {&ch[0].ao.spcmd, 0x00000000}, {&ch[0].ao.ckectrl, 0x88d02440}, + + /* MR12 */ {&ch[0].ao.mrs, 0x00000c5d}, {&ch[0].ao.spcmd, 0x00000001}, {&ch[0].ao.spcmd, 0x00000000}, {&ch[0].ao.ckectrl, 0x88d02440}, + + /* MR1 */ {&ch[0].ao.mrs, 0x00000156}, {&ch[0].ao.spcmd, 0x00000001}, {&ch[0].ao.spcmd, 0x00000000}, {&ch[0].ao.ckectrl, 0x88d02440}, + + /* MR2 */ {&ch[0].ao.mrs, 0x0000020b}, {&ch[0].ao.spcmd, 0x00000001}, {&ch[0].ao.spcmd, 0x00000000}, {&ch[0].ao.ckectrl, 0x88d02440}, + + /* MR11 */ {&ch[0].ao.mrs, 0x00000b00}, {&ch[0].ao.spcmd, 0x00000001}, {&ch[0].ao.spcmd, 0x00000000}, {&ch[0].ao.ckectrl, 0x88d02440}, + + /* MR22 */ {&ch[0].ao.mrs, 0x00001638}, {&ch[0].ao.spcmd, 0x00000001}, {&ch[0].ao.spcmd, 0x00000000}, {&ch[0].ao.ckectrl, 0x88d02440}, + + /* MR14 */ {&ch[0].ao.mrs, 0x00000e5d}, {&ch[0].ao.spcmd, 0x00000001}, {&ch[0].ao.spcmd, 0x00000000}, {&ch[0].ao.ckectrl, 0x88d02440}, + + /* MR3 */ {&ch[0].ao.mrs, 0x00000330}, {&ch[0].ao.spcmd, 0x00000001}, {&ch[0].ao.spcmd, 0x00000000}, {&ch[0].ao.ckectrl, 0x88d02440}, + + /* MR13 */ {&ch[0].ao.mrs, 0x00000d58}, {&ch[0].ao.spcmd, 0x00000001}, {&ch[0].ao.spcmd, 0x00000000}, {&ch[0].ao.ckectrl, 0x88d02440}, + + /* MR12 */ {&ch[0].ao.mrs, 0x00000c5d}, {&ch[0].ao.spcmd, 0x00000001}, {&ch[0].ao.spcmd, 0x00000000}, {&ch[0].ao.ckectrl, 0x88d02440}, + + /* MR1 */ {&ch[0].ao.mrs, 0x00000156}, {&ch[0].ao.spcmd, 0x00000001}, {&ch[0].ao.spcmd, 0x00000000}, {&ch[0].ao.ckectrl, 0x88d02440}, + + /* MR2 */ {&ch[0].ao.mrs, 0x0000022d}, {&ch[0].ao.spcmd, 0x00000001}, {&ch[0].ao.spcmd, 0x00000000}, {&ch[0].ao.ckectrl, 0x88d02440}, + + /* MR11 */ {&ch[0].ao.mrs, 0x00000b23}, {&ch[0].ao.spcmd, 0x00000001}, {&ch[0].ao.spcmd, 0x00000000}, {&ch[0].ao.ckectrl, 0x88d02440}, + + /* MR22 */ {&ch[0].ao.mrs, 0x00001634}, {&ch[0].ao.spcmd, 0x00000001}, {&ch[0].ao.spcmd, 0x00000000}, {&ch[0].ao.ckectrl, 0x88d02440}, + + /* MR14 */ {&ch[0].ao.mrs, 0x00000e10}, {&ch[0].ao.spcmd, 0x00000001}, {&ch[0].ao.spcmd, 0x00000000}, {&ch[0].ao.ckectrl, 0x88d02440}, + + /* MR3 */ {&ch[0].ao.mrs, 0x00000330}, {&ch[0].ao.spcmd, 0x00000001}, {&ch[0].ao.spcmd, 0x00000000}, {&ch[0].ao.ckectrl, 0x88d02440}, + + /* dramc ZQ Calibration */ {&ch[0].ao.mrs, 0x01000330}, {&ch[0].ao.dramc_pd_ctrl, 0xc4000107}, {&ch[0].ao.ckectrl, 0x88d02440}, @@ -715,76 +797,112 @@ struct reg_init_value dramc_init_sequence[] = { {&ch[0].ao.mrs, 0x01000330}, {&ch[0].ao.dramc_pd_ctrl, 0xc4000107}, {&ch[0].ao.ckectrl, 0x88d02440}, + + /* MR13 */ {&ch[0].ao.mrs, 0x01000d18}, {&ch[0].ao.spcmd, 0x00000001}, {&ch[0].ao.spcmd, 0x00000000}, {&ch[0].ao.ckectrl, 0x88d02440}, + + /* MR12 */ {&ch[0].ao.mrs, 0x01000c5d}, {&ch[0].ao.spcmd, 0x00000001}, {&ch[0].ao.spcmd, 0x00000000}, {&ch[0].ao.ckectrl, 0x88d02440}, + + /* MR1 */ {&ch[0].ao.mrs, 0x01000156}, {&ch[0].ao.spcmd, 0x00000001}, {&ch[0].ao.spcmd, 0x00000000}, {&ch[0].ao.ckectrl, 0x88d02440}, + + /* MR2 */ {&ch[0].ao.mrs, 0x0100020b}, {&ch[0].ao.spcmd, 0x00000001}, {&ch[0].ao.spcmd, 0x00000000}, {&ch[0].ao.ckectrl, 0x88d02440}, + + /* MR11 */ {&ch[0].ao.mrs, 0x01000b00}, {&ch[0].ao.spcmd, 0x00000001}, {&ch[0].ao.spcmd, 0x00000000}, {&ch[0].ao.ckectrl, 0x88d02440}, + + /* MR22 */ {&ch[0].ao.mrs, 0x01001638}, {&ch[0].ao.spcmd, 0x00000001}, {&ch[0].ao.spcmd, 0x00000000}, {&ch[0].ao.ckectrl, 0x88d02440}, + + /* MR14 */ {&ch[0].ao.mrs, 0x01000e5d}, {&ch[0].ao.spcmd, 0x00000001}, {&ch[0].ao.spcmd, 0x00000000}, {&ch[0].ao.ckectrl, 0x88d02440}, + + /* MR3 */ {&ch[0].ao.mrs, 0x01000330}, {&ch[0].ao.spcmd, 0x00000001}, {&ch[0].ao.spcmd, 0x00000000}, {&ch[0].ao.ckectrl, 0x88d02440}, + + /* MR13 */ {&ch[0].ao.mrs, 0x01000d58}, {&ch[0].ao.spcmd, 0x00000001}, {&ch[0].ao.spcmd, 0x00000000}, {&ch[0].ao.ckectrl, 0x88d02440}, + + /* MR12 */ {&ch[0].ao.mrs, 0x01000c5d}, {&ch[0].ao.spcmd, 0x00000001}, {&ch[0].ao.spcmd, 0x00000000}, {&ch[0].ao.ckectrl, 0x88d02440}, + + /* MR1 */ {&ch[0].ao.mrs, 0x01000156}, {&ch[0].ao.spcmd, 0x00000001}, {&ch[0].ao.spcmd, 0x00000000}, {&ch[0].ao.ckectrl, 0x88d02440}, + + /* MR2 */ {&ch[0].ao.mrs, 0x0100022d}, {&ch[0].ao.spcmd, 0x00000001}, {&ch[0].ao.spcmd, 0x00000000}, {&ch[0].ao.ckectrl, 0x88d02440}, + + /* MR11 */ {&ch[0].ao.mrs, 0x01000b23}, {&ch[0].ao.spcmd, 0x00000001}, {&ch[0].ao.spcmd, 0x00000000}, {&ch[0].ao.ckectrl, 0x88d02440}, + + /* MR22 */ {&ch[0].ao.mrs, 0x01001634}, {&ch[0].ao.spcmd, 0x00000001}, {&ch[0].ao.spcmd, 0x00000000}, {&ch[0].ao.ckectrl, 0x88d02440}, + + /* MR14 */ {&ch[0].ao.mrs, 0x01000e10}, {&ch[0].ao.spcmd, 0x00000001}, {&ch[0].ao.spcmd, 0x00000000}, {&ch[0].ao.ckectrl, 0x88d02440}, + + /* MR3 */ {&ch[0].ao.mrs, 0x01000330}, {&ch[0].ao.spcmd, 0x00000001}, {&ch[0].ao.spcmd, 0x00000000}, {&ch[0].ao.ckectrl, 0x88d02440}, + + /* MR13 */ {&ch[0].ao.mrs, 0x00000330}, {&ch[0].ao.ckectrl, 0x88d02440}, {&ch[0].ao.mrs, 0x00000dd8}, {&ch[0].ao.spcmd, 0x00000001}, {&ch[0].ao.spcmd, 0x00000000}, {&ch[0].ao.ckectrl, 0x88d02440}, + + /* MR13 */ {&ch[0].ao.mrs, 0x01000dd8}, {&ch[0].ao.ckectrl, 0x88d02440}, {&ch[0].ao.mrs, 0x01000dd8}, @@ -792,9 +910,12 @@ struct reg_init_value dramc_init_sequence[] = { {&ch[0].ao.spcmd, 0x00000000}, {&ch[0].ao.ckectrl, 0x88d02440}, {&ch[0].ao.mrs, 0x01000dd8}, + {&ch[0].ao.shu[0].hwset_mr13, 0x00d8000d}, {&ch[0].ao.shu[0].hwset_vrcg, 0x00d8000d}, {&ch[0].ao.shu[0].hwset_mr2, 0x002d0002}, + + /* CH1 dramc ZQ Calibration */ {&ch[1].ao.mrs, 0x00000000}, {&ch[1].ao.dramc_pd_ctrl, 0xc4000107}, {&ch[1].ao.ckectrl, 0x88d02440}, @@ -961,49 +1082,6 @@ struct reg_init_value dramc_init_sequence[] = { {&ch[1].ao.shu[0].hwset_mr2, 0x002d0002}, {&ch[0].ao.mrs, 0x00000dd8}, {&ch[1].ao.mrs, 0x00000dd8}, - - /* update the ac timing */ - {&ch[0].ao.shu[0].actim[0], 0x06020c07}, - {&ch[0].ao.shu[0].actim[1], 0x10080501}, - {&ch[0].ao.shu[0].actim[2], 0x07070201}, - {&ch[0].ao.shu[0].actim[3], 0x6164002c}, - {&ch[0].ao.shu[0].actim[4], 0x22650077}, - {&ch[0].ao.shu[0].actim[5], 0x0a000c0b}, - {&ch[0].ao.shu[0].actim_xrt, 0x05030609}, - {&ch[0].ao.shu[0].ac_time_05t, 0x000106e1}, - {&ch[0].ao.catraining1, 0x0b000000}, - {&ch[0].ao.shu[0].rk[0].dqsctl, 0x00000004}, - {&ch[0].ao.shu[0].rk[1].dqsctl, 0x00000004}, - {&ch[0].ao.shu[0].odtctrl, 0xc001004f}, - {&ch[0].ao.shu[0].conf[1], 0x34000d0f}, - {&ch[0].ao.shu[0].conf[2], 0x9007640f}, - {&ch[0].ao.shu[0].scintv, 0x4e39eb36}, - {&ch[0].ao.shu[0].ckectrl, 0x33210000}, - {&ch[0].ao.ckectrl, 0x88d02440}, - {&ch[0].ao.shu[0].rankctl, 0x64300003}, - {&ch[0].ao.shu[0].rankctl, 0x64301203}, - {&ch[1].ao.shu[0].actim[0], 0x06020c07}, - {&ch[1].ao.shu[0].actim[1], 0x10080501}, - {&ch[1].ao.shu[0].actim[2], 0x07070201}, - {&ch[1].ao.shu[0].actim[3], 0x6164002c}, - {&ch[1].ao.shu[0].actim[4], 0x22650077}, - {&ch[1].ao.shu[0].actim[5], 0x0a000c0b}, - {&ch[1].ao.shu[0].actim_xrt, 0x05030609}, - {&ch[1].ao.shu[0].ac_time_05t, 0x000106e1}, - {&ch[1].ao.catraining1, 0x0b000000}, - {&ch[1].ao.shu[0].rk[0].dqsctl, 0x00000004}, - {&ch[1].ao.shu[0].rk[1].dqsctl, 0x00000004}, - {&ch[1].ao.shu[0].odtctrl, 0xc001004f}, - {&ch[1].ao.shu[0].conf[1], 0x34000d0f}, - {&ch[1].ao.shu[0].conf[2], 0x9007640f}, - {&ch[1].ao.shu[0].scintv, 0x4e39eb36}, - {&ch[1].ao.shu[0].ckectrl, 0x33210000}, - {&ch[1].ao.ckectrl, 0x88d02440}, - {&ch[1].ao.shu[0].rankctl, 0x64300003}, - {&ch[1].ao.shu[0].rankctl, 0x64301203}, - {&ch[0].ao.arbctl, 0x00000c80}, - {&ch[0].ao.rstmask, 0x00000000}, - {&ch[0].ao.arbctl, 0x00000c80}, }; void dramc_init(void) @@ -1011,4 +1089,10 @@ void dramc_init(void) for (int i = 0; i < ARRAY_SIZE(dramc_init_sequence); i++) write32(dramc_init_sequence[i].addr, dramc_init_sequence[i].value); + + for (int i = 0; i < ARRAY_SIZE(dramc_mode_reg_init_sequence); i++) { + write32(dramc_mode_reg_init_sequence[i].addr, + dramc_mode_reg_init_sequence[i].value); + udelay(2); + } } diff --git a/src/soc/mediatek/mt8183/dramc_pi_basic_api.c b/src/soc/mediatek/mt8183/dramc_pi_basic_api.c index 3ca5c22fcc..cdba2af2df 100644 --- a/src/soc/mediatek/mt8183/dramc_pi_basic_api.c +++ b/src/soc/mediatek/mt8183/dramc_pi_basic_api.c @@ -20,7 +20,7 @@ #include #include -static void sw_imp_cal_vref_sel(u8 term_option, u8 impcal_stage) +static void dramc_sw_imp_cal_vref_sel(u8 term_option, u8 impcal_stage) { u8 vref_sel = 0; @@ -56,7 +56,7 @@ void dramc_sw_impedance(const struct sdram_params *params) sw_impedance[ODT_OFF][3] = sw_impedance[ODT_ON][3]; clrsetbits_le32(&ch[0].phy.shu[0].ca_cmd[11], 0xff, 0x3); - sw_imp_cal_vref_sel(dq_term, IMPCAL_STAGE_DRVP); + dramc_sw_imp_cal_vref_sel(dq_term, IMPCAL_STAGE_DRVP); /* DQ */ clrsetbits_le32(&ch[0].ao.shu[0].drving[0], (0x1f << 5) | (0x1f << 0), @@ -154,9 +154,6 @@ static void dramc_rx_input_delay_tracking(u8 chn) for (size_t r = 0; r < 2; r++) for (size_t b = 0; b < 2; b++) { - /* Track rising and update rising/falling together */ - clrbits_le32(&ch[chn].phy.r[r].b[b].rxdvs[2], - 0x1 << 29); clrsetbits_le32(&ch[chn].phy.r[r].b[b].rxdvs[7], (0x3f << 0) | (0x3f << 8) | (0x7f << 16) | (0x7f << 24), @@ -172,8 +169,6 @@ static void dramc_rx_input_delay_tracking(u8 chn) (0x3 << 18) | (0x3 << 16)); } - clrbits_le32(&ch[chn].phy.ca_cmd[10], (0x7 << 28) | (0x7 << 24)); - /* Rx DLY tracking setting (Static) */ clrsetbits_le32(&ch[chn].phy.b0_rxdvs[0], (0x1 << 29) | (0xf << 4) | (0x1 << 0), @@ -181,6 +176,7 @@ static void dramc_rx_input_delay_tracking(u8 chn) clrsetbits_le32(&ch[chn].phy.b1_rxdvs[0], (0x1 << 29) | (0xf << 4) | (0x1 << 0), (0x1 << 29) | (0x0 << 4) | (0x1 << 0)); + clrbits_le32(&ch[chn].phy.ca_cmd[10], (0x7 << 28) | (0x7 << 24)); for (u8 b = 0; b < 2; b++) { clrsetbits_le32(&ch[chn].phy.b[b].dq[9], @@ -201,10 +197,12 @@ static void dramc_rx_input_delay_tracking(u8 chn) static void dramc_hw_dqs_gating_tracking(u8 chn) { - setbits_le32(&ch[chn].ao.stbcal, (0x3 << 26) | (0x1 << 0)); + clrsetbits_le32(&ch[chn].ao.stbcal, + (0x1 << 21) | (0x3 << 15) | (0x1f << 8) | (0x1 << 4), + (0x3 << 26) | (0x1 << 0)); clrsetbits_le32(&ch[chn].ao.stbcal1, (0xffff << 16) | (0x1 << 8) | (0x1 << 6), - (0x1 << 16) | (0x1 << 8) | (0x0 << 6)); + (0x1 << 16) | (0x1 << 8) | (0x1 << 6)); clrsetbits_le32(&ch[chn].phy.misc_ctrl0, (0x1 << 24) | (0x1f << 11) | (0xf << 0), @@ -262,6 +260,63 @@ static void dramc_phy_low_power_enable(void) dramc_set_broadcast(broadcast_bak); } + +static void dramc_dummy_read_for_tracking_enable(u8 chn) +{ + setbits_le32(&ch[chn].ao.dummy_rd, 0x3 << 16); + + for (size_t r = 0; r < 2; r++) + for (size_t i = 0; i < 4; i++) + write32(&ch[chn].ao.rk[r].dummy_rd_wdata[i], + 0xaaaa5555); + + clrsetbits_le32(&ch[chn].ao.test2_4, 0x7 << 28, 0x4 << 28); + for (size_t r = 0; r < 2; r++) { + clrsetbits_le32(&ch[chn].ao.rk[r].dummy_rd_adr, + (0x1ffff << 0) | (0x7ff << 17) | (0xf << 28), + (0x7fff << 0) | (0x3f0 << 17)); + setbits_le32(&ch[chn].ao.rk[r].dummy_rd_bk, 0x7 << 0); + } + + clrbits_le32(&ch[chn].ao.dummy_rd, 0x1 << 25 | 0x1 << 20); +} + +static void dramc_set_CKE_2_rank_independent(u8 chn) +{ + clrsetbits_le32(&ch[chn].ao.rkcfg, (0x1 << 15) | (0x1 << 12), 0x1 << 2); + clrsetbits_le32(&ch[chn].ao.ckectrl, + (0x1 << 1) | (0xf << 8) | (0x7 << 13), + (0x4 << 8) | (0x2 << 13)); + + for (u8 shu = 0; shu < DRAM_DFS_SHUFFLE_MAX; shu++) + setbits_le32(&ch[chn].ao.shu[shu].conf[2], + (0x1 << 29) | (0x1 << 31)); + clrbits_le32(&ch[chn].ao.dramctrl, 0x1 << 9); +} + +static void dramc_pa_improve(u8 chn) +{ + clrbits_le32(&ch[chn].ao.clkar, 0xffff); + clrbits_le32(&ch[chn].ao.srefctrl, 0xf << 12); + clrbits_le32(&ch[chn].ao.zqcs, 0x1 << 19); + clrbits_le32(&ch[chn].ao.pre_tdqsck[0], 0x1 << 17); + clrbits_le32(&ch[chn].ao.zqcs, 0x1 << 19); + clrbits_le32(&ch[chn].ao.pre_tdqsck[0], 0x1 << 17); + + for (u8 shu = 0; shu < DRAM_DFS_SHUFFLE_MAX; shu++) + clrbits_le32(&ch[chn].ao.shu[shu].odtctrl, 0x3 << 2); +} + +static void dramc_enable_dramc_dcm(void) +{ + for (size_t chn = 0; chn < CHANNEL_MAX; chn++) { + clrsetbits_le32(&ch[chn].ao.dramc_pd_ctrl, + (0x7 << 0) | (0x1 << 26) | (0x1 << 30) | (0x1 << 31), + (0x7 << 0) | (0x1 << 30) | (0x1 << 31)); + setbits_le32(&ch[chn].ao.clkar, 0x1 << 31); + } +} + void dramc_runtime_config(void) { clrbits_le32(&ch[0].ao.refctrl0, 0x1 << 29); @@ -270,39 +325,78 @@ void dramc_runtime_config(void) transfer_pll_to_spm_control(); setbits_le32(&mtk_spm->spm_power_on_val0, 0x3 << 25); + /* RX_TRACKING: ON */ for (u8 chn = 0; chn < CHANNEL_MAX; chn++) dramc_rx_input_delay_tracking(chn); + /* HW_GATING: ON */ dramc_hw_gating_init(); dramc_hw_gating_onoff(CHANNEL_A, true); + dramc_hw_gating_onoff(CHANNEL_B, true); + /* HW_GATING DBG: OFF */ for (size_t chn = 0; chn < CHANNEL_MAX; chn++) clrbits_le32(&ch[chn].ao.stbcal2, (0x3 << 4) | (0x3 << 8) | (0x1 << 28)); + /* DUMMY_READ_FOR_TRACKING: ON */ + for (u8 chn = 0; chn < CHANNEL_MAX; chn++) + dramc_dummy_read_for_tracking_enable(chn); + + /* ZQCS_ENABLE_LP4: ON */ clrbits_le32(&ch[0].ao.spcmdctrl, 0x1 << 30); clrbits_le32(&ch[1].ao.spcmdctrl, 0x1 << 30); + /* LOWPOWER_GOLDEN_SETTINGS(DCM): ON */ dramc_phy_low_power_enable(); dramc_enable_phy_dcm(true); + /* DUMMY_READ_FOR_DQS_GATING_RETRY: OFF */ for (size_t chn = 0; chn < CHANNEL_MAX; chn++) for (size_t shu = 0; shu < DRAM_DFS_SHUFFLE_MAX; shu++) clrbits_le32(&ch[chn].ao.shu[shu].dqsg_retry, (0x1 << 1) | (0x3 << 13)); + /* SPM_CONTROL_AFTERK: ON */ write32(&ch[0].phy.misc_spm_ctrl0, 0xfbffefff); write32(&ch[1].phy.misc_spm_ctrl0, 0xfbffefff); write32(&ch[0].phy.misc_spm_ctrl2, 0xffffffef); write32(&ch[1].phy.misc_spm_ctrl2, 0x7fffffef); + /* IMPEDANCE_TRACKING: ON */ dramc_impedance_tracking_enable(); for (size_t chn = 0; chn < CHANNEL_MAX; chn++) { + /* TEMP_SENSOR: ON */ clrbits_le32(&ch[chn].ao.spcmdctrl, 0x3 << 28); setbits_le32(&ch[chn].ao.hw_mrr_fun, (0x1 << 0) | (0x1 << 11)); - clrbits_le32(&ch[0].ao.refctrl0, 0x1 << 18); - setbits_le32(&ch[chn].phy.dvfs_emi_clk, 0x1 << 24); - setbits_le32(&ch[chn].ao.dvfsdll, 0x1 << 7); + + /* PER_BANK_REFRESH: ON */ + clrbits_le32(&ch[chn].ao.refctrl0, 0x1 << 18); + + /* HW_SAVE_FOR_SR: ON */ + clrbits_le32(&ch[chn].ao.rstmask, (0x1 << 25) | (0x1 << 28)); + setbits_le32(&ch[chn].ao.refctrl1, 0x1 << 0); + clrsetbits_le32(&ch[chn].ao.srefctrl, 0x1 << 20, 0x1 << 22); + + /* SET_CKE_2_RANK_INDEPENDENT_RUN_TIME: ON */ + dramc_set_CKE_2_rank_independent(chn); + + /* CLK_FREE_FUN_FOR_DRAMC_PSEL: ON */ + clrbits_le32(&ch[chn].ao.refctrl1, (0x1 << 6) | (0x3 << 2)); + clrbits_le32(&ch[chn].ao.clkar, 0x1 << 19); + + /* PA_IMPROVEMENT_FOR_DRAMC_ACTIVE_POWER: ON */ + dramc_pa_improve(chn); + + /* DRAM DRS DISABLE */ + clrsetbits_le32(&ch[chn].ao.drsctrl, + (0x1 << 21) | (0x3f << 12) | (0xf << 8) | (0x1 << 6), + (0x1 << 19) | (0x3 << 12) | (0x8 << 8) | + (0x3 << 4) | (0x1 << 2) | (0x1 << 0)); + setbits_le32(&ch[chn].ao.dummy_rd, 0x3 << 26); } + + enable_emi_dcm(); + dramc_enable_dramc_dcm(); } diff --git a/src/soc/mediatek/mt8183/dramc_pi_calibration_api.c b/src/soc/mediatek/mt8183/dramc_pi_calibration_api.c index f3c76a9273..05f793ec4b 100644 --- a/src/soc/mediatek/mt8183/dramc_pi_calibration_api.c +++ b/src/soc/mediatek/mt8183/dramc_pi_calibration_api.c @@ -32,7 +32,7 @@ enum { enum { FIRST_DQ_DELAY = 0, - FIRST_DQS_DELAY = -10, + FIRST_DQS_DELAY = -16, MAX_DQDLY_TAPS = 16, MAX_RX_DQDLY_TAPS = 63, }; @@ -86,7 +86,7 @@ struct per_byte_dly { u16 final_dly; }; -static void auto_refresh_switch(u8 chn, bool option) +static void dramc_auto_refresh_switch(u8 chn, bool option) { clrsetbits_le32(&ch[chn].ao.refctrl0, 1 << REFCTRL0_REFDIS_SHIFT, (option ? 0 : 1) << REFCTRL0_REFDIS_SHIFT); @@ -157,7 +157,7 @@ static void dramc_write_leveling(u8 chn, u8 rank, } } -static void cmd_bus_training(u8 chn, u8 rank, +static void dramc_cmd_bus_training(u8 chn, u8 rank, const struct sdram_params *params) { u32 cbt_cs, mr12_value; @@ -257,7 +257,7 @@ void dramc_enable_phy_dcm(bool en) dramc_set_broadcast(broadcast_bak); } -static void reset_delay_chain_before_calibration(void) +static void dramc_reset_delay_chain_before_calibration(void) { for (size_t chn = 0; chn < CHANNEL_MAX; chn++) for (size_t rank = 0; rank < RANK_MAX; rank++) { @@ -290,10 +290,10 @@ static void dramc_rx_input_delay_tracking_init_by_freq(u8 chn) clrbits_le32(&shu->b[1].dq[7], (0x1 << 12) | (0x1 << 13)); } -void dramc_apply_pre_calibration_config(void) +void dramc_apply_config_before_calibration(void) { dramc_enable_phy_dcm(false); - reset_delay_chain_before_calibration(); + dramc_reset_delay_chain_before_calibration(); setbits_le32(&ch[0].ao.shu[0].conf[3], 0x1ff << 16); setbits_le32(&ch[0].ao.spcmdctrl, 0x1 << 24); @@ -344,7 +344,53 @@ void dramc_apply_pre_calibration_config(void) } } -static void rx_dqs_isi_pulse_cg_switch(u8 chn, bool flag) +static void dramc_set_mr13_vrcg_to_Normal(u8 chn) +{ + for (u8 rank = 0; rank < RANK_MAX; rank++) + dramc_mode_reg_write_by_rank(chn, rank, 13, 0xd0); + + for (u8 shu = 0; shu < DRAM_DFS_SHUFFLE_MAX; shu++) + clrbits_le32(&ch[chn].ao.shu[shu].hwset_vrcg, 0x1 << 19); +} + +void dramc_apply_config_after_calibration(void) +{ + for (size_t chn = 0; chn < CHANNEL_MAX; chn++) { + setbits_le32(&ch[chn].phy.misc_cg_ctrl4, 0x11400000); + clrbits_le32(&ch[chn].ao.refctrl1, 0x1 << 7); + clrbits_le32(&ch[chn].ao.shuctrl, 0x1 << 2); + clrbits_le32(&ch[chn].phy.ca_cmd[6], 0x1 << 6); + dramc_set_mr13_vrcg_to_Normal(chn); + + clrbits_le32(&ch[chn].phy.b[0].dq[6], 0x3); + clrbits_le32(&ch[chn].phy.b[1].dq[6], 0x3); + clrbits_le32(&ch[chn].phy.ca_cmd[6], 0x3); + setbits_le32(&ch[chn].phy.b[0].dq[6], 0x1 << 5); + setbits_le32(&ch[chn].phy.b[1].dq[6], 0x1 << 5); + setbits_le32(&ch[chn].phy.ca_cmd[6], 0x1 << 5); + + clrbits_le32(&ch[chn].ao.impcal, 0x3 << 24); + clrbits_le32(&ch[chn].phy.misc_imp_ctrl0, 0x7); + + clrbits_le32(&ch[chn].phy.misc_ctrl0, 0x1 << 31); + clrbits_le32(&ch[chn].phy.misc_ctrl1, 0x1 << 25); + + setbits_le32(&ch[chn].ao.spcmdctrl, 1 << 29); + setbits_le32(&ch[chn].ao.dqsoscr, 1 << 24); + + for (u8 shu = 0; shu < DRAM_DFS_SHUFFLE_MAX; shu++) + clrbits_le32(&ch[chn].ao.shu[shu].scintv, 0x1 << 30); + + clrbits_le32(&ch[chn].ao.dummy_rd, (0x7 << 20) | (0x1 << 7)); + dramc_cke_fix_onoff(chn, false, false); + clrbits_le32(&ch[chn].ao.dramc_pd_ctrl, 0x1 << 26); + + clrbits_le32(&ch[chn].ao.eyescan, 0x7 << 8); + clrsetbits_le32(&ch[chn].ao.test2_4, 0x7 << 28, 0x4 << 28); + } +} + +static void dramc_rx_dqs_isi_pulse_cg_switch(u8 chn, bool flag) { for (size_t b = 0; b < 2; b++) clrsetbits_le32(&ch[chn].phy.b[b].dq[6], 1 << 5, @@ -468,7 +514,7 @@ static void dramc_engine2_end(u8 chn) clrbits_le32(&ch[chn].ao.test2_4, 0x1 << 17); } -static void find_gating_window(u32 result_r, u32 result_f, u32 *debug_cnt, +static void dramc_find_gating_window(u32 result_r, u32 result_f, u32 *debug_cnt, u8 dly_coarse_large, u8 dly_coarse_0p5t, u8 *pass_begin, u8 *pass_count, u8 *dly_fine_xt, u32 *coarse_tune, u8 *dqs_high) { @@ -509,7 +555,7 @@ static void find_gating_window(u32 result_r, u32 result_f, u32 *debug_cnt, } } -static void find_dly_tune(u8 chn, u8 dly_coarse_large, u8 dly_coarse_0p5t, +static void dramc_find_dly_tune(u8 chn, u8 dly_coarse_large, u8 dly_coarse_0p5t, u8 dly_fine_xt, u8 *dqs_high, u8 *dly_coarse_large_cnt, u8 *dly_coarse_0p5t_cnt, u8 *dly_fine_tune_cnt, u8 *dqs_trans) { @@ -577,7 +623,7 @@ static void dramc_set_gating_mode(u8 chn, bool mode) static void dramc_rx_dqs_gating_cal_pre(u8 chn, u8 rank) { - rx_dqs_isi_pulse_cg_switch(chn, false); + dramc_rx_dqs_isi_pulse_cg_switch(chn, false); clrbits_le32(&ch[chn].ao.refctrl0, 1 << REFCTRL0_PBREFEN_SHIFT); dramc_hw_gating_onoff(chn, false); @@ -606,7 +652,7 @@ static void dramc_write_dqs_gating_result(u8 chn, u8 rank, u8 best_coarse_rodt_p1[DQS_NUMBER]; u8 best_coarse_0p5t_rodt_p1[DQS_NUMBER]; - rx_dqs_isi_pulse_cg_switch(chn, true); + dramc_rx_dqs_isi_pulse_cg_switch(chn, true); write32(&ch[chn].ao.shu[0].rk[rank].selph_dqsg0, ((u32) best_coarse_tune2t[0] << @@ -807,9 +853,9 @@ static void dramc_rx_dqs_gating_cal(u8 chn, u8 rank) dramc_set_gating_mode(chn, 1); dramc_engine2_run(chn, TE_OP_READ_CHECK); - find_dly_tune(chn, dly_coarse_large, dly_coarse_0p5t, - dly_fine_xt, dqs_high, dly_coarse_large_cnt, - dly_coarse_0p5t_cnt, + dramc_find_dly_tune(chn, dly_coarse_large, + dly_coarse_0p5t, dly_fine_xt, dqs_high, + dly_coarse_large_cnt, dly_coarse_0p5t_cnt, dly_fine_tune_cnt, dqs_transition); dramc_dbg("%d %d %d |", dly_coarse_large, @@ -825,7 +871,7 @@ static void dramc_rx_dqs_gating_cal(u8 chn, u8 rank) } dramc_dbg("\n"); - find_gating_window(result_r, result_f, debug_cnt, + dramc_find_gating_window(result_r, result_f, debug_cnt, dly_coarse_large, dly_coarse_0p5t, pass_begin, pass_count, &dly_fine_xt, &coarse_tune, dqs_high); @@ -971,7 +1017,7 @@ static void dramc_transfer_dly_tune( dly_tune->coarse_tune_large_oen = tmp_val >> 3; } -static void set_rx_dly_factor(u8 chn, u8 rank, enum RX_TYPE type, u32 val) +static void dramc_set_rx_dly_factor(u8 chn, u8 rank, enum RX_TYPE type, u32 val) { u32 tmp, mask; @@ -1006,7 +1052,8 @@ static void set_rx_dly_factor(u8 chn, u8 rank, enum RX_TYPE type, u32 val) } } -static void set_tx_dly_factor(u8 chn, u8 rank, enum CAL_TYPE type, u32 val) +static void dramc_set_tx_dly_factor(u8 chn, u8 rank, + enum CAL_TYPE type, u32 val) { struct tx_dly_tune dly_tune = {0}; u32 coarse_tune_large = 0, coarse_tune_large_oen = 0; @@ -1203,19 +1250,18 @@ static void dramc_set_rx_dly(u8 chn, u8 rank, s32 dly) { if (dly <= 0) { /* Hold time calibration */ - set_rx_dly_factor(chn, rank, RX_DQS, -dly); + dramc_set_rx_dly_factor(chn, rank, RX_DQS, -dly); dram_phy_reset(chn); } else { /* Setup time calibration */ - set_rx_dly_factor(chn, rank, RX_DQS, 0); - set_rx_dly_factor(chn, rank, RX_DQM, dly); + dramc_set_rx_dly_factor(chn, rank, RX_DQS, 0); + dramc_set_rx_dly_factor(chn, rank, RX_DQM, dly); dram_phy_reset(chn); - set_rx_dly_factor(chn, rank, RX_DQ, dly); + dramc_set_rx_dly_factor(chn, rank, RX_DQ, dly); } - } -static void set_tx_best_dly_factor(u8 chn, u8 rank_start, +static void dramc_set_tx_best_dly_factor(u8 chn, u8 rank_start, struct per_byte_dly *tx_perbyte_dly, u16 dq_precal_result[]) { u32 coarse_tune_large = 0; @@ -1268,7 +1314,7 @@ static void set_tx_best_dly_factor(u8 chn, u8 rank_start, FINE_TUNE_DQM_SHIFT)); } -static void set_rx_best_dly_factor(u8 chn, u8 rank, +static void dramc_set_rx_best_dly_factor(u8 chn, u8 rank, struct dqdqs_perbit_dly *dqdqs_perbit_dly, u32 *max_dqsdly_byte, u32 *ave_dqm_dly) { @@ -1335,7 +1381,7 @@ static void dramc_set_dqdqs_dly(u8 chn, u8 rank, enum CAL_TYPE type, s32 dly) if ((type == RX_WIN_RD_DQC) || (type == RX_WIN_TEST_ENG)) dramc_set_rx_dly(chn, rank, dly); else - set_tx_dly_factor(chn, rank, type, dly); + dramc_set_tx_dly_factor(chn, rank, type, dly); } static void dramc_set_tx_best_dly(u8 chn, u8 rank, @@ -1380,7 +1426,8 @@ static void dramc_set_tx_best_dly(u8 chn, u8 rank, byte_dly_cell[i]); } - set_tx_best_dly_factor(chn, rank, tx_perbyte_dly, tx_dq_precal_result); + dramc_set_tx_best_dly_factor(chn, rank, tx_perbyte_dly, + tx_dq_precal_result); } static int dramc_set_rx_best_dly(u8 chn, u8 rank, @@ -1425,7 +1472,7 @@ static int dramc_set_rx_best_dly(u8 chn, u8 rank, return -1; } - set_rx_best_dly_factor(chn, rank, rx_dly, max_dqsdly_byte, + dramc_set_rx_best_dly_factor(chn, rank, rx_dly, max_dqsdly_byte, ave_dqmdly_byte); return 0; } @@ -1546,8 +1593,10 @@ static u8 dramc_window_perbit_cal(u8 chn, u8 rank, dramc_set_vref(chn, rank, type, vref_dly.vref); if ((type == RX_WIN_RD_DQC) || (type == RX_WIN_TEST_ENG)) { - set_rx_dly_factor(chn, rank, RX_DQM, FIRST_DQ_DELAY); - set_rx_dly_factor(chn, rank, RX_DQ, FIRST_DQ_DELAY); + dramc_set_rx_dly_factor(chn, rank, + RX_DQM, FIRST_DQ_DELAY); + dramc_set_rx_dly_factor(chn, rank, + RX_DQ, FIRST_DQ_DELAY); } dramc_get_dly_range(chn, rank, type, dq_precal_result, @@ -1625,7 +1674,7 @@ static u8 dramc_window_perbit_cal(u8 chn, u8 rank, return 0; } -static void dle_factor_handler(u8 chn, u8 val) +static void dramc_dle_factor_handler(u8 chn, u8 val) { val = MAX(val, 2); clrsetbits_le32(&ch[chn].ao.shu[0].conf[1], @@ -1650,7 +1699,7 @@ static u8 dramc_rx_datlat_cal(u8 chn, u8 rank) dramc_engine2_init(chn, rank, 0x400, false); for (datlat = 12; datlat < DATLAT_TAP_NUMBER; datlat++) { - dle_factor_handler(chn, datlat); + dramc_dle_factor_handler(chn, datlat); u32 err = dramc_engine2_run(chn, TE_OP_WRITE_READ_CHECK); @@ -1679,7 +1728,7 @@ static u8 dramc_rx_datlat_cal(u8 chn, u8 rank) assert(sum != 0); - dle_factor_handler(chn, best_step); + dramc_dle_factor_handler(chn, best_step); clrsetbits_le32(&ch[chn].ao.padctrl, PADCTRL_DQIENQKEND_MASK, (0x1 << PADCTRL_DQIENQKEND_SHIFT) | @@ -1691,7 +1740,7 @@ static u8 dramc_rx_datlat_cal(u8 chn, u8 rank) static void dramc_dual_rank_rx_datlat_cal(u8 chn, u8 datlat0, u8 datlat1) { u8 final_datlat = MAX(datlat0, datlat1); - dle_factor_handler(chn, final_datlat); + dramc_dle_factor_handler(chn, final_datlat); } static void dramc_rx_dqs_gating_post_process(u8 chn) @@ -1794,10 +1843,10 @@ void dramc_calibrate_all_channels(const struct sdram_params *pams) for (u8 chn = 0; chn < CHANNEL_MAX; chn++) { for (u8 rk = RANK_0; rk < RANK_MAX; rk++) { dramc_show("Start K ch:%d, rank:%d\n", chn, rk); - auto_refresh_switch(chn, false); - cmd_bus_training(chn, rk, pams); + dramc_auto_refresh_switch(chn, false); + dramc_cmd_bus_training(chn, rk, pams); dramc_write_leveling(chn, rk, pams->wr_level); - auto_refresh_switch(chn, true); + dramc_auto_refresh_switch(chn, true); dramc_rx_dqs_gating_cal(chn, rk); dramc_window_perbit_cal(chn, rk, RX_WIN_RD_DQC, pams); dramc_window_perbit_cal(chn, rk, TX_WIN_DQ_DQM, pams); diff --git a/src/soc/mediatek/mt8183/emi.c b/src/soc/mediatek/mt8183/emi.c index 757a453de9..937d06de37 100644 --- a/src/soc/mediatek/mt8183/emi.c +++ b/src/soc/mediatek/mt8183/emi.c @@ -292,11 +292,21 @@ static void init_dram(const struct sdram_params *params) emi_init2(params); } +void enable_emi_dcm(void) +{ + clrbits_le32(&emi_regs->conm, 0xff << 24); + clrbits_le32(&emi_regs->conn, 0xff << 24); + + for (size_t chn = 0; chn < CHANNEL_MAX; chn++) + clrbits_le32(&ch[chn].emi.chn_conb, 0xff << 24); +} + static void do_calib(const struct sdram_params *params) { - dramc_apply_pre_calibration_config(); + dramc_apply_config_before_calibration(); dramc_calibrate_all_channels(params); dramc_ac_timing_optimize(); + dramc_apply_config_after_calibration(); dramc_runtime_config(); } diff --git a/src/soc/mediatek/mt8183/gpio.c b/src/soc/mediatek/mt8183/gpio.c index 327d389eb2..3eccfbd50d 100644 --- a/src/soc/mediatek/mt8183/gpio.c +++ b/src/soc/mediatek/mt8183/gpio.c @@ -15,11 +15,15 @@ #include #include +#include +#include enum { EN_OFFSET = 0x60, SEL_OFFSET = 0x80, EH_RSEL_OFFSET = 0xF0, + GPIO_DRV0_OFFSET = 0xA0, + GPIO_DRV1_OFFSET = 0XB0, }; static void gpio_set_pull_pupd(gpio_t gpio, enum pull_enable enable, @@ -128,3 +132,54 @@ void gpio_set_i2c_eh_rsel(void) I2C_EH_RSL_MASK(SCL5) | I2C_EH_RSL_MASK(SDA5), I2C_EH_RSL_VAL(SCL5) | I2C_EH_RSL_VAL(SDA5)); } + +void gpio_set_spi_driving(unsigned int bus, enum spi_pad_mask pad_select, + unsigned int milliamps) +{ + void *reg = NULL; + unsigned int reg_val = milliamps / 2 - 1, offset = 0; + + assert(bus < SPI_BUS_NUMBER); + assert(milliamps >= 2 && milliamps <= 16); + assert(pad_select <= SPI_PAD1_MASK); + + switch (bus) { + case 0: + reg = (void *)(IOCFG_RB_BASE + GPIO_DRV1_OFFSET); + offset = 0; + break; + case 1: + if (pad_select == SPI_PAD0_MASK) { + reg = (void *)(IOCFG_LM_BASE + GPIO_DRV0_OFFSET); + offset = 0; + } else if (pad_select == SPI_PAD1_MASK) { + clrsetbits_le32((void *)IOCFG_RM_BASE + + GPIO_DRV0_OFFSET, 0xf | 0xf << 20, + reg_val | reg_val << 20); + clrsetbits_le32((void *)IOCFG_RM_BASE + + GPIO_DRV1_OFFSET, 0xf << 16, + reg_val << 16); + return; + } + break; + case 2: + clrsetbits_le32((void *)IOCFG_RM_BASE + GPIO_DRV0_OFFSET, + 0xf << 8 | 0xf << 12, + reg_val << 8 | reg_val << 12); + return; + case 3: + reg = (void *)(IOCFG_LM_BASE + GPIO_DRV0_OFFSET); + offset = 16; + break; + case 4: + reg = (void *)(IOCFG_LM_BASE + GPIO_DRV0_OFFSET); + offset = 12; + break; + case 5: + reg = (void *)(IOCFG_LM_BASE + GPIO_DRV0_OFFSET); + offset = 8; + break; + } + + clrsetbits_le32(reg, 0xf << offset, reg_val << offset); +} diff --git a/src/soc/mediatek/mt8183/include/soc/addressmap.h b/src/soc/mediatek/mt8183/include/soc/addressmap.h index d41b2b942e..e9f80d1607 100644 --- a/src/soc/mediatek/mt8183/include/soc/addressmap.h +++ b/src/soc/mediatek/mt8183/include/soc/addressmap.h @@ -50,6 +50,7 @@ enum { IOCFG_LB_BASE = IO_PHYS + 0x01E70000, IOCFG_LM_BASE = IO_PHYS + 0x01E80000, IOCFG_BL_BASE = IO_PHYS + 0x01E90000, + EFUSEC_BASE = IO_PHYS + 0x01F10000, IOCFG_LT_BASE = IO_PHYS + 0x01F20000, IOCFG_TL_BASE = IO_PHYS + 0x01F30000, SSUSB_SIF_BASE = IO_PHYS + 0x01F40300, diff --git a/src/soc/mediatek/mt8183/include/soc/dramc_pi_api.h b/src/soc/mediatek/mt8183/include/soc/dramc_pi_api.h index 781443a397..23b5cf032c 100644 --- a/src/soc/mediatek/mt8183/include/soc/dramc_pi_api.h +++ b/src/soc/mediatek/mt8183/include/soc/dramc_pi_api.h @@ -123,8 +123,10 @@ void dramc_set_broadcast(u32 onoff); u32 dramc_get_broadcast(void); void dramc_init(void); void dramc_sw_impedance(const struct sdram_params *params); -void dramc_apply_pre_calibration_config(void); +void dramc_apply_config_before_calibration(void); +void dramc_apply_config_after_calibration(void); void dramc_calibrate_all_channels(const struct sdram_params *params); void dramc_hw_gating_onoff(u8 chn, bool onoff); void dramc_enable_phy_dcm(bool bEn); + #endif /* _DRAMC_PI_API_MT8183_H */ diff --git a/src/soc/mediatek/mt8183/include/soc/dramc_register.h b/src/soc/mediatek/mt8183/include/soc/dramc_register.h index 2487504a28..f0720a7272 100644 --- a/src/soc/mediatek/mt8183/include/soc/dramc_register.h +++ b/src/soc/mediatek/mt8183/include/soc/dramc_register.h @@ -265,10 +265,7 @@ check_member(dramc_nao_regs, cmddrv2, 0x0474); struct dramc_ao_regs_rk { uint32_t dqsosc; uint32_t rsvd_1[5]; - uint32_t dummy_rd_wdata0; - uint32_t dummy_rd_wdata1; - uint32_t dummy_rd_wdata2; - uint32_t dummy_rd_wdata3; + uint32_t dummy_rd_wdata[4]; uint32_t dummy_rd_adr; uint32_t dummy_rd_bk; uint32_t pre_tdqsck[12]; diff --git a/src/soc/mediatek/mt8183/include/soc/efuse.h b/src/soc/mediatek/mt8183/include/soc/efuse.h new file mode 100644 index 0000000000..32126abc4e --- /dev/null +++ b/src/soc/mediatek/mt8183/include/soc/efuse.h @@ -0,0 +1,30 @@ +/* + * This file is part of the coreboot project. + * + * Copyright 2018 MediaTek 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. + */ + +#ifndef _MTK_EFUSE_H +#define _MTK_EFUSE_H + +#include +#include + +struct efuse_regs { + uint32_t rserved[109]; + uint32_t adc_cali_reg; +}; + +check_member(efuse_regs, adc_cali_reg, 0x1b4); +static struct efuse_regs *const mtk_efuse = (void *)EFUSEC_BASE; + +#endif diff --git a/src/soc/mediatek/mt8183/include/soc/emi.h b/src/soc/mediatek/mt8183/include/soc/emi.h index 81e3d91daa..2c04a50e9e 100644 --- a/src/soc/mediatek/mt8183/include/soc/emi.h +++ b/src/soc/mediatek/mt8183/include/soc/emi.h @@ -38,6 +38,7 @@ extern const u8 phy_mapping[CHANNEL_MAX][16]; int complex_mem_test(u8 *start, unsigned int len); size_t sdram_size(void); const struct sdram_params *get_sdram_config(void); +void enable_emi_dcm(void); void mt_set_emi(const struct sdram_params *params); void mt_mem_init(const struct sdram_params *params); diff --git a/src/soc/mediatek/mt8183/include/soc/gpio.h b/src/soc/mediatek/mt8183/include/soc/gpio.h index 5a98953974..a0d6262abb 100644 --- a/src/soc/mediatek/mt8183/include/soc/gpio.h +++ b/src/soc/mediatek/mt8183/include/soc/gpio.h @@ -19,6 +19,7 @@ #include #include #include +#include enum { MAX_GPIO_REG_BITS = 32, @@ -617,5 +618,7 @@ check_member(gpio_regs, mode[22].val, 0x460); static struct gpio_regs *const mtk_gpio = (void *)(GPIO_BASE); void gpio_set_i2c_eh_rsel(void); +void gpio_set_spi_driving(unsigned int bus, enum spi_pad_mask pad_select, + unsigned int milliamps); #endif diff --git a/src/soc/mediatek/mt8183/include/soc/mt6358.h b/src/soc/mediatek/mt8183/include/soc/mt6358.h index 02937bac9a..277ee9aa35 100644 --- a/src/soc/mediatek/mt8183/include/soc/mt6358.h +++ b/src/soc/mediatek/mt8183/include/soc/mt6358.h @@ -27,6 +27,7 @@ enum { PMIC_CPSDSA4 = 0x0a2e, PMIC_VDRAM1_VOSEL_SLEEP = 0x160a, PMIC_SMPS_ANA_CON0 = 0x1808, + PMIC_VSIM2_ANA_CON0 = 0x1e30, }; struct pmic_setting { @@ -38,5 +39,6 @@ struct pmic_setting { void mt6358_init(void); void pmic_set_power_hold(bool enable); +void pmic_set_vsim2_cali(unsigned int vsim2_mv); #endif /* __SOC_MEDIATEK_MT6358_H__ */ diff --git a/src/soc/mediatek/mt8183/include/soc/pll.h b/src/soc/mediatek/mt8183/include/soc/pll.h index 2a72e2c61c..3807e0087e 100644 --- a/src/soc/mediatek/mt8183/include/soc/pll.h +++ b/src/soc/mediatek/mt8183/include/soc/pll.h @@ -270,4 +270,13 @@ enum { SPI_HZ = MAINPLL_D5_D2_HZ, }; +enum { + DCM_INFRA_BUS_MASK = 0x40907ffb, + DCM_INFRA_BUS_ON = 0x40904203, + DCM_INFRA_MEM_ON = 0x1 << 27, + DCM_INFRA_P2PRX_MASK = 0xf, + DCM_INFRA_PERI_MASK = 0xf03ffffb, + DCM_INFRA_PERI_ON = 0xf03f83e3, +}; + #endif /* SOC_MEDIATEK_MT8183_PLL_H */ diff --git a/src/soc/mediatek/mt8183/include/soc/spi.h b/src/soc/mediatek/mt8183/include/soc/spi.h index 9bc7121847..f718081f67 100644 --- a/src/soc/mediatek/mt8183/include/soc/spi.h +++ b/src/soc/mediatek/mt8183/include/soc/spi.h @@ -49,5 +49,10 @@ enum { SPI_CFG2_SCK_HIGH_SHIFT = 16, }; +enum { + SPI_CFG1_TICK_DLY_SHIFT = 29, + SPI_CFG1_TICK_DLY_MASK = 0x7 << SPI_CFG1_TICK_DLY_SHIFT, + +}; #endif diff --git a/src/soc/mediatek/mt8183/mt6358.c b/src/soc/mediatek/mt8183/mt6358.c index 705424337f..53d2a43803 100644 --- a/src/soc/mediatek/mt8183/mt6358.c +++ b/src/soc/mediatek/mt8183/mt6358.c @@ -13,6 +13,7 @@ * GNU General Public License for more details. */ +#include #include #include #include @@ -496,8 +497,10 @@ static struct pmic_setting init_setting[] = { {0x1B6C, 0x6, 0x6, 0}, /* Vproc11/Vproc12 to 1.05V */ + /* [6:0]: RG_BUCK_VPROC11_VOSEL */ {0x13a6, 0x58, 0x7F, 0}, - {0x140a, 0x58, 0x7F, 0}, + /* [6:0]: RG_BUCK_VPROC12_VOSEL */ + {0x1426, 0x58, 0x7F, 0}, }; static struct pmic_setting lp_setting[] = { @@ -733,6 +736,46 @@ void pmic_set_power_hold(bool enable) pwrap_write_field(PMIC_PWRHOLD, (enable) ? 1 : 0, 0x1, 0); } +void pmic_set_vsim2_cali(unsigned int vsim2_mv) +{ + u16 vsim2_reg, cali_mv; + + cali_mv = vsim2_mv % 100; + assert(cali_mv % 10 == 0); + + switch (vsim2_mv - cali_mv) { + case 1700: + vsim2_reg = 0x3; + break; + + case 1800: + vsim2_reg = 0x4; + break; + + case 2700: + vsim2_reg = 0x8; + break; + + case 3000: + vsim2_reg = 0xb; + break; + + case 3100: + vsim2_reg = 0xc; + break; + + default: + assert(0); + return; + }; + + /* [11:8]=0x8, RG_VSIM2_VOSEL */ + pwrap_write_field(PMIC_VSIM2_ANA_CON0, vsim2_reg, 0xF, 8); + + /* [3:0], RG_VSIM2_VOCAL */ + pwrap_write_field(PMIC_VSIM2_ANA_CON0, cali_mv / 10, 0xF, 0); +} + static void pmic_wdt_set(void) { /* [5]=1, RG_WDTRSTB_DEB */ diff --git a/src/soc/mediatek/mt8183/pll.c b/src/soc/mediatek/mt8183/pll.c index 07ce6603f6..5368077318 100644 --- a/src/soc/mediatek/mt8183/pll.c +++ b/src/soc/mediatek/mt8183/pll.c @@ -344,6 +344,12 @@ void mt_pll_init(void) /* enable infrasys DCM */ setbits_le32(&mt8183_infracfg->infra_bus_dcm_ctrl, 0x3 << 21); + clrsetbits_le32(&mt8183_infracfg->infra_bus_dcm_ctrl, + DCM_INFRA_BUS_MASK, DCM_INFRA_BUS_ON); + setbits_le32(&mt8183_infracfg->mem_dcm_ctrl, DCM_INFRA_MEM_ON); + clrbits_le32(&mt8183_infracfg->p2p_rx_clk_on, DCM_INFRA_P2PRX_MASK); + clrsetbits_le32(&mt8183_infracfg->peri_bus_dcm_ctrl, + DCM_INFRA_PERI_MASK, DCM_INFRA_PERI_ON); /* enable [11] for change i2c module source clock to TOPCKGEN */ setbits_le32(&mt8183_infracfg->module_clk_sel, 0x1 << 11); diff --git a/src/soc/mediatek/mt8183/spi.c b/src/soc/mediatek/mt8183/spi.c index a79dafba94..982f6439ed 100644 --- a/src/soc/mediatek/mt8183/spi.c +++ b/src/soc/mediatek/mt8183/spi.c @@ -109,7 +109,8 @@ void mtk_spi_set_gpio_pinmux(unsigned int bus, enum spi_pad_mask pad_select) gpio_set_mode((gpio_t){.id = ptr[i].pin_id}, ptr[i].func); } -void mtk_spi_set_timing(struct mtk_spi_regs *regs, u32 sck_ticks, u32 cs_ticks) +void mtk_spi_set_timing(struct mtk_spi_regs *regs, u32 sck_ticks, u32 cs_ticks, + unsigned int tick_dly) { write32(®s->spi_cfg0_reg, ((cs_ticks - 1) << SPI_CFG0_CS_HOLD_SHIFT) | @@ -119,7 +120,9 @@ void mtk_spi_set_timing(struct mtk_spi_regs *regs, u32 sck_ticks, u32 cs_ticks) ((sck_ticks - 1) << SPI_CFG2_SCK_HIGH_SHIFT) | ((sck_ticks - 1) << SPI_CFG2_SCK_LOW_SHIFT)); - clrsetbits_le32(®s->spi_cfg1_reg, SPI_CFG1_CS_IDLE_MASK, + clrsetbits_le32(®s->spi_cfg1_reg, SPI_CFG1_TICK_DLY_MASK | + SPI_CFG1_CS_IDLE_MASK, + (tick_dly << SPI_CFG1_TICK_DLY_SHIFT) | ((cs_ticks - 1) << SPI_CFG1_CS_IDLE_SHIFT)); } diff --git a/src/soc/qualcomm/common/qclib.c b/src/soc/qualcomm/common/qclib.c index 73c525001e..25512a938f 100644 --- a/src/soc/qualcomm/common/qclib.c +++ b/src/soc/qualcomm/common/qclib.c @@ -41,7 +41,7 @@ void qclib_add_if_table_entry(const char *name, void *base, struct qclib_cb_if_table_entry *te = &qclib_cb_if_table.te[qclib_cb_if_table.num_entries++]; assert(qclib_cb_if_table.num_entries <= qclib_cb_if_table.max_entries); - strncpy(te->name, name, sizeof(te->name)); + strncpy(te->name, name, sizeof(te->name) - 1); te->blob_address = (uintptr_t)base; te->size = size; te->blob_attributes = attrs; diff --git a/src/southbridge/amd/cimx/sb900/early.c b/src/southbridge/amd/cimx/sb900/early.c index 5ebe47e5fb..1aa9a5a4ba 100644 --- a/src/southbridge/amd/cimx/sb900/early.c +++ b/src/southbridge/amd/cimx/sb900/early.c @@ -39,7 +39,7 @@ void sb_poweron_init(void) //Enable/Disable PCI Bridge Device 14 Function 4. outb(0xEA, 0xCD6); data = inb(0xCD7); - data &= !BIT0; + data &= ~BIT0; if (!CONFIG(PCIB_ENABLE)) { data |= BIT0; } diff --git a/src/southbridge/amd/rs780/cmn.c b/src/southbridge/amd/rs780/cmn.c index 17ca98079a..1520748796 100644 --- a/src/southbridge/amd/rs780/cmn.c +++ b/src/southbridge/amd/rs780/cmn.c @@ -263,7 +263,6 @@ u8 PcieTrainPort(struct device *nb_dev, struct device *dev, u32 port) gfx_gpp_sb_sel = PCIE_CORE_INDEX_GPP; break; default: - gfx_gpp_sb_sel = -1; return 0; } diff --git a/src/southbridge/amd/sb700/fadt.c b/src/southbridge/amd/sb700/fadt.c index 4bc36221ad..4a5746ccd7 100644 --- a/src/southbridge/amd/sb700/fadt.c +++ b/src/southbridge/amd/sb700/fadt.c @@ -37,7 +37,7 @@ void acpi_create_fadt(acpi_fadt_t * fadt, acpi_facs_t * facs, void *dsdt) memset((void *)fadt, 0, sizeof(acpi_fadt_t)); memcpy(header->signature, "FACP", 4); header->length = 244; - header->revision = 3; + header->revision = get_acpi_table_revision(FADT); memcpy(header->oem_id, OEM_ID, 6); memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); memcpy(header->asl_compiler_id, ASLC, 4); diff --git a/src/southbridge/amd/sb700/sb700.c b/src/southbridge/amd/sb700/sb700.c index e3594fd583..1836f34eb0 100644 --- a/src/southbridge/amd/sb700/sb700.c +++ b/src/southbridge/amd/sb700/sb700.c @@ -104,7 +104,7 @@ void sb7xx_51xx_enable(struct device *dev) { struct device *sm_dev = NULL; struct device *bus_dev = NULL; - int index = -1; + int index; u32 deviceid; u32 vendorid; @@ -171,7 +171,6 @@ void sb7xx_51xx_enable(struct device *dev) index = 8; set_sm_enable_bits(sm_dev, 0xac, 1 << index, (dev->enabled ? 1 : 0) << index); - index += 32 * 3; break; case PCI_DEVFN(0x12, 0): case PCI_DEVFN(0x12, 1): @@ -179,7 +178,6 @@ void sb7xx_51xx_enable(struct device *dev) index = dev->path.pci.devfn & 3; set_sm_enable_bits(sm_dev, 0x68, 1 << index, (dev->enabled ? 1 : 0) << index); - index += 32 * 2; break; case PCI_DEVFN(0x13, 0): case PCI_DEVFN(0x13, 1): @@ -187,34 +185,27 @@ void sb7xx_51xx_enable(struct device *dev) index = (dev->path.pci.devfn & 3) + 4; set_sm_enable_bits(sm_dev, 0x68, 1 << index, (dev->enabled ? 1 : 0) << index); - index += 32 * 2; break; case PCI_DEVFN(0x14, 5): index = 7; set_sm_enable_bits(sm_dev, 0x68, 1 << index, (dev->enabled ? 1 : 0) << index); - index += 32 * 2; break; case PCI_DEVFN(0x14, 0): - index = 0; break; case PCI_DEVFN(0x14, 1): - index = 1; break; case PCI_DEVFN(0x14, 2): index = 3; set_pmio_enable_bits(sm_dev, 0x59, 1 << index, (dev->enabled ? 1 : 0) << index); - index += 32 * 4; break; case PCI_DEVFN(0x14, 3): index = 20; set_sm_enable_bits(sm_dev, 0x64, 1 << index, (dev->enabled ? 1 : 0) << index); - index += 32 * 1; break; case PCI_DEVFN(0x14, 4): - index = 4; break; default: printk(BIOS_DEBUG, "unknown dev: %s deviceid=%4x\n", dev_path(dev), diff --git a/src/southbridge/amd/sb800/fadt.c b/src/southbridge/amd/sb800/fadt.c index d94ac73b4a..71bdf2313b 100644 --- a/src/southbridge/amd/sb800/fadt.c +++ b/src/southbridge/amd/sb800/fadt.c @@ -37,7 +37,7 @@ void acpi_create_fadt(acpi_fadt_t * fadt, acpi_facs_t * facs, void *dsdt) memset((void *)fadt, 0, sizeof(acpi_fadt_t)); memcpy(header->signature, "FACP", 4); header->length = 244; - header->revision = 3; + header->revision = get_acpi_table_revision(FADT); memcpy(header->oem_id, OEM_ID, 6); memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); memcpy(header->asl_compiler_id, ASLC, 4); diff --git a/src/southbridge/amd/sb800/sb800.c b/src/southbridge/amd/sb800/sb800.c index eda4d304d3..801cc65e4a 100644 --- a/src/southbridge/amd/sb800/sb800.c +++ b/src/southbridge/amd/sb800/sb800.c @@ -228,7 +228,7 @@ void sb800_enable(struct device *dev) { struct device *sm_dev = NULL; struct device *bus_dev = NULL; - int index = -1; + int index; u32 deviceid; u32 vendorid; @@ -295,9 +295,9 @@ void sb800_enable(struct device *dev) switch (dev->path.pci.devfn - (devfn - (0x14 << 3))) { case PCI_DEVFN(0x11, 0): - index = 8; - set_pmio_enable_bits(0xDA, 1 << 0, - (dev->enabled ? 1 : 0) << 0); + index = 0; + set_pmio_enable_bits(0xDA, 1 << index, + (dev->enabled ? 1 : 0) << index); /* Set the device ID of SATA as 0x4390 to reduce the confusing. */ dword = pci_read_config32(dev, 0x40); dword |= 1 << 0; @@ -305,7 +305,6 @@ void sb800_enable(struct device *dev) pci_write_config16(dev, 0x2, 0x4390); dword &= ~1; pci_write_config32(dev, 0x40, dword);//for (;;); - index += 32 * 3; break; case PCI_DEVFN(0x12, 0): case PCI_DEVFN(0x12, 2): @@ -318,15 +317,13 @@ void sb800_enable(struct device *dev) index = (dev->path.pci.devfn & 0x3) / 2 + 2; set_pmio_enable_bits(0xEF, 1 << index, (dev->enabled ? 1 : 0) << index); - index += 32 * 2; break; case PCI_DEVFN(0x14, 0): - index = 0; break; case PCI_DEVFN(0x14, 1): - index = 1; - set_pmio_enable_bits(0xDA, 1 << 3, - (dev->enabled ? 0 : 1) << 3); + index = 3; + set_pmio_enable_bits(0xDA, 1 << index, + (dev->enabled ? 0 : 1) << index); break; case PCI_DEVFN(0x14, 2): index = 0; @@ -337,7 +334,6 @@ void sb800_enable(struct device *dev) index = 0; set_pmio_enable_bits(0xEC, 1 << index, (dev->enabled ? 1 : 0) << index); - index += 32 * 1; break; case PCI_DEVFN(0x14, 4): index = 0; @@ -356,7 +352,6 @@ void sb800_enable(struct device *dev) break; case PCI_DEVFN(0x15, 0): set_sb800_gpp(dev); - index = 4; break; case PCI_DEVFN(0x15, 1): case PCI_DEVFN(0x15, 2): diff --git a/src/southbridge/amd/sr5650/pcie.c b/src/southbridge/amd/sr5650/pcie.c index f87fadbb08..6c42fdde4d 100644 --- a/src/southbridge/amd/sr5650/pcie.c +++ b/src/southbridge/amd/sr5650/pcie.c @@ -59,11 +59,11 @@ static void PciePowerOffGppPorts(struct device *nb_dev, struct device *dev, u32 { printk(BIOS_DEBUG, "PciePowerOffGppPorts() port %d\n", port); u32 reg; - u16 state_save; + u32 state_save; uint8_t i; struct southbridge_amd_sr5650_config *cfg = (struct southbridge_amd_sr5650_config *)nb_dev->chip_info; - u16 state = cfg->port_enable; + u32 state = cfg->port_enable; if (!(AtiPcieCfg.Config & PCIE_DISABLE_HIDE_UNUSED_PORTS)) state &= AtiPcieCfg.PortDetect; diff --git a/src/southbridge/intel/bd82x6x/early_pch.c b/src/southbridge/intel/bd82x6x/early_pch.c index e74c3043f0..c1631f4229 100644 --- a/src/southbridge/intel/bd82x6x/early_pch.c +++ b/src/southbridge/intel/bd82x6x/early_pch.c @@ -27,6 +27,7 @@ #include #include "pch.h" +#include "chip.h" #define SOUTHBRIDGE PCI_DEV(0, 0x1f, 0) @@ -40,7 +41,6 @@ wait_iobp(void) static u32 read_iobp(u32 address) { - volatile u32 tmp; u32 ret; RCBA32(IOBPIRI) = address; @@ -48,14 +48,13 @@ read_iobp(u32 address) wait_iobp(); ret = RCBA32(IOBPD); wait_iobp(); - tmp = RCBA8(IOBPS); // call wait_iobp() instead here? + RCBA8(IOBPS); // call wait_iobp() instead here? return ret; } static void write_iobp(u32 address, u32 val) { - volatile u32 tmp; /* this function was probably pch_iobp_update with the andvalue * being 0. So either the IOBP read can be removed or this function * and the pch_iobp_update function in ramstage could be merged */ @@ -67,7 +66,7 @@ write_iobp(u32 address, u32 val) wait_iobp(); RCBA16(IOBPS) = (RCBA16(IOBPS) & 0x1ff) | 0x600; - tmp = RCBA8(IOBPS); // call wait_iobp() instead here? + RCBA8(IOBPS); // call wait_iobp() instead here? } void early_pch_init_native_dmi_pre(void) @@ -84,14 +83,12 @@ void early_pch_init_native_dmi_pre(void) void early_pch_init_native_dmi_post(void) { - volatile u32 tmp; - - tmp = RCBA32(0x0050); // !!! = 0x01200654 + RCBA32(0x0050); // !!! = 0x01200654 RCBA32(0x0050) = 0x01200654; - tmp = RCBA32(0x0050); // !!! = 0x01200654 + RCBA32(0x0050); // !!! = 0x01200654 RCBA32(0x0050) = 0x012a0654; - tmp = RCBA32(0x0050); // !!! = 0x012a0654 - tmp = RCBA8(0x1114); // !!! = 0x00 + RCBA32(0x0050); // !!! = 0x012a0654 + RCBA8(0x1114); // !!! = 0x00 RCBA8(0x1114) = 0x05; /* @@ -118,7 +115,7 @@ void early_pch_init_native_dmi_post(void) */ RCBA32(0x2020) = (1 << 31) | (1 << 24) | (0x11 << 1); /* Read back register */ - tmp = RCBA32(0x2020); + RCBA32(0x2020); /* Virtual Channel private Resource Control Register. * Enable channel. @@ -127,7 +124,7 @@ void early_pch_init_native_dmi_post(void) */ RCBA32(0x2030) = (1 << 31) | (2 << 24) | (0x22 << 1); /* Read back register */ - tmp = RCBA32(0x2030); + RCBA32(0x2030); /* Virtual Channel ME Resource Control Register. * Enable channel. @@ -139,7 +136,7 @@ void early_pch_init_native_dmi_post(void) /* Lock Virtual Channel Resource control register. */ RCBA32(0x0050) |= 0x80000000; /* Read back register */ - tmp = RCBA32(0x0050); + RCBA32(0x0050); /* Wait for virtual channels negotiation pending */ while (RCBA16(0x201a) & VCNEGPND) @@ -155,24 +152,23 @@ void early_pch_init_native_dmi_post(void) void early_pch_init_native (void) { - volatile u32 tmp; pci_write_config8 (SOUTHBRIDGE, 0xa6, pci_read_config8 (SOUTHBRIDGE, 0xa6) | 2); RCBA32(0x2088) = 0x00109000; - tmp = RCBA32(0x20ac); // !!! = 0x00000000 + RCBA32(0x20ac); // !!! = 0x00000000 RCBA32(0x20ac) = 0x40000000; RCBA32(0x100c) = 0x01110000; RCBA8(0x2340) = 0x1b; - tmp = RCBA32(0x2314); // !!! = 0x0a080000 + RCBA32(0x2314); // !!! = 0x0a080000 RCBA32(0x2314) = 0x0a280000; - tmp = RCBA32(0x2310); // !!! = 0xc809605b + RCBA32(0x2310); // !!! = 0xc809605b RCBA32(0x2310) = 0xa809605b; RCBA32(0x2324) = 0x00854c74; - tmp = RCBA8(0x0400); // !!! = 0x00 - tmp = RCBA32(0x2310); // !!! = 0xa809605b + RCBA8(0x0400); // !!! = 0x00 + RCBA32(0x2310); // !!! = 0xa809605b RCBA32(0x2310) = 0xa809605b; - tmp = RCBA32(0x2310); // !!! = 0xa809605b + RCBA32(0x2310); // !!! = 0xa809605b RCBA32(0x2310) = 0xa809605b; write_iobp(0xea007f62, 0x00590133); @@ -258,10 +254,31 @@ static void pch_generic_setup(void) write_pmbase16(TCO1_CNT, 1 << 11); /* halt timer */ } +static void pch_enable_lpc_gen_decode(void) +{ + const struct device *dev = pcidev_on_root(0x1f, 0); + const struct southbridge_intel_bd82x6x_config *config = NULL; + + /* Set up generic decode ranges */ + if (!dev) + return; + if (dev->chip_info) + config = dev->chip_info; + if (!config) + return; + + pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, config->gen1_dec); + pci_write_config32(PCH_LPC_DEV, LPC_GEN2_DEC, config->gen2_dec); + pci_write_config32(PCH_LPC_DEV, LPC_GEN3_DEC, config->gen3_dec); + pci_write_config32(PCH_LPC_DEV, LPC_GEN4_DEC, config->gen4_dec); +} + void early_pch_init(void) { pch_enable_lpc(); + pch_enable_lpc_gen_decode(); + pch_enable_bars(); pch_generic_setup(); diff --git a/src/southbridge/intel/bd82x6x/lpc.c b/src/southbridge/intel/bd82x6x/lpc.c index 773750186f..661c1d483d 100644 --- a/src/southbridge/intel/bd82x6x/lpc.c +++ b/src/southbridge/intel/bd82x6x/lpc.c @@ -908,12 +908,6 @@ static void lpc_final(struct device *dev) if (CONFIG(INTEL_CHIPSET_LOCKDOWN) || acpi_is_wakeup_s3()) { outb(APM_CNT_FINALIZE, APM_CNT); - if (CONFIG(CONSOLE_SPI_FLASH)) - /* Re-init SPI driver to handle locked BAR. - This prevents flashconsole from hanging. - If other code needs to use SPI during - ramstage, whitelist it here. */ - spi_init(); } } } diff --git a/src/southbridge/intel/common/Makefile.inc b/src/southbridge/intel/common/Makefile.inc index 4cf6e6f57e..deab85ff97 100644 --- a/src/southbridge/intel/common/Makefile.inc +++ b/src/southbridge/intel/common/Makefile.inc @@ -45,6 +45,7 @@ romstage-$(CONFIG_SOUTHBRIDGE_INTEL_COMMON_GPIO) += gpio.c ramstage-$(CONFIG_SOUTHBRIDGE_INTEL_COMMON_GPIO) += gpio.c smm-$(CONFIG_SOUTHBRIDGE_INTEL_COMMON_GPIO) += gpio.c +bootblock-$(CONFIG_SOUTHBRIDGE_INTEL_COMMON_SPI) += spi.c romstage-$(CONFIG_SOUTHBRIDGE_INTEL_COMMON_SPI) += spi.c postcar-$(CONFIG_SOUTHBRIDGE_INTEL_COMMON_SPI) += spi.c ramstage-$(CONFIG_SOUTHBRIDGE_INTEL_COMMON_SPI) += spi.c diff --git a/src/southbridge/intel/common/smbus.c b/src/southbridge/intel/common/smbus.c index af1eb602a0..e575abc40e 100644 --- a/src/southbridge/intel/common/smbus.c +++ b/src/southbridge/intel/common/smbus.c @@ -4,6 +4,7 @@ * Copyright (C) 2005 Yinghai Lu * Copyright (C) 2009 coresystems GmbH * Copyright (C) 2013 Vladimir Serbinenko + * Copyright (C) 2018-2019 Eltan B.V. * * 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 @@ -410,3 +411,47 @@ int do_i2c_eeprom_read(unsigned int smbus_base, u8 device, return ret; } + +/* + * The caller is responsible of settings HOSTC I2C_EN bit prior to making this + * call! + */ +int do_i2c_block_write(unsigned int smbus_base, u8 device, + unsigned int bytes, u8 *buf) +{ + u8 cmd; + int ret; + + if (!CONFIG(SOC_INTEL_BRASWELL)) + return SMBUS_ERROR; + + if (!bytes || (bytes > SMBUS_BLOCK_MAXLEN)) + return SMBUS_ERROR; + + /* Set up for a block data write. */ + ret = setup_command(smbus_base, I801_BLOCK_DATA, XMIT_WRITE(device)); + if (ret < 0) + return ret; + + /* + * In i2c mode SMBus controller sequence on bus will be: + * .. + * The SMBHSTCMD must be written also to ensure the SMBUs controller + * will generate the i2c sequence. + */ + cmd = *buf++; + bytes--; + outb(cmd, smbus_base + SMBHSTCMD); + outb(cmd, smbus_base + SMBHSTDAT1); + + /* Execute block transaction. */ + ret = block_cmd_loop(smbus_base, buf, bytes, BLOCK_WRITE); + if (ret < 0) + return ret; + + if (ret < bytes) + return SMBUS_ERROR; + + ret++; /* 1st byte has been written using SMBHSTDAT1 */ + return ret; +} diff --git a/src/southbridge/intel/common/smbus.h b/src/southbridge/intel/common/smbus.h index ded31d0ae2..4875581573 100644 --- a/src/southbridge/intel/common/smbus.h +++ b/src/southbridge/intel/common/smbus.h @@ -43,4 +43,6 @@ int do_smbus_block_write(unsigned int smbus_base, u8 device, /* Only since ICH5 */ int do_i2c_eeprom_read(unsigned int smbus_base, u8 device, unsigned int offset, unsigned int bytes, u8 *buf); +int do_i2c_block_write(unsigned int smbus_base, u8 device, + unsigned int bytes, u8 *buf); #endif diff --git a/src/southbridge/intel/common/spi.c b/src/southbridge/intel/common/spi.c index bf2a44c86c..e8c8f01407 100644 --- a/src/southbridge/intel/common/spi.c +++ b/src/southbridge/intel/common/spi.c @@ -38,11 +38,7 @@ static int spi_is_multichip(void); -typedef struct spi_slave ich_spi_slave; - -static int g_ichspi_lock = 0; - -typedef struct ich7_spi_regs { +struct ich7_spi_regs { uint16_t spis; uint16_t spic; uint32_t spia; @@ -53,9 +49,9 @@ typedef struct ich7_spi_regs { uint16_t optype; uint8_t opmenu[8]; uint32_t pbr[3]; -} __packed ich7_spi_regs; +} __packed; -typedef struct ich9_spi_regs { +struct ich9_spi_regs { uint32_t bfpr; uint16_t hsfs; uint16_t hsfc; @@ -86,15 +82,18 @@ typedef struct ich9_spi_regs { uint32_t srdl; uint32_t srdc; uint32_t srd; -} __packed ich9_spi_regs; +} __packed; -typedef struct ich_spi_controller { +struct ich_spi_controller { int locked; uint32_t flmap0; uint32_t flcomp; uint32_t hsfs; - ich9_spi_regs *ich9_spi; + union { + struct ich9_spi_regs *ich9_spi; + struct ich7_spi_regs *ich7_spi; + }; uint8_t *opmenu; int menubytes; uint16_t *preop; @@ -107,9 +106,9 @@ typedef struct ich_spi_controller { uint32_t *bbar; uint32_t *fpr; uint8_t fpr_max; -} ich_spi_controller; +}; -static ich_spi_controller g_cntlr; +static struct ich_spi_controller g_cntlr; enum { SPIS_SCIP = 0x0001, @@ -254,7 +253,7 @@ static void read_reg(const void *src, void *value, uint32_t size) static void ich_set_bbar(uint32_t minaddr) { - ich_spi_controller *cntlr = &g_cntlr; + struct ich_spi_controller *cntlr = &g_cntlr; const uint32_t bbar_mask = 0x00ffff00; uint32_t ichspi_bbar; @@ -266,12 +265,12 @@ static void ich_set_bbar(uint32_t minaddr) void spi_init(void) { - ich_spi_controller *cntlr = &g_cntlr; + struct ich_spi_controller *cntlr = &g_cntlr; uint8_t *rcrb; /* Root Complex Register Block */ uint32_t rcba; /* Root Complex Base Address */ uint8_t bios_cntl; - ich9_spi_regs *ich9_spi; - ich7_spi_regs *ich7_spi; + struct ich9_spi_regs *ich9_spi; + struct ich7_spi_regs *ich7_spi; uint16_t hsfs; #ifdef __SIMPLE_DEVICE__ @@ -284,7 +283,8 @@ void spi_init(void) /* Bits 31-14 are the base address, 13-1 are reserved, 0 is enable. */ rcrb = (uint8_t *)(rcba & 0xffffc000); if (CONFIG(SOUTHBRIDGE_INTEL_I82801GX)) { - ich7_spi = (ich7_spi_regs *)(rcrb + 0x3020); + ich7_spi = (struct ich7_spi_regs *)(rcrb + 0x3020); + cntlr->ich7_spi = ich7_spi; cntlr->opmenu = ich7_spi->opmenu; cntlr->menubytes = sizeof(ich7_spi->opmenu); cntlr->optype = &ich7_spi->optype; @@ -292,17 +292,15 @@ void spi_init(void) cntlr->data = (uint8_t *)ich7_spi->spid; cntlr->databytes = sizeof(ich7_spi->spid); cntlr->status = (uint8_t *)&ich7_spi->spis; - g_ichspi_lock = readw_(&ich7_spi->spis) & HSFS_FLOCKDN; cntlr->control = &ich7_spi->spic; cntlr->bbar = &ich7_spi->bbar; cntlr->preop = &ich7_spi->preop; cntlr->fpr = &ich7_spi->pbr[0]; cntlr->fpr_max = 3; } else { - ich9_spi = (ich9_spi_regs *)(rcrb + 0x3800); + ich9_spi = (struct ich9_spi_regs *)(rcrb + 0x3800); cntlr->ich9_spi = ich9_spi; hsfs = readw_(&ich9_spi->hsfs); - g_ichspi_lock = hsfs & HSFS_FLOCKDN; cntlr->hsfs = hsfs; cntlr->opmenu = ich9_spi->opmenu; cntlr->menubytes = sizeof(ich9_spi->opmenu); @@ -334,6 +332,16 @@ void spi_init(void) pci_write_config8(dev, 0xdc, bios_cntl | 0x1); } +static int spi_locked(void) +{ + struct ich_spi_controller *cntlr = &g_cntlr; + if (CONFIG(SOUTHBRIDGE_INTEL_I82801GX)) { + return !!(readw_(&cntlr->ich7_spi->spis) & HSFS_FLOCKDN); + } else { + return !!(readw_(&cntlr->ich9_spi->hsfs) | HSFS_FLOCKDN); + } +} + static void spi_init_cb(void *unused) { spi_init(); @@ -399,13 +407,13 @@ static void spi_setup_type(spi_transaction *trans) static int spi_setup_opcode(spi_transaction *trans) { - ich_spi_controller *cntlr = &g_cntlr; + struct ich_spi_controller *cntlr = &g_cntlr; uint16_t optypes; uint8_t opmenu[cntlr->menubytes]; trans->opcode = trans->out[0]; spi_use_out(trans, 1); - if (!g_ichspi_lock) { + if (!spi_locked()) { /* The lock is off, so just use index 0. */ writeb_(trans->opcode, cntlr->opmenu); optypes = readw_(cntlr->optype); @@ -480,7 +488,7 @@ static int spi_setup_offset(spi_transaction *trans) */ static int ich_status_poll(u16 bitmask, int wait_til_set) { - ich_spi_controller *cntlr = &g_cntlr; + struct ich_spi_controller *cntlr = &g_cntlr; int timeout = 600000; /* This will result in 6 seconds */ u16 status = 0; @@ -501,7 +509,7 @@ static int ich_status_poll(u16 bitmask, int wait_til_set) static int spi_is_multichip(void) { - ich_spi_controller *cntlr = &g_cntlr; + struct ich_spi_controller *cntlr = &g_cntlr; if (!(cntlr->hsfs & HSFS_FDV)) return 0; return !!((cntlr->flmap0 >> 8) & 3); @@ -510,7 +518,7 @@ static int spi_is_multichip(void) static int spi_ctrlr_xfer(const struct spi_slave *slave, const void *dout, size_t bytesout, void *din, size_t bytesin) { - ich_spi_controller *cntlr = &g_cntlr; + struct ich_spi_controller *cntlr = &g_cntlr; uint16_t control; int16_t opcode_index; int with_address; @@ -550,7 +558,7 @@ static int spi_ctrlr_xfer(const struct spi_slave *slave, const void *dout, * in order to prevent the Management Engine from * issuing a transaction between WREN and DATA. */ - if (!g_ichspi_lock) + if (!spi_locked()) writew_(trans.opcode, cntlr->preop); return 0; } @@ -660,7 +668,7 @@ spi_xfer_exit: /* Sets FLA in FADDR to (addr & 0x01FFFFFF) without touching other bits. */ static void ich_hwseq_set_addr(uint32_t addr) { - ich_spi_controller *cntlr = &g_cntlr; + struct ich_spi_controller *cntlr = &g_cntlr; uint32_t addr_old = readl_(&cntlr->ich9_spi->faddr) & ~0x01FFFFFF; writel_((addr & 0x01FFFFFF) | addr_old, &cntlr->ich9_spi->faddr); @@ -673,7 +681,7 @@ static void ich_hwseq_set_addr(uint32_t addr) static int ich_hwseq_wait_for_cycle_complete(unsigned int timeout, unsigned int len) { - ich_spi_controller *cntlr = &g_cntlr; + struct ich_spi_controller *cntlr = &g_cntlr; uint16_t hsfs; uint32_t addr; @@ -713,7 +721,7 @@ static int ich_hwseq_wait_for_cycle_complete(unsigned int timeout, static int ich_hwseq_erase(const struct spi_flash *flash, u32 offset, size_t len) { - ich_spi_controller *cntlr = &g_cntlr; + struct ich_spi_controller *cntlr = &g_cntlr; u32 start, end, erase_size; int ret; uint16_t hsfc; @@ -763,7 +771,7 @@ out: static void ich_read_data(uint8_t *data, int len) { - ich_spi_controller *cntlr = &g_cntlr; + struct ich_spi_controller *cntlr = &g_cntlr; int i; uint32_t temp32 = 0; @@ -778,7 +786,7 @@ static void ich_read_data(uint8_t *data, int len) static int ich_hwseq_read(const struct spi_flash *flash, u32 addr, size_t len, void *buf) { - ich_spi_controller *cntlr = &g_cntlr; + struct ich_spi_controller *cntlr = &g_cntlr; uint16_t hsfc; uint16_t timeout = 100 * 60; uint8_t block_len; @@ -824,7 +832,7 @@ static int ich_hwseq_read(const struct spi_flash *flash, u32 addr, size_t len, */ static void ich_fill_data(const uint8_t *data, int len) { - ich_spi_controller *cntlr = &g_cntlr; + struct ich_spi_controller *cntlr = &g_cntlr; uint32_t temp32 = 0; int i; @@ -848,7 +856,7 @@ static void ich_fill_data(const uint8_t *data, int len) static int ich_hwseq_write(const struct spi_flash *flash, u32 addr, size_t len, const void *buf) { - ich_spi_controller *cntlr = &g_cntlr; + struct ich_spi_controller *cntlr = &g_cntlr; uint16_t hsfc; uint16_t timeout = 100 * 60; uint8_t block_len; @@ -904,7 +912,7 @@ static const struct spi_flash_ops spi_flash_ops = { static int spi_flash_programmer_probe(const struct spi_slave *spi, struct spi_flash *flash) { - ich_spi_controller *cntlr = &g_cntlr; + struct ich_spi_controller *cntlr = &g_cntlr; if (CONFIG(SOUTHBRIDGE_INTEL_I82801GX)) return spi_flash_generic_probe(spi, flash); @@ -984,7 +992,7 @@ static int spi_flash_protect(const struct spi_flash *flash, const struct region *region, const enum ctrlr_prot_type type) { - ich_spi_controller *cntlr = &g_cntlr; + struct ich_spi_controller *cntlr = &g_cntlr; u32 start = region_offset(region); u32 end = start + region_sz(region) - 1; u32 reg; @@ -1030,8 +1038,7 @@ static int spi_flash_protect(const struct spi_flash *flash, /* Set the FPR register and verify it is protected */ write32(&fpr_base[fpr], reg); - reg = read32(&fpr_base[fpr]); - if (!(reg & protect_mask)) { + if (reg != read32(&fpr_base[fpr])) { printk(BIOS_ERR, "ERROR: Unable to set SPI FPR %d\n", fpr); return -1; } @@ -1043,7 +1050,7 @@ static int spi_flash_protect(const struct spi_flash *flash, static const struct spi_ctrlr spi_ctrlr = { .xfer_vector = xfer_vectors, - .max_xfer_size = member_size(ich9_spi_regs, fdata), + .max_xfer_size = member_size(struct ich9_spi_regs, fdata), .flash_probe = spi_flash_programmer_probe, .flash_protect = spi_flash_protect, }; diff --git a/src/southbridge/intel/ibexpeak/smihandler.c b/src/southbridge/intel/ibexpeak/smihandler.c index dbc412c072..208075bbea 100644 --- a/src/southbridge/intel/ibexpeak/smihandler.c +++ b/src/southbridge/intel/ibexpeak/smihandler.c @@ -24,7 +24,10 @@ #include #include #include +#include +#include #include +#include #include "pch.h" #include "nvs.h" @@ -182,4 +185,8 @@ void southbridge_update_gnvs(u8 apm_cnt, int *smm_done) void southbridge_finalize_all(void) { + intel_me_finalize_smm(); + intel_pch_finalize_smm(); + intel_nehalem_finalize_smm(); + intel_model_2065x_finalize_smm(); } diff --git a/src/southbridge/nvidia/ck804/fadt.c b/src/southbridge/nvidia/ck804/fadt.c index 6a096617f3..713a51ea0a 100644 --- a/src/southbridge/nvidia/ck804/fadt.c +++ b/src/southbridge/nvidia/ck804/fadt.c @@ -33,13 +33,8 @@ void acpi_create_fadt(acpi_fadt_t * fadt, acpi_facs_t * facs, void *dsdt) /* Prepare the header */ memset((void *)fadt, 0, sizeof(acpi_fadt_t)); memcpy(header->signature, "FACP", 4); -#ifdef LONG_FADT - header->length = 244; - header->revision = 3; -#else - header->length = 0x74; - header->revision = 1; -#endif + header->length = sizeof(acpi_fadt_t); + header->revision = get_acpi_table_revision(FADT); memcpy(header->oem_id, OEM_ID, 6); memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); memcpy(header->asl_compiler_id, ASLC, 4); diff --git a/src/southbridge/nvidia/ck804/lpc.c b/src/southbridge/nvidia/ck804/lpc.c index 21235548a0..8caa8ed1ee 100644 --- a/src/southbridge/nvidia/ck804/lpc.c +++ b/src/southbridge/nvidia/ck804/lpc.c @@ -124,10 +124,9 @@ static void lpc_init(struct device *dev) get_option(&on, "slow_cpu"); if (on) { u16 pm10_bar; - u32 dword; pm10_bar = (pci_read_config16(dev, 0x60) & 0xff00); outl(((on << 1) + 0x10), (pm10_bar + 0x10)); - dword = inl(pm10_bar + 0x10); + inl(pm10_bar + 0x10); on = 8 - on; printk(BIOS_DEBUG, "Throttling CPU %2d.%1.1d percent.\n", (on * 12) + (on >> 1), (on & 1) * 5); diff --git a/src/superio/nuvoton/common/early_serial.c b/src/superio/nuvoton/common/early_serial.c index b35ec9d8b9..eaa3c5af64 100644 --- a/src/superio/nuvoton/common/early_serial.c +++ b/src/superio/nuvoton/common/early_serial.c @@ -64,9 +64,15 @@ void nuvoton_pnp_exit_conf_state(pnp_devfn_t dev) void nuvoton_enable_serial(pnp_devfn_t dev, u16 iobase) { nuvoton_pnp_enter_conf_state(dev); + if (CONFIG(SUPERIO_NUVOTON_NCT6776_COM_A)) - /* Route GPIO8 pin group to COM A */ + /* Route COM A to GPIO8 pin group */ pnp_write_config(dev, 0x2a, 0x40); + + if (CONFIG(SUPERIO_NUVOTON_NCT6791D_COM_A)) + /* Route COM A to GPIO8 pin group */ + pnp_write_config(dev, 0x2a, 0x00); + pnp_set_logical_device(dev); pnp_set_enable(dev, 0); pnp_set_iobase(dev, PNP_IDX_IO0, iobase); diff --git a/src/superio/nuvoton/nct6776/Kconfig b/src/superio/nuvoton/nct6776/Kconfig index 90d4d32555..441692bddd 100644 --- a/src/superio/nuvoton/nct6776/Kconfig +++ b/src/superio/nuvoton/nct6776/Kconfig @@ -20,4 +20,5 @@ config SUPERIO_NUVOTON_NCT6776 config SUPERIO_NUVOTON_NCT6776_COM_A bool + depends on SUPERIO_NUVOTON_NCT6776 default n diff --git a/src/superio/nuvoton/nct6791d/Kconfig b/src/superio/nuvoton/nct6791d/Kconfig index 6e39e462aa..55581fbcfe 100644 --- a/src/superio/nuvoton/nct6791d/Kconfig +++ b/src/superio/nuvoton/nct6791d/Kconfig @@ -16,3 +16,8 @@ config SUPERIO_NUVOTON_NCT6791D bool select SUPERIO_NUVOTON_COMMON_PRE_RAM + +config SUPERIO_NUVOTON_NCT6791D_COM_A + bool + depends on SUPERIO_NUVOTON_NCT6791D + default n diff --git a/src/vendorcode/amd/agesa/f12/Proc/GNB/Modules/GnbPcieConfig/PcieConfigLib.c b/src/vendorcode/amd/agesa/f12/Proc/GNB/Modules/GnbPcieConfig/PcieConfigLib.c index ee7ef01035..c76b290727 100644 --- a/src/vendorcode/amd/agesa/f12/Proc/GNB/Modules/GnbPcieConfig/PcieConfigLib.c +++ b/src/vendorcode/amd/agesa/f12/Proc/GNB/Modules/GnbPcieConfig/PcieConfigLib.c @@ -202,7 +202,7 @@ PcieConfigGetNumberOfPhyLane ( IN PCIe_ENGINE_CONFIG *Engine ) { - if (Engine->EngineData.StartLane >= UNUSED_LANE_ID || Engine->EngineData.StartLane >= UNUSED_LANE_ID) { + if (Engine->EngineData.StartLane >= UNUSED_LANE_ID || Engine->EngineData.EndLane >= UNUSED_LANE_ID) { return 0; } if (Engine->EngineData.StartLane > Engine->EngineData.EndLane) { diff --git a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/PcieConfigLib.c b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/PcieConfigLib.c index 788c0b779a..dae9899683 100644 --- a/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/PcieConfigLib.c +++ b/src/vendorcode/amd/agesa/f14/Proc/GNB/Modules/GnbPcieConfig/PcieConfigLib.c @@ -178,7 +178,7 @@ PcieConfigGetNumberOfPhyLane ( IN PCIe_ENGINE_CONFIG *Engine ) { - if (Engine->EngineData.StartLane >= UNUSED_LANE_ID || Engine->EngineData.StartLane >= UNUSED_LANE_ID) { + if (Engine->EngineData.StartLane >= UNUSED_LANE_ID || Engine->EngineData.EndLane >= UNUSED_LANE_ID) { return 0; } if (Engine->EngineData.StartLane > Engine->EngineData.EndLane) { diff --git a/src/vendorcode/amd/agesa/f15tn/Proc/GNB/Modules/GnbPcieConfig/PcieConfigLib.c b/src/vendorcode/amd/agesa/f15tn/Proc/GNB/Modules/GnbPcieConfig/PcieConfigLib.c index 6466862194..9b7bcbded2 100644 --- a/src/vendorcode/amd/agesa/f15tn/Proc/GNB/Modules/GnbPcieConfig/PcieConfigLib.c +++ b/src/vendorcode/amd/agesa/f15tn/Proc/GNB/Modules/GnbPcieConfig/PcieConfigLib.c @@ -205,7 +205,7 @@ PcieConfigGetNumberOfPhyLane ( IN PCIe_ENGINE_CONFIG *Engine ) { - if (Engine->EngineData.StartLane >= UNUSED_LANE_ID || Engine->EngineData.StartLane >= UNUSED_LANE_ID) { + if (Engine->EngineData.StartLane >= UNUSED_LANE_ID || Engine->EngineData.EndLane >= UNUSED_LANE_ID) { return 0; } if (Engine->EngineData.StartLane > Engine->EngineData.EndLane) { diff --git a/src/vendorcode/amd/agesa/f15tn/Proc/IDS/Library/IdsLib.c b/src/vendorcode/amd/agesa/f15tn/Proc/IDS/Library/IdsLib.c index 34a12a78e6..046d1826aa 100644 --- a/src/vendorcode/amd/agesa/f15tn/Proc/IDS/Library/IdsLib.c +++ b/src/vendorcode/amd/agesa/f15tn/Proc/IDS/Library/IdsLib.c @@ -900,7 +900,7 @@ IdsCheckPciExisit ( _pciaddr = PciAddr; _pciaddr.Address.Register = 0; LibAmdPciRead (AccessWidth32, _pciaddr, &_pcidata, StdHeader); - if (_pcidata != 0xFFFFFFFF || _pcidata != 0) { + if (_pcidata != 0xFFFFFFFF && _pcidata != 0) { status = TRUE; } return status; diff --git a/src/vendorcode/amd/agesa/f16kb/Proc/GNB/Modules/GnbPcieConfig/PcieConfigLib.c b/src/vendorcode/amd/agesa/f16kb/Proc/GNB/Modules/GnbPcieConfig/PcieConfigLib.c index 8e5e3dd43a..27e7bcefda 100644 --- a/src/vendorcode/amd/agesa/f16kb/Proc/GNB/Modules/GnbPcieConfig/PcieConfigLib.c +++ b/src/vendorcode/amd/agesa/f16kb/Proc/GNB/Modules/GnbPcieConfig/PcieConfigLib.c @@ -205,7 +205,7 @@ PcieConfigGetNumberOfPhyLane ( IN PCIe_ENGINE_CONFIG *Engine ) { - if (Engine->EngineData.StartLane >= UNUSED_LANE_ID || Engine->EngineData.StartLane >= UNUSED_LANE_ID) { + if (Engine->EngineData.StartLane >= UNUSED_LANE_ID || Engine->EngineData.EndLane >= UNUSED_LANE_ID) { return 0; } if (Engine->EngineData.StartLane > Engine->EngineData.EndLane) { diff --git a/src/vendorcode/amd/agesa/f16kb/Proc/IDS/Library/IdsLib.c b/src/vendorcode/amd/agesa/f16kb/Proc/IDS/Library/IdsLib.c index 0cb0a63680..b7a49b27f1 100644 --- a/src/vendorcode/amd/agesa/f16kb/Proc/IDS/Library/IdsLib.c +++ b/src/vendorcode/amd/agesa/f16kb/Proc/IDS/Library/IdsLib.c @@ -983,7 +983,7 @@ IdsCheckPciExisit ( _pciaddr = PciAddr; _pciaddr.Address.Register = 0; LibAmdPciRead (AccessWidth32, _pciaddr, &_pcidata, StdHeader); - if (_pcidata != 0xFFFFFFFF || _pcidata != 0) { + if (_pcidata != 0xFFFFFFFF && _pcidata != 0) { status = TRUE; } return status; diff --git a/src/vendorcode/cavium/bdk/lame_string.c b/src/vendorcode/cavium/bdk/lame_string.c index 11c5add209..3906ca5904 100644 --- a/src/vendorcode/cavium/bdk/lame_string.c +++ b/src/vendorcode/cavium/bdk/lame_string.c @@ -11,6 +11,7 @@ */ #include +#include #include #include diff --git a/src/vendorcode/cavium/bdk/libdram/dram-spd.c b/src/vendorcode/cavium/bdk/libdram/dram-spd.c index 1296119b65..84df69a923 100644 --- a/src/vendorcode/cavium/bdk/libdram/dram-spd.c +++ b/src/vendorcode/cavium/bdk/libdram/dram-spd.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include diff --git a/src/vendorcode/google/chromeos/vpd_mac.c b/src/vendorcode/google/chromeos/vpd_mac.c index e3ef04b669..fcd3efec9e 100644 --- a/src/vendorcode/google/chromeos/vpd_mac.c +++ b/src/vendorcode/google/chromeos/vpd_mac.c @@ -15,6 +15,7 @@ #include #include +#include #include #include diff --git a/toolchain.inc b/toolchain.inc index 0486287444..875cb20387 100644 --- a/toolchain.inc +++ b/toolchain.inc @@ -131,7 +131,7 @@ OBJDUMP_$(1) := $(OBJDUMP_$(2)) STRIP_$(1) := $(STRIP_$(2)) READELF_$(1) := $(READELF_$(2)) CFLAGS_$(1) = $$(CFLAGS_common) $$(CFLAGS_$(2)) -ADAFLAGS_$(1) = --RTS=$$(obj)/libgnat-$(2)/ $$(ADAFLAGS_common) $$(GCC_CFLAGS_$(2)) +ADAFLAGS_$(1) = --RTS=$$(obj)/libgnat-$(2)/ $$(ADAFLAGS_common) $$(GCC_ADAFLAGS_$(2)) CPPFLAGS_$(1) = $$(CPPFLAGS_common) $$(CPPFLAGS_$(2)) -D__ARCH_$(2)__ COMPILER_RT_$(1) := $$(COMPILER_RT_$(2)) COMPILER_RT_FLAGS_$(1) := $$(COMPILER_RT_FLAGS_$(2)) diff --git a/util/amdfwtool/amdfwtool.c b/util/amdfwtool/amdfwtool.c index ac9ee48888..37dbcd093f 100644 --- a/util/amdfwtool/amdfwtool.c +++ b/util/amdfwtool/amdfwtool.c @@ -90,6 +90,8 @@ #define PSP_COOKIE 0x50535024 /* 'PSP$' */ #define PSPL2_COOKIE 0x324c5024 /* '2LP$' */ #define PSP2_COOKIE 0x50535032 /* 'PSP2' */ +#define BDT1_COOKIE 0x44484224 /* 'DHB$ */ +#define BDT2_COOKIE 0x324c4224 /* '2LB$ */ /* * Beginning with Family 15h Models 70h-7F, a.k.a Stoney Ridge, the PSP @@ -193,6 +195,28 @@ static void usage(void) printf("-w | --smufirmware2 Add smufirmware2\n"); printf("-m | --smuscs Add smuscs\n"); printf("-T | --soft-fuse Override default soft fuse values\n"); + printf("-z | --abl-image Add AGESA Binary\n"); + printf("-J | --sec-gasket Add security gasket\n"); + printf("-B | --mp2-fw Add MP2 firmware\n"); + printf("-N | --secdebug Add secure unlock image\n"); + printf("-U | --token-unlock Reserve space for debug token\n"); + printf("-K | --drv-entry-pts Add PSP driver entry points\n"); + printf("-L | --ikek Add Wrapped iKEK\n"); + printf("-Y | --s0i3drv Add s0i3 driver\n"); + printf("\nBIOS options:\n"); + printf("-I | --instance Sets instance field for the next BIOS firmware\n"); + printf("-a | --apcb Add AGESA PSP customization block\n"); + printf("-Q | --apob-base Destination for AGESA PSP output block\n"); + printf("-F | --apob-nv-base Location of S3 resume data\n"); + printf("-H | --apob-nv-size Size of S3 resume data\n"); + printf("-y | --pmu-inst Add PMU firmware instruction portion\n"); + printf("-G | --pmu-data Add PMU firmware data portion\n"); + printf("-u | --ucode Add microcode patch\n"); + printf("-X | --mp2-config Add MP2 configuration\n"); + printf("-V | --bios-bin Add compressed image; auto source address\n"); + printf("-e | --bios-bin-src Address in flash of source if -V not used\n"); + printf("-v | --bios-bin-dest Destination for uncompressed BIOS\n"); + printf("-j | --bios-uncomp-size Uncompressed size of BIOS image\n"); printf("\n-o | --output output filename\n"); printf("-f | --flashsize ROM size in bytes\n"); printf(" size must be larger than %dKB\n", @@ -202,6 +226,39 @@ static void usage(void) printf("-h | --help show this help\n"); } +typedef enum _amd_bios_type { + AMD_BIOS_APCB = 0x60, + AMD_BIOS_APOB = 0x61, + AMD_BIOS_BIN = 0x62, + AMD_BIOS_APOB_NV = 0x63, + AMD_BIOS_PMUI = 0x64, + AMD_BIOS_PMUD = 0x65, + AMD_BIOS_UCODE = 0x66, + AMD_BIOS_APCB_BK = 0x68, + AMD_BIOS_MP2_CFG = 0x6a, + AMD_BIOS_L2_PTR = 0x70, + AMD_BIOS_INVALID, +} amd_bios_type; + +#define BDT_LVL1 0x1 +#define BDT_LVL2 0x2 +#define BDT_BOTH (BDT_LVL1 | BDT_LVL2) +typedef struct _amd_bios_entry { + amd_bios_type type; + int region_type; + int reset; + int copy; + int ro; + int zlib; + int inst; + int subpr; + uint64_t src; + uint64_t dest; + size_t size; + char *filename; + int level; +} amd_bios_entry; + typedef enum _amd_fw_type { AMD_FW_PSP_PUBKEY = 0, AMD_FW_PSP_BOOTLOADER = 1, @@ -216,6 +273,22 @@ typedef enum _amd_fw_type { AMD_FW_PSP_SMU_FIRMWARE2 = 18, AMD_PSP_FUSE_CHAIN = 11, AMD_FW_PSP_SMUSCS = 95, + AMD_DEBUG_UNLOCK = 0x13, + AMD_WRAPPED_IKEK = 0x21, + AMD_TOKEN_UNLOCK = 0x22, + AMD_SEC_GASKET = 0x24, + AMD_MP2_FW = 0x25, + AMD_DRIVER_ENTRIES = 0x28, + AMD_S0I3_DRIVER = 0x2d, + AMD_ABL0 = 0x30, + AMD_ABL1 = 0x31, + AMD_ABL2 = 0x32, + AMD_ABL3 = 0x33, + AMD_ABL4 = 0x34, + AMD_ABL5 = 0x35, + AMD_ABL6 = 0x36, + AMD_ABL7 = 0x37, + AMD_FW_PSP_WHITELIST = 0x3a, AMD_FW_L2_PTR = 0x40, AMD_FW_IMC, AMD_FW_GEC, @@ -252,8 +325,26 @@ static amd_fw_entry amd_psp_fw_table[] = { { .type = AMD_FW_PSP_SMU_FIRMWARE2, .level = PSP_BOTH }, { .type = AMD_FW_PSP_SMUSCS, .level = PSP_BOTH }, { .type = AMD_PSP_FUSE_CHAIN, .level = PSP_LVL2 }, + { .type = AMD_DEBUG_UNLOCK, .level = PSP_LVL2 }, + { .type = AMD_WRAPPED_IKEK, .level = PSP_BOTH }, + { .type = AMD_TOKEN_UNLOCK, .level = PSP_BOTH }, + { .type = AMD_SEC_GASKET, .subprog = 2, .level = PSP_BOTH }, + { .type = AMD_SEC_GASKET, .subprog = 1, .level = PSP_BOTH }, + { .type = AMD_MP2_FW, .subprog = 2, .level = PSP_LVL2 }, + { .type = AMD_MP2_FW, .subprog = 1, .level = PSP_LVL2 }, + { .type = AMD_DRIVER_ENTRIES, .level = PSP_LVL2 }, + { .type = AMD_S0I3_DRIVER, .level = PSP_LVL2 }, + { .type = AMD_ABL0, .level = PSP_BOTH }, + { .type = AMD_ABL1, .level = PSP_BOTH }, + { .type = AMD_ABL2, .level = PSP_BOTH }, + { .type = AMD_ABL3, .level = PSP_BOTH }, + { .type = AMD_ABL4, .level = PSP_BOTH }, + { .type = AMD_ABL5, .level = PSP_BOTH }, + { .type = AMD_ABL6, .level = PSP_BOTH }, + { .type = AMD_ABL7, .level = PSP_BOTH }, { .type = AMD_FW_PSP_SMU_FIRMWARE, .subprog = 1, .level = PSP_BOTH }, { .type = AMD_FW_PSP_SMU_FIRMWARE2, .subprog = 1, .level = PSP_BOTH }, + { .type = AMD_FW_PSP_WHITELIST, .level = PSP_LVL2 }, { .type = AMD_FW_INVALID }, }; @@ -264,6 +355,28 @@ static amd_fw_entry amd_fw_table[] = { { .type = AMD_FW_INVALID }, }; +static amd_bios_entry amd_bios_table[] = { + { .type = AMD_BIOS_APCB, .level = BDT_BOTH }, + { .type = AMD_BIOS_APCB_BK, .level = BDT_BOTH }, + { .type = AMD_BIOS_APOB, .level = BDT_BOTH }, + { .type = AMD_BIOS_BIN, + .reset = 1, .copy = 1, .zlib = 1, .level = BDT_BOTH }, + { .type = AMD_BIOS_APOB_NV, .level = BDT_LVL2 }, + { .type = AMD_BIOS_PMUI, .inst = 1, .subpr = 0, .level = BDT_BOTH }, + { .type = AMD_BIOS_PMUD, .inst = 1, .subpr = 0, .level = BDT_BOTH }, + { .type = AMD_BIOS_PMUI, .inst = 4, .subpr = 0, .level = BDT_BOTH }, + { .type = AMD_BIOS_PMUD, .inst = 4, .subpr = 0, .level = BDT_BOTH }, + { .type = AMD_BIOS_PMUI, .inst = 1, .subpr = 1, .level = BDT_BOTH }, + { .type = AMD_BIOS_PMUD, .inst = 1, .subpr = 1, .level = BDT_BOTH }, + { .type = AMD_BIOS_PMUI, .inst = 4, .subpr = 1, .level = BDT_BOTH }, + { .type = AMD_BIOS_PMUD, .inst = 4, .subpr = 1, .level = BDT_BOTH }, + { .type = AMD_BIOS_UCODE, .inst = 0, .level = BDT_LVL2 }, + { .type = AMD_BIOS_UCODE, .inst = 1, .level = BDT_LVL2 }, + { .type = AMD_BIOS_UCODE, .inst = 2, .level = BDT_LVL2 }, + { .type = AMD_BIOS_MP2_CFG, .level = BDT_LVL2 }, + { .type = AMD_BIOS_INVALID }, +}; + typedef struct _embedded_firmware { uint32_t signature; /* 0x55aa55aa */ uint32_t imc_entry; @@ -271,6 +384,8 @@ typedef struct _embedded_firmware { uint32_t xhci_entry; uint32_t psp_entry; uint32_t comboable; + uint32_t bios0_entry; /* todo: add way to select correct entry */ + uint32_t bios1_entry; } __attribute__((packed, aligned(16))) embedded_firmware; typedef struct _psp_directory_header { @@ -316,6 +431,34 @@ typedef struct _psp_combo_directory { #define MAX_COMBO_ENTRIES 1 +typedef struct _bios_directory_hdr { + uint32_t cookie; + uint32_t checksum; + uint32_t num_entries; + uint32_t reserved; +} __attribute__((packed, aligned(16))) bios_directory_hdr; + +typedef struct _bios_directory_entry { + uint8_t type; + uint8_t region_type; + int reset:1; + int copy:1; + int ro:1; + int compressed:1; + int inst:4; + uint8_t subprog; /* b[7:3] reserved */ + uint32_t size; + uint64_t source; + uint64_t dest; +} __attribute__((packed)) bios_directory_entry; + +typedef struct _bios_directory_table { + bios_directory_hdr header; + bios_directory_entry entries[]; +} bios_directory_table; + +#define MAX_BIOS_ENTRIES 0x1f + typedef struct _context { char *rom; /* target buffer, size of flash device */ uint32_t rom_size; /* size of flash device */ @@ -365,6 +508,7 @@ static void fill_dir_header(void *directory, uint32_t count, uint32_t cookie) { psp_combo_directory *cdir = directory; psp_directory_table *dir = directory; + bios_directory_table *bdir = directory; if (!count) return; @@ -394,6 +538,17 @@ static void fill_dir_header(void *directory, uint32_t count, uint32_t cookie) + sizeof(dir->header.num_entries) + sizeof(dir->header.reserved)); break; + case BDT1_COOKIE: + case BDT2_COOKIE: + bdir->header.cookie = cookie; + bdir->header.num_entries = count; + bdir->header.reserved = 0; + /* checksum everything that comes after the Checksum field */ + bdir->header.checksum = fletcher32(&bdir->header.num_entries, + count * sizeof(bios_directory_entry) + + sizeof(bdir->header.num_entries) + + sizeof(bdir->header.reserved)); + break; } } @@ -500,7 +655,18 @@ static void integrate_psp_firmwares(context *ctx, if (!(fw_table[i].level & level)) continue; - if (fw_table[i].type == AMD_PSP_FUSE_CHAIN) { + if (fw_table[i].type == AMD_TOKEN_UNLOCK) { + if (!fw_table[i].other) + continue; + ctx->current = ALIGN(ctx->current, ERASE_ALIGNMENT); + pspdir->entries[count].type = fw_table[i].type; + pspdir->entries[count].size = 4096; /* TODO: doc? */ + pspdir->entries[count].addr = RUN_CURRENT(*ctx); + pspdir->entries[count].subprog = fw_table[i].subprog; + pspdir->entries[count].rsvd = 0; + ctx->current = ALIGN(ctx->current + 4096, 0x100U); + count++; + } else if (fw_table[i].type == AMD_PSP_FUSE_CHAIN) { pspdir->entries[count].type = fw_table[i].type; pspdir->entries[count].subprog = fw_table[i].subprog; pspdir->entries[count].rsvd = 0; @@ -575,13 +741,244 @@ static void integrate_psp_firmwares(context *ctx, fill_dir_header(pspdir, count, cookie); } -static const char *optstring = "x:i:g:AMS:p:b:s:r:k:c:n:d:t:u:w:m:T:o:f:l:h"; +static void *new_bios_dir(context *ctx, int multi) +{ + void *ptr; + + /* + * Force both onto boundary when multi. Primary table is after + * updatable table, so alignment ensures primary can stay intact + * if secondary is reprogrammed. + */ + if (multi) + ctx->current = ALIGN(ctx->current, TABLE_ERASE_ALIGNMENT); + else + ctx->current = ALIGN(ctx->current, TABLE_ALIGNMENT); + ptr = BUFF_CURRENT(*ctx); + ctx->current += sizeof(bios_directory_hdr) + + MAX_BIOS_ENTRIES * sizeof(bios_directory_entry); + return ptr; +} + +static int locate_bdt2_bios(bios_directory_table *level2, + uint64_t *source, uint32_t *size) +{ + int i; + + *source = 0; + *size = 0; + if (!level2) + return 0; + + for (i = 0 ; i < level2->header.num_entries ; i++) { + if (level2->entries[i].type == AMD_BIOS_BIN) { + *source = level2->entries[i].source; + *size = level2->entries[i].size; + return 1; + } + } + return 0; +} + +static int have_bios_tables(amd_bios_entry *table) +{ + int i; + + for (i = 0 ; table[i].type != AMD_BIOS_INVALID; i++) { + if (table[i].level & BDT_LVL1 && table[i].filename) + return 1; + } + return 0; +} + +static void integrate_bios_firmwares(context *ctx, + bios_directory_table *biosdir, + bios_directory_table *biosdir2, + amd_bios_entry *fw_table, + uint32_t cookie) +{ + ssize_t bytes; + unsigned int i, j, count; + int level; + + /* This function can create a primary table, a secondary table, or a + * flattened table which contains all applicable types. These if-else + * statements infer what the caller intended. If a 2nd-level cookie + * is passed, clearly a 2nd-level table is intended. However, a + * 1st-level cookie may indicate level 1 or flattened. If the caller + * passes a pointer to a 2nd-level table, then assume not flat. + */ + if (cookie == BDT2_COOKIE) + level = BDT_LVL2; + else if (biosdir2) + level = BDT_LVL1; + else + level = BDT_BOTH; + + ctx->current = ALIGN(ctx->current, BLOB_ALIGNMENT); + + for (i = 0, count = 0; fw_table[i].type != AMD_BIOS_INVALID; i++) { + if (!(fw_table[i].level & level)) + continue; + if (fw_table[i].filename == NULL && ( + fw_table[i].type != AMD_BIOS_APOB && + fw_table[i].type != AMD_BIOS_APOB_NV && + fw_table[i].type != AMD_BIOS_L2_PTR && + fw_table[i].type != AMD_BIOS_BIN)) + continue; + /* APOB_NV needs a size, else no S3 and skip item */ + if (fw_table[i].type == AMD_BIOS_APOB_NV && !fw_table[i].size) + continue; + + /* BIOS Directory items may have additional requirements */ + + /* APOB_NV must have a size if it has a source */ + if (fw_table[i].type == AMD_BIOS_APOB_NV && fw_table[i].src) { + if (!fw_table[i].size) { + printf("Error: APOB NV address provided, but no size\n"); + free(ctx->rom); + exit(1); + } + } + + /* APOB_DATA needs destination */ + if (fw_table[i].type == AMD_BIOS_APOB && !fw_table[i].dest) { + printf("Error: APOB destination not provided\n"); + free(ctx->rom); + exit(1); + } + + /* BIOS binary must have destination and uncompressed size. If + * no filename given, then user must provide a source address. + */ + if (fw_table[i].type == AMD_BIOS_BIN) { + if (!fw_table[i].dest || !fw_table[i].size) { + printf("Error: BIOS binary destination and uncompressed size are required\n"); + free(ctx->rom); + exit(1); + } + if (!fw_table[i].filename && !fw_table[i].src) { + printf("Error: BIOS binary assumed outside amdfw.rom but no source address given\n"); + free(ctx->rom); + exit(1); + } + } + + biosdir->entries[count].type = fw_table[i].type; + biosdir->entries[count].region_type = fw_table[i].region_type; + biosdir->entries[count].dest = fw_table[i].dest ? + fw_table[i].dest : (uint64_t)-1; + biosdir->entries[count].reset = fw_table[i].reset; + biosdir->entries[count].copy = fw_table[i].copy; + biosdir->entries[count].ro = fw_table[i].ro; + biosdir->entries[count].compressed = fw_table[i].zlib; + biosdir->entries[count].inst = fw_table[i].inst; + biosdir->entries[count].subprog = fw_table[i].subpr; + + switch (fw_table[i].type) { + case AMD_BIOS_APOB: + biosdir->entries[count].size = fw_table[i].size; + biosdir->entries[count].source = fw_table[i].src; + break; + case AMD_BIOS_APOB_NV: + if (fw_table[i].src) { + /* If source is given, use that and its size */ + biosdir->entries[count].source = fw_table[i].src; + biosdir->entries[count].size = fw_table[i].size; + } else { + /* Else reserve size bytes within amdfw.rom */ + ctx->current = ALIGN(ctx->current, ERASE_ALIGNMENT); + biosdir->entries[count].source = RUN_CURRENT(*ctx); + biosdir->entries[count].size = ALIGN( + fw_table[i].size, ERASE_ALIGNMENT); + memset(BUFF_CURRENT(*ctx), 0xff, + biosdir->entries[count].size); + ctx->current = ctx->current + + biosdir->entries[count].size; + } + break; + case AMD_BIOS_BIN: + /* Don't make a 2nd copy, point to the same one */ + if (level == BDT_LVL1 && locate_bdt2_bios(biosdir2, + &biosdir->entries[count].source, + &biosdir->entries[count].size)) + break; + + /* level 2, or level 1 and no copy found in level 2 */ + biosdir->entries[count].source = fw_table[i].src; + biosdir->entries[count].dest = fw_table[i].dest; + biosdir->entries[count].size = fw_table[i].size; + + if (!fw_table[i].filename) + break; + + bytes = copy_blob(BUFF_CURRENT(*ctx), + fw_table[i].filename, BUFF_ROOM(*ctx)); + if (bytes <= 0) { + free(ctx->rom); + exit(1); + } + + biosdir->entries[count].source = RUN_CURRENT(*ctx); + + ctx->current = ALIGN(ctx->current + bytes, 0x100U); + break; + default: /* everything else is copied from input */ + if (fw_table[i].type == AMD_BIOS_APCB || + fw_table[i].type == AMD_BIOS_APCB_BK) + ctx->current = ALIGN( + ctx->current, ERASE_ALIGNMENT); + + bytes = copy_blob(BUFF_CURRENT(*ctx), + fw_table[i].filename, BUFF_ROOM(*ctx)); + if (bytes <= 0) { + free(ctx->rom); + exit(1); + } + + biosdir->entries[count].size = (uint32_t)bytes; + biosdir->entries[count].source = RUN_CURRENT(*ctx); + + ctx->current = ALIGN(ctx->current + bytes, 0x100U); + break; + } + + count++; + } + + if (biosdir2) { + biosdir->entries[count].type = AMD_BIOS_L2_PTR; + biosdir->entries[count].size = + + MAX_BIOS_ENTRIES + * sizeof(bios_directory_entry); + biosdir->entries[count].source = + BUFF_TO_RUN(*ctx, biosdir2); + biosdir->entries[count].subprog = 0; + biosdir->entries[count].inst = 0; + biosdir->entries[count].copy = 0; + biosdir->entries[count].compressed = 0; + biosdir->entries[count].dest = -1; + biosdir->entries[count].reset = 0; + biosdir->entries[count].ro = 0; + count++; + } + + if (count > MAX_BIOS_ENTRIES) { + printf("Error: BIOS entries exceeds max allowed items\n"); + free(ctx->rom); + exit(1); + } + + fill_dir_header(biosdir, count, cookie); +} + +static const char *optstring = "x:i:g:AMS:p:b:s:r:k:c:n:d:t:u:w:m:T:z:J:B:K:L:Y:N:UW:I:a:Q:V:e:v:j:y:G:O:X:F:H:o:f:l:h"; static struct option long_options[] = { {"xhci", required_argument, 0, 'x' }, {"imc", required_argument, 0, 'i' }, {"gec", required_argument, 0, 'g' }, - /* PSP */ + /* PSP Directory Table items */ {"combo-capable", no_argument, 0, 'A' }, {"multilevel", no_argument, 0, 'M' }, {"subprogram", required_argument, 0, 'S' }, @@ -598,11 +995,34 @@ static struct option long_options[] = { {"smufirmware2", required_argument, 0, 'w' }, {"smuscs", required_argument, 0, 'm' }, {"soft-fuse", required_argument, 0, 'T' }, + {"abl-image", required_argument, 0, 'z' }, + {"sec-gasket", required_argument, 0, 'J' }, + {"mp2-fw", required_argument, 0, 'B' }, + {"drv-entry-pts", required_argument, 0, 'K' }, + {"ikek", required_argument, 0, 'L' }, + {"s0i3drv", required_argument, 0, 'Y' }, + {"secdebug", required_argument, 0, 'N' }, + {"token-unlock", no_argument, 0, 'U' }, + {"whitelist", required_argument, 0, 'W' }, + /* BIOS Directory Table items */ + {"instance", required_argument, 0, 'I' }, + {"apcb", required_argument, 0, 'a' }, + {"apob-base", required_argument, 0, 'Q' }, + {"bios-bin", required_argument, 0, 'V' }, + {"bios-bin-src", required_argument, 0, 'e' }, + {"bios-bin-dest", required_argument, 0, 'v' }, + {"bios-uncomp-size", required_argument, 0, 'j' }, + {"pmu-inst", required_argument, 0, 'y' }, + {"pmu-data", required_argument, 0, 'G' }, + {"ucode", required_argument, 0, 'O' }, + {"mp2-config", required_argument, 0, 'X' }, + {"apob-nv-base", required_argument, 0, 'F' }, + {"apob-nv-size", required_argument, 0, 'H' }, + /* other */ {"output", required_argument, 0, 'o' }, {"flashsize", required_argument, 0, 'f' }, {"location", required_argument, 0, 'l' }, {"help", no_argument, 0, 'h' }, - {NULL, 0, 0, 0 } }; @@ -619,6 +1039,19 @@ static void register_fw_fuse(char *str) } } +static void register_fw_token_unlock(void) +{ + int i; + + for (i = 0; i < sizeof(amd_psp_fw_table) / sizeof(amd_fw_entry); i++) { + if (amd_psp_fw_table[i].type != AMD_TOKEN_UNLOCK) + continue; + + amd_psp_fw_table[i].other = 1; + return; + } +} + static void register_fw_filename(amd_fw_type type, uint8_t sub, char filename[]) { unsigned int i; @@ -641,6 +1074,39 @@ static void register_fw_filename(amd_fw_type type, uint8_t sub, char filename[]) } } +static void register_bdt_data(amd_bios_type type, int sub, int ins, char name[]) +{ + int i; + + for (i = 0; i < sizeof(amd_bios_table) / sizeof(amd_bios_entry); i++) { + if (amd_bios_table[i].type == type + && amd_bios_table[i].inst == ins + && amd_bios_table[i].subpr == sub) { + amd_bios_table[i].filename = name; + return; + } + } +} + +static void register_fw_addr(amd_fw_type type, char *src_str, + char *dst_str, char *size_str) +{ + int i; + for (i = 0; i < sizeof(amd_bios_table) / sizeof(amd_bios_entry); i++) { + if (amd_bios_table[i].type != type) + continue; + + if (src_str) + amd_bios_table[i].src = strtoull(src_str, NULL, 16); + if (dst_str) + amd_bios_table[i].dest = strtoull(dst_str, NULL, 16); + if (size_str) + amd_bios_table[i].size = strtoul(size_str, NULL, 16); + + return; + } +} + int main(int argc, char **argv) { int c; @@ -656,10 +1122,12 @@ int main(int argc, char **argv) context ctx = { .rom_size = CONFIG_ROM_SIZE, }; + /* Values cleared after each firmware or parameter, regardless if N/A */ + uint8_t sub = 0, instance = 0; + int abl_image = 0; uint32_t dir_location = 0; uint32_t romsig_offset; uint32_t rom_base_address; - uint8_t sub = 0; int multi = 0; while (1) { @@ -673,15 +1141,15 @@ int main(int argc, char **argv) switch (c) { case 'x': register_fw_filename(AMD_FW_XHCI, sub, optarg); - sub = 0; + sub = instance = 0; break; case 'i': register_fw_filename(AMD_FW_IMC, sub, optarg); - sub = 0; + sub = instance = 0; break; case 'g': register_fw_filename(AMD_FW_GEC, sub, optarg); - sub = 0; + sub = instance = 0; break; case 'A': comboable = 1; @@ -689,69 +1157,167 @@ int main(int argc, char **argv) case 'M': multi = 1; break; + case 'U': + register_fw_token_unlock(); + sub = instance = 0; + break; case 'S': sub = (uint8_t)strtoul(optarg, &tmp, 16); break; + case 'I': + instance = strtoul(optarg, &tmp, 16); + break; case 'p': register_fw_filename(AMD_FW_PSP_PUBKEY, sub, optarg); - sub = 0; + sub = instance = 0; break; case 'b': register_fw_filename(AMD_FW_PSP_BOOTLOADER, sub, optarg); - sub = 0; + sub = instance = 0; break; case 's': register_fw_filename(AMD_FW_PSP_SMU_FIRMWARE, sub, optarg); - sub = 0; + sub = instance = 0; break; case 'r': register_fw_filename(AMD_FW_PSP_RECOVERY, sub, optarg); - sub = 0; + sub = instance = 0; break; case 'k': register_fw_filename(AMD_FW_PSP_RTM_PUBKEY, sub, optarg); - sub = 0; + sub = instance = 0; break; case 'c': register_fw_filename(AMD_FW_PSP_SECURED_OS, sub, optarg); - sub = 0; + sub = instance = 0; break; case 'n': register_fw_filename(AMD_FW_PSP_NVRAM, sub, optarg); - sub = 0; + sub = instance = 0; break; case 'd': register_fw_filename(AMD_FW_PSP_SECURED_DEBUG, sub, optarg); - sub = 0; + sub = instance = 0; break; case 't': register_fw_filename(AMD_FW_PSP_TRUSTLETS, sub, optarg); - sub = 0; + sub = instance = 0; break; case 'u': register_fw_filename(AMD_FW_PSP_TRUSTLETKEY, sub, optarg); - sub = 0; + sub = instance = 0; break; case 'w': register_fw_filename(AMD_FW_PSP_SMU_FIRMWARE2, sub, optarg); - sub = 0; + sub = instance = 0; break; case 'm': register_fw_filename(AMD_FW_PSP_SMUSCS, sub, optarg); - sub = 0; + sub = instance = 0; break; case 'T': register_fw_fuse(optarg); fuse_defined = 1; sub = 0; break; + case 'a': + register_bdt_data(AMD_BIOS_APCB, sub, instance, optarg); + register_bdt_data(AMD_BIOS_APCB_BK, sub, + instance, optarg); + sub = instance = 0; + break; + case 'Q': + /* APOB destination */ + register_fw_addr(AMD_BIOS_APOB, 0, optarg, 0); + sub = instance = 0; + break; + case 'F': + /* APOB NV source */ + register_fw_addr(AMD_BIOS_APOB_NV, optarg, 0, 0); + sub = instance = 0; + break; + case 'H': + /* APOB NV size */ + register_fw_addr(AMD_BIOS_APOB_NV, 0, 0, optarg); + sub = instance = 0; + break; + case 'V': + register_bdt_data(AMD_BIOS_BIN, sub, instance, optarg); + sub = instance = 0; + break; + case 'e': + /* BIOS source */ + register_fw_addr(AMD_BIOS_BIN, optarg, 0, 0); + sub = instance = 0; + break; + case 'v': + /* BIOS destination */ + register_fw_addr(AMD_BIOS_BIN, 0, optarg, 0); + sub = instance = 0; + break; + case 'j': + /* BIOS destination size */ + register_fw_addr(AMD_BIOS_BIN, 0, 0, optarg); + sub = instance = 0; + break; + case 'y': + register_bdt_data(AMD_BIOS_PMUI, sub, instance, optarg); + sub = instance = 0; + break; + case 'G': + register_bdt_data(AMD_BIOS_PMUD, sub, instance, optarg); + sub = instance = 0; + break; + case 'O': + register_bdt_data(AMD_BIOS_UCODE, sub, + instance, optarg); + sub = instance = 0; + break; + case 'J': + register_fw_filename(AMD_SEC_GASKET, sub, optarg); + sub = instance = 0; + break; + case 'B': + register_fw_filename(AMD_MP2_FW, sub, optarg); + sub = instance = 0; + break; + case 'z': + register_fw_filename(AMD_ABL0 + abl_image++, + sub, optarg); + sub = instance = 0; + break; + case 'X': + register_bdt_data(AMD_BIOS_MP2_CFG, sub, + instance, optarg); + sub = instance = 0; + break; + case 'K': + register_fw_filename(AMD_DRIVER_ENTRIES, sub, optarg); + sub = instance = 0; + break; + case 'L': + register_fw_filename(AMD_WRAPPED_IKEK, sub, optarg); + sub = instance = 0; + break; + case 'Y': + register_fw_filename(AMD_S0I3_DRIVER, sub, optarg); + sub = instance = 0; + break; + case 'N': + register_fw_filename(AMD_DEBUG_UNLOCK, sub, optarg); + sub = instance = 0; + break; + case 'W': + register_fw_filename(AMD_FW_PSP_WHITELIST, sub, optarg); + sub = instance = 0; + break; case 'o': output = optarg; break; @@ -887,6 +1453,27 @@ int main(int argc, char **argv) fill_dir_header(combo_dir, 1, PSP2_COOKIE); #endif + if (have_bios_tables(amd_bios_table)) { + bios_directory_table *biosdir; + if (multi) { + /* Do 2nd level BIOS directory followed by 1st */ + bios_directory_table *biosdir2 = + new_bios_dir(&ctx, multi); + integrate_bios_firmwares(&ctx, biosdir2, 0, + amd_bios_table, BDT2_COOKIE); + + biosdir = new_bios_dir(&ctx, multi); + integrate_bios_firmwares(&ctx, biosdir, biosdir2, + amd_bios_table, BDT1_COOKIE); + } else { + /* flat: BDT1 cookie and no pointer to 2nd table */ + biosdir = new_bios_dir(&ctx, multi); + integrate_bios_firmwares(&ctx, biosdir, 0, + amd_bios_table, BDT1_COOKIE); + } + amd_romsig->bios1_entry = BUFF_TO_RUN(ctx, biosdir); + } + targetfd = open(output, O_RDWR | O_CREAT | O_TRUNC, 0666); if (targetfd >= 0) { write(targetfd, amd_romsig, ctx.current - romsig_offset); diff --git a/util/autoport/bd82x6x.go b/util/autoport/bd82x6x.go index e93704ec4a..141ec5c7ae 100644 --- a/util/autoport/bd82x6x.go +++ b/util/autoport/bd82x6x.go @@ -28,7 +28,7 @@ func (b bd82x6x) writeGPIOSet(ctx Context, sb *os.File, } for i := uint(0); i < max; i++ { - if ((constraint>>i)&1 == 1) { + if (constraint>>i)&1 == 1 { fmt.Fprintf(sb, " .gpio%d = %s,\n", (set-1)*32+i, bits[partno][(val>>i)&1]) @@ -236,8 +236,8 @@ func (b bd82x6x) Scan(ctx Context, addr PCIDevData) { "p_cnt_throttling_supported": (FormatBool(FADT[104] == 1 && FADT[105] == 3)), "c2_latency": FormatHexLE16(FADT[96:98]), "docking_supported": (FormatBool((FADT[113] & (1 << 1)) != 0)), - "spi_uvscc": fmt.Sprintf("0x%x", inteltool.RCBA[0x38c8]), - "spi_lvscc": fmt.Sprintf("0x%x", inteltool.RCBA[0x38c4] &^ (1 << 23)), + "spi_uvscc": fmt.Sprintf("0x%x", inteltool.RCBA[0x38c8]), + "spi_lvscc": fmt.Sprintf("0x%x", inteltool.RCBA[0x38c4]&^(1<<23)), }, PCISlots: []PCISlot{ PCISlot{PCIAddr: PCIAddr{Dev: 0x14, Func: 0}, writeEmpty: false, additionalComment: "USB 3.0 Controller"}, @@ -315,10 +315,6 @@ void pch_enable_lpc(void) { `) RestorePCI16Simple(sb, addr, 0x82) - RestorePCI32Simple(sb, addr, 0x84) - RestorePCI32Simple(sb, addr, 0x88) - RestorePCI32Simple(sb, addr, 0x8c) - RestorePCI32Simple(sb, addr, 0x90) RestorePCI16Simple(sb, addr, 0x80) diff --git a/util/cbfstool/Makefile b/util/cbfstool/Makefile index d7137e907b..d5321f6959 100644 --- a/util/cbfstool/Makefile +++ b/util/cbfstool/Makefile @@ -12,7 +12,7 @@ OBJCOPY ?= objcopy VBOOT_SOURCE ?= $(top)/3rdparty/vboot .PHONY: all -all: cbfstool fmaptool rmodtool ifwitool cbfs-compression-tool +all: cbfstool ifittool fmaptool rmodtool ifwitool cbfs-compression-tool cbfstool: $(objutil)/cbfstool/cbfstool @@ -22,15 +22,18 @@ rmodtool: $(objutil)/cbfstool/rmodtool ifwitool: $(objutil)/cbfstool/ifwitool +ifittool: $(objutil)/cbfstool/ifittool + cbfs-compression-tool: $(objutil)/cbfstool/cbfs-compression-tool -.PHONY: clean cbfstool fmaptool rmodtool ifwitool cbfs-compression-tool +.PHONY: clean cbfstool ifittool fmaptool rmodtool ifwitool cbfs-compression-tool clean: $(RM) fmd_parser.c fmd_parser.h fmd_scanner.c fmd_scanner.h $(RM) $(objutil)/cbfstool/cbfstool $(cbfsobj) $(RM) $(objutil)/cbfstool/fmaptool $(fmapobj) $(RM) $(objutil)/cbfstool/rmodtool $(rmodobj) $(RM) $(objutil)/cbfstool/ifwitool $(ifwiobj) + $(RM) $(objutil)/cbfstool/ifittool $(ifitobj) $(RM) $(objutil)/cbfstool/cbfs-compression-tool $(cbfscompobj) linux_trampoline.c: linux_trampoline.S @@ -49,6 +52,7 @@ install: all $(INSTALL) fmaptool $(DESTDIR)$(BINDIR) $(INSTALL) rmodtool $(DESTDIR)$(BINDIR) $(INSTALL) ifwitool $(DESTDIR)$(BINDIR) + $(INSTALL) ifittool $(DESTDIR)$(BINDIR) $(INSTALL) cbfs-compression-tool $(DESTDIR)$(BINDIR) ifneq ($(V),1) diff --git a/util/cbfstool/Makefile.inc b/util/cbfstool/Makefile.inc index 79285207b0..efc3dca6f5 100644 --- a/util/cbfstool/Makefile.inc +++ b/util/cbfstool/Makefile.inc @@ -21,7 +21,6 @@ cbfsobj += cbfs-mkpayload.o cbfsobj += elfheaders.o cbfsobj += rmodule.o cbfsobj += xdr.o -cbfsobj += fit.o cbfsobj += partitioned_file.o # COMMONLIB cbfsobj += cbfs.o @@ -66,6 +65,35 @@ ifwiobj := ifwiobj += ifwitool.o ifwiobj += common.o +ifitobj := +ifitobj += ifittool.o +ifitobj += common.o +ifitobj += fit.o +ifitobj += cbfs_image.o +# Make it link .... +ifitobj += xdr.o +ifitobj += elfheaders.o +ifitobj += partitioned_file.o +ifitobj += cbfs-mkstage.o +ifitobj += cbfs-mkpayload.o +ifitobj += rmodule.o +# COMMONLIB +ifitobj += cbfs.o +ifitobj += mem_pool.o +ifitobj += region.o +# CRYPTOLIB +ifitobj += 2sha_utility.o +ifitobj += 2sha1.o +ifitobj += 2sha256.o +ifitobj += 2sha512.o +# FMAP +ifitobj += fmap.o +ifitobj += kv_pair.o +ifitobj += valstr.o +# compression algorithms +ifitobj += $(compressionobj) + + cbfscompobj := cbfscompobj += $(compressionobj) cbfscompobj += cbfscomptool.o @@ -149,6 +177,10 @@ $(objutil)/cbfstool/ifwitool: $(addprefix $(objutil)/cbfstool/,$(ifwiobj)) printf " HOSTCC $(subst $(objutil)/,,$(@)) (link)\n" $(HOSTCC) $(TOOLLDFLAGS) -o $@ $(addprefix $(objutil)/cbfstool/,$(ifwiobj)) +$(objutil)/cbfstool/ifittool: $(addprefix $(objutil)/cbfstool/,$(ifitobj)) + printf " HOSTCC $(subst $(objutil)/,,$(@)) (link)\n" + $(HOSTCC) $(TOOLLDFLAGS) -o $@ $(addprefix $(objutil)/cbfstool/,$(ifitobj)) + $(objutil)/cbfstool/cbfs-compression-tool: $(addprefix $(objutil)/cbfstool/,$(cbfscompobj)) printf " HOSTCC $(subst $(objutil)/,,$(@)) (link)\n" $(HOSTCC) $(TOOLLDFLAGS) -o $@ $(addprefix $(objutil)/cbfstool/,$(cbfscompobj)) diff --git a/util/cbfstool/cbfstool.c b/util/cbfstool/cbfstool.c index e8b1f6f9ee..cf89b473fa 100644 --- a/util/cbfstool/cbfstool.c +++ b/util/cbfstool/cbfstool.c @@ -28,7 +28,6 @@ #include "cbfs_image.h" #include "cbfs_sections.h" #include "elfparsing.h" -#include "fit.h" #include "partitioned_file.h" #include #include @@ -84,7 +83,6 @@ static struct param { bool autogen_attr; bool machine_parseable; bool unprocessed; - int fit_empty_entries; enum comp_algo compression; int precompression; enum vb2_hash_algorithm hash; @@ -1190,54 +1188,6 @@ static int cbfs_read(void) return buffer_write_file(param.image_region, param.filename); } -static int cbfs_update_fit(void) -{ - if (!param.name) { - ERROR("You need to specify -n/--name.\n"); - return 1; - } - - if (param.fit_empty_entries <= 0) { - ERROR("Invalid number of fit entries " - "(-x/--empty-fits): %d\n", param.fit_empty_entries); - return 1; - } - - struct buffer bootblock; - // The bootblock is part of the CBFS on x86 - buffer_clone(&bootblock, param.image_region); - - struct cbfs_image image; - if (cbfs_image_from_buffer(&image, param.image_region, - param.headeroffset)) - return 1; - - uint32_t addr = 0; - - /* - * Get the address of provided region for first row. - */ - if (param.ucode_region) { - struct buffer ucode; - - if (partitioned_file_read_region(&ucode, - param.image_file, param.ucode_region)) - addr = -convert_to_from_top_aligned(&ucode, 0); - else - return 1; - } - - - if (fit_update_table(&bootblock, &image, param.name, - param.fit_empty_entries, convert_to_from_top_aligned, - param.topswap_size, addr)) - return 1; - - // The region to be written depends on the type of image, so we write it - // here rather than having main() write the CBFS region back as usual. - return !partitioned_file_write_region(param.image_file, &bootblock); -} - static int cbfs_copy(void) { struct cbfs_image src_image; @@ -1320,7 +1270,6 @@ static const struct command commands[] = { {"print", "H:r:vkh?", cbfs_print, true, false}, {"read", "r:f:vh?", cbfs_read, true, false}, {"remove", "H:r:n:vh?", cbfs_remove, true, true}, - {"update-fit", "H:r:n:x:vh?j:q:", cbfs_update_fit, true, true}, {"write", "r:f:i:Fudvh?", cbfs_write, true, true}, {"expand", "r:h?", cbfs_expand, true, true}, {"truncate", "r:h?", cbfs_truncate, true, true}, @@ -1486,15 +1435,6 @@ static void usage(char *name) "Truncate CBFS and print new size on stdout\n" " expand [-r fmap-region] " "Expand CBFS to span entire region\n" - " update-fit [-r image,regions] -n MICROCODE_BLOB_NAME \\\n" - " -x EMTPY_FIT_ENTRIES \\ \n" - " [-j topswap-size [-q ucode-region](Intel CPUs only)] " - "Updates the FIT table with microcode entries.\n" - " " - " ucode-region is a region in the FMAP, its address is \n" - " " - " inserted as the first entry in the topswap FIT. \n" - "\n" "OFFSETs:\n" " Numbers accompanying -b, -H, and -o switches* may be provided\n" " in two possible formats: if their value is greater than\n" @@ -1732,15 +1672,6 @@ int main(int argc, char **argv) case 'w': param.show_immutable = true; break; - case 'x': - param.fit_empty_entries = strtol( - optarg, &suffix, 0); - if (!*optarg || (suffix && *suffix)) { - ERROR("Invalid number of fit entries " - "'%s'.\n", optarg); - return 1; - } - break; case 'j': param.topswap_size = strtol(optarg, NULL, 0); if (!is_valid_topswap()) diff --git a/util/cbfstool/fit.c b/util/cbfstool/fit.c index aeb1755032..ee12c96610 100644 --- a/util/cbfstool/fit.c +++ b/util/cbfstool/fit.c @@ -2,6 +2,8 @@ * Firmware Interface Table support. * * Copyright (C) 2012 Google Inc. + * Copyright (C) 2019 9elements Agency GmbH + * Copyright (C) 2019 Facebook 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 @@ -13,6 +15,7 @@ * GNU General Public License for more details. */ +#include #include #include #include @@ -25,17 +28,42 @@ #define FIT_POINTER_LOCATION 0xffffffc0 #define FIT_TABLE_LOWEST_ADDRESS ((uint32_t)(-(16 << 20))) #define FIT_ENTRY_CHECKSUM_VALID 0x80 -#define FIT_TYPE_HEADER 0x0 -#define FIT_HEADER_VERSION 0x0100 -#define FIT_HEADER_ADDRESS "_FIT_ " -#define FIT_TYPE_MICROCODE 0x1 -#define FIT_MICROCODE_VERSION 0x0100 +#define FIT_HEADER_VERSION 0x0100 +#define FIT_HEADER_ADDRESS "_FIT_ " +#define FIT_MICROCODE_VERSION 0x0100 +#define FIT_TXT_VERSION 0x0100 + +#define FIT_SIZE_ALIGNMENT 16 struct fit_entry { + /** + * Address is the base address of the firmware component + * must be aligned on 16 byte boundary + */ uint64_t address; + /** + * Size is the span of the component in multiple of 16 bytes + * Bits [24:31] are reserved and must be set to 0 + */ uint32_t size_reserved; + /** + * Component's version number in binary coded decimal (BCD) format. + * For the FIT header entry, the value in this field will indicate the + * revision number of the FIT data structure. The upper byte of the + * revision field indicates the major revision and the lower byte + * indicates the minor revision. + */ uint16_t version; + /** + * FIT types 0x00 to 0x7F + * Bit 7 (C_V) indicates whether component has valid checksum. + */ uint8_t type_checksum_valid; + /** + * Component's checksum. The modulo sum of all the bytes in the + * component and the value in this field (Chksum) must add up to zero. + * This field is only valid if the C_V flag is non-zero. + */ uint8_t checksum; } __packed; @@ -67,20 +95,20 @@ static inline void *rom_buffer_pointer(struct buffer *buffer, int offset) return &buffer->data[offset]; } -static inline int fit_entry_size_bytes(struct fit_entry *entry) +static inline size_t fit_entry_size_bytes(const struct fit_entry *entry) { return (entry->size_reserved & 0xffffff) << 4; } static inline void fit_entry_update_size(struct fit_entry *entry, - int size_bytes) + const int size_bytes) { /* Size is multiples of 16 bytes. */ entry->size_reserved = (size_bytes >> 4) & 0xffffff; } static inline void fit_entry_add_size(struct fit_entry *entry, - int size_bytes) + const int size_bytes) { int size = fit_entry_size_bytes(entry); size += size_bytes; @@ -114,8 +142,70 @@ static inline uint32_t offset_to_ptr(fit_offset_converter_t helper, return -helper(region, offset); } +/* + * Return the number of FIT entries. + */ +static inline size_t fit_table_entries(const struct fit_table *fit) +{ + if (!fit) + return 0; + + return (fit_entry_size_bytes(&fit->header) / FIT_SIZE_ALIGNMENT) - 1; +} + +/* + * Return the number of unused entries. + */ +static inline size_t fit_free_space(struct fit_table *fit, + const size_t max_entries) +{ + if (!fit) + return 0; + + return max_entries - fit_table_entries(fit); +} + +/* + * Sort entries by type and fill gaps (entries with type unused). + * To be called after adding or deleting entries. + * + * This one is critical, as mentioned in Chapter 1.2.1 "FIT Ordering Rules" + * "Firmware Interface Table BIOS Specification". + * + * We need to use a stable sorting algortihm, as the order of + * FIT_TYPE_BIOS_STARTUP matter for measurements. + */ +static void sort_fit_table(struct fit_table *fit) +{ + struct fit_entry tmp; + size_t i, j; + int swapped; + + /* Bubble sort entries */ + for (j = 0; j < fit_table_entries(fit) - 1; j++) { + swapped = 0; + for (i = 0; i < fit_table_entries(fit) - j - 1; i++) { + if (fit->entries[i].type_checksum_valid <= + fit->entries[i + 1].type_checksum_valid) + continue; + /* SWAP entries */ + memcpy(&tmp, &fit->entries[i], sizeof(tmp)); + memcpy(&fit->entries[i], &fit->entries[i + 1], + sizeof(fit->entries[i])); + memcpy(&fit->entries[i + 1], &tmp, + sizeof(fit->entries[i + 1])); + swapped = 1; + } + if (!swapped) + break; + } +} + static int fit_table_verified(struct fit_table *table) { + if (!table) + return 0; + /* Check that the address field has the proper signature. */ if (strncmp((const char *)&table->header.address, FIT_HEADER_ADDRESS, sizeof(table->header.address))) @@ -127,35 +217,17 @@ static int fit_table_verified(struct fit_table *table) if (fit_entry_type(&table->header) != FIT_TYPE_HEADER) return 0; - /* Assume that the FIT table only contains the header */ - if (fit_entry_size_bytes(&table->header) != sizeof(struct fit_entry)) + /* Assume that the FIT table contains at least the header */ + if (fit_entry_size_bytes(&table->header) < sizeof(struct fit_entry)) return 0; return 1; } -static struct fit_table *locate_fit_table(fit_offset_converter_t offset_helper, - struct buffer *buffer) -{ - struct fit_table *table; - uint32_t *fit_pointer; - - fit_pointer = rom_buffer_pointer(buffer, - ptr_to_offset(offset_helper, buffer, - FIT_POINTER_LOCATION)); - - /* Ensure pointer is below 4GiB and within 16MiB of 4GiB */ - if (fit_pointer[1] != 0 || fit_pointer[0] < FIT_TABLE_LOWEST_ADDRESS) - return NULL; - - table = rom_buffer_pointer(buffer, - ptr_to_offset(offset_helper, buffer, *fit_pointer)); - if (!fit_table_verified(table)) - return NULL; - else - return table; -} - +/* + * Update the FIT checksum. + * To be called after modifiying the table. + */ static void update_fit_checksum(struct fit_table *fit) { int size_bytes; @@ -163,6 +235,9 @@ static void update_fit_checksum(struct fit_table *fit) uint8_t result; int i; + if (!fit) + return; + fit->header.checksum = 0; size_bytes = fit_entry_size_bytes(&fit->header); result = 0; @@ -172,92 +247,68 @@ static void update_fit_checksum(struct fit_table *fit) fit->header.checksum = -result; } -static void update_fit_ucode_entry(struct fit_table *fit, - struct fit_entry *entry, uint64_t mcu_addr) +/* + * Return a pointer to the next free entry. + * Caller must take care if enough space is available. + */ +static struct fit_entry *get_next_free_entry(struct fit_table *fit) { - entry->address = mcu_addr; - /* - * While loading MCU, its size is not referred from FIT and - * rather from the MCU header, hence we can assign zero here - */ - entry->size_reserved = 0x0000; - entry->type_checksum_valid = FIT_TYPE_MICROCODE; - entry->version = FIT_MICROCODE_VERSION; - entry->checksum = 0; - fit_entry_add_size(&fit->header, sizeof(struct fit_entry)); + return &fit->entries[fit_table_entries(fit)]; } -static void add_microcodde_entries(struct fit_table *fit, - const struct cbfs_image *image, - int num_mcus, struct microcode_entry *mcus, - fit_offset_converter_t offset_helper, - uint32_t first_mcu_addr) -{ - int i = 0; - /* - * Check if an entry has to be forced into the FIT at index 0. - * first_mcu_addr is an address (in ROM) that will point to a - * microcode patch. - */ - if (first_mcu_addr) { - struct fit_entry *entry = &fit->entries[0]; - update_fit_ucode_entry(fit, entry, first_mcu_addr); - i = 1; - } - - struct microcode_entry *mcu = &mcus[0]; - for (; i < num_mcus; i++) { - struct fit_entry *entry = &fit->entries[i]; - update_fit_ucode_entry(fit, entry, offset_to_ptr(offset_helper, - &image->buffer, mcu->offset)); - mcu++; - } -} - -static void cbfs_file_get_header(struct buffer *buf, struct cbfs_file *file) -{ - bgets(buf, &file->magic, sizeof(file->magic)); - file->len = xdr_be.get32(buf); - file->type = xdr_be.get32(buf); - file->attributes_offset = xdr_be.get32(buf); - file->offset = xdr_be.get32(buf); -} - -static int fit_header(void *ptr, uint32_t *current_offset, uint32_t *file_length) +static void fit_location_from_cbfs_header(uint32_t *current_offset, + uint32_t *file_length, void *ptr) { struct buffer buf; struct cbfs_file header; + memset(&buf, 0, sizeof(buf)); + buf.data = ptr; buf.size = sizeof(header); - cbfs_file_get_header(&buf, &header); + + bgets(&buf, header.magic, sizeof(header.magic)); + header.len = xdr_be.get32(&buf); + header.type = xdr_be.get32(&buf); + header.attributes_offset = xdr_be.get32(&buf); + header.offset = xdr_be.get32(&buf); + *current_offset = header.offset; *file_length = header.len; - return 0; } -static int parse_microcode_blob(struct cbfs_image *image, - struct cbfs_file *mcode_file, - struct microcode_entry *mcus, - int total_entries, int *mcus_found) +static int +parse_microcode_blob(struct cbfs_image *image, + const char *blob_name, + size_t *mcus_found, + struct microcode_entry *mcus, + const size_t max_fit_entries) { - int num_mcus; + size_t num_mcus; uint32_t current_offset; uint32_t file_length; + struct cbfs_file *mcode_file; - fit_header(mcode_file, ¤t_offset, &file_length); - current_offset += (int)((char *)mcode_file - image->buffer.data); + mcode_file = cbfs_get_entry(image, blob_name); + if (!mcode_file) + return 1; + + fit_location_from_cbfs_header(¤t_offset, &file_length, + mcode_file); + current_offset += cbfs_get_entry_addr(image, mcode_file); num_mcus = 0; - while (file_length > sizeof(struct microcode_header)) - { + while (file_length > sizeof(struct microcode_header)) { const struct microcode_header *mcu_header; mcu_header = rom_buffer_pointer(&image->buffer, current_offset); + if (!mcu_header) { + ERROR("Couldn't parse microcode header.\n"); + return 1; + } /* Newer microcode updates include a size field, whereas older * containers set it at 0 and are exactly 2048 bytes long */ - uint32_t total_size = mcu_header->total_size - ? mcu_header->total_size : 2048; + uint32_t total_size = mcu_header->total_size ?: 2048; /* Quickly sanity check a prospective microcode update. */ if (total_size < sizeof(*mcu_header)) @@ -271,9 +322,8 @@ static int parse_microcode_blob(struct cbfs_image *image, current_offset += mcus[num_mcus].size; file_length -= mcus[num_mcus].size; num_mcus++; - /* Reached limit of FIT entries. */ - if (num_mcus == total_entries) + if (num_mcus == max_fit_entries) break; if (file_length < sizeof(struct microcode_header)) break; @@ -285,78 +335,406 @@ static int parse_microcode_blob(struct cbfs_image *image, return 0; } -int fit_update_table(struct buffer *bootblock, struct cbfs_image *image, - const char *microcode_blob_name, int empty_entries, - fit_offset_converter_t offset_fn, uint32_t topswap_size, - uint32_t first_mcu_addr) +/* There can be zero or more FIT_TYPE_MICROCODE entries */ +static void update_fit_ucode_entry(struct fit_table *fit, + struct fit_entry *entry, + const uint64_t mcu_addr) +{ + entry->address = mcu_addr; + /* + * While loading MCU, its size is not referred from FIT and + * rather from the MCU header, hence we can assign zero here. + */ + entry->size_reserved = 0; + entry->type_checksum_valid = FIT_TYPE_MICROCODE; + entry->version = FIT_MICROCODE_VERSION; + entry->checksum = 0; + fit_entry_add_size(&fit->header, sizeof(struct fit_entry)); +} + +/* + * There can be zero or one FIT_TYPE_BIOS_ACM entry per table. + * In case there's a FIT_TYPE_BIOS_ACM entry, at least one + * FIT_TYPE_BIOS_STARTUP entry must exist. + * + * The caller has to provide valid arguments as those aren't verfied. + */ +static void update_fit_bios_acm_entry(struct fit_table *fit, + struct fit_entry *entry, + const uint64_t acm_addr) +{ + entry->address = acm_addr; + /* + * The Address field points to a BIOS ACM. The Address field points to + * the first byte of the AC module header. When BIOS ACM is loaded in + * Authenticated Code RAM, one MTRR base/limit pair is used to map it. + */ + entry->size_reserved = 0; + entry->type_checksum_valid = FIT_TYPE_BIOS_ACM; + entry->version = FIT_TXT_VERSION; + entry->checksum = 0; + fit_entry_add_size(&fit->header, sizeof(struct fit_entry)); +} + +/* + * In case there's a FIT_TYPE_BIOS_ACM entry, at least one + * FIT_TYPE_BIOS_STARTUP entry must exist. + * + * The caller has to provide valid arguments as those aren't verfied. + */ +static void update_fit_bios_startup_entry(struct fit_table *fit, + struct fit_entry *entry, + const uint64_t sm_addr, + const uint32_t sm_size) +{ + entry->address = sm_addr; + assert(sm_size % 16 == 0); + /* + * BIOS Startup code is defined as the code that gets control at the + * reset vector and continues the chain of trust in TCG-compliant + * fashion. In addition, this code may also configure memory and SMRAM. + */ + fit_entry_update_size(entry, sm_size); + entry->type_checksum_valid = FIT_TYPE_BIOS_STARTUP; + entry->version = FIT_TXT_VERSION; + entry->checksum = 0; + fit_entry_add_size(&fit->header, sizeof(struct fit_entry)); +} + +/* + * There can be zero or one FIT_TYPE_BIOS_POLICY Record in the FIT. + * If the platform uses the hash comparison method and employs a + * failsafe bootblock, one FIT_TYPE_BIOS_POLICY entry is needed to + * contain the failsafe hash. + * If the platform uses the Signature verification method, one + * FIT_TYPE_BIOS_POLICY entry is needed. In this case, the entry + * contains the OEM key, hash of the BIOS and signature over the hash + * using the OEM key. + * In all other cases, the FIT_TYPE_BIOS_POLICY record is not required. + * + * The caller has to provide valid arguments as those aren't verfied. + */ +static void update_fit_bios_policy_entry(struct fit_table *fit, + struct fit_entry *entry, + const uint64_t lcp_policy_addr, + const uint32_t lcp_policy_size) +{ + entry->address = lcp_policy_addr; + fit_entry_update_size(entry, lcp_policy_size); + entry->type_checksum_valid = FIT_TYPE_BIOS_POLICY; + entry->version = FIT_TXT_VERSION; + entry->checksum = 0; + fit_entry_add_size(&fit->header, sizeof(struct fit_entry)); +} + +/* + * There can be zero or one FIT_TYPE_TXT_POLICY entries + * + * The caller has to provide valid arguments as those aren't verfied. + */ +static void update_fit_txt_policy_entry(struct fit_table *fit, + struct fit_entry *entry, + uint64_t txt_policy_addr) +{ + entry->address = txt_policy_addr; + /* + * Points to the flag indicating if TXT is enabled on this platform. + * If not present, TXT is not disabled by FIT. + */ + entry->size_reserved = 0; + entry->type_checksum_valid = FIT_TYPE_TXT_POLICY; + entry->version = 0x1; + entry->checksum = 0; + fit_entry_add_size(&fit->header, sizeof(struct fit_entry)); +} + +/* Special case for ucode CBFS file, as it might contain more than one ucode */ +int fit_add_microcode_file(struct fit_table *fit, + struct cbfs_image *image, + const char *blob_name, + fit_offset_converter_t offset_helper, + const size_t max_fit_entries) { - struct fit_table *fit, *fit2; - struct cbfs_file *mcode_file; struct microcode_entry *mcus; - int mcus_found; - int ret = 0; - // struct rom_image image = { .rom = rom, .size = romsize, }; - - fit = locate_fit_table(offset_fn, bootblock); - - if (!fit) { - ERROR("FIT not found.\n"); - return 1; - } - - mcode_file = cbfs_get_entry(image, microcode_blob_name); - if (!mcode_file) { - ERROR("File '%s' not found in CBFS.\n", - microcode_blob_name); - return 1; - } - - mcus = malloc(sizeof(*mcus) * empty_entries); + size_t i; + size_t mcus_found; + mcus = malloc(sizeof(*mcus) * max_fit_entries); if (!mcus) { - ERROR("Couldn't allocate memory for microcode update entries.\n"); + ERROR("Couldn't allocate memory for microcode entries.\n"); return 1; } - if (parse_microcode_blob(image, mcode_file, mcus, empty_entries, - &mcus_found)) { + if (parse_microcode_blob(image, blob_name, &mcus_found, mcus, + max_fit_entries)) { ERROR("Couldn't parse microcode blob.\n"); - ret = 1; - goto out; + free(mcus); + return 1; } - add_microcodde_entries(fit, image, mcus_found, mcus, offset_fn, 0); + if (mcus_found > fit_free_space(fit, max_fit_entries)) { + ERROR("Maximum of FIT entries reached.\n"); + free(mcus); + return 1; + } + + for (i = 0; i < mcus_found; i++) { + if (fit_add_entry(fit, + offset_to_ptr(offset_helper, &image->buffer, + mcus[i].offset), + 0, + FIT_TYPE_MICROCODE, + max_fit_entries)) { + + free(mcus); + return 1; + } + } + + free(mcus); + return 0; +} + +/* + * Return a pointer to the active FIT. + */ +struct fit_table *fit_get_table(struct buffer *bootblock, + fit_offset_converter_t offset_fn, + uint32_t topswap_size) +{ + struct fit_table *fit; + uint32_t *fit_pointer; + + fit_pointer = rom_buffer_pointer(bootblock, + ptr_to_offset(offset_fn, bootblock, + FIT_POINTER_LOCATION)); + + /* Ensure pointer is below 4GiB and within 16MiB of 4GiB */ + if (fit_pointer[1] != 0 || fit_pointer[0] < FIT_TABLE_LOWEST_ADDRESS) { + ERROR("FIT not found.\n"); + return NULL; + } + + fit = rom_buffer_pointer(bootblock, + ptr_to_offset(offset_fn, bootblock, *fit_pointer)); + if (!fit_table_verified(fit)) { + ERROR("FIT not found.\n"); + return NULL; + } + + if (topswap_size) { + struct fit_table *fit2 = (struct fit_table *)((uintptr_t)fit - + topswap_size); + if (!fit_table_verified(fit2)) { + ERROR("second FIT is invalid\n"); + return NULL; + } + fit = fit2; + } + + DEBUG("Operating on table (0x%x)\n", *fit_pointer - topswap_size); + + return fit; +} + +/* + * Dump the current FIT in human readable format to stdout. + */ +int fit_dump(struct fit_table *fit) +{ + size_t i; + + if (!fit) + return 1; + + printf("\n"); + printf(" FIT table:\n"); + + if (fit_table_entries(fit) < 1) { + printf(" empty\n\n"); + return 0; + } + + printf(" %-6s %-20s %-16s %-8s\n", "Index", "Type", "Addr", "Size"); + + for (i = 0; i < fit_table_entries(fit); i++) { + const char *name; + + switch (fit->entries[i].type_checksum_valid) { + case FIT_TYPE_MICROCODE: + name = "Microcode"; + break; + case FIT_TYPE_BIOS_ACM: + name = "BIOS ACM"; + break; + case FIT_TYPE_BIOS_STARTUP: + name = "BIOS Startup Module"; + break; + case FIT_TYPE_TPM_POLICY: + name = "TPM Policy"; + break; + case FIT_TYPE_BIOS_POLICY: + name = "BIOS Policy"; + break; + case FIT_TYPE_TXT_POLICY: + name = "TXT Policy"; + break; + case FIT_TYPE_KEY_MANIFEST: + name = "Key Manifest"; + break; + case FIT_TYPE_BOOT_POLICY: + name = "Boot Policy"; + break; + case FIT_TYPE_CSE_SECURE_BOOT: + name = "CSE SecureBoot"; + break; + case FIT_TYPE_TXTSX_POLICY: + name = "TXTSX policy"; + break; + case FIT_TYPE_JMP_DEBUG_POLICY: + name = "JMP debug policy"; + break; + case FIT_TYPE_UNUSED: + name = "unused"; + break; + default: + name = "unknown"; + } + + printf(" %6zd %-20s 0x%08"PRIx64" 0x%08zx\n", i, name, + fit->entries[i].address, + fit_entry_size_bytes(&fit->entries[i])); + } + printf("\n"); + return 0; +} + +/* + * Remove all entries from table. + */ +int fit_clear_table(struct fit_table *fit) +{ + if (!fit) + return 1; + + memset(fit->entries, 0, + sizeof(struct fit_entry) * fit_table_entries(fit)); + + /* Reset entry counter in header */ + fit_entry_update_size(&fit->header, sizeof(fit->header)); update_fit_checksum(fit); - /* A second fit is exactly topswap size away from the bottom one */ - if (topswap_size) { - - fit2 = (struct fit_table *)((uintptr_t)fit - topswap_size); - - if (!fit_table_verified(fit2)) { - ERROR("second FIT is invalid\n"); - ret = 1; - goto out; - } - /* Check if we have room for first entry */ - if (first_mcu_addr) { - if (mcus_found >= empty_entries) { - ERROR("No room, blob mcus = %d, total entries = %d\n", - mcus_found, empty_entries); - ret = 1; - goto out; - } - /* Add 1 for the first entry */ - mcus_found++; - } - /* Add entries in the second FIT */ - add_microcodde_entries(fit2, image, mcus_found, mcus, - offset_fn, first_mcu_addr); - update_fit_checksum(fit2); - } -out: - free(mcus); - return ret; + return 0; +} + +/* + * Returns true if the FIT type is know and can be added to the table. + */ +int fit_is_supported_type(const enum fit_type type) +{ + switch (type) { + case FIT_TYPE_MICROCODE: + case FIT_TYPE_BIOS_ACM: + case FIT_TYPE_BIOS_STARTUP: + case FIT_TYPE_BIOS_POLICY: + case FIT_TYPE_TXT_POLICY: + return 1; + case FIT_TYPE_TPM_POLICY: + case FIT_TYPE_KEY_MANIFEST: + case FIT_TYPE_BOOT_POLICY: + default: + return 0; + } +} + +/* + * Adds an known entry to the FIT. + * len is optional for same types and might be zero. + * offset is an absolute address in 32-bit protected mode address space. + */ +int fit_add_entry(struct fit_table *fit, + const uint32_t offset, + const uint32_t len, + const enum fit_type type, + const size_t max_fit_entries) +{ + struct fit_entry *entry; + + if (!fit) { + ERROR("Internal error."); + return 1; + } + + if (fit_free_space(fit, max_fit_entries) < 1) { + ERROR("No space left in FIT."); + return 1; + } + + if (!fit_is_supported_type(type)) { + ERROR("Unsupported FIT type %u\n", type); + return 1; + } + + DEBUG("Adding new entry type %u at offset %zd\n", type, + fit_table_entries(fit)); + + entry = get_next_free_entry(fit); + + switch (type) { + case FIT_TYPE_MICROCODE: + update_fit_ucode_entry(fit, entry, offset); + break; + case FIT_TYPE_BIOS_ACM: + update_fit_bios_acm_entry(fit, entry, offset); + break; + case FIT_TYPE_BIOS_STARTUP: + update_fit_bios_startup_entry(fit, entry, offset, len); + break; + case FIT_TYPE_BIOS_POLICY: + update_fit_bios_policy_entry(fit, entry, offset, len); + break; + case FIT_TYPE_TXT_POLICY: + update_fit_txt_policy_entry(fit, entry, offset); + break; + default: + return 1; + } + + sort_fit_table(fit); + + update_fit_checksum(fit); + + return 0; +} + +/* + * Delete one entry from table. + */ +int fit_delete_entry(struct fit_table *fit, + const size_t idx) +{ + if (!fit) { + ERROR("Internal error."); + return 1; + } + + if (idx >= fit_table_entries(fit)) { + ERROR("Index out of range."); + return 1; + } + + memset(&fit->entries[idx], 0, sizeof(struct fit_entry)); + + fit->entries[idx].type_checksum_valid = FIT_TYPE_UNUSED; + + sort_fit_table(fit); + + /* The unused entry is now the last one */ + fit_entry_add_size(&fit->header, -(int)sizeof(struct fit_entry)); + + update_fit_checksum(fit); + + return 0; } diff --git a/util/cbfstool/fit.h b/util/cbfstool/fit.h index 42b3b4722a..c647ec506e 100644 --- a/util/cbfstool/fit.h +++ b/util/cbfstool/fit.h @@ -2,6 +2,8 @@ * Firmware Interface Table support. * * Copyright (C) 2012 Google Inc. + * Copyright (C) 2019 9elements Agency GmbH + * Copyright (C) 2019 Facebook 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 @@ -19,6 +21,26 @@ #include "cbfs_image.h" #include "common.h" +/** + * Based on "Intel Trusted Execution Technology (Intel TXT) LAB Handout" and + * https://github.com/slimbootloader/slimbootloader/ + */ +enum fit_type { + FIT_TYPE_HEADER = 0, + FIT_TYPE_MICROCODE = 1, + FIT_TYPE_BIOS_ACM = 2, + FIT_TYPE_BIOS_STARTUP = 7, + FIT_TYPE_TPM_POLICY = 8, + FIT_TYPE_BIOS_POLICY = 9, + FIT_TYPE_TXT_POLICY = 0xa, + FIT_TYPE_KEY_MANIFEST = 0xb, + FIT_TYPE_BOOT_POLICY = 0xc, + FIT_TYPE_CSE_SECURE_BOOT = 0x10, + FIT_TYPE_TXTSX_POLICY = 0x2d, + FIT_TYPE_JMP_DEBUG_POLICY = 0x2f, + FIT_TYPE_UNUSED = 127, +}; + /* * Converts between offsets from the start of the specified image region and * "top-aligned" offsets from the top of the entire flash image. Should work in @@ -28,15 +50,26 @@ typedef unsigned (*fit_offset_converter_t)(const struct buffer *region, unsigned offset); -/* - * populate FIT with the MCUs prepsent in the blob provided. - * - * first_mcu_addr is an address (in ROM) that will point to a - * microcode patch. When provided, it will be forced as the first - * MCU entry into the FIT located in the topswap bootblock. - */ -int fit_update_table(struct buffer *bootblock, struct cbfs_image *image, - const char *microcode_blob_name, int empty_entries, - fit_offset_converter_t offset_fn, - uint32_t topswap_size, uint32_t first_mcu_addr); +struct fit_table; + +struct fit_table *fit_get_table(struct buffer *bootblock, + fit_offset_converter_t offset_fn, + uint32_t topswap_size); +int fit_dump(struct fit_table *fit); +int fit_clear_table(struct fit_table *fit); +int fit_is_supported_type(const enum fit_type type); +int fit_add_entry(struct fit_table *fit, + const uint32_t offset, + const uint32_t len, + const enum fit_type type, + const size_t max_fit_entries); +int fit_delete_entry(struct fit_table *fit, + const size_t idx); + +int fit_add_microcode_file(struct fit_table *fit, + struct cbfs_image *image, + const char *blob_name, + fit_offset_converter_t offset_helper, + const size_t max_fit_entries); + #endif diff --git a/util/cbfstool/flashmap/fmap.c b/util/cbfstool/flashmap/fmap.c index f1d2fb9e0c..06f179f1f9 100644 --- a/util/cbfstool/flashmap/fmap.c +++ b/util/cbfstool/flashmap/fmap.c @@ -48,10 +48,9 @@ #include #include -#include -#include - +#include "fmap.h" #include "kv_pair.h" +#include "valstr.h" #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) diff --git a/util/cbfstool/ifittool.c b/util/cbfstool/ifittool.c new file mode 100644 index 0000000000..a83fd96715 --- /dev/null +++ b/util/cbfstool/ifittool.c @@ -0,0 +1,431 @@ +/* + * cbfstool, CLI utility for creating rmodules + * + * Copyright (C) 2019 9elements Agency GmbH + * Copyright (C) 2019 Facebook 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 +#include + +#include "common.h" +#include "cbfs_image.h" +#include "partitioned_file.h" +#include "fit.h" + +/* Global variables */ +partitioned_file_t *image_file; + +static const char *optstring = "H:j:f:r:d:t:n:s:caDvh?"; +static struct option long_options[] = { + {"file", required_argument, 0, 'f' }, + {"region", required_argument, 0, 'r' }, + {"add-cbfs-entry", no_argument, 0, 'a' }, + {"add-region", no_argument, 0, 'A' }, + {"del-entry", required_argument, 0, 'd' }, + {"clear-table", no_argument, 0, 'c' }, + {"fit-type", required_argument, 0, 't' }, + {"cbfs-filename", required_argument, 0, 'n' }, + {"max-table-size", required_argument, 0, 's' }, + {"topswap-size", required_argument, 0, 'j' }, + {"dump", no_argument, 0, 'D' }, + {"verbose", no_argument, 0, 'v' }, + {"help", no_argument, 0, 'h' }, + {"header-offset", required_argument, 0, 'H' }, + {NULL, 0, 0, 0 } +}; + +static void usage(const char *name) +{ + printf( + "ifittool: utility for modifying Intel Firmware Interface Table\n\n" + "USAGE: %s [-h] [-H] [-v] [-D] [-c] <-f|--file name> <-s|--max-table-size size> <-r|--region fmap region> OPERATION\n" + "\tOPERATION:\n" + "\t\t-a|--add-entry : Add a CBFS file as new entry to FIT\n" + "\t\t-A|--add-region : Add region as new entry to FIT (for microcodes)\n" + "\t\t-d|--del-entry number : Delete existing entry\n" + "\t\t-t|--fit-type : Type of new entry\n" + "\t\t-n|--name : The CBFS filename or region to add to table\n" + "\tOPTIONAL ARGUMENTS:\n" + "\t\t-h|--help : Display this text\n" + "\t\t-H|--header-offset : Do not search for header, use this offset\n" + "\t\t-v|--verbose : Be verbose\n" + "\t\t-D|--dump : Dump FIT table (at end of operation)\n" + "\t\t-c|--clear-table : Remove all existing entries (do not update)\n" + "\t\t-j|--topswap-size : Use second FIT table if non zero\n" + "\tREQUIRED ARGUMENTS:\n" + "\t\t-f|--file name : The file containing the CBFS\n" + "\t\t-s|--max-table-size : The number of possible FIT entries in table\n" + "\t\t-r|--region : The FMAP region to operate on\n" + , name); +} + +static int is_valid_topswap(size_t topswap_size) +{ + switch (topswap_size) { + case (64 * KiB): + case (128 * KiB): + case (256 * KiB): + case (512 * KiB): + case (1 * MiB): + break; + default: + ERROR("Invalid topswap_size %zd\n", topswap_size); + ERROR("topswap can be 64K|128K|256K|512K|1M\n"); + return 0; + } + return 1; +} + +/* + * Converts between offsets from the start of the specified image region and + * "top-aligned" offsets from the top of the entire boot media. See comment + * below for convert_to_from_top_aligned() about forming addresses. + */ +static unsigned int convert_to_from_absolute_top_aligned( + const struct buffer *region, unsigned int offset) +{ + assert(region); + + size_t image_size = partitioned_file_total_size(image_file); + + return image_size - region->offset - offset; +} + +/* + * Converts between offsets from the start of the specified image region and + * "top-aligned" offsets from the top of the image region. Works in either + * direction: pass in one type of offset and receive the other type. + * N.B. A top-aligned offset is always a positive number, and should not be + * confused with a top-aligned *address*, which is its arithmetic inverse. */ +static unsigned int convert_to_from_top_aligned(const struct buffer *region, + unsigned int offset) +{ + assert(region); + + /* Cover the situation where a negative base address is given by the + * user. Callers of this function negate it, so it'll be a positive + * number smaller than the region. + */ + if ((offset > 0) && (offset < region->size)) + return region->size - offset; + + return convert_to_from_absolute_top_aligned(region, offset); +} + +/* + * Get a pointer from an offset. This function assumes the ROM is located + * in the host address space at [4G - romsize -> 4G). It also assume all + * pointers have values within this address range. + */ +static inline uint32_t offset_to_ptr(fit_offset_converter_t helper, + const struct buffer *region, int offset) +{ + return -helper(region, offset); +} + +enum fit_operation { + NO_OP = 0, + ADD_CBFS_OP, + ADD_REGI_OP, + ADD_ADDR_OP, + DEL_OP +}; + +int main(int argc, char *argv[]) +{ + int c; + const char *input_file = NULL; + const char *name = NULL; + const char *region_name = NULL; + enum fit_operation op = NO_OP; + bool dump = false, clear_table = false; + size_t max_table_size = 0; + size_t table_entry = 0; + uint32_t addr = 0; + size_t topswap_size = 0; + enum fit_type fit_type = 0; + uint32_t headeroffset = ~0u; + + verbose = 0; + + if (argc < 4) { + usage(argv[0]); + return 1; + } + + while (1) { + int optindex = 0; + char *suffix = NULL; + + c = getopt_long(argc, argv, optstring, long_options, &optindex); + + if (c == -1) + break; + + switch (c) { + case 'h': + usage(argv[0]); + return 1; + case 'a': + if (op != NO_OP) { + ERROR("specified multiple actions at once\n"); + usage(argv[0]); + return 1; + } + op = ADD_CBFS_OP; + break; + case 'A': + if (op != NO_OP) { + ERROR("specified multiple actions at once\n"); + usage(argv[0]); + return 1; + } + op = ADD_REGI_OP; + break; + case 'x': + if (op != NO_OP) { + ERROR("specified multiple actions at once\n"); + usage(argv[0]); + return 1; + } + op = ADD_ADDR_OP; + addr = atoll(optarg); + break; + case 'c': + clear_table = true; + break; + case 'd': + if (op != NO_OP) { + ERROR("specified multiple actions at once\n"); + usage(argv[0]); + return 1; + } + op = DEL_OP; + table_entry = atoi(optarg); + break; + case 'D': + dump = true; + break; + case 'f': + input_file = optarg; + break; + case 'H': + headeroffset = strtoul(optarg, &suffix, 0); + if (!*optarg || (suffix && *suffix)) { + ERROR("Invalid header offset '%s'.\n", optarg); + return 1; + } + break; + case 'j': + topswap_size = atoi(optarg); + if (!is_valid_topswap(topswap_size)) + return 1; + break; + case 'n': + name = optarg; + break; + case 'r': + region_name = optarg; + break; + case 's': + max_table_size = atoi(optarg); + break; + case 't': + fit_type = atoi(optarg); + break; + case 'v': + verbose++; + break; + default: + break; + } + } + + if (input_file == NULL) { + ERROR("No input file given\n"); + usage(argv[0]); + return 1; + } + + if (op == ADD_CBFS_OP || op == ADD_REGI_OP) { + if (fit_type == 0) { + ERROR("Adding FIT entry, but no type given\n"); + usage(argv[0]); + return 1; + } else if (name == NULL) { + ERROR("Adding FIT entry, but no name set\n"); + usage(argv[0]); + return 1; + } else if (max_table_size == 0) { + ERROR("Maximum table size not given\n"); + usage(argv[0]); + return 1; + } + } + if (op == ADD_ADDR_OP) { + if (fit_type == 0) { + ERROR("Adding FIT entry, but no type given\n"); + usage(argv[0]); + return 1; + } else if (max_table_size == 0) { + ERROR("Maximum table size not given\n"); + usage(argv[0]); + return 1; + } + } + + if (!region_name) { + ERROR("Region not given\n"); + usage(argv[0]); + return 1; + } + + image_file = partitioned_file_reopen(input_file, + op != NO_OP || clear_table); + + struct buffer image_region; + + if (!partitioned_file_read_region(&image_region, image_file, + region_name)) { + partitioned_file_close(image_file); + ERROR("The image will be left unmodified.\n"); + return 1; + } + + struct buffer bootblock; + // The bootblock is part of the CBFS on x86 + buffer_clone(&bootblock, &image_region); + + struct cbfs_image image; + if (cbfs_image_from_buffer(&image, &image_region, headeroffset)) { + partitioned_file_close(image_file); + return 1; + } + + struct fit_table *fit = fit_get_table(&bootblock, + convert_to_from_top_aligned, + topswap_size); + if (!fit) { + partitioned_file_close(image_file); + ERROR("FIT not found.\n"); + return 1; + } + + if (clear_table) { + if (fit_clear_table(fit)) { + partitioned_file_close(image_file); + ERROR("Failed to clear table.\n"); + return 1; + } + } + + switch (op) { + case ADD_REGI_OP: + { + struct buffer region; + addr = 0; + + if (partitioned_file_read_region(®ion, image_file, name)) { + addr = -convert_to_from_top_aligned(®ion, 0); + } else { + partitioned_file_close(image_file); + return 1; + } + + if (fit_add_entry(fit, addr, 0, fit_type, max_table_size)) { + partitioned_file_close(image_file); + ERROR("Adding type %u FIT entry\n", fit_type); + return 1; + } + break; + } + case ADD_CBFS_OP: + { + if (fit_type == FIT_TYPE_MICROCODE) { + if (fit_add_microcode_file(fit, &image, name, + convert_to_from_top_aligned, + max_table_size)) { + return 1; + } + } else { + uint32_t offset, len; + struct cbfs_file *cbfs_file; + + cbfs_file = cbfs_get_entry(&image, name); + if (!cbfs_file) { + partitioned_file_close(image_file); + ERROR("%s not found in CBFS.\n", name); + return 1; + } + + len = ntohl(cbfs_file->len); + offset = offset_to_ptr(convert_to_from_top_aligned, + &image.buffer, + cbfs_get_entry_addr(&image, cbfs_file) + + ntohl(cbfs_file->offset)); + + + if (fit_add_entry(fit, offset, len, fit_type, + max_table_size)) { + partitioned_file_close(image_file); + ERROR("Adding type %u FIT entry\n", fit_type); + return 1; + } + } + break; + } + case ADD_ADDR_OP: + { + if (fit_add_entry(fit, addr, 0, fit_type, max_table_size)) { + partitioned_file_close(image_file); + ERROR("Adding type %u FIT entry\n", fit_type); + return 1; + } + } + break; + case DEL_OP: + { + if (fit_delete_entry(fit, table_entry)) { + partitioned_file_close(image_file); + ERROR("Deleting FIT entry %zu failed\n", table_entry); + return 1; + } + break; + } + case NO_OP: + default: + break; + } + + if (op != NO_OP || clear_table) { + if (!partitioned_file_write_region(image_file, &bootblock)) { + ERROR("Failed to write changes to disk.\n"); + partitioned_file_close(image_file); + return 1; + } + } + + if (dump) { + if (fit_dump(fit)) { + partitioned_file_close(image_file); + return 1; + } + } + + partitioned_file_close(image_file); + + return 0; +} diff --git a/util/lint/lint-007-checkpatch b/util/lint/lint-007-checkpatch index afa593e3b0..a7b63e8d7c 100755 --- a/util/lint/lint-007-checkpatch +++ b/util/lint/lint-007-checkpatch @@ -28,6 +28,8 @@ EXCLUDED_DIRS="^payloads/libpayload/util/kconfig\|\ ^src/vendorcode\|\ ^Documentation" +opts="--max-line-length 96" + # default: test src and util if [ "$1" = "" ]; then INCLUDED_DIRS="src util" @@ -35,7 +37,7 @@ if [ "$1" = "" ]; then elif [ "$1" = "diff" ]; then args=$( echo $EXCLUDED_DIRS | \ sed -e 's,\\|, ,g' -e 's,\^,--exclude=,g' ) - util/lint/checkpatch.pl --quiet --no-signoff $args - + util/lint/checkpatch.pl --quiet --no-signoff $opts $args - exit $? # Space separated list of directories to test else @@ -49,5 +51,5 @@ FILELIST=$( git ls-files $INCLUDED_DIRS | \ grep -v $EXCLUDED_DIRS ) for FILE in $FILELIST; do - util/lint/checkpatch.pl --show-types --file --quiet "$FILE" + util/lint/checkpatch.pl --show-types --file --quiet $opts "$FILE" done diff --git a/util/superiotool/nuvoton.c b/util/superiotool/nuvoton.c index 82772e78a7..81bff96eab 100644 --- a/util/superiotool/nuvoton.c +++ b/util/superiotool/nuvoton.c @@ -582,6 +582,68 @@ static const struct superio_registers reg_table[] = { {0x30,0xe0,0xe1,0xe2,0xe3,EOT}, {0x20,0x20,0x04,0x05,0x01,EOT}}, {EOT}}}, + {0xd121, "NCT5539D", { + {NOLDN, NULL, + {0x10,0x11,0x13,0x14,0x1a,0x1b,0x1c,0x1d,0x22,0x24, + 0x25,0x26,0x27,0x28,0x2a,0x2b,0x2c,0x2d,0x2f,EOT}, + {0xff,0xff,0x00,0x00,0x30,0x50,0x10,0x00,0xff,0x04, + 0x00,MISC,0x03,0x00,0xc0,0x00,0x01,MISC,MISC,EOT}}, + {0x02, "UART A", + {0x30,0x60,0x61,0x70,0xf0,0xf2,EOT}, + {0x01,0x03,0xf8,0x04,0x00,0x00,EOT}}, + {0x05, "Keyboard Controller", + {0x30,0x60,0x61,0x62,0x63,0x70,0x72,0xf0,EOT}, + {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x83,EOT}}, + {0x06, "Consumer IR", + {0x30,0x60,0x61,0x70,EOT}, + {0x00,0x00,0x00,0x00,EOT}}, + {0x07, "GPIO 7, GPIO 8", + {0x30,0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xec,0xed,EOT}, + {0x00,0xff,NANA,0x00,NANA,0xff,NANA,0x00,NANA,0x00,0x00,EOT}}, + {0x08, "WDT1, WDT3, GPIO 0, KBC P20", + {0x30,0x60,0x61,0xe0,0xe1,0xe2,0xe3,0xe4,0xf5,0xf6, + 0xf7,0xf8,0xf9,0xfa,0xfe,0xff,EOT}, + {0x00,0x00,0x00,0xff,NANA,0x00,NANA,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00, 0x00,EOT}}, + {0x09, "GPIO 2, GPIO 3, GPIO 4, GPIO 5", + {0x30,0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8, + 0xe9,0xea,0xeb,0xee, 0xf0,0xf1,0xf2,0xf4,0xf5,0xf6,0xf7,EOT}, + {0x00,0xff,NANA,0x00,NANA,0x7f,NANA,0x00,NANA,NANA, + 0x00,0x00,0x00,0x00,0xff,NANA,0x00,0xff,NANA,0x00,NANA,EOT}}, + {0x0a, "ACPI", + {0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe9,0xec, + 0xed,0xee,0xf0,0xf1,0xf2,0xf3,0xf6,0xf7,0xfc,EOT}, + {0x01,0x00,0x00,0x00,0x00,0x02,0x1a,0x00,0x00,0x00, + 0x01,0x00,0x10,0x48,0x5c,0x00,0x00,0xc0,0x80,EOT}}, + {0x0b, "Hardware Monitor, Front Panel LED", + {0x30,0x60,0x61,0x70,0xe0,0xe1,0xe2,0xe3,0xe4,0xe5, + 0xe6,0xe7,0xec,0xed,0xf0,0xf1,0xf2,0xf6,0xf7,0xf8, + 0xf9,0xfa,0xfb,0xfc,EOT}, + {0x00,0x00,0x00,0x00,0x7f,0x7f,0x7f,0x7f,0x7f,0xa8, + 0x08,0x7f,0x00,0x81,0x00,0x00,0x00,0x00,0x87,0x47, + 0x00,0x00,0x00,0x02,EOT}}, + {0x0d, "WDT2", + {0xe7,0xe8,0xeb,0xed,0xf0,0xf3,EOT}, + {0x10,0x32,0x14,0x00,0x00,0x00,EOT}}, + {0x0e, "CIR Wake-Up", + {0x30,0x60,0x61,0x70,EOT}, + {0x00,0x00,0x00,0x00,EOT}}, + {0x0f, "GPIO Push-Pull or Open-Drain selection", + {0xe1,0xe2,0xe3,0xe4,0xe6,0xe7,0xe9,EOT}, + {0xff,0x7f,0xff,0xff,0xff,0xff,0xff,EOT}}, + {0x11, "GPIO, RI PSOUT Wake-Up Status", + {0xe1,0xe2,0xe9,EOT}, + {0x00,0x00,0x00,EOT}}, + {0x12, "SW Error Control", + {0xe1,0xe7,0xea,0xeb,0xec,EOT}, + {0x00,0x00,0x10,0x00,0x00,EOT}}, + {0x15, "Fading LED", + {0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,EOT}, + {0xff,0x7f,0x00,0x56,0x56,0x17,0x00,0x0f,0x10,EOT}}, + {0x16, "Deep Sleep", + {0x30,0xe0,0xe1,0xe2,0xe3,EOT}, + {0xa0,0x20,0x04,0x05,0x01,EOT}}, + {EOT}}}, {EOT} }; diff --git a/util/xcompile/xcompile b/util/xcompile/xcompile index 7ab1cb7af8..e8d6677994 100755 --- a/util/xcompile/xcompile +++ b/util/xcompile/xcompile @@ -162,7 +162,7 @@ testas() { "elf32-i386" ) LDFLAGS="$LDFLAGS -melf_i386" CFLAGS_GCC="$CFLAGS_GCC -Wl,-b,elf32-i386 -Wl,-melf_i386" - CFLAGS_CLANG="$CFLAGS_GCC -Wl,-b,elf32-i386 -Wl,-melf_i386" + CFLAGS_CLANG="$CFLAGS_CLANG -Wl,-b,elf32-i386 -Wl,-melf_i386" ;; esac @@ -225,6 +225,9 @@ SUBARCH_SUPPORTED+=${TSUPP-${TARCH}} # GCC GCC_CC_${TARCH}:=${GCC} GCC_CFLAGS_${TARCH}:=${CFLAGS_GCC} +# Generally available for GCC's cc1: +GCC_CFLAGS_${TARCH}+=-Wlogical-op +GCC_ADAFLAGS_${TARCH}:=${CFLAGS_GCC} GCC_COMPILER_RT_${TARCH}:=${CC_RT_GCC} GCC_COMPILER_RT_FLAGS_${TARCH}:=${CC_RT_EXTRA_GCC}