Skip to contentSkip to conversation

dm: Add programatic generation of ACPI tables (part D)

PATCH Superseded Simon Glass 5 participants 80 messages Sep 6, 2020 – Sep 22, 2020

Subsystems (5)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover dm: Add programatic generation of ACPI tables (part D)

Note: This is part D of this effort. With this, Coral includes all required ACPI tables.

At present on x86 U-Boot supports creating ACPI (Advanced Configuration and Power Interface) tables using the Intel ACPI Source Language (ASL) compiler.

This is good enough for basic operation but some devices need to add their information dynamically at runtime. An example is a device that needs to report its enable GPIO. This is described in the device tree, so we want to add code in the driver to convert that device-tree description into an ACPI description for use on Linux.

This series adds support for generation of ACPI tables and fragments by devices. The core support is built into driver model.

Several files are brought over from coreboot to do the actual generation.

As an example of using this new feature, chromebook_coral is updated to write out a wide array of ACPI tables including DSDT and SSDT.

This initial version of the series lays out the general approach. More work is needed to figure out the difference between CONFIG_ACPIGEN and CONFIG_GENERATE_ACPI_TABLE with respect to what is built.

Changes in v3:
- Rebase to master

Changes in v2:
- Add new patch to allow more space for U-Boot on link
- Add new patch to move include of bitops out of ACPI region
- Fix incorrect space in enable-off-delay-ms
- Rebase to master
- add new patch to fix polarity type in acpi_dp_add_gpio()

Changes in v1:
- Add NHLT audio support
- Add NHLT information
- Add comments
- Add more comments and rename cpu_get_bus_clock to cpu_get_bus_clock_khz()
- Add new patch with coral audio descriptor files
- Add support for NHLT table
- Adjust implementation to match new ACPI GPIO generation
- Capitalise ACPI_OPS_PTR
- Don't build for SPL
- Drop unnecessary callbacks
- Fix i2c PCI addresses
- Handle table generation without callbacks
- Move ASL_REVISION define into this patch
- Move acpi_create_dbg2() into generic code
- Move the acpi.h header file to this commit
- Move this code into an x86-specific file
- Put this code in an x86-specific place and update commit message
- Rename acpi-probed to linux,probed
- Rename cpi,hid-desc-reg-offset to hid-desc-addr
- Split PCT and PTC tables into a separate patch
- Support hid-over-i2c separately as well
- UIse hid-over-i2 compatible string
- Update ACPI ordering to include multiple CPUs
- Update commit message
- Update commit message with a comma
- Update for acpi_device_write_i2c_dev() return-value change
- Use OEM_TABLE_ID instead of ACPI_TABLE_CREATOR
- Use SHIFT and MASK for defines
- Use acpi,ddn instead of acpi,desc
- Use this file in APL
- Use updated acpi_device_write_dsm_i2c_hid() function

Simon Glass (57):
x86: acpi: Add cros_ec tables
x86: acpi: Add base asl files for common x86 devices
x86: acpi: apl: Add asl files for Apollo Lake
x86: acpi: Add DPTF asl files
x86: apl: Correct PCIE_ECAM_BASE
x86: Add a config for the systemagent PCIEX regions size
x86: Add a common global NVS structure
x86: acpi: Support external GNVS tables
x86: acpi: Expand the GNVS
x86: coral: Add ACPI tables for coral
acpi: Add support for writing a _PRW
acpi: Add support for conditions and return values
acpi: Support generating a multi-function _DSM for devices
dm: acpi: Use correct GPIO polarity type in acpi_dp_add_gpio()
x86: link: Allow more space for U-Boot
i2c: Add a generic driver to generate ACPI info
x86: Add wake sources for the acpi_gpe driver
x86: apl: Support writing the IntelGraphicsMem table
x86: acpi: Add a common routine to write WiFi info
x86: Add some definitions for SMM
x86: apl: Add power-management definitions
x86: apl: Update iomap for ACPI
x86: Add a few common Intel CPU functions
x86: acpi: Support generation of the HPET table
x86: acpi: Support generation of the DBG2 table
acpi: Add support for generating processor tables
x86: acpi: Add PCT and PTC tables
acpi: Add more support for generating processor tables
x86: acpi: Add common Intel ACPI tables
x86: Support Atom SoCs using SWSMISCI rather than the SWSCI
x86: acpi: Add support for additional Intel tables
x86: apl: Allow reading hostbridge base addresses
p2sb: Add some definitions used for ACPI
x86: apl: Generate required ACPI tables
x86: apl: Add support for hostbridge ACPI generation
x86: apl: Generate CPU tables
x86: apl: Generate ACPI table for LPC
x86: apl: Drop unnecessary code in PMC driver
tpm: cr50: Add ACPI support
x86: fsp: Update the FSP API with the end-firmware method
x86: cpu: Report address width from cpu_get_info()
x86: Sort the MTRR table
x86: Notify the FSP of the 'end firmware' event
x86: Correct the assembly guard in e820.h
x86: Add a header guard to asm/acpi_table.h
x86: Correct handling of MADT table CPUs
acpi: tpm: Add a TPM2 table
acpi: tpm: Add a TPM1 table
x86: acpi: Set the log category for x86 table generation
x86: coral: Add audio descriptor files
x86: apl: Check low-level init in FSP-S pre-init
x86: fsp: Add more debugging for silicon init
x86: fsp: Show FSP-S or FSP-M address in fsp_get_header()
acpi: Use defines for field lengths
x86: Add a way to add to the e820 memory table
x86: Move include of bitops out of ACPI region
x86: coral: Update config and device tree for ACPI

 arch/x86/Kconfig                              |  47 ++
 arch/x86/cpu/apollolake/Kconfig               |   4 +
 arch/x86/cpu/apollolake/Makefile              |   1 +
 arch/x86/cpu/apollolake/acpi.c                | 211 ++++++
 arch/x86/cpu/apollolake/cpu.c                 |  77 +++
 arch/x86/cpu/apollolake/fsp_s.c               |   2 +
 arch/x86/cpu/apollolake/hostbridge.c          | 244 ++++++-
 arch/x86/cpu/apollolake/lpc.c                 |  18 +
 arch/x86/cpu/apollolake/pmc.c                 |   8 +-
 arch/x86/cpu/cpu.c                            |  15 +
 arch/x86/cpu/i386/cpu.c                       |  23 +
 arch/x86/cpu/intel_common/Makefile            |   7 +
 arch/x86/cpu/intel_common/acpi.c              | 377 ++++++++++
 arch/x86/cpu/intel_common/cpu.c               |  79 +++
 arch/x86/cpu/intel_common/generic_wifi.c      | 120 ++++
 arch/x86/cpu/intel_common/intel_opregion.c    | 168 +++++
 arch/x86/cpu/mtrr.c                           |  12 +
 arch/x86/cpu/x86_64/cpu.c                     |   5 +
 arch/x86/dts/chromebook_coral.dts             | 224 +++++-
 arch/x86/include/asm/acpi/chromeos.asl        | 108 +++
 arch/x86/include/asm/acpi/cpu.asl             |  25 +
 arch/x86/include/asm/acpi/cros_ec/ac.asl      |  22 +
 arch/x86/include/asm/acpi/cros_ec/als.asl     |  56 ++
 arch/x86/include/asm/acpi/cros_ec/battery.asl | 411 +++++++++++
 arch/x86/include/asm/acpi/cros_ec/cros_ec.asl |  57 ++
 arch/x86/include/asm/acpi/cros_ec/ec.asl      | 557 +++++++++++++++
 arch/x86/include/asm/acpi/cros_ec/emem.asl    |  53 ++
 .../asm/acpi/cros_ec/keyboard_backlight.asl   |  52 ++
 arch/x86/include/asm/acpi/cros_ec/pd.asl      |  15 +
 arch/x86/include/asm/acpi/cros_ec/superio.asl | 159 +++++
 arch/x86/include/asm/acpi/cros_ec/tbmc.asl    |  23 +
 arch/x86/include/asm/acpi/cros_gnvs.asl       |  29 +
 arch/x86/include/asm/acpi/dptf/charger.asl    |  65 ++
 arch/x86/include/asm/acpi/dptf/cpu.asl        | 186 +++++
 arch/x86/include/asm/acpi/dptf/dptf.asl       | 121 ++++
 arch/x86/include/asm/acpi/dptf/fan.asl        |  57 ++
 arch/x86/include/asm/acpi/dptf/thermal.asl    | 521 ++++++++++++++
 arch/x86/include/asm/acpi/global_nvs.h        |   5 +-
 arch/x86/include/asm/acpi/lpc.asl             | 141 ++++
 arch/x86/include/asm/acpi/pci_osc.asl         |  21 +
 arch/x86/include/asm/acpi/pcr.asl             |  80 +++
 arch/x86/include/asm/acpi/ramoops.asl         |  32 +
 arch/x86/include/asm/acpi/sleepstates.asl     |  12 +-
 arch/x86/include/asm/acpi_table.h             | 162 +++++
 arch/x86/include/asm/acpigen.h                |  35 +
 arch/x86/include/asm/arch-apollolake/acpi.h   |  18 +
 .../include/asm/arch-apollolake/acpi/dptf.asl |  35 +
 .../asm/arch-apollolake/acpi/globalnvs.asl    |  41 ++
 .../include/asm/arch-apollolake/acpi/gpio.asl | 191 ++++++
 .../asm/arch-apollolake/acpi/gpiolib.asl      | 109 +++
 .../include/asm/arch-apollolake/acpi/lpss.asl | 105 +++
 .../asm/arch-apollolake/acpi/northbridge.asl  | 120 ++++
 .../asm/arch-apollolake/acpi/pch_hda.asl      |  77 +++
 .../asm/arch-apollolake/acpi/pci_irqs.asl     |  52 ++
 .../include/asm/arch-apollolake/acpi/pcie.asl |  22 +
 .../asm/arch-apollolake/acpi/pcie_port.asl    | 113 +++
 .../asm/arch-apollolake/acpi/platform.asl     |  10 +
 .../asm/arch-apollolake/acpi/pmc_ipc.asl      |  49 ++
 .../include/asm/arch-apollolake/acpi/scs.asl  | 173 +++++
 .../asm/arch-apollolake/acpi/soc_int.asl      |  50 ++
 .../asm/arch-apollolake/acpi/southbridge.asl  |  34 +
 .../include/asm/arch-apollolake/acpi/xhci.asl |  33 +
 .../arch-apollolake/acpi/xhci_apl_ports.asl   |  23 +
 .../arch-apollolake/acpi/xhci_glk_ports.asl   |  24 +
 .../include/asm/arch-apollolake/global_nvs.h  |  23 +-
 arch/x86/include/asm/arch-apollolake/gpe.h    | 135 ++++
 arch/x86/include/asm/arch-apollolake/gpio.h   |   3 +
 arch/x86/include/asm/arch-apollolake/iomap.h  |  16 +
 arch/x86/include/asm/arch-apollolake/pm.h     |  40 +-
 .../include/asm/arch-apollolake/systemagent.h |  31 +
 arch/x86/include/asm/cpu.h                    |   9 +
 arch/x86/include/asm/cpu_common.h             |  56 ++
 arch/x86/include/asm/e820.h                   |   3 +-
 arch/x86/include/asm/fsp/fsp_api.h            |  15 +-
 arch/x86/include/asm/intel_acpi.h             |  52 ++
 arch/x86/include/asm/intel_gnvs.h             |  44 ++
 arch/x86/include/asm/intel_opregion.h         | 247 +++++++
 arch/x86/include/asm/smm.h                    |  27 +
 arch/x86/lib/Makefile                         |   1 +
 arch/x86/lib/acpi_table.c                     | 390 ++++++++++-
 arch/x86/lib/acpigen.c                        |  96 +++
 arch/x86/lib/fsp/fsp_common.c                 |  16 +
 arch/x86/lib/fsp/fsp_dram.c                   |  17 +
 arch/x86/lib/fsp/fsp_graphics.c               |  32 +
 arch/x86/lib/fsp2/fsp_silicon_init.c          |   4 +-
 arch/x86/lib/fsp2/fsp_support.c               |  22 +-
 board/google/chromebook_coral/Kconfig         |   2 +-
 board/google/chromebook_coral/Makefile        |   1 +
 .../chromebook_coral/baseboard_dptf.asl       |  71 ++
 board/google/chromebook_coral/coral.c         | 135 ++++
 .../chromebook_coral/dialog-2ch-48khz-24b.dat | Bin 0 -> 100 bytes
 .../chromebook_coral/dmic-1ch-48khz-16b.dat   | Bin 0 -> 3048 bytes
 .../chromebook_coral/dmic-2ch-48khz-16b.dat   | Bin 0 -> 3048 bytes
 .../chromebook_coral/dmic-4ch-48khz-16b.dat   | Bin 0 -> 3048 bytes
 board/google/chromebook_coral/dsdt.asl        |  60 ++
 .../max98357-render-2ch-48khz-24b.dat         | Bin 0 -> 116 bytes
 .../google/chromebook_coral/variant_dptf.asl  |   6 +
 board/google/chromebook_coral/variant_ec.h    |  75 ++
 board/google/chromebook_coral/variant_gpio.h  |  63 ++
 configs/chromebook_coral_defconfig            |  13 +-
 configs/chromebook_link_defconfig             |   2 +-
 doc/device-tree-bindings/chosen.txt           |  18 +
 doc/device-tree-bindings/device.txt           |   3 +
 doc/device-tree-bindings/i2c/generic-acpi.txt |  42 ++
 drivers/core/Kconfig                          |   9 +
 drivers/i2c/Makefile                          |   3 +
 drivers/i2c/acpi_i2c.c                        | 226 ++++++
 drivers/i2c/acpi_i2c.h                        |  15 +
 drivers/i2c/i2c-uclass.c                      |  17 +
 drivers/sound/max98357a.c                     |   2 +-
 drivers/tpm/cr50_i2c.c                        |  55 ++
 include/acpi/acpi_device.h                    |  69 ++
 include/acpi/acpi_dp.h                        |   2 +-
 include/acpi/acpi_s3.h                        |   4 +
 include/acpi/acpi_table.h                     | 140 +++-
 include/acpi/acpigen.h                        | 415 +++++++++++
 include/bloblist.h                            |   8 +
 include/i2c.h                                 |  23 +
 include/p2sb.h                                |   8 +
 include/power/acpi_pmc.h                      |   4 +-
 lib/acpi/acpi_device.c                        |  43 ++
 lib/acpi/acpi_dp.c                            |   4 +-
 lib/acpi/acpi_table.c                         |  64 ++
 lib/acpi/acpigen.c                            | 354 ++++++++++
 test/dm/acpi_dp.c                             |   4 +-
 test/dm/acpigen.c                             | 647 ++++++++++++++++++
 126 files changed, 9696 insertions(+), 116 deletions(-)
 create mode 100644 arch/x86/cpu/apollolake/acpi.c
 create mode 100644 arch/x86/cpu/intel_common/acpi.c
 create mode 100644 arch/x86/cpu/intel_common/generic_wifi.c
 create mode 100644 arch/x86/cpu/intel_common/intel_opregion.c
 create mode 100644 arch/x86/include/asm/acpi/chromeos.asl
 create mode 100644 arch/x86/include/asm/acpi/cpu.asl
 create mode 100644 arch/x86/include/asm/acpi/cros_ec/ac.asl
 create mode 100644 arch/x86/include/asm/acpi/cros_ec/als.asl
 create mode 100644 arch/x86/include/asm/acpi/cros_ec/battery.asl
 create mode 100644 arch/x86/include/asm/acpi/cros_ec/cros_ec.asl
 create mode 100644 arch/x86/include/asm/acpi/cros_ec/ec.asl
 create mode 100644 arch/x86/include/asm/acpi/cros_ec/emem.asl
 create mode 100644 arch/x86/include/asm/acpi/cros_ec/keyboard_backlight.asl
 create mode 100644 arch/x86/include/asm/acpi/cros_ec/pd.asl
 create mode 100644 arch/x86/include/asm/acpi/cros_ec/superio.asl
 create mode 100644 arch/x86/include/asm/acpi/cros_ec/tbmc.asl
 create mode 100644 arch/x86/include/asm/acpi/cros_gnvs.asl
 create mode 100644 arch/x86/include/asm/acpi/dptf/charger.asl
 create mode 100644 arch/x86/include/asm/acpi/dptf/cpu.asl
 create mode 100644 arch/x86/include/asm/acpi/dptf/dptf.asl
 create mode 100644 arch/x86/include/asm/acpi/dptf/fan.asl
 create mode 100644 arch/x86/include/asm/acpi/dptf/thermal.asl
 create mode 100644 arch/x86/include/asm/acpi/lpc.asl
 create mode 100644 arch/x86/include/asm/acpi/pci_osc.asl
 create mode 100644 arch/x86/include/asm/acpi/pcr.asl
 create mode 100644 arch/x86/include/asm/acpi/ramoops.asl
 create mode 100644 arch/x86/include/asm/acpigen.h
 create mode 100644 arch/x86/include/asm/arch-apollolake/acpi.h
 create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/dptf.asl
 create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/globalnvs.asl
 create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/gpio.asl
 create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/gpiolib.asl
 create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/lpss.asl
 create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/northbridge.asl
 create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/pch_hda.asl
 create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/pci_irqs.asl
 create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/pcie.asl
 create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/pcie_port.asl
 create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/platform.asl
 create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/pmc_ipc.asl
 create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/scs.asl
 create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/soc_int.asl
 create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/southbridge.asl
 create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/xhci.asl
 create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/xhci_apl_ports.asl
 create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/xhci_glk_ports.asl
 create mode 100644 arch/x86/include/asm/arch-apollolake/gpe.h
 create mode 100644 arch/x86/include/asm/intel_acpi.h
 create mode 100644 arch/x86/include/asm/intel_gnvs.h
 create mode 100644 arch/x86/include/asm/intel_opregion.h
 create mode 100644 arch/x86/include/asm/smm.h
 create mode 100644 arch/x86/lib/acpigen.c
 create mode 100644 board/google/chromebook_coral/baseboard_dptf.asl
 create mode 100644 board/google/chromebook_coral/dialog-2ch-48khz-24b.dat
 create mode 100644 board/google/chromebook_coral/dmic-1ch-48khz-16b.dat
 create mode 100644 board/google/chromebook_coral/dmic-2ch-48khz-16b.dat
 create mode 100644 board/google/chromebook_coral/dmic-4ch-48khz-16b.dat
 create mode 100644 board/google/chromebook_coral/dsdt.asl
 create mode 100644 board/google/chromebook_coral/max98357-render-2ch-48khz-24b.dat
 create mode 100644 board/google/chromebook_coral/variant_dptf.asl
 create mode 100644 board/google/chromebook_coral/variant_ec.h
 create mode 100644 board/google/chromebook_coral/variant_gpio.h
 create mode 100644 doc/device-tree-bindings/i2c/generic-acpi.txt
 create mode 100644 drivers/i2c/acpi_i2c.c
 create mode 100644 drivers/i2c/acpi_i2c.h
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#1 lore raw

PATCH v3 1/57 x86: acpi: Add cros_ec tables

Add ASL files for the Chrome OS EC, taken from coreboot.

---

(no changes since v1)

 arch/x86/include/asm/acpi/cros_ec/ac.asl      |  22 +
 arch/x86/include/asm/acpi/cros_ec/als.asl     |  56 ++
 arch/x86/include/asm/acpi/cros_ec/battery.asl | 411 +++++++++++++
 arch/x86/include/asm/acpi/cros_ec/cros_ec.asl |  57 ++
 arch/x86/include/asm/acpi/cros_ec/ec.asl      | 557 ++++++++++++++++++
 arch/x86/include/asm/acpi/cros_ec/emem.asl    |  53 ++
 .../asm/acpi/cros_ec/keyboard_backlight.asl   |  52 ++
 arch/x86/include/asm/acpi/cros_ec/pd.asl      |  15 +
 arch/x86/include/asm/acpi/cros_ec/superio.asl | 159 +++++
 arch/x86/include/asm/acpi/cros_ec/tbmc.asl    |  23 +
 10 files changed, 1405 insertions(+)
 create mode 100644 arch/x86/include/asm/acpi/cros_ec/ac.asl
 create mode 100644 arch/x86/include/asm/acpi/cros_ec/als.asl
 create mode 100644 arch/x86/include/asm/acpi/cros_ec/battery.asl
 create mode 100644 arch/x86/include/asm/acpi/cros_ec/cros_ec.asl
 create mode 100644 arch/x86/include/asm/acpi/cros_ec/ec.asl
 create mode 100644 arch/x86/include/asm/acpi/cros_ec/emem.asl
 create mode 100644 arch/x86/include/asm/acpi/cros_ec/keyboard_backlight.asl
 create mode 100644 arch/x86/include/asm/acpi/cros_ec/pd.asl
 create mode 100644 arch/x86/include/asm/acpi/cros_ec/superio.asl
 create mode 100644 arch/x86/include/asm/acpi/cros_ec/tbmc.asl
arch/x86/include/asm/acpi/cros_ec/ac.asl new file +22 -0
new file mode 100644
index 00000000000..80e0ebd3ad5
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2012 The Chromium OS Authors. All rights reserved.
+ */
+
+// Scope (EC0)
+
+Device (AC)
+{
+	Name (_HID, "ACPI0003")
+	Name (_PCL, Package () { \_SB })
+
+	Method (_PSR)
+	{
+		Return (ACEX)
+	}
+
+	Method (_STA)
+	{
+		Return (0x0F)
+	}
+}
arch/x86/include/asm/acpi/cros_ec/als.asl new file +56 -0

56 lines not on this page · raw message

arch/x86/include/asm/acpi/cros_ec/battery.asl new file +411 -0

411 lines not on this page · raw message

arch/x86/include/asm/acpi/cros_ec/cros_ec.asl new file +57 -0

57 lines not on this page · raw message

arch/x86/include/asm/acpi/cros_ec/ec.asl new file +557 -0

557 lines not on this page · raw message

arch/x86/include/asm/acpi/cros_ec/emem.asl new file +53 -0

53 lines not on this page · raw message

arch/x86/include/asm/acpi/cros_ec/keyboard_backlight.asl new file +52 -0

52 lines not on this page · raw message

arch/x86/include/asm/acpi/cros_ec/pd.asl new file +15 -0
new file mode 100644
index 00000000000..e55fde347c2
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2014 Google Inc.
+ */
+
+Device (ECPD)
+{
+	Name (_HID, "GOOG0003")
+	Name (_UID, 1)
+	Name (_DDN, "EC PD Device")
+	Method(_STA, 0)
+	{
+		Return (0xB)
+	}
+}
arch/x86/include/asm/acpi/cros_ec/superio.asl new file +159 -0

159 lines not on this page · raw message

arch/x86/include/asm/acpi/cros_ec/tbmc.asl new file +23 -0
new file mode 100644
index 00000000000..bfe38d668ed
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright 2017 Google Inc.
+ */
+
+Device (TBMC)
+{
+	Name (_HID, "GOOG0006")
+	Name (_UID, 1)
+	Name (_DDN, "Tablet Motion Control")
+	Method (TBMC)
+	{
+		If (LEqual (^^RCTM, One)) {
+			Return (0x1)
+		} Else {
+			Return (0x0)
+		}
+	}
+	Method(_STA, 0)
+	{
+		Return (0xB)
+	}
+}
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#2 lore raw

PATCH v3 2/57 x86: acpi: Add base asl files for common x86 devices

In reply to Simon Glass

Add common x86 ASL files, taken from coreboot.

---

(no changes since v1)

 arch/x86/include/asm/acpi/chromeos.asl    | 108 +++++++++++++++++
 arch/x86/include/asm/acpi/cpu.asl         |  25 ++++
 arch/x86/include/asm/acpi/cros_gnvs.asl   |  29 +++++
 arch/x86/include/asm/acpi/lpc.asl         | 141 ++++++++++++++++++++++
 arch/x86/include/asm/acpi/pci_osc.asl     |  21 ++++
 arch/x86/include/asm/acpi/pcr.asl         |  80 ++++++++++++
 arch/x86/include/asm/acpi/ramoops.asl     |  32 +++++
 arch/x86/include/asm/acpi/sleepstates.asl |  12 +-
 8 files changed, 443 insertions(+), 5 deletions(-)
 create mode 100644 arch/x86/include/asm/acpi/chromeos.asl
 create mode 100644 arch/x86/include/asm/acpi/cpu.asl
 create mode 100644 arch/x86/include/asm/acpi/cros_gnvs.asl
 create mode 100644 arch/x86/include/asm/acpi/lpc.asl
 create mode 100644 arch/x86/include/asm/acpi/pci_osc.asl
 create mode 100644 arch/x86/include/asm/acpi/pcr.asl
 create mode 100644 arch/x86/include/asm/acpi/ramoops.asl
arch/x86/include/asm/acpi/chromeos.asl new file +108 -0
new file mode 100644
index 00000000000..2a0fd33265d
@@ -0,0 +1,108 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2011 The ChromiumOS Authors.  All rights reserved.
+ */
+
+#ifdef CONFIG_CHROMEOS
+
+#define CONFIG_VBOOT_VBNV_OFFSET 0x26
+
+#include <asm/acpi/vbnv_layout.h>
+
+/* GPIO package generated at run time. */
+External (OIPG)
+
+Device (CRHW)
+{
+	Name(_HID, EISAID("GGL0001"))
+
+	Method(_STA, 0, Serialized)
+	{
+		Return (0xb)
+	}
+
+	Method(CHSW, 0, Serialized)
+	{
+		Name (WSHC, Package() { VBT3 })
+		Return (WSHC)
+	}
+
+	Method(FWID, 0, Serialized)
+	{
+		Name (DIW1, "")
+		ToString(VBT5, 63, DIW1)
+		Name (DIWF, Package() { DIW1 })
+		Return(DIWF)
+	}
+
+	Method(FRID, 0, Serialized)
+	{
+		Name (DIR1, "")
+		ToString(VBT6, 63, DIR1)
+		Name (DIRF, Package() { DIR1 })
+		Return (DIRF)
+	}
+
+	Method(HWID, 0, Serialized)
+	{
+		Name (DIW0, "")
+		ToString(VBT4, 255, DIW0)
+		Name (DIWH, Package() { DIW0 })
+		Return (DIWH)
+	}
+
+	Method(BINF, 0, Serialized)
+	{
+		Name (FNIB, Package() { VBT0, VBT1, VBT2, VBT7, VBT8 })
+		Return (FNIB)
+	}
+
+	Method(GPIO, 0, Serialized)
+	{
+		Return (OIPG)
+
+	}
+
+	Method(VBNV, 0, Serialized)
+	{
+		Name(VNBV, Package() {
+			// See src/vendorcode/google/chromeos/Kconfig
+			// for the definition of these:
+			CONFIG_VBOOT_VBNV_OFFSET,
+			VBOOT_VBNV_BLOCK_SIZE
+		})
+		Return(VNBV)
+	}
+
+	Method(VDAT, 0, Serialized)
+	{
+		Name(TAD0,"")
+		ToBuffer(CHVD, TAD0)
+		Name (TADV, Package() { TAD0 })
+		Return (TADV)
+	}
+
+	Method(FMAP, 0, Serialized)
+	{
+		Name(PAMF, Package() { VBT9 })
+		Return(PAMF)
+	}
+
+	Method(MECK, 0, Serialized)
+	{
+		Name(HASH, Package() { MEHH })
+		Return(HASH)
+	}
+
+	Method(MLST, 0, Serialized)
+	{
+		Name(TSLM, Package() { "CHSW", "FWID", "HWID", "FRID", "BINF",
+			   "GPIO", "VBNV", "VDAT", "FMAP", "MECK"
+		})
+		Return (TSLM)
+	}
+}
+
+#include "ramoops.asl"
+
+#endif
arch/x86/include/asm/acpi/cpu.asl new file +25 -0
new file mode 100644
index 00000000000..b20b3572f2b
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright 2019 Google LLC
+ */
+
+/* These come from the dynamically created CPU SSDT */
+External (\_PR.CNOT, MethodObj)
+
+/* Notify OS to re-read CPU tables */
+Method (PNOT)
+{
+	\_PR.CNOT (0x81)
+}
+
+/* Notify OS to re-read CPU _PPC limit */
+Method (PPCN)
+{
+	\_PR.CNOT (0x80)
+}
+
+/* Notify OS to re-read Throttle Limit tables */
+Method (TNOT)
+{
+	\_PR.CNOT (0x82)
+}
arch/x86/include/asm/acpi/cros_gnvs.asl new file +29 -0
new file mode 100644
index 00000000000..c20b64565e0
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright 2019 Google LLC
+ */
+
+/* This is the ChromeOS specific ACPI information needed by
+ * the mainboard's chromeos.asl
+ */
+
+VBT0,   32,	// 0x000 - Boot Reason
+VBT1,   32,	// 0x004 - Active Main Firmware
+VBT2,   32,	// 0x008 - Active EC Firmware
+VBT3,   16,	// 0x00c - CHSW
+VBT4, 2048,	// 0x00e - HWID
+VBT5,  512,	// 0x10e - FWID
+VBT6,  512,	// 0x14e - FRID
+VBT7,   32,	// 0x18e - active main firmware type
+VBT8,   32,	// 0x192 - Recovery Reason
+VBT9,   32,	// 0x196 - FMAP base address
+CHVD, 24576,	// 0x19a - VDAT space filled by verified boot
+VBTA,	32,	// 0xd9a - pointer to smbios FWID
+MEHH,  256,	// 0xd9e - Management Engine Hash
+RMOB,   32,	// 0xdbe - RAM oops base address
+RMOL,   32,	// 0xdc2 - RAM oops length
+ROVP,	32,	// 0xdc6 - pointer to RO_VPD
+ROVL,	32,	// 0xdca - size of RO_VPD
+RWVP,	32,	// 0xdce - pointer to RW_VPD
+RWVL,	32,	// 0xdd2 - size of RW_VPD
+		// 0xdd6
arch/x86/include/asm/acpi/lpc.asl new file +141 -0

141 lines not on this page · raw message

arch/x86/include/asm/acpi/pci_osc.asl new file +21 -0
new file mode 100644
index 00000000000..864556fa831
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2016 Intel Corp.
+ */
+
+#define PCI_OSC_UUID "33DB4D5B-1FF7-401C-9657-7441C03DD766"
+
+Scope (\_SB.PCI0) {
+	Method (_OSC, 4) {
+		/* Check for proper GUID */
+		If (LEqual (Arg0, ToUUID (PCI_OSC_UUID))) {
+			/* Let OS control everything */
+			Return (Arg3)
+		} Else {
+			/* Unrecognized UUID */
+			CreateDWordField (Arg3, 0, CDW1)
+			Or (CDW1, 4, CDW1)
+			Return (Arg3)
+		}
+	}
+}
arch/x86/include/asm/acpi/pcr.asl new file +80 -0

80 lines not on this page · raw message

arch/x86/include/asm/acpi/ramoops.asl new file +32 -0
new file mode 100644
index 00000000000..55939e1aa33
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2014 Google Inc.
+ */
+
+Scope (\_SB)
+{
+	Device(RMOP)
+	{
+		Name (_HID, "GOOG9999")
+		Name (_CID, "GOOG9999")
+		Name (_UID, 1)
+
+		Name (RBUF, ResourceTemplate()
+		{
+			Memory32Fixed (ReadWrite, 0, 0, MRES)
+		})
+
+		Method (_CRS)
+		{
+			CreateDwordField (^RBUF, ^MRES._BAS, RBAS)
+			CreateDwordField (^RBUF, ^MRES._LEN, RLEN)
+			Store (\RMOB, RBAS)
+			Store (\RMOL, RLEN)
+			Return (^RBUF)
+		}
+		Method(_STA, 0)
+		{
+			Return (0xB)
+		}
+	}
+}
arch/x86/include/asm/acpi/sleepstates.asl +7 -5
index 32e16a2c2f5..31aa69a5704 100644
@@ -6,9 +6,11 @@
  * Modified from coreboot src/soc/intel/baytrail/acpi/sleepstates.asl
  */
 
-Name(\_S0, Package() {0x0, 0x0, 0x0, 0x0})
-#ifdef CONFIG_HAVE_ACPI_RESUME
-Name(\_S3, Package() {0x5, 0x0, 0x0, 0x0})
+Name(\_S0, Package(){0x0,0x0,0x0,0x0})
+#if !IS_ENABLED(CONFIG_HAVE_ACPI_RESUME)
+Name(\_S1, Package(){0x1,0x0,0x0,0x0})
+#else
+Name(\_S3, Package(){0x5,0x0,0x0,0x0})
 #endif
-Name(\_S4, Package() {0x6, 0x0, 0x0, 0x0})
-Name(\_S5, Package() {0x7, 0x0, 0x0, 0x0})
+Name(\_S4, Package(){0x6,0x0,0x0,0x0})
+Name(\_S5, Package(){0x7,0x0,0x0,0x0})
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#3 lore raw

PATCH v3 2/57 x86: acpi: Add base asl files for common x86 devices

Hi Simon,

-----"Simon Glass" <[email protected]> schrieb: -----

Quoted 9 lines

Betreff: [PATCH v3 02/57] x86: acpi: Add base asl files for common x86 devices

Add common x86 ASL files, taken from coreboot.

---

(no changes since v1)

Quoted 16 lines
 arch/x86/include/asm/acpi/chromeos.asl    | 108 +++++++++++++++++
 arch/x86/include/asm/acpi/cpu.asl         |  25 ++++
 arch/x86/include/asm/acpi/cros_gnvs.asl   |  29 +++++
 arch/x86/include/asm/acpi/lpc.asl         | 141 ++++++++++++++++++++++
 arch/x86/include/asm/acpi/pci_osc.asl     |  21 ++++
 arch/x86/include/asm/acpi/pcr.asl         |  80 ++++++++++++
 arch/x86/include/asm/acpi/ramoops.asl     |  32 +++++
 arch/x86/include/asm/acpi/sleepstates.asl |  12 +-
 8 files changed, 443 insertions(+), 5 deletions(-)
 create mode 100644 arch/x86/include/asm/acpi/chromeos.asl
 create mode 100644 arch/x86/include/asm/acpi/cpu.asl
 create mode 100644 arch/x86/include/asm/acpi/cros_gnvs.asl
 create mode 100644 arch/x86/include/asm/acpi/lpc.asl
 create mode 100644 arch/x86/include/asm/acpi/pci_osc.asl
 create mode 100644 arch/x86/include/asm/acpi/pcr.asl
 create mode 100644 arch/x86/include/asm/acpi/ramoops.asl

There are recent (~June 2020) commits in coreboot which convert most ASL files to ASL 2.0. The ASL 2.0 syntax is much easier to read IMHO, and I think it would be good to update this patch to take advantage of the recent coreboot developments. See e.g. the commit at [1].

regards, Wolfgang

[1] https://github.com/coreboot/coreboot/commit/03248033e7be6f81ad5b60ed21a60071aee32c67

#4 lore raw

PATCH v3 2/57 x86: acpi: Add base asl files for common x86 devices

Hi Wolfgang,

Quoted 30 lines · Wolfgang Wallner

Hi Simon,

-----"Simon Glass" <[email protected]> schrieb: -----

Quoted 9 lines

Betreff: [PATCH v3 02/57] x86: acpi: Add base asl files for common x86 devices

Add common x86 ASL files, taken from coreboot.

---

(no changes since v1)

Quoted 16 lines
 arch/x86/include/asm/acpi/chromeos.asl    | 108 +++++++++++++++++
 arch/x86/include/asm/acpi/cpu.asl         |  25 ++++
 arch/x86/include/asm/acpi/cros_gnvs.asl   |  29 +++++
 arch/x86/include/asm/acpi/lpc.asl         | 141 ++++++++++++++++++++++
 arch/x86/include/asm/acpi/pci_osc.asl     |  21 ++++
 arch/x86/include/asm/acpi/pcr.asl         |  80 ++++++++++++
 arch/x86/include/asm/acpi/ramoops.asl     |  32 +++++
 arch/x86/include/asm/acpi/sleepstates.asl |  12 +-
 8 files changed, 443 insertions(+), 5 deletions(-)
 create mode 100644 arch/x86/include/asm/acpi/chromeos.asl
 create mode 100644 arch/x86/include/asm/acpi/cpu.asl
 create mode 100644 arch/x86/include/asm/acpi/cros_gnvs.asl
 create mode 100644 arch/x86/include/asm/acpi/lpc.asl
 create mode 100644 arch/x86/include/asm/acpi/pci_osc.asl
 create mode 100644 arch/x86/include/asm/acpi/pcr.asl
 create mode 100644 arch/x86/include/asm/acpi/ramoops.asl
Quoted 4 lines

There are recent (~June 2020) commits in coreboot which convert most ASL files to ASL 2.0. The ASL 2.0 syntax is much easier to read IMHO, and I think it would be good to update this patch to take advantage of the recent coreboot developments. See e.g. the commit at [1].

Yes that looks nicer, but I have everything working and tested now so don't want to go back and unpick things. This seems like something we can pick up once we finally have this in the tree. The good thing is that this is just a syntax change as I understand it.

A WFH project has been putting a few Chromebooks in my lab, and I expect to put coral in there once everything lands. That should give us the confidence to make minor and major changes in future.

Regards,
SImon

Quoted 4 lines

[1] https://github.com/coreboot/coreboot/commit/03248033e7be6f81ad5b60ed21a60071aee32c67

#5 lore raw

PATCH v3 2/57 x86: acpi: Add base asl files for common x86 devices

Hi Simon,

-----"Simon Glass" <[email protected]> schrieb: -----

Quoted 41 lines

Betreff: Re: [PATCH v3 02/57] x86: acpi: Add base asl files for common x86 devices

Hi Wolfgang,

Quoted 30 lines · Wolfgang Wallner

Hi Simon,

-----"Simon Glass" <[email protected]> schrieb: -----

Quoted 9 lines

Betreff: [PATCH v3 02/57] x86: acpi: Add base asl files for common x86 devices

Add common x86 ASL files, taken from coreboot.

---

(no changes since v1)

Quoted 16 lines
 arch/x86/include/asm/acpi/chromeos.asl    | 108 +++++++++++++++++
 arch/x86/include/asm/acpi/cpu.asl         |  25 ++++
 arch/x86/include/asm/acpi/cros_gnvs.asl   |  29 +++++
 arch/x86/include/asm/acpi/lpc.asl         | 141 ++++++++++++++++++++++
 arch/x86/include/asm/acpi/pci_osc.asl     |  21 ++++
 arch/x86/include/asm/acpi/pcr.asl         |  80 ++++++++++++
 arch/x86/include/asm/acpi/ramoops.asl     |  32 +++++
 arch/x86/include/asm/acpi/sleepstates.asl |  12 +-
 8 files changed, 443 insertions(+), 5 deletions(-)
 create mode 100644 arch/x86/include/asm/acpi/chromeos.asl
 create mode 100644 arch/x86/include/asm/acpi/cpu.asl
 create mode 100644 arch/x86/include/asm/acpi/cros_gnvs.asl
 create mode 100644 arch/x86/include/asm/acpi/lpc.asl
 create mode 100644 arch/x86/include/asm/acpi/pci_osc.asl
 create mode 100644 arch/x86/include/asm/acpi/pcr.asl
 create mode 100644 arch/x86/include/asm/acpi/ramoops.asl
Quoted 4 lines

There are recent (~June 2020) commits in coreboot which convert most ASL files to ASL 2.0. The ASL 2.0 syntax is much easier to read IMHO, and I think it would be good to update this patch to take advantage of the recent coreboot developments. See e.g. the commit at [1].

Quoted 4 lines

Yes that looks nicer, but I have everything working and tested now so don't want to go back and unpick things. This seems like something we can pick up once we finally have this in the tree. The good thing is that this is just a syntax change as I understand it.

Fair enough. Yes, it should only be a syntax change.

Regardingn testing: I haven't tested individual patches of part D, but I have tested the complete series. After applying the fix for the DSDT length my ApolloLake board has booted reliably with ACPI enabled.

I have some remaining issues that I haven't gone after yet (e.g. I see a machine check error in the log), but the board always boots.

Quoted 9 lines

A WFH project has been putting a few Chromebooks in my lab, and I expect to put coral in there once everything lands. That should give us the confidence to make minor and major changes in future.

Regards,
SImon

Quoted 2 lines

[1] https://github.com/coreboot/coreboot/commit/03248033e7be6f81ad5b60ed21a60071aee32c67

regards, Wolfgang

#6 lore raw

PATCH v3 2/57 x86: acpi: Add base asl files for common x86 devices

Hi Wolfgang,

Quoted 50 lines · Wolfgang Wallner

Hi Simon,

-----"Simon Glass" <[email protected]> schrieb: -----

Quoted 41 lines

Betreff: Re: [PATCH v3 02/57] x86: acpi: Add base asl files for common x86 devices

Hi Wolfgang,

Quoted 30 lines · Wolfgang Wallner

Hi Simon,

-----"Simon Glass" <[email protected]> schrieb: -----

Quoted 9 lines

Betreff: [PATCH v3 02/57] x86: acpi: Add base asl files for common x86 devices

Add common x86 ASL files, taken from coreboot.

---

(no changes since v1)

Quoted 16 lines
 arch/x86/include/asm/acpi/chromeos.asl    | 108 +++++++++++++++++
 arch/x86/include/asm/acpi/cpu.asl         |  25 ++++
 arch/x86/include/asm/acpi/cros_gnvs.asl   |  29 +++++
 arch/x86/include/asm/acpi/lpc.asl         | 141 ++++++++++++++++++++++
 arch/x86/include/asm/acpi/pci_osc.asl     |  21 ++++
 arch/x86/include/asm/acpi/pcr.asl         |  80 ++++++++++++
 arch/x86/include/asm/acpi/ramoops.asl     |  32 +++++
 arch/x86/include/asm/acpi/sleepstates.asl |  12 +-
 8 files changed, 443 insertions(+), 5 deletions(-)
 create mode 100644 arch/x86/include/asm/acpi/chromeos.asl
 create mode 100644 arch/x86/include/asm/acpi/cpu.asl
 create mode 100644 arch/x86/include/asm/acpi/cros_gnvs.asl
 create mode 100644 arch/x86/include/asm/acpi/lpc.asl
 create mode 100644 arch/x86/include/asm/acpi/pci_osc.asl
 create mode 100644 arch/x86/include/asm/acpi/pcr.asl
 create mode 100644 arch/x86/include/asm/acpi/ramoops.asl
Quoted 4 lines

There are recent (~June 2020) commits in coreboot which convert most ASL files to ASL 2.0. The ASL 2.0 syntax is much easier to read IMHO, and I think it would be good to update this patch to take advantage of the recent coreboot developments. See e.g. the commit at [1].

Quoted 4 lines

Yes that looks nicer, but I have everything working and tested now so don't want to go back and unpick things. This seems like something we can pick up once we finally have this in the tree. The good thing is that this is just a syntax change as I understand it.

Quoted 6 lines

Fair enough. Yes, it should only be a syntax change.

Regardingn testing: I haven't tested individual patches of part D, but I have tested the complete series. After applying the fix for the DSDT length my ApolloLake board has booted reliably with ACPI enabled.

Will you add the "Tested-by" tag for this series?

BTW: any plan to upstream your board support?

Quoted 3 lines

I have some remaining issues that I haven't gone after yet (e.g. I see a machine check error in the log), but the board always boots.

Regards,
Bin

#7 lore raw

PATCH v3 2/57 x86: acpi: Add base asl files for common x86 devices

Hi Bin,

-----"Bin Meng" <[email protected]> schrieb: -----

Quoted 56 lines

Betreff: Re: [PATCH v3 02/57] x86: acpi: Add base asl files for common x86 devices

Hi Wolfgang,

Quoted 50 lines · Wolfgang Wallner

Hi Simon,

-----"Simon Glass" <[email protected]> schrieb: -----

Quoted 45 lines

Betreff: Re: [PATCH v3 02/57] x86: acpi: Add base asl files for common x86 devices

Hi Wolfgang,

Quoted 30 lines · Wolfgang Wallner

Hi Simon,

-----"Simon Glass" <[email protected]> schrieb: -----

Quoted 9 lines

Betreff: [PATCH v3 02/57] x86: acpi: Add base asl files for common x86 devices

Add common x86 ASL files, taken from coreboot.

---

(no changes since v1)

Quoted 16 lines
 arch/x86/include/asm/acpi/chromeos.asl    | 108 +++++++++++++++++
 arch/x86/include/asm/acpi/cpu.asl         |  25 ++++
 arch/x86/include/asm/acpi/cros_gnvs.asl   |  29 +++++
 arch/x86/include/asm/acpi/lpc.asl         | 141 ++++++++++++++++++++++
 arch/x86/include/asm/acpi/pci_osc.asl     |  21 ++++
 arch/x86/include/asm/acpi/pcr.asl         |  80 ++++++++++++
 arch/x86/include/asm/acpi/ramoops.asl     |  32 +++++
 arch/x86/include/asm/acpi/sleepstates.asl |  12 +-
 8 files changed, 443 insertions(+), 5 deletions(-)
 create mode 100644 arch/x86/include/asm/acpi/chromeos.asl
 create mode 100644 arch/x86/include/asm/acpi/cpu.asl
 create mode 100644 arch/x86/include/asm/acpi/cros_gnvs.asl
 create mode 100644 arch/x86/include/asm/acpi/lpc.asl
 create mode 100644 arch/x86/include/asm/acpi/pci_osc.asl
 create mode 100644 arch/x86/include/asm/acpi/pcr.asl
 create mode 100644 arch/x86/include/asm/acpi/ramoops.asl
Quoted 4 lines

There are recent (~June 2020) commits in coreboot which convert most ASL files to ASL 2.0. The ASL 2.0 syntax is much easier to read IMHO, and I think it would be good to update this patch to take advantage of the recent coreboot developments. See e.g. the commit at [1].

Yes that looks nicer, but I have everything working and tested now so don't want to go back and unpick things. This seems like something we can pick up once we finally have this in the tree. The good thing is that this is just a syntax change as I understand it.

Quoted 8 lines
Quoted 6 lines

Fair enough. Yes, it should only be a syntax change.

Regardingn testing: I haven't tested individual patches of part D, but I have tested the complete series. After applying the fix for the DSDT length my ApolloLake board has booted reliably with ACPI enabled.

Will you add the "Tested-by" tag for this series?

I lack experience in testing complete series, which is why I was not sure how this should be handled. If testing a complete series at once is enough, without testing the individual patches, then this series is:

Tested on a custom ApolloLake board.

Quoted 1 line

BTW: any plan to upstream your board support?

Yes, that would be one of the long term goals.

regards, Wolfgang

#8 lore raw

PATCH v3 2/57 x86: acpi: Add base asl files for common x86 devices

Hi Wolfgang,

Quoted 67 lines · Wolfgang Wallner

Hi Bin,

-----"Bin Meng" <[email protected]> schrieb: -----

Quoted 63 lines

Betreff: Re: [PATCH v3 02/57] x86: acpi: Add base asl files for common x86 devices

Hi Wolfgang,

Quoted 56 lines · Wolfgang Wallner

Hi Simon,

-----"Simon Glass" <[email protected]> schrieb: -----

Quoted 41 lines

Betreff: Re: [PATCH v3 02/57] x86: acpi: Add base asl files for common x86 devices

Hi Wolfgang,

Quoted 30 lines · Wolfgang Wallner

Hi Simon,

-----"Simon Glass" <[email protected]> schrieb: -----

Quoted 9 lines

Betreff: [PATCH v3 02/57] x86: acpi: Add base asl files for common x86 devices

Add common x86 ASL files, taken from coreboot.

---

(no changes since v1)

Quoted 16 lines
 arch/x86/include/asm/acpi/chromeos.asl    | 108 +++++++++++++++++
 arch/x86/include/asm/acpi/cpu.asl         |  25 ++++
 arch/x86/include/asm/acpi/cros_gnvs.asl   |  29 +++++
 arch/x86/include/asm/acpi/lpc.asl         | 141 ++++++++++++++++++++++
 arch/x86/include/asm/acpi/pci_osc.asl     |  21 ++++
 arch/x86/include/asm/acpi/pcr.asl         |  80 ++++++++++++
 arch/x86/include/asm/acpi/ramoops.asl     |  32 +++++
 arch/x86/include/asm/acpi/sleepstates.asl |  12 +-
 8 files changed, 443 insertions(+), 5 deletions(-)
 create mode 100644 arch/x86/include/asm/acpi/chromeos.asl
 create mode 100644 arch/x86/include/asm/acpi/cpu.asl
 create mode 100644 arch/x86/include/asm/acpi/cros_gnvs.asl
 create mode 100644 arch/x86/include/asm/acpi/lpc.asl
 create mode 100644 arch/x86/include/asm/acpi/pci_osc.asl
 create mode 100644 arch/x86/include/asm/acpi/pcr.asl
 create mode 100644 arch/x86/include/asm/acpi/ramoops.asl
Quoted 4 lines

There are recent (~June 2020) commits in coreboot which convert most ASL files to ASL 2.0. The ASL 2.0 syntax is much easier to read IMHO, and I think it would be good to update this patch to take advantage of the recent coreboot developments. See e.g. the commit at [1].

Quoted 4 lines

Yes that looks nicer, but I have everything working and tested now so don't want to go back and unpick things. This seems like something we can pick up once we finally have this in the tree. The good thing is that this is just a syntax change as I understand it.

Fair enough. Yes, it should only be a syntax change.

Regardingn testing: I haven't tested individual patches of part D, but I have tested the complete series. After applying the fix for the DSDT length my ApolloLake board has booted reliably with ACPI enabled.

Quoted 8 lines
Quoted 1 line

Will you add the "Tested-by" tag for this series?

I lack experience in testing complete series, which is why I was not sure how this should be handled. If testing a complete series at once is enough, without testing the individual patches, then this series is:

Tested on a custom ApolloLake board.

Thank you. But I will leave Simon to pick up the tag in the next version whenever it makes sense.

Quoted 4 lines
Quoted 2 lines

BTW: any plan to upstream your board support?

Yes, that would be one of the long term goals.

Great!

Regards,
Bin

#9 lore raw

PATCH v3 3/57 x86: acpi: apl: Add asl files for Apollo Lake

In reply to Simon Glass

Add Apollo Lake ASL files, taken from coreboot.

---

(no changes since v1)

 .../include/asm/arch-apollolake/acpi/dptf.asl |  35 ++++
 .../asm/arch-apollolake/acpi/globalnvs.asl    |  41 ++++
 .../include/asm/arch-apollolake/acpi/gpio.asl | 191 ++++++++++++++++++
 .../asm/arch-apollolake/acpi/gpiolib.asl      | 109 ++++++++++
 .../include/asm/arch-apollolake/acpi/lpss.asl | 105 ++++++++++
 .../asm/arch-apollolake/acpi/northbridge.asl  | 120 +++++++++++
 .../asm/arch-apollolake/acpi/pch_hda.asl      |  77 +++++++
 .../asm/arch-apollolake/acpi/pci_irqs.asl     |  52 +++++
 .../include/asm/arch-apollolake/acpi/pcie.asl |  22 ++
 .../asm/arch-apollolake/acpi/pcie_port.asl    | 113 +++++++++++
 .../asm/arch-apollolake/acpi/platform.asl     |  10 +
 .../asm/arch-apollolake/acpi/pmc_ipc.asl      |  49 +++++
 .../include/asm/arch-apollolake/acpi/scs.asl  | 173 ++++++++++++++++
 .../asm/arch-apollolake/acpi/soc_int.asl      |  50 +++++
 .../asm/arch-apollolake/acpi/southbridge.asl  |  34 ++++
 .../include/asm/arch-apollolake/acpi/xhci.asl |  33 +++
 .../arch-apollolake/acpi/xhci_apl_ports.asl   |  23 +++
 .../arch-apollolake/acpi/xhci_glk_ports.asl   |  24 +++
 18 files changed, 1261 insertions(+)
 create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/dptf.asl
 create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/globalnvs.asl
 create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/gpio.asl
 create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/gpiolib.asl
 create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/lpss.asl
 create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/northbridge.asl
 create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/pch_hda.asl
 create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/pci_irqs.asl
 create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/pcie.asl
 create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/pcie_port.asl
 create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/platform.asl
 create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/pmc_ipc.asl
 create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/scs.asl
 create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/soc_int.asl
 create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/southbridge.asl
 create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/xhci.asl
 create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/xhci_apl_ports.asl
 create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/xhci_glk_ports.asl
arch/x86/include/asm/arch-apollolake/acpi/dptf.asl new file +35 -0
new file mode 100644
index 00000000000..4c50bb45c0f
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2016 Intel Corporation.
+ */
+
+#define DPTF_CPU_DEVICE		TCPU
+#define DPTF_CPU_ADDR		0x00000001
+
+#ifndef DPTF_CPU_PASSIVE
+#define DPTF_CPU_PASSIVE	80
+#endif
+
+#ifndef DPTF_CPU_CRITICAL
+#define DPTF_CPU_CRITICAL	90
+#endif
+
+#ifndef DPTF_CPU_ACTIVE_AC0
+#define DPTF_CPU_ACTIVE_AC0	90
+#endif
+
+#ifndef DPTF_CPU_ACTIVE_AC1
+#define DPTF_CPU_ACTIVE_AC1	80
+#endif
+
+#ifndef DPTF_CPU_ACTIVE_AC2
+#define DPTF_CPU_ACTIVE_AC2	70
+#endif
+
+#ifndef DPTF_CPU_ACTIVE_AC3
+#define DPTF_CPU_ACTIVE_AC3	60
+#endif
+
+#ifndef DPTF_CPU_ACTIVE_AC4
+#define DPTF_CPU_ACTIVE_AC4	50
+#endif
arch/x86/include/asm/arch-apollolake/acpi/globalnvs.asl new file +41 -0

41 lines not on this page · raw message

arch/x86/include/asm/arch-apollolake/acpi/gpio.asl new file +191 -0

191 lines not on this page · raw message

arch/x86/include/asm/arch-apollolake/acpi/gpiolib.asl new file +109 -0

109 lines not on this page · raw message

arch/x86/include/asm/arch-apollolake/acpi/lpss.asl new file +105 -0

105 lines not on this page · raw message

arch/x86/include/asm/arch-apollolake/acpi/northbridge.asl new file +120 -0

120 lines not on this page · raw message

arch/x86/include/asm/arch-apollolake/acpi/pch_hda.asl new file +77 -0

77 lines not on this page · raw message

arch/x86/include/asm/arch-apollolake/acpi/pci_irqs.asl new file +52 -0

52 lines not on this page · raw message

arch/x86/include/asm/arch-apollolake/acpi/pcie.asl new file +22 -0
new file mode 100644
index 00000000000..ecff59ab1c7
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2016 Intel Corporation
+ */
+
+/* PCIe Ports */
+
+Device (RP01)
+{
+	Name (_ADR, 0x00140000)
+	Name (_DDN, "PCIe-B 0")
+
+	#include "pcie_port.asl"
+}
+
+Device (RP03)
+{
+	Name (_ADR, 0x00130000)
+	Name (_DDN, "PCIe-A 0")
+
+	#include "pcie_port.asl"
+}
arch/x86/include/asm/arch-apollolake/acpi/pcie_port.asl new file +113 -0

113 lines not on this page · raw message

arch/x86/include/asm/arch-apollolake/acpi/platform.asl new file +10 -0
new file mode 100644
index 00000000000..b631a9fb38a
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2007-2009 coresystems GmbH
+ * Copyright (C) 2012 Google Inc.
+ * Copyright (C) 2016 Intel Corp
+ */
+
+/* Enable ACPI _SWS methods */
+#include <soc/intel/common/acpi/acpi_wake_source.asl>
+#include <soc/intel/common/acpi/platform.asl>
arch/x86/include/asm/arch-apollolake/acpi/pmc_ipc.asl new file +49 -0

49 lines not on this page · raw message

arch/x86/include/asm/arch-apollolake/acpi/scs.asl new file +173 -0

173 lines not on this page · raw message

arch/x86/include/asm/arch-apollolake/acpi/soc_int.asl new file +50 -0

50 lines not on this page · raw message

arch/x86/include/asm/arch-apollolake/acpi/southbridge.asl new file +34 -0
new file mode 100644
index 00000000000..08290194f60
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2016 Intel Corp.
+ * (Written by Lance Zhao <[email protected]> for Intel Corp.)
+ */
+
+#include <p2sb.h>
+#include <asm/arch/gpe.h>
+
+/* PCIE device */
+#include "pcie.asl"
+
+/* LPSS device */
+#include "lpss.asl"
+
+/* PCI IRQ assignment */
+#include "pci_irqs.asl"
+
+/* GPIO controller */
+#include "gpio.asl"
+
+#include "xhci.asl"
+
+/* LPC */
+#include <asm/acpi/lpc.asl>
+
+/* eMMC */
+#include "scs.asl"
+
+/* PMC IPC controller */
+#include "pmc_ipc.asl"
+
+/* PCI _OSC */
+#include <asm/acpi/pci_osc.asl>
arch/x86/include/asm/arch-apollolake/acpi/xhci.asl new file +33 -0
new file mode 100644
index 00000000000..6333126c3fd
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2016 Intel Corporation.
+ */
+
+/* XHCI Controller 0:15.0 */
+Device (XHCI) {
+	Name (_ADR, 0x00150000)  /* Device 21, Function 0 */
+
+	Name (_S3D, 3)  /* D3 supported in S3 */
+	Name (_S0W, 3)  /* D3 can wake device in S0 */
+	Name (_S3W, 3)  /* D3 can wake system from S3 */
+
+	/* Declare XHCI GPE status and enable bits are bit 13 */
+	Name (_PRW, Package() { GPE0A_XHCI_PME_STS, 3 })
+
+	Method (_STA, 0)
+	{
+		Return (0xF)
+	}
+
+	Device (RHUB)
+	{
+		/* Root Hub */
+		Name (_ADR, Zero)
+
+#if IS_ENABLED(CONFIG_SOC_INTEL_GLK)
+#include "xhci_glk_ports.asl"
+#else
+#include "xhci_apl_ports.asl"
+#endif
+	}
+}
arch/x86/include/asm/arch-apollolake/acpi/xhci_apl_ports.asl new file +23 -0
new file mode 100644
index 00000000000..3ab7d18fc84
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2019 Google LLC.
+ * Copyright 2019 Intel Corp.
+ */
+
+/* USB2 */
+Device (HS01) { Name (_ADR, 1) }
+Device (HS02) { Name (_ADR, 2) }
+Device (HS03) { Name (_ADR, 3) }
+Device (HS04) { Name (_ADR, 4) }
+Device (HS05) { Name (_ADR, 5) }
+Device (HS06) { Name (_ADR, 6) }
+Device (HS07) { Name (_ADR, 7) }
+Device (HS08) { Name (_ADR, 8) }
+
+/* USB3 */
+Device (SS01) { Name (_ADR, 9) }
+Device (SS02) { Name (_ADR, 10) }
+Device (SS03) { Name (_ADR, 11) }
+Device (SS04) { Name (_ADR, 12) }
+Device (SS05) { Name (_ADR, 13) }
+Device (SS06) { Name (_ADR, 14) }
arch/x86/include/asm/arch-apollolake/acpi/xhci_glk_ports.asl new file +24 -0
new file mode 100644
index 00000000000..192267221fc
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2019 Google LLC.
+ * Copyright 2019 Intel Corp.
+ */
+
+/* USB2 */
+Device (HS01) { Name (_ADR, 1) }
+Device (HS02) { Name (_ADR, 2) }
+Device (HS03) { Name (_ADR, 3) }
+Device (HS04) { Name (_ADR, 4) }
+Device (HS05) { Name (_ADR, 5) }
+Device (HS06) { Name (_ADR, 6) }
+Device (HS07) { Name (_ADR, 7) }
+Device (HS08) { Name (_ADR, 8) }
+Device (HS09) { Name (_ADR, 9) }
+
+/* USB3 */
+Device (SS01) { Name (_ADR, 10) }
+Device (SS02) { Name (_ADR, 11) }
+Device (SS03) { Name (_ADR, 12) }
+Device (SS04) { Name (_ADR, 13) }
+Device (SS05) { Name (_ADR, 14) }
+Device (SS06) { Name (_ADR, 15) }
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#10 lore raw

PATCH v3 4/57 x86: acpi: Add DPTF asl files

In reply to Simon Glass

Add common DPTF (Intel Dynamic Performance and Thermal Framework) files, taken from coreboot.

---

(no changes since v1)

 arch/x86/include/asm/acpi/dptf/charger.asl |  65 +++
 arch/x86/include/asm/acpi/dptf/cpu.asl     | 186 ++++++++
 arch/x86/include/asm/acpi/dptf/dptf.asl    | 121 +++++
 arch/x86/include/asm/acpi/dptf/fan.asl     |  57 +++
 arch/x86/include/asm/acpi/dptf/thermal.asl | 521 +++++++++++++++++++++
 5 files changed, 950 insertions(+)
 create mode 100644 arch/x86/include/asm/acpi/dptf/charger.asl
 create mode 100644 arch/x86/include/asm/acpi/dptf/cpu.asl
 create mode 100644 arch/x86/include/asm/acpi/dptf/dptf.asl
 create mode 100644 arch/x86/include/asm/acpi/dptf/fan.asl
 create mode 100644 arch/x86/include/asm/acpi/dptf/thermal.asl
arch/x86/include/asm/acpi/dptf/charger.asl new file +65 -0
new file mode 100644
index 00000000000..7f4a7ecd36e
@@ -0,0 +1,65 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2014 Google Inc.
+ * Copyright (C) 2016 Intel Corporation.
+ */
+
+Device (TCHG)
+{
+	Name (_HID, "INT3403")
+	Name (_UID, 0)
+	Name (PTYP, 0x0B)
+	Name (_STR, Unicode("Battery Charger"))
+
+	Method (_STA)
+	{
+		If (LEqual (\DPTE, One)) {
+			Return (0xF)
+		} Else {
+			Return (0x0)
+		}
+	}
+
+	/* Return charger performance states defined by mainboard */
+	Method (PPSS)
+	{
+		Return (\_SB.CHPS)
+	}
+
+	/* Return maximum charger current limit */
+	Method (PPPC)
+	{
+		/* Convert size of PPSS table to index */
+		Store (SizeOf (\_SB.CHPS), Local0)
+		Decrement (Local0)
+
+		/* Check if charging is disabled (AC removed) */
+		If (LEqual (\_SB.PCI0.LPCB.EC0.ACEX, Zero)) {
+			/* Return last power state */
+			Return (Local0)
+		} Else {
+			/* Return highest power state */
+			Return (0)
+		}
+
+		Return (0)
+	}
+
+	/* Set charger current limit */
+	Method (SPPC, 1)
+	{
+		/* Retrieve Control (index 4) for specified PPSS level */
+		Store (DeRefOf (Index (DeRefOf (Index
+			(\_SB.CHPS, ToInteger (Arg0))), 4)), Local0)
+
+		/* Pass Control value to EC to limit charging */
+		\_SB.PCI0.LPCB.EC0.CHGS (Local0)
+	}
+
+	/* Initialize charger participant */
+	Method (INIT)
+	{
+		/* Disable charge limit */
+		\_SB.PCI0.LPCB.EC0.CHGD ()
+	}
+}
arch/x86/include/asm/acpi/dptf/cpu.asl new file +186 -0

186 lines not on this page · raw message

arch/x86/include/asm/acpi/dptf/dptf.asl new file +121 -0

121 lines not on this page · raw message

arch/x86/include/asm/acpi/dptf/fan.asl new file +57 -0

57 lines not on this page · raw message

arch/x86/include/asm/acpi/dptf/thermal.asl new file +521 -0

521 lines not on this page · raw message

Signature · 1 line
2.28.0.526.ge36021eeef-goog
#11 lore raw

PATCH v3 5/57 x86: apl: Correct PCIE_ECAM_BASE

In reply to Simon Glass

This value is incorrect and causes problems booting Linux. Fix it.

---

(no changes since v1)

 board/google/chromebook_coral/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
board/google/chromebook_coral/Kconfig +1 -1
index 27671958e14..53c651c3f9e 100644
@@ -23,7 +23,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
 	select BOARD_ROMSIZE_KB_16384
 
 config PCIE_ECAM_BASE
-	default 0xf0000000
+	default 0xe0000000
 
 config EARLY_POST_CROS_EC
 	bool "Enable early post to Chrome OS EC"
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#13 lore raw

PATCH v3 6/57 x86: Add a config for the systemagent PCIEX regions size

In reply to Simon Glass

Add a way to specify the required size for this region. This is used when generating ACPI tables.

---

(no changes since v1)

 arch/x86/Kconfig                | 18 ++++++++++++++++++
 arch/x86/cpu/apollolake/Kconfig |  1 +
 2 files changed, 19 insertions(+)
arch/x86/Kconfig +18 -0
index 76276c60274..256a1100bd3 100644
@@ -976,4 +976,22 @@ config TPL_ACPI_GPE
 
 	  See https://queue.acm.org/blogposting.cfm?id=18977 for more info
 
+config SA_PCIEX_LENGTH
+	hex
+	default 0x10000000 if (PCIEX_LENGTH_256MB)
+	default 0x8000000 if (PCIEX_LENGTH_128MB)
+	default 0x4000000 if (PCIEX_LENGTH_64MB)
+	default 0x10000000
+	help
+	  This option allows you to select length of PCIEX region.
+
+config PCIEX_LENGTH_256MB
+	bool
+
+config PCIEX_LENGTH_128MB
+	bool
+
+config PCIEX_LENGTH_64MB
+	bool
+
 endmenu
arch/x86/cpu/apollolake/Kconfig +1 -0
index 99d4e105c25..37d6289ee41 100644
@@ -13,6 +13,7 @@ config INTEL_APOLLOLAKE
 	select TPL_X86_TSC_TIMER_NATIVE
 	select SPL_PCH_SUPPORT
 	select TPL_PCH_SUPPORT
+	select PCIEX_LENGTH_256MB
 	select PCH_SUPPORT
 	select P2SB
 	select SMP_AP_WORK
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#14 lore raw

PATCH v3 7/57 x86: Add a common global NVS structure

In reply to Simon Glass

Add the definition of this structure common to Intel devices. It includes some optional Chrome OS pieces which are used when vboot is integrated.

Drop the APL version as it is basically the same.

---

(no changes since v1)

Changes in v1:
- Use this file in APL

 .../include/asm/arch-apollolake/global_nvs.h  | 23 +---------
 arch/x86/include/asm/intel_gnvs.h             | 43 +++++++++++++++++++
 2 files changed, 44 insertions(+), 22 deletions(-)
 create mode 100644 arch/x86/include/asm/intel_gnvs.h
arch/x86/include/asm/arch-apollolake/global_nvs.h +1 -22
index fe62194b02e..ef8eb228dbe 100644
@@ -10,27 +10,6 @@
 #ifndef _GLOBAL_NVS_H_
 #define _GLOBAL_NVS_H_
 
-struct __packed acpi_global_nvs {
-	/* Miscellaneous */
-	u8	pcnt; /* 0x00 - Processor Count */
-	u8	ppcm; /* 0x01 - Max PPC State */
-	u8	lids; /* 0x02 - LID State */
-	u8	pwrs; /* 0x03 - AC Power State */
-	u8	dpte; /* 0x04 - Enable DPTF */
-	u32	cbmc; /* 0x05 - 0x08 - U-Boot Console */
-	u64	pm1i; /* 0x09 - 0x10 - System Wake Source - PM1 Index */
-	u64	gpei; /* 0x11 - 0x18 - GPE Wake Source */
-	u64	nhla; /* 0x19 - 0x20 - NHLT Address */
-	u32	nhll; /* 0x21 - 0x24 - NHLT Length */
-	u32	prt0; /* 0x25 - 0x28 - PERST_0 Address */
-	u8	scdp; /* 0x29 - SD_CD GPIO portid */
-	u8	scdo; /* 0x2a - GPIO pad offset relative to the community */
-	u8	uior; /* 0x2b - UART debug controller init on S3 resume */
-	u8	ecps; /* 0x2c - SGX Enabled status */
-	u64	emna; /* 0x2d - 0x34 EPC base address */
-	u64	elng; /* 0x35 - 0x3c EPC Length */
-	u8	unused1[0x100 - 0x3d];		/* Pad out to 256 bytes */
-	u8	unused2[0x1000 - 0x100];	/* Pad out to 4096 bytes */
-};
+#include <asm/intel_gnvs.h>
 
 #endif /* _GLOBAL_NVS_H_ */
arch/x86/include/asm/intel_gnvs.h new file +43 -0

43 lines not on this page · raw message

Signature · 1 line
2.28.0.526.ge36021eeef-goog
#15 lore raw

PATCH v3 8/57 x86: acpi: Support external GNVS tables

In reply to Simon Glass

At present U-Boot puts a magic number in the ASL for the GNVS table and searches for it later.

Add a Kconfig option to use a different approach, where the ASL files declare the table as an external symbol. U-Boot can then put it wherever it likes, without any magic numbers or searching.

---

(no changes since v1)

 arch/x86/Kconfig                       |  7 +++++
 arch/x86/cpu/apollolake/Kconfig        |  1 +
 arch/x86/include/asm/acpi/global_nvs.h |  3 ++
 arch/x86/lib/acpi_table.c              | 42 ++++++++++++++------------
 4 files changed, 33 insertions(+), 20 deletions(-)
arch/x86/Kconfig +7 -0
index 256a1100bd3..680f26f1b8e 100644
@@ -788,6 +788,13 @@ config GENERATE_ACPI_TABLE
 	  by the operating system. It defines platform-independent interfaces
 	  for configuration and power management monitoring.
 
+config ACPI_GNVS_EXTERNAL
+	bool
+	help
+	  Put the GNVS (Global Non-Volatile Sleeping) table separate from the
+	  DSDT and add a pointer to the table from the DSDT. This allows
+	  U-Boot to better control the address of the GNVS.
+
 endmenu
 
 config HAVE_ACPI_RESUME
arch/x86/cpu/apollolake/Kconfig +1 -0
index 37d6289ee41..16ac2b3f504 100644
@@ -17,6 +17,7 @@ config INTEL_APOLLOLAKE
 	select PCH_SUPPORT
 	select P2SB
 	select SMP_AP_WORK
+	select ACPI_GNVS_EXTERNAL
 	imply ENABLE_MRC_CACHE
 	imply AHCI_PCI
 	imply SCSI
arch/x86/include/asm/acpi/global_nvs.h +3 -0
index d56d35ca533..a552cf6374f 100644
@@ -11,6 +11,9 @@
  * ACPI_GNVS_SIZE. They are to be used in platform's global_nvs.asl file
  * to declare the GNVS OperationRegion, as well as write_acpi_tables()
  * for the GNVS address runtime fix up.
+ *
+ * If using CONFIG_ACPI_GNVS_EXTERNAL, we don't need to locate the GNVS in
+ * DSDT, since it is created by code, so ACPI_GNVS_ADDR is unused.
  */
 #define ACPI_GNVS_ADDR	0xdeadbeef
 #define ACPI_GNVS_SIZE	0x100
arch/x86/lib/acpi_table.c +22 -20

59 lines not on this page · raw message

Signature · 1 line
2.28.0.526.ge36021eeef-goog
#16 lore raw

PATCH v3 9/57 x86: acpi: Expand the GNVS

In reply to Simon Glass

Expand this to 4KB so that it is possible to add custom information to it. On Chromebooks this is used to pass verified-boot information.

---

(no changes since v1)

 arch/x86/include/asm/acpi/global_nvs.h | 2 +-
 arch/x86/include/asm/intel_gnvs.h      | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
arch/x86/include/asm/acpi/global_nvs.h +1 -1
index a552cf6374f..46383629cc5 100644
@@ -16,6 +16,6 @@
  * DSDT, since it is created by code, so ACPI_GNVS_ADDR is unused.
  */
 #define ACPI_GNVS_ADDR	0xdeadbeef
-#define ACPI_GNVS_SIZE	0x100
+#define ACPI_GNVS_SIZE	0x1000
 
 #endif /* _ACPI_GNVS_H_ */
arch/x86/include/asm/intel_gnvs.h +1 -0
index e2d479d4f32..c1e9d65779f 100644
@@ -36,6 +36,7 @@ struct __packed acpi_global_nvs {
 	u8	unused2[0x1000 - 0x100];	/* Pad out to 4096 bytes */
 #endif
 };
+
 #ifdef CONFIG_CHROMEOS
 check_member(acpi_global_nvs, chromeos, GNVS_CHROMEOS_ACPI_OFFSET);
 #endif
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#17 lore raw

PATCH v3 10/57 x86: coral: Add ACPI tables for coral

In reply to Simon Glass

This device has a large set of ACPI tables. Bring these in from coreboot so that full functionality is available (apart from SMI).

---

(no changes since v1)

Changes in v1:
- Add NHLT audio support
- Capitalise ACPI_OPS_PTR
- Use OEM_TABLE_ID instead of ACPI_TABLE_CREATOR

 board/google/chromebook_coral/Makefile        |   1 +
 .../chromebook_coral/baseboard_dptf.asl       |  71 +++++++++
 board/google/chromebook_coral/coral.c         | 135 ++++++++++++++++++
 board/google/chromebook_coral/dsdt.asl        |  60 ++++++++
 .../google/chromebook_coral/variant_dptf.asl  |   6 +
 board/google/chromebook_coral/variant_ec.h    |  75 ++++++++++
 board/google/chromebook_coral/variant_gpio.h  |  63 ++++++++
 include/bloblist.h                            |   5 +
 8 files changed, 416 insertions(+)
 create mode 100644 board/google/chromebook_coral/baseboard_dptf.asl
 create mode 100644 board/google/chromebook_coral/dsdt.asl
 create mode 100644 board/google/chromebook_coral/variant_dptf.asl
 create mode 100644 board/google/chromebook_coral/variant_ec.h
 create mode 100644 board/google/chromebook_coral/variant_gpio.h
board/google/chromebook_coral/Makefile +1 -0
index 6a27ce3da1b..f7a0ca6cc0a 100644
@@ -3,3 +3,4 @@
 # Copyright 2019 Google LLC
 
 obj-y	+= coral.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o
board/google/chromebook_coral/baseboard_dptf.asl new file +71 -0

71 lines not on this page · raw message

board/google/chromebook_coral/coral.c +135 -0

145 lines not on this page · raw message

board/google/chromebook_coral/dsdt.asl new file +60 -0

60 lines not on this page · raw message

board/google/chromebook_coral/variant_dptf.asl new file +6 -0
new file mode 100644
index 00000000000..943ebeaac26
@@ -0,0 +1,6 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright 2016 Google Inc.
+ */
+
+#include "baseboard_dptf.asl"
board/google/chromebook_coral/variant_ec.h new file +75 -0

75 lines not on this page · raw message

board/google/chromebook_coral/variant_gpio.h new file +63 -0

63 lines not on this page · raw message

include/bloblist.h +5 -0
index 609ac421d66..bbe0a35d5a2 100644
@@ -27,6 +27,11 @@ enum bloblist_tag_t {
 	BLOBLISTT_SPL_HANDOFF,		/* Hand-off info from SPL */
 	BLOBLISTT_VBOOT_CTX,		/* Chromium OS verified boot context */
 	BLOBLISTT_VBOOT_HANDOFF,	/* Chromium OS internal handoff info */
+	/*
+	 * Advanced Configuration and Power Interface Global Non-Volatile
+	 * Sleeping table. This forms part of the ACPI tables passed to Linux.
+	 */
+	BLOBLISTT_ACPI_GNVS,
 };
 
 /**
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#18 lore raw

PATCH v3 11/57 acpi: Add support for writing a _PRW

In reply to Simon Glass

A 'Power Resource for Wake' list the resources a device depends on for wake. Add a function to generate this.

---

(no changes since v1)

 include/acpi/acpigen.h | 10 ++++++++++
 lib/acpi/acpigen.c     | 10 ++++++++++
 test/dm/acpigen.c      | 30 ++++++++++++++++++++++++++++++
 3 files changed, 50 insertions(+)
include/acpi/acpigen.h +10 -0
index 228ac9c404b..a9b70123c0a 100644
@@ -563,4 +563,14 @@ int acpigen_set_enable_tx_gpio(struct acpi_ctx *ctx, u32 tx_state_val,
 			       const char *dw0_read, const char *dw0_write,
 			       struct acpi_gpio *gpio, bool enable);
 
+/**
+ * acpigen_write_prw() - Write a power resource for wake (_PRW)
+ *
+ * @ctx: ACPI context pointer
+ * @wake: GPE that wakes up the device
+ * @level: Deepest power system sleeping state that can be entered while still
+ *	providing wake functionality
+ */
+void acpigen_write_prw(struct acpi_ctx *ctx, uint wake, uint level);
+
 #endif
lib/acpi/acpigen.c +10 -0
index c609ef4daa4..527de89b1e1 100644
@@ -426,6 +426,16 @@ void acpigen_write_register_resource(struct acpi_ctx *ctx,
 	acpigen_write_resourcetemplate_footer(ctx);
 }
 
+void acpigen_write_prw(struct acpi_ctx *ctx, uint wake, uint level)
+{
+	/* Name (_PRW, Package () { wake, level } */
+	acpigen_write_name(ctx, "_PRW");
+	acpigen_write_package(ctx, 2);
+	acpigen_write_integer(ctx, wake);
+	acpigen_write_integer(ctx, level);
+	acpigen_pop_len(ctx);
+}
+
 /*
  * ToUUID(uuid)
  *
test/dm/acpigen.c +30 -0
index 1b2767e732d..16ae7025856 100644
@@ -1097,3 +1097,33 @@ static int dm_test_acpi_write_name(struct unit_test_state *uts)
 	return 0;
 }
 DM_TEST(dm_test_acpi_write_name, 0);
+
+/* Test emitting a string */
+static int dm_test_acpi_write_prw(struct unit_test_state *uts)
+{
+	struct acpi_ctx *ctx;
+	u8 *ptr;
+
+	ut_assertok(alloc_context(&ctx));
+
+	ptr = acpigen_get_current(ctx);
+	acpigen_write_prw(ctx, 5, 3);
+	ut_asserteq(NAME_OP, *ptr++);
+
+	ut_asserteq_strn("_PRW", (char *)ptr);
+	ptr += 4;
+	ut_asserteq(PACKAGE_OP, *ptr++);
+	ut_asserteq(8, acpi_test_get_length(ptr));
+	ptr += 3;
+	ut_asserteq(2, *ptr++);
+	ut_asserteq(BYTE_PREFIX, *ptr++);
+	ut_asserteq(5, *ptr++);
+	ut_asserteq(BYTE_PREFIX, *ptr++);
+	ut_asserteq(3, *ptr++);
+	ut_asserteq_ptr(ptr, ctx->current);
+
+	free_context(&ctx);
+
+	return 0;
+}
+DM_TEST(dm_test_acpi_write_prw, 0);
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#19 lore raw

PATCH v3 12/57 acpi: Add support for conditions and return values

In reply to Simon Glass

Add functions to support generating ACPI code for condition checks and return values.

---

(no changes since v1)

 include/acpi/acpigen.h | 93 ++++++++++++++++++++++++++++++++++++++++++
 lib/acpi/acpigen.c     | 68 ++++++++++++++++++++++++++++++
 test/dm/acpigen.c      | 93 +++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 253 insertions(+), 1 deletion(-)
include/acpi/acpigen.h +93 -0
index a9b70123c0a..fa9409e3528 100644
@@ -52,12 +52,24 @@ enum {
 	LOCAL5_OP		= 0x65,
 	LOCAL6_OP		= 0x66,
 	LOCAL7_OP		= 0x67,
+	ARG0_OP			= 0x68,
+	ARG1_OP			= 0x69,
+	ARG2_OP			= 0x6a,
+	ARG3_OP			= 0x6b,
+	ARG4_OP			= 0x6c,
+	ARG5_OP			= 0x6d,
+	ARG6_OP			= 0x6e,
 	STORE_OP		= 0x70,
 	AND_OP			= 0x7b,
 	OR_OP			= 0x7d,
 	NOT_OP			= 0x80,
 	DEVICE_OP		= 0x82,
 	POWER_RES_OP		= 0x84,
+	LEQUAL_OP		= 0x93,
+	TO_BUFFER_OP		= 0x96,
+	TO_INTEGER_OP		= 0x99,
+	IF_OP			= 0xa0,
+	ELSE_OP			= 0xa1,
 	RETURN_OP		= 0xa4,
 };
 
@@ -573,4 +585,85 @@ int acpigen_set_enable_tx_gpio(struct acpi_ctx *ctx, u32 tx_state_val,
  */
 void acpigen_write_prw(struct acpi_ctx *ctx, uint wake, uint level);
 
+/**
+ * acpigen_write_if() - Write an If block
+ *
+ * This requires a call to acpigen_pop_len() to complete the block
+ *
+ * @ctx: ACPI context pointer
+ */
+void acpigen_write_if(struct acpi_ctx *ctx);
+
+/**
+ * acpigen_write_if_lequal_op_int() - Write comparison between op and integer
+ *
+ * Generates ACPI code for checking if operand1 and operand2 are equal
+ *
+ * If (Lequal (op, val))
+ *
+ * @ctx: ACPI context pointer
+ * @op: Operand to check
+ * @val: Value to check against
+ */
+void acpigen_write_if_lequal_op_int(struct acpi_ctx *ctx, uint op, u64 val);
+
+/**
+ * acpigen_write_else() - Write an Ef block
+ *
+ * This requires a call to acpigen_pop_len() to complete the block
+ *
+ * @ctx: ACPI context pointer
+ */
+void acpigen_write_else(struct acpi_ctx *ctx);
+
+/**
+ * acpigen_write_to_buffer() - Write a ToBuffer operation
+ *
+ * E.g.: to generate: ToBuffer (Arg0, Local0)
+ * use acpigen_write_to_buffer(ctx, ARG0_OP, LOCAL0_OP)
+ *
+ * @ctx: ACPI context pointer
+ * @src: Source argument
+ * @dst: Destination argument
+ */
+void acpigen_write_to_buffer(struct acpi_ctx *ctx, uint src, uint dst);
+
+/**
+ * acpigen_write_to_integer() - Write a ToInteger operation
+ *
+ * E.g.: to generate: ToInteger (Arg0, Local0)
+ * use acpigen_write_to_integer(ctx, ARG0_OP, LOCAL0_OP)
+ *
+ * @ctx: ACPI context pointer
+ * @src: Source argument
+ * @dst: Destination argument
+ */
+void acpigen_write_to_integer(struct acpi_ctx *ctx, uint src, uint dst);
+
+/**
+ * acpigen_write_return_byte_buffer() - Write a return of a byte buffer
+ *
+ * @ctx: ACPI context pointer
+ * @arr: Array of bytes to return
+ * @size: Number of bytes
+ */
+void acpigen_write_return_byte_buffer(struct acpi_ctx *ctx, u8 *arr,
+				      size_t size);
+
+/**
+ * acpigen_write_return_singleton_buffer() - Write a return of a 1-byte buffer
+ *
+ * @ctx: ACPI context pointer
+ * @arg: Byte to return
+ */
+void acpigen_write_return_singleton_buffer(struct acpi_ctx *ctx, uint arg);
+
+/**
+ * acpigen_write_return_byte() - Write a return of a byte
+ *
+ * @ctx: ACPI context pointer
+ * @arg: Byte to return
+ */
+void acpigen_write_return_byte(struct acpi_ctx *ctx, uint arg);
+
 #endif
lib/acpi/acpigen.c +68 -0

74 lines not on this page · raw message

test/dm/acpigen.c +92 -1

102 lines not on this page · raw message

Signature · 1 line
2.28.0.526.ge36021eeef-goog
#20 lore raw

PATCH v3 13/57 acpi: Support generating a multi-function _DSM for devices

In reply to Simon Glass

Add a function to generate ACPI code for a _DSM method for a device. This includes functions for starting and ending each part of the _DSM.

---

(no changes since v1)

 include/acpi/acpi_device.h |  14 +++++
 include/acpi/acpigen.h     |  99 +++++++++++++++++++++++++++++
 lib/acpi/acpi_device.c     |  43 +++++++++++++
 lib/acpi/acpigen.c         |  54 ++++++++++++++++
 test/dm/acpigen.c          | 126 +++++++++++++++++++++++++++++++++++++
 5 files changed, 336 insertions(+)
include/acpi/acpi_device.h +14 -0
index 11461e168d3..a5b12217820 100644
@@ -28,6 +28,9 @@ struct udevice;
 /* Length of a full path to an ACPI device */
 #define ACPI_PATH_MAX		30
 
+/* UUID for an I2C _DSM method */
+#define ACPI_DSM_I2C_HID_UUID	"3cdff6f7-4267-4555-ad05-b30a3d8938de"
+
 /* Values that can be returned for ACPI device _STA method */
 enum acpi_dev_status {
 	ACPI_DSTATUS_PRESENT		= BIT(0),
@@ -319,6 +322,17 @@ int acpi_device_write_gpio_desc(struct acpi_ctx *ctx,
 int acpi_device_write_interrupt_or_gpio(struct acpi_ctx *ctx,
 					struct udevice *dev, const char *prop);
 
+/**
+ * acpi_device_write_dsm_i2c_hid() - Write a device-specific method for HID
+ *
+ * This writes a DSM for an I2C Human-Interface Device based on the config
+ * provided
+ *
+ * @hid_desc_reg_offset: HID register offset
+ */
+int acpi_device_write_dsm_i2c_hid(struct acpi_ctx *ctx,
+				  int hid_desc_reg_offset);
+
 /**
  * acpi_device_write_i2c_dev() - Write an I2C device to ACPI
  *
include/acpi/acpigen.h +99 -0

103 lines not on this page · raw message

lib/acpi/acpi_device.c +43 -0

49 lines not on this page · raw message

lib/acpi/acpigen.c +54 -0

60 lines not on this page · raw message

test/dm/acpigen.c +126 -0

135 lines not on this page · raw message

Signature · 1 line
2.28.0.526.ge36021eeef-goog
#21 lore raw

PATCH v3 14/57 dm: acpi: Use correct GPIO polarity type in acpi_dp_add_gpio()

In reply to Simon Glass

This function currently accepts the IRQ-polarity type. Fix it to use the GPIO type instead.

---

(no changes since v2)

Changes in v2:
- add new patch to fix polarity type in acpi_dp_add_gpio()

 drivers/sound/max98357a.c | 2 +-
 include/acpi/acpi_dp.h    | 2 +-
 lib/acpi/acpi_dp.c        | 4 ++--
 test/dm/acpi_dp.c         | 4 ++--
 4 files changed, 6 insertions(+), 6 deletions(-)
drivers/sound/max98357a.c +1 -1
index 841bc6ef682..827262d235c 100644
@@ -81,7 +81,7 @@ static int max98357a_acpi_fill_ssdt(const struct udevice *dev,
 	dp = acpi_dp_new_table("_DSD");
 	acpi_dp_add_gpio(dp, "sdmode-gpio", path, 0, 0,
 			 priv->sdmode_gpio.flags & GPIOD_ACTIVE_LOW ?
-			 ACPI_IRQ_ACTIVE_LOW : ACPI_IRQ_ACTIVE_HIGH);
+			 ACPI_GPIO_ACTIVE_LOW : ACPI_GPIO_ACTIVE_HIGH);
 	acpi_dp_add_integer(dp, "sdmode-delay",
 			    dev_read_u32_default(dev, "sdmode-delay", 0));
 	acpi_dp_write(ctx, dp);
include/acpi/acpi_dp.h +1 -1
index 0b514bce59c..5e539b1d218 100644
@@ -221,7 +221,7 @@ struct acpi_dp *acpi_dp_add_child(struct acpi_dp *dp, const char *name,
  */
 struct acpi_dp *acpi_dp_add_gpio(struct acpi_dp *dp, const char *name,
 				 const char *ref, int index, int pin,
-				 enum acpi_irq_polarity polarity);
+				 enum acpi_gpio_polarity polarity);
 
 /**
  * acpi_dp_write() - Write Device Property hierarchy and clean up resources
lib/acpi/acpi_dp.c +2 -2
index 579cab47715..7e3e3259d8d 100644
@@ -324,7 +324,7 @@ struct acpi_dp *acpi_dp_add_integer_array(struct acpi_dp *dp, const char *name,
 
 struct acpi_dp *acpi_dp_add_gpio(struct acpi_dp *dp, const char *name,
 				 const char *ref, int index, int pin,
-				 enum acpi_irq_polarity polarity)
+				 enum acpi_gpio_polarity polarity)
 {
 	struct acpi_dp *gpio;
 
@@ -336,7 +336,7 @@ struct acpi_dp *acpi_dp_add_gpio(struct acpi_dp *dp, const char *name,
 	if (!acpi_dp_add_reference(gpio, NULL, ref) ||
 	    !acpi_dp_add_integer(gpio, NULL, index) ||
 	    !acpi_dp_add_integer(gpio, NULL, pin) ||
-	    !acpi_dp_add_integer(gpio, NULL, polarity == ACPI_IRQ_ACTIVE_LOW))
+	    !acpi_dp_add_integer(gpio, NULL, polarity == ACPI_GPIO_ACTIVE_LOW))
 		return NULL;
 
 	if (!acpi_dp_add_array(dp, gpio))
test/dm/acpi_dp.c +2 -2
index e0fa61263c8..44bcabda6bc 100644
@@ -398,9 +398,9 @@ static int dm_test_acpi_dp_gpio(struct unit_test_state *uts)
 
 	/* Try a few different parameters */
 	ut_assertnonnull(acpi_dp_add_gpio(dp, "reset", TEST_REF, 0x23, 0x24,
-					  ACPI_IRQ_ACTIVE_HIGH));
+					  ACPI_GPIO_ACTIVE_HIGH));
 	ut_assertnonnull(acpi_dp_add_gpio(dp, "allow", TEST_REF, 0, 0,
-					  ACPI_IRQ_ACTIVE_LOW));
+					  ACPI_GPIO_ACTIVE_LOW));
 
 	ptr = acpigen_get_current(ctx);
 	ut_assertok(acpi_dp_write(ctx, dp));
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#22 lore raw

PATCH v3 15/57 x86: link: Allow more space for U-Boot

In reply to Simon Glass

The extra ACPI code increases U-Boot above it current size limit. Move the start earlier to provide space.

---

(no changes since v2)

Changes in v2:
- Add new patch to allow more space for U-Boot on link

 configs/chromebook_link_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configs/chromebook_link_defconfig +1 -1
index 82485a5a3f7..c59a7f3c994 100644
@@ -1,5 +1,5 @@
 CONFIG_X86=y
-CONFIG_SYS_TEXT_BASE=0xFFF00000
+CONFIG_SYS_TEXT_BASE=0xFFEF0000
 CONFIG_SYS_MALLOC_F_LEN=0x2400
 CONFIG_NR_DRAM_BANKS=8
 CONFIG_ENV_SIZE=0x1000
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#23 lore raw

PATCH v3 15/57 x86: link: Allow more space for U-Boot

Quoted 7 lines · Simon Glass

The extra ACPI code increases U-Boot above it current size limit. Move the start earlier to provide space.

---

Quoted 8 lines

(no changes since v2)

Changes in v2:
- Add new patch to allow more space for U-Boot on link

 configs/chromebook_link_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
#24 lore raw

PATCH v3 16/57 i2c: Add a generic driver to generate ACPI info

In reply to Simon Glass

Many I2C devices produce roughly the same ACPI data with just things like the GPIO/interrupt information being different.

This can be handled by a generic driver along with some information in the device tree.

Add a generic i2c driver for this purpose.

---

(no changes since v2)

Changes in v2:
- Fix incorrect space in enable-off-delay-ms

Changes in v1:
- Adjust implementation to match new ACPI GPIO generation
- Capitalise ACPI_OPS_PTR
- Rename acpi-probed to linux,probed
- Support hid-over-i2c separately as well
- Use acpi,ddn instead of acpi,desc
- Use updated acpi_device_write_dsm_i2c_hid() function

 doc/device-tree-bindings/i2c/generic-acpi.txt |  42 ++++
 drivers/i2c/Makefile                          |   3 +
 drivers/i2c/acpi_i2c.c                        | 226 ++++++++++++++++++
 drivers/i2c/acpi_i2c.h                        |  15 ++
 drivers/i2c/i2c-uclass.c                      |  17 ++
 include/acpi/acpi_device.h                    |  55 +++++
 include/i2c.h                                 |  23 ++
 7 files changed, 381 insertions(+)
 create mode 100644 doc/device-tree-bindings/i2c/generic-acpi.txt
 create mode 100644 drivers/i2c/acpi_i2c.c
 create mode 100644 drivers/i2c/acpi_i2c.h
doc/device-tree-bindings/i2c/generic-acpi.txt new file +42 -0
new file mode 100644
index 00000000000..3510a71b570
@@ -0,0 +1,42 @@
+I2C generic device
+==================
+
+This is used only to generate ACPI tables for an I2C device.
+
+Required properties :
+
+ - compatible : "i2c-chip";
+ - reg : I2C chip address
+ - acpi,hid : HID name for the device
+
+Optional properies in addition to device.txt:
+
+ - reset-gpios : GPIO used to assert reset to the device
+ - irq-gpios : GPIO used for interrupt (if Interrupt is not used)
+ - stop-gpios : GPIO used to stop the device
+ - interrupts-extended : Interrupt to use for the device
+ - reset-delay-ms : Delay after de-asserting reset, in ms
+ - reset-off-delay-ms : Delay after asserting reset (during power off)
+ - enable-delay-ms : Delay after asserting enable
+ - enable-off-delay-ms : Delay after de-asserting enable (during power off)
+ - stop-delay-ms : Delay after de-aserting stop
+ - stop-off-delay-ms : Delay after asserting stop (during power off)
+ - hid-descr-addr : HID register offset (for Human Interface Devices)
+
+Example
+-------
+
+	elan-touchscreen at 10 {
+		compatible = "i2c-chip";
+		reg = <0x10>;
+		acpi,hid = "ELAN0001";
+		acpi,ddn = "ELAN Touchscreen";
+		interrupts-extended = <&acpi_gpe GPIO_21_IRQ
+			IRQ_TYPE_EDGE_FALLING>;
+		linux,probed;
+		reset-gpios = <&gpio_n GPIO_36 GPIO_ACTIVE_HIGH>;
+		reset-delay-ms = <20>;
+		enable-gpios = <&gpio_n GPIO_152 GPIO_ACTIVE_HIGH>;
+		enable-delay-ms = <1>;
+		acpi,has-power-resource;
+	};
drivers/i2c/Makefile +3 -0
index f7b27864488..bd248cbf52b 100644
@@ -3,6 +3,9 @@
 # (C) Copyright 2000-2007
 # Wolfgang Denk, DENX Software Engineering, wd at denx.de.
 obj-$(CONFIG_DM_I2C) += i2c-uclass.o
+ifdef CONFIG_ACPIGEN
+obj-$(CONFIG_DM_I2C) += acpi_i2c.o
+endif
 obj-$(CONFIG_DM_I2C_GPIO) += i2c-gpio.o
 obj-$(CONFIG_$(SPL_)I2C_CROS_EC_TUNNEL) += cros_ec_tunnel.o
 obj-$(CONFIG_$(SPL_)I2C_CROS_EC_LDO) += cros_ec_ldo.o
drivers/i2c/acpi_i2c.c new file +226 -0

226 lines not on this page · raw message

drivers/i2c/acpi_i2c.h new file +15 -0
new file mode 100644
index 00000000000..1f4be296016
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2019 Google LLC
+ */
+
+#ifndef __ACPI_I2C_H
+#define __ACPI_I2C_H
+
+#include <dm/acpi.h>
+
+extern struct acpi_ops acpi_i2c_ops;
+
+int acpi_i2c_ofdata_to_platdata(struct udevice *dev);
+
+#endif
drivers/i2c/i2c-uclass.c +17 -0
index 2373aa2ea4c..5c4626b0442 100644
@@ -9,6 +9,8 @@
 #include <i2c.h>
 #include <log.h>
 #include <malloc.h>
+#include <acpi/acpi_device.h>
+#include <dm/acpi.h>
 #include <dm/device-internal.h>
 #include <dm/lists.h>
 #include <dm/pinctrl.h>
@@ -16,6 +18,7 @@
 #include <asm/gpio.h>
 #endif
 #include <linux/delay.h>
+#include "acpi_i2c.h"
 
 #define I2C_MAX_OFFSET_LEN	4
 
@@ -749,7 +752,21 @@ UCLASS_DRIVER(i2c_generic) = {
 	.name		= "i2c_generic",
 };
 
+static const struct udevice_id generic_chip_i2c_ids[] = {
+	{ .compatible = "i2c-chip", .data = I2C_DEVICE_GENERIC },
+#if CONFIG_IS_ENABLED(ACPIGEN)
+	{ .compatible = "hid-over-i2c", .data = I2C_DEVICE_HID_OVER_I2C },
+#endif
+	{ }
+};
+
 U_BOOT_DRIVER(i2c_generic_chip_drv) = {
 	.name		= "i2c_generic_chip_drv",
 	.id		= UCLASS_I2C_GENERIC,
+	.of_match	= generic_chip_i2c_ids,
+#if CONFIG_IS_ENABLED(ACPIGEN)
+	.ofdata_to_platdata	= acpi_i2c_ofdata_to_platdata,
+	.priv_auto_alloc_size	= sizeof(struct acpi_i2c_priv),
+#endif
+	ACPI_OPS_PTR(&acpi_i2c_ops)
 };
include/acpi/acpi_device.h +55 -0

68 lines not on this page · raw message

include/i2c.h +23 -0
index 1d792db454a..880aa8032b7 100644
@@ -58,6 +58,12 @@ enum i2c_address_mode {
 	I2C_MODE_10_BIT
 };
 
+/** enum i2c_device_t - Types of I2C devices, used for compatible strings */
+enum i2c_device_t {
+	I2C_DEVICE_GENERIC,
+	I2C_DEVICE_HID_OVER_I2C,
+};
+
 struct udevice;
 /**
  * struct dm_i2c_chip - information about an i2c chip
@@ -558,6 +564,23 @@ int i2c_emul_find(struct udevice *dev, struct udevice **emulp);
  */
 struct udevice *i2c_emul_get_device(struct udevice *emul);
 
+/* ACPI operations for generic I2C devices */
+extern struct acpi_ops i2c_acpi_ops;
+
+/**
+ * acpi_i2c_ofdata_to_platdata() - Read properties intended for ACPI
+ *
+ * This reads the generic I2C properties from the device tree, so that these
+ * can be used to create ACPI information for the device.
+ *
+ * See the i2c/generic-acpi.txt binding file for information about the
+ * properties.
+ *
+ * @dev: I2C device to process
+ * @return 0 if OK, -EINVAL if acpi,hid is not present
+ */
+int acpi_i2c_ofdata_to_platdata(struct udevice *dev);
+
 #ifndef CONFIG_DM_I2C
 
 /*
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#25 lore raw

PATCH v3 17/57 x86: Add wake sources for the acpi_gpe driver

In reply to Simon Glass

Some devices can wake the system from sleep, e.g opening the lid on a clamshell or moving a USB mouse.

Add a wake to specify this for USB devices and add the settings for Apollo Lake.

---

(no changes since v1)

 arch/x86/include/asm/arch-apollolake/gpe.h  | 135 ++++++++++++++++++++
 arch/x86/include/asm/arch-apollolake/gpio.h |   3 +
 doc/device-tree-bindings/device.txt         |   3 +
 3 files changed, 141 insertions(+)
 create mode 100644 arch/x86/include/asm/arch-apollolake/gpe.h
arch/x86/include/asm/arch-apollolake/gpe.h new file +135 -0
new file mode 100644
index 00000000000..f5792960bee
@@ -0,0 +1,135 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright 2016 Intel Corporation
+ * Copyright 2020 Google LLC
+ *
+ * Taken from coreboot apl gpe.h
+ */
+
+#ifndef _ASM_ARCH_GPE_H_
+#define _ASM_ARCH_GPE_H_
+
+/* bit position in GPE0a_STS register */
+#define GPE0A_PCIE_SCI_STS		0
+#define GPE0A_SWGPE_STS			2
+#define GPE0A_PCIE_WAKE0_STS		3
+#define GPE0A_PUNIT_SCI_STS		4
+#define GPE0A_PCIE_WAKE1_STS		6
+#define GPE0A_PCIE_WAKE2_STS		7
+#define GPE0A_PCIE_WAKE3_STS		8
+#define GPE0A_PCIE_GPE_STS		9
+#define GPE0A_BATLOW_STS		10
+#define GPE0A_CSE_PME_STS		11
+#define GPE0A_XDCI_PME_STS		12
+#define GPE0A_XHCI_PME_STS		13
+#define GPE0A_AVS_PME_STS		14
+#define GPE0A_GPIO_TIER1_SCI_STS	15
+#define GPE0A_SMB_WAK_STS		16
+#define GPE0A_SATA_PME_STS		17
+#define GPE0A_CNVI_PME_STS	        18
+
+/* Group DW0 is reserved in Apollolake */
+
+/* GPE_63_32 */
+#define GPE0_DW1_00		32
+#define GPE0_DW1_01		33
+#define GPE0_DW1_02		34
+#define GPE0_DW1_03		36
+#define GPE0_DW1_04		36
+#define GPE0_DW1_05		37
+#define GPE0_DW1_06		38
+#define GPE0_DW1_07		39
+#define GPE0_DW1_08		40
+#define GPE0_DW1_09		41
+#define GPE0_DW1_10		42
+#define GPE0_DW1_11		43
+#define GPE0_DW1_12		44
+#define GPE0_DW1_13		45
+#define GPE0_DW1_14		46
+#define GPE0_DW1_15		47
+#define GPE0_DW1_16		48
+#define GPE0_DW1_17		49
+#define GPE0_DW1_18		50
+#define GPE0_DW1_19		51
+#define GPE0_DW1_20		52
+#define GPE0_DW1_21		53
+#define GPE0_DW1_22		54
+#define GPE0_DW1_23		55
+#define GPE0_DW1_24		56
+#define GPE0_DW1_25		57
+#define GPE0_DW1_26		58
+#define GPE0_DW1_27		59
+#define GPE0_DW1_28		60
+#define GPE0_DW1_29		61
+#define GPE0_DW1_30		62
+#define GPE0_DW1_31		63
+/* GPE_95_64 */
+#define GPE0_DW2_00		64
+#define GPE0_DW2_01		65
+#define GPE0_DW2_02		66
+#define GPE0_DW2_03		67
+#define GPE0_DW2_04		68
+#define GPE0_DW2_05		69
+#define GPE0_DW2_06		70
+#define GPE0_DW2_07		71
+#define GPE0_DW2_08		72
+#define GPE0_DW2_09		73
+#define GPE0_DW2_10		74
+#define GPE0_DW2_11		75
+#define GPE0_DW2_12		76
+#define GPE0_DW2_13		77
+#define GPE0_DW2_14		78
+#define GPE0_DW2_15		79
+#define GPE0_DW2_16		80
+#define GPE0_DW2_17		81
+#define GPE0_DW2_18		82
+#define GPE0_DW2_19		83
+#define GPE0_DW2_20		84
+#define GPE0_DW2_21		85
+#define GPE0_DW2_22		86
+#define GPE0_DW2_23		87
+#define GPE0_DW2_24		88
+#define GPE0_DW2_25		89
+#define GPE0_DW2_26		90
+#define GPE0_DW2_27		91
+#define GPE0_DW2_28		92
+#define GPE0_DW2_29		93
+#define GPE0_DW2_30		94
+#define GPE0_DW2_31		95
+/* GPE_127_96 */
+#define GPE0_DW3_00		96
+#define GPE0_DW3_01		97
+#define GPE0_DW3_02		98
+#define GPE0_DW3_03		99
+#define GPE0_DW3_04		100
+#define GPE0_DW3_05		101
+#define GPE0_DW3_06		102
+#define GPE0_DW3_07		103
+#define GPE0_DW3_08		104
+#define GPE0_DW3_09		105
+#define GPE0_DW3_10		106
+#define GPE0_DW3_11		107
+#define GPE0_DW3_12		108
+#define GPE0_DW3_13		109
+#define GPE0_DW3_14		110
+#define GPE0_DW3_15		111
+#define GPE0_DW3_16		112
+#define GPE0_DW3_17		113
+#define GPE0_DW3_18		114
+#define GPE0_DW3_19		115
+#define GPE0_DW3_20		116
+#define GPE0_DW3_21		117
+#define GPE0_DW3_22		118
+#define GPE0_DW3_23		119
+#define GPE0_DW3_24		120
+#define GPE0_DW3_25		121
+#define GPE0_DW3_26		122
+#define GPE0_DW3_27		123
+#define GPE0_DW3_28		124
+#define GPE0_DW3_29		125
+#define GPE0_DW3_30		126
+#define GPE0_DW3_31		127
+
+#define GPE_MAX			GPE0_DW3_31
+
+#endif
arch/x86/include/asm/arch-apollolake/gpio.h +3 -0
index 10879c168ec..ab5860c0fd0 100644
@@ -482,4 +482,7 @@
 #define GPIO_72_IRQ			0x65
 #define GPIO_73_IRQ			0x66
 
+/* This is needed by ACPI */
+#define GPIO_NUM_PAD_CFG_REGS   2 /* DW0, DW1 */
+
 #endif /* _ASM_ARCH_GPIO_H_ */
doc/device-tree-bindings/device.txt +3 -0
index 2a5736c5981..73ce2a3b5b5 100644
@@ -22,6 +22,8 @@ the acpi,compatible property.
  - acpi,name : Provides the ACPI name for a device, which is a string consisting
    of four alphanumeric character (upper case)
  - acpi,uid : _UID value for device
+ - acpi,wake : Provides the GPE used to detect a request from a device to wake
+   from sleep
  - linux,probed : Tells U-Boot to add 'linux,probed' to the ACPI tables so that
     Linux will only load the driver if the device can be detected (e.g. on I2C
     bus). Note that this is an out-of-tree Linux feature.
@@ -46,6 +48,7 @@ pcie-a0 at 14,0 {
 		compatible = "intel,generic-wifi";
 		acpi,ddn = "Intel WiFi";
 		acpi,name = "WF00";
+		acpi,wake = <GPE0_DW3_00>;
 		interrupts-extended = <&acpi_gpe 0x3c 0>;
 	};
 };
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#26 lore raw

PATCH v3 18/57 x86: apl: Support writing the IntelGraphicsMem table

In reply to Simon Glass

This table is needed by the Linux graphics driver to handle graphics correctly. Write it to ACPI.

---

(no changes since v1)

Changes in v1:
- Capitalise ACPI_OPS_PTR
- Don't build for SPL

 arch/x86/Kconfig                           |   8 +
 arch/x86/cpu/apollolake/Kconfig            |   1 +
 arch/x86/cpu/intel_common/Makefile         |   4 +
 arch/x86/cpu/intel_common/intel_opregion.c | 168 ++++++++++++++
 arch/x86/include/asm/intel_opregion.h      | 247 +++++++++++++++++++++
 arch/x86/lib/fsp/fsp_graphics.c            |  32 +++
 include/bloblist.h                         |   1 +
 7 files changed, 461 insertions(+)
 create mode 100644 arch/x86/cpu/intel_common/intel_opregion.c
 create mode 100644 arch/x86/include/asm/intel_opregion.h
arch/x86/Kconfig +8 -0
index 680f26f1b8e..675a43e3b60 100644
@@ -1001,4 +1001,12 @@ config PCIEX_LENGTH_128MB
 config PCIEX_LENGTH_64MB
 	bool
 
+config INTEL_GMA_ACPI
+	bool "Generate ACPI table for Intel GMA graphics"
+	help
+	  The Intel GMA graphics driver in Linux expects an ACPI table
+	  which describes the layout of the registers and the display
+	  connected to the device. Enable this option to create this
+	  table so that graphics works correctly.
+
 endmenu
arch/x86/cpu/apollolake/Kconfig +1 -0
index 16ac2b3f504..319f12684b7 100644
@@ -48,6 +48,7 @@ config INTEL_APOLLOLAKE
 	imply CMD_CLK
 	imply CLK_INTEL
 	imply ACPI_GPE
+	imply INTEL_GMA_ACPI
 
 if INTEL_APOLLOLAKE
 
arch/x86/cpu/intel_common/Makefile +4 -0
index 374803b8760..207d5413965 100644
@@ -9,6 +9,10 @@ obj-$(CONFIG_$(SPL_TPL_)X86_32BIT_INIT) += report_platform.o
 obj-$(CONFIG_$(SPL_TPL_)X86_32BIT_INIT) += mrc.o
 endif
 
+ifndef CONFIG_SPL_BUILD
+obj-$(CONFIG_INTEL_GMA_ACPI) += intel_opregion.o
+endif
+
 ifdef CONFIG_INTEL_CAR_CQOS
 obj-$(CONFIG_TPL_BUILD) += car2.o
 ifndef CONFIG_SPL_BUILD
arch/x86/cpu/intel_common/intel_opregion.c new file +168 -0

168 lines not on this page · raw message

arch/x86/include/asm/intel_opregion.h new file +247 -0

247 lines not on this page · raw message

arch/x86/lib/fsp/fsp_graphics.c +32 -0
index e8c1e07af1c..858d7942fed 100644
@@ -3,14 +3,19 @@
  * Copyright (C) 2017, Bin Meng <[email protected]>
  */
 
+#define LOG_CATEGORY UCLASS_VIDEO
+
 #include <common.h>
 #include <dm.h>
 #include <init.h>
 #include <log.h>
 #include <vbe.h>
 #include <video.h>
+#include <acpi/acpi_table.h>
 #include <asm/fsp/fsp_support.h>
+#include <asm/intel_opregion.h>
 #include <asm/mtrr.h>
+#include <dm/acpi.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -127,6 +132,32 @@ static int fsp_video_bind(struct udevice *dev)
 	return 0;
 }
 
+#ifdef CONFIG_INTEL_GMA_ACPI
+static int fsp_video_acpi_write_tables(const struct udevice *dev,
+				       struct acpi_ctx *ctx)
+{
+	struct igd_opregion *opregion;
+	int ret;
+
+	printf("ACPI:    * IGD OpRegion\n");
+	opregion = (struct igd_opregion *)ctx->current;
+
+	ret = intel_gma_init_igd_opregion((struct udevice *)dev, opregion);
+	if (ret)
+		return ret;
+
+	acpi_inc_align(ctx, sizeof(struct igd_opregion));
+
+	return 0;
+}
+#endif
+
+struct acpi_ops fsp_video_acpi_ops = {
+#ifdef CONFIG_INTEL_GMA_ACPI
+	.write_tables	= fsp_video_acpi_write_tables,
+#endif
+};
+
 static const struct udevice_id fsp_video_ids[] = {
 	{ .compatible = "fsp-fb" },
 	{ }
@@ -139,6 +170,7 @@ U_BOOT_DRIVER(fsp_video) = {
 	.bind	= fsp_video_bind,
 	.probe	= fsp_video_probe,
 	.flags	= DM_FLAG_PRE_RELOC,
+	ACPI_OPS_PTR(&fsp_video_acpi_ops)
 };
 
 static struct pci_device_id fsp_video_supported[] = {
include/bloblist.h +1 -0
index bbe0a35d5a2..7d8480548e0 100644
@@ -32,6 +32,7 @@ enum bloblist_tag_t {
 	 * Sleeping table. This forms part of the ACPI tables passed to Linux.
 	 */
 	BLOBLISTT_ACPI_GNVS,
+	BLOBLISTT_INTEL_VBT,		/* Intel Video-BIOS table */
 };
 
 /**
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#27 lore raw

PATCH v3 19/57 x86: acpi: Add a common routine to write WiFi info

In reply to Simon Glass

Intel WiFi chips can use a common routine to write the information needed by linux. Add an implementation of this.

Enable it for coral.

---

(no changes since v1)

Changes in v1:
- Capitalise ACPI_OPS_PTR
- Use acpi,ddn instead of acpi,desc

 arch/x86/Kconfig                         |   8 ++
 arch/x86/cpu/intel_common/Makefile       |   1 +
 arch/x86/cpu/intel_common/generic_wifi.c | 120 +++++++++++++++++++++++
 configs/chromebook_coral_defconfig       |   1 +
 4 files changed, 130 insertions(+)
 create mode 100644 arch/x86/cpu/intel_common/generic_wifi.c
arch/x86/Kconfig +8 -0
index 675a43e3b60..495629d32ed 100644
@@ -1009,4 +1009,12 @@ config INTEL_GMA_ACPI
 	  connected to the device. Enable this option to create this
 	  table so that graphics works correctly.
 
+config INTEL_GENERIC_WIFI
+	bool "Enable generation of ACPI tables for Intel WiFi"
+	help
+	  Select this option to provide code to a build generic WiFi ACPI table
+	  for Intel WiFi devices. This is not a WiFi driver and offers no
+	  network functionality. It is only here to generate the ACPI tables
+	  required by Linux.
+
 endmenu
arch/x86/cpu/intel_common/Makefile +1 -0
index 207d5413965..f1d1513a981 100644
@@ -24,6 +24,7 @@ obj-y += cpu.o
 obj-y += fast_spi.o
 obj-y += lpc.o
 obj-y += lpss.o
+obj-$(CONFIG_INTEL_GENERIC_WIFI) += generic_wifi.o
 ifndef CONFIG_TARGET_EFI_APP
 obj-$(CONFIG_$(SPL_TPL_)X86_32BIT_INIT) += microcode.o
 ifndef CONFIG_$(SPL_)X86_64
arch/x86/cpu/intel_common/generic_wifi.c new file +120 -0

120 lines not on this page · raw message

configs/chromebook_coral_defconfig +1 -0
index e1d0749239b..c9006e2f934 100644
@@ -18,6 +18,7 @@ CONFIG_HAVE_ACPI_RESUME=y
 CONFIG_INTEL_CAR_CQOS=y
 CONFIG_X86_OFFSET_U_BOOT=0xffe00000
 CONFIG_X86_OFFSET_SPL=0xffe80000
+CONFIG_INTEL_GENERIC_WIFI=y
 CONFIG_BOOTSTAGE=y
 CONFIG_SPL_BOOTSTAGE=y
 CONFIG_TPL_BOOTSTAGE=y
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#28 lore raw

PATCH v3 20/57 x86: Add some definitions for SMM

In reply to Simon Glass

U-Boot does not support SMM (System Management Mode) at present, but needs a few definitions to correctly set up the ACPI table. Add these.

---

(no changes since v1)

 arch/x86/include/asm/smm.h | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100644 arch/x86/include/asm/smm.h
arch/x86/include/asm/smm.h new file +27 -0
new file mode 100644
index 00000000000..1e539fda067
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * SMM definitions (U-Boot does not support SMM itself)
+ *
+ * Copyright (C) 2008-2009 coresystems GmbH
+ * Copyright 2019 Google LLC
+ *
+ * Modified from coreboot smm.h
+ */
+
+#ifndef _ASM_SMM_H
+#define _ASM_SMM_H
+
+#define APM_CNT			0xb2
+#define APM_CNT_CST_CONTROL	0x85
+#define APM_CNT_PST_CONTROL	0x80
+#define APM_CNT_ACPI_DISABLE	0x1e
+#define APM_CNT_ACPI_ENABLE	0xe1
+#define APM_CNT_MBI_UPDATE	0xeb
+#define APM_CNT_GNVS_UPDATE	0xea
+#define APM_CNT_FINALIZE	0xcb
+#define APM_CNT_LEGACY		0xcc
+#define APM_CNT_SMMSTORE	0xed
+#define APM_CNT_ELOG_GSMI	0xef
+#define APM_STS			0xb3
+
+#endif /* _ASM_SMM_H */
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#29 lore raw

PATCH v3 21/57 x86: apl: Add power-management definitions

In reply to Simon Glass

Add SCI and power-state definitions required by ACPI tables. Fix the license to match the original source file.

Als update the guard on acpi_pmc.h to avoid an error when buiding ASL.

---

(no changes since v1)

Changes in v1:
- Use SHIFT and MASK for defines

 arch/x86/include/asm/arch-apollolake/pm.h | 40 ++++++++++++++++++++++-
 include/power/acpi_pmc.h                  |  4 +--
 2 files changed, 41 insertions(+), 3 deletions(-)
arch/x86/include/asm/arch-apollolake/pm.h +39 -1
index 6718290c4fe..9a8d971e910 100644
@@ -1,12 +1,15 @@
-/* SPDX-License-Identifier: GPL-2.0 */
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * Copyright (C) 2015-2016 Intel Corp.
  * (Written by Lance Zhao <[email protected]> for Intel Corp.)
+ * Copyright 2019 Google LLC
  */
 
 #ifndef _ASM_ARCH_PM_H
 #define _ASM_ARCH_PM_H
 
+#include <power/acpi_pmc.h>
+
 #define PMC_GPE_SW_31_0	0
 #define PMC_GPE_SW_63_32	1
 #define PMC_GPE_NW_31_0	3
@@ -16,4 +19,39 @@
 #define PMC_GPE_N_63_32	7
 #define PMC_GPE_W_31_0		9
 
+#define IRQ_REG			0x106c
+#define SCI_IRQ_SHIFT		24
+#define SCI_IRQ_MASK		(0xff << SCI_IRQ_SHIFT)
+#define SCIS_IRQ9		9
+#define SCIS_IRQ10		10
+#define SCIS_IRQ11		11
+#define SCIS_IRQ20		20
+#define SCIS_IRQ21		21
+#define SCIS_IRQ22		22
+#define SCIS_IRQ23		23
+
+/* P-state configuration */
+#define PSS_MAX_ENTRIES		8
+#define PSS_RATIO_STEP		2
+#define PSS_LATENCY_TRANSITION	10
+#define PSS_LATENCY_BUSMASTER	10
+
+#ifndef __ASSEMBLY__
+/* Track power state from reset to log events */
+struct __packed chipset_power_state {
+	u16 pm1_sts;
+	u16 pm1_en;
+	u32 pm1_cnt;
+	u32 gpe0_sts[GPE0_REG_MAX];
+	u32 gpe0_en[GPE0_REG_MAX];
+	u16 tco1_sts;
+	u16 tco2_sts;
+	u32 prsts;
+	u32 gen_pmcon1;
+	u32 gen_pmcon2;
+	u32 gen_pmcon3;
+	u32 prev_sleep_state;
+};
+#endif /* !__ASSEMBLY__ */
+
 #endif
include/power/acpi_pmc.h +2 -2
index 5fbf7451369..222288b71a4 100644
@@ -6,7 +6,7 @@
 #ifndef __ACPI_PMC_H
 #define __ACPI_PMC_H
 
-#ifndef __ACPI__
+#ifndef __ASSEMBLY__
 
 enum {
 	GPE0_REG_MAX	= 4,
@@ -194,6 +194,6 @@ void pmc_dump_info(struct udevice *dev);
  */
 int pmc_gpe_init(struct udevice *dev);
 
-#endif /* !__ACPI__ */
+#endif /* !__ASSEMBLY__ */
 
 #endif
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#30 lore raw

PATCH v3 22/57 x86: apl: Update iomap for ACPI

In reply to Simon Glass

Add some more definitions to the iomap. These will be used by ACPI-generation code as well as the device tree.

---

(no changes since v1)

 arch/x86/include/asm/arch-apollolake/iomap.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
arch/x86/include/asm/arch-apollolake/iomap.h +16 -0
index 4ce10170558..21c5f33021a 100644
@@ -11,11 +11,27 @@
 
 /* Put p2sb at 0xd0000000 in TPL */
 #define IOMAP_P2SB_BAR		0xd0000000
+#define IOMAP_P2SB_SIZE		0x10000000
 
 #define IOMAP_SPI_BASE		0xfe010000
 
 #define IOMAP_ACPI_BASE		0x400
 #define IOMAP_ACPI_SIZE		0x100
+#define ACPI_BASE_ADDRESS	IOMAP_ACPI_BASE
+
+#define PMC_BAR0		0xfe042000
+
+#define MCH_BASE_ADDRESS	0xfed10000
+#define MCH_SIZE		0x8000
+
+#ifdef __ACPI__
+#define HPET_BASE_ADDRESS	0xfed00000
+
+#define SRAM_BASE_0		0xfe900000
+#define SRAM_SIZE_0		(8 * KiB)
+#define SRAM_BASE_2		0xfe902000
+#define SRAM_SIZE_2		(4 * KiB)
+#endif
 
 /*
  * Use UART2. To use UART1 you need to set '2' to '1', change device tree serial
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#31 lore raw

PATCH v3 23/57 x86: Add a few common Intel CPU functions

In reply to Simon Glass

Add functions to query CPU information, needed for ACPI.

---

(no changes since v1)

Changes in v1:
- Add more comments and rename cpu_get_bus_clock to cpu_get_bus_clock_khz()

 arch/x86/cpu/intel_common/cpu.c   | 64 +++++++++++++++++++++++++++++++
 arch/x86/include/asm/cpu_common.h | 49 +++++++++++++++++++++++
 include/acpi/acpigen.h            | 12 ++++++
 3 files changed, 125 insertions(+)
arch/x86/cpu/intel_common/cpu.c +64 -0
index 509730aea96..cb4ef84013a 100644
@@ -12,6 +12,7 @@
 #include <dm.h>
 #include <errno.h>
 #include <log.h>
+#include <acpi/acpigen.h>
 #include <asm/cpu.h>
 #include <asm/cpu_common.h>
 #include <asm/intel_regs.h>
@@ -227,3 +228,66 @@ void cpu_set_eist(bool eist_status)
 		msr.lo &= ~MISC_ENABLE_ENHANCED_SPEEDSTEP;
 	msr_write(MSR_IA32_MISC_ENABLE, msr);
 }
+
+int cpu_get_coord_type(void)
+{
+	return HW_ALL;
+}
+
+int cpu_get_min_ratio(void)
+{
+	msr_t msr;
+
+	/* Get bus ratio limits and calculate clock speeds */
+	msr = msr_read(MSR_PLATFORM_INFO);
+
+	return (msr.hi >> 8) & 0xff;	/* Max Efficiency Ratio */
+}
+
+int cpu_get_max_ratio(void)
+{
+	u32 ratio_max;
+	msr_t msr;
+
+	if (cpu_config_tdp_levels()) {
+		/* Set max ratio to nominal TDP ratio */
+		msr = msr_read(MSR_CONFIG_TDP_NOMINAL);
+		ratio_max = msr.lo & 0xff;
+	} else {
+		msr = msr_read(MSR_PLATFORM_INFO);
+		/* Max Non-Turbo Ratio */
+		ratio_max = (msr.lo >> 8) & 0xff;
+	}
+
+	return ratio_max;
+}
+
+int cpu_get_bus_clock_khz(void)
+{
+	/*
+	 * CPU bus clock is set by default here to 100MHz. This function returns
+	 * the bus clock in KHz.
+	 */
+	return INTEL_BCLK_MHZ * 1000;
+}
+
+int cpu_get_power_max(void)
+{
+	int power_unit;
+	msr_t msr;
+
+	msr = msr_read(MSR_PKG_POWER_SKU_UNIT);
+	power_unit = 2 << ((msr.lo & 0xf) - 1);
+	msr = msr_read(MSR_PKG_POWER_SKU);
+
+	return (msr.lo & 0x7fff) * 1000 / power_unit;
+}
+
+int cpu_get_max_turbo_ratio(void)
+{
+	msr_t msr;
+
+	msr = msr_read(MSR_TURBO_RATIO_LIMIT);
+
+	return msr.lo & 0xff;
+}
arch/x86/include/asm/cpu_common.h +49 -0

53 lines not on this page · raw message

include/acpi/acpigen.h +12 -0
index 34b3115bc9c..c412898169e 100644
@@ -73,6 +73,18 @@ enum {
 	RETURN_OP		= 0xa4,
 };
 
+/**
+ * enum psd_coord - Coordination types for P-states
+ *
+ * The type of coordination that exists (hardware) or is required (software) as
+ * a result of the underlying hardware dependency
+ */
+enum psd_coord {
+	SW_ALL = 0xfc,
+	SW_ANY = 0xfd,
+	HW_ALL = 0xfe
+};
+
 /**
  * acpigen_get_current() - Get the current ACPI code output pointer
  *
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#32 lore raw

PATCH v3 24/57 x86: acpi: Support generation of the HPET table

In reply to Simon Glass

Add an implementation of the HPET (High Precision Event Timer) ACPI table. Since this is x86-specific, put it in an x86-specific file

---

(no changes since v1)

Changes in v1:
- Put this code in an x86-specific place and update commit message

 arch/x86/include/asm/acpi_table.h | 10 ++++++
 arch/x86/lib/acpi_table.c         | 59 +++++++++++++++++++++++++++++++
 include/acpi/acpi_table.h         | 31 +++++++++++-----
 3 files changed, 91 insertions(+), 9 deletions(-)
arch/x86/include/asm/acpi_table.h +10 -0
index 733085c1785..7047ee6c772 100644
@@ -36,6 +36,16 @@ int acpi_create_mcfg_mmconfig(struct acpi_mcfg_mmconfig *mmconfig, u32 base,
 u32 acpi_fill_mcfg(u32 current);
 u32 acpi_fill_csrt(u32 current);
 
+/**
+ * acpi_write_hpet() - Write out a HPET table
+ *
+ * Write out the table for High-Precision Event Timers
+ *
+ * @ctx: Current ACPI context
+ * @return 0 if OK, -ve on error
+ */
+int acpi_write_hpet(struct acpi_ctx *ctx);
+
 /**
  * acpi_create_gnvs() - Create a GNVS (Global Non Volatile Storage) table
  *
arch/x86/lib/acpi_table.c +59 -0

62 lines not on this page · raw message

include/acpi/acpi_table.h +22 -9
index fe9b29f3f82..f8140446a59 100644
@@ -20,6 +20,9 @@
 #define OEM_TABLE_ID		"U-BOOTBL"	/* U-Boot Table */
 #define ASLC_ID			"INTL"		/* Intel ASL Compiler */
 
+/* TODO(sjg at chromium.org): Figure out how to get compiler revision */
+#define ASL_REVISION	0
+
 #define ACPI_RSDP_REV_ACPI_1_0	0
 #define ACPI_RSDP_REV_ACPI_2_0	2
 
@@ -56,6 +59,15 @@ struct __packed acpi_table_header {
 	u32 aslc_revision;	/* ASL compiler revision number */
 };
 
+struct acpi_gen_regaddr {
+	u8 space_id;	/* Address space ID */
+	u8 bit_width;	/* Register size in bits */
+	u8 bit_offset;	/* Register bit offset */
+	u8 access_size;	/* Access size */
+	u32 addrl;	/* Register address, low 32 bits */
+	u32 addrh;	/* Register address, high 32 bits */
+};
+
 /* A maximum number of 32 ACPI tables ought to be enough for now */
 #define MAX_ACPI_TABLES		32
 
@@ -71,6 +83,16 @@ struct acpi_xsdt {
 	u64 entry[MAX_ACPI_TABLES];
 };
 
+/* HPET timers */
+struct __packed acpi_hpet {
+	struct acpi_table_header header;
+	u32 id;
+	struct acpi_gen_regaddr addr;
+	u8 number;
+	u16 min_tick;
+	u8 attributes;
+};
+
 /* FADT Preferred Power Management Profile */
 enum acpi_pm_profile {
 	ACPI_PM_UNSPECIFIED = 0,
@@ -138,15 +160,6 @@ enum acpi_address_space_size {
 	ACPI_ACCESS_SIZE_QWORD_ACCESS
 };
 
-struct acpi_gen_regaddr {
-	u8 space_id;	/* Address space ID */
-	u8 bit_width;	/* Register size in bits */
-	u8 bit_offset;	/* Register bit offset */
-	u8 access_size;	/* Access size */
-	u32 addrl;	/* Register address, low 32 bits */
-	u32 addrh;	/* Register address, high 32 bits */
-};
-
 /* FADT (Fixed ACPI Description Table) */
 struct __packed acpi_fadt {
 	struct acpi_table_header header;
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#33 lore raw

PATCH v3 25/57 x86: acpi: Support generation of the DBG2 table

In reply to Simon Glass

Add an implementation of the DBG2 (Debug Port Table 2) ACPI table. Adjust one of the header includes to be in the correct order, before adding more.

Note that the DBG2 table is generic but the PCI UART is x86-specific at present since it assumes an ns16550 UART. It can be generalised later if necessary.

---

(no changes since v1)

Changes in v1:
- Move ASL_REVISION define into this patch
- Move acpi_create_dbg2() into generic code
- Update commit message

 arch/x86/include/asm/acpi_table.h | 11 ++++++
 arch/x86/lib/acpi_table.c         | 41 ++++++++++++++++++++
 include/acpi/acpi_table.h         | 40 +++++++++++++++++++
 lib/acpi/acpi_table.c             | 64 +++++++++++++++++++++++++++++++
 4 files changed, 156 insertions(+)
arch/x86/include/asm/acpi_table.h +11 -0
index 7047ee6c772..1b7ff509516 100644
@@ -46,6 +46,17 @@ u32 acpi_fill_csrt(u32 current);
  */
 int acpi_write_hpet(struct acpi_ctx *ctx);
 
+/**
+ * acpi_write_dbg2_pci_uart() - Write out a DBG2 table
+ *
+ * @ctx: Current ACPI context
+ * @dev: Debug UART device to describe
+ * @access_size: Access size for UART (e.g. ACPI_ACCESS_SIZE_DWORD_ACCESS)
+ * @return 0 if OK, -ve on error
+ */
+int acpi_write_dbg2_pci_uart(struct acpi_ctx *ctx, struct udevice *dev,
+			     uint access_size);
+
 /**
  * acpi_create_gnvs() - Create a GNVS (Global Non Volatile Storage) table
  *
arch/x86/lib/acpi_table.c +41 -0

50 lines not on this page · raw message

include/acpi/acpi_table.h +40 -0
index f8140446a59..c826a797f5b 100644
@@ -448,6 +448,29 @@ struct __packed acpi_dmar {
 
 #define ACPI_DBG2_UNKNOWN		0x00FF
 
+/* DBG2: Microsoft Debug Port Table 2 header */
+struct __packed acpi_dbg2_header {
+	struct acpi_table_header header;
+	u32 devices_offset;
+	u32 devices_count;
+};
+
+/* DBG2: Microsoft Debug Port Table 2 device entry */
+struct __packed acpi_dbg2_device {
+	u8  revision;
+	u16 length;
+	u8 address_count;
+	u16 namespace_string_length;
+	u16 namespace_string_offset;
+	u16 oem_data_length;
+	u16 oem_data_offset;
+	u16 port_type;
+	u16 port_subtype;
+	u8  reserved[2];
+	u16 base_address_offset;
+	u16 address_size_offset;
+};
+
 /* SPCR (Serial Port Console Redirection table) */
 struct __packed acpi_spcr {
 	struct acpi_table_header header;
@@ -522,6 +545,23 @@ int acpi_get_table_revision(enum acpi_tables table);
  */
 int acpi_create_dmar(struct acpi_dmar *dmar, enum dmar_flags flags);
 
+/**
+ * acpi_create_dbg2() - Create a DBG2 table
+ *
+ * This table describes how to access the debug UART
+ *
+ * @dbg2: Place to put information
+ * @port_type: Serial port type (see ACPI_DBG2_...)
+ * @port_subtype: Serial port sub-type (see ACPI_DBG2_...)
+ * @address: ACPI address of port
+ * @address_size: Size of address space
+ * @device_path: Path of device (created using acpi_device_path())
+ */
+void acpi_create_dbg2(struct acpi_dbg2_header *dbg2,
+		      int port_type, int port_subtype,
+		      struct acpi_gen_regaddr *address, uint32_t address_size,
+		      const char *device_path);
+
 /**
  * acpi_fill_header() - Set up a new table header
  *
lib/acpi/acpi_table.c +64 -0

67 lines not on this page · raw message

Signature · 1 line
2.28.0.526.ge36021eeef-goog
#34 lore raw

PATCH v3 26/57 acpi: Add support for generating processor tables

In reply to Simon Glass

ACPI has a number of CPU-related tables. Add utility functions to write out the basic packages.

---

(no changes since v1)

 include/acpi/acpigen.h |  39 +++++++++++++++
 lib/acpi/acpigen.c     |  55 +++++++++++++++++++++
 test/dm/acpigen.c      | 106 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 200 insertions(+)
include/acpi/acpigen.h +39 -0
index c412898169e..3a2c6339d5e 100644
@@ -64,7 +64,9 @@ enum {
 	OR_OP			= 0x7d,
 	NOT_OP			= 0x80,
 	DEVICE_OP		= 0x82,
+	PROCESSOR_OP		= 0x83,
 	POWER_RES_OP		= 0x84,
+	NOTIFY_OP		= 0x86,
 	LEQUAL_OP		= 0x93,
 	TO_BUFFER_OP		= 0x96,
 	TO_INTEGER_OP		= 0x99,
@@ -777,4 +779,41 @@ void acpigen_write_dsm_uuid_end(struct acpi_ctx *ctx);
  */
 void acpigen_write_dsm_end(struct acpi_ctx *ctx);
 
+/**
+ * acpigen_write_processor() - Write a Processor package
+ *
+ * This emits a Processor package header with the required information. The
+ * caller must complete the information and call acpigen_pop_len() at the end
+ *
+ * @ctx: ACPI context pointer
+ * @cpuindex: CPU number
+ * @pblock_addr: PBlk system IO address
+ * @pblock_len: PBlk length
+ */
+void acpigen_write_processor(struct acpi_ctx *ctx, uint cpuindex,
+			     u32 pblock_addr, uint pblock_len);
+
+/**
+ * acpigen_write_processor_package() - Write a package containing the processors
+ *
+ * The package containins the name of each processor in the SoC
+ *
+ * @ctx: ACPI context pointer
+ * @name: Package name (.e.g "PPKG")
+ * @first_core: Number of the first core (e.g. 0)
+ * @core_count: Number of cores (e.g. 4)
+ */
+void acpigen_write_processor_package(struct acpi_ctx *ctx, const char *name,
+				     uint first_core, uint core_count);
+
+/**
+ * acpigen_write_processor_cnot() - Write a processor notification method
+ *
+ * This writes a method that notifies all CPU cores
+ *
+ * @ctx: ACPI context pointer
+ * @num_cores: Number of CPU cores
+ */
+void acpigen_write_processor_cnot(struct acpi_ctx *ctx, const uint num_cores);
+
 #endif
lib/acpi/acpigen.c +55 -0

67 lines not on this page · raw message

test/dm/acpigen.c +106 -0

109 lines not on this page · raw message

Signature · 1 line
2.28.0.526.ge36021eeef-goog
#35 lore raw

PATCH v3 27/57 x86: acpi: Add PCT and PTC tables

In reply to Simon Glass

These are needed for the CPU tables. Add them into an x86-specific file since we do not support them on sandbox, or include tests.

---

(no changes since v1)

Changes in v1:
- Split PCT and PTC tables into a separate patch

 arch/x86/include/asm/acpigen.h | 35 +++++++++++++
 arch/x86/lib/Makefile          |  2 +-
 arch/x86/lib/acpigen.c         | 96 ++++++++++++++++++++++++++++++++++
 3 files changed, 132 insertions(+), 1 deletion(-)
 create mode 100644 arch/x86/include/asm/acpigen.h
 create mode 100644 arch/x86/lib/acpigen.c
arch/x86/include/asm/acpigen.h new file +35 -0
new file mode 100644
index 00000000000..c531dd61d53
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Generation of x86-specific ACPI tables
+ *
+ * Copyright 2020 Google LLC
+ */
+
+#ifndef __ASM_ACPIGEN_H__
+#define __ASM_ACPIGEN_H__
+
+struct acpi_ctx;
+
+/**
+ * acpigen_write_empty_pct() - Write an empty PCT
+ *
+ * See ACPI v6.3 section 8.4.6.1: _PCT (Performance Control)
+ *
+ * This writes an empty table so that CPU performance works as expected
+ *
+ * @ctx: ACPI context pointer
+ */
+void acpigen_write_empty_pct(struct acpi_ctx *ctx);
+
+/**
+ * acpigen_write_empty_ptc() - Write an empty PTC
+ *
+ * See ACPI v6.3 section 8.4.5.1: _PTC (Processor Throttling Control)
+ *
+ * This writes an empty table so that CPU performance works as expected
+ *
+ * @ctx: ACPI context pointer
+ */
+void acpigen_write_empty_ptc(struct acpi_ctx *ctx);
+
+#endif /* __ASM_ACPI_H__ */
arch/x86/lib/Makefile +1 -1
index 1185a88c27c..f04d275dd9a 100644
@@ -38,7 +38,7 @@ obj-y += sfi.o
 obj-y	+= acpi.o
 obj-$(CONFIG_HAVE_ACPI_RESUME) += acpi_s3.o
 ifndef CONFIG_QEMU
-obj-$(CONFIG_GENERATE_ACPI_TABLE) += acpi_table.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += acpi_table.o acpigen.o
 endif
 obj-y	+= tables.o
 ifndef CONFIG_SPL_BUILD
arch/x86/lib/acpigen.c new file +96 -0

96 lines not on this page · raw message

Signature · 1 line
2.28.0.526.ge36021eeef-goog
#36 lore raw

PATCH v3 28/57 acpi: Add more support for generating processor tables

In reply to Simon Glass

This adds tables relating to P-States and C-States.

---

(no changes since v1)

 include/acpi/acpigen.h | 162 +++++++++++++++++++++++
 lib/acpi/acpigen.c     | 167 +++++++++++++++++++++++
 test/dm/acpigen.c      | 294 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 623 insertions(+)
include/acpi/acpigen.h +162 -0
index 3a2c6339d5e..976f4dbb9af 100644
@@ -10,8 +10,10 @@
 #ifndef __ACPI_ACPIGEN_H
 #define __ACPI_ACPIGEN_H
 
+#include <acpi/acpi_table.h>
 #include <linux/types.h>
 
+struct acpi_cstate;
 struct acpi_ctx;
 struct acpi_gen_regaddr;
 struct acpi_gpio;
@@ -87,6 +89,53 @@ enum psd_coord {
 	HW_ALL = 0xfe
 };
 
+/**
+ * enum csd_coord -  Coordination types for C-states
+ *
+ * The type of coordination that exists (hardware) or is required (software) as
+ * a result of the underlying hardware dependency
+ */
+enum csd_coord {
+	CSD_HW_ALL = 0xfe,
+};
+
+/**
+ * struct acpi_cstate - Information about a C-State
+ *
+ * @ctype: C State type (1=C1, 2=C2, 3=C3)
+ * @latency: Worst-case latency to enter and exit the C State (in uS)
+ * @power: Average power consumption of the processor when in this C-State (mW)
+ * @resource: Register to read to place the processor in this state
+ */
+struct acpi_cstate {
+	uint ctype;
+	uint latency;
+	uint power;
+	struct acpi_gen_regaddr resource;
+};
+
+/**
+ * struct acpi_tstate - Information about a Throttling Supported State
+ *
+ * See ACPI v6.3 section 8.4.5.2: _TSS (Throttling Supported States)
+ *
+ * @percent: Percent of the core CPU operating frequency that will be
+ *	available when this throttling state is invoked
+ * @power: Throttling state?s maximum power dissipation (mw)
+ * @latency: Worst-case latency (uS) that the CPU is unavailable during a
+ *	transition from any throttling state to this throttling state
+ * @control: Value to be written to the Processor Control Register
+ *	(THROTTLE_CTRL) to initiate a transition to this throttling state
+ * @status: Value in THROTTLE_STATUS when in this state
+ */
+struct acpi_tstate {
+	uint percent;
+	uint power;
+	uint latency;
+	uint control;
+	uint status;
+};
+
 /**
  * acpigen_get_current() - Get the current ACPI code output pointer
  *
@@ -816,4 +865,117 @@ void acpigen_write_processor_package(struct acpi_ctx *ctx, const char *name,
  */
 void acpigen_write_processor_cnot(struct acpi_ctx *ctx, const uint num_cores);
 
+/**
+ * acpigen_write_ppc() - generates a function returning max P-states
+ *
+ * @ctx: ACPI context pointer
+ * @num_pstates: Number of pstates to return
+ */
+void acpigen_write_ppc(struct acpi_ctx *ctx, uint num_pstates);
+
+/**
+ * acpigen_write_ppc() - generates a function returning PPCM
+ *
+ * This returns the maximum number of supported P-states, as saved in the
+ * variable PPCM
+ *
+ * @ctx: ACPI context pointer
+ */
+void acpigen_write_ppc_nvs(struct acpi_ctx *ctx);
+
+/**
+ * acpigen_write_tpc() - Write a _TPC method that returns the TPC limit
+ *
+ * @ctx: ACPI context pointer
+ * @gnvs_tpc_limit: Variable that holds the TPC limit
+ */
+void acpigen_write_tpc(struct acpi_ctx *ctx, const char *gnvs_tpc_limit);
+
+/**
+ * acpigen_write_pss_package() - Write a PSS package
+ *
+ * See ACPI v6.3 section 8.4.6: Processor Performance Control
+ *
+ * @ctx: ACPI context pointer
+ * @corefreq: CPU core frequency in MHz
+ * @translat: worst-case latency in uS that the CPU is unavailable during a
+ *	transition from any performance state to this performance state
+ * @busmlat: worst-case latency in microseconds that Bus Masters are prevented
+ *	from accessing memory during a transition from any performance state to
+ *	this performance state
+ * @control: Value to write to PERF_CTRL to move to this performance state
+ * @status: Expected PERF_STATUS value when in this state
+ */
+void acpigen_write_pss_package(struct acpi_ctx *ctx, uint corefreq, uint power,
+			       uint translat, uint busmlat, uint control,
+			       uint status);
+
+/**
+ * acpigen_write_psd_package() - Write a PSD package
+ *
+ * Writes a P-State dependency package
+ *
+ * See ACPI v6.3 section 8.4.6.5: _PSD (P-State Dependency)
+ *
+ * @ctx: ACPI context pointer
+ * @domain: Dependency domain number to which this P state entry belongs
+ * @numprocs: Number of processors belonging to the domain for this logical
+ *	processor?s P-states
+ * @coordtype: Coordination type
+ */
+void acpigen_write_psd_package(struct acpi_ctx *ctx, uint domain, uint numprocs,
+			       enum psd_coord coordtype);
+
+/**
+ * acpigen_write_cst_package() - Write a _CST package
+ *
+ * See ACPI v6.3 section 8.4.2.1: _CST (C States)
+ *
+ * @ctx: ACPI context pointer
+ * @entry: Array of entries
+ * @nentries; Number of entries
+ */
+void acpigen_write_cst_package(struct acpi_ctx *ctx,
+			       const struct acpi_cstate *entry, int nentries);
+
+/**
+ * acpigen_write_csd_package() - Write a _CSD Package
+ *
+ * See ACPI v6.3 section 8.4.2.2: _CSD (C-State Dependency)
+ *
+ * @ctx: ACPI context pointer
+ * @domain: dependency domain number to which this C state entry belongs
+ * @numprocs: number of processors belonging to the domain for the particular
+ *	C-state
+ * @coordtype: Co-ordination type
+ * @index: Index of the C-State entry in the _CST object for which the
+ *	dependency applies
+ */
+void acpigen_write_csd_package(struct acpi_ctx *ctx, uint domain, uint numprocs,
+			       enum csd_coord coordtype, uint index);
+
+/**
+ * acpigen_write_tss_package() - Write a _TSS package
+ *
+ * @ctx: ACPI context pointer
+ * @entry: Entries to write
+ * @nentries: Number of entries to write
+ */
+void acpigen_write_tss_package(struct acpi_ctx *ctx,
+			       struct acpi_tstate *entry, int nentries);
+
+/**
+ * acpigen_write_tsd_package() - Write a _TSD package
+ *
+ * See ACPI v6.3 section 8.4.5.4: _TSD (T-State Dependency)
+ *
+ * @ctx: ACPI context pointer
+ * @domain: dependency domain number to which this T state entry belongs
+ * @numprocs: Number of processors belonging to the domain for this logical
+ *	processor?s T-states
+ * @coordtype: Coordination type
+ */
+void acpigen_write_tsd_package(struct acpi_ctx *ctx, uint domain, uint numprocs,
+			       enum psd_coord coordtype);
+
 #endif
lib/acpi/acpigen.c +167 -0

179 lines not on this page · raw message

test/dm/acpigen.c +294 -0

297 lines not on this page · raw message

Signature · 1 line
2.28.0.526.ge36021eeef-goog
#37 lore raw

PATCH v3 29/57 x86: acpi: Add common Intel ACPI tables

In reply to Simon Glass

Add various tables that are common to Intel CPUs. These functions can be used by arch-specific CPU code.

---

(no changes since v1)

 arch/x86/cpu/intel_common/Makefile |   2 +
 arch/x86/cpu/intel_common/acpi.c   | 377 +++++++++++++++++++++++++++++
 arch/x86/cpu/intel_common/cpu.c    |  14 ++
 arch/x86/include/asm/acpi_table.h  |  22 ++
 arch/x86/include/asm/cpu_common.h  |   7 +
 arch/x86/include/asm/intel_acpi.h  |  52 ++++
 drivers/core/Kconfig               |   9 +
 7 files changed, 483 insertions(+)
 create mode 100644 arch/x86/cpu/intel_common/acpi.c
 create mode 100644 arch/x86/include/asm/intel_acpi.h
arch/x86/cpu/intel_common/Makefile +2 -0
index f1d1513a981..4a5cf17e41d 100644
@@ -2,6 +2,8 @@
 #
 # Copyright (c) 2016 Google, Inc
 
+obj-$(CONFIG_INTEL_ACPIGEN) += acpi.o
+
 ifdef CONFIG_HAVE_MRC
 obj-$(CONFIG_$(SPL_TPL_)X86_16BIT_INIT) += car.o
 obj-$(CONFIG_$(SPL_TPL_)X86_32BIT_INIT) += me_status.o
arch/x86/cpu/intel_common/acpi.c new file +377 -0

377 lines not on this page · raw message

arch/x86/cpu/intel_common/cpu.c +14 -0
index cb4ef84013a..d8a3d60ae72 100644
@@ -291,3 +291,17 @@ int cpu_get_max_turbo_ratio(void)
 
 	return msr.lo & 0xff;
 }
+
+int cpu_get_cores_per_package(void)
+{
+	struct cpuid_result result;
+	int cores = 1;
+
+	if (gd->arch.x86_vendor != X86_VENDOR_INTEL)
+		return 1;
+
+	result = cpuid_ext(0xb, 1);
+	cores = result.ebx & 0xff;
+
+	return cores;
+}
arch/x86/include/asm/acpi_table.h +22 -0
index 1b7ff509516..3245e447813 100644
@@ -76,4 +76,26 @@ ulong write_acpi_tables(ulong start);
  */
 ulong acpi_get_rsdp_addr(void);
 
+/**
+ * arch_read_sci_irq_select() - Read the system-control interrupt number
+ *
+ * @returns value of IRQ register in the PMC
+ */
+int arch_read_sci_irq_select(void);
+
+/**
+ * arch_write_sci_irq_select() - Set the system-control interrupt number
+ *
+ * @scis: New value for IRQ register in the PMC
+ */
+int arch_write_sci_irq_select(uint scis);
+
+/**
+ * arch_madt_sci_irq_polarity() - Return the priority to use for the MADT
+ *
+ * @sci: System-control interrupt number
+ * @return priority to use (MP_IRQ_POLARITY_...)
+ */
+int arch_madt_sci_irq_polarity(int sci);
+
 #endif /* __ASM_ACPI_TABLE_H__ */
arch/x86/include/asm/cpu_common.h +7 -0
index a7b7112d417..48f56c2aad9 100644
@@ -177,4 +177,11 @@ int cpu_get_power_max(void);
  */
 int cpu_get_max_turbo_ratio(void);
 
+/**
+ * cpu_get_cores_per_package() - Get the number of CPU cores in each package
+ *
+ * @return number of cores
+ */
+int cpu_get_cores_per_package(void);
+
 #endif
arch/x86/include/asm/intel_acpi.h new file +52 -0

52 lines not on this page · raw message

drivers/core/Kconfig +9 -0
index 00d1d80dc38..1ca5d66141b 100644
@@ -277,4 +277,13 @@ config ACPIGEN
 	  things like generating device-specific tables and returning the ACPI
 	  name of a device.
 
+config INTEL_ACPIGEN
+	bool "Support ACPI table generation for Intel SoCs"
+	depends on ACPIGEN
+	help
+	  This option adds some functions used for programatic generation of
+	  ACPI tables on Intel SoCs. This provides features for writing CPU
+	  information such as P states and T stages. Also included is a way
+	  to create a GNVS table and set it up.
+
 endmenu
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#38 lore raw

PATCH v3 30/57 x86: Support Atom SoCs using SWSMISCI rather than the SWSCI

In reply to Simon Glass

Some Atom SoCs use SWSMISCI for SMI control. Add a Kconfig to select this. It is used on Apollo Lake.

---

(no changes since v1)

 arch/x86/Kconfig                | 6 ++++++
 arch/x86/cpu/apollolake/Kconfig | 1 +
 2 files changed, 7 insertions(+)
arch/x86/Kconfig +6 -0
index 495629d32ed..eddf2a774ef 100644
@@ -1017,4 +1017,10 @@ config INTEL_GENERIC_WIFI
 	  network functionality. It is only here to generate the ACPI tables
 	  required by Linux.
 
+config INTEL_GMA_SWSMISCI
+	bool
+	help
+	  Select this option for Atom-based platforms which use the SWSMISCI
+	  register (0xe0) rather than the SWSCI register (0xe8).
+
 endmenu
arch/x86/cpu/apollolake/Kconfig +1 -0
index 319f12684b7..35a425cd1bc 100644
@@ -17,6 +17,7 @@ config INTEL_APOLLOLAKE
 	select PCH_SUPPORT
 	select P2SB
 	select SMP_AP_WORK
+	select INTEL_GMA_SWSMISCI
 	select ACPI_GNVS_EXTERNAL
 	imply ENABLE_MRC_CACHE
 	imply AHCI_PCI
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#39 lore raw

PATCH v3 31/57 x86: acpi: Add support for additional Intel tables

In reply to Simon Glass

Apollo Lake needs to generate a few more table types used on Intel SoCs. Add support for these into the x86 ACPI code.

---

(no changes since v1)

Changes in v1:
- Move this code into an x86-specific file
- Update commit message
- Use OEM_TABLE_ID instead of ACPI_TABLE_CREATOR

 arch/x86/include/asm/acpi_table.h | 115 ++++++++++++++++++++++++++++++
 arch/x86/lib/acpi_table.c         | 111 ++++++++++++++++++++++++++++
 include/acpi/acpi_table.h         |  43 +++++++++++
 3 files changed, 269 insertions(+)
arch/x86/include/asm/acpi_table.h +115 -0
index 3245e447813..faf31730730 100644
@@ -98,4 +98,119 @@ int arch_write_sci_irq_select(uint scis);
  */
 int arch_madt_sci_irq_polarity(int sci);
 
+/**
+ * acpi_create_dmar_drhd() - Create a table for DMA remapping with the IOMMU
+ *
+ * See here for the specification
+ * https://software.intel.com/sites/default/files/managed/c5/15/vt-directed-io-spec.pdf
+ *
+ * @ctx: ACPI context pointer
+ * @flags: (DRHD_INCLUDE_...)
+ * @segment: PCI segment asscociated with this unit
+ * @bar: Base address of remapping hardware register-set for this unit
+ */
+void acpi_create_dmar_drhd(struct acpi_ctx *ctx, uint flags, uint segment,
+			   u64 bar);
+
+/**
+ * acpi_create_dmar_rmrr() - Set up an RMRR
+ *
+ * This sets up a Reserved-Memory Region Reporting structure, used to allow
+ * DMA to regions used by devices that the BIOS controls.
+ *
+ * @ctx: ACPI context pointer
+ * @segment: PCI segment asscociated with this unit
+ * @bar: Base address of mapping
+ * @limit: End address of mapping
+ */
+void acpi_create_dmar_rmrr(struct acpi_ctx *ctx, uint segment, u64 bar,
+			   u64 limit);
+
+/**
+ * acpi_dmar_drhd_fixup() - Set the length of an DRHD
+ *
+ * This sets the DRHD length field based on the current ctx->current
+ *
+ * @ctx: ACPI context pointer
+ * @base: Address of the start of the DRHD
+ */
+void acpi_dmar_drhd_fixup(struct acpi_ctx *ctx, void *base);
+
+/**
+ * acpi_dmar_rmrr_fixup() - Set the length of an RMRR
+ *
+ * This sets the RMRR length field based on the current ctx->current
+ *
+ * @ctx: ACPI context pointer
+ * @base: Address of the start of the RMRR
+ */
+void acpi_dmar_rmrr_fixup(struct acpi_ctx *ctx, void *base);
+
+/**
+ * acpi_create_dmar_ds_pci() - Set up a DMAR scope for a PCI device
+ *
+ * @ctx: ACPI context pointer
+ * @bdf: PCI device to add
+ * @return length of mapping in bytes
+ */
+int acpi_create_dmar_ds_pci(struct acpi_ctx *ctx, pci_dev_t bdf);
+
+/**
+ * acpi_create_dmar_ds_pci_br() - Set up a DMAR scope for a PCI bridge
+ *
+ * This is used to provide a mapping for a PCI bridge
+ *
+ * @ctx: ACPI context pointer
+ * @bdf: PCI device to add
+ * @return length of mapping in bytes
+ */
+int acpi_create_dmar_ds_pci_br(struct acpi_ctx *ctx, pci_dev_t bdf);
+
+/**
+ * acpi_create_dmar_ds_ioapic() - Set up a DMAR scope for an IOAPIC device
+ *
+ * @ctx: ACPI context pointer
+ * @enumeration_id: Enumeration ID (typically 2)
+ * @bdf: PCI device to add
+ * @return length of mapping in bytes
+ */
+int acpi_create_dmar_ds_ioapic(struct acpi_ctx *ctx, uint enumeration_id,
+			       pci_dev_t bdf);
+
+/**
+ * acpi_create_dmar_ds_msi_hpet() - Set up a DMAR scope for an HPET
+ *
+ * Sets up a scope for a High-Precision Event Timer that supports
+ * Message-Signalled Interrupts
+ *
+ * @ctx: ACPI context pointer
+ * @enumeration_id: Enumeration ID (typically 0)
+ * @bdf: PCI device to add
+ * @return length of mapping in bytes
+ */
+int acpi_create_dmar_ds_msi_hpet(struct acpi_ctx *ctx, uint enumeration_id,
+				 pci_dev_t bdf);
+
+/**
+ * acpi_fadt_common() - Handle common parts of filling out an FADT
+ *
+ * This sets up the Fixed ACPI Description Table
+ *
+ * @fadt: Pointer to place to put FADT
+ * @facs: Pointer to the FACS
+ * @dsdt: Pointer to the DSDT
+ */
+void acpi_fadt_common(struct acpi_fadt *fadt, struct acpi_facs *facs,
+		      void *dsdt);
+
+/**
+ * intel_acpi_fill_fadt() - Set up the contents of the FADT
+ *
+ * This sets up parts of the Fixed ACPI Description Table that are common to
+ * Intel chips
+ *
+ * @fadt: Pointer to place to put FADT
+ */
+void intel_acpi_fill_fadt(struct acpi_fadt *fadt);
+
 #endif /* __ASM_ACPI_TABLE_H__ */
arch/x86/lib/acpi_table.c +111 -0

114 lines not on this page · raw message

include/acpi/acpi_table.h +43 -0

49 lines not on this page · raw message

Signature · 1 line
2.28.0.526.ge36021eeef-goog
#40 lore raw

PATCH v3 32/57 x86: apl: Allow reading hostbridge base addresses

In reply to Simon Glass

Add a few functions to permit reading of various useful base addresses provided by the hostbridge.

---

(no changes since v1)

Changes in v1:
- Add comments

 arch/x86/cpu/apollolake/hostbridge.c          | 27 ++++++++++++++++
 .../include/asm/arch-apollolake/systemagent.h | 31 +++++++++++++++++++
 2 files changed, 58 insertions(+)
arch/x86/cpu/apollolake/hostbridge.c +27 -0
index cb46ec6c0bb..056f7e57a9a 100644
@@ -40,7 +40,9 @@ enum {
 
 	PCIEXBAR_PCIEXBAREN	= 1 << 0,
 
+	BGSM			= 0xb4,  /* Base GTT Stolen Memory */
 	TSEG			= 0xb8,  /* TSEG base */
+	TOLUD			= 0xbc,
 };
 
 static int apl_hostbridge_early_init_pinctrl(struct udevice *dev)
@@ -165,6 +167,31 @@ static int apl_hostbridge_probe(struct udevice *dev)
 	return 0;
 }
 
+static ulong sa_read_reg(struct udevice *dev, int reg)
+{
+	u32 val;
+
+	/* All regions concerned for have 1 MiB alignment */
+	dm_pci_read_config32(dev, BGSM, &val);
+
+	return ALIGN_DOWN(val, 1 << 20);
+}
+
+ulong sa_get_tolud_base(struct udevice *dev)
+{
+	return sa_read_reg(dev, TOLUD);
+}
+
+ulong sa_get_gsm_base(struct udevice *dev)
+{
+	return sa_read_reg(dev, BGSM);
+}
+
+ulong sa_get_tseg_base(struct udevice *dev)
+{
+	return sa_read_reg(dev, TSEG);
+}
+
 static const struct udevice_id apl_hostbridge_ids[] = {
 	{ .compatible = "intel,apl-hostbridge" },
 	{ }
arch/x86/include/asm/arch-apollolake/systemagent.h +31 -0
index 9e7bd62751a..788a63d7999 100644
@@ -35,4 +35,35 @@
  */
 void enable_bios_reset_cpl(void);
 
+/**
+ * sa_get_tolud_base() - Get the TOLUD base address
+ *
+ * This returns the Top Of Low Useable DRAM, marking the top of usable DRAM
+ * below 4GB
+ *
+ * @dev: hostbridge device
+ * @return TOLUD address
+ */
+ulong sa_get_tolud_base(struct udevice *dev);
+
+/**
+ * sa_get_gsm_base() - Get the GSM base address
+ *
+ * This returns the base of GTT Stolen Memory, marking the start of memory used
+ * for Graphics Translation Tables.
+ *
+ * @dev: hostbridge device
+ * @return GSM address
+ */
+ulong sa_get_gsm_base(struct udevice *dev);
+
+/**
+ * sa_get_tseg_base() - Get the TSEG base address
+ *
+ * This returns the top address of DRAM available below 4GB
+ *
+ * @return TSEG base
+ */
+ulong sa_get_tseg_base(struct udevice *dev);
+
 #endif
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#41 lore raw

PATCH v3 33/57 p2sb: Add some definitions used for ACPI

In reply to Simon Glass

Allow this header to be included in ASL files by adding a header guard and a few definitions that are needed.

---

(no changes since v1)

 include/p2sb.h | 8 ++++++++
 1 file changed, 8 insertions(+)
include/p2sb.h +8 -0
index 93e1155dca6..a25170e3d11 100644
@@ -10,6 +10,12 @@
 /* Port Id lives in bits 23:16 and register offset lives in 15:0 of address */
 #define PCR_PORTID_SHIFT	16
 
+#if !defined(__ACPI__)
+
+/* These registers contain IOAPIC and HPET devfn */
+#define PCH_P2SB_IBDF		0x6c
+#define PCH_P2SB_HBDF		0x70
+
 /**
  * struct p2sb_child_platdata - Information about each child of a p2sb device
  *
@@ -164,4 +170,6 @@ int p2sb_get_port_id(struct udevice *dev);
  */
 void *pcr_reg_address(struct udevice *dev, uint offset);
 
+#endif /* !__ACPI__ */
+
 #endif
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#42 lore raw

PATCH v3 34/57 x86: apl: Generate required ACPI tables

In reply to Simon Glass

Add support for generating various ACPI tables for Apollo Lake. Add a few S3 definitions that are needed.

---

(no changes since v1)

Changes in v1:
- Drop unnecessary callbacks

 arch/x86/cpu/apollolake/Makefile            |   1 +
 arch/x86/cpu/apollolake/acpi.c              | 211 ++++++++++++++++++++
 arch/x86/include/asm/arch-apollolake/acpi.h |  18 ++
 include/acpi/acpi_s3.h                      |   4 +
 4 files changed, 234 insertions(+)
 create mode 100644 arch/x86/cpu/apollolake/acpi.c
 create mode 100644 arch/x86/include/asm/arch-apollolake/acpi.h
arch/x86/cpu/apollolake/Makefile +1 -0
index 3aa2a556765..2ddf4af62c5 100644
@@ -16,6 +16,7 @@ obj-y += fsp_m.o
 endif
 endif
 ifndef CONFIG_SPL_BUILD
+obj-y += acpi.o
 obj-y += fsp_s.o
 endif
 
arch/x86/cpu/apollolake/acpi.c new file +211 -0

211 lines not on this page · raw message

arch/x86/include/asm/arch-apollolake/acpi.h new file +18 -0
new file mode 100644
index 00000000000..ed852feee03
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright 2019 Google LLC
+ */
+
+#ifndef _ASM_ARCH_ACPI_H
+#define _ASM_ARCH_ACPI_H
+
+struct acpi_ctx;
+
+/**
+ * apl_acpi_fill_dmar() - Set up the DMAR for APL
+ *
+ * @ctx: ACPI context pointer
+ */
+int apl_acpi_fill_dmar(struct acpi_ctx *ctx);
+
+#endif /* _ASM_ARCH_CPU_H */
include/acpi/acpi_s3.h +4 -0
index baa848dcd15..847139baa0c 100644
@@ -28,6 +28,10 @@
 #define SLP_TYP_S4	6
 #define SLP_TYP_S5	7
 
+/* PM1_STS register */
+#define RTC_EN		BIT(10)
+#define PWRBTN_EN	BIT(8)
+
 /* Memory size reserved for S3 resume */
 #define S3_RESERVE_SIZE	0x1000
 
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#43 lore raw

PATCH v3 35/57 x86: apl: Add support for hostbridge ACPI generation

In reply to Simon Glass

Support generating a DMAR table and add a few helper routines as well. Also set up NHLT so that audio works.

---

(no changes since v1)

Changes in v1:
- Add support for NHLT table
- Capitalise ACPI_OPS_PTR
- Move the acpi.h header file to this commit
- Update commit message

 arch/x86/cpu/apollolake/hostbridge.c | 221 +++++++++++++++++++++++++--
 1 file changed, 212 insertions(+), 9 deletions(-)
arch/x86/cpu/apollolake/hostbridge.c +212 -9
index 056f7e57a9a..cf60fd8b021 100644
@@ -1,17 +1,45 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright 2019 Google LLC
+ * Copyright (C) 2015 - 2017 Intel Corp.
+ * Copyright (C) 2017 - 2019 Siemens AG
+ * (Written by Alexandru Gagniuc <[email protected]> for Intel Corp.)
+ * (Written by Andrey Petrov <[email protected]> for Intel Corp.)
+ *
+ * Portions from coreboot soc/intel/apollolake/chip.c
  */
 
+#define LOG_CATEGORY UCLASS_NORTHBRIDGE
+
 #include <common.h>
 #include <dm.h>
 #include <dt-structs.h>
 #include <log.h>
 #include <spl.h>
+#include <tables_csum.h>
+#include <acpi/acpi_table.h>
+#include <asm/acpi_nhlt.h>
 #include <asm/intel_pinctrl.h>
 #include <asm/intel_regs.h>
+#include <asm/io.h>
 #include <asm/pci.h>
+#include <asm/arch/acpi.h>
 #include <asm/arch/systemagent.h>
+#include <dt-bindings/sound/nhlt.h>
+#include <dm/acpi.h>
+
+enum {
+	PCIEXBAR		= 0x60,
+	PCIEXBAR_LENGTH_256MB	= 0,
+	PCIEXBAR_LENGTH_128MB,
+	PCIEXBAR_LENGTH_64MB,
+
+	PCIEXBAR_PCIEXBAREN	= 1 << 0,
+
+	BGSM			= 0xb4,  /* Base GTT Stolen Memory */
+	TSEG			= 0xb8,  /* TSEG base */
+	TOLUD			= 0xbc,
+};
 
 /**
  * struct apl_hostbridge_platdata - platform data for hostbridge
@@ -32,17 +60,100 @@ struct apl_hostbridge_platdata {
 	pci_dev_t bdf;
 };
 
-enum {
-	PCIEXBAR		= 0x60,
-	PCIEXBAR_LENGTH_256MB	= 0,
-	PCIEXBAR_LENGTH_128MB,
-	PCIEXBAR_LENGTH_64MB,
+static const struct nhlt_format_config dmic_1ch_formats[] = {
+	/* 48 KHz 16-bits per sample. */
+	{
+		.num_channels = 1,
+		.sample_freq_khz = 48,
+		.container_bits_per_sample = 16,
+		.valid_bits_per_sample = 16,
+		.settings_file = "dmic-1ch-48khz-16b.dat",
+	},
+};
 
-	PCIEXBAR_PCIEXBAREN	= 1 << 0,
+static const struct nhlt_dmic_array_config dmic_1ch_mic_config = {
+	.tdm_config = {
+		.config_type = NHLT_TDM_MIC_ARRAY,
+	},
+	.array_type = NHLT_MIC_ARRAY_VENDOR_DEFINED,
+};
 
-	BGSM			= 0xb4,  /* Base GTT Stolen Memory */
-	TSEG			= 0xb8,  /* TSEG base */
-	TOLUD			= 0xbc,
+static const struct nhlt_endp_descriptor dmic_1ch_descriptors[] = {
+	{
+		.link = NHLT_LINK_PDM,
+		.device = NHLT_PDM_DEV,
+		.direction = NHLT_DIR_CAPTURE,
+		.vid = NHLT_VID,
+		.did = NHLT_DID_DMIC,
+		.cfg = &dmic_1ch_mic_config,
+		.cfg_size = sizeof(dmic_1ch_mic_config),
+		.formats = dmic_1ch_formats,
+		.num_formats = ARRAY_SIZE(dmic_1ch_formats),
+	},
+};
+
+static const struct nhlt_format_config dmic_2ch_formats[] = {
+	/* 48 KHz 16-bits per sample. */
+	{
+		.num_channels = 2,
+		.sample_freq_khz = 48,
+		.container_bits_per_sample = 16,
+		.valid_bits_per_sample = 16,
+		.settings_file = "dmic-2ch-48khz-16b.dat",
+	},
+};
+
+static const struct nhlt_dmic_array_config dmic_2ch_mic_config = {
+	.tdm_config = {
+		.config_type = NHLT_TDM_MIC_ARRAY,
+	},
+	.array_type = NHLT_MIC_ARRAY_2CH_SMALL,
+};
+
+static const struct nhlt_endp_descriptor dmic_2ch_descriptors[] = {
+	{
+		.link = NHLT_LINK_PDM,
+		.device = NHLT_PDM_DEV,
+		.direction = NHLT_DIR_CAPTURE,
+		.vid = NHLT_VID,
+		.did = NHLT_DID_DMIC,
+		.cfg = &dmic_2ch_mic_config,
+		.cfg_size = sizeof(dmic_2ch_mic_config),
+		.formats = dmic_2ch_formats,
+		.num_formats = ARRAY_SIZE(dmic_2ch_formats),
+	},
+};
+
+static const struct nhlt_format_config dmic_4ch_formats[] = {
+	/* 48 KHz 16-bits per sample. */
+	{
+		.num_channels = 4,
+		.sample_freq_khz = 48,
+		.container_bits_per_sample = 16,
+		.valid_bits_per_sample = 16,
+		.settings_file = "dmic-4ch-48khz-16b.dat",
+	},
+};
+
+static const struct nhlt_dmic_array_config dmic_4ch_mic_config = {
+	.tdm_config = {
+		.config_type = NHLT_TDM_MIC_ARRAY,
+	},
+	.array_type = NHLT_MIC_ARRAY_4CH_L_SHAPED,
+};
+
+static const struct nhlt_endp_descriptor dmic_4ch_descriptors[] = {
+	{
+		.link = NHLT_LINK_PDM,
+		.device = NHLT_PDM_DEV,
+		.direction = NHLT_DIR_CAPTURE,
+		.vid = NHLT_VID,
+		.did = NHLT_DID_DMIC,
+		.cfg = &dmic_4ch_mic_config,
+		.cfg_size = sizeof(dmic_4ch_mic_config),
+		.formats = dmic_4ch_formats,
+		.num_formats = ARRAY_SIZE(dmic_4ch_formats),
+	},
 };
 
 static int apl_hostbridge_early_init_pinctrl(struct udevice *dev)
@@ -167,6 +278,87 @@ static int apl_hostbridge_probe(struct udevice *dev)
 	return 0;
 }
 
+static int apl_acpi_hb_get_name(const struct udevice *dev, char *out_name)
+{
+	return acpi_copy_name(out_name, "RHUB");
+}
+
+#ifdef CONFIG_GENERATE_ACPI_TABLE
+static int apl_acpi_hb_write_tables(const struct udevice *dev,
+				    struct acpi_ctx *ctx)
+{
+	struct acpi_table_header *header;
+	struct acpi_dmar *dmar;
+	u32 val;
+
+	/*
+	 * Create DMAR table only if virtualization is enabled. Due to some
+	 * constraints on Apollo Lake SoC (some stepping affected), VTD could
+	 * not be enabled together with IPU. Doing so will override and disable
+	 * VTD while leaving CAPID0_A still reporting that VTD is available.
+	 * As in this case FSP will lock VTD to disabled state, we need to make
+	 * sure that DMAR table generation only happens when@least DEFVTBAR
+	 * is enabled. Otherwise the DMAR header will be generated while the
+	 * content of the table will be missing.
+	 */
+	dm_pci_read_config32(dev, CAPID0_A, &val);
+	if ((val & VTD_DISABLE) ||
+	    !(readl(MCHBAR_REG(DEFVTBAR)) & VTBAR_ENABLED))
+		return 0;
+
+	log_debug("ACPI:    * DMAR\n");
+	dmar = (struct acpi_dmar *)ctx->current;
+	header = &dmar->header;
+	acpi_create_dmar(dmar, DMAR_INTR_REMAP);
+	ctx->current += sizeof(struct acpi_dmar);
+	apl_acpi_fill_dmar(ctx);
+
+	/* (Re)calculate length and checksum */
+	header->length = ctx->current - (void *)dmar;
+	header->checksum = table_compute_checksum((void *)dmar, header->length);
+
+	acpi_align(ctx);
+	acpi_add_table(ctx, dmar);
+	acpi_align(ctx);
+
+	return 0;
+}
+#endif
+
+static int apl_acpi_setup_nhlt(const struct udevice *dev, struct acpi_ctx *ctx)
+{
+	struct nhlt *nhlt = ctx->nhlt;
+	u32 channels;
+	ofnode node;
+
+	node = ofnode_find_subnode(dev_ofnode(dev), "nhlt");
+	if (ofnode_read_u32(node, "intel,dmic-channels", &channels))
+		return log_msg_ret("channels", -EINVAL);
+	switch (channels) {
+	case 1:
+		return nhlt_add_endpoints(nhlt, dmic_1ch_descriptors,
+					  ARRAY_SIZE(dmic_1ch_descriptors));
+	case 2:
+		return nhlt_add_endpoints(nhlt, dmic_2ch_descriptors,
+					  ARRAY_SIZE(dmic_2ch_descriptors));
+	case 4:
+		return nhlt_add_endpoints(nhlt, dmic_4ch_descriptors,
+					  ARRAY_SIZE(dmic_4ch_descriptors));
+	}
+
+	return log_msg_ret("channels", -EINVAL);
+}
+
+static int apl_hostbridge_remove(struct udevice *dev)
+{
+	/*
+	 * TODO(sjg at chromium.org): Consider adding code from coreboot's
+	 * platform_fsp_notify_status()
+	 */
+
+	return 0;
+}
+
 static ulong sa_read_reg(struct udevice *dev, int reg)
 {
 	u32 val;
@@ -192,6 +384,14 @@ ulong sa_get_tseg_base(struct udevice *dev)
 	return sa_read_reg(dev, TSEG);
 }
 
+struct acpi_ops apl_hostbridge_acpi_ops = {
+	.get_name	= apl_acpi_hb_get_name,
+#ifdef CONFIG_GENERATE_ACPI_TABLE
+	.write_tables	= apl_acpi_hb_write_tables,
+#endif
+	.setup_nhlt	= apl_acpi_setup_nhlt,
+};
+
 static const struct udevice_id apl_hostbridge_ids[] = {
 	{ .compatible = "intel,apl-hostbridge" },
 	{ }
@@ -203,5 +403,8 @@ U_BOOT_DRIVER(apl_hostbridge_drv) = {
 	.of_match	= apl_hostbridge_ids,
 	.ofdata_to_platdata = apl_hostbridge_ofdata_to_platdata,
 	.probe		= apl_hostbridge_probe,
+	.remove		= apl_hostbridge_remove,
 	.platdata_auto_alloc_size = sizeof(struct apl_hostbridge_platdata),
+	ACPI_OPS_PTR(&apl_hostbridge_acpi_ops)
+	.flags		= DM_FLAG_OS_PREPARE,
 };
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#44 lore raw

PATCH v3 36/57 x86: apl: Generate CPU tables

In reply to Simon Glass

Add ACPI generation to the APL CPU driver.

---

(no changes since v1)

Changes in v1:
- Capitalise ACPI_OPS_PTR
- Handle table generation without callbacks

 arch/x86/cpu/apollolake/cpu.c      | 77 ++++++++++++++++++++++++++++++
 arch/x86/lib/Makefile              |  3 +-
 configs/chromebook_coral_defconfig |  1 +
 3 files changed, 80 insertions(+), 1 deletion(-)
arch/x86/cpu/apollolake/cpu.c +77 -0
index 0a6d2ad7a4a..8da2e64e226 100644
@@ -6,14 +6,90 @@
 #include <common.h>
 #include <cpu.h>
 #include <dm.h>
+#include <log.h>
+#include <acpi/acpigen.h>
+#include <acpi/acpi_table.h>
 #include <asm/cpu_common.h>
 #include <asm/cpu_x86.h>
+#include <asm/intel_acpi.h>
+#include <asm/msr.h>
+#include <dm/acpi.h>
+
+#define CSTATE_RES(address_space, width, offset, address)		\
+	{								\
+	.space_id = address_space,					\
+	.bit_width = width,						\
+	.bit_offset = offset,						\
+	.addrl = address,						\
+	}
+
+static struct acpi_cstate cstate_map[] = {
+	{
+		/* C1 */
+		.ctype = 1,		/* ACPI C1 */
+		.latency = 1,
+		.power = 1000,
+		.resource = {
+			.space_id = ACPI_ADDRESS_SPACE_FIXED,
+		},
+	}, {
+		.ctype = 2,		/* ACPI C2 */
+		.latency = 50,
+		.power = 10,
+		.resource = {
+			.space_id = ACPI_ADDRESS_SPACE_IO,
+			.bit_width = 8,
+			.addrl = 0x415,
+		},
+	}, {
+		.ctype = 3,		/* ACPI C3 */
+		.latency = 150,
+		.power = 10,
+		.resource = {
+			.space_id = ACPI_ADDRESS_SPACE_IO,
+			.bit_width = 8,
+			.addrl = 0x419,
+		},
+	},
+};
 
 static int apl_get_info(const struct udevice *dev, struct cpu_info *info)
 {
 	return cpu_intel_get_info(info, INTEL_BCLK_MHZ);
 }
 
+static int acpi_cpu_fill_ssdt(const struct udevice *dev, struct acpi_ctx *ctx)
+{
+	uint core_id = dev->req_seq;
+	int cores_per_package;
+	int ret;
+
+	cores_per_package = cpu_get_cores_per_package();
+	ret = acpi_generate_cpu_header(ctx, core_id, cstate_map,
+				       ARRAY_SIZE(cstate_map));
+
+	/* Generate P-state tables */
+	generate_p_state_entries(ctx, core_id, cores_per_package);
+
+	/* Generate T-state tables */
+	generate_t_state_entries(ctx, core_id, cores_per_package, NULL, 0);
+
+	acpigen_pop_len(ctx);
+
+	if (device_is_last_sibling(dev)) {
+		ret = acpi_generate_cpu_package_final(ctx, cores_per_package);
+
+		if (ret)
+			return ret;
+	}
+
+	return 0;
+}
+
+struct acpi_ops apl_cpu_acpi_ops = {
+	.fill_ssdt	= acpi_cpu_fill_ssdt,
+};
+
 static const struct cpu_ops cpu_x86_apl_ops = {
 	.get_desc	= cpu_x86_get_desc,
 	.get_info	= apl_get_info,
@@ -32,5 +108,6 @@ U_BOOT_DRIVER(cpu_x86_apl_drv) = {
 	.of_match	= cpu_x86_apl_ids,
 	.bind		= cpu_x86_bind,
 	.ops		= &cpu_x86_apl_ops,
+	ACPI_OPS_PTR(&apl_cpu_acpi_ops)
 	.flags		= DM_FLAG_PRE_RELOC,
 };
arch/x86/lib/Makefile +2 -1
index f04d275dd9a..1bcbb49a61f 100644
@@ -38,7 +38,8 @@ obj-y += sfi.o
 obj-y	+= acpi.o
 obj-$(CONFIG_HAVE_ACPI_RESUME) += acpi_s3.o
 ifndef CONFIG_QEMU
-obj-$(CONFIG_GENERATE_ACPI_TABLE) += acpi_table.o acpigen.o
+obj-y += acpigen.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += acpi_table.o
 endif
 obj-y	+= tables.o
 ifndef CONFIG_SPL_BUILD
configs/chromebook_coral_defconfig +1 -0
index c9006e2f934..ef4dabbe26e 100644
@@ -72,6 +72,7 @@ CONFIG_ENV_OVERWRITE=y
 CONFIG_REGMAP=y
 CONFIG_SYSCON=y
 CONFIG_SPL_OF_TRANSLATE=y
+CONFIG_INTEL_ACPIGEN=y
 CONFIG_CPU=y
 CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_DW=y
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#45 lore raw

PATCH v3 37/57 x86: apl: Generate ACPI table for LPC

In reply to Simon Glass

Add an ACPI table for the LPC on Apollo Lake.

---

(no changes since v1)

Changes in v1:
- Capitalise ACPI_OPS_PTR

 arch/x86/cpu/apollolake/lpc.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
arch/x86/cpu/apollolake/lpc.c +18 -0
index b81a458f2eb..a29832c879a 100644
@@ -9,10 +9,14 @@
 #include <dm.h>
 #include <log.h>
 #include <spl.h>
+#include <acpi/acpi_table.h>
+#include <asm/cpu_common.h>
+#include <asm/intel_acpi.h>
 #include <asm/lpc_common.h>
 #include <asm/pci.h>
 #include <asm/arch/iomap.h>
 #include <asm/arch/lpc.h>
+#include <dm/acpi.h>
 #include <linux/log2.h>
 
 void lpc_enable_fixed_io_ranges(uint io_enables)
@@ -110,6 +114,19 @@ void lpc_io_setup_comm_a_b(void)
 	lpc_enable_fixed_io_ranges(com_enable);
 }
 
+static int apl_acpi_lpc_get_name(const struct udevice *dev, char *out_name)
+{
+	return acpi_copy_name(out_name, "LPCB");
+}
+
+struct acpi_ops apl_lpc_acpi_ops = {
+	.get_name	= apl_acpi_lpc_get_name,
+#ifdef CONFIG_GENERATE_ACPI_TABLE
+	.write_tables	= intel_southbridge_write_acpi_tables,
+#endif
+	.inject_dsdt	= southbridge_inject_dsdt,
+};
+
 static const struct udevice_id apl_lpc_ids[] = {
 	{ .compatible = "intel,apl-lpc" },
 	{ }
@@ -120,4 +137,5 @@ U_BOOT_DRIVER(apl_lpc_drv) = {
 	.name		= "intel_apl_lpc",
 	.id		= UCLASS_LPC,
 	.of_match	= apl_lpc_ids,
+	ACPI_OPS_PTR(&apl_lpc_acpi_ops)
 };
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#46 lore raw

PATCH v3 38/57 x86: apl: Drop unnecessary code in PMC driver

In reply to Simon Glass

We don't have CONFIG_PCI in TPL but it is present in SPL, etc. So this code is not needed. Drop it, and fix a code-style nit just above.

---

(no changes since v1)

 arch/x86/cpu/apollolake/pmc.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
arch/x86/cpu/apollolake/pmc.c +2 -6
index 192dec7109a..576d0187570 100644
@@ -118,7 +118,8 @@ int apl_pmc_ofdata_to_uc_platdata(struct udevice *dev)
 	int size;
 	int ret;
 
-	ret = dev_read_u32_array(dev, "early-regs", base, ARRAY_SIZE(base));
+	ret = dev_read_u32_array(dev, "early-regs", base,
+				 ARRAY_SIZE(base));
 	if (ret)
 		return log_msg_ret("Missing/short early-regs", ret);
 	if (spl_phase() == PHASE_TPL) {
@@ -133,11 +134,6 @@ int apl_pmc_ofdata_to_uc_platdata(struct udevice *dev)
 	}
 	upriv->acpi_base = base[4];
 
-	/* Since PCI is not enabled, we must get the BDF manually */
-	plat->bdf = pci_get_devfn(dev);
-	if (plat->bdf < 0)
-		return log_msg_ret("Cannot get PMC PCI address", plat->bdf);
-
 	/* Get the dwX values for pmc gpe settings */
 	size = dev_read_size(dev, "gpe0-dw");
 	if (size < 0)
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#47 lore raw

PATCH v3 39/57 tpm: cr50: Add ACPI support

In reply to Simon Glass

Generate ACPI information for this device so that Linux can use it correctly.

---

(no changes since v1)

Changes in v1:
- Capitalise ACPI_OPS_PTR
- Update for acpi_device_write_i2c_dev() return-value change
- Use acpi,ddn instead of acpi,desc

 drivers/tpm/cr50_i2c.c | 55 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
drivers/tpm/cr50_i2c.c +55 -0
index 1942c07c605..64831a42232 100644
@@ -14,11 +14,14 @@
 #include <log.h>
 #include <spl.h>
 #include <tpm-v2.h>
+#include <acpi/acpigen.h>
+#include <acpi/acpi_device.h>
 #include <asm/gpio.h>
 #include <asm/io.h>
 #include <asm/arch/iomap.h>
 #include <asm/arch/pm.h>
 #include <linux/delay.h>
+#include <dm/acpi.h>
 
 enum {
 	TIMEOUT_INIT_MS		= 30000, /* Very long timeout for TPM init */
@@ -581,6 +584,53 @@ static int cr50_i2c_cleanup(struct udevice *dev)
 	return 0;
 }
 
+static int cr50_acpi_fill_ssdt(const struct udevice *dev, struct acpi_ctx *ctx)
+{
+	char scope[ACPI_PATH_MAX];
+	char name[ACPI_NAME_MAX];
+	const char *hid;
+	int ret;
+
+	ret = acpi_device_scope(dev, scope, sizeof(scope));
+	if (ret)
+		return log_msg_ret("scope", ret);
+	ret = acpi_get_name(dev, name);
+	if (ret)
+		return log_msg_ret("name", ret);
+
+	hid = dev_read_string(dev, "acpi,hid");
+	if (!hid)
+		return log_msg_ret("hid", ret);
+
+	/* Device */
+	acpigen_write_scope(ctx, scope);
+	acpigen_write_device(ctx, name);
+	acpigen_write_name_string(ctx, "_HID", hid);
+	acpigen_write_name_integer(ctx, "_UID",
+				   dev_read_u32_default(dev, "acpi,uid", 0));
+	acpigen_write_name_string(ctx, "_DDN",
+				  dev_read_string(dev, "acpi,ddn"));
+	acpigen_write_sta(ctx, acpi_device_status(dev));
+
+	/* Resources */
+	acpigen_write_name(ctx, "_CRS");
+	acpigen_write_resourcetemplate_header(ctx);
+	ret = acpi_device_write_i2c_dev(ctx, dev);
+	if (ret < 0)
+		return log_msg_ret("i2c", ret);
+	ret = acpi_device_write_interrupt_or_gpio(ctx, (struct udevice *)dev,
+						  "ready-gpios");
+	if (ret < 0)
+		return log_msg_ret("irq_gpio", ret);
+
+	acpigen_write_resourcetemplate_footer(ctx);
+
+	acpigen_pop_len(ctx); /* Device */
+	acpigen_pop_len(ctx); /* Scope */
+
+	return 0;
+}
+
 enum {
 	TPM_TIMEOUT_MS		= 5,
 	SHORT_TIMEOUT_MS	= 750,
@@ -653,6 +703,10 @@ static int cr50_i2c_probe(struct udevice *dev)
 	return 0;
 }
 
+struct acpi_ops cr50_acpi_ops = {
+	.fill_ssdt	= cr50_acpi_fill_ssdt,
+};
+
 static const struct tpm_ops cr50_i2c_ops = {
 	.open		= cr50_i2c_open,
 	.get_desc	= cr50_i2c_get_desc,
@@ -675,5 +729,6 @@ U_BOOT_DRIVER(cr50_i2c) = {
 	.probe	= cr50_i2c_probe,
 	.remove	= cr50_i2c_cleanup,
 	.priv_auto_alloc_size = sizeof(struct cr50_priv),
+	ACPI_OPS_PTR(&cr50_acpi_ops)
 	.flags		= DM_FLAG_OS_PREPARE,
 };
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#48 lore raw

PATCH v3 39/57 tpm: cr50: Add ACPI support

drivers/tpm/cr50_i2c.c static int cr50_i2c_cleanup(struct udevice *dev) · line 624

Quoted 7 lines · Simon Glass

Generate ACPI information for this device so that Linux can use it correctly.

drivers/tpm/cr50_i2c.c +4 -0
+	ret = acpi_device_write_interrupt_or_gpio(ctx, (struct udevice *)dev,
+						  "ready-gpios");
+	if (ret < 0)
+		return log_msg_ret("irq_gpio", ret);

I looked a bit closer at the acpi_table.c and would like to emphasize on lessons learn from BIOS mistakes found in the wild with GPIOs.

Because GPIO resources are quite badly described in ACPI (it seems MS failed to deliver GPIO abstraction to ACPI and to Windows API), there are some corner cases, in order to mitigate which we need to consider the following to avoid potential glitches and misconfiguration:

- GpioIo() doesn't have any means of Active Low / High setting, the _DSD must be provided to mitigate this.

- GpioIo() doesn't properly communicate the initial state of the output pin, thus Linux assumes the simple rule:

Pull Bias Polarity Requested...

Implicit x AS IS (assumed firmware configured for us)
Explicit x (no _DSD) as Pull Bias (Up == High, Down == Low),
assuming non-active (Polarity = !Pull Bias)

Down Low as low, assuming active
Down High as high, assuming non-active
Up Low as low, assuming non-active
Up High as high, assuming active

Hopefully this helps (and maybe can be added to some documentation).

P.S. Why I2cSerialBus() and not I2cSerialBusV2() ?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#49 lore raw

PATCH v3 39/57 tpm: cr50: Add ACPI support

Quoted 29 lines · Andy Shevchenko

drivers/tpm/cr50_i2c.c static int cr50_i2c_cleanup(struct udevice *dev) · line 624

Quoted 7 lines · Simon Glass

Generate ACPI information for this device so that Linux can use it correctly.

drivers/tpm/cr50_i2c.c +4 -0
+	ret = acpi_device_write_interrupt_or_gpio(ctx, (struct udevice *)dev,
+						  "ready-gpios");
+	if (ret < 0)
+		return log_msg_ret("irq_gpio", ret);

I looked a bit closer at the acpi_table.c and would like to emphasize on lessons learn from BIOS mistakes found in the wild with GPIOs.

Because GPIO resources are quite badly described in ACPI (it seems MS failed to deliver GPIO abstraction to ACPI and to Windows API), there are some corner cases, in order to mitigate which we need to consider the following to avoid potential glitches and misconfiguration:

- GpioIo() doesn't have any means of Active Low / High setting, the _DSD must be provided to mitigate this.

- GpioIo() doesn't properly communicate the initial state of the output pin, thus Linux assumes the simple rule:

Pull Bias Polarity Requested...

Implicit x AS IS (assumed firmware configured for us)
Explicit x (no _DSD) as Pull Bias (Up == High, Down == Low),
assuming non-active (Polarity = !Pull Bias)

Quoted 8 lines

Down Low as low, assuming active
Down High as high, assuming non-active
Up Low as low, assuming non-active
Up High as high, assuming active

Hopefully this helps (and maybe can be added to some documentation).

P.S. Why I2cSerialBus() and not I2cSerialBusV2() ?

Forgot one important aspect.

GpioIo() can be used as interrupt and in this case the IoRestriction mustn't be OutputOnly. It also requires active_low flag from _DSD in cases where it's needed (better to always provide than rely on above assumption made on OS level).

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#50 lore raw

PATCH v3 39/57 tpm: cr50: Add ACPI support

In reply to Andy Shevchenko

Hi Simon,

Quoted 30 lines · Andy Shevchenko

drivers/tpm/cr50_i2c.c static int cr50_i2c_cleanup(struct udevice *dev) · line 624

Quoted 7 lines · Simon Glass

Generate ACPI information for this device so that Linux can use it correctly.

drivers/tpm/cr50_i2c.c +4 -0
+     ret = acpi_device_write_interrupt_or_gpio(ctx, (struct udevice *)dev,
+                                               "ready-gpios");
+     if (ret < 0)
+             return log_msg_ret("irq_gpio", ret);

I looked a bit closer at the acpi_table.c and would like to emphasize on lessons learn from BIOS mistakes found in the wild with GPIOs.

Because GPIO resources are quite badly described in ACPI (it seems MS failed to deliver GPIO abstraction to ACPI and to Windows API), there are some corner cases, in order to mitigate which we need to consider the following to avoid potential glitches and misconfiguration:

- GpioIo() doesn't have any means of Active Low / High setting, the _DSD must be provided to mitigate this.

- GpioIo() doesn't properly communicate the initial state of the output pin, thus Linux assumes the simple rule:

Pull Bias Polarity Requested...

  Implicit        x             AS IS (assumed firmware configured for us)
  Explicit        x (no _DSD)   as Pull Bias (Up == High, Down == Low),

assuming non-active (Polarity = !Pull Bias)

Quoted 9 lines
  Down            Low           as low, assuming active
  Down            High          as high, assuming non-active
  Up              Low           as low, assuming non-active
  Up              High          as high, assuming active

Hopefully this helps (and maybe can be added to some documentation).

P.S. Why I2cSerialBus() and not I2cSerialBusV2() ?

Will you address Andy's comments by adding documentation in the next version?

Regards,
Bin

#51 lore raw

PATCH v3 39/57 tpm: cr50: Add ACPI support

In reply to Andy Shevchenko
Quoted 28 lines · Andy Shevchenko

drivers/tpm/cr50_i2c.c static int cr50_i2c_cleanup(struct udevice *dev) · line 624

Quoted 7 lines · Simon Glass

Generate ACPI information for this device so that Linux can use it correctly.

drivers/tpm/cr50_i2c.c +4 -0
+     ret = acpi_device_write_interrupt_or_gpio(ctx, (struct udevice *)dev,
+                                               "ready-gpios");
+     if (ret < 0)
+             return log_msg_ret("irq_gpio", ret);

I looked a bit closer at the acpi_table.c and would like to emphasize on lessons learn from BIOS mistakes found in the wild with GPIOs.

Because GPIO resources are quite badly described in ACPI (it seems MS failed to deliver GPIO abstraction to ACPI and to Windows API), there are some corner cases, in order to mitigate which we need to consider the following to avoid potential glitches and misconfiguration:

- GpioIo() doesn't have any means of Active Low / High setting, the _DSD must be provided to mitigate this.

- GpioIo() doesn't properly communicate the initial state of the output pin, thus Linux assumes the simple rule:

Pull Bias Polarity Requested...

  Implicit        x             AS IS (assumed firmware configured for us)
  Explicit        x (no _DSD)   as Pull Bias (Up == High, Down == Low),
Quoted 7 lines

assuming non-active (Polarity = !Pull Bias)

  Down            Low           as low, assuming active
  Down            High          as high, assuming non-active
  Up              Low           as low, assuming non-active
  Up              High          as high, assuming active

I re-read the above piece of the table and found that I mistakenly placed words after 'as ' part.
Should be
as low, ...
as low, ...
as high, ...
as high, ...

So, request follows the bias setting, but polarity, if explicitly present, defines active/non-active state.

Quoted 9 lines

Hopefully this helps (and maybe can be added to some documentation).

P.S. Why I2cSerialBus() and not I2cSerialBusV2() ?

--
With Best Regards,
Andy Shevchenko

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#52 lore raw

PATCH v3 40/57 x86: fsp: Update the FSP API with the end-firmware method

In reply to Simon Glass

This new method is intended to be called when UEFI shuts down the 'boot services', i.e. any lingering code in the boot loader that might be used by the OS.

Add a definition for this new method and update the comments a little.

---

(no changes since v1)

 arch/x86/include/asm/fsp/fsp_api.h | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
arch/x86/include/asm/fsp/fsp_api.h +12 -3
index 4941e2d74f0..3a9b61903c0 100644
@@ -10,9 +10,18 @@
 
 enum fsp_phase {
 	/* Notification code for post PCI enuermation */
-	INIT_PHASE_PCI	= 0x20,
-	/* Notification code before transferring control to the payload */
-	INIT_PHASE_BOOT	= 0x40
+	INIT_PHASE_PCI		= 0x20,
+	/*
+	 * Notification code before transferring control to the payload.
+	 * This is issued at the end of init before starting main(), i.e.
+	 * the command line / boot script.
+	 */
+	INIT_PHASE_BOOT		= 0x40,
+	/*
+	 * Notification code before existing boot services. This is issued
+	 * just before removing devices and booting the kernel.
+	 */
+	INIT_PHASE_END_FIRMWARE	= 0xf0,
 };
 
 struct fsp_notify_params {
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#53 lore raw

PATCH v3 40/57 x86: fsp: Update the FSP API with the end-firmware method

Quoted 7 lines · Simon Glass

This new method is intended to be called when UEFI shuts down the 'boot services', i.e. any lingering code in the boot loader that might be used by the OS.

Add a definition for this new method and update the comments a little.

Quoted 8 lines

---

(no changes since v1)

 arch/x86/include/asm/fsp/fsp_api.h | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
#54 lore raw

PATCH v3 41/57 x86: cpu: Report address width from cpu_get_info()

In reply to Simon Glass

Add support for this new field in the common code used by most x86 CPU drivers.

---

(no changes since v1)

 arch/x86/cpu/i386/cpu.c         | 23 +++++++++++++++++++++++
 arch/x86/cpu/intel_common/cpu.c |  1 +
 arch/x86/cpu/x86_64/cpu.c       |  5 +++++
 arch/x86/include/asm/cpu.h      |  9 +++++++++
 4 files changed, 38 insertions(+)
arch/x86/cpu/i386/cpu.c +23 -0
index 8f342dd06e2..7517b756f43 100644
@@ -34,6 +34,10 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#define CPUID_FEATURE_PAE	BIT(6)
+#define CPUID_FEATURE_PSE36	BIT(17)
+#define CPUID_FEAURE_HTT	BIT(28)
+
 /*
  * Constructor for a conventional segment GDT (or LDT) entry
  * This is a macro so it can be used in initialisers
@@ -388,6 +392,25 @@ static void setup_identity(void)
 	}
 }
 
+static uint cpu_cpuid_extended_level(void)
+{
+	return cpuid_eax(0x80000000);
+}
+
+int cpu_phys_address_size(void)
+{
+	if (!has_cpuid())
+		return 32;
+
+	if (cpu_cpuid_extended_level() >= 0x80000008)
+		return cpuid_eax(0x80000008) & 0xff;
+
+	if (cpuid_edx(1) & (CPUID_FEATURE_PAE | CPUID_FEATURE_PSE36))
+		return 36;
+
+	return 32;
+}
+
 /* Don't allow PCI region 3 to use memory in the 2-4GB memory hole */
 static void setup_pci_ram_top(void)
 {
arch/x86/cpu/intel_common/cpu.c +1 -0
index d8a3d60ae72..39aa0f63c65 100644
@@ -127,6 +127,7 @@ int cpu_intel_get_info(struct cpu_info *info, int bclk)
 	info->cpu_freq = ((msr.lo >> 8) & 0xff) * bclk * 1000000;
 	info->features = 1 << CPU_FEAT_L1_CACHE | 1 << CPU_FEAT_MMU |
 		1 << CPU_FEAT_UCODE | 1 << CPU_FEAT_DEVICE_ID;
+	info->address_width = cpu_phys_address_size();
 
 	return 0;
 }
arch/x86/cpu/x86_64/cpu.c +5 -0
index 1b4d3971b04..90a766c3c57 100644
@@ -70,3 +70,8 @@ int x86_cpu_reinit_f(void)
 {
 	return 0;
 }
+
+int cpu_phys_address_size(void)
+{
+	return CONFIG_CPU_ADDR_BITS;
+}
arch/x86/include/asm/cpu.h +9 -0
index 21a05dab7de..5b001bbee21 100644
@@ -288,4 +288,13 @@ u32 cpu_get_family_model(void);
  */
 u32 cpu_get_stepping(void);
 
+/**
+ * cpu_phys_address_size() - Get the physical address size in bits
+ *
+ * This is 32 for older CPUs but newer ones may support 36.
+ *
+ * @return address size (typically 32 or 36)
+ */
+int cpu_phys_address_size(void);
+
 #endif
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#55 lore raw

PATCH v3 42/57 x86: Sort the MTRR table

In reply to Simon Glass

At present the MTRR registers are programmed with the list the U-Boot builds up in the same order. In some cases this list may be out of order. It looks better in Linux to have the registers in order, so sort them,

---

(no changes since v1)

 arch/x86/cpu/mtrr.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/x86/cpu/mtrr.c +12 -0
index 2468d88a80a..08fa80f8bc7 100644
@@ -19,6 +19,7 @@
 #include <common.h>
 #include <cpu_func.h>
 #include <log.h>
+#include <sort.h>
 #include <asm/cache.h>
 #include <asm/io.h>
 #include <asm/mp.h>
@@ -124,6 +125,16 @@ static int mtrr_copy_to_aps(void)
 	return 0;
 }
 
+static int h_comp_mtrr(const void *p1, const void *p2)
+{
+	const struct mtrr_request *req1 = p1;
+	const struct mtrr_request *req2 = p2;
+
+	s64 diff = req1->start - req2->start;
+
+	return diff < 0 ? -1 : diff > 0 ? 1 : 0;
+}
+
 int mtrr_commit(bool do_caches)
 {
 	struct mtrr_request *req = gd->arch.mtrr_req;
@@ -139,6 +150,7 @@ int mtrr_commit(bool do_caches)
 	debug("open\n");
 	mtrr_open(&state, do_caches);
 	debug("open done\n");
+	qsort(req, gd->arch.mtrr_req_count, sizeof(*req), h_comp_mtrr);
 	for (i = 0; i < gd->arch.mtrr_req_count; i++, req++)
 		set_var_mtrr(i, req->type, req->start, req->size);
 
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#56 lore raw

PATCH v3 43/57 x86: Notify the FSP of the 'end firmware' event

In reply to Simon Glass

Send this notification when U-Boot is about to boot into Linux, as requested by the FSP.

Currently this causes a crash with the APL FSP, so leave it disabled for now.

---

(no changes since v1)

 arch/x86/cpu/cpu.c            | 15 +++++++++++++++
 arch/x86/lib/fsp/fsp_common.c | 16 ++++++++++++++++
 2 files changed, 31 insertions(+)
arch/x86/cpu/cpu.c +15 -0
index 69c14189d1f..f8692753963 100644
@@ -189,6 +189,14 @@ __weak void board_final_init(void)
 {
 }
 
+/*
+ * Implement a weak default function for boards that need to do some final
+ * processing before booting the OS.
+ */
+__weak void board_final_cleanup(void)
+{
+}
+
 int last_stage_init(void)
 {
 	struct acpi_fadt __maybe_unused *fadt;
@@ -218,6 +226,13 @@ int last_stage_init(void)
 		}
 	}
 
+	/*
+	 * TODO(sjg at chromium.org): Move this to bootm_announce_and_cleanup()
+	 * once APL FSP-S at 0x200000 does not overlap with the bzimage at
+	 * 0x100000.
+	 */
+	board_final_cleanup();
+
 	return 0;
 }
 #endif
arch/x86/lib/fsp/fsp_common.c +16 -0
index ea529547254..4061fa244c4 100644
@@ -60,6 +60,22 @@ void board_final_init(void)
 		debug("OK\n");
 }
 
+void board_final_cleanup(void)
+{
+	u32 status;
+
+	/* TODO(sjg at chromium.org): This causes Linux to crash */
+	return;
+
+	/* call into FspNotify */
+	debug("Calling into FSP (notify phase INIT_PHASE_END_FIRMWARE): ");
+	status = fsp_notify(NULL, INIT_PHASE_END_FIRMWARE);
+	if (status)
+		debug("fail, error code %x\n", status);
+	else
+		debug("OK\n");
+}
+
 int fsp_save_s3_stack(void)
 {
 	struct udevice *dev;
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#57 lore raw

PATCH v3 44/57 x86: Correct the assembly guard in e820.h

In reply to Simon Glass

This is currently in the wrong place, so including the file in the device tree fails. Fix it.

---

(no changes since v1)

Changes in v1:
- Update commit message with a comma

 arch/x86/include/asm/e820.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/include/asm/e820.h +1 -2
index 9d29f82f972..87af0f492ec 100644
@@ -21,10 +21,9 @@ struct e820_entry {
 #define ISA_START_ADDRESS	0xa0000
 #define ISA_END_ADDRESS		0x100000
 
-#endif /* __ASSEMBLY__ */
-
 /* Implementation defined function to install an e820 map */
 unsigned int install_e820_map(unsigned int max_entries,
 			      struct e820_entry *);
+#endif /* __ASSEMBLY__ */
 
 #endif /* _ASM_X86_E820_H */
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#58 lore raw

PATCH v3 44/57 x86: Correct the assembly guard in e820.h

Quoted 7 lines · Simon Glass

This is currently in the wrong place, so including the file in the device tree fails. Fix it.

---

Quoted 8 lines

(no changes since v1)

Changes in v1:
- Update commit message with a comma

 arch/x86/include/asm/e820.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
#59 lore raw

PATCH v3 45/57 x86: Add a header guard to asm/acpi_table.h

In reply to Simon Glass

This file cannot currently be included in ASL files. Add a header guard to permit this.

---

(no changes since v1)

 arch/x86/include/asm/acpi_table.h | 4 ++++
 1 file changed, 4 insertions(+)
arch/x86/include/asm/acpi_table.h +4 -0
index faf31730730..1b49ccadc0c 100644
@@ -9,6 +9,8 @@
 #ifndef __ASM_ACPI_TABLE_H__
 #define __ASM_ACPI_TABLE_H__
 
+#ifndef __ACPI__
+
 struct acpi_facs;
 struct acpi_fadt;
 struct acpi_global_nvs;
@@ -213,4 +215,6 @@ void acpi_fadt_common(struct acpi_fadt *fadt, struct acpi_facs *facs,
  */
 void intel_acpi_fill_fadt(struct acpi_fadt *fadt);
 
+#endif /* !__ACPI__ */
+
 #endif /* __ASM_ACPI_TABLE_H__ */
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#60 lore raw

PATCH v3 45/57 x86: Add a header guard to asm/acpi_table.h

Quoted 4 lines · Simon Glass

This file cannot currently be included in ASL files. Add a header guard to permit this.

Quoted 8 lines

---

(no changes since v1)

 arch/x86/include/asm/acpi_table.h | 4 ++++
 1 file changed, 4 insertions(+)
#61 lore raw

PATCH v3 46/57 x86: Correct handling of MADT table CPUs

In reply to Simon Glass

At present if hyperthreading is disabled the CPU numbering is not sequential. Fix this.

---

(no changes since v1)

 arch/x86/lib/acpi_table.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
arch/x86/lib/acpi_table.c +6 -3
index b0cc1f123e2..667059b5ace 100644
@@ -66,14 +66,17 @@ int acpi_create_madt_lapics(u32 current)
 {
 	struct udevice *dev;
 	int total_length = 0;
+	int cpu_num = 0;
 
 	for (uclass_find_first_device(UCLASS_CPU, &dev);
 	     dev;
 	     uclass_find_next_device(&dev)) {
 		struct cpu_platdata *plat = dev_get_parent_platdata(dev);
-		int length = acpi_create_madt_lapic(
-				(struct acpi_madt_lapic *)current,
-				plat->cpu_id, plat->cpu_id);
+		int length;
+
+		length = acpi_create_madt_lapic(
+			(struct acpi_madt_lapic *)current, cpu_num++,
+			plat->cpu_id);
 		current += length;
 		total_length += length;
 	}
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#62 lore raw

PATCH v3 47/57 acpi: tpm: Add a TPM2 table

In reply to Simon Glass

This provides information about a v2 TPM in the system. Generate this table if the TPM is present.

---

(no changes since v1)

 arch/x86/lib/acpi_table.c | 74 +++++++++++++++++++++++++++++++++++++++
 include/acpi/acpi_table.h | 11 ++++++
 include/bloblist.h        |  1 +
 3 files changed, 86 insertions(+)
arch/x86/lib/acpi_table.c +74 -0
index 667059b5ace..9b13880f996 100644
@@ -7,6 +7,7 @@
  */
 
 #include <common.h>
+#include <bloblist.h>
 #include <cpu.h>
 #include <dm.h>
 #include <log.h>
@@ -214,6 +215,64 @@ static void acpi_create_mcfg(struct acpi_mcfg *mcfg)
 	header->checksum = table_compute_checksum((void *)mcfg, header->length);
 }
 
+static int get_tpm2_log(void **ptrp, int *sizep)
+{
+	const int tpm2_default_log_len = 0x10000;
+	int size;
+	int ret;
+
+	*sizep = 0;
+	size = tpm2_default_log_len;
+	ret = bloblist_ensure_size_ret(BLOBLISTT_TPM2_TCG_LOG, &size, ptrp);
+	if (ret)
+		return log_msg_ret("blob", ret);
+	*sizep = size;
+
+	return 0;
+}
+
+static int acpi_create_tpm2(struct acpi_tpm2 *tpm2)
+{
+	struct acpi_table_header *header = &tpm2->header;
+	int tpm2_log_len;
+	void *lasa;
+	int ret;
+
+	memset((void *)tpm2, 0, sizeof(struct acpi_tpm2));
+
+	/*
+	 * Some payloads like SeaBIOS depend on log area to use TPM2.
+	 * Get the memory size and address of TPM2 log area or initialize it.
+	 */
+	ret = get_tpm2_log(&lasa, &tpm2_log_len);
+	if (ret)
+		return ret;
+
+	/* Fill out header fields. */
+	acpi_fill_header(header, "TPM2");
+	memcpy(header->aslc_id, ASLC_ID, 4);
+
+	header->length = sizeof(struct acpi_tpm2);
+	header->revision = acpi_get_table_revision(ACPITAB_TPM2);
+
+	/* Hard to detect for coreboot. Just set it to 0 */
+	tpm2->platform_class = 0;
+
+	/* Must be set to 0 for FIFO-interface support */
+	tpm2->control_area = 0;
+	tpm2->start_method = 6;
+	memset(tpm2->msp, 0, sizeof(tpm2->msp));
+
+	/* Fill the log area size and start address fields. */
+	tpm2->laml = tpm2_log_len;
+	tpm2->lasa = (uintptr_t)lasa;
+
+	/* Calculate checksum. */
+	header->checksum = table_compute_checksum((void *)tpm2, header->length);
+
+	return 0;
+}
+
 __weak u32 acpi_fill_csrt(u32 current)
 {
 	return 0;
@@ -486,6 +545,21 @@ ulong write_acpi_tables(ulong start_addr)
 	acpi_inc_align(ctx, mcfg->header.length);
 	acpi_add_table(ctx, mcfg);
 
+	if (IS_ENABLED(CONFIG_TPM_V2)) {
+		struct acpi_tpm2 *tpm2;
+		int ret;
+
+		debug("ACPI:    * TPM2\n");
+		tpm2 = (struct acpi_tpm2 *)ctx->current;
+		ret = acpi_create_tpm2(tpm2);
+		if (!ret) {
+			acpi_inc_align(ctx, tpm2->header.length);
+			acpi_add_table(ctx, tpm2);
+		} else {
+			log_warning("TPM2 table creation failed\n");
+		}
+	}
+
 	debug("ACPI:    * MADT\n");
 	madt = ctx->current;
 	acpi_create_madt(madt);
include/acpi/acpi_table.h +11 -0
index a2e510cf56e..c7ee8b55da4 100644
@@ -93,6 +93,17 @@ struct __packed acpi_hpet {
 	u8 attributes;
 };
 
+struct __packed acpi_tpm2 {
+	struct acpi_table_header header;
+	u16 platform_class;
+	u8  reserved[2];
+	u64 control_area;
+	u32 start_method;
+	u8  msp[12];
+	u32 laml;
+	u64 lasa;
+};
+
 /* FADT Preferred Power Management Profile */
 enum acpi_pm_profile {
 	ACPI_PM_UNSPECIFIED = 0,
include/bloblist.h +1 -0
index 7d8480548e0..dc7d80bd851 100644
@@ -33,6 +33,7 @@ enum bloblist_tag_t {
 	 */
 	BLOBLISTT_ACPI_GNVS,
 	BLOBLISTT_INTEL_VBT,		/* Intel Video-BIOS table */
+	BLOBLISTT_TPM2_TCG_LOG,		/* TPM v2 log space */
 };
 
 /**
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#63 lore raw

PATCH v3 48/57 acpi: tpm: Add a TPM1 table

In reply to Simon Glass

This provides information about a v1 TPM in the system. Generate this table if the TPM is present.

Add a required new bloblist type and correct the header order of one header file.

---

(no changes since v1)

 arch/x86/lib/acpi_table.c | 54 ++++++++++++++++++++++++++++++++++++++-
 include/acpi/acpi_table.h |  7 +++++
 include/bloblist.h        |  1 +
 3 files changed, 61 insertions(+), 1 deletion(-)
arch/x86/lib/acpi_table.c +53 -1
index 9b13880f996..a3db94b8318 100644
@@ -215,6 +215,47 @@ static void acpi_create_mcfg(struct acpi_mcfg *mcfg)
 	header->checksum = table_compute_checksum((void *)mcfg, header->length);
 }
 
+/**
+ * acpi_create_tcpa() - Create a TCPA table
+ *
+ * @tcpa: Pointer to place to put table
+ *
+ * Trusted Computing Platform Alliance Capabilities Table
+ * TCPA PC Specific Implementation SpecificationTCPA is defined in the PCI
+ * Firmware Specification 3.0
+ */
+static int acpi_create_tcpa(struct acpi_tcpa *tcpa)
+{
+	struct acpi_table_header *header = &tcpa->header;
+	u32 current = (u32)tcpa + sizeof(struct acpi_tcpa);
+	int size = 0x10000;	/* Use this as the default size */
+	void *log;
+	int ret;
+
+	if (!CONFIG_IS_ENABLED(BLOBLIST))
+		return -ENXIO;
+	memset(tcpa, '\0', sizeof(struct acpi_tcpa));
+
+	/* Fill out header fields */
+	acpi_fill_header(header, "TCPA");
+	header->length = sizeof(struct acpi_tcpa);
+	header->revision = 1;
+
+	ret = bloblist_ensure_size_ret(BLOBLISTT_TCPA_LOG, &size, &log);
+	if (ret)
+		return log_msg_ret("blob", ret);
+
+	tcpa->platform_class = 0;
+	tcpa->laml = size;
+	tcpa->lasa = (ulong)log;
+
+	/* (Re)calculate length and checksum */
+	header->length = current - (u32)tcpa;
+	header->checksum = table_compute_checksum((void *)tcpa, header->length);
+
+	return 0;
+}
+
 static int get_tpm2_log(void **ptrp, int *sizep)
 {
 	const int tpm2_default_log_len = 0x10000;
@@ -455,11 +496,13 @@ ulong write_acpi_tables(ulong start_addr)
 	struct acpi_fadt *fadt;
 	struct acpi_table_header *ssdt;
 	struct acpi_mcfg *mcfg;
+	struct acpi_tcpa *tcpa;
 	struct acpi_madt *madt;
 	struct acpi_csrt *csrt;
 	struct acpi_spcr *spcr;
 	void *start;
 	ulong addr;
+	int ret;
 	int i;
 
 	start = map_sysmem(start_addr, 0);
@@ -547,7 +590,6 @@ ulong write_acpi_tables(ulong start_addr)
 
 	if (IS_ENABLED(CONFIG_TPM_V2)) {
 		struct acpi_tpm2 *tpm2;
-		int ret;
 
 		debug("ACPI:    * TPM2\n");
 		tpm2 = (struct acpi_tpm2 *)ctx->current;
@@ -566,6 +608,16 @@ ulong write_acpi_tables(ulong start_addr)
 	acpi_inc_align(ctx, madt->header.length);
 	acpi_add_table(ctx, madt);
 
+	debug("ACPI:    * TCPA\n");
+	tcpa = (struct acpi_tcpa *)ctx->current;
+	ret = acpi_create_tcpa(tcpa);
+	if (ret) {
+		log_warning("Failed to create TCPA table (err=%d)\n", ret);
+	} else {
+		acpi_inc_align(ctx, tcpa->header.length);
+		acpi_add_table(ctx, tcpa);
+	}
+
 	debug("ACPI:    * CSRT\n");
 	csrt = ctx->current;
 	if (!acpi_create_csrt(csrt)) {
include/acpi/acpi_table.h +7 -0
index c7ee8b55da4..9fba6536f50 100644
@@ -104,6 +104,13 @@ struct __packed acpi_tpm2 {
 	u64 lasa;
 };
 
+struct __packed acpi_tcpa {
+	struct acpi_table_header header;
+	u16 platform_class;
+	u32 laml;
+	u64 lasa;
+};
+
 /* FADT Preferred Power Management Profile */
 enum acpi_pm_profile {
 	ACPI_PM_UNSPECIFIED = 0,
include/bloblist.h +1 -0
index dc7d80bd851..5784c2226e7 100644
@@ -34,6 +34,7 @@ enum bloblist_tag_t {
 	BLOBLISTT_ACPI_GNVS,
 	BLOBLISTT_INTEL_VBT,		/* Intel Video-BIOS table */
 	BLOBLISTT_TPM2_TCG_LOG,		/* TPM v2 log space */
+	BLOBLISTT_TCPA_LOG,		/* TPM log space */
 };
 
 /**
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#64 lore raw

PATCH v3 49/57 x86: acpi: Set the log category for x86 table generation

In reply to Simon Glass

This file doesn't currently have a log category. Add one so that items are logged correctly.

---

(no changes since v1)

 arch/x86/lib/acpi_table.c | 2 ++
 1 file changed, 2 insertions(+)
arch/x86/lib/acpi_table.c +2 -0
index a3db94b8318..faab9d9de3c 100644
@@ -6,6 +6,8 @@
  * Copyright (C) 2016, Bin Meng <[email protected]>
  */
 
+#define LOG_CATEGORY LOGC_ACPI
+
 #include <common.h>
 #include <bloblist.h>
 #include <cpu.h>
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#65 lore raw

PATCH v3 49/57 x86: acpi: Set the log category for x86 table generation

Quoted 4 lines · Simon Glass

This file doesn't currently have a log category. Add one so that items are logged correctly.

Quoted 8 lines

---

(no changes since v1)

 arch/x86/lib/acpi_table.c | 2 ++
 1 file changed, 2 insertions(+)
#66 lore raw

PATCH v3 50/57 x86: coral: Add audio descriptor files

In reply to Simon Glass

Add files describing the various audio configurations supported on coral. These are passed to Linux in the ACPI tables.

---

(no changes since v1)

Changes in v1:
- Add new patch with coral audio descriptor files

 .../chromebook_coral/dialog-2ch-48khz-24b.dat    | Bin 0 -> 100 bytes
 .../chromebook_coral/dmic-1ch-48khz-16b.dat      | Bin 0 -> 3048 bytes
 .../chromebook_coral/dmic-2ch-48khz-16b.dat      | Bin 0 -> 3048 bytes
 .../chromebook_coral/dmic-4ch-48khz-16b.dat      | Bin 0 -> 3048 bytes
 .../max98357-render-2ch-48khz-24b.dat            | Bin 0 -> 116 bytes
 5 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 board/google/chromebook_coral/dialog-2ch-48khz-24b.dat
 create mode 100644 board/google/chromebook_coral/dmic-1ch-48khz-16b.dat
 create mode 100644 board/google/chromebook_coral/dmic-2ch-48khz-16b.dat
 create mode 100644 board/google/chromebook_coral/dmic-4ch-48khz-16b.dat
 create mode 100644 board/google/chromebook_coral/max98357-render-2ch-48khz-24b.dat
board/google/chromebook_coral/dialog-2ch-48khz-24b.dat new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..46c0efbd0adc0883564cf8404503fa1de7c4cc33
GIT binary patch
board/google/chromebook_coral/dmic-1ch-48khz-16b.dat new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..6a7f2cef4efea7707f4b2c57f8278962a53ca7c6
GIT binary patch

zcmeH{?Q5207{-tL at yXPo^x&v;5##(}YE((R^uH$tuM#U0<xwe19QX~tH4S!ser zHDiGqA$;!h!vv2kkDSuj9ylRh1M!Z(N?HATPkin{f=b}_8$b#4Hwsay`9&29_R18 z5=lifa=D^hE=M=?jbiTKb{)Oj#jjN3{FjXWZ(_JF;<r)B@WhBeulFREjF=rBF5q_q z$JcOKZCZLFB~8kOP7H>sSgT?D0{yFuU;8_>nsFU%595k~&|1!xVg3wf4xSI4XZ~IM zY{u4OjJKW(t!KS{tklW=ulhpU*;^6P0DDUQ2)*1Nn#uTKoNYK0YV8eWFO^=pQd-I0 z4}N0qY^Y_5bg&qWj)y9{Lw%E^wyUN7lcDKfgf?OCmRV9IYAydL)XScJf;e}r)beHM z_<>LtHcFRDi~kJm&4%vc{(=XH`x@!#_Ru|Vg*Gmfvh at Vbnf|8G{n+blmX?-D->)O4 zH$$VJl0M!jjcp6PSQ~mDKQ23r7WiB~BXsLF{Ogc5(^4Bk^9w>ZRG{tTL``=~SDnmg zurf6H6Y0 at A5+#R1Z$FvQsz*ZaEJxIJi5l+<J$|-OZ!8Io=}c66V@g%TxwE=Z&Jg} z6n3hbM>?&TJ00kYFn1loqbYfo;15a!WEU$kY3-SV;wC^4jai)*M(3wPqrCb?Cnu z-N%ueZKp#E>F1))64vIi?^({Zz{h*!^?B at OX@mUtGB?0ljy;FTbFjaL)_~n=?l?vm zichi3{v96cKT_IbNDl#GdKMen##Rh+}Dl|6POzhTN(DP&q!axLp at yF#@WTp-;CWU z_;>nu_ at Pywf=TY%%G!ZK7 at i25S4b-ea#bAjDK6O+864As8zDG4#wYp%1xl8mxSC zxzt)N9i1+1nkwyrrya10Z(Pe(EM{a!v*ZB(#V7W)b)G<Z$;~_SB#UIv?U}E37WU z{&)LBb9RJg!^G~6(3&6Mx<op%K)Sa9cAt|@G%<$1Uy126SlhP({mVnkibKE636*em z^X=$7G12}DiPj!XX(r;oGCr+URq3JLW6yit@G-heBO3!&vtF!_xL{F>-+78{jp#6 z&wkop)&UnhvRWvj?ZyAUdQeDt%LQjF4o67Sug8m{j8()w650II$Lk+ZvCAH=fin% zew-)g%XxGDoJZ%=d3AoBXXo2_cmB<Rcz5|!<?8Gb7OwYk$Ey#=F6O!H*;tH%%OQS zm*&%)npbmce$BCYHrM9coSS!ZZ~k2et_RnJ>%(>8dU4&jeq2YcC)bth%XQ{@bKSZA pT!*+YRF|&Lq31RF6 at u|2r>V@!&m-&&%f{a_dWl<|KHyCe*hgO-4Xx*

literal 0
HcmV?d00001

board/google/chromebook_coral/dmic-2ch-48khz-16b.dat new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..71d7648202154b6e8116dcf99cb7336f92731ac9
GIT binary patch

zYQ_R>L~rgn5i3N4A)!6_7(J{A3$0a-qODMKwp84@+R3_g#LoKZ at BibzSE=*E!$w zIaea7cxo<JoXh3-4F3vPyEJa%>mel!jnim<3P$+v<-Zc9O_!L-}rat{odq?|J?K9 zT*f*sS;b{_Y3b>dG(HzPITWg9ua^1CeBWUH=HH=}%<CDum{$&lR&%x-_h&hC;6msE z>mLwj3%;IYzWID;E&C0lq%Q2g>JM$jwlbtaY|8!!y*3b<#{98jsqt*6tuK_lQhN1T zX*sqZ|HRt4Q0qkLKq)$$2vzljo~M{*GmJZLQ}p7ZNT3h)1@lZT6!?lhs^*<oWD_O z{W5f7U#J@&;}%H^{tWHThVJA3!iUNG2I;wu&;##=*3Xl&4J6H(f#%Rd0Hws7Lli zuOX**LL;7)4zHI+wTE7*3w=Z!R~<nMVy>7Px^oNhbxIo<sdb?_grz2(RM<j=KH1V zPGvMy6Jsg^u#@hl0%{Qp2=v%<DvJLBI=q%O%H~iI#;B(7luZ5C91nMrE2orUQ?t! z%ZqdxKh-S-+TD{@M at d@ki&MI{U&_puW)w<<0y at OV_!b@O8Ch!BM2)&HhI**ac66;r z|CQ)In%ZnR6Pm|&7Wyn?Z#H%>aIO_TKBTTM;Wx_|;{QI at 2HDGDbA&nv_O*;g{MK;C zanhKN-KLR9Nf2B4PG+7Xo;jSk?XS=z?(OEj4q_-_Z47K>uv?pvzJYexVVe63s}D$ zzY~e?%<u5Ss5uRj+_#y%eMK-l7B;VumXY)$oc)>jHsSZJ-q52kRQhA+Cmf&xo<M8 zd~>zbRv{gmB5jx??SQ9ku-XYv<;T(db2$4n)O$3vi~FXN_s!IB=PYb$(F2_iakdRs z=i~poyh=gLNj1uXJ=^D4{%*39i1yJX@uPurIXFf;qO;+V7|gEJOc_(Bjh2Z!<$> zoZWagI*(1X_hO>e$5NVx_^*#iYejW>0KgXy>C0)<&0)kNw%N{reu@=X-s><8VBV z%keo*$LqKqzw>ZD&dd2ZPv5roxgRk9 at fSBSSRac-K?K=w4T=0dVk}ZQZTE>)?90 zF0PO3<a)VouAl4Zdb+Nzuj}l3yY8;PIWQ0A!hDz$^I~qyk2x|==E{7TGxKKd%%3?l zkLJ>Rnp5*?Zq2VbHqYkTe4BIgZtl&$`@sF+zHooIPuwr=8~2a<$o=HLa(}tc+;8qX n_n-Ta5Qh8G{YeP<_ub5)SN?s^zwi0?Jw5#1=im4L$NT;ddMe!=

literal 0
HcmV?d00001

board/google/chromebook_coral/dmic-4ch-48khz-16b.dat new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..142ab353f3736f110f30e9befbd72f7e8ae4264b
GIT binary patch

zg_FLimxY_Z#f at Y$A04&sT=#R2SPirtqf at ho3cMbuMUQ0Fn_dIYC0Qg?+<0KlwP at 3 zT7m6{Ke2W$)HYc<Sc(oOLRGz?fr(Pb_0r&}(6lc@8}WDBOsNXBmVF%R$7YZu&fh4t zeHA)!Ak>482}6!e}?vEL-%lh;X~wogY;}?=)Si at 8x}~}Mv~^tU`yyh{B^fVOUkA1 z*OJp)p;6CBpKOrEbc9~64}Cx!R~<$RVy>tT-M*Fhx};5v)cVl8!q82XXgeuU%e~Td zr!pF at 3QhV{di<_L$)V6YPiM69vCzBA5Or;$<_AJgo-5Lui$kNk6V>0GQVn_Tsx8vK z6-7FYpPJSJ?d?sgvm~vKr77J#AZ6xCvkE0b0Ucswe20z=j4U;5rbay%L%q~z7rHi} z|0;AJOKrBE2%6|2YnW^Hy69-IoAds?^D+o at tb7~^M5~UL+s_SIZT}c#MGwervho z7-=lTZu4lQB#0e+r!vnG&pgiD@>ggI_x5mKCoz<;HV(Ej*saS*-@rp7T-?FgMXcY7 z-^s*x=6CpE)SiY(?%TrNfg%_l51ZFW%SrlS&i+h%oALWbU+57SD*Z9^+%KVzxNj<~ ze0#OjULhTwCT*M|y$(-1VYLgM%8#M>7jX7jsP9N<5BJR^@9ETV_Z)2M&;y+hakd>+ z7vlf;{?P25p;<7oyDPN%2e>Yij?9<tZ-U(yq?0Yo;qO;+W)8wEl2-~(9+V-Z?i*X zoZWOMI*(7Z|6-ywM^l=C_^*viYh_J(<m<WDy>C0)<&0)kNw%N{reu@=X-s><8VBV z%keo*$LqKqzw>ZD&dd2ZPv5roxgRk9 at fSBSSRac-K?K=w4T=0dVk}ZQZTE>)?90 zF0PO3<a)VouAl4Zdb+Nzuj}l3yY8;PIWQ0A!hDz$^I~qyk2x|==E{7TGxKKd%%3?l zkLJ>Rnp5*?Zq2VbHqYkTe4BIgZtl&$`@sF+zHooIPuwr=8~2a<$o=HLa(}tc+;8qX n_n-Ta5Jvja{YeP<_ub5)SN?s^zwi0?Jw5W?=im4L$NT;dsY=};

literal 0
HcmV?d00001

board/google/chromebook_coral/max98357-render-2ch-48khz-24b.dat new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..b0b5b9ba648c4546f98e15e42356a5fc4af6bb27
GIT binary patch
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#67 lore raw

PATCH v3 51/57 x86: apl: Check low-level init in FSP-S pre-init

In reply to Simon Glass

If U-Boot is not running FSP-S it should not do the pre-init either. Add a condition to handle this.

---

(no changes since v1)

 arch/x86/cpu/apollolake/fsp_s.c | 2 ++
 1 file changed, 2 insertions(+)
arch/x86/cpu/apollolake/fsp_s.c +2 -0
index e54b0ac1047..715ceab6ac7 100644
@@ -157,6 +157,8 @@ int arch_fsps_preinit(void)
 	struct udevice *itss;
 	int ret;
 
+	if (!ll_boot_init())
+		return 0;
 	ret = irq_first_device_type(X86_IRQT_ITSS, &itss);
 	if (ret)
 		return log_msg_ret("no itss", ret);
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#68 lore raw

PATCH v3 52/57 x86: fsp: Add more debugging for silicon init

In reply to Simon Glass

If locating the FSP header hangs for whatever reason it is useful to see where it got stuck. Add a debug print. Also show the address of the FSP-S entry point as a sanity check.

---

(no changes since v1)

 arch/x86/lib/fsp2/fsp_silicon_init.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/lib/fsp2/fsp_silicon_init.c +3 -1
index 0f221a864fb..ead3493de82 100644
@@ -26,8 +26,10 @@ int fsp_silicon_init(bool s3wake, bool use_spi_flash)
 	struct binman_entry entry;
 	struct udevice *dev;
 	ulong rom_offset = 0;
+	u32 init_addr;
 	int ret;
 
+	log_debug("Locating FSP\n");
 	ret = fsp_locate_fsp(FSP_S, &entry, use_spi_flash, &dev, &hdr,
 			     &rom_offset);
 	if (ret)
@@ -44,7 +46,7 @@ int fsp_silicon_init(bool s3wake, bool use_spi_flash)
 	ret = fsps_update_config(dev, rom_offset, &upd);
 	if (ret)
 		return log_msg_ret("Could not setup config", ret);
-	log_debug("Silicon init...");
+	log_debug("Silicon init @ %x...", init_addr);
 	bootstage_start(BOOTSTAGE_ID_ACCUM_FSP_S, "fsp-s");
 	func = (fsp_silicon_init_func)(hdr->img_base + hdr->fsp_silicon_init);
 	ret = func(&upd);
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#69 lore raw

PATCH v3 52/57 x86: fsp: Add more debugging for silicon init

Quoted 5 lines · Simon Glass

If locating the FSP header hangs for whatever reason it is useful to see where it got stuck. Add a debug print. Also show the address of the FSP-S entry point as a sanity check.

Quoted 8 lines

---

(no changes since v1)

 arch/x86/lib/fsp2/fsp_silicon_init.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
#70 lore raw

PATCH v3 53/57 x86: fsp: Show FSP-S or FSP-M address in fsp_get_header()

In reply to Simon Glass

At present this function only supports FSP-M but it is also used to read FSP-S, in which case FSP-M may be zero. Add support for showing whichever address is present in the FSP binary.

Also change the debug() statements to log_debug() while here.

---

(no changes since v1)

 arch/x86/lib/fsp2/fsp_support.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)
arch/x86/lib/fsp2/fsp_support.c +14 -8
index 3f2ca840dc9..f220ef498b0 100644
@@ -35,7 +35,8 @@ int fsp_get_header(ulong offset, ulong size, bool use_spi_flash,
 	 *
 	 * You are in a maze of twisty little headers all alike.
 	 */
-	debug("offset=%x buf=%x\n", (uint)offset, (uint)buf);
+	log_debug("offset=%x buf=%x, use_spi_flash=%d\n", (uint)offset,
+		  (uint)buf, use_spi_flash);
 	if (use_spi_flash) {
 		ret = uclass_first_device_err(UCLASS_SPI_FLASH, &dev);
 		if (ret)
@@ -52,16 +53,16 @@ int fsp_get_header(ulong offset, ulong size, bool use_spi_flash,
 	fv = ptr;
 
 	/* Check the FV signature, _FVH */
-	debug("offset=%x sign=%x\n", (uint)offset, (uint)fv->sign);
+	log_debug("offset=%x sign=%x\n", (uint)offset, (uint)fv->sign);
 	if (fv->sign != EFI_FVH_SIGNATURE)
 		return log_msg_ret("Base FV signature", -EINVAL);
 
 	/* Go to the end of the FV header and align the address */
-	debug("fv->ext_hdr_off = %x\n", fv->ext_hdr_off);
+	log_debug("fv->ext_hdr_off = %x\n", fv->ext_hdr_off);
 	ptr += fv->ext_hdr_off;
 	exhdr = ptr;
 	ptr += ALIGN(exhdr->ext_hdr_size, 8);
-	debug("ptr=%x\n", ptr - (void *)buf);
+	log_debug("ptr=%x\n", ptr - (void *)buf);
 
 	/* Check the FFS GUID */
 	file_hdr = ptr;
@@ -71,7 +72,7 @@ int fsp_get_header(ulong offset, ulong size, bool use_spi_flash,
 	ptr = file_hdr + 1;
 
 	raw = ptr;
-	debug("raw->type = %x\n", raw->type);
+	log_debug("raw->type = %x\n", raw->type);
 	if (raw->type != EFI_SECTION_RAW)
 		return log_msg_ret("Section type not RAW", -ENOEXEC);
 
@@ -80,13 +81,18 @@ int fsp_get_header(ulong offset, ulong size, bool use_spi_flash,
 	fsp = ptr;
 
 	/* Check the FSPH header */
-	debug("fsp %x\n", (uint)fsp);
+	log_debug("fsp %x, fsp-buf=%x, si=%x\n", (uint)fsp, ptr - (void *)buf,
+		  (void *)&fsp->fsp_silicon_init - (void *)buf);
 	if (fsp->sign != EFI_FSPH_SIGNATURE)
 		return log_msg_ret("Base FSPH signature", -EACCES);
 
 	base = (void *)fsp->img_base;
-	debug("Image base %x\n", (uint)base);
-	debug("Image addr %x\n", (uint)fsp->fsp_mem_init);
+	log_debug("image base %x\n", (uint)base);
+	if (fsp->fsp_mem_init)
+		log_debug("mem_init offset %x\n", (uint)fsp->fsp_mem_init);
+	else if (fsp->fsp_silicon_init)
+		log_debug("silicon_init offset %x\n",
+			  (uint)fsp->fsp_silicon_init);
 	if (use_spi_flash) {
 		ret = spi_flash_read_dm(dev, offset, size, base);
 		if (ret)
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#71 lore raw

PATCH v3 53/57 x86: fsp: Show FSP-S or FSP-M address in fsp_get_header()

Quoted 7 lines · Simon Glass

At present this function only supports FSP-M but it is also used to read FSP-S, in which case FSP-M may be zero. Add support for showing whichever address is present in the FSP binary.

Also change the debug() statements to log_debug() while here.

Quoted 8 lines

---

(no changes since v1)

 arch/x86/lib/fsp2/fsp_support.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)
#72 lore raw

PATCH v3 54/57 acpi: Use defines for field lengths

In reply to Simon Glass

A few fields have an open-coded length. Use the defines for this purpose instead.

---

(no changes since v1)

 include/acpi/acpi_table.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
include/acpi/acpi_table.h +3 -2
index 9fba6536f50..3a243bf19ce 100644
@@ -13,6 +13,7 @@
 #ifndef __ACPI_TABLE_H__
 #define __ACPI_TABLE_H__
 
+#include <dm/acpi.h>
 #include <linux/bitops.h>
 
 #define RSDP_SIG		"RSD PTR "	/* RSDP pointer signature */
@@ -48,7 +49,7 @@ struct acpi_rsdp {
 
 /* Generic ACPI header, provided by (almost) all tables */
 struct __packed acpi_table_header {
-	char signature[4];	/* ACPI signature (4 ASCII characters) */
+	char signature[ACPI_NAME_LEN];	/* ACPI signature (4 ASCII chars) */
 	u32 length;		/* Table length in bytes (incl. header) */
 	u8 revision;		/* Table version (not ACPI version!) */
 	volatile u8 checksum;	/* To make sum of entire table == 0 */
@@ -263,7 +264,7 @@ struct __packed acpi_fadt {
 
 /* FACS (Firmware ACPI Control Structure) */
 struct acpi_facs {
-	char signature[4];		/* "FACS" */
+	char signature[ACPI_NAME_LEN];	/* "FACS" */
 	u32 length;			/* Length in bytes (>= 64) */
 	u32 hardware_signature;		/* Hardware signature */
 	u32 firmware_waking_vector;	/* Firmware waking vector */
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#73 lore raw

PATCH v3 54/57 acpi: Use defines for field lengths

Quoted 4 lines · Simon Glass

A few fields have an open-coded length. Use the defines for this purpose instead.

Quoted 8 lines

---

(no changes since v1)

 include/acpi/acpi_table.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
#74 lore raw

PATCH v3 55/57 x86: Add a way to add to the e820 memory table

In reply to Simon Glass

Some boards want to reserve extra regions of memory. Add a 'chosen' property to support this.

---

(no changes since v1)

 arch/x86/lib/fsp/fsp_dram.c         | 17 +++++++++++++++++
 doc/device-tree-bindings/chosen.txt | 18 ++++++++++++++++++
 2 files changed, 35 insertions(+)
arch/x86/lib/fsp/fsp_dram.c +17 -0
index faa819fab4b..a76497d4e01 100644
@@ -12,6 +12,7 @@
 #include <asm/mrccache.h>
 #include <asm/mtrr.h>
 #include <asm/post.h>
+#include <dm/ofnode.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -92,6 +93,8 @@ unsigned int install_e820_map(unsigned int max_entries,
 	unsigned int num_entries = 0;
 	const struct hob_header *hdr;
 	struct hob_res_desc *res_desc;
+	const fdt64_t *prop;
+	int size;
 
 	hdr = gd->arch.hob_list;
 
@@ -133,6 +136,20 @@ unsigned int install_e820_map(unsigned int max_entries,
 		num_entries++;
 	}
 
+	prop = ofnode_read_chosen_prop("e820-entries", &size);
+	if (prop) {
+		int count = size / (sizeof(u64) * 3);
+		int i;
+
+		if (num_entries + count >= max_entries)
+			return -ENOSPC;
+		for (i = 0; i < count; i++, num_entries++, prop += 3) {
+			entries[num_entries].addr = fdt64_to_cpu(prop[0]);
+			entries[num_entries].size = fdt64_to_cpu(prop[1]);
+			entries[num_entries].type = fdt64_to_cpu(prop[2]);
+		}
+	}
+
 	return num_entries;
 }
 
doc/device-tree-bindings/chosen.txt +18 -0
index d4dfc05847b..e5ba6720ce1 100644
@@ -143,3 +143,21 @@ This provides the ordering to use when writing device data to the ACPI SSDT
 node to add. The ACPI information is written in this order.
 
 If the ordering does not include all nodes, an error is generated.
+
+e820-entries
+------------
+
+This provides a way to add entries to the e820 table which tells the OS about
+the memory map. The property contains three sets of 64-bit values:
+
+   address   - Start address of region
+   size      - Size of region
+   flags     - Flags (E820_...)
+
+Example:
+
+chosen {
+	e820-entries = /bits/ 64 <
+		IOMAP_P2SB_BAR IOMAP P2SB_SIZE E820_RESERVED
+		MCH_BASE_ADDRESS     MCH_SIZE  E820_RESERVED>;
+};
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#75 lore raw

PATCH v3 55/57 x86: Add a way to add to the e820 memory table

Quoted 4 lines · Simon Glass

Some boards want to reserve extra regions of memory. Add a 'chosen' property to support this.

Quoted 9 lines

---

(no changes since v1)

 arch/x86/lib/fsp/fsp_dram.c         | 17 +++++++++++++++++
 doc/device-tree-bindings/chosen.txt | 18 ++++++++++++++++++
 2 files changed, 35 insertions(+)
#76 lore raw

PATCH v3 56/57 x86: Move include of bitops out of ACPI region

In reply to Simon Glass

At present linux/bitops.h is included in ACPI code. This is not needed and can cause a problem in fls64.h since BITS_PER_LONG is not defined. Move the #include into the part not used by ACPI.

---

(no changes since v2)

Changes in v2:
- Add new patch to move include of bitops out of ACPI region

 include/acpi/acpi_table.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/acpi/acpi_table.h +2 -1
index 3a243bf19ce..abbca6530db 100644
@@ -14,7 +14,6 @@
 #define __ACPI_TABLE_H__
 
 #include <dm/acpi.h>
-#include <linux/bitops.h>
 
 #define RSDP_SIG		"RSD PTR "	/* RSDP pointer signature */
 #define OEM_ID			"U-BOOT"	/* U-Boot */
@@ -29,6 +28,8 @@
 
 #if !defined(__ACPI__)
 
+#include <linux/bitops.h>
+
 struct acpi_ctx;
 
 /*
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#77 lore raw

PATCH v3 56/57 x86: Move include of bitops out of ACPI region

Quoted 8 lines · Simon Glass

At present linux/bitops.h is included in ACPI code. This is not needed and can cause a problem in fls64.h since BITS_PER_LONG is not defined. Move the #include into the part not used by ACPI.

---

Quoted 8 lines

(no changes since v2)

Changes in v2:
- Add new patch to move include of bitops out of ACPI region

 include/acpi/acpi_table.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
#78 lore raw

PATCH v3 57/57 x86: coral: Update config and device tree for ACPI

In reply to Simon Glass

Enable new features and provide require device-tree config so that U-Boot produces the correct ACPI tables on Coral.

---

Changes in v3:
- Rebase to master

Changes in v2:
- Rebase to master

Changes in v1:
- Add NHLT information
- Fix i2c PCI addresses
- Rename acpi-probed to linux,probed
- Rename cpi,hid-desc-reg-offset to hid-desc-addr
- UIse hid-over-i2 compatible string
- Update ACPI ordering to include multiple CPUs
- Use acpi,ddn instead of acpi,desc

 arch/x86/dts/chromebook_coral.dts  | 224 +++++++++++++++++++++++++++--
 configs/chromebook_coral_defconfig |  11 +-
 2 files changed, 220 insertions(+), 15 deletions(-)
arch/x86/dts/chromebook_coral.dts +211 -13
index a17a9c28003..8c08259b001 100644
@@ -15,14 +15,20 @@
 #include "flashmap-16mb-rw.dtsi"
 #endif
 
+#include <dt-bindings/clock/intel-clock.h>
+#include <dt-bindings/interrupt-controller/irq.h>
+#include <dt-bindings/interrupt-controller/x86-irq.h>
+#include <asm/e820.h>
 #include <asm/intel_pinctrl_defs.h>
 #include <asm/arch-apollolake/cpu.h>
+#include <asm/arch-apollolake/gpe.h>
 #include <asm/arch-apollolake/gpio.h>
 #include <asm/arch-apollolake/iomap.h>
 #include <asm/arch-apollolake/pm.h>
 #include <dt-bindings/clock/intel-clock.h>
 #include <asm/arch-apollolake/fsp/fsp_m_upd.h>
 #include <asm/arch-apollolake/fsp/fsp_s_upd.h>
+#include <dt-bindings/sound/nhlt.h>
 
 / {
 	model = "Google Coral";
@@ -40,6 +46,14 @@
 		i2c5 = &i2c_5;
 		i2c6 = &i2c_6;
 		i2c7 = &i2c_7;
+		mmc1 = &sdmmc;
+	};
+
+	board: board {
+		compatible = "google,coral";
+		recovery-gpios = <&gpio_nw (-1) GPIO_ACTIVE_LOW>;
+		write-protect-gpios = <&gpio_nw GPIO_75 GPIO_ACTIVE_HIGH>;
+		phase-enforce-gpios = <&gpio_n GPIO_10 GPIO_ACTIVE_HIGH>;
 	};
 
 	config {
@@ -48,6 +62,15 @@
 
 	chosen {
 		stdout-path = &serial;
+		e820-entries = /bits/ 64 <
+			IOMAP_P2SB_BAR IOMAP_P2SB_SIZE E820_RESERVED
+			MCH_BASE_ADDRESS     MCH_SIZE  E820_RESERVED>;
+		u-boot,acpi-ssdt-order = <&cpu_0 &cpu_1 &cpu_2 &cpu_3
+			&i2c_0 &i2c_1 &i2c_2 &i2c_3 &i2c_4 &i2c_5
+			&sdmmc &maxim_codec &wifi &da_codec &tpm
+			&elan_touchscreen &raydium_touchscreen
+			&elan_touchpad &synaptics_touchpad &wacom_digitizer>;
+		u-boot,acpi-dsdt-order = <&board &lpc>;
 	};
 
 	clk: clock {
@@ -60,7 +83,7 @@
 		#address-cells = <1>;
 		#size-cells = <0>;
 
-		cpu at 0 {
+		cpu_0: cpu at 0 {
 			u-boot,dm-pre-reloc;
 			device_type = "cpu";
 			compatible = "intel,apl-cpu";
@@ -68,21 +91,21 @@
 			intel,apic-id = <0>;
 		};
 
-		cpu at 1 {
+		cpu_1: cpu at 1 {
 			device_type = "cpu";
 			compatible = "intel,apl-cpu";
 			reg = <1>;
 			intel,apic-id = <2>;
 		};
 
-		cpu at 2 {
+		cpu_2: cpu at 2 {
 			device_type = "cpu";
 			compatible = "intel,apl-cpu";
 			reg = <2>;
 			intel,apic-id = <4>;
 		};
 
-		cpu at 3 {
+		cpu_3: cpu at 3 {
 			device_type = "cpu";
 			compatible = "intel,apl-cpu";
 			reg = <3>;
@@ -128,6 +151,10 @@
 			 */
 			fsp_s: fsp-s {
 			};
+
+			nhlt {
+				intel,dmic-channels = <4>;
+			};
 		};
 
 		punit at 0,1 {
@@ -136,21 +163,29 @@
 			compatible = "intel,apl-punit";
 		};
 
+		gma at 2,0 {
+			reg = <0x00001000 0 0 0 0>;
+			compatible = "vesa-fb";
+		};
+
 		p2sb: p2sb at d,0 {
 			u-boot,dm-pre-reloc;
 			reg = <0x02006810 0 0 0 0>;
 			compatible = "intel,p2sb";
 			early-regs = <IOMAP_P2SB_BAR 0x100000>;
+			pci,no-autoconfig;
 
 			n {
 				compatible = "intel,apl-pinctrl";
 				u-boot,dm-pre-reloc;
 				intel,p2sb-port-id = <PID_GPIO_N>;
+				acpi,path = "\\_SB.GPO0";
 				gpio_n: gpio-n {
 					compatible = "intel,gpio";
 					u-boot,dm-pre-reloc;
 					gpio-controller;
 					#gpio-cells = <2>;
+					linux-name = "INT3452:00";
 				};
 			};
 
@@ -159,11 +194,13 @@
 				compatible = "intel,apl-pinctrl";
 				intel,p2sb-port-id = <PID_GPIO_NW>;
 				#gpio-cells = <2>;
+				acpi,path = "\\_SB.GPO1";
 				gpio_nw: gpio-nw {
 					compatible = "intel,gpio";
 					u-boot,dm-pre-reloc;
 					gpio-controller;
 					#gpio-cells = <2>;
+					linux-name = "INT3452:01";
 				};
 			};
 
@@ -172,11 +209,13 @@
 				compatible = "intel,apl-pinctrl";
 				intel,p2sb-port-id = <PID_GPIO_W>;
 				#gpio-cells = <2>;
+				acpi,path = "\\_SB.GPO2";
 				gpio_w: gpio-w {
 					compatible = "intel,gpio";
 					u-boot,dm-pre-reloc;
 					gpio-controller;
 					#gpio-cells = <2>;
+					linux-name = "INT3452:02";
 				};
 			};
 
@@ -185,11 +224,13 @@
 				compatible = "intel,apl-pinctrl";
 				intel,p2sb-port-id = <PID_GPIO_SW>;
 				#gpio-cells = <2>;
+				acpi,path = "\\_SB.GPO3";
 				gpio_sw: gpio-sw {
 					compatible = "intel,gpio";
 					u-boot,dm-pre-reloc;
 					gpio-controller;
 					#gpio-cells = <2>;
+					linux-name = "INT3452:03";
 				};
 			};
 
@@ -238,6 +279,24 @@
 			gpe0-en = <0x30>;
 		};
 
+		audio at e,0 {
+			reg = <0x7000 0 0 0 0>;
+			compatible = "simple-bus";
+			acpi,name = "HDAS";
+			i2s {
+				compatible = "fred";
+			};
+			maxim_codec: maxim-codec {
+				compatible = "maxim,max98357a";
+				acpi,ddn = "Maxim Integrated 98357A Amplifier";
+				sdmode-gpios = <&gpio_n GPIO_76 GPIO_ACTIVE_HIGH>;
+				sdmode-delay = <5>;
+				acpi,name = "MAXM";
+				acpi,hid = "MX98357A";
+				acpi,audio-link = <AUDIO_LINK_SSP5>;
+			};
+		};
+
 		spi: fast-spi at d,2 {
 			u-boot,dm-pre-reloc;
 			reg = <0x02006a10 0 0 0 0>;
@@ -267,19 +326,63 @@
 			};
 		};
 
+		/* WiFi */
+		pcie-a0 at 14,0 {
+			reg = <0x0000a000 0 0 0 0>;
+			acpi,name = "RP01";
+			wifi: wifi {
+				compatible = "intel,generic-wifi";
+				acpi,ddn = "Intel WiFi";
+				acpi,name = "WF00";
+				acpi,wake = <GPE0_DW3_00>;
+				interrupts-extended = <&acpi_gpe 0x3c 0>;
+			};
+		};
+
 		i2c_0: i2c2 at 16,0 {
 			compatible = "intel,apl-i2c";
 			reg = <0x0200b010 0 0 0 0>;
 			clocks = <&clk CLK_I2C>;
 			i2c-scl-rising-time-ns = <104>;
 			i2c-scl-falling-time-ns = <52>;
+			clock-frequency = <400000>;
+			i2c,speeds = <100000 400000 1000000>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			da_codec: da-codec {
+				reg = <0x1a>;
+				compatible = "dlg,da7219";
+				interrupts-extended = <&acpi_gpe GPIO_116_IRQ
+					(IRQ_TYPE_LEVEL_LOW | X86_IRQ_TYPE_SHARED)>;
+				acpi,name = "DLG7";
+				acpi,ddn = "Dialog Semiconductor DA7219 Audio Codec";
+				acpi,audio-link = <AUDIO_LINK_SSP1>;
+				dlg,micbias-lvl = <2600>;
+				dlg,mic-amp-in-sel = "diff";
+				da7219_aad {
+					dlg,btn-cfg = <50>;
+					dlg,mic-det-thr = <500>;
+					dlg,jack-ins-deb = <20>;
+					dlg,jack-det-rate = "32ms_64ms";
+					dlg,jack-rem-deb = <1>;
+					dlg,a-d-btn-thr = <0xa>;
+					dlg,d-b-btn-thr = <0x16>;
+					dlg,b-c-btn-thr = <0x21>;
+					dlg,c-mic-btn-thr = <0x3e>;
+					dlg,btn-avg = <4>;
+					dlg,adc-1bit-rpt = <1>;
+				};
+			};
 		};
 
 		i2c_1: i2c2 at 16,1 {
 			compatible = "intel,apl-i2c";
 			reg = <0x0200b110 0 0 0 0>;
 			clocks = <&clk CLK_I2C>;
-			status = "disabled";
+			clock-frequency = <400000>;
+			i2c,speeds = <100000 400000 1000000 3400000>;
+			i2c-scl-rising-time-ns = <52>;
+			i2c-scl-falling-time-ns = <52>;
 		};
 
 		i2c_2: i2c2 at 16,2 {
@@ -288,53 +391,130 @@
 			#address-cells = <1>;
 			#size-cells = <0>;
 			clock-frequency = <400000>;
+			i2c,speeds = <100000 400000 1000000>;
 			clocks = <&clk CLK_I2C>;
 			i2c-scl-rising-time-ns = <57>;
 			i2c-scl-falling-time-ns = <28>;
-			tpm at 50 {
+			tpm: tpm at 50 {
 				reg = <0x50>;
 				compatible = "google,cr50";
 				u-boot,i2c-offset-len = <0>;
 				ready-gpios = <&gpio_n 28 GPIO_ACTIVE_LOW>;
-				interrupts-extended = <&acpi_gpe 0x3c 0>;
+				interrupts-extended = <&acpi_gpe GPIO_28_IRQ
+					 IRQ_TYPE_EDGE_FALLING>;
+				acpi,hid = "GOOG0005";
+				acpi,ddn = "I2C TPM";
+				acpi,name = "TPMI";
 			};
 		};
 
 		i2c_3: i2c2 at 16,3 {
 			compatible = "intel,apl-i2c";
-			reg = <0x0200b110 0 0 0 0>;
+			reg = <0x0200b310 0 0 0 0>;
+			#address-cells = <1>;
+			#size-cells = <0>;
 			clocks = <&clk CLK_I2C>;
 			i2c-scl-rising-time-ns = <76>;
 			i2c-scl-falling-time-ns = <164>;
+			clock-frequency = <400000>;
+			i2c,speeds = <100000 400000>;
+			elan_touchscreen: elan-touchscreen at 10 {
+				compatible = "i2c-chip";
+				reg = <0x10>;
+				acpi,hid = "ELAN0001";
+				acpi,ddn = "ELAN Touchscreen";
+				interrupts-extended = <&acpi_gpe GPIO_21_IRQ
+					IRQ_TYPE_EDGE_FALLING>;
+				linux,probed;
+				reset-gpios = <&gpio_n GPIO_36 GPIO_ACTIVE_HIGH>;
+				reset-delay-ms = <20>;
+				enable-gpios = <&gpio_n GPIO_152 GPIO_ACTIVE_HIGH>;
+				enable-delay-ms = <1>;
+				acpi,has-power-resource;
+			};
+
+			raydium_touchscreen: raydium-touchscreen at 39 {
+				compatible = "i2c-chip";
+				reg = <0x39>;
+				acpi,hid = "RAYD0001";
+				acpi,ddn = "Raydium Touchscreen";
+				interrupts-extended = <&acpi_gpe GPIO_21_IRQ
+					IRQ_TYPE_EDGE_FALLING>;
+				linux,probed;
+				reset-gpios = <&gpio_n GPIO_36 GPIO_ACTIVE_HIGH>;
+				reset-delay-ms = <1>;
+				enable-gpios = <&gpio_n GPIO_152 GPIO_ACTIVE_HIGH>;
+				enable-delay-ms = <50>;
+				acpi,has-power-resource;
+			};
 		};
 
 		i2c_4: i2c2 at 17,0 {
 			compatible = "intel,apl-i2c";
-			reg = <0x0200b110 0 0 0 0>;
+			reg = <0x0200b810 0 0 0 0>;
+			#address-cells = <1>;
+			#size-cells = <0>;
 			clocks = <&clk CLK_I2C>;
 			i2c-sda-hold-time-ns = <350>;
 			i2c-scl-rising-time-ns = <114>;
 			i2c-scl-falling-time-ns = <164>;
+			clock-frequency = <400000>;
+			i2c,speeds = <100000 400000>;
+			elan_touchpad: elan-touchpad at 15 {
+				compatible = "i2c-chip";
+				reg = <0x15>;
+				u-boot,i2c-offset-len = <0>;
+				acpi,hid = "ELAN0000";
+				acpi,ddn = "ELAN Touchpad";
+				interrupts-extended = <&acpi_gpe GPIO_18_IRQ
+					 IRQ_TYPE_EDGE_FALLING>;
+				acpi,wake = <GPE0_DW1_15>;
+				linux,probed;
+			};
+			synaptics_touchpad: synaptics-touchpad at 2c {
+				compatible = "hid-over-i2c";
+				reg = <0x2c>;
+				acpi,hid = "PNP0C50";
+				acpi,ddn = "Synaptics Touchpad";
+				interrupts-extended = <&acpi_gpe GPIO_18_IRQ
+					 IRQ_TYPE_EDGE_FALLING>;
+				acpi,wake = <GPE0_DW1_15>;
+				linux,probed;
+				hid-descr-addr = <0x20>;
+			};
 		};
 
 		i2c_5: i2c2 at 17,1 {
 			compatible = "intel,apl-i2c";
-			reg = <0x0200b110 0 0 0 0>;
+			reg = <0x0200b910 0 0 0 0>;
+			#address-cells = <1>;
+			#size-cells = <0>;
 			clocks = <&clk CLK_I2C>;
 			i2c-scl-rising-time-ns = <76>;
 			i2c-scl-falling-time-ns = <164>;
+			clock-frequency = <400000>;
+			i2c,speeds = <100000 400000 1000000>;
+			wacom_digitizer: wacom-digitizer at 9 {
+				compatible = "hid-over-i2c";
+				reg = <0x9>;
+				acpi,hid = "WCOM50C1";
+				acpi,ddn = "WCOM Digitizer";
+				interrupts-extended = <&acpi_gpe GPIO_13_IRQ
+					(IRQ_TYPE_LEVEL_LOW | X86_IRQ_TYPE_SHARED)>;
+				hid-descr-addr = <0x1>;
+			};
 		};
 
 		i2c_6: i2c2 at 17,2 {
 			compatible = "intel,apl-i2c";
-			reg = <0x0200b110 0 0 0 0>;
+			reg = <0x0200ba10 0 0 0 0>;
 			clocks = <&clk CLK_I2C>;
 			status = "disabled";
 		};
 
 		i2c_7: i2c2 at 17,3 {
 			compatible = "intel,apl-i2c";
-			reg = <0x0200b110 0 0 0 0>;
+			reg = <0x0200bb10 0 0 0 0>;
 			clocks = <&clk CLK_I2C>;
 			status = "disabled";
 		};
@@ -347,6 +527,15 @@
 			reg-shift = <2>;
 			clock-frequency = <1843200>;
 			current-speed = <115200>;
+			acpi,name = "URT3";
+			pci,no-autoconfig;
+		};
+
+		sdmmc: sdmmc at 1b,0 {
+			reg = <0x0000d800 0 0 0 0>;
+			compatible = "intel,apl-sd";
+			cd-gpios = <&gpio_n GPIO_177 GPIO_ACTIVE_LOW>;
+			acpi,name = "SDCD";
 		};
 
 		pch: pch at 1f,0 {
@@ -356,7 +545,7 @@
 			#address-cells = <1>;
 			#size-cells = <1>;
 
-			lpc {
+			lpc: lpc {
 				compatible = "intel,apl-lpc";
 				#address-cells = <1>;
 				#size-cells = <0>;
@@ -600,6 +789,11 @@
 	fsps,emmc-rx-cmd-data-cntl1 = <0x00181717>;
 	fsps,emmc-rx-cmd-data-cntl2 = <0x10008>;
 
+	/* Enable Audio Clock and Power gating */
+	fsps,hd-audio-clk-gate = <1>;
+	fsps,hd-audio-pwr-gate = <1>;
+	fsps,bios-cfg-lock-down = <1>;
+
 	/* Enable WiFi */
 	fsps,pcie-root-port-en = [01 00 00 00 00 00];
 	fsps,pcie-rp-hot-plug = [00 00 00 00 00 00];
@@ -611,6 +805,10 @@
 	fsps,port-usb20-per-port-pe-txi-set = [07 07 06 06 07 07 07 01];
 	fsps,port-usb20-per-port-txi-set = [00 02 00 00 00 00 00 03];
 
+	fsps,lpss-s0ix-enable = <1>;
+	fsps,usb-otg = <0>;
+	fsps,monitor-mwait-enable = <0>;
+
 	/*
 	 * TODO(sjg at chromium.org): Move this to the I2C nodes
 	 * Intel Common SoC Config
configs/chromebook_coral_defconfig +9 -2
index ef4dabbe26e..af0397ff1f4 100644
@@ -4,6 +4,7 @@ CONFIG_SYS_MALLOC_F_LEN=0x3d00
 CONFIG_NR_DRAM_BANKS=8
 CONFIG_SPL_DM_SPI=y
 CONFIG_SPL_TEXT_BASE=0xfef10000
+CONFIG_MAX_CPUS=8
 CONFIG_SPL_SYS_MALLOC_F_LEN=0xf000
 CONFIG_BOOTSTAGE_STASH_ADDR=0xfef00000
 CONFIG_DEBUG_UART_BOARD_INIT=y
@@ -14,9 +15,10 @@ CONFIG_VENDOR_GOOGLE=y
 CONFIG_TARGET_CHROMEBOOK_CORAL=y
 CONFIG_DEBUG_UART=y
 CONFIG_FSP_VERSION2=y
+CONFIG_GENERATE_ACPI_TABLE=y
 CONFIG_HAVE_ACPI_RESUME=y
 CONFIG_INTEL_CAR_CQOS=y
-CONFIG_X86_OFFSET_U_BOOT=0xffe00000
+CONFIG_X86_OFFSET_U_BOOT=0xffd00000
 CONFIG_X86_OFFSET_SPL=0xffe80000
 CONFIG_INTEL_GENERIC_WIFI=y
 CONFIG_BOOTSTAGE=y
@@ -26,13 +28,14 @@ CONFIG_BOOTSTAGE_REPORT=y
 CONFIG_SPL_BOOTSTAGE_RECORD_COUNT=10
 CONFIG_BOOTSTAGE_STASH=y
 CONFIG_USE_BOOTARGS=y
-CONFIG_BOOTARGS="root=/dev/sdb3 init=/sbin/init rootwait ro earlyprintk console=tty0 console=ttyS0,115200"
+CONFIG_BOOTARGS="console=ttyS2,115200n8 cros_legacy loglevel=9 init=/sbin/init oops=panic panic=-1 root=PARTUUID=35c775e7-3735-d745-93e5-d9e0238f7ed0/PARTNROFF=1 rootwait rw noinitrd vt.global_cursor_default=0 add_efi_memmap boot=local noresume noswap i915.modeset=1 nmi_watchdog=panic,lapic disablevmx=off"
 CONFIG_SYS_CONSOLE_INFO_QUIET=y
 CONFIG_SPL_LOG=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_LAST_STAGE_INIT=y
 CONFIG_BLOBLIST=y
 # CONFIG_TPL_BLOBLIST is not set
+CONFIG_BLOBLIST_SIZE=0x30000
 CONFIG_BLOBLIST_ADDR=0x100000
 CONFIG_HANDOFF=y
 CONFIG_TPL_SYS_MALLOC_SIMPLE=y
@@ -74,8 +77,10 @@ CONFIG_SYSCON=y
 CONFIG_SPL_OF_TRANSLATE=y
 CONFIG_INTEL_ACPIGEN=y
 CONFIG_CPU=y
+CONFIG_BOARD=y
 CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_DW=y
+CONFIG_MISC=y
 CONFIG_TPL_MISC=y
 CONFIG_CROS_EC=y
 CONFIG_CROS_EC_LPC=y
@@ -87,7 +92,9 @@ CONFIG_PINCTRL=y
 CONFIG_DEBUG_UART_SHIFT=2
 CONFIG_SYS_NS16550=y
 CONFIG_SOUND=y
+CONFIG_SOUND_DA7219=y
 CONFIG_SOUND_I8254=y
+CONFIG_SOUND_MAX98357A=y
 CONFIG_SOUND_RT5677=y
 CONFIG_SPI=y
 CONFIG_ICH_SPI=y
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#79 lore raw

v3 cover dm: Add programatic generation of ACPI tables (part D)

In reply to Simon Glass

Hi Simon,

Quoted 17 lines · Simon Glass

Note: This is part D of this effort. With this, Coral includes all required ACPI tables.

At present on x86 U-Boot supports creating ACPI (Advanced Configuration and Power Interface) tables using the Intel ACPI Source Language (ASL) compiler.

This is good enough for basic operation but some devices need to add their information dynamically at runtime. An example is a device that needs to report its enable GPIO. This is described in the device tree, so we want to add code in the driver to convert that device-tree description into an ACPI description for use on Linux.

This series adds support for generation of ACPI tables and fragments by devices. The core support is built into driver model.

Quoted 9 lines

Several files are brought over from coreboot to do the actual generation.

As an example of using this new feature, chromebook_coral is updated to write out a wide array of ACPI tables including DSDT and SSDT.

This initial version of the series lays out the general approach. More work is needed to figure out the difference between CONFIG_ACPIGEN and CONFIG_GENERATE_ACPI_TABLE with respect to what is built.

This series does not apply on u-boot-x86/next. Could you please rebase, and address Andy's comments?

Regards,
Bin