RFC: dm: Add programatic generation of ACPI tables
Subsystems (16)
cover RFC: dm: Add programatic generation of 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.
Simon Glass (108):
cpu: Support querying the address width
spi: Add SPI mode enums
tpm: cr50: Release locality on exit
tpm: cr50: Tidy up various comments
tpm: cr50: Use the correct GPIO binding
tpm: Don't cleanup unless an error happens
dm: pci: Allow disabling auto-config for a device
x86: Correct wording of coreboot source code
x86: apl: Move p2sb ofdata reading to the correct method
pci: Adjust dm_pci_read_bar32() to return errors correctly
x86: apl: Add Global NVS table header
dm: core: Add basic ACPI support
acpi: Add a binding for ACPI settings in the device tree
acpi: Add a simple sandbox test
x86: Move acpi_table header to main include/ directory
acpi: Add an __ACPI__ preprocessor symbol
acpi: Add a central location for table version numbers
acpi: Add support for DMAR
acpi: Move acpi_fill_header() to generic code
acpi: Add a method to write tables for a device
acpi: Convert part of acpi_table to use acpi_ctx
x86: Allow devices to write ACPI tables
acpi: Drop code for missing XSDT from acpi_write_rsdp()
acpi: Move acpi_add_table() to generic code
acpi: Put table-setup code in its own function
acpi: Move the xsdt pointer to acpi_ctx
acpi: Add an acpi command
acpi: Add some tables required by the generation code
acpi: Add generation code for devices
acpi: Add functions to generate ACPI code
gpio: Add a method to convert a GPIO to ACPI
irq: Add a method to convert an interrupt to ACPI
acpi: Add support for SSDT generation
x86: acpi: Move MADT up a bit
acpi: Record the items added to SSDT
acpi: Support ordering SSDT data by device
x86: Allow devices to write an SSDT
acpi: Add support for DSDT generation
x86: Allow devices to write to DSDT
dm: core: Add an ACPI name for the root node
dm: acpi: Enhance acpi_get_name()
acpi: Add an acpi split command
acpi: Allow creating the GNVS to fail
dtoc: Support ACPI paths in of-platdata
acpi: mmc: Generate ACPI info for the PCI SD Card
sound: Add an ACPI driver for Dialog Semicondutor da7219
sound: Add an ACPI driver for Maxim MAX98357ac
x86: pinctrl: Add a way to get the pinctrl reg address
x86: pinctrl: Update comment for intel_pinctrl_get_pad()
x86: pinctrl: Add multi-ACPI control
x86: pinctrl: Set up itss in the probe() method
x86: pinctrl: Drop the acpi_name member
dm: core: Add a way of overriding the ACPI device path
x86: gpio: Add support for obtaining ACPI info for a GPIO
i2c: designware_i2c: Support ACPI table generation
i2c: Add a generic driver to generate ACPI info
p2sb: Add a method to hide the bus
x86: apl: Support set_hide() in p2sb driver
x86: apl: Hide the p2sb on exit from U-Boot
pmc: Move common registers to the header file
x86: irq: Support flags for acpi_gpe
x86: Add debugging to table writing
x86: Rename board_final_cleanup() to board_final_init()
acpi: Enable ACPI table generation by default on 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: coral: Add ACPI tables for coral
x86: acpi: Support external GNVS tables
x86: acpi: Expand the GNVS
x86: Add wake sources for the acpi_gpe driver
x86: Add a config for the systemagent PCIEX regions size
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: Add a common global NVS structure
cpu: Convert the methods to use a const udevice *
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
x86: acpi: Add common Intel ACPI tables
x86: Support Atom SoCs using SWSMISCI rather than the SWSCI
x86: apl: Add a check for reading the FSP-S config
x86: apl: Store FSP-S config for later use
p2sb: Add some definitions used for ACPI
x86: apl: Add support for hostbridge ACPI generation
x86: apl: Generate required ACPI tables
x86: acpi: Add support for additional DMAR tables
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: Add a way to add to the e820 memory table
x86: Notify the FSP of the 'end firmware' event
x86: Add a layout for Chrome OS verified boot
x86: Correct the assembly guard in e802.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: coral: Update config and device tree for ACPI
arch/Kconfig | 1 + arch/nios2/cpu/cpu.c | 8 +- arch/sandbox/dts/test.dts | 14 + arch/sandbox/include/asm/acpi_table.h | 9 + arch/sandbox/include/asm/global_data.h | 1 + arch/x86/Kconfig | 47 + arch/x86/cpu/acpi_gpe.c | 22 + arch/x86/cpu/apollolake/Kconfig | 4 + arch/x86/cpu/apollolake/Makefile | 1 + arch/x86/cpu/apollolake/acpi.c | 437 +++++ arch/x86/cpu/apollolake/cpu.c | 27 +- arch/x86/cpu/apollolake/fsp_s.c | 246 +-- arch/x86/cpu/apollolake/hostbridge.c | 104 + arch/x86/cpu/apollolake/lpc.c | 16 + arch/x86/cpu/apollolake/p2sb.c | 73 +- arch/x86/cpu/apollolake/pmc.c | 8 +- arch/x86/cpu/baytrail/acpi.c | 6 +- arch/x86/cpu/baytrail/cpu.c | 4 +- arch/x86/cpu/broadwell/cpu_full.c | 4 +- arch/x86/cpu/coreboot/coreboot.c | 4 +- arch/x86/cpu/coreboot/timestamp.c | 4 +- arch/x86/cpu/cpu.c | 23 +- arch/x86/cpu/cpu_x86.c | 6 +- arch/x86/cpu/efi/app.c | 2 +- arch/x86/cpu/i386/cpu.c | 23 + arch/x86/cpu/intel_common/Makefile | 5 + arch/x86/cpu/intel_common/acpi.c | 441 +++++ arch/x86/cpu/intel_common/cpu.c | 60 + arch/x86/cpu/intel_common/generic_wifi.c | 119 ++ arch/x86/cpu/intel_common/intel_opregion.c | 168 ++ arch/x86/cpu/ivybridge/model_206ax.c | 5 +- arch/x86/cpu/mtrr.c | 12 + arch/x86/cpu/qemu/cpu.c | 4 +- arch/x86/cpu/quark/acpi.c | 6 +- arch/x86/cpu/quark/quark.c | 2 +- arch/x86/cpu/tangier/acpi.c | 6 +- arch/x86/dts/chromebook_coral.dts | 207 +- arch/x86/include/asm/acpi/chromeos.asl | 110 ++ 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/vbnv_layout.h | 41 + arch/x86/include/asm/acpi_table.h | 393 +--- arch/x86/include/asm/arch-apollolake/acpi.h | 13 + .../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 | 44 + arch/x86/include/asm/arch-apollolake/gpe.h | 134 ++ arch/x86/include/asm/arch-apollolake/gpio.h | 3 + arch/x86/include/asm/arch-apollolake/iomap.h | 17 + arch/x86/include/asm/arch-apollolake/pm.h | 56 +- .../include/asm/arch-apollolake/soc_config.h | 221 +++ .../include/asm/arch-apollolake/systemagent.h | 6 + .../x86/include/asm/arch-coreboot/timestamp.h | 4 +- arch/x86/include/asm/cpu.h | 9 + arch/x86/include/asm/cpu_common.h | 32 + arch/x86/include/asm/cpu_x86.h | 4 +- arch/x86/include/asm/e820.h | 3 +- arch/x86/include/asm/fsp/fsp_api.h | 15 +- arch/x86/include/asm/global_data.h | 2 + arch/x86/include/asm/intel_acpi.h | 25 + arch/x86/include/asm/intel_gnvs.h | 43 + arch/x86/include/asm/intel_opregion.h | 247 +++ arch/x86/include/asm/intel_pinctrl.h | 19 +- arch/x86/include/asm/intel_pinctrl_defs.h | 2 - arch/x86/include/asm/smm.h | 36 + arch/x86/lib/acpi.c | 2 +- arch/x86/lib/acpi_s3.c | 2 +- arch/x86/lib/acpi_table.c | 723 +++++-- arch/x86/lib/fsp/fsp_common.c | 18 +- arch/x86/lib/fsp/fsp_dram.c | 16 + arch/x86/lib/fsp/fsp_graphics.c | 28 + arch/x86/lib/tables.c | 37 +- arch/x86/lib/zimage.c | 2 +- board/google/chromebook_coral/Kconfig | 2 +- board/google/chromebook_coral/Makefile | 1 + .../chromebook_coral/baseboard_dptf.asl | 71 + board/google/chromebook_coral/coral.c | 104 + 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 + cmd/Kconfig | 14 + cmd/Makefile | 1 + cmd/acpi.c | 190 ++ configs/chromebook_coral_defconfig | 17 +- configs/sandbox_defconfig | 4 + doc/device-tree-bindings/chosen.txt | 27 + doc/device-tree-bindings/device.txt | 77 + .../gpio/intel,apl-gpio.txt | 2 +- doc/device-tree-bindings/i2c/generic-acpi.txt | 42 + .../interrupt-controller/intel,acpi-gpe.txt | 2 +- doc/device-tree-bindings/pci/x86-pci.txt | 24 + doc/device-tree-bindings/sound/da7219.txt | 113 ++ doc/device-tree-bindings/sound/max98357a.txt | 22 + drivers/core/Kconfig | 9 + drivers/core/Makefile | 1 + drivers/core/acpi.c | 328 ++++ drivers/core/root.c | 13 + drivers/cpu/bmips_cpu.c | 8 +- drivers/cpu/cpu-uclass.c | 8 +- drivers/cpu/cpu_sandbox.c | 9 +- drivers/cpu/imx8_cpu.c | 8 +- drivers/cpu/mpc83xx_cpu.c | 17 +- drivers/cpu/riscv_cpu.c | 6 +- drivers/gpio/gpio-uclass.c | 21 + drivers/gpio/intel_gpio.c | 46 +- drivers/i2c/Makefile | 3 + drivers/i2c/acpi_i2c.c | 228 +++ drivers/i2c/acpi_i2c.h | 15 + drivers/i2c/designware_i2c.c | 25 + drivers/i2c/designware_i2c.h | 15 + drivers/i2c/designware_i2c_pci.c | 104 +- drivers/i2c/i2c-uclass.c | 14 + drivers/misc/irq-uclass.c | 18 +- drivers/misc/p2sb-uclass.c | 26 +- drivers/mmc/pci_mmc.c | 76 +- drivers/pci/pci-uclass.c | 11 +- drivers/pinctrl/intel/Kconfig | 4 + drivers/pinctrl/intel/pinctrl.c | 21 +- drivers/pinctrl/intel/pinctrl_apl.c | 4 - drivers/power/acpi_pmc/acpi-pmc-uclass.c | 9 - drivers/sound/Kconfig | 18 + drivers/sound/Makefile | 2 + drivers/sound/da7219.c | 115 ++ drivers/sound/max98357a.c | 109 ++ drivers/tpm/cr50_i2c.c | 83 +- drivers/tpm/tpm-uclass.c | 13 +- include/acpi_device.h | 746 ++++++++ include/acpi_s3.h | 4 + include/acpi_table.h | 724 +++++++ include/acpigen.h | 482 +++++ include/asm-generic/gpio.h | 27 + include/bloblist.h | 8 + include/cpu.h | 18 +- include/dm/acpi.h | 190 ++ include/dm/device.h | 7 +- include/dm/uclass-id.h | 1 + .../interrupt-controller/x86-irq.h | 14 + include/i2c.h | 17 + include/irq.h | 43 + include/log.h | 2 + include/p2sb.h | 42 +- include/power/acpi_pmc.h | 14 + include/spi.h | 33 + lib/Makefile | 1 + lib/acpi/Makefile | 6 + lib/acpi/acpi_device.c | 1203 ++++++++++++ lib/acpi/acpi_table.c | 258 +++ lib/acpi/acpigen.c | 1683 +++++++++++++++++ lib/efi_loader/efi_acpi.c | 2 +- scripts/Makefile.lib | 4 +- test/dm/Makefile | 1 + test/dm/acpi.c | 478 +++++ test/dm/cpu.c | 1 + tools/dtoc/dtb_platdata.py | 4 +- tools/dtoc/dtoc_test_simple.dts | 1 + tools/dtoc/test_dtoc.py | 3 + 194 files changed, 15704 insertions(+), 1014 deletions(-) create mode 100644 arch/sandbox/include/asm/acpi_table.h 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/acpi/vbnv_layout.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/global_nvs.h create mode 100644 arch/x86/include/asm/arch-apollolake/gpe.h create mode 100644 arch/x86/include/asm/arch-apollolake/soc_config.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 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 create mode 100644 cmd/acpi.c create mode 100644 doc/device-tree-bindings/device.txt create mode 100644 doc/device-tree-bindings/i2c/generic-acpi.txt create mode 100644 doc/device-tree-bindings/sound/da7219.txt create mode 100644 doc/device-tree-bindings/sound/max98357a.txt create mode 100644 drivers/core/acpi.c create mode 100644 drivers/i2c/acpi_i2c.c create mode 100644 drivers/i2c/acpi_i2c.h create mode 100644 drivers/sound/da7219.c create mode 100644 drivers/sound/max98357a.c create mode 100644 include/acpi_device.h create mode 100644 include/acpi_table.h create mode 100644 include/acpigen.h create mode 100644 include/dm/acpi.h create mode 100644 include/dt-bindings/interrupt-controller/x86-irq.h create mode 100644 lib/acpi/Makefile create mode 100644 lib/acpi/acpi_device.c create mode 100644 lib/acpi/acpi_table.c create mode 100644 lib/acpi/acpigen.c create mode 100644 test/dm/acpi.c
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 1/108 cpu: Support querying the address width
Different CPUs may support different address widths, meaning the amount of memory they can address. Add a property for this to the cpu_info struct.
---
drivers/cpu/cpu_sandbox.c | 1 + include/cpu.h | 2 ++ test/dm/cpu.c | 1 + 3 files changed, 4 insertions(+)
drivers/cpu/cpu_sandbox.c +1 -0
@@ -19,6 +19,7 @@ int cpu_sandbox_get_info(struct udevice *dev, struct cpu_info *info) { info->cpu_freq =42 *42 *42 *42 *42 ; info->features =0x42424242 ; + info->address_width =IS_ENABLED (CONFIG_PHYS_64BIT ) ?64 :32 ;return 0 ; }
include/cpu.h +2 -0
@@ -44,10 +44,12 @@ enum {* * @cpu_freq: Current CPU frequency in Hz * @features: Flags for supported CPU features +* @address_width: Width of the CPU address space in bits (e.g. 32) */ struct cpu_info {ulong cpu_freq;ulong features; +uint address_width; };struct cpu_ops {
test/dm/cpu.c +1 -0
@@ -33,6 +33,7 @@ static int dm_test_cpu(struct unit_test_state *uts)ut_assertok (cpu_get_info (dev, &info));ut_asserteq (info.cpu_freq,42 *42 *42 *42 *42 );ut_asserteq (info.features,0x42424242 ); +ut_asserteq (info.address_width,32 );ut_asserteq (cpu_get_count (dev),42 );
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 1/108 cpu: Support querying the address width
Quoted 4 lines · Simon Glass
Different CPUs may support different address widths, meaning the amount of memory they can address. Add a property for this to the
cpu_infostruct.
Quoted 8 lines
Signed-off-by Simon Glass <[email protected]>---
drivers/cpu/cpu_sandbox.c | 1 + include/cpu.h | 2 ++ test/dm/cpu.c | 1 + 3 files changed, 4 insertions(+)
PATCH 2/108 spi: Add SPI mode enums
In reply to Simon GlassWith ACPI we need to describe the settings of the SPI bus. Add enums to handle this.
---
include/spi.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
include/spi.h +33 -0
@@ -62,6 +62,39 @@ struct dm_spi_slave_platdata { uint mode; }; +/** +* enum spi_clock_phase - indicates the clock phase to use for SPI (CPHA) +* +* @SPI_CLOCK_PHASE_FIRST: Data sampled on the first phase +* @SPI_CLOCK_PHASE_SECOND: Data sampled on the second phase +*/ +enum spi_clock_phase { +SPI_CLOCK_PHASE_FIRST , +SPI_CLOCK_PHASE_SECOND +}; + +/** +* enum spi_wire_mode - indicates the number of wires used for SPI +* +* @SPI_4_WIRE_MODE: Normal bidirectional mode with MOSI and MISO +* @SPI_3_WIRE_MODE: Unidirectional version with a single data line SISO +*/ +enum spi_wire_mode { +SPI_4_WIRE_MODE , +SPI_3_WIRE_MODE +}; + +/** +* enum spi_polarity - indicates the polarity of the SPI bus (CPOL) +* +* @SPI_POLARITY_LOW: Clock is low in idle state +* @SPI_POLARITY_HIGH: Clock is high in idle state +*/ +enum spi_polarity { +SPI_POLARITY_LOW , +SPI_POLARITY_HIGH +}; +#endif /* CONFIG_DM_SPI */ /**
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 2/108 spi: Add SPI mode enums
Quoted 10 lines · Simon Glass
With ACPI we need to describe the settings of the SPI bus. Add enums to handle this.
Signed-off-by Simon Glass <[email protected]>---
include/spi.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
PATCH 3/108 tpm: cr50: Release locality on exit
In reply to Simon GlassAt present the cr50 driver claims the locality and does not release it for Linux. This causes problems. Fix this by tracking what is claimed, and adding a 'remove' method.
---
drivers/tpm/cr50_i2c.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/tpm/cr50_i2c.c +11 -2
@@ -208,7 +208,7 @@ static int release_locality(struct udevice *dev, int force)cr50_i2c_write (dev, addr, &buf,1 ); } - priv->locality =0 ; + priv->locality =-1 ;return 0 ; }
@@ -500,6 +500,7 @@ static int process_reset(struct udevice *dev)static int claim_locality (struct udevice *dev,int loc) {const u8 mask =TPM_ACCESS_VALID |TPM_ACCESS_ACTIVE_LOCALITY ; +struct cr50_priv *priv =dev_get_priv (dev);u8 access;int ret;
@@ -526,6 +527,7 @@ static int claim_locality(struct udevice *dev, int loc)return -EPERM ; }log_info ("Claimed locality %d\n" , loc); + priv->locality = loc;return 0 ; }
@@ -560,7 +562,11 @@ static int cr50_i2c_open(struct udevice *dev)static int cr50_i2c_cleanup (struct udevice *dev) { -release_locality (dev,1 ); +struct cr50_priv *priv =dev_get_priv (dev); + +printf ("%s: cleanup %d\n" , __func__, priv->locality); +if (priv->locality !=-1 ) +release_locality (dev,1 );return 0 ; }
@@ -632,6 +638,7 @@ static int cr50_i2c_probe(struct udevice *dev)return log_msg_ret ("vendor-id" , -EXDEV ); } priv->vendor = vendor; + priv->locality =-1 ;return 0 ; }
@@ -656,5 +663,7 @@ U_BOOT_DRIVER(cr50_i2c) = { .ops = &cr50_i2c_ops, .ofdata_to_platdata = cr50_i2c_ofdata_to_platdata, .probe = cr50_i2c_probe, + .remove = cr50_i2c_cleanup, .priv_auto_alloc_size = sizeof(struct cr50_priv), + .flags = DM_FLAG_OS_PREPARE, };
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 3/108 tpm: cr50: Release locality on exit
Quoted 11 lines · Simon Glass
At present the cr50 driver claims the locality and does not release it for Linux. This causes problems. Fix this by tracking what is claimed, and adding a 'remove' method.
Signed-off-by Simon Glass <[email protected]>---
drivers/tpm/cr50_i2c.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
PATCH 4/108 tpm: cr50: Tidy up various comments
In reply to Simon GlassAdd a comment for the private structure and drop the incorrect coreboot reference in one function.
---
drivers/tpm/cr50_i2c.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/tpm/cr50_i2c.c +11 -2
@@ -34,6 +34,15 @@ enum { CR50_MAX_BUF_SIZE = 63, }; +/** +* struct cr50_priv - Private driver data +* +* @ready_gpio: GPIO to use to check if the TPM is ready +* @irq: IRQ to use check if the TPM is ready (has priority over @ready_gpio) +* @locality: Currenttly claimed locality (-1 if none) +* @vendor: vendor: Vendor ID for TPM +* @use_irq: true to use @irq, false to use @ready if available +*/ struct cr50_priv {struct gpio_desc ready_gpio;struct irq irq;
@@ -493,8 +502,8 @@ static int process_reset(struct udevice *dev) }/* -* Locality could be already claimed (if this is a later coreboot stage and -* the RO did not release it), or not yet claimed, if this is verstage or the +* Locality could be already claimed (if this is a later U-Boot phase and +* RO did not release it), or not yet claimed, if this is TPL or the * older RO did release it. */ static int claim_locality (struct udevice *dev,int loc)
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 4/108 tpm: cr50: Tidy up various comments
Quoted 10 lines · Simon Glass
Add a comment for the private structure and drop the incorrect coreboot reference in one function.
Signed-off-by Simon Glass <[email protected]>---
drivers/tpm/cr50_i2c.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
I believe this one needs rebase as the coreboot comment was already pointed out and corrected in previous series.
Regards,
Bin
PATCH 5/108 tpm: cr50: Use the correct GPIO binding
In reply to Simon GlassThis device should use ready-gpios rather than ready-gpio. Fix it.
---
arch/x86/dts/chromebook_coral.dts | 2 +- doc/device-tree-bindings/gpio/intel,apl-gpio.txt | 2 +- .../interrupt-controller/intel,acpi-gpe.txt | 2 +- drivers/tpm/cr50_i2c.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
arch/x86/dts/chromebook_coral.dts +1 -1
@@ -292,7 +292,7 @@ reg = <0x50>; compatible = "google,cr50"; u-boot,i2c-offset-len = <0>; - ready-gpio = <&gpio_n 28 GPIO_ACTIVE_LOW>; + ready-gpios = <&gpio_n 28 GPIO_ACTIVE_LOW>; interrupts-extended = <&acpi_gpe 0x3c 0>; }; };
doc/device-tree-bindings/gpio/intel,apl-gpio.txt +1 -1
@@ -47,7 +47,7 @@ Example: reg = <0x50>; compatible = "google,cr50"; u-boot,i2c-offset-len = <0>; - ready-gpio = <&gpio_n GPIO_28 GPIO_ACTIVE_LOW>; + ready-gpios = <&gpio_n GPIO_28 GPIO_ACTIVE_LOW>; }; };
doc/device-tree-bindings/interrupt-controller/intel,acpi-gpe.txt +1 -1
@@ -25,6 +25,6 @@ Example: tpm at 50 { reg = <0x50>; compatible = "google,cr50"; - ready-gpio = <&gpio_n 0x1c GPIO_ACTIVE_LOW>; + ready-gpios = <&gpio_n 0x1c GPIO_ACTIVE_LOW>; interrupts-extended = <&acpi_gpe 0x3c 0>; };
drivers/tpm/cr50_i2c.c +1 -1
@@ -608,7 +608,7 @@ static int cr50_i2c_ofdata_to_platdata(struct udevice *dev) priv->irq = irq; priv->use_irq = true; }else { - ret =gpio_request_by_name (dev,"ready-gpio" ,0 , + ret =gpio_request_by_name (dev,"ready-gpios" ,0 , &priv->ready_gpio,GPIOD_IS_IN );if (ret) { log_warning("Cr50 does not have an ready GPIO/interrupt (err=%d)\n",
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 5/108 tpm: cr50: Use the correct GPIO binding
Quoted 2 lines · Simon Glass
This device should use ready-gpios rather than ready-gpio. Fix it.
Where does this requirement come from? Is this coming from the Linux kernel bindings?
Quoted 10 lines
Signed-off-by Simon Glass <[email protected]>---
arch/x86/dts/chromebook_coral.dts | 2 +- doc/device-tree-bindings/gpio/intel,apl-gpio.txt | 2 +- .../interrupt-controller/intel,acpi-gpe.txt | 2 +- drivers/tpm/cr50_i2c.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
PATCH 5/108 tpm: cr50: Use the correct GPIO binding
Hi Bin,
Quoted 7 lines · Bin Meng
Quoted 2 lines · Simon Glass
This device should use ready-gpios rather than ready-gpio. Fix it.
Where does this requirement come from? Is this coming from the Linux kernel bindings?
Yes it seems to be the way things are done in Linux.
Quoted 5 lines
Quoted 5 lines
Signed-off-by Simon Glass <[email protected]>---
Quoted 8 lines
Quoted 6 lines
arch/x86/dts/chromebook_coral.dts | 2 +- doc/device-tree-bindings/gpio/intel,apl-gpio.txt | 2 +- .../interrupt-controller/intel,acpi-gpe.txt | 2 +- drivers/tpm/cr50_i2c.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)Reviewed-by Bin Meng <[email protected]>
Regards,
Simon
PATCH 6/108 tpm: Don't cleanup unless an error happens
In reply to Simon GlassAt present the cleanup() method is called on every transfer. It should only be called on failing transfers. Fix this and tidy up the error handling a little.
---
drivers/tpm/tpm-uclass.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/tpm/tpm-uclass.c +10 -3
@@ -72,7 +72,7 @@ int tpm_xfer(struct udevice *dev, const uint8_t *sendbuf, size_t send_size,struct tpm_ops *ops =tpm_get_ops (dev);ulong start, stop;uint count, ordinal; -int ret, ret2; +int ret, ret2 =0 ;if (ops->xfer)return ops->xfer (dev, sendbuf, send_size, recvbuf, recv_size);
@@ -120,9 +120,16 @@ int tpm_xfer(struct udevice *dev, const uint8_t *sendbuf, size_t send_size, } }while (ret); - ret2 = ops->cleanup ? ops->cleanup (dev) :0 ; +if (ret) { +if (ops->cleanup) { + ret2 = ops->cleanup (dev); +if (ret2) +return log_msg_ret ("cleanup" , ret2); + } +return log_msg_ret ("xfer" , ret); + } -return ret2 ? ret2 : ret; +return 0 ; }UCLASS_DRIVER (tpm) = {
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 6/108 tpm: Don't cleanup unless an error happens
Quoted 11 lines · Simon Glass
At present the
cleanup()method is called on every transfer. It should only be called on failing transfers. Fix this and tidy up the error handling a little.Signed-off-by Simon Glass <[email protected]>---
drivers/tpm/tpm-uclass.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
PATCH 7/108 dm: pci: Allow disabling auto-config for a device
In reply to Simon GlassAdd a means to avoid configuring a device when needed. Add an explanation of why this is useful to the binding file.
---
doc/device-tree-bindings/pci/x86-pci.txt | 24 ++++++++++++++++++++++++ drivers/pci/pci-uclass.c | 2 ++ 2 files changed, 26 insertions(+)
doc/device-tree-bindings/pci/x86-pci.txt +24 -0
@@ -10,6 +10,17 @@ Optional properties: configuration in TPL/SPL to reduce code size and boot time, since these phases only know about a small subset of PCI devices. +For PCI devices the following optional property is available: + +- pci,no-autoconfig : Don't automatically configure this PCI device at all. + This is used when the device is statically configured and must maintain + this same config throughout the boot process. An example is a serial + UART being used to debug PCI configuration, since reconfiguring it stops + the UART from working until the driver is re-probed, and this can cause + output to be lost. This should not generally be used in production code, + although it is often harmless. + + Example: pci {
@@ -21,4 +32,17 @@ pci { 0x42000000 0x0 0xb0000000 0xb0000000 0 0x10000000 0x01000000 0x0 0x1000 0x1000 0 0xefff>; u-boot,skip-auto-config-until-reloc; + + + serial: serial at 18,2 { + reg = <0x0200c210 0 0 0 0>; + u-boot,dm-pre-reloc; + compatible = "intel,apl-ns16550"; + early-regs = <0xde000000 0x20>; + reg-shift = <2>; + clock-frequency = <1843200>; + current-speed = <115200>; + acpi,name = "URT3"; + pci,no-autoconfig; + }; };
drivers/pci/pci-uclass.c +2 -0
@@ -535,6 +535,8 @@ int pci_auto_config_devices(struct udevice *bus)int ret;debug ("%s: device %s\n" , __func__, dev->name); +if (dev_read_bool (dev,"pci,no-autoconfig" )) +continue ; ret =dm_pciauto_config_device (dev);if (ret <0 )return ret;
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 7/108 dm: pci: Allow disabling auto-config for a device
Hi Simon,
Quoted 4 lines · Simon Glass
Add a means to avoid configuring a device when needed. Add an explanation of why this is useful to the binding file.
Does disabling CONFIG_PCI_PNP not help?
Quoted 7 lines
Signed-off-by Simon Glass <[email protected]>---
doc/device-tree-bindings/pci/x86-pci.txt | 24 ++++++++++++++++++++++++ drivers/pci/pci-uclass.c | 2 ++ 2 files changed, 26 insertions(+)
Regards,
Bin
PATCH 7/108 dm: pci: Allow disabling auto-config for a device
Hi Bin,
Quoted 10 lines · Bin Meng
Hi Simon,
Quoted 4 lines · Simon Glass
Add a means to avoid configuring a device when needed. Add an explanation of why this is useful to the binding file.
Does disabling
CONFIG_PCI_PNPnot help?
That is for all devices. Here we just want the UART to stay where it is so that we can debug serial drivers, FSP-S, etc. If the UART moves then any output after that hangs the machine until we reinit the serial driver.
Quoted 8 lines
Quoted 8 lines
Signed-off-by Simon Glass <[email protected]>---
doc/device-tree-bindings/pci/x86-pci.txt | 24 ++++++++++++++++++++++++ drivers/pci/pci-uclass.c | 2 ++ 2 files changed, 26 insertions(+)
Regards,
SImon
PATCH 7/108 dm: pci: Allow disabling auto-config for a device
Hi Simon,
Quoted 13 lines · Simon Glass
Hi Bin,
Quoted 9 lines · Bin Meng
Hi Simon,
Quoted 4 lines · Simon Glass
Add a means to avoid configuring a device when needed. Add an explanation of why this is useful to the binding file.
Quoted 6 lines
Quoted 1 line
Does disabling
CONFIG_PCI_PNPnot help?That is for all devices. Here we just want the UART to stay where it is so that we can debug serial drivers, FSP-S, etc. If the UART moves then any output after that hangs the machine until we reinit the serial driver.
OK, I think this is for debugging purpose, right? As you must have get Coral boot for some time, and this is only for retaining the console debug output?
Regards,
Bin
PATCH 7/108 dm: pci: Allow disabling auto-config for a device
Hi Bin,
Quoted 19 lines · Bin Meng
Hi Simon,
Quoted 15 lines · Simon Glass
Hi Bin,
Quoted 10 lines · Bin Meng
Hi Simon,
Quoted 4 lines · Simon Glass
Add a means to avoid configuring a device when needed. Add an explanation of why this is useful to the binding file.
Does disabling
CONFIG_PCI_PNPnot help?
Quoted 8 lines
Quoted 4 lines
That is for all devices. Here we just want the UART to stay where it is so that we can debug serial drivers, FSP-S, etc. If the UART moves then any output after that hangs the machine until we reinit the serial driver.
OK, I think this is for debugging purpose, right? As you must have get Coral boot for some time, and this is only for retaining the console debug output?
Sort-of, but I've actually left it enabled. The problem is that if you get an error or any debug output very early after relocation in U-Boot, it hangs. I feel it is quite confusing for people to add a bit of debugging and have it crash.
Admittedly there is a very small window where this happens (roughly between arch_fsp_init_r() returning and initr_serial() being called. But i found it pretty annoying.
What do you think?
Also I'd like to change it to suppress console output when it is not allowed (and print a warning later), but haven't tried that yet.
Quoted 5 lines
Reviewed-by Bin Meng <[email protected]>Regards,
Bin
PATCH 7/108 dm: pci: Allow disabling auto-config for a device
Hi Simon,
Quoted 37 lines · Simon Glass
Hi Bin,
Quoted 19 lines · Bin Meng
Hi Simon,
Quoted 15 lines · Simon Glass
Hi Bin,
Quoted 10 lines · Bin Meng
Hi Simon,
Quoted 4 lines · Simon Glass
Add a means to avoid configuring a device when needed. Add an explanation of why this is useful to the binding file.
Does disabling
CONFIG_PCI_PNPnot help?Quoted 8 lines
Quoted 4 lines
That is for all devices. Here we just want the UART to stay where it is so that we can debug serial drivers, FSP-S, etc. If the UART moves then any output after that hangs the machine until we reinit the serial driver.
OK, I think this is for debugging purpose, right? As you must have get Coral boot for some time, and this is only for retaining the console debug output?
Sort-of, but I've actually left it enabled. The problem is that if you get an error or any debug output very early after relocation in U-Boot, it hangs. I feel it is quite confusing for people to add a bit of debugging and have it crash.
Quoted 6 lines
Admittedly there is a very small window where this happens (roughly between
arch_fsp_init_r()returning andinitr_serial()being called. But i found it pretty annoying.What do you think?
Sounds good to me for leaving it enabled by default.
Quoted 3 lines
Also I'd like to change it to suppress console output when it is not allowed (and print a warning later), but haven't tried that yet.
Regards,
Bin
PATCH 8/108 x86: Correct wording of coreboot source code
In reply to Simon GlassSome files are taken or modified from coreboot, but the files are no-longer part of the coreboot project. Fix the wording in a few places.
---
arch/x86/cpu/coreboot/timestamp.c | 4 ++-- arch/x86/include/asm/arch-coreboot/timestamp.h | 4 ++-- arch/x86/include/asm/intel_pinctrl_defs.h | 2 -- 3 files changed, 4 insertions(+), 6 deletions(-)
arch/x86/cpu/coreboot/timestamp.c +2 -2
@@ -1,8 +1,8 @@// SPDX-License-Identifier: GPL-2.0+ /* -* This file is part of the coreboot project. -* * Copyright (C) 2011 The ChromiumOS Authors. All rights reserved. +* +* Modified from the coreboot version */ #include <common.h>
arch/x86/include/asm/arch-coreboot/timestamp.h +2 -2
@@ -1,8 +1,8 @@/* SPDX-License-Identifier: GPL-2.0 */ /* -* This file is part of the coreboot project. -* * Copyright (C) 2011 The ChromiumOS Authors. All rights reserved. +* +* Taken from the coreboot version */ #ifndef __COREBOOT_TIMESTAMP_H__
arch/x86/include/asm/intel_pinctrl_defs.h +0 -2
@@ -1,7 +1,5 @@/* SPDX-License-Identifier: GPL-2.0 */ /* -* This file is part of the coreboot project. -* * Copyright (C) 2015-2016 Intel Corp. * Copyright 2019 Google LLC *
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 8/108 x86: Correct wording of coreboot source code
Quoted 4 lines · Simon Glass
Some files are taken or modified from coreboot, but the files are no-longer part of the coreboot project. Fix the wording in a few places.
Quoted 8 lines
Signed-off-by Simon Glass <[email protected]>---
arch/x86/cpu/coreboot/timestamp.c | 4 ++-- arch/x86/include/asm/arch-coreboot/timestamp.h | 4 ++-- arch/x86/include/asm/intel_pinctrl_defs.h | 2 -- 3 files changed, 4 insertions(+), 6 deletions(-)
PATCH 9/108 x86: apl: Move p2sb ofdata reading to the correct method
In reply to Simon GlassWith P2SB the initial BAR (base-address register) is set up by TPL and this is used unchanged right through U-Boot.
At present the reading of this address is split between the ofdata() and probe() methods. There are a few problems that are unique to the p2sb. One is that its children need to call pcr_read32(), etc. which needs to have the p2sb address correct. Also some of its children are pinctrl devices and pinctrl is used when any device is probed. So p2sb really needs to get its base address set up in ofdata_to_platdata(), before it is probed.
Another point is that reading the p2sb BAR will not work if the p2sb is hidden. The FSP-S seems to hide it, presumably to avoid confusing PCI enumeration.
Reading ofdata in ofdata_to_platdata() is the correct place anyway, so this is easy to fix.
Move the code into one place and use the early-regs property in all cases for simplicity and to avoid needing to probe any PCI devices just to read the BAR.
---
arch/x86/cpu/apollolake/p2sb.c | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-)
arch/x86/cpu/apollolake/p2sb.c +11 -22
@@ -92,27 +92,25 @@ int apl_p2sb_ofdata_to_platdata(struct udevice *dev)#if !CONFIG_IS_ENABLED (OF_PLATDATA )int ret; +u32 base[2 ]; + ret =dev_read_u32_array (dev,"early-regs" , base,ARRAY_SIZE (base)); +if (ret) +return log_msg_ret ("Missing/short early-regs" , ret); + plat->mmio_base = base[0 ]; +/* TPL sets up the initial BAR */ if (spl_phase () ==PHASE_TPL ) { -u32 base[2 ]; - -/* TPL sets up the initial BAR */ - ret =dev_read_u32_array (dev,"early-regs" , base, -ARRAY_SIZE (base)); -if (ret) -return log_msg_ret ("Missing/short early-regs" , ret); - plat->mmio_base = base[0 ]; plat->bdf =pci_get_devfn (dev);if (plat->bdf <0 )return log_msg_ret ("Cannot get p2sb PCI address" , - plat->bdf); + plat->bdf); } + upriv->mmio_base = plat->mmio_base;#else plat->mmio_base = plat->dtplat.early_regs[0 ]; plat->bdf =pci_ofplat_get_devfn (plat->dtplat.reg[0 ]); -#endif upriv->mmio_base = plat->mmio_base; -debug ("p2sb: mmio_base=%x\n" , (uint )plat->mmio_base); +#endif return 0 ; }
@@ -121,17 +119,8 @@ static int apl_p2sb_probe(struct udevice *dev) {if (spl_phase () ==PHASE_TPL )return apl_p2sb_early_init (dev); -else { -struct p2sb_platdata *plat =dev_get_platdata (dev); - - plat->mmio_base =dev_read_addr_pci (dev); -/* Don't set BDF since it should not be used */ -if (!plat->mmio_base || plat->mmio_base ==FDT_ADDR_T_NONE ) -return -EINVAL ; - -if (spl_phase () ==PHASE_SPL ) -return apl_p2sb_spl_init (dev); - } +else if (spl_phase () ==PHASE_SPL ) +return apl_p2sb_spl_init (dev);return 0 ; }
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 9/108 x86: apl: Move p2sb ofdata reading to the correct method
+Wolfgang Wallner
Quoted 23 lines · Simon Glass
With P2SB the initial BAR (base-address register) is set up by TPL and this is used unchanged right through U-Boot.
At present the reading of this address is split between the
ofdata()andprobe()methods. There are a few problems that are unique to the p2sb. One is that its children need to callpcr_read32(), etc. which needs to have the p2sb address correct. Also some of its children are pinctrl devices and pinctrl is used when any device is probed. So p2sb really needs to get its base address set up inofdata_to_platdata(), before it is probed.Another point is that reading the p2sb BAR will not work if the p2sb is hidden. The FSP-S seems to hide it, presumably to avoid confusing PCI enumeration.
Reading ofdata in
ofdata_to_platdata()is the correct place anyway, so this is easy to fix.Move the code into one place and use the early-regs property in all cases for simplicity and to avoid needing to probe any PCI devices just to read the BAR.
Quoted 6 lines
Signed-off-by Simon Glass <[email protected]>---
arch/x86/cpu/apollolake/p2sb.c | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-)
I think this one needs to be rebased.
I suspect it breaks Wolfgang's use case. Wolfgang, any comments?
Regards,
Bin
Antwort: Re: [PATCH 009/108] x86: apl: Move p2sb ofdata reading to the correct method
Hello Bin, Simon,
-----"Bin Meng" <[email protected]> schrieb: -----
Quoted 29 lines
+Wolfgang Wallner
Quoted 26 lines · Simon Glass
With P2SB the initial BAR (base-address register) is set up by TPL and this is used unchanged right through U-Boot.
At present the reading of this address is split between the
ofdata()andprobe()methods. There are a few problems that are unique to the p2sb. One is that its children need to callpcr_read32(), etc. which needs to have the p2sb address correct. Also some of its children are pinctrl devices and pinctrl is used when any device is probed. So p2sb really needs to get its base address set up inofdata_to_platdata(), before it is probed.Another point is that reading the p2sb BAR will not work if the p2sb is hidden. The FSP-S seems to hide it, presumably to avoid confusing PCI enumeration.
Reading ofdata in
ofdata_to_platdata()is the correct place anyway, so this is easy to fix.Move the code into one place and use the early-regs property in all cases for simplicity and to avoid needing to probe any PCI devices just to read the BAR.
Signed-off-by Simon Glass <[email protected]>---
Quoted 7 lines
Quoted 3 lines
arch/x86/cpu/apollolake/p2sb.c | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-)I think this one needs to be rebased.
I suspect it breaks Wolfgang's use case. Wolfgang, any comments?
Thanks for pointing this out.
As far as I understand, the patch changes the following for my use case (Coreboot + U-Boot, no TPL and no SPL):
* Before: plat->mmio_base was read from the PCI BAR in apl_p2sb_probe()
* After: plat->mmio_base is read from the "early-regs" device tree property in apl_p2sb_ofdata_to_platdata()
I think this is fine, Coreboot does not change the address in BAR0 and I can use the "early-regs" property in my device tree.
regards, Wolfgang
Tested on an Apollo Lake board with Coreboot + U-Boot.
PATCH 10/108 pci: Adjust dm_pci_read_bar32() to return errors correctly
In reply to Simon GlassAt present if reading a BAR returns 0xffffffff (e.g. the device is not present) then the value is masked and a different value is returned. This makes it harder to detect the problem when debugging.
Update the function to avoid masking in this case.
---
drivers/pci/pci-uclass.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/pci/pci-uclass.c +8 -1
@@ -1210,7 +1210,14 @@ u32 dm_pci_read_bar32(const struct udevice *dev, int barnum) bar =PCI_BASE_ADDRESS_0 + barnum *4 ;dm_pci_read_config32 (dev, bar, &addr); -if (addr &PCI_BASE_ADDRESS_SPACE_IO ) + +/* +* If we get an invalid address, return this so that comparisons with +* FDT_ADDR_T_NONE work correctly +*/ +if (addr ==0xffffffff ) +return addr; +else if (addr &PCI_BASE_ADDRESS_SPACE_IO )return addr &PCI_BASE_ADDRESS_IO_MASK ;else return addr &PCI_BASE_ADDRESS_MEM_MASK ;
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 10/108 pci: Adjust dm_pci_read_bar32() to return errors correctly
Quoted 5 lines · Simon Glass
At present if reading a BAR returns
0xffffffff(e.g. the device is not present) then the value is masked and a different value is returned. This makes it harder to detect the problem when debugging.
Quoted 8 lines
Update the function to avoid masking in this case.
Signed-off-by Simon Glass <[email protected]>---
drivers/pci/pci-uclass.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
PATCH 11/108 x86: apl: Add Global NVS table header
In reply to Simon GlassAdd the C version of this header. It includes a few Chrome OS bits which are disabled for a normal build.
---
.../include/asm/arch-apollolake/global_nvs.h | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 arch/x86/include/asm/arch-apollolake/global_nvs.h
arch/x86/include/asm/arch-apollolake/global_nvs.h new file +44 -0
@@ -0,0 +1,44 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2015-2017 Intel Corp. +* (Written by Lance Zhao <[email protected]> for Intel Corp.) +* Copyright Google LLC 2019 +* +* Modified from coreboot apollolake/include/soc/nvs.h +*/ + +#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 - coreboot Memory 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 unused[195 ]; +#ifdef CONFIG_CHROMEOS +/* ChromeOS specific (0x100 - 0xfff) */ +struct chromeos_acpi chromeos; +#else +u8 unused2[0xf00 ]; +#endif +}; +#ifdef CONFIG_CHROMEOS +check_member (acpi_global_nvs, chromeos,GNVS_CHROMEOS_ACPI_OFFSET ); +#endif + +#endif /* _GLOBAL_NVS_H_ */
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 11/108 x86: apl: Add Global NVS table header
Hi Simon,
Quoted 27 lines · Simon Glass
Add the C version of this header. It includes a few Chrome OS bits which are disabled for a normal build.
Signed-off-by Simon Glass <[email protected]>---
.../include/asm/arch-apollolake/global_nvs.h | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 arch/x86/include/asm/arch-apollolake/global_nvs.harch/x86/include/asm/arch-apollolake/global_nvs.h new file +10
-0@@ -0,0 +1,44 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2015-2017 Intel Corp. +* (Written by Lance Zhao <[email protected]> for Intel Corp.) +* Copyright Google LLC 2019 +* +* Modified from coreboot apollolake/include/soc/nvs.h +*/ + +#ifndef _GLOBAL_NVS_H_
arch/x86/include/asm/arch-apollolake/global_nvs.h line 20
Quoted 10 lines
arch/x86/include/asm/arch-apollolake/global_nvs.h new file +10
-0+#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 - coreboot Memory Console */
Is this needed for U-Boot?
Quoted 5 lines
arch/x86/include/asm/arch-apollolake/global_nvs.h new file +5
-0+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 */
arch/x86/include/asm/arch-apollolake/global_nvs.h line 35
Quoted 10 lines
arch/x86/include/asm/arch-apollolake/global_nvs.h new file +10
-0+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 unused[195 ]; +#ifdef CONFIG_CHROMEOS +/* ChromeOS specific (0x100 - 0xfff) */ +struct chromeos_acpi chromeos;
Where is this struct defined?
arch/x86/include/asm/arch-apollolake/global_nvs.h line 41
Quoted 6 lines
arch/x86/include/asm/arch-apollolake/global_nvs.h new file +6
-0+#else +u8 unused2[0xf00 ]; +#endif +}; +#ifdef CONFIG_CHROMEOS +check_member (acpi_global_nvs, chromeos,GNVS_CHROMEOS_ACPI_OFFSET );
Where is this GNVS_CHROMEOS_ACPI_OFFSET defined?
arch/x86/include/asm/arch-apollolake/global_nvs.h line 43
Quoted 2 lines
arch/x86/include/asm/arch-apollolake/global_nvs.h new file +2
-0+#endif +
Regards,
Bin
PATCH 12/108 dm: core: Add basic ACPI support
In reply to Simon GlassACPI (Advanced Configuration and Power Interface) is an Intel standard for specifying information about a platform. It is a little like device tree but considerably more complicated and with more backslashes. A primary difference is that it supports an interpreted bytecode language.
Driver model does not use ACPI for U-Boot's configuration, but it is convenient to have it support generation of ACPI tables for passing to Linux, etc.
As a starting point, add an optional set of ACPI operations to each device. Initially only a single operation is available, to obtain the ACPI name for the device. More operations are added later.
Enable ACPI for sandbox to ensure build coverage and so that we can add tests.
---
drivers/core/Kconfig | 9 ++++++ drivers/core/Makefile | 1 + drivers/core/acpi.c | 32 +++++++++++++++++++ include/dm/acpi.h | 73 +++++++++++++++++++++++++++++++++++++++++++ include/dm/device.h | 5 +++ 5 files changed, 120 insertions(+) create mode 100644 drivers/core/acpi.c create mode 100644 include/dm/acpi.h
drivers/core/Kconfig +9 -0
@@ -261,4 +261,13 @@ config DM_DEV_READ_INLINE bool default y if !OF_LIVE +config ACPIGEN + bool "Support ACPI table generation in driver model" + default y if SANDBOX || GENERATE_ACPI_TABLE + help + This option enables generation of ACPI tables using driver-model + devices. It adds a new operation struct to each driver, to support + things like generating device-specific tables and returning the ACPI + name of a device. + endmenu
drivers/core/Makefile +1 -0
@@ -3,6 +3,7 @@ # Copyright (c) 2013 Google, Inc obj-y += device.o fdtaddr.o lists.o root.o uclass.o util.o +obj-$(CONFIG_$(SPL_TPL_)ACPIGEN) += acpi.o obj-$(CONFIG_DEVRES) += devres.o obj-$(CONFIG_$(SPL_)DM_DEVICE_REMOVE) += device-remove.o obj-$(CONFIG_$(SPL_)SIMPLE_BUS) += simple-bus.o
drivers/core/acpi.c new file +32 -0
@@ -0,0 +1,32 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Core driver model support for ACPI table generation +* +* Copyright 2019 Google LLC +* Written by Simon Glass <[email protected]> +*/ + +#define LOG_CATEOGRY LOGC_ACPI + +#include <common.h> +#include <dm.h> +#include <dm/acpi.h> +#include <dm/root.h> + +int acpi_return_name (char *out_name,const char *name) +{ +strcpy (out_name, name); + +return 0 ; +} + +int acpi_get_name (const struct udevice *dev,char *out_name) +{ +struct acpi_ops *aops; + + aops =device_get_acpi_ops (dev); +if (aops && aops->get_name) +return aops->get_name (dev, out_name); + +return -ENOSYS ; +}
include/dm/acpi.h new file +73 -0
73 lines not on this page · raw message
include/dm/device.h +5 -0
@@ -240,6 +240,8 @@ struct udevice_id {* pointers defined by the driver, to implement driver functions required by * the uclass. * @flags: driver flags - see DM_FLAGS_... +* @acpi_ops: Advanced Configuration and Power Interface (ACPI) operations, +* allowing the device to add things to the ACPI tables passed to Linux */ struct driver {char *name;
@@ -259,6 +261,9 @@ struct driver {int per_child_platdata_auto_alloc_size;const void *ops;/* driver-specific operations */ uint32_t flags; +#if CONFIG_IS_ENABLED (ACPIGEN ) +struct acpi_ops *acpi_ops; +#endif };/* Declare a new U-Boot driver */
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 12/108 dm: core: Add basic ACPI support
Quoted 65 lines · Simon Glass
ACPI (Advanced Configuration and Power Interface) is an Intel standard for specifying information about a platform. It is a little like device tree but considerably more complicated and with more backslashes. A primary difference is that it supports an interpreted bytecode language.
Driver model does not use ACPI for U-Boot's configuration, but it is convenient to have it support generation of ACPI tables for passing to Linux, etc.
As a starting point, add an optional set of ACPI operations to each device. Initially only a single operation is available, to obtain the ACPI name for the device. More operations are added later.
Enable ACPI for sandbox to ensure build coverage and so that we can add tests.
Signed-off-by Simon Glass <[email protected]>---
drivers/core/Kconfig | 9 ++++++ drivers/core/Makefile | 1 + drivers/core/acpi.c | 32 +++++++++++++++++++ include/dm/acpi.h | 73 +++++++++++++++++++++++++++++++++++++++++++ include/dm/device.h | 5 +++ 5 files changed, 120 insertions(+) create mode 100644 drivers/core/acpi.c create mode 100644 include/dm/acpi.hdrivers/core/Kconfig +9
-0@@ -261,4 +261,13 @@ config DM_DEV_READ_INLINE bool default y if !OF_LIVE +config ACPIGEN + bool "Support ACPI table generation in driver model" + default y if SANDBOX || GENERATE_ACPI_TABLE + help + This option enables generation of ACPI tables using driver-model + devices. It adds a new operation struct to each driver, to support + things like generating device-specific tables and returning the ACPI + name of a device. + endmenudrivers/core/Makefile +1
-0@@ -3,6 +3,7 @@ # Copyright (c) 2013 Google, Inc obj-y += device.o fdtaddr.o lists.o root.o uclass.o util.o +obj-$(CONFIG_$(SPL_TPL_)ACPIGEN) += acpi.o obj-$(CONFIG_DEVRES) += devres.o obj-$(CONFIG_$(SPL_)DM_DEVICE_REMOVE) += device-remove.o obj-$(CONFIG_$(SPL_)SIMPLE_BUS) += simple-bus.odrivers/core/acpi.c new file +0
-0
drivers/core/acpi.c line 9
Quoted 9 lines
drivers/core/acpi.c new file +9
-0@@ -0,0 +1,32 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Core driver model support for ACPI table generation +* +* Copyright 2019 Google LLC +* Written by Simon Glass <[email protected]> +*/ + +#define LOG_CATEOGRY LOGC_ACPI
Need add this to log.h
drivers/core/acpi.c line 15
Quoted 6 lines
drivers/core/acpi.c new file +6
-0+ +#include <common.h> +#include <dm.h> +#include <dm/acpi.h> +#include <dm/root.h> +
Other than that,
PATCH 13/108 acpi: Add a binding for ACPI settings in the device tree
In reply to Simon GlassDevices need to report various identifiers in the ACPI tables. Rather than hard-coding these in drivers it is typically better to put them in the device tree.
Add a binding file to describe this.
---
doc/device-tree-bindings/device.txt | 37 +++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 doc/device-tree-bindings/device.txt
doc/device-tree-bindings/device.txt new file +37 -0
@@ -0,0 +1,37 @@ +Devices +======= + +Device bindings are described by their own individual binding files. + +U-Boot provides for some optional properties which are documented here. + + - acpi,has-power-resource : (boolean) true if this device has a power resource. + This causes a PRIC (ACPI PowerResource) to be written containing the + properties provided by this binding, to describe how to handle powering the + device up and down using GPIOs + - acpi,cid : Contains the string to use as the compatible ID (_CID) + - acpi,compatible : compatible string to report + - acpi,desc : Contains the string to use as the _DDN (DOS (Disk Operating + System) Device Name) + - acpi,hid : Contains the string to use as the HID (Human Interface Device) + identifier _HID + - acpi,hid-desc-reg-offset : HID register offset (for Human Interface Devices) + - acpi,probed : Tells U-Boot to add 'linux,probed' to the ACPI tables so that + Linux will not re-init the device + - acpi,uid : _UID value for device + + +Example +------- + +synaptics_touchpad: synaptics-touchpad at 2c { + compatible = "i2c-chip"; + reg = <0x2c>; + acpi,hid = "PNP0C50"; + acpi,cid = "PNP0C50"; + acpi,desc = "Synaptics Touchpad"; + interrupts-extended = <&acpi_gpe GPIO_18_IRQ + IRQ_TYPE_EDGE_FALLING>; + acpi,probed; + acpi,hid-desc-reg-offset = <0x20>; +};
Signature · 1 line
2.25.0.341.g760bfbb309-goog
Antwort: [PATCH 013/108] acpi: Add a binding for ACPI settings in the device tree
Hi Simon,
Quoted 7 lines
doc/device-tree-bindings/device.txt new file +7
-0+Devices +======= + +Device bindings are described by their own individual binding files. + +U-Boot provides for some optional properties which are documented here. +
doc/device-tree-bindings/device.txt line 17
Quoted 10 lines
doc/device-tree-bindings/device.txt new file +10
-0+ - acpi,has-power-resource : (boolean) true if this device has a power resource. + This causes a PRIC (ACPI PowerResource) to be written containing the + properties provided by this binding, to describe how to handle powering the + device up and down using GPIOs + - acpi,cid : Contains the string to use as the compatible ID (_CID) + - acpi,compatible : compatible string to report + - acpi,desc : Contains the string to use as the _DDN (DOS (Disk Operating + System) Device Name) + - acpi,hid : Contains the string to use as the HID (Human Interface Device) + identifier _HID
Nit: "_HID" in ACPI stands for "Hardware ID"
Quoted 4 lines
+ - acpi,hid-desc-reg-offset : HID register offset (for Human Interface Devices)
+ - acpi,probed : Tells U-Boot to add 'linux,probed' to the ACPI tables so that
+ Linux will not re-init the device
+ - acpi,uid :_UIDvalue for device
Would it make sense to automatically infer ACPI properties from existing device tree properties?
E.g. if the compatible string contains "hid-over-i2c", then _CID could be set to "PNP0C50".
And a "hid-over-i2c" device would also have a "hid-descr-addr" device tree property for the offset of the HID descriptor register which could be passed on in ACPI as part of the _DSM method.
Quoted 5 lines
doc/device-tree-bindings/device.txt new file +5
-0+ + +Example +------- +
doc/device-tree-bindings/device.txt line 36
Quoted 10 lines
doc/device-tree-bindings/device.txt new file +10
-0+synaptics_touchpad: synaptics-touchpad at 2c { + compatible = "i2c-chip"; + reg = <0x2c>; + acpi,hid = "PNP0C50"; + acpi,cid = "PNP0C50"; + acpi,desc = "Synaptics Touchpad"; + interrupts-extended = <&acpi_gpe GPIO_18_IRQ + IRQ_TYPE_EDGE_FALLING>; + acpi,probed; + acpi,hid-desc-reg-offset = <0x20>;
regards, Wolfgang
PATCH 13/108 acpi: Add a binding for ACPI settings in the device tree
Hi Wolfgang,
Quoted 14 lines · Wolfgang Wallner
Hi Simon,
Quoted 11 lines
doc/device-tree-bindings/device.txt new file +11
-0+Devices +======= + +Device bindings are described by their own individual binding files. + +U-Boot provides for some optional properties which are documented here. + + - acpi,has-power-resource : (boolean) true if this device has a power resource. + This causes a PRIC (ACPI PowerResource) to be written containing the + properties provided by this binding, to describe how to handle powering the + device up and down using GPIOs
Quoted 8 lines
doc/device-tree-bindings/device.txt line 17
Quoted 6 lines
+ - acpi,cid : Contains the string to use as the compatible ID (
_CID)
+ - acpi,compatible : compatible string to report
+ - acpi,desc : Contains the string to use as the_DDN(DOS (Disk Operatingdoc/device-tree-bindings/device.txt new file +3
-0+ System) Device Name) + - acpi,hid : Contains the string to use as the HID (Human Interface Device) + identifier _HIDNit: "
_HID" in ACPI stands for "Hardware ID"
OK thank you, will fix. I am trying to write things out in full since it is very hard to find out what all these different things mean.
Quoted 11 lines
Quoted 5 lines
+ - acpi,hid-desc-reg-offset : HID register offset (for Human Interface Devices)
+ - acpi,probed : Tells U-Boot to add 'linux,probed' to the ACPI tables so that
+ Linux will not re-init the device
+ - acpi,uid :_UIDvalue for deviceWould it make sense to automatically infer ACPI properties from existing device tree properties?
E.g. if the compatible string contains "hid-over-i2c", then
_CIDcould be set to "PNP0C50".
Yes we could do that. So is that true for all devices that use this i2c driver?
Quoted 3 lines
And a "hid-over-i2c" device would also have a "hid-descr-addr" device tree property for the offset of the HID descriptor register which could be passed on in ACPI as part of the
_DSMmethod.
Are you suggesting renaming acpi,hid-desc-reg-offset to hid-descr-addr?
Regards,
Simon
Antwort: Re: [PATCH 013/108] acpi: Add a binding for ACPI settings in the device tree
Hi Simon,
Quoted 28 lines
-----"Simon Glass" <[email protected]> schrieb: ----- Hi Wolfgang,
Quoted 14 lines · Wolfgang Wallner
Hi Simon,
Quoted 11 lines
doc/device-tree-bindings/device.txt new file +11
-0+Devices +======= + +Device bindings are described by their own individual binding files. + +U-Boot provides for some optional properties which are documented here. + + - acpi,has-power-resource : (boolean) true if this device has a power resource. + This causes a PRIC (ACPI PowerResource) to be written containing the + properties provided by this binding, to describe how to handle powering the + device up and down using GPIOsQuoted 8 lines
doc/device-tree-bindings/device.txt line 17
Quoted 6 lines
+ - acpi,cid : Contains the string to use as the compatible ID (
_CID)
+ - acpi,compatible : compatible string to report
+ - acpi,desc : Contains the string to use as the_DDN(DOS (Disk Operatingdoc/device-tree-bindings/device.txt new file +3
-0+ System) Device Name) + - acpi,hid : Contains the string to use as the HID (Human Interface Device) + identifier _HIDNit: "
_HID" in ACPI stands for "Hardware ID"
Quoted 2 lines
OK thank you, will fix. I am trying to write things out in full since it is very hard to find out what all these different things mean.
I appreciate that, it makes it easier for to follow the text.
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
+ - acpi,hid-desc-reg-offset : HID register offset (for Human Interface Devices)
+ - acpi,probed : Tells U-Boot to add 'linux,probed' to the ACPI tables so that
+ Linux will not re-init the device
+ - acpi,uid :_UIDvalue for device
Quoted 7 lines
Quoted 5 lines
Would it make sense to automatically infer ACPI properties from existing device tree properties?
E.g. if the compatible string contains "hid-over-i2c", then
_CIDcould be set to "PNP0C50".Yes we could do that. So is that true for all devices that use this i2c driver?
As far as I understand the ids "PNP0C50" and "hid-over-i2c" serve the same purpose, just in two different description languages.
Devicetree: If an I2C over HID device is described in Devicetree, it should
have a compatible string of "hid-over-i2c" (see [1] for details).
ACPI: If an I2C over HID device is described in ACPI, it should have a
_CID of "PNP0C50" (See [2] for details).
[1] https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/input/hid-over-i2c.txt
[2] https://docs.microsoft.com/en-us/windows-hardware/drivers/hid/plug-and-play-support-and-power-management
As both identifiers are standardized, I think we could infer one from the other.
I'm not sure whether inferring ACPI-properties from Devicetree properties is worth it, but I wanted to bring up the idea for discussion as adding new properties for someting where we already have something similar feels redundant.
Quoted 5 lines
Quoted 3 lines
And a "hid-over-i2c" device would also have a "hid-descr-addr" device tree property for the offset of the HID descriptor register which could be passed on in ACPI as part of the
_DSMmethod.Are you suggesting renaming acpi,hid-desc-reg-offset to hid-descr-addr?
An ACPI "PNP0C50"-device has a _DSM (Device Specific Method) which provides the HID descriptor offset (for UUID "3CDFF6F7-4267-4555-AD05-B30A3D8938DE").
A Devicetree "hid-over-i2c"-device has a property "hid-descr-addr" which provides the HID descriptor offset.
So instead of adding a new "acpi,hid-desc-reg-offset" I think we could also use the existing "hid-descr-addr" property.
Interrupts are another topic that need to be described in both worlds:
Devicetree: "interrupts"-property
ACPI: "_CRS"-method (Current Resource Settings)
Maybe we could also infer that description too?
regards, Wolfgang
PATCH 13/108 acpi: Add a binding for ACPI settings in the device tree
Hi Wolfgang,
Quoted 75 lines · Wolfgang Wallner
Hi Simon,
Quoted 28 lines
-----"Simon Glass" <[email protected]> schrieb: ----- Hi Wolfgang,
Quoted 14 lines · Wolfgang Wallner
Hi Simon,
Quoted 11 lines
doc/device-tree-bindings/device.txt new file +11
-0+Devices +======= + +Device bindings are described by their own individual binding files. + +U-Boot provides for some optional properties which are documented here. + + - acpi,has-power-resource : (boolean) true if this device has a power resource. + This causes a PRIC (ACPI PowerResource) to be written containing the + properties provided by this binding, to describe how to handle powering the + device up and down using GPIOsQuoted 8 lines
doc/device-tree-bindings/device.txt line 17
Quoted 6 lines
+ - acpi,cid : Contains the string to use as the compatible ID (
_CID)
+ - acpi,compatible : compatible string to report
+ - acpi,desc : Contains the string to use as the_DDN(DOS (Disk Operatingdoc/device-tree-bindings/device.txt new file +3
-0+ System) Device Name) + - acpi,hid : Contains the string to use as the HID (Human Interface Device) + identifier _HIDNit: "
_HID" in ACPI stands for "Hardware ID"Quoted 2 lines
OK thank you, will fix. I am trying to write things out in full since it is very hard to find out what all these different things mean.
I appreciate that, it makes it easier for to follow the text.
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
+ - acpi,hid-desc-reg-offset : HID register offset (for Human Interface Devices)
+ - acpi,probed : Tells U-Boot to add 'linux,probed' to the ACPI tables so that
+ Linux will not re-init the device
+ - acpi,uid :_UIDvalue for deviceQuoted 7 lines
Quoted 5 lines
Would it make sense to automatically infer ACPI properties from existing device tree properties?
E.g. if the compatible string contains "hid-over-i2c", then
_CIDcould be set to "PNP0C50".Yes we could do that. So is that true for all devices that use this i2c driver?
As far as I understand the ids "PNP0C50" and "hid-over-i2c" serve the same purpose, just in two different description languages.
Devicetree: If an I2C over HID device is described in Devicetree, it should
have a compatible string of "hid-over-i2c" (see [1] for details).ACPI: If an I2C over HID device is described in ACPI, it should have a
_CID of "PNP0C50" (See [2] for details).[1] https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/input/hid-over-i2c.txt
[2] https://docs.microsoft.com/en-us/windows-hardware/drivers/hid/plug-and-play-support-and-power-managementAs both identifiers are standardized, I think we could infer one from the other.
I'm not sure whether inferring ACPI-properties from Devicetree properties is worth it, but I wanted to bring up the idea for discussion as adding new properties for someting where we already have something similar feels redundant.
Quoted 5 lines
Quoted 3 lines
And a "hid-over-i2c" device would also have a "hid-descr-addr" device tree property for the offset of the HID descriptor register which could be passed on in ACPI as part of the
_DSMmethod.Are you suggesting renaming acpi,hid-desc-reg-offset to hid-descr-addr?
Quoted 8 lines
An ACPI "PNP0C50"-device has a
_DSM(Device Specific Method) which provides the HID descriptor offset (for UUID "3CDFF6F7-4267-4555-AD05-B30A3D8938DE").A Devicetree "hid-over-i2c"-device has a property "hid-descr-addr" which provides the HID descriptor offset.
So instead of adding a new "acpi,hid-desc-reg-offset" I think we could also use the existing "hid-descr-addr" property.
OK I've updated that in v2.
Quoted 7 lines
Interrupts are another topic that need to be described in both worlds:
Devicetree: "interrupts"-property
ACPI: "_CRS"-method (Current Resource Settings)Maybe we could also infer that description too?
It might be possible, I think. If we do that we'll need to document it somewhere. But CRS does have multiple GPIOs sometimes, so I'm not sure if we would want to scan the DT node and add all of those to the CRS? In any case this is something we can refine later since it doesn't affect the binding.
Regards,
Simon
PATCH 14/108 acpi: Add a simple sandbox test
In reply to Simon GlassAdd a sandbox test for the basic ACPI functionality we have so far.
---
arch/sandbox/dts/test.dts | 4 +++ include/dm/uclass-id.h | 1 + test/dm/Makefile | 1 + test/dm/acpi.c | 55 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 61 insertions(+) create mode 100644 test/dm/acpi.c
arch/sandbox/dts/test.dts +4 -0
@@ -206,6 +206,10 @@ compatible = "denx,u-boot-devres-test"; }; + acpi-test { + compatible = "denx,u-boot-acpi-test"; + }; + clocks { clk_fixed: clk-fixed { compatible = "fixed-clock";
include/dm/uclass-id.h +1 -0
@@ -20,6 +20,7 @@ enum uclass_id {UCLASS_TEST_PROBE ,UCLASS_TEST_DUMMY ,UCLASS_TEST_DEVRES , +UCLASS_TEST_ACPI ,UCLASS_SPI_EMUL ,/* sandbox SPI device emulator */ UCLASS_I2C_EMUL ,/* sandbox I2C device emulator */ UCLASS_I2C_EMUL_PARENT, /* parent for I2C device emulators */
test/dm/Makefile +1 -0
@@ -13,6 +13,7 @@ obj-$(CONFIG_UT_DM) += test-uclass.o # subsystem you must add sandbox tests here. obj-$(CONFIG_UT_DM) += core.o ifneq ($(CONFIG_SANDBOX),) +obj-$(CONFIG_ACPIGEN) += acpi.o obj-$(CONFIG_SOUND) += audio.o obj-$(CONFIG_BLK) += blk.o obj-$(CONFIG_BOARD) += board.o
test/dm/acpi.c new file +55 -0
55 lines not on this page · raw message
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 14/108 acpi: Add a simple sandbox test
Quoted 4 lines · Simon Glass
Add a sandbox test for the basic ACPI functionality we have so far.
Signed-off-by Simon Glass <[email protected]>
Quoted 9 lines
---
arch/sandbox/dts/test.dts | 4 +++ include/dm/uclass-id.h | 1 + test/dm/Makefile | 1 + test/dm/acpi.c | 55 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 61 insertions(+) create mode 100644 test/dm/acpi.c
PATCH 15/108 x86: Move acpi_table header to main include/ directory
In reply to Simon GlassThis file is potentially useful to other architectures saddled with ACPI so move it into a common location.
---
arch/x86/cpu/baytrail/acpi.c | 2 +- arch/x86/cpu/cpu.c | 2 +- arch/x86/cpu/quark/acpi.c | 2 +- arch/x86/cpu/tangier/acpi.c | 2 +- arch/x86/include/asm/acpi_table.h | 376 ---------------------------- arch/x86/lib/acpi.c | 2 +- arch/x86/lib/acpi_s3.c | 2 +- arch/x86/lib/acpi_table.c | 2 +- arch/x86/lib/tables.c | 2 +- arch/x86/lib/zimage.c | 2 +- include/acpi_table.h | 394 ++++++++++++++++++++++++++++++ lib/efi_loader/efi_acpi.c | 2 +- 12 files changed, 404 insertions(+), 386 deletions(-) create mode 100644 include/acpi_table.h
arch/x86/cpu/baytrail/acpi.c +1 -1
@@ -8,7 +8,7 @@#include <cpu.h> #include <dm.h> #include <dm/uclass-internal.h> -#include <asm/acpi_table.h> +#include <acpi_table.h> #include <asm/io.h> #include <asm/tables.h> #include <asm/arch/global_nvs.h>
arch/x86/cpu/cpu.c +1 -1
@@ -27,7 +27,7 @@#include <malloc.h> #include <syscon.h> #include <asm/acpi.h> -#include <asm/acpi_table.h> +#include <acpi_table.h> #include <asm/control_regs.h> #include <asm/coreboot_tables.h> #include <asm/cpu.h>
arch/x86/cpu/quark/acpi.c +1 -1
@@ -4,7 +4,7 @@*/ #include <common.h> -#include <asm/acpi_table.h> +#include <acpi_table.h> #include <asm/tables.h> #include <asm/arch/global_nvs.h> #include <asm/arch/iomap.h>
arch/x86/cpu/tangier/acpi.c +1 -1
@@ -9,7 +9,7 @@#include <cpu.h> #include <dm.h> #include <dm/uclass-internal.h> -#include <asm/acpi_table.h> +#include <acpi_table.h> #include <asm/ioapic.h> #include <asm/mpspec.h> #include <asm/tables.h>
arch/x86/include/asm/acpi_table.h +0 -376
382 lines not on this page · raw message
arch/x86/lib/acpi.c +1 -1
@@ -4,7 +4,7 @@*/ #include <common.h> -#include <asm/acpi_table.h> +#include <acpi_table.h> #include <asm/io.h> #include <asm/tables.h>
arch/x86/lib/acpi_s3.c +1 -1
@@ -6,7 +6,7 @@#include <common.h> #include <acpi_s3.h> #include <asm/acpi.h> -#include <asm/acpi_table.h> +#include <acpi_table.h> #include <asm/post.h> #include <linux/linkage.h>
arch/x86/lib/acpi_table.c +1 -1
@@ -13,7 +13,7 @@#include <serial.h> #include <version.h> #include <asm/acpi/global_nvs.h> -#include <asm/acpi_table.h> +#include <acpi_table.h> #include <asm/ioapic.h> #include <asm/lapic.h> #include <asm/mpspec.h>
arch/x86/lib/tables.c +1 -1
@@ -8,7 +8,7 @@#include <asm/sfi.h> #include <asm/mpspec.h> #include <asm/tables.h> -#include <asm/acpi_table.h> +#include <acpi_table.h> #include <asm/coreboot_tables.h> /**
arch/x86/lib/zimage.c +1 -1
@@ -16,7 +16,7 @@#include <env.h> #include <irq_func.h> #include <malloc.h> -#include <asm/acpi_table.h> +#include <acpi_table.h> #include <asm/io.h> #include <asm/ptrace.h> #include <asm/zimage.h>
include/acpi_table.h new file +394 -0
394 lines not on this page · raw message
lib/efi_loader/efi_acpi.c +1 -1
@@ -7,7 +7,7 @@#include <common.h> #include <efi_loader.h> -#include <asm/acpi_table.h> +#include <acpi_table.h> static const efi_guid_t acpi_guid =EFI_ACPI_TABLE_GUID ;
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 15/108 x86: Move acpi_table header to main include/ directory
Quoted 7 lines · Simon Glass
This file is potentially useful to other architectures saddled with ACPI so move it into a common location.
Signed-off-by Simon Glass <[email protected]>---
Quoted 15 lines
arch/x86/cpu/baytrail/acpi.c | 2 +- arch/x86/cpu/cpu.c | 2 +- arch/x86/cpu/quark/acpi.c | 2 +- arch/x86/cpu/tangier/acpi.c | 2 +- arch/x86/include/asm/acpi_table.h | 376 ---------------------------- arch/x86/lib/acpi.c | 2 +- arch/x86/lib/acpi_s3.c | 2 +- arch/x86/lib/acpi_table.c | 2 +- arch/x86/lib/tables.c | 2 +- arch/x86/lib/zimage.c | 2 +- include/acpi_table.h | 394 ++++++++++++++++++++++++++++++ lib/efi_loader/efi_acpi.c | 2 +- 12 files changed, 404 insertions(+), 386 deletions(-) create mode 100644 include/acpi_table.h
PATCH 16/108 acpi: Add an __ACPI__ preprocessor symbol
In reply to Simon GlassThe ASL compiler cannot handle C structures and the like so needs some sort of header guard around these.
We already have an __ASSEMBLY__ #define but it seems best to create a new one for ACPI since the rules may be different.
Add the check to a few files that ACPI always includes.
---
include/acpi_table.h | 4 ++++ include/dm/acpi.h | 4 ++++ scripts/Makefile.lib | 4 ++-- 3 files changed, 10 insertions(+), 2 deletions(-)
include/acpi_table.h +4 -0
@@ -21,6 +21,8 @@#define ACPI_RSDP_REV_ACPI_1_0 0#define ACPI_RSDP_REV_ACPI_2_0 2 +#if !defined(__ACPI__) +/* * RSDP (Root System Description Pointer) * Note: ACPI 1.0 didn't have length, xsdt_address, and ext_checksum
@@ -389,6 +391,8 @@ struct __packed acpi_spcr {u32 reserved2; }; +#endif /* !__ACPI__*/ +#include <asm/acpi_table.h> #endif /* __ACPI_TABLE_H__ */
include/dm/acpi.h +4 -0
@@ -22,6 +22,8 @@/* Length of an ACPI name string including nul terminator */ #define ACPI_NAME_MAX 5 +#if !defined(__ACPI__) +/** * struct acpi_ops - ACPI operations supported by driver model */
@@ -70,4 +72,6 @@ int acpi_get_name(const struct udevice *dev, char *out_name);*/ int acpi_return_name (char *out_name,const char *name); +#endif /* __ACPI__ */ +#endif
scripts/Makefile.lib +2 -2
@@ -409,8 +409,8 @@ ASL_TMP = $(patsubst %.c,%.asl.tmp,$@) quiet_cmd_acpi_c_asl= ASL $< cmd_acpi_c_asl= \ - $(CPP) -x assembler-with-cpp -D__ASSEMBLY__ -P $(UBOOTINCLUDE) \ - -o $(ASL_TMP) $< && \ + $(CPP) -x assembler-with-cpp -D__ASSEMBLY__ -D__ACPI__ \ + -P $(UBOOTINCLUDE) -o $(ASL_TMP) $< && \ iasl -p $@ -tc $(ASL_TMP) $(if $(KBUILD_VERBOSE:1=), >/dev/null) && \ mv $(patsubst %.c,%.hex,$@) $@
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 16/108 acpi: Add an __ACPI__ preprocessor symbol
Quoted 9 lines · Simon Glass
The ASL compiler cannot handle C structures and the like so needs some sort of header guard around these.
We already have an
__ASSEMBLY__#define but it seems best to create a new one for ACPI since the rules may be different.Add the check to a few files that ACPI always includes.
Quoted 8 lines
Signed-off-by Simon Glass <[email protected]>---
include/acpi_table.h | 4 ++++ include/dm/acpi.h | 4 ++++ scripts/Makefile.lib | 4 ++-- 3 files changed, 10 insertions(+), 2 deletions(-)
PATCH 17/108 acpi: Add a central location for table version numbers
In reply to Simon GlassEach ACPI table has its own version number. Add the version numbers in a single function so we can keep them consistent and easily see what versions are supported.
Start a new acpi_table file in a generic directory to house this function. We can move things over to this file from x86 as needed.
---
arch/sandbox/include/asm/acpi_table.h | 9 ++++ include/acpi_table.h | 53 ++++++++++++++++++++++++ lib/Makefile | 1 + lib/acpi/Makefile | 4 ++ lib/acpi/acpi_table.c | 59 +++++++++++++++++++++++++++ test/dm/acpi.c | 14 +++++++ 6 files changed, 140 insertions(+) create mode 100644 arch/sandbox/include/asm/acpi_table.h create mode 100644 lib/acpi/Makefile create mode 100644 lib/acpi/acpi_table.c
arch/sandbox/include/asm/acpi_table.h new file +9 -0
@@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright 2019 Google LLC +*/ + +#ifndef __ASM_ACPI_TABLE_H__ +#define __ASM_ACPI_TABLE_H__ + +#endif /* __ASM_ACPI_TABLE_H__ */
include/acpi_table.h +53 -0
65 lines not on this page · raw message
lib/Makefile +1 -0
@@ -5,6 +5,7 @@ ifndef CONFIG_SPL_BUILD +obj-$(CONFIG_$(SPL_TPL_)ACPIGEN) += acpi/ obj-$(CONFIG_EFI) += efi/ obj-$(CONFIG_EFI_LOADER) += efi_driver/ obj-$(CONFIG_EFI_LOADER) += efi_loader/
lib/acpi/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0+ +# + +obj-y += acpi_table.o
lib/acpi/acpi_table.c new file +59 -0
59 lines not on this page · raw message
test/dm/acpi.c +14 -0
@@ -7,6 +7,7 @@*/ #include <common.h> +#include <acpi_table.h> #include <dm.h> #include <dm/acpi.h> #include <dm/test.h>
@@ -53,3 +54,16 @@ static int dm_test_acpi_get_name(struct unit_test_state *uts)return 0 ; }DM_TEST (dm_test_acpi_get_name,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT ); + +/* Test acpi_get_table_revision() */ +static int dm_test_acpi_get_table_revision (struct unit_test_state *uts) +{ +ut_asserteq (1 ,acpi_get_table_revision (ACPITAB_MCFG )); +ut_asserteq (2 ,acpi_get_table_revision (ACPITAB_RSDP )); +ut_asserteq (4 ,acpi_get_table_revision (ACPITAB_TPM2 )); +ut_asserteq (-EINVAL ,acpi_get_table_revision (ACPITAB_COUNT )); + +return 0 ; +} +DM_TEST (dm_test_acpi_get_table_revision, +DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT );
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 17/108 acpi: Add a central location for table version numbers
Hi Simon,
Quoted 28 lines · Simon Glass
Each ACPI table has its own version number. Add the version numbers in a single function so we can keep them consistent and easily see what versions are supported.
Start a new
acpi_tablefile in a generic directory to house this function. We can move things over to this file from x86 as needed.Signed-off-by Simon Glass <[email protected]>---
arch/sandbox/include/asm/acpi_table.h | 9 ++++ include/acpi_table.h | 53 ++++++++++++++++++++++++ lib/Makefile | 1 + lib/acpi/Makefile | 4 ++ lib/acpi/acpi_table.c | 59 +++++++++++++++++++++++++++ test/dm/acpi.c | 14 +++++++ 6 files changed, 140 insertions(+) create mode 100644 arch/sandbox/include/asm/acpi_table.h create mode 100644 lib/acpi/Makefile create mode 100644 lib/acpi/acpi_table.carch/sandbox/include/asm/acpi_table.h new file +0
-0
arch/sandbox/include/asm/acpi_table.h line 9
Quoted 9 lines
arch/sandbox/include/asm/acpi_table.h new file +9
-0@@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright 2019 Google LLC +*/ + +#ifndef __ASM_ACPI_TABLE_H__ +#define __ASM_ACPI_TABLE_H__ + +#endif /* __ASM_ACPI_TABLE_H__ */
I suspect this file should be added in patch [014/108] acpi: Add a simple sandbox test, otherwise patch [014/108] cannot be built.
Quoted 106 lines
include/acpi_table.h +53
-0@@ -202,6 +202,18 @@ struct __packed acpi_fadt {struct acpi_gen_regaddr x_gpe1_blk; }; +/* FADT TABLE Revision values */ +#define ACPI_FADT_REV_ACPI_1_0 1 +#define ACPI_FADT_REV_ACPI_2_0 3 +#define ACPI_FADT_REV_ACPI_3_0 4 +#define ACPI_FADT_REV_ACPI_4_0 4 +#define ACPI_FADT_REV_ACPI_5_0 5 +#define ACPI_FADT_REV_ACPI_6_0 6 + +/* IVRS Revision Field */ +#define IVRS_FORMAT_FIXED 0x01/* Type 10h & 11h only */ +#define IVRS_FORMAT_MIXED 0x02/* Type 10h, 11h, & 40h */ +/* FACS flags */ #define ACPI_FACS_S4BIOS_F BIT(0)#define ACPI_FACS_64BIT_WAKE_F BIT(1)@@ -391,6 +403,47 @@ struct __packed acpi_spcr { u32 reserved2; }; +/* Tables defined by ACPI and generated by U-Boot */ +enum acpi_tables { +ACPITAB_BERT , +ACPITAB_DBG2 , +ACPITAB_DMAR , +ACPITAB_DSDT , +ACPITAB_FACS , +ACPITAB_FADT , +ACPITAB_HEST , +ACPITAB_HPET , +ACPITAB_IVRS , +ACPITAB_MADT , +ACPITAB_MCFG , +ACPITAB_RSDP , +ACPITAB_RSDT , +ACPITAB_SLIT , +ACPITAB_SRAT , +ACPITAB_SSDT , +ACPITAB_TCPA , +ACPITAB_TPM2 , +ACPITAB_XSDT , +ACPITAB_ECDT , + +/* Additional proprietary tables */ +ACPITAB_VFCT , +ACPITAB_NHLT , +ACPITAB_SPMI , + +ACPITAB_COUNT , +}; + +/** +* acpi_get_table_revision() - Get the revision number generated for a table +* +* This keeps the version-number information in one place +* +* @table: ACPI table to check +* @return version number that U-Boot generates +*/ +int acpi_get_table_revision (enum acpi_tables table); +#endif /* !__ACPI__*/ #include <asm/acpi_table.h> lib/Makefile +1
-0@@ -5,6 +5,7 @@ ifndef CONFIG_SPL_BUILD +obj-$(CONFIG_$(SPL_TPL_)ACPIGEN) += acpi/ obj-$(CONFIG_EFI) += efi/ obj-$(CONFIG_EFI_LOADER) += efi_driver/ obj-$(CONFIG_EFI_LOADER) += efi_loader/lib/acpi/Makefile new file +4
-0@@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0+ +# + +obj-y += acpi_table.olib/acpi/acpi_table.c new file +7
-0@@ -0,0 +1,59 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Tests for ACPI table generation +* +* Copyright 2019 Google LLC +*/ +
lib/acpi/acpi_table.c line 17
Quoted 10 lines
lib/acpi/acpi_table.c new file +10
-0+#include <common.h> +#include <acpi_table.h> + +int acpi_get_table_revision (enum acpi_tables table) +{ +switch (table) { +case ACPITAB_FADT : +return ACPI_FADT_REV_ACPI_3_0 ; +case ACPITAB_MADT :/* ACPI 3.0: 2, ACPI 4.0/5.0: 3, ACPI 6.2b/6.3: 5 */ +return 2 ;
Why magic number of 2? In the FADT case ACPI_FADT_REV_ACPI_3_0 is used.
lib/acpi/acpi_table.c line 19
Quoted 2 lines
lib/acpi/acpi_table.c new file +2
-0+case ACPITAB_MCFG : +return 1 ;
ditto
Quoted 60 lines
lib/acpi/acpi_table.c new file +40
-0+case ACPITAB_TCPA : +return 2 ; +case ACPITAB_TPM2 : +return 4 ; +case ACPITAB_SSDT :/* ACPI 3.0 upto 6.3: 2 */ +return 2 ; +case ACPITAB_SRAT :/* ACPI 2.0: 1, ACPI 3.0: 2, ACPI 4.0 upto 6.3: 3 */ +return 1 ;/* TODO Should probably be upgraded to 2 */ +case ACPITAB_DMAR : +return 1 ; +case ACPITAB_SLIT :/* ACPI 2.0 upto 6.3: 1 */ +return 1 ; +case ACPITAB_SPMI :/* IMPI 2.0 */ +return 5 ; +case ACPITAB_HPET :/* Currently 1. Table added in ACPI 2.0. */ +return 1 ; +case ACPITAB_VFCT :/* ACPI 2.0/3.0/4.0: 1 */ +return 1 ; +case ACPITAB_IVRS : +return IVRS_FORMAT_FIXED ; +case ACPITAB_DBG2 : +return 0 ; +case ACPITAB_FACS :/* ACPI 2.0/3.0: 1, ACPI 4.0 upto 6.3: 2 */ +return 1 ; +case ACPITAB_RSDT :/* ACPI 1.0 upto 6.3: 1 */ +return 1 ; +case ACPITAB_XSDT :/* ACPI 2.0 upto 6.3: 1 */ +return 1 ; +case ACPITAB_RSDP :/* ACPI 2.0 upto 6.3: 2 */ +return 2 ; +case ACPITAB_HEST : +return 1 ; +case ACPITAB_NHLT : +return 5 ; +case ACPITAB_BERT : +return 1 ; +default : +return -EINVAL ; + } +}test/dm/acpi.c +5
-0@@ -7,6 +7,7 @@*/ #include <common.h> +#include <acpi_table.h> #include <dm.h> #include <dm/acpi.h> #include <dm/test.h> @@ -53,3 +54,16 @@ static int dm_test_acpi_get_name(struct unit_test_state *uts)return 0 ; }DM_TEST (dm_test_acpi_get_name,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT ); + +/* Test acpi_get_table_revision() */ +static int dm_test_acpi_get_table_revision (struct unit_test_state *uts) +{
test/dm/acpi.c static int dm_test_acpi_get_name(struct unit_test_state *uts)
Quoted 10 lines
test/dm/acpi.c +9
-1+ut_asserteq (1 ,acpi_get_table_revision (ACPITAB_MCFG )); +ut_asserteq (2 ,acpi_get_table_revision (ACPITAB_RSDP )); +ut_asserteq (4 ,acpi_get_table_revision (ACPITAB_TPM2 )); +ut_asserteq (-EINVAL ,acpi_get_table_revision (ACPITAB_COUNT )); + +return 0 ; +} +DM_TEST (dm_test_acpi_get_table_revision, +DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT ); --
Regards,
Bin
PATCH 18/108 acpi: Add support for DMAR
In reply to Simon GlassThe DMA Remapping Reporting (DMAR) table contains information about DMA remapping.
Add a version simple version of this table with only the minimum fields filled out. i.e. no entries.
---
include/acpi_table.h | 57 +++++++++++++++++++++++++++++++++++++++++++ lib/acpi/acpi_table.c | 26 ++++++++++++++++++++ test/dm/acpi.c | 14 +++++++++++ 3 files changed, 97 insertions(+)
include/acpi_table.h +57 -0
@@ -21,6 +21,9 @@#define ACPI_RSDP_REV_ACPI_1_0 0#define ACPI_RSDP_REV_ACPI_2_0 2 +/* TODO(sjg at chromium.org): Figure out how to get compiler revision */ +#define ASL_REVISION 0 +#if !defined(__ACPI__)/*
@@ -352,6 +355,51 @@ struct acpi_csrt_shared_info {u32 max_block_size; }; +enum dmar_type { +DMAR_DRHD =0 , +DMAR_RMRR =1 , +DMAR_ATSR =2 , +DMAR_RHSA =3 , +DMAR_ANDD =4 +}; + +enum { +DRHD_INCLUDE_PCI_ALL =1 +}; + +enum dmar_flags { +DMAR_INTR_REMAP =1 <<0 , +DMAR_X2APIC_OPT_OUT =1 <<1 , +DMA_CTRL_PLATFORM_OPT_IN_FLAG =1 <<2 , +}; + +struct __packed dmar_entry { +u16 type; +u16 length; +u8 flags; +u8 reserved; +u16 segment; +u64 bar; +}; + +struct __packed dmar_rmrr_entry { +u16 type; +u16 length; +u16 reserved; +u16 segment; +u64 bar; +u64 limit; +}; + +/* DMAR (DMA Remapping Reporting Structure) */ +struct acpi_dmar { +struct acpi_table_header header; +u8 host_address_width; +u8 flags; +u8 reserved[10 ]; +struct dmar_entry structure[0 ]; +} __packed; +/* DBG2 definitions are partially used for SPCR interface_type */ /* Types for port_type field */
@@ -444,6 +492,15 @@ enum acpi_tables {*/ int acpi_get_table_revision (enum acpi_tables table); +/** +* acpi_create_dmar() - Create a DMA Remapping Reporting (DMAR) table +* +* @dmar: Place to put the table +* @flags: DMAR flags to use +* @return 0 if OK, -ve on error +*/ +int acpi_create_dmar (struct acpi_dmar *dmar,enum dmar_flags flags); +#endif /* !__ACPI__*/ #include <asm/acpi_table.h>
lib/acpi/acpi_table.c +26 -0
@@ -6,7 +6,33 @@*/ #include <common.h> +#include <dm.h> #include <acpi_table.h> +#include <cpu.h> + +int acpi_create_dmar (struct acpi_dmar *dmar,enum dmar_flags flags) +{ +struct acpi_table_header *header = &dmar->header; +struct cpu_info info; +struct udevice *cpu; +int ret; + + ret =uclass_first_device (UCLASS_CPU , &cpu); +if (ret) +return log_msg_ret ("cpu" , ret); + ret =cpu_get_info (cpu, &info); +memset ((void *)dmar,0 ,sizeof (struct acpi_dmar )); + +/* Fill out header fields. */ +acpi_fill_header (&dmar->header,"DMAR" ); + header->length =sizeof (struct acpi_dmar ); + header->revision =acpi_get_table_revision (ACPITAB_DMAR ); + + dmar->host_address_width = info.address_width -1 ; + dmar->flags = flags; + +return 0 ; +}int acpi_get_table_revision (enum acpi_tables table) {
test/dm/acpi.c +14 -0
@@ -67,3 +67,17 @@ static int dm_test_acpi_get_table_revision(struct unit_test_state *uts) }DM_TEST (dm_test_acpi_get_table_revision,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT ); + +/* Test acpi_create_dmar() */ +static int dm_test_acpi_create_dmar (struct unit_test_state *uts) +{ +struct acpi_dmar dmar; + +ut_assertok (acpi_create_dmar (&dmar,DMAR_INTR_REMAP )); +ut_asserteq (DMAR_INTR_REMAP , dmar.flags); +ut_asserteq (DMAR_INTR_REMAP , dmar.flags); +ut_asserteq (32 -1 , dmar.host_address_width); + +return 0 ; +} +DM_TEST (dm_test_acpi_create_dmar,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT );
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 18/108 acpi: Add support for DMAR
Hi Simon,
Quoted 42 lines · Simon Glass
The DMA Remapping Reporting (DMAR) table contains information about DMA remapping.
Add a version simple version of this table with only the minimum fields filled out. i.e. no entries.
Signed-off-by Simon Glass <[email protected]>---
include/acpi_table.h | 57 +++++++++++++++++++++++++++++++++++++++++++ lib/acpi/acpi_table.c | 26 ++++++++++++++++++++ test/dm/acpi.c | 14 +++++++++++ 3 files changed, 97 insertions(+)include/acpi_table.h +12
-0@@ -21,6 +21,9 @@#define ACPI_RSDP_REV_ACPI_1_0 0#define ACPI_RSDP_REV_ACPI_2_0 2 +/* TODO(sjg at chromium.org): Figure out how to get compiler revision */ +#define ASL_REVISION 0 +#if !defined(__ACPI__)/* @@ -352,6 +355,51 @@ struct acpi_csrt_shared_info {u32 max_block_size; }; +enum dmar_type { +DMAR_DRHD =0 , +DMAR_RMRR =1 , +DMAR_ATSR =2 , +DMAR_RHSA =3 , +DMAR_ANDD =4 +}; + +enum {
include/acpi_table.h struct acpi_csrt_shared_info { · line 376
Quoted 10 lines
include/acpi_table.h +10
-0+ DRHD_INCLUDE_PCI_ALL = 1 +}; + +enum dmar_flags { +DMAR_INTR_REMAP =1 <<0 , +DMAR_X2APIC_OPT_OUT =1 <<1 , +DMA_CTRL_PLATFORM_OPT_IN_FLAG =1 <<2 , +}; + +struct __packed dmar_entry {
__packed is not necessary.
include/acpi_table.h struct acpi_csrt_shared_info { · line 385
Quoted 9 lines
include/acpi_table.h +9
-0+u16 type; +u16 length; +u8 flags; +u8 reserved; +u16 segment; +u64 bar; +}; + +struct __packed dmar_rmrr_entry {
__packed is not necessary.
Quoted 6 lines
include/acpi_table.h +6
-0+u16 type; +u16 length; +u16 reserved; +u16 segment; +u64 bar; +u64 limit;
include/acpi_table.h struct acpi_csrt_shared_info { · line 401
Quoted 10 lines
include/acpi_table.h +10
-0+}; + +/* DMAR (DMA Remapping Reporting Structure) */ +struct acpi_dmar { +struct acpi_table_header header; +u8 host_address_width; +u8 flags; +u8 reserved[10 ]; +struct dmar_entry structure[0 ]; +} __packed;
nits: put __packed after struct
Quoted 71 lines
include/acpi_table.h +10
-0+/* DBG2 definitions are partially used for SPCR interface_type */ /* Types for port_type field */ @@ -444,6 +492,15 @@ enum acpi_tables {*/ int acpi_get_table_revision (enum acpi_tables table); +/** +* acpi_create_dmar() - Create a DMA Remapping Reporting (DMAR) table +* +* @dmar: Place to put the table +* @flags: DMAR flags to use +* @return 0 if OK, -ve on error +*/ +int acpi_create_dmar (struct acpi_dmar *dmar,enum dmar_flags flags); +#endif /* !__ACPI__*/ #include <asm/acpi_table.h> lib/acpi/acpi_table.c +26
-0@@ -6,7 +6,33 @@*/ #include <common.h> +#include <dm.h> #include <acpi_table.h> +#include <cpu.h> + +int acpi_create_dmar (struct acpi_dmar *dmar,enum dmar_flags flags) +{ +struct acpi_table_header *header = &dmar->header; +struct cpu_info info; +struct udevice *cpu; +int ret; + + ret =uclass_first_device (UCLASS_CPU , &cpu); +if (ret) +return log_msg_ret ("cpu" , ret); + ret =cpu_get_info (cpu, &info); +memset ((void *)dmar,0 ,sizeof (struct acpi_dmar )); + +/* Fill out header fields. */ +acpi_fill_header (&dmar->header,"DMAR" ); + header->length =sizeof (struct acpi_dmar ); + header->revision =acpi_get_table_revision (ACPITAB_DMAR ); + + dmar->host_address_width = info.address_width -1 ; + dmar->flags = flags; + +return 0 ; +}int acpi_get_table_revision (enum acpi_tables table) {test/dm/acpi.c +5
-0@@ -67,3 +67,17 @@ static int dm_test_acpi_get_table_revision(struct unit_test_state *uts) }DM_TEST (dm_test_acpi_get_table_revision,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT ); + +/* Test acpi_create_dmar() */ +static int dm_test_acpi_create_dmar (struct unit_test_state *uts) +{ +struct acpi_dmar dmar;
test/dm/acpi.c static int dm_test_acpi_get_table_revision(struct unit_test_state *uts)
Quoted 10 lines
test/dm/acpi.c +9
-1+ +ut_assertok (acpi_create_dmar (&dmar,DMAR_INTR_REMAP )); +ut_asserteq (DMAR_INTR_REMAP , dmar.flags); +ut_asserteq (DMAR_INTR_REMAP , dmar.flags); +ut_asserteq (32 -1 , dmar.host_address_width); + +return 0 ; +} +DM_TEST (dm_test_acpi_create_dmar,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT ); --
Other than above,
Regards,
Bin
PATCH 19/108 acpi: Move acpi_fill_header() to generic code
In reply to Simon GlassThis function needs to be used by sandbox for tests. Move it into the generic directory.
---
include/acpi_table.h | 10 ++++++++++ lib/acpi/acpi_table.c | 10 ++++++++++ test/dm/acpi.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+)
include/acpi_table.h +10 -0
@@ -501,6 +501,16 @@ int acpi_get_table_revision(enum acpi_tables table);*/ int acpi_create_dmar (struct acpi_dmar *dmar,enum dmar_flags flags); +/** +* acpi_fill_header() - Set up a new table header +* +* This sets all fields except length, revision, checksum and aslc_revision +* +* @header: ACPI header to update +* @signature: Table signature to use (4 characters) +*/ +void acpi_fill_header (struct acpi_table_header *header,char *signature); +#endif /* !__ACPI__*/ #include <asm/acpi_table.h>
lib/acpi/acpi_table.c +10 -0
@@ -9,6 +9,7 @@#include <dm.h> #include <acpi_table.h> #include <cpu.h> +#include <version.h> int acpi_create_dmar (struct acpi_dmar *dmar,enum dmar_flags flags) {
@@ -83,3 +84,12 @@ int acpi_get_table_revision(enum acpi_tables table)return -EINVAL ; } } + +void acpi_fill_header (struct acpi_table_header *header,char *signature) +{ +memcpy (header->signature, signature,4 ); +memcpy (header->oem_id,OEM_ID ,6 ); +memcpy (header->oem_table_id,OEM_TABLE_ID ,8 ); + header->oem_revision =U_BOOT_BUILD_DATE ; +memcpy (header->aslc_id,ASLC_ID ,4 ); +}
test/dm/acpi.c +28 -0
@@ -9,6 +9,7 @@#include <common.h> #include <acpi_table.h> #include <dm.h> +#include <version.h> #include <dm/acpi.h> #include <dm/test.h> #include <test/ut.h>
@@ -81,3 +82,30 @@ static int dm_test_acpi_create_dmar(struct unit_test_state *uts)return 0 ; }DM_TEST (dm_test_acpi_create_dmar,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT ); + +/* Test acpi_fill_header() */ +static int dm_test_acpi_fill_header (struct unit_test_state *uts) +{ +struct acpi_table_header hdr; + +/* Make sure these 5 fields are not changed */ + hdr.length =0x11 ; + hdr.revision =0x22 ; + hdr.checksum =0x33 ; + hdr.aslc_revision =0x44 ; +acpi_fill_header (&hdr,"ABCD" ); + +ut_assertok (memcmp ("ABCD" , hdr.signature,sizeof (hdr.signature))); +ut_asserteq (0x11 , hdr.length); +ut_asserteq (0x22 , hdr.revision); +ut_asserteq (0x33 , hdr.checksum); +ut_assertok (memcmp (OEM_ID , hdr.oem_id,sizeof (hdr.oem_id))); +ut_assertok (memcmp (OEM_TABLE_ID , hdr.oem_table_id, +sizeof (hdr.oem_table_id))); +ut_asserteq (U_BOOT_BUILD_DATE , hdr.oem_revision); +ut_assertok (memcmp (ASLC_ID , hdr.aslc_id,sizeof (hdr.aslc_id))); +ut_asserteq (0x44 , hdr.aslc_revision); + +return 0 ; +} +DM_TEST (dm_test_acpi_fill_header,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT );
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 19/108 acpi: Move acpi_fill_header() to generic code
Quoted 4 lines · Simon Glass
This function needs to be used by sandbox for tests. Move it into the generic directory.
Quoted 8 lines
Signed-off-by Simon Glass <[email protected]>---
include/acpi_table.h | 10 ++++++++++ lib/acpi/acpi_table.c | 10 ++++++++++ test/dm/acpi.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+)
PATCH 20/108 acpi: Add a method to write tables for a device
In reply to Simon GlassA device may want to write out ACPI tables to describe itself to Linux. Add a method to permit this.
---
arch/sandbox/dts/test.dts | 4 ++++ drivers/core/acpi.c | 33 ++++++++++++++++++++++++++++++ include/acpi_table.h | 1 + include/dm/acpi.h | 30 +++++++++++++++++++++++++++ test/dm/acpi.c | 43 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 111 insertions(+)
arch/sandbox/dts/test.dts +4 -0
@@ -210,6 +210,10 @@ compatible = "denx,u-boot-acpi-test"; }; + acpi-test2 { + compatible = "denx,u-boot-acpi-test"; + }; + clocks { clk_fixed: clk-fixed { compatible = "fixed-clock";
drivers/core/acpi.c +33 -0
@@ -30,3 +30,36 @@ int acpi_get_name(const struct udevice *dev, char *out_name)return -ENOSYS ; } + +int _acpi_write_dev_tables (struct acpi_ctx *ctx,const struct udevice *parent) +{ +struct acpi_ops *aops; +struct udevice *dev; +int ret; + + aops =device_get_acpi_ops (parent); +if (aops && aops->write_tables) { +log_debug ("- %s\n" , parent->name); + ret = aops->write_tables (parent, ctx); +if (ret) +return ret; + } + device_foreach_child(dev, parent) { + ret =_acpi_write_dev_tables (ctx, dev); +if (ret) +return ret; + } + +return 0 ; +} + +int acpi_write_dev_tables (struct acpi_ctx *ctx) +{ +int ret; + +log_debug ("Writing device tables\n" ); + ret =_acpi_write_dev_tables (ctx,dm_root ()); +log_debug ("Writing finished, err=%d\n" , ret); + +return ret; +}
include/acpi_table.h +1 -0
@@ -17,6 +17,7 @@#define OEM_ID "U-BOOT"/* U-Boot */ #define OEM_TABLE_ID "U-BOOTBL"/* U-Boot Table */ #define ASLC_ID "INTL"/* Intel ASL Compiler */ +#define ACPI_TABLE_CREATOR OEM_TABLE_ID#define ACPI_RSDP_REV_ACPI_1_0 0#define ACPI_RSDP_REV_ACPI_2_0 2
include/dm/acpi.h +30 -0
@@ -24,6 +24,17 @@#if !defined(__ACPI__) +/** +* struct acpi_ctx - Context used for writing ACPI tables +* +* This contains a few useful pieces of information used when writing +* +* @current: Current address for writing +*/ +struct acpi_ctx { +void *current; +}; +/** * struct acpi_ops - ACPI operations supported by driver model */
@@ -38,6 +49,15 @@ struct acpi_ops {* other error */ int (*get_name)(const struct udevice *dev,char *out_name); + +/** +* write_tables() - Write out any tables required by this device +* +* @dev: Device to write +* @ctx: ACPI context to use +* @return 0 if OK, -ve on error +*/ +int (*write_tables)(const struct udevice *dev,struct acpi_ctx *ctx); };#define device_get_acpi_ops (dev) ((dev)->driver->acpi_ops)
@@ -72,6 +92,16 @@ int acpi_get_name(const struct udevice *dev, char *out_name);*/ int acpi_return_name (char *out_name,const char *name); +/** +* acpi_write_dev_tables() - Write ACPI tables required by devices +* +* This scans through all devices and tells them to write any tables they want +* to write. +* +* @return 0 if OK, -ve if any device returned an error +*/ +int acpi_write_dev_tables (struct acpi_ctx *ctx); +#endif /* __ACPI__ */ #endif
test/dm/acpi.c +43 -0
58 lines not on this page · raw message
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 20/108 acpi: Add a method to write tables for a device
Hi Simon,
Quoted 34 lines · Simon Glass
A device may want to write out ACPI tables to describe itself to Linux. Add a method to permit this.
Signed-off-by Simon Glass <[email protected]>---
arch/sandbox/dts/test.dts | 4 ++++ drivers/core/acpi.c | 33 ++++++++++++++++++++++++++++++ include/acpi_table.h | 1 + include/dm/acpi.h | 30 +++++++++++++++++++++++++++ test/dm/acpi.c | 43 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 111 insertions(+)arch/sandbox/dts/test.dts +4
-0@@ -210,6 +210,10 @@ compatible = "denx,u-boot-acpi-test"; }; + acpi-test2 { + compatible = "denx,u-boot-acpi-test"; + }; + clocks { clk_fixed: clk-fixed { compatible = "fixed-clock";drivers/core/acpi.c +0
-0
drivers/core/acpi.c int acpi_get_name(const struct udevice *dev, char *out_name) · line 34
Quoted 5 lines
drivers/core/acpi.c +2
-0@@ -30,3 +30,36 @@ int acpi_get_name(const struct udevice *dev, char *out_name)return -ENOSYS ; } + +int _acpi_write_dev_tables (struct acpi_ctx *ctx,const struct udevice *parent)
Is this supposed to a public API? Otherwise we have to use static.
nits: to align with the signature of aops->write_tables(), can we exchange the parameter order to have parent come first?
Quoted 36 lines
drivers/core/acpi.c +31
-0+{ +struct acpi_ops *aops; +struct udevice *dev; +int ret; + + aops =device_get_acpi_ops (parent); +if (aops && aops->write_tables) { +log_debug ("- %s\n" , parent->name); + ret = aops->write_tables (parent, ctx); +if (ret) +return ret; + } + device_foreach_child(dev, parent) { + ret =_acpi_write_dev_tables (ctx, dev); +if (ret) +return ret; + } + +return 0 ; +} + +int acpi_write_dev_tables (struct acpi_ctx *ctx) +{ +int ret; + +log_debug ("Writing device tables\n" ); + ret =_acpi_write_dev_tables (ctx,dm_root ()); +log_debug ("Writing finished, err=%d\n" , ret); + +return ret; +}include/acpi_table.h +0
-0
include/acpi_table.h line 20
Quoted 4 lines
include/acpi_table.h +1
-0@@ -17,6 +17,7 @@#define OEM_ID "U-BOOT"/* U-Boot */ #define OEM_TABLE_ID "U-BOOTBL"/* U-Boot Table */ #define ASLC_ID "INTL"/* Intel ASL Compiler */ +#define ACPI_TABLE_CREATOR OEM_TABLE_ID
This macro is not used in this patch. Probably need to move it to the commit where it gets used.
Quoted 114 lines
include/acpi_table.h +0
-0#define ACPI_RSDP_REV_ACPI_1_0 0#define ACPI_RSDP_REV_ACPI_2_0 2include/dm/acpi.h +30
-0@@ -24,6 +24,17 @@#if !defined(__ACPI__) +/** +* struct acpi_ctx - Context used for writing ACPI tables +* +* This contains a few useful pieces of information used when writing +* +* @current: Current address for writing +*/ +struct acpi_ctx { +void *current; +}; +/** * struct acpi_ops - ACPI operations supported by driver model */ @@ -38,6 +49,15 @@ struct acpi_ops {* other error */ int (*get_name)(const struct udevice *dev,char *out_name); + +/** +* write_tables() - Write out any tables required by this device +* +* @dev: Device to write +* @ctx: ACPI context to use +* @return 0 if OK, -ve on error +*/ +int (*write_tables)(const struct udevice *dev,struct acpi_ctx *ctx); };#define device_get_acpi_ops (dev) ((dev)->driver->acpi_ops)@@ -72,6 +92,16 @@ int acpi_get_name(const struct udevice *dev, char *out_name);*/ int acpi_return_name (char *out_name,const char *name); +/** +* acpi_write_dev_tables() - Write ACPI tables required by devices +* +* This scans through all devices and tells them to write any tables they want +* to write. +* +* @return 0 if OK, -ve if any device returned an error +*/ +int acpi_write_dev_tables (struct acpi_ctx *ctx); +#endif /* __ACPI__ */ #endif test/dm/acpi.c +34
-0@@ -15,6 +15,19 @@#include <test/ut.h> #define ACPI_TEST_DEV_NAME "ABCD" +#define BUF_SIZE 4096 + +static int testacpi_write_tables (const struct udevice *dev, +struct acpi_ctx *ctx) +{ +struct acpi_dmar *dmar; + + dmar = (struct acpi_dmar *)ctx->current; +acpi_create_dmar (dmar,DMAR_INTR_REMAP ); + ctx->current +=sizeof (struct acpi_dmar ); + +return 0 ; +}static int testacpi_get_name (const struct udevice *dev,char *out_name) {@@ -23,6 +36,7 @@ static int testacpi_get_name(const struct udevice *dev, char *out_name)struct acpi_ops testacpi_ops = { .get_name = testacpi_get_name, + .write_tables = testacpi_write_tables, };static const struct udevice_id testacpi_ids[] = {@@ -109,3 +123,32 @@ static int dm_test_acpi_fill_header(struct unit_test_state *uts)return 0 ; }DM_TEST (dm_test_acpi_fill_header,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT ); + +/* Test ACPI write_tables() */ +static int dm_test_acpi_write_tables (struct unit_test_state *uts) +{ +struct acpi_dmar *dmar; +struct acpi_ctx ctx; +void *buf; + + buf =malloc (BUF_SIZE ); +ut_assertnonnull (buf); + + ctx.current = buf; +ut_assertok (acpi_write_dev_tables (&ctx)); + dmar = buf; + +/* +* We should have two dmar tables, one for each "denx,u-boot-acpi-test" +* device +*/ +ut_asserteq_ptr (dmar +2 , ctx.current);
test/dm/acpi.c static int dm_test_acpi_fill_header(struct unit_test_state *uts)
Quoted 10 lines
test/dm/acpi.c +9
-1+ut_asserteq (DMAR_INTR_REMAP , dmar->flags); +ut_asserteq (32 -1 , dmar->host_address_width); + +ut_asserteq (DMAR_INTR_REMAP , dmar[1 ].flags); +ut_asserteq (32 -1 , dmar[1 ].host_address_width); + +return 0 ; +} +DM_TEST (dm_test_acpi_write_tables,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT ); --
Regards,
Bin
PATCH 21/108 acpi: Convert part of acpi_table to use acpi_ctx
In reply to Simon GlassThe current code uses an address but a pointer would result in fewer casts. Also it repeats the alignment code in a lot of places so this would be better done in a helper function.
Update write_acpi_tables() to make use of the new acpi_ctx structure, adding a few helpers to clean things up.
---
arch/x86/lib/acpi_table.c | 88 +++++++++++++++++++-------------------- include/acpi_table.h | 36 ++++++++++++++++ lib/acpi/acpi_table.c | 22 ++++++++++ test/dm/acpi.c | 28 +++++++++++++ 4 files changed, 129 insertions(+), 45 deletions(-)
arch/x86/lib/acpi_table.c +43 -45
@@ -10,6 +10,7 @@#include <cpu.h> #include <dm.h> #include <dm/uclass-internal.h> +#include <mapmem.h> #include <serial.h> #include <version.h> #include <asm/acpi/global_nvs.h>
@@ -19,6 +20,7 @@#include <asm/mpspec.h> #include <asm/tables.h> #include <asm/arch/global_nvs.h> +#include <dm/acpi.h> /* * IASL compiles the dsdt entries and writes the hex values
@@ -477,9 +479,9 @@ static void acpi_create_spcr(struct acpi_spcr *spcr)/* * QEMU's version of write_acpi_tables is defined in drivers/misc/qfw.c */ -ulong write_acpi_tables (ulong start) +ulong write_acpi_tables (ulong start_addr) { -u32 current; +struct acpi_ctx sctx, *ctx = &sctx;struct acpi_rsdp *rsdp;struct acpi_rsdt *rsdt;struct acpi_xsdt *xsdt;
@@ -490,60 +492,61 @@ ulong write_acpi_tables(ulong start)struct acpi_madt *madt;struct acpi_csrt *csrt;struct acpi_spcr *spcr; +void *start; +ulong addr;int i; - current = start; + start =map_sysmem (start_addr,0 ); + ctx->current = start;/* Align ACPI tables to 16 byte */ - current =ALIGN (current,16 ); +acpi_align (ctx); -debug ("ACPI: Writing ACPI tables at %lx\n" , start); +debug ("ACPI: Writing ACPI tables at %lx\n" , start_addr);/* We need at least an RSDP and an RSDT Table */ - rsdp = (struct acpi_rsdp *)current; - current +=sizeof (struct acpi_rsdp ); - current =ALIGN (current,16 ); - rsdt = (struct acpi_rsdt *)current; - current +=sizeof (struct acpi_rsdt ); - current =ALIGN (current,16 ); - xsdt = (struct acpi_xsdt *)current; - current +=sizeof (struct acpi_xsdt ); + rsdp = ctx->current; +acpi_inc_align (ctx,sizeof (struct acpi_rsdp )); + rsdt = ctx->current; +acpi_inc_align (ctx,sizeof (struct acpi_rsdt )); + xsdt = ctx->current; +acpi_inc_align (ctx,sizeof (struct acpi_xsdt ));/* * Per ACPI spec, the FACS table address must be aligned to a 64 byte * boundary (Windows checks this, but Linux does not). */ - current =ALIGN (current,64 ); +acpi_align_large (ctx);/* clear all table memory */ -memset ((void *)start,0 , current - start); +memset ((void *)start,0 , ctx->current - start);acpi_write_rsdp (rsdp, rsdt, xsdt);acpi_write_rsdt (rsdt);acpi_write_xsdt (xsdt);debug ("ACPI: * FACS\n" ); - facs = (struct acpi_facs *)current; - current +=sizeof (struct acpi_facs ); - current =ALIGN (current,16 ); + facs = ctx->current; +acpi_inc_align (ctx,sizeof (struct acpi_facs ));acpi_create_facs (facs);debug ("ACPI: * DSDT\n" ); - dsdt = (struct acpi_table_header *)current; + dsdt = ctx->current;memcpy (dsdt, &AmlCode,sizeof (struct acpi_table_header )); - current +=sizeof (struct acpi_table_header ); -memcpy ((char *)current, +acpi_inc (ctx,sizeof (struct acpi_table_header )); +memcpy (ctx->current, (char *)&AmlCode +sizeof (struct acpi_table_header ), dsdt->length -sizeof (struct acpi_table_header )); - current += dsdt->length -sizeof (struct acpi_table_header ); - current =ALIGN (current,16 ); +acpi_inc_align (ctx, dsdt->length -sizeof (struct acpi_table_header ));/* Pack GNVS into the ACPI table area */ for (i =0 ; i < dsdt->length; i++) {u32 *gnvs = (u32 *)((u32 )dsdt + i);if (*gnvs ==ACPI_GNVS_ADDR ) { -debug ("Fix up global NVS in DSDT to 0x%08x\n" , current); - *gnvs = current; +ulong addr = (ulong )map_to_sysmem (ctx->current); + +debug ("Fix up global NVS in DSDT to %#08lx\n" , addr); + *gnvs = addr;break ; } }
@@ -553,51 +556,46 @@ ulong write_acpi_tables(ulong start) dsdt->checksum =table_compute_checksum ((void *)dsdt, dsdt->length);/* Fill in platform-specific global NVS variables */ -acpi_create_gnvs ((struct acpi_global_nvs *)current); - current +=sizeof (struct acpi_global_nvs ); - current =ALIGN (current,16 ); +acpi_create_gnvs (ctx->current); +acpi_inc_align (ctx,sizeof (struct acpi_global_nvs ));debug ("ACPI: * FADT\n" ); - fadt = (struct acpi_fadt *)current; - current +=sizeof (struct acpi_fadt ); - current =ALIGN (current,16 ); + fadt = ctx->current; +acpi_inc_align (ctx,sizeof (struct acpi_fadt ));acpi_create_fadt (fadt, facs, dsdt);acpi_add_table (rsdp, fadt);debug ("ACPI: * MADT\n" ); - madt = (struct acpi_madt *)current; + madt = ctx->current;acpi_create_madt (madt); - current += madt->header.length; +acpi_inc_align (ctx, madt->header.length);acpi_add_table (rsdp, madt); - current =ALIGN (current,16 );debug ("ACPI: * MCFG\n" ); - mcfg = (struct acpi_mcfg *)current; + mcfg = ctx->current;acpi_create_mcfg (mcfg); - current += mcfg->header.length; +acpi_inc_align (ctx, mcfg->header.length);acpi_add_table (rsdp, mcfg); - current =ALIGN (current,16 );debug ("ACPI: * CSRT\n" ); - csrt = (struct acpi_csrt *)current; + csrt = ctx->current;acpi_create_csrt (csrt); - current += csrt->header.length; +acpi_inc_align (ctx, csrt->header.length);acpi_add_table (rsdp, csrt); - current =ALIGN (current,16 );debug ("ACPI: * SPCR\n" ); - spcr = (struct acpi_spcr *)current; + spcr = ctx->current;acpi_create_spcr (spcr); - current += spcr->header.length; +acpi_inc_align (ctx, spcr->header.length);acpi_add_table (rsdp, spcr); - current =ALIGN (current,16 ); -debug ("current = %x\n" , current); + addr =map_to_sysmem (ctx->current); +debug ("current = %lx\n" , addr); acpi_rsdp_addr = (unsigned long )rsdp;debug ("ACPI: done\n" ); -return current; +return addr; }ulong acpi_get_rsdp_addr (void )
include/acpi_table.h +36 -0
@@ -27,6 +27,8 @@#if !defined(__ACPI__) +struct acpi_ctx ; +/* * RSDP (Root System Description Pointer) * Note: ACPI 1.0 didn't have length, xsdt_address, and ext_checksum
@@ -512,6 +514,40 @@ int acpi_create_dmar(struct acpi_dmar *dmar, enum dmar_flags flags);*/ void acpi_fill_header (struct acpi_table_header *header,char *signature); +/** +* acpi_align() - Align the ACPI output pointer to a 16-byte boundary +* +* @ctx: ACPI context +*/ +void acpi_align (struct acpi_ctx *ctx); + +/** +* acpi_align_large() - Align the ACPI output pointer to a 64-byte boundary +* +* @ctx: ACPI context +*/ +void acpi_align_large (struct acpi_ctx *ctx); + +/** +* acpi_inc() - Increment the ACPI output pointer by a bit +* +* The pointer is NOT aligned afterwards. +* +* @ctx: ACPI context +* @amount: Amount to increment by +*/ +void acpi_inc (struct acpi_ctx *ctx,uint amount); + +/** +* acpi_inc_align() - Increment the ACPI output pointer by a bit and align +* +* The pointer is aligned afterwards. +* +* @ctx: ACPI context +* @amount: Amount to increment by +*/ +void acpi_inc_align (struct acpi_ctx *ctx,uint amount); +#endif /* !__ACPI__*/ #include <asm/acpi_table.h>
lib/acpi/acpi_table.c +22 -0
@@ -10,6 +10,7 @@#include <acpi_table.h> #include <cpu.h> #include <version.h> +#include <dm/acpi.h> int acpi_create_dmar (struct acpi_dmar *dmar,enum dmar_flags flags) {
@@ -93,3 +94,24 @@ void acpi_fill_header(struct acpi_table_header *header, char *signature) header->oem_revision =U_BOOT_BUILD_DATE ;memcpy (header->aslc_id,ASLC_ID ,4 ); } + +void acpi_align (struct acpi_ctx *ctx) +{ + ctx->current = (void *)ALIGN ((ulong )ctx->current,16 ); +} + +void acpi_align_large (struct acpi_ctx *ctx) +{ + ctx->current = (void *)ALIGN ((ulong )ctx->current,64 ); +} + +void acpi_inc (struct acpi_ctx *ctx,uint amount) +{ + ctx->current += amount; +} + +void acpi_inc_align (struct acpi_ctx *ctx,uint amount) +{ + ctx->current += amount; +acpi_align (ctx); +}
test/dm/acpi.c +28 -0
@@ -152,3 +152,31 @@ static int dm_test_acpi_write_tables(struct unit_test_state *uts)return 0 ; }DM_TEST (dm_test_acpi_write_tables,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT ); + +/* Test basic ACPI functions */ +static int dm_test_acpi_basic (struct unit_test_state *uts) +{ +struct acpi_ctx ctx; + +/* Check align works */ + ctx.current = (void *)5 ; +acpi_align (&ctx); +ut_asserteq_ptr ((void *)16 , ctx.current); + +/* Check that align does nothing if already aligned */ +acpi_align (&ctx); +ut_asserteq_ptr ((void *)16 , ctx.current); +acpi_align_large (&ctx); +ut_asserteq_ptr ((void *)64 , ctx.current); +acpi_align_large (&ctx); +ut_asserteq_ptr ((void *)64 , ctx.current); + +/* Check incrementing */ +acpi_inc (&ctx,3 ); +ut_asserteq_ptr ((void *)67 , ctx.current); +acpi_inc_align (&ctx,3 ); +ut_asserteq_ptr ((void *)80 , ctx.current); + +return 0 ; +} +DM_TEST (dm_test_acpi_basic,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT );
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 22/108 x86: Allow devices to write ACPI tables
In reply to Simon GlassCall the new core function to permit devices to write their own ACPI tables. These tables will appear after all other tables.
---
arch/x86/lib/acpi_table.c | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/lib/acpi_table.c +2 -0
@@ -589,6 +589,8 @@ ulong write_acpi_tables(ulong start_addr)acpi_inc_align (ctx, spcr->header.length);acpi_add_table (rsdp, spcr); +acpi_write_dev_tables (ctx); + addr =map_to_sysmem (ctx->current);debug ("current = %lx\n" , addr);
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 23/108 acpi: Drop code for missing XSDT from acpi_write_rsdp()
In reply to Simon GlassWe don't actually support tables without an XSDT so we can drop this dead code.
---
arch/x86/lib/acpi_table.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-)
arch/x86/lib/acpi_table.c +2 -13
@@ -42,19 +42,8 @@ static void acpi_write_rsdp(struct acpi_rsdp *rsdp, struct acpi_rsdt *rsdt, rsdp->length =sizeof (struct acpi_rsdp ); rsdp->rsdt_address = (u32 )rsdt; -/* -* Revision: ACPI 1.0: 0, ACPI 2.0/3.0/4.0: 2 -* -* Some OSes expect an XSDT to be present for RSD PTR revisions >= 2. -* If we don't have an ACPI XSDT, force ACPI 1.0 (and thus RSD PTR -* revision 0) -*/ -if (xsdt ==NULL ) { - rsdp->revision =ACPI_RSDP_REV_ACPI_1_0 ; - }else { - rsdp->xsdt_address = (u64 )(u32 )xsdt; - rsdp->revision =ACPI_RSDP_REV_ACPI_2_0 ; - } + rsdp->xsdt_address = (u64 )(u32 )xsdt; + rsdp->revision =ACPI_RSDP_REV_ACPI_2_0 ;/* Calculate checksums */ rsdp->checksum =table_compute_checksum ((void *)rsdp,20 );
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 24/108 acpi: Move acpi_add_table() to generic code
In reply to Simon GlassMove this code to a generic location so that we can test it with sandbox. This requires adding a few new fields to acpi_ctx, so drop the local variables used in the original code.
Also use mapmem to avoid pointer-to-address casts which don't work on sandbox.
---
arch/x86/lib/acpi_table.c | 82 +++++---------------------------------- include/acpi_table.h | 9 +++++ include/dm/acpi.h | 5 +++ lib/acpi/acpi_table.c | 64 ++++++++++++++++++++++++++++++ test/dm/acpi.c | 4 ++ 5 files changed, 92 insertions(+), 72 deletions(-)
arch/x86/lib/acpi_table.c +10 -72
@@ -92,66 +92,6 @@ static void acpi_write_xsdt(struct acpi_xsdt *xsdt) sizeof(struct acpi_xsdt)); } -/** -* Add an ACPI table to the RSDT (and XSDT) structure, recalculate length -* and checksum. -*/ -static void acpi_add_table (struct acpi_rsdp *rsdp,void *table) -{ -int i, entries_num; -struct acpi_rsdt *rsdt; -struct acpi_xsdt *xsdt =NULL ; - -/* The RSDT is mandatory while the XSDT is not */ - rsdt = (struct acpi_rsdt *)rsdp->rsdt_address; - -if (rsdp->xsdt_address) - xsdt = (struct acpi_xsdt *)((u32 )rsdp->xsdt_address); - -/* This should always be MAX_ACPI_TABLES */ - entries_num =ARRAY_SIZE (rsdt->entry); - -for (i =0 ; i < entries_num; i++) { -if (rsdt->entry[i] ==0 ) -break ; - } - -if (i >= entries_num) { -debug ("ACPI: Error: too many tables\n" ); -return ; - } - -/* Add table to the RSDT */ - rsdt->entry[i] = (u32 )table; - -/* Fix RSDT length or the kernel will assume invalid entries */ - rsdt->header.length =sizeof (struct acpi_table_header ) + - (sizeof (u32) * (i +1 )); - -/* Re-calculate checksum */ - rsdt->header.checksum =0 ; - rsdt->header.checksum =table_compute_checksum ((u8 *)rsdt, - rsdt->header.length); - -/* -* And now the same thing for the XSDT. We use the same index as for -* now we want the XSDT and RSDT to always be in sync in U-Boot -*/ -if (xsdt) { -/* Add table to the XSDT */ - xsdt->entry[i] = (u64 )(u32 )table; - -/* Fix XSDT length */ - xsdt->header.length =sizeof (struct acpi_table_header ) + - (sizeof (u64) * (i +1 )); - -/* Re-calculate checksum */ - xsdt->header.checksum =0 ; - xsdt->header.checksum =table_compute_checksum ((u8 *)xsdt, - xsdt->header.length); - } -} -static void acpi_create_facs (struct acpi_facs *facs) {memset ((void *)facs,0 ,sizeof (struct acpi_facs ));
@@ -471,8 +411,6 @@ static void acpi_create_spcr(struct acpi_spcr *spcr)ulong write_acpi_tables (ulong start_addr) {struct acpi_ctx sctx, *ctx = &sctx; -struct acpi_rsdp *rsdp; -struct acpi_rsdt *rsdt;struct acpi_xsdt *xsdt;struct acpi_facs *facs;struct acpi_table_header *dsdt;
@@ -494,9 +432,9 @@ ulong write_acpi_tables(ulong start_addr)debug ("ACPI: Writing ACPI tables at %lx\n" , start_addr);/* We need at least an RSDP and an RSDT Table */ - rsdp = ctx->current; + ctx->rsdp = ctx->current;acpi_inc_align (ctx,sizeof (struct acpi_rsdp )); - rsdt = ctx->current; + ctx->rsdt = ctx->current;acpi_inc_align (ctx,sizeof (struct acpi_rsdt )); xsdt = ctx->current;acpi_inc_align (ctx,sizeof (struct acpi_xsdt ));
@@ -509,8 +447,8 @@ ulong write_acpi_tables(ulong start_addr)/* clear all table memory */ memset ((void *)start,0 , ctx->current - start); -acpi_write_rsdp (rsdp, rsdt, xsdt); -acpi_write_rsdt (rsdt); +acpi_write_rsdp (ctx->rsdp, ctx->rsdt, xsdt); +acpi_write_rsdt (ctx->rsdt);acpi_write_xsdt (xsdt);debug ("ACPI: * FACS\n" );
@@ -552,38 +490,38 @@ ulong write_acpi_tables(ulong start_addr) fadt = ctx->current;acpi_inc_align (ctx,sizeof (struct acpi_fadt ));acpi_create_fadt (fadt, facs, dsdt); -acpi_add_table (rsdp, fadt); +acpi_add_table (ctx, fadt);debug ("ACPI: * MADT\n" ); madt = ctx->current;acpi_create_madt (madt);acpi_inc_align (ctx, madt->header.length); -acpi_add_table (rsdp, madt); +acpi_add_table (ctx, madt);debug ("ACPI: * MCFG\n" ); mcfg = ctx->current;acpi_create_mcfg (mcfg);acpi_inc_align (ctx, mcfg->header.length); -acpi_add_table (rsdp, mcfg); +acpi_add_table (ctx, mcfg);debug ("ACPI: * CSRT\n" ); csrt = ctx->current;acpi_create_csrt (csrt);acpi_inc_align (ctx, csrt->header.length); -acpi_add_table (rsdp, csrt); +acpi_add_table (ctx, csrt);debug ("ACPI: * SPCR\n" ); spcr = ctx->current;acpi_create_spcr (spcr);acpi_inc_align (ctx, spcr->header.length); -acpi_add_table (rsdp, spcr); +acpi_add_table (ctx, spcr);acpi_write_dev_tables (ctx); addr =map_to_sysmem (ctx->current);debug ("current = %lx\n" , addr); - acpi_rsdp_addr = (unsigned long )rsdp; + acpi_rsdp_addr = (unsigned long )ctx->rsdp;debug ("ACPI: done\n" );return addr;
include/acpi_table.h +9 -0
@@ -548,6 +548,15 @@ void acpi_inc(struct acpi_ctx *ctx, uint amount);*/ void acpi_inc_align (struct acpi_ctx *ctx,uint amount); +/** +* acpi_add_table() - Add a new table to the RSDP and XSDT +* +* @ctx: ACPI context +* @table: Table to add +* @return 0 if OK, -E2BIG if too many tables +*/ +int acpi_add_table (struct acpi_ctx *ctx,void *table); +#endif /* !__ACPI__*/ #include <asm/acpi_table.h>
include/dm/acpi.h +5 -0
@@ -30,9 +30,14 @@* This contains a few useful pieces of information used when writing * * @current: Current address for writing +* @rsdp: Pointer to the Root System Description Pointer, typically used when +* adding a new table. The RSDP holds pointers to the RSDP and XSDT. +* @rsdt: Pointer to the Root System Description Table */ struct acpi_ctx {void *current; +struct acpi_rsdp *rsdp; +struct acpi_rsdt *rsdt; };/**
lib/acpi/acpi_table.c +64 -0
73 lines not on this page · raw message
test/dm/acpi.c +4 -0
@@ -21,10 +21,14 @@ static int testacpi_write_tables(const struct udevice *dev, struct acpi_ctx *ctx) {struct acpi_dmar *dmar; +int ret; dmar = (struct acpi_dmar *)ctx->current;acpi_create_dmar (dmar,DMAR_INTR_REMAP ); ctx->current +=sizeof (struct acpi_dmar ); + ret =acpi_add_table (ctx, dmar); +if (ret) +return log_msg_ret ("add" , ret);return 0 ; }
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 25/108 acpi: Put table-setup code in its own function
In reply to Simon GlassWe always write three basic tables to ACPI at the start. Move this into its own function, along with acpi_fill_header(), so we can write a test for this code.
---
arch/x86/lib/acpi_table.c | 86 +-------------------------------------- include/acpi_table.h | 10 +++++ lib/acpi/acpi_table.c | 86 ++++++++++++++++++++++++++++++++++++++- test/dm/acpi.c | 55 ++++++++++++++++++++++++- 4 files changed, 148 insertions(+), 89 deletions(-)
arch/x86/lib/acpi_table.c +1 -85
@@ -31,67 +31,6 @@ extern const unsigned char AmlCode[];/* ACPI RSDP address to be used in boot parameters */ static ulong acpi_rsdp_addr; -static void acpi_write_rsdp (struct acpi_rsdp *rsdp,struct acpi_rsdt *rsdt, -struct acpi_xsdt *xsdt) -{ -memset (rsdp,0 ,sizeof (struct acpi_rsdp )); - -memcpy (rsdp->signature,RSDP_SIG ,8 ); -memcpy (rsdp->oem_id,OEM_ID ,6 ); - - rsdp->length =sizeof (struct acpi_rsdp ); - rsdp->rsdt_address = (u32 )rsdt; - - rsdp->xsdt_address = (u64 )(u32 )xsdt; - rsdp->revision =ACPI_RSDP_REV_ACPI_2_0 ; - -/* Calculate checksums */ - rsdp->checksum =table_compute_checksum ((void *)rsdp,20 ); - rsdp->ext_checksum =table_compute_checksum ((void *)rsdp, -sizeof (struct acpi_rsdp )); -} - -void acpi_fill_header (struct acpi_table_header *header,char *signature) -{ -memcpy (header->signature, signature,4 ); -memcpy (header->oem_id,OEM_ID ,6 ); -memcpy (header->oem_table_id,OEM_TABLE_ID ,8 ); - header->oem_revision =U_BOOT_BUILD_DATE ; -memcpy (header->aslc_id,ASLC_ID ,4 ); -} - -static void acpi_write_rsdt (struct acpi_rsdt *rsdt) -{ -struct acpi_table_header *header = &(rsdt->header); - -/* Fill out header fields */ -acpi_fill_header (header,"RSDT" ); - header->length =sizeof (struct acpi_rsdt ); - header->revision =1 ; - -/* Entries are filled in later, we come with an empty set */ - -/* Fix checksum */ - header->checksum =table_compute_checksum ((void *)rsdt, -sizeof (struct acpi_rsdt )); -} - -static void acpi_write_xsdt (struct acpi_xsdt *xsdt) -{ -struct acpi_table_header *header = &(xsdt->header); - -/* Fill out header fields */ -acpi_fill_header (header,"XSDT" ); - header->length =sizeof (struct acpi_xsdt ); - header->revision =1 ; - -/* Entries are filled in later, we come with an empty set */ - -/* Fix checksum */ - header->checksum =table_compute_checksum ((void *)xsdt, -sizeof (struct acpi_xsdt )); -} -static void acpi_create_facs (struct acpi_facs *facs) {memset ((void *)facs,0 ,sizeof (struct acpi_facs ));
@@ -411,7 +350,6 @@ static void acpi_create_spcr(struct acpi_spcr *spcr)ulong write_acpi_tables (ulong start_addr) {struct acpi_ctx sctx, *ctx = &sctx; -struct acpi_xsdt *xsdt;struct acpi_facs *facs;struct acpi_table_header *dsdt;struct acpi_fadt *fadt;
@@ -424,32 +362,10 @@ ulong write_acpi_tables(ulong start_addr)int i; start =map_sysmem (start_addr,0 ); - ctx->current = start; - -/* Align ACPI tables to 16 byte */ -acpi_align (ctx);debug ("ACPI: Writing ACPI tables at %lx\n" , start_addr); -/* We need at least an RSDP and an RSDT Table */ - ctx->rsdp = ctx->current; -acpi_inc_align (ctx,sizeof (struct acpi_rsdp )); - ctx->rsdt = ctx->current; -acpi_inc_align (ctx,sizeof (struct acpi_rsdt )); - xsdt = ctx->current; -acpi_inc_align (ctx,sizeof (struct acpi_xsdt )); -/* -* Per ACPI spec, the FACS table address must be aligned to a 64 byte -* boundary (Windows checks this, but Linux does not). -*/ -acpi_align_large (ctx); - -/* clear all table memory */ -memset ((void *)start,0 , ctx->current - start); - -acpi_write_rsdp (ctx->rsdp, ctx->rsdt, xsdt); -acpi_write_rsdt (ctx->rsdt); -acpi_write_xsdt (xsdt); +acpi_setup_base_tables (ctx, start);debug ("ACPI: * FACS\n" ); facs = ctx->current;
include/acpi_table.h +10 -0
@@ -557,6 +557,16 @@ void acpi_inc_align(struct acpi_ctx *ctx, uint amount);*/ int acpi_add_table (struct acpi_ctx *ctx,void *table); +/** +* acpi_setup_base_tables() - Set up context along with RSDP, RSDT and XDST +* +* Set up the context with the given start position. Some basic tables are +* always needed, so set them up as well. +* +* @ctx: Context to set up +*/ +void acpi_setup_base_tables (struct acpi_ctx *ctx,void *start); +#endif /* !__ACPI__*/ #include <asm/acpi_table.h>
lib/acpi/acpi_table.c +84 -2
99 lines not on this page · raw message
test/dm/acpi.c +53 -2
77 lines not on this page · raw message
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 26/108 acpi: Move the xsdt pointer to acpi_ctx
In reply to Simon GlassPut this in the context along with the other important pointers.
---
include/dm/acpi.h | 2 ++ lib/acpi/acpi_table.c | 38 ++++++++++++++++---------------------- test/dm/acpi.c | 5 +++++ 3 files changed, 23 insertions(+), 22 deletions(-)
include/dm/acpi.h +2 -0
@@ -33,11 +33,13 @@* @rsdp: Pointer to the Root System Description Pointer, typically used when * adding a new table. The RSDP holds pointers to the RSDP and XSDT. * @rsdt: Pointer to the Root System Description Table +* @xsdt: Pointer to the Extended System Description Table */ struct acpi_ctx {void *current;struct acpi_rsdp *rsdp;struct acpi_rsdt *rsdt; +struct acpi_xsdt *xsdt; };/**
lib/acpi/acpi_table.c +16 -22
@@ -126,13 +126,11 @@ int acpi_add_table(struct acpi_ctx *ctx, void *table) {int i, entries_num;struct acpi_rsdt *rsdt; -struct acpi_xsdt *xsdt =NULL ; +struct acpi_xsdt *xsdt;/* The RSDT is mandatory while the XSDT is not */ rsdt = ctx->rsdt; - -if (ctx->rsdp->xsdt_address) - xsdt =map_sysmem (ctx->rsdp->xsdt_address,0 ); + xsdt = ctx->xsdt;/* This should always be MAX_ACPI_TABLES */ entries_num =ARRAY_SIZE (rsdt->entry);
@@ -163,19 +161,17 @@ int acpi_add_table(struct acpi_ctx *ctx, void *table)* And now the same thing for the XSDT. We use the same index as for * now we want the XSDT and RSDT to always be in sync in U-Boot */ -if (xsdt) { -/* Add table to the XSDT */ - xsdt->entry[i] =map_to_sysmem (table); - -/* Fix XSDT length */ - xsdt->header.length =sizeof (struct acpi_table_header ) + - (sizeof (u64) * (i +1 )); - -/* Re-calculate checksum */ - xsdt->header.checksum =0 ; - xsdt->header.checksum = - table_compute_checksum((xsdt, xsdt->header.length); - } +/* Add table to the XSDT */ + xsdt->entry[i] =map_to_sysmem (table); + +/* Fix XSDT length */ + xsdt->header.length =sizeof (struct acpi_table_header ) + + (sizeof (u64) * (i +1 )); + +/* Re-calculate checksum */ + xsdt->header.checksum =0 ; + xsdt->header.checksum =table_compute_checksum (xsdt, + xsdt->header.length);return 0 ; }
@@ -234,8 +230,6 @@ static void acpi_write_xsdt(struct acpi_xsdt *xsdt)void acpi_setup_base_tables (struct acpi_ctx *ctx,void *start) { -struct acpi_xsdt *xsdt; - ctx->current = start;/* Align ACPI tables to 16 byte */
@@ -246,7 +240,7 @@ void acpi_setup_base_tables(struct acpi_ctx *ctx, void *start)acpi_inc_align (ctx,sizeof (struct acpi_rsdp )); ctx->rsdt = ctx->current;acpi_inc_align (ctx,sizeof (struct acpi_rsdt )); - xsdt = ctx->current; + ctx->xsdt = ctx->current;acpi_inc_align (ctx,sizeof (struct acpi_xsdt ));/* * Per ACPI spec, the FACS table address must be aligned to a 64 byte
@@ -257,7 +251,7 @@ void acpi_setup_base_tables(struct acpi_ctx *ctx, void *start)/* clear all table memory */ memset ((void *)start,'\0' , ctx->current - start); -acpi_write_rsdp (ctx->rsdp, ctx->rsdt, xsdt); +acpi_write_rsdp (ctx->rsdp, ctx->rsdt, ctx->xsdt);acpi_write_rsdt (ctx->rsdt); -acpi_write_xsdt (xsdt); +acpi_write_xsdt (ctx->xsdt); }
test/dm/acpi.c +5 -0
@@ -161,6 +161,10 @@ static int dm_test_acpi_write_tables(struct unit_test_state *uts)ut_asserteq (map_to_sysmem (dmar +1 ), ctx.rsdt->entry[1 ]);ut_asserteq (0 , ctx.rsdt->entry[2 ]); +ut_asserteq (map_to_sysmem (dmar), ctx.xsdt->entry[0 ]); +ut_asserteq (map_to_sysmem (dmar +1 ), ctx.xsdt->entry[1 ]); +ut_asserteq (0 , ctx.xsdt->entry[2 ]); +return 0 ; }DM_TEST (dm_test_acpi_write_tables,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT );
@@ -221,6 +225,7 @@ static int dm_test_acpi_setup_base_tables(struct unit_test_state *uts)ut_assertok (table_compute_checksum (rsdt,sizeof (*rsdt))); xsdt =PTR_ALIGN ((void *)rsdt +sizeof (*rsdt),16 ); +ut_asserteq_ptr (xsdt, ctx.xsdt);ut_assertok (memcmp ("XSDT" , xsdt->header.signature,ACPI_NAME_LEN ));ut_asserteq (sizeof (*xsdt), xsdt->header.length);ut_assertok (table_compute_checksum (xsdt,sizeof (*xsdt)));
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 27/108 acpi: Add an acpi command
In reply to Simon GlassIt is useful to dump ACPI tables in U-Boot to see what has been generated. Add a command to handle this.
To allow the command to find the tables, add a position into the global data.
Support subcommands to list and dump the tables.
---
arch/sandbox/include/asm/global_data.h | 1 + arch/x86/include/asm/global_data.h | 1 + cmd/Kconfig | 14 ++ cmd/Makefile | 1 + cmd/acpi.c | 179 +++++++++++++++++++++++++ lib/acpi/acpi_table.c | 1 + test/dm/acpi.c | 73 ++++++++++ 7 files changed, 270 insertions(+) create mode 100644 cmd/acpi.c
arch/sandbox/include/asm/global_data.h +1 -0
@@ -13,6 +13,7 @@struct arch_global_data {uint8_t *ram_buf;/* emulated RAM buffer */ void *text_base;/* pointer to base of text region */ +ulong acpi_start;/* Start address of ACPI tables */ };#include <asm-generic/global_data.h>
arch/x86/include/asm/global_data.h +1 -0
@@ -123,6 +123,7 @@ struct arch_global_data {#ifdef CONFIG_FSP_VERSION2 struct fsp_header *fsp_s_hdr;/* Pointer to FSP-S header */ #endif + ulong acpi_start; /* Start address of ACPI tables */ };#endif
cmd/Kconfig +14 -0
@@ -190,6 +190,20 @@ comment "Commands" menu "Info commands" +config CMD_ACPI + bool "acpi" + default y if ACPIGEN + help + List and dump ACPI tables. ACPI (Advanced Configuration and Power + Interface) is used mostly on x86 for providing information to the + Operating System about devices in the system. The tables are set up + by the firmware, typically U-Boot but possibly an earlier firmware + module, if U-Boot is chain-loaded from something else. ACPI tables + can also include code, to perform hardware-specific tasks required + by the Operating Systems. This allows some amount of separation + between the firmware and OS, and is particularly useful when you + want to make hardware changes without the OS needing to be adjusted. + config CMD_BDI bool "bdinfo" default y
cmd/Makefile +1 -0
@@ -11,6 +11,7 @@ obj-y += help.o obj-y += version.o # command +obj-$(CONFIG_CMD_ACPI) += acpi.o obj-$(CONFIG_CMD_AES) += aes.o obj-$(CONFIG_CMD_AB_SELECT) += ab_select.o obj-$(CONFIG_CMD_ADC) += adc.o
cmd/acpi.c new file +179 -0
179 lines not on this page · raw message
lib/acpi/acpi_table.c +1 -0
@@ -234,6 +234,7 @@ void acpi_setup_base_tables(struct acpi_ctx *ctx, void *start)/* Align ACPI tables to 16 byte */ acpi_align (ctx); + gd->arch.acpi_start =map_to_sysmem (ctx->current);/* We need at least an RSDP and an RSDT Table */ ctx->rsdp = ctx->current;
test/dm/acpi.c +73 -0
91 lines not on this page · raw message
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 28/108 acpi: Add some tables required by the generation code
In reply to Simon GlassThe code which generates ACPI tables programmatically, add a few ACPI definitions required by that code.
---
include/acpi_table.h | 50 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+)
include/acpi_table.h +50 -0
@@ -29,6 +29,18 @@struct acpi_ctx ; +/* +* The assigned ACPI ID for the coreboot project is 'BOOT' +* http://www.uefi.org/acpi_id_list +*/ +#define COREBOOT_ACPI_ID "BOOT"/* ACPI ID for coreboot HIDs */ + +/* List of ACPI HID that use the coreboot ACPI ID */ +enum coreboot_acpi_ids { +COREBOOT_ACPI_ID_CBTABLE =0x0000 ,/* BOOT0000 */ +COREBOOT_ACPI_ID_MAX =0xFFFF ,/* BOOTFFFF */ +}; +/* * RSDP (Root System Description Pointer) * Note: ACPI 1.0 didn't have length, xsdt_address, and ext_checksum
@@ -358,6 +370,44 @@ struct acpi_csrt_shared_info {u32 max_block_size; }; +struct __packed acpi_cstate { +u8 ctype; +u16 latency; +u32 power; +struct acpi_gen_regaddr resource; +}; + +struct __packed acpi_tstate { +u32 percent; +u32 power; +u32 latency; +u32 control; +u32 status; +}; + +/* Port types for ACPI _UPC object */ +enum acpi_upc_type { +UPC_TYPE_A , +UPC_TYPE_MINI_AB , +UPC_TYPE_EXPRESSCARD , +UPC_TYPE_USB3_A , +UPC_TYPE_USB3_B , +UPC_TYPE_USB3_MICRO_B , +UPC_TYPE_USB3_MICRO_AB , +UPC_TYPE_USB3_POWER_B , +UPC_TYPE_C_USB2_ONLY , +UPC_TYPE_C_USB2_SS_SWITCH , +UPC_TYPE_C_USB2_SS , +UPC_TYPE_PROPRIETARY =0xff , +/* +* The following types are not directly defined in the ACPI +* spec but are used by coreboot to identify a USB device type. +*/ +UPC_TYPE_INTERNAL =0xff , +UPC_TYPE_UNUSED , +UPC_TYPE_HUB +}; +enum dmar_type {DMAR_DRHD =0 ,DMAR_RMRR =1 ,
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 29/108 acpi: Add generation code for devices
In reply to Simon GlassSome devices need to create ACPI tables to communcate their parameters to Linux. Add support for this.
---
include/acpi_device.h | 707 ++++++++++++++++++++++++++ lib/acpi/acpi_device.c | 1093 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1800 insertions(+) create mode 100644 include/acpi_device.h create mode 100644 lib/acpi/acpi_device.c
include/acpi_device.h new file +707 -0
@@ -0,0 +1,707 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Generation of tables for particular device types +* +* Copyright 2019 Google LLC +* Mostly taken from coreboot file of the same name +*/ + +#ifndef __ACPI_DEVICE_H +#define __ACPI_DEVICE_H + +#include <i2c.h> +#include <irq.h> +#include <spi.h> +#include <asm-generic/gpio.h> + +struct acpi_ctx ; +struct irq ; +struct gpio_desc ; +struct udevice ; + +/** +* enum acpi_dp_type - types of device property objects +* +* These refer to the types defined by struct acpi_dp below +* +* @ACPI_DP_TYPE_UNKNOWN: Unknown / do not use +* @ACPI_DP_TYPE_INTEGER: Integer value (u64) in @integer +* @ACPI_DP_TYPE_STRING: String value in @string +* @ACPI_DP_TYPE_REFERENCE: Reference to another object, with value in @string +* @ACPI_DP_TYPE_TABLE: Type for a top-level table which may have children +* @ACPI_DP_TYPE_ARRAY: Array of items with first item in @array and following +* items linked from that item's @next +* @ACPI_DP_TYPE_CHILD: Child object, with siblings in that child's @next +*/ +enum acpi_dp_type { +ACPI_DP_TYPE_UNKNOWN , +ACPI_DP_TYPE_INTEGER , +ACPI_DP_TYPE_STRING , +ACPI_DP_TYPE_REFERENCE , +ACPI_DP_TYPE_TABLE , +ACPI_DP_TYPE_ARRAY , +ACPI_DP_TYPE_CHILD , +}; + +/* ACPI descriptor values for common descriptors: SERIAL_BUS means I2C */ +#define ACPI_DESCRIPTOR_LARGE BIT(7) +#define ACPI_DESCRIPTOR_INTERRUPT (ACPI_DESCRIPTOR_LARGE | 9) +#define ACPI_DESCRIPTOR_GPIO (ACPI_DESCRIPTOR_LARGE | 12) +#define ACPI_DESCRIPTOR_SERIAL_BUS (ACPI_DESCRIPTOR_LARGE | 14) + +/* +* PRP0001 is a special DT namespace link device ID. It provides a means to use +* existing DT-compatible device identification in ACPI. When this _HID is used +* by an ACPI device, the ACPI subsystem in OS looks up "compatible" property in +* the device object's _DSD and will use the value of that property to identify +* the corresponding device in analogy with the original DT device +* identification algorithm. +* More details can be found in Linux kernel documentation: +* Documentation/acpi/enumeration.txt +*/ +#define ACPI_DT_NAMESPACE_HID "PRP0001" + +/* Length of a full path to an ACPI device */ +#define ACPI_PATH_MAX 30 + +/** +* acpi_device_name() - Locate and return the ACPI name for this device +* +* @dev: Device to check +* @name: Returns the character name, must be at least ACPI_NAME_MAX long +* @return 0 if OK, -ve on error +*/ +int acpi_device_name (const struct udevice *dev,char *name); + +/** +* acpi_device_path() - Get the full path to an ACPI device +* +* This gets the full path in the form XXXX.YYYY.ZZZZ where XXXX is the root +* and ZZZZ is the device. All parent devices are added to the path. +* +* @dev: Device to check +* @buf: Buffer to place the path in (should be ACPI_PATH_MAX long) +* @maxlen: Size of buffer (typically ACPI_PATH_MAX) +* @return 0 if OK, -ve on error +*/ +int acpi_device_path (const struct udevice *dev,char *buf,int maxlen); + +/** +* acpi_device_scope() - Get the scope of an ACPI device +* +* This gets the scope which is the full path of the parent device, as per +* acpi_device_path(). +* +* @dev: Device to check +* @buf: Buffer to place the path in (should be ACPI_PATH_MAX long) +* @maxlen: Size of buffer (typically ACPI_PATH_MAX) +* @return 0 if OK, -EINVAL if the device has no parent, other -ve on other +* error +*/ +int acpi_device_scope (const struct udevice *dev,char *scope,int maxlen); + +/** +* acpi_device_status() - Get the status of a device +* +* This currently just returns ACPI_STATUS_DEVICE_ALL_ON. It does not support +* inactive or hidden devices. +* +* @dev: Device to check +* @return device status, as ACPI_STATUS_DEVICE_... +*/ +int acpi_device_status (const struct udevice *dev); + +/** enum acpi_irq_mode - edge/level trigger mode */ +enum acpi_irq_mode { +ACPI_IRQ_EDGE_TRIGGERED , +ACPI_IRQ_LEVEL_TRIGGERED , +}; + +/** +* enum acpi_irq_polarity - polarity of interrupt +* +* @ACPI_IRQ_ACTIVE_LOW - for ACPI_IRQ_EDGE_TRIGGERED this means falling edge +* @ACPI_IRQ_ACTIVE_HIGH - for ACPI_IRQ_EDGE_TRIGGERED this means rising edge +* @ACPI_IRQ_ACTIVE_BOTH - not meaningful for ACPI_IRQ_EDGE_TRIGGERED +*/ +enum acpi_irq_polarity { +ACPI_IRQ_ACTIVE_LOW , +ACPI_IRQ_ACTIVE_HIGH , +ACPI_IRQ_ACTIVE_BOTH , +}; + +/** +* enum acpi_irq_shared - whether interrupt is shared or not +* +* @ACPI_IRQ_EXCLUSIVE: only this device uses the interrupt +* @ACPI_IRQ_SHARED: other devices may use this interrupt +*/ +enum acpi_irq_shared { +ACPI_IRQ_EXCLUSIVE , +ACPI_IRQ_SHARED , +}; + +/** enum acpi_irq_wake - indicates whether this interrupt can wake the device */ +enum acpi_irq_wake { +ACPI_IRQ_NO_WAKE , +ACPI_IRQ_WAKE , +}; + +/** +* struct acpi_irq - representation of an ACPI interrupt +* +* @pin: ACPI pin that is monitored for the interrupt +* @mode: Edge/level triggering +* @polarity: Interrupt polarity +* @shared: Whether interrupt is shared or not +* @wake: Whether interrupt can wake the device from sleep +*/ +struct acpi_irq { +unsigned int pin; +enum acpi_irq_mode mode; +enum acpi_irq_polarity polarity; +enum acpi_irq_shared shared; +enum acpi_irq_wake wake; +}; + +/** +* enum acpi_gpio_type - type of the descriptor +* +* @ACPI_GPIO_TYPE_INTERRUPT: GpioInterrupt +* @ACPI_GPIO_TYPE_IO: GpioIo +*/ +enum acpi_gpio_type { +ACPI_GPIO_TYPE_INTERRUPT , +ACPI_GPIO_TYPE_IO , +}; + +/** +* enum acpi_gpio_pull - pull direction +* +* @ACPI_GPIO_PULL_DEFAULT: Use default value for pin +* @ACPI_GPIO_PULL_UP: Pull up +* @ACPI_GPIO_PULL_DOWN: Pull down +* @ACPI_GPIO_PULL_NONE: No pullup/pulldown +*/ +enum acpi_gpio_pull { +ACPI_GPIO_PULL_DEFAULT , +ACPI_GPIO_PULL_UP , +ACPI_GPIO_PULL_DOWN , +ACPI_GPIO_PULL_NONE , +}; + +/** +* enum acpi_gpio_io_restrict - controls input/output of pin +* +* @ACPI_GPIO_IO_RESTRICT_NONE: no restrictions +* @ACPI_GPIO_IO_RESTRICT_INPUT: input only (no output) +* @ACPI_GPIO_IO_RESTRICT_OUTPUT: output only (no input) +* @ACPI_GPIO_IO_RESTRICT_PRESERVE: preserve settings when driver not active +*/ +enum acpi_gpio_io_restrict { +ACPI_GPIO_IO_RESTRICT_NONE , +ACPI_GPIO_IO_RESTRICT_INPUT , +ACPI_GPIO_IO_RESTRICT_OUTPUT , +ACPI_GPIO_IO_RESTRICT_PRESERVE , +}; + +/** enum acpi_gpio_polarity - controls the GPIO polarity */ +enum acpi_gpio_polarity { +ACPI_GPIO_ACTIVE_HIGH =0 , +ACPI_GPIO_ACTIVE_LOW =1 , +}; + +#define ACPI_GPIO_REVISION_ID 1 +#define ACPI_GPIO_MAX_PINS 2 + +/** +* struct acpi_gpio - representation of an ACPI GPIO +* +* @pin_count: Number of pins represented +* @pins: List of pins +* @type: GPIO type +* @pull: Pullup/pulldown setting +* @resource: Resource name for this GPIO controller +* For GpioInt: +* @interrupt_debounce_timeout: Debounce timeout in units of 10us +* @irq: Interrupt +* +* For GpioIo: +* @output_drive_strength: Drive strength in units of 10uA +* @io_shared; true if GPIO is shared +* @io_restrict: I/O restriction setting +* @polarity: GPIO polarity +*/ +struct acpi_gpio { +int pin_count; +u16 pins[ACPI_GPIO_MAX_PINS ]; + +enum acpi_gpio_type type; +enum acpi_gpio_pull pull; +char resource[ACPI_PATH_MAX ]; + +/* GpioInt */ +u16 interrupt_debounce_timeout; +struct acpi_irq irq; + +/* GpioIo */ +u16 output_drive_strength; +bool io_shared; +enum acpi_gpio_io_restrict io_restrict; +enum acpi_gpio_polarity polarity; +}; + +/* ACPI Descriptors for Serial Bus interfaces */ +#define ACPI_SERIAL_BUS_TYPE_I2C 1 +#define ACPI_SERIAL_BUS_TYPE_SPI 2 +#define ACPI_I2C_SERIAL_BUS_REVISION_ID 1/* TODO: upgrade to 2 */ +#define ACPI_I2C_TYPE_SPECIFIC_REVISION_ID 1 +#define ACPI_SPI_SERIAL_BUS_REVISION_ID 1 +#define ACPI_SPI_TYPE_SPECIFIC_REVISION_ID 1 + +/** +* struct acpi_gpio - representation of an ACPI I2C device +* +* @address: 7-bit or 10-bit I2C address +* @mode_10bit: Which address size is used +* @speed: Bus speed in Hz +* @resource: Resource name for the I2C controller +*/ +struct acpi_i2c { +u16 address; +enum i2c_address_mode mode_10bit; +enum i2c_speed_rate speed; +const char *resource; +}; + +/** +* struct acpi_spi - representation of an ACPI SPI device +* +* @device_select: Chip select used by this device (typically 0) +* @device_select_polarity: Polarity for the device +* @wire_mode: Number of wires used for SPI +* @speed: Bus speed in Hz +* @data_bit_length: Word length for SPI (typically 8) +* @clock_phase: Clock phase to capture data +* @clock_polarity: Bus polarity +* @resource: Resource name for the SPI controller +*/ +struct acpi_spi { +u16 device_select; +enum spi_polarity device_select_polarity; +enum spi_wire_mode wire_mode; +unsigned int speed; +u8 data_bit_length; +enum spi_clock_phase clock_phase; +enum spi_polarity clock_polarity; +const char *resource; +}; + +/** +* struct acpi_power_res_params - power on/off sequence information +* +* This provides GPIOs and timing information for powering a device on and off. +* This can be applied to any device that has power control, so is fairly +* generic. +* +* @reset_gpio: GPIO used to take device out of reset or to put it into reset +* @reset_delay_ms: Delay to be inserted after device is taken out of reset +* (_ON method delay) +* @reset_off_delay_ms: Delay to be inserted after device is put into reset +* (_OFF method delay) +* @enable_gpio: GPIO used to enable device +* @enable_delay_ms: Delay to be inserted after device is enabled +* @enable_off_delay_ms: Delay to be inserted after device is disabled +* (_OFF method delay) +* @stop_gpio: GPIO used to stop operation of device +* @stop_delay_ms: Delay to be inserted after disabling stop (_ON method delay) +* @stop_off_delay_ms: Delay to be inserted after enabling stop. +* (_OFF method delay) +*/ +struct acpi_power_res_params { +struct acpi_gpio *reset_gpio; +unsigned int reset_delay_ms; +unsigned int reset_off_delay_ms; +struct acpi_gpio *enable_gpio; +unsigned int enable_delay_ms; +unsigned int enable_off_delay_ms; +struct acpi_gpio *stop_gpio; +unsigned int stop_delay_ms; +unsigned int stop_off_delay_ms; +}; + +/** +* struct acpi_dp - ACPI device properties +* +* Writing Device Properties objects via _DSD +* +* This provides a structure to handle nested device-specific data which ends +* up in a _DSD table. +* +* https://www.kernel.org/doc/html/latest/firmware-guide/acpi/DSD-properties-rules.html +* https://uefi.org/sites/default/files/resources/_DSD-device-properties-UUID.pdf +* https://uefi.org/sites/default/files/resources/_DSD-hierarchical-data-extension-UUID-v1.1.pdf +* +* The Device Property Hierarchy can be multiple levels deep with multiple +* children possible in each level. In order to support this flexibility +* the device property hierarchy must be built up before being written out. +* +* For example: +* +* // Child table with string and integer +* struct acpi_dp *child = acpi_dp_new_table("CHLD"); +* acpi_dp_add_string(child, "childstring", "CHILD"); +* acpi_dp_add_integer(child, "childint", 100); +* +* // _DSD table with integer and gpio and child pointer +* struct acpi_dp *dsd = acpi_dp_new_table("_DSD"); +* acpi_dp_add_integer(dsd, "number1", 1); +* acpi_dp_add_gpio(dsd, "gpio", "\_SB.PCI0.GPIO", 0, 0, 1); +* acpi_dp_add_child(dsd, "child", child); +* +* // Write entries into SSDT and clean up resources +* acpi_dp_write(dsd); +* +* Name(_DSD, Package() { +* ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301") +* Package() { +* Package() { "gpio", Package() { \_SB.PCI0.GPIO, 0, 0, 0 } } +* Package() { "number1", 1 } +* } +* ToUUID("dbb8e3e6-5886-4ba6-8795-1319f52a966b") +* Package() { +* Package() { "child", CHLD } +* } +* } +* Name(CHLD, Package() { +* ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301") +* Package() { +* Package() { "childstring", "CHILD" } +* Package() { "childint", 100 } +* } +* } +* +* @type: Table type +* @name: Name of object, typically _DSD but could be CHLD for a child object +* @next: Next object in list (next array element or next sibling) +* @child: Pointer to first child, if @type == ACPI_DP_TYPE_CHILD, else NULL +* @array: First array element, if @type == ACPI_DP_TYPE_ARRAY, else NULL +* @integer: Integer value of the property, if @type == ACPI_DP_TYPE_INTEGER +* @string: String value of the property, if @type == ACPI_DP_TYPE_STRING; +* child name if @type == ACPI_DP_TYPE_CHILD; +* reference name if @type == ACPI_DP_TYPE_REFERENCE; +*/ +struct acpi_dp { +enum acpi_dp_type type; +const char *name; +struct acpi_dp *next; +union { +struct acpi_dp *child; +struct acpi_dp *array; + }; +union { +u64 integer; +const char *string; + }; +}; + +/** +* acpi_dp_new_table() - Start a new Device Property table +* +* @ref: ACPI reference (e.g. "_DSD") +* @return pointer to table, or NULL if out of memory +*/ +struct acpi_dp *acpi_dp_new_table (const char *ref); + +/** +* acpi_dp_add_integer() - Add integer Device Property +* +* A new node is added to the end of the property list of @dp +* +* @dp: Table to add this property to +* @name: Name of property +* @value: Integer value +* @return pointer to new node, or NULL if out of memory +*/ +struct acpi_dp *acpi_dp_add_integer (struct acpi_dp *dp,const char *name, +u64 value); + +/** +* acpi_dp_add_string() - Add string Device Property +* +* A new node is added to the end of the property list of @dp +* +* @dp: Table to add this property to +* @name: Name of property +* @string: String value +* @return pointer to new node, or NULL if out of memory +*/ +struct acpi_dp *acpi_dp_add_string (struct acpi_dp *dp,const char *name, +const char *string); + +/** +* acpi_dp_add_reference() - Add reference Device Property +* +* A new node is added to the end of the property list of @dp +* +* @dp: Table to add this property to +* @name: Name of property +* @reference: Reference value +* @return pointer to new node, or NULL if out of memory +*/ +struct acpi_dp *acpi_dp_add_reference (struct acpi_dp *dp,const char *name, +const char *reference); + +/** +* acpi_dp_add_array() - Add array Device Property +* +* A new node is added to the end of the property list of @dp, with the array +* attached to that. +* +* @dp: Table to add this property to +* @name: Name of property +* @return pointer to new node, or NULL if out of memory +*/ +struct acpi_dp *acpi_dp_add_array (struct acpi_dp *dp,struct acpi_dp *array); + +/** +* acpi_dp_add_integer_array() - Add an array of integers +* +* A new node is added to the end of the property list of @dp, with the array +* attached to that. Each element of the array becomes a new node. +* +* @dp: Table to add this property to +* @name: Name of property +* @return pointer to new array node, or NULL if out of memory +*/ +struct acpi_dp *acpi_dp_add_integer_array (struct acpi_dp *dp,const char *name, +u64 *array,int len); + +/** +* acpi_dp_add_gpio() - Add a GPIO binding Device Property +* +* A new node is added to the end of the property list of @dp, with the +* GPIO properties added to the the new node +* +* @dp: Table to add this property to +* @name: Name of property +* @ref: Reference of the device that has _CRS containing GpioIO()/GpioInt() +* @index: Index of the GPIO resource in _CRS starting from zero +* @pin: Pin in the GPIO resource, typically zero +* @active_low: true if pin is active low +* @return pointer to new node, or NULL if out of memory +*/ +struct acpi_dp *acpi_dp_add_gpio (struct acpi_dp *dp,const char *name, +const char *ref,int index,int pin, +bool active_low); + +/** +* acpi_dp_add_child() - Add a child table of Device Properties +* +* A new node is added as a child of @dp +* +* @dp: Table to add this child to +* @name: Name of child +* @child: Child node to add +* @return pointer to new array node, or NULL if out of memory +*/ +struct acpi_dp *acpi_dp_add_child (struct acpi_dp *dp,const char *name, +struct acpi_dp *child); + +/** +* acpi_dp_add_property_list() - Add a list of of Device Properties +* +* This adds a list of properties to @dp. Any properties without a name or of +* type ACPI_DP_TYPE_UNKNOWN are ignored. +* +* @dp: Table to add properties to +* @property_list: List of properties to add +* @property_count: Number of properties in the list +* @return number of properties added +*/ +size_t acpi_dp_add_property_list (struct acpi_dp *dp, +const struct acpi_dp *property_list, +size_t property_count); + +/** +* acpi_dp_write() - Write Device Property hierarchy and clean up resources +* +* This writes the table using acpigen and then frees it +* +* @table: Table to write +* @return 0 if OK, -ve on error +*/ +int acpi_dp_write (struct acpi_ctx *ctx,struct acpi_dp *table); + +/** +* acpi_device_write_i2c_dev() - Write an I2C device to ACPI, including +* information ACPI needs to use it. +* +* This writes a serial bus descriptor for the I2C device so that ACPI can +*/ +int acpi_device_write_i2c_dev (struct acpi_ctx *ctx,const struct udevice *dev); + +/** +* struct acpi_i2c_priv - Information read from device tree +* +* This is used by devices which want to specify various pieces of ACPI +* information, including power control. It allows a generic function to +* generate the information for ACPI, based on device-tree properties. +* +* @disable_gpio_export_in_crs: Don't export GPIOs in the CRS +* @reset_gpio: GPIO used to assert reset to the device +* @enable_gpio: GPIO used to enable the device +* @stop_gpio: GPIO used to stop the device +* @irq_gpio: GPIO used for interrupt (if @irq is not used) +* @irq: IRQ used for interrupt (if @irq_gpio is not used) +* @hid: _HID value for device (required) +* @cid: _CID value for device +* @uid: _UID value for device +* @desc: _DDN value for device +* @wake: Wake event, e.g. GPE0_DW1_15; 0 if none +* @property_count: Number of other DSD properties (currently always 0) +* @probed: true set set 'linux,probed' property +* @compat_string: Device tree compatible string to report through ACPI +* @has_power_resource: true if this device has a power resource +* @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_desc_reg_offset: HID register offset (for Human Interface Devices) +*/ +struct acpi_i2c_priv { +bool disable_gpio_export_in_crs; +struct gpio_desc reset_gpio; +struct gpio_desc enable_gpio; +struct gpio_desc irq_gpio; +struct gpio_desc stop_gpio; +struct irq irq; +const char *hid; +const char *cid; +u32 uid; +const char *desc; +u32 wake; +u32 property_count; +bool probed; +const char *compat_string; +bool has_power_resource; +u32 reset_delay_ms; +u32 reset_off_delay_ms; +u32 enable_delay_ms; +u32 enable_off_delay_ms; +u32 stop_delay_ms; +u32 stop_off_delay_ms; +u32 hid_desc_reg_offset; +}; + +/** +* I2C Human-Interface Devices configuration +* +* @hid_desc_reg_offset: HID register offset +*/ +struct dsm_i2c_hid_config { +u8 hid_desc_reg_offset; +}; + +/** +* acpi_device_write_gpio() - Write GpioIo() or GpioInt() descriptor +* +* @gpio: GPIO information to write +* @return 0 if OK, -ve on error +*/ +int acpi_device_write_gpio (struct acpi_ctx *ctx,const struct acpi_gpio *gpio); + +/* +* acpi_device_add_power_res() - Add a basic PowerResource block for a device +* +* This includes GPIOs to control enable, reset and stop operation of the +* device. Each GPIO is optional, but at least one must be provided. +* +* Reset - Put the device into / take the device out of reset. +* Enable - Enable / disable power to device. +* Stop - Stop / start operation of device. +* +* @return 0 if OK, -ve if at least one GPIO is not provided +*/ +int acpi_device_add_power_res (struct acpi_ctx *ctx, +const struct acpi_power_res_params *params); + +/** +* gpio_get_acpi() - Convert a GPIO description into an ACPI GPIO +* +* At present this is fairly limited. It only supports ACPI_GPIO_TYPE_IO and +* has hard-coded settings for type, pull, IO restrict and polarity. These +* could come from pinctrl potentially. +* +* @desc: GPIO description to convert +* @gpio: Place to put ACPI GPIO information +* @return 0 if OK, -ENOENT if @desc is invalid +*/ +int gpio_get_acpi (const struct gpio_desc *desc,struct acpi_gpio *gpio); + +/** +* 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 +* +* @config: Config information to write +*/ +void acpi_device_write_dsm_i2c_hid (struct acpi_ctx *ctx, +struct dsm_i2c_hid_config *config); + +/** +* acpi_dp_ofnode_copy_int() - Copy a property from device tree to DP +* +* This copies an integer property from the device tree to the ACPI DP table. +* +* @dev: Device to copy from +* @dp: DP to copy to +* @prop: Property name to copy +* @return 0 if OK, -ve on error +*/ +int acpi_dp_ofnode_copy_int (ofnode node,struct acpi_dp *dp,const char *prop); + +/** +* acpi_dp_dev_copy_str() - Copy a property from device tree to DP +* +* This copies a string property from the device tree to the ACPI DP table. +* +* @dev: Device to copy from +* @dp: DP to copy to +* @prop: Property name to copy +* @return 0 if OK, -ve on error +*/ +int acpi_dp_ofnode_copy_str (ofnode node,struct acpi_dp *dp,const char *prop); + +/** +* acpi_dp_dev_copy_int() - Copy a property from device tree to DP +* +* This copies an integer property from the device tree to the ACPI DP table. +* +* @dev: Device to copy from +* @dp: DP to copy to +* @prop: Property name to copy +* @return 0 if OK, -ve on error +*/ +int acpi_dp_dev_copy_int (const struct udevice *dev,struct acpi_dp *dp, +const char *prop); + +/** +* acpi_dp_dev_copy_str() - Copy a property from device tree to DP +* +* This copies a string property from the device tree to the ACPI DP table. +* +* @dev: Device to copy from +* @dp: DP to copy to +* @prop: Property name to copy +* @return 0 if OK, -ve on error +*/ +int acpi_dp_dev_copy_str (const struct udevice *dev,struct acpi_dp *dp, +const char *prop); + +int acpi_device_get_name (const struct udevice *dev,char *out_name); + +#endif
lib/acpi/acpi_device.c new file +1093 -0
1,093 lines not on this page · raw message
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 30/108 acpi: Add functions to generate ACPI code
In reply to Simon GlassSometimes we need to generate ACPI code on the fly based on things only known at run time. Add a new 'acpigen' library to handle this. This code comes from coreboot and has been modified to support the acpi_ctx struct.
Also add acpi_device.c to the build, since these files are co-dependent.
---
include/acpigen.h | 482 +++++++++++++ include/dm/acpi.h | 7 + include/irq.h | 2 + include/log.h | 2 + lib/acpi/Makefile | 2 + lib/acpi/acpigen.c | 1683 ++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 2178 insertions(+) create mode 100644 include/acpigen.h create mode 100644 lib/acpi/acpigen.c
include/acpigen.h new file +482 -0
@@ -0,0 +1,482 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Core ACPI (Advanced Configuration and Power Interface) support +* +* Copyright 2019 Google LLC +* +* Modified from coreboot file acpigen.h +*/ + +#ifndef _ACPIGEN_H +#define _ACPIGEN_H + +#include <acpi_table.h> + +struct acpi_cstate ; +struct acpi_pld ; +struct acpi_gpio ; +struct acpi_tstate ; + +/* Values that can be returned for ACPI Device _STA method */ +#define ACPI_STATUS_DEVICE_PRESENT BIT(0) +#define ACPI_STATUS_DEVICE_ENABLED BIT(1) +#define ACPI_STATUS_DEVICE_SHOW_IN_UI BIT(2) +#define ACPI_STATUS_DEVICE_STATE_OK BIT(3) + +#define ACPI_STATUS_DEVICE_ALL_OFF 0 +#define ACPI_STATUS_DEVICE_ALL_ON (ACPI_STATUS_DEVICE_PRESENT |\ + ACPI_STATUS_DEVICE_ENABLED |\ + ACPI_STATUS_DEVICE_SHOW_IN_UI |\ + ACPI_STATUS_DEVICE_STATE_OK) +#define ACPI_STATUS_DEVICE_HIDDEN_ON (ACPI_STATUS_DEVICE_PRESENT |\ + ACPI_STATUS_DEVICE_ENABLED |\ + ACPI_STATUS_DEVICE_STATE_OK) + +/* ACPI Op/Prefix Codes */ +enum { +ZERO_OP =0x00 , +ONE_OP =0x01 , +ALIAS_OP =0x06 , +NAME_OP =0x08 , +BYTE_PREFIX =0x0A , +WORD_PREFIX =0x0B , +DWORD_PREFIX =0x0C , +STRING_PREFIX =0x0D , +QWORD_PREFIX =0x0E , +SCOPE_OP =0x10 , +BUFFER_OP =0x11 , +PACKAGE_OP =0x12 , +VARIABLE_PACKAGE_OP =0x13 , +METHOD_OP =0x14 , +EXTERNAL_OP =0x15 , +DUAL_NAME_PREFIX =0x2E , +MULTI_NAME_PREFIX =0x2F , +EXT_OP_PREFIX =0x5B , + +MUTEX_OP =0x01 , +EVENT_OP =0x01 , +SF_RIGHT_OP =0x10 , +SF_LEFT_OP =0x11 , +COND_REFOF_OP =0x12 , +CREATEFIELD_OP =0x13 , +LOAD_TABLE_OP =0x1f , +LOAD_OP =0x20 , +STALL_OP =0x21 , +SLEEP_OP =0x22 , +ACQUIRE_OP =0x23 , +SIGNAL_OP =0x24 , +WAIT_OP =0x25 , +RST_OP =0x26 , +RELEASE_OP =0x27 , +FROM_BCD_OP =0x28 , +TO_BCD_OP =0x29 , +UNLOAD_OP =0x2A , +REVISON_OP =0x30 , +DEBUG_OP =0x31 , +FATAL_OP =0x32 , +TIMER_OP =0x33 , +OPREGION_OP =0x80 , +FIELD_OP =0x81 , +DEVICE_OP =0x82 , +PROCESSOR_OP =0x83 , +POWER_RES_OP =0x84 , +THERMAL_ZONE_OP =0x85 , +INDEX_FIELD_OP =0x86 , +BANK_FIELD_OP =0x87 , +DATA_REGION_OP =0x88 , + +ROOT_PREFIX =0x5C , +PARENT_PREFIX =0x5D , +LOCAL0_OP =0x60 , +LOCAL1_OP =0x61 , +LOCAL2_OP =0x62 , +LOCAL3_OP =0x63 , +LOCAL4_OP =0x64 , +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 , +REF_OF_OP =0x71 , +ADD_OP =0x72 , +CONCATENATE_OP =0x73 , +SUBTRACT_OP =0x74 , +INCREMENT_OP =0x75 , +DECREMENT_OP =0x76 , +MULTIPLY_OP =0x77 , +DIVIDE_OP =0x78 , +SHIFT_LEFT_OP =0x79 , +SHIFT_RIGHT_OP =0x7A , +AND_OP =0x7B , +NAND_OP =0x7C , +OR_OP =0x7D , +NOR_OP =0x7E , +XOR_OP =0x7F , +NOT_OP =0x80 , +FD_SHIFT_LEFT_BIT_OR =0x81 , +FD_SHIFT_RIGHT_BIT_OR =0x82 , +DEREF_OP =0x83 , +CONCATENATE_TEMP_OP =0x84 , +MOD_OP =0x85 , +NOTIFY_OP =0x86 , +SIZEOF_OP =0x87 , +INDEX_OP =0x88 , +MATCH_OP =0x89 , +CREATE_DWORD_OP =0x8A , +CREATE_WORD_OP =0x8B , +CREATE_BYTE_OP =0x8C , +CREATE_BIT_OP =0x8D , +OBJ_TYPE_OP =0x8E , +CREATE_QWORD_OP =0x8F , +LAND_OP =0x90 , +LOR_OP =0x91 , +LNOT_OP =0x92 , +LEQUAL_OP =0x93 , +LGREATER_OP =0x94 , +LLESS_OP =0x95 , +TO_BUFFER_OP =0x96 , +TO_DEC_STRING_OP =0x97 , +TO_HEX_STRING_OP =0x98 , +TO_INTEGER_OP =0x99 , +TO_STRING_OP =0x9C , +CP_OBJ_OP =0x9D , +MID_OP =0x9E , +CONTINUE_OP =0x9F , +IF_OP =0xA0 , +ELSE_OP =0xA1 , +WHILE_OP =0xA2 , +NOOP_OP =0xA3 , +RETURN_OP =0xA4 , +BREAK_OP =0xA5 , +COMMENT_OP =0xA9 , +BREAKPIONT_OP =0xCC , +ONES_OP =0xFF , +}; + +#define FIELDLIST_OFFSET (_bits) { .type = OFFSET, \ + .name = "", \ + .bits = _bits * 8, \ + } +#define FIELDLIST_NAMESTR (_name, _bits) { .type = NAME_STRING, \ + .name = _name, \ + .bits = _bits, \ + } + +#define FIELD_ANYACC 0 +#define FIELD_BYTEACC 1 +#define FIELD_WORDACC 2 +#define FIELD_DWORDACC 3 +#define FIELD_QWORDACC 4 +#define FIELD_BUFFERACC 5 +#define FIELD_NOLOCK (0 << 4) +#define FIELD_LOCK (1 << 4) +#define FIELD_PRESERVE (0 << 5) +#define FIELD_WRITEASONES (1 << 5) +#define FIELD_WRITEASZEROS (2 << 5) + +enum field_type { +OFFSET , +NAME_STRING , +FIELD_TYPE_MAX , +}; + +struct fieldlist { +enum field_type type; +const char *name; +u32 bits; +}; + +#define OPREGION (rname, space, offset, len) {.name = rname, \ + .regionspace = space, \ + .regionoffset = offset, \ + .regionlen = len, \ + } + +enum region_space { +SYSTEMMEMORY , +SYSTEMIO , +PCI_CONFIG , +EMBEDDEDCONTROL , +SMBUS , +CMOS , +PCIBARTARGET , +IPMI , +GPIO_REGION , +GPSERIALBUS , +PCC , +FIXED_HARDWARE =0x7F , +REGION_SPACE_MAX , +}; + +struct opregion { +const char *name; +enum region_space regionspace; +unsigned long regionoffset; +unsigned long regionlen; +}; + +#define DSM_UUID (DSM_UUID ,DSM_CALLBACKS ,DSM_COUNT ,DSM_ARG ) \ + { .uuid = DSM_UUID, \ + .callbacks = DSM_CALLBACKS, \ + .count = DSM_COUNT, \ + .arg = DSM_ARG, \ + } + +typedef void (*hid_callback_func )(struct acpi_ctx *ctx,void *arg); + +struct dsm_uuid { +const char *uuid; +hid_callback_func *callbacks; +size_t count; +void *arg; +}; + +/* version 1 has 15 fields, version 2 has 19, and version 3 has 21 */ +enum cppc_fields { +CPPC_HIGHEST_PERF ,/* can be DWORD */ +CPPC_NOMINAL_PERF ,/* can be DWORD */ +CPPC_LOWEST_NONL_PERF ,/* can be DWORD */ +CPPC_LOWEST_PERF ,/* can be DWORD */ +CPPC_GUARANTEED_PERF , +CPPC_DESIRED_PERF , +CPPC_MIN_PERF , +CPPC_MAX_PERF , +CPPC_PERF_REDUCE_TOLERANCE , +CPPC_TIME_WINDOW , +CPPC_COUNTER_WRAP ,/* can be DWORD */ +CPPC_REF_PERF_COUNTER , +CPPC_DELIVERED_PERF_COUNTER , +CPPC_PERF_LIMITED , +CPPC_ENABLE ,/* can be System I/O */ +CPPC_MAX_FIELDS_VER_1 , +CPPC_AUTO_SELECT =/* can be DWORD */ +CPPC_MAX_FIELDS_VER_1 , +CPPC_AUTO_ACTIVITY_WINDOW , +CPPC_PERF_PREF , +CPPC_REF_PERF ,/* can be DWORD */ +CPPC_MAX_FIELDS_VER_2 , +CPPC_LOWEST_FREQ =/* can be DWORD */ +CPPC_MAX_FIELDS_VER_2 , +CPPC_NOMINAL_FREQ ,/* can be DWORD */ +CPPC_MAX_FIELDS_VER_3 , +}; + +struct cppc_config { +u32 version;/* must be 1, 2, or 3 */ +/* +* The generic struct acpi_gen_regaddr structure is being used, though +* anything besides PPC or FFIXED generally requires checking +* if the OS has advertised support for it (via _OSC). +* +* NOTE: some fields permit DWORDs to be used. If you +* provide a System Memory register with all zeros (which +* represents unsupported) then this will be used as-is. +* Otherwise, a System Memory register with a 32-bit +* width will be converted into a DWORD field (the value +* of which will be the value of 'addrl'. Any other use +* of System Memory register is currently undefined. +* (i.e., if you have an actual need for System Memory +* then you'll need to adjust this kludge). +*/ +struct acpi_gen_regaddr regs[CPPC_MAX_FIELDS_VER_3 ]; +}; + +void acpigen_write_return_integer (struct acpi_ctx *ctx,u64 arg); +void acpigen_write_return_string (struct acpi_ctx *ctx,const char *arg); +void acpigen_write_len_f (struct acpi_ctx *ctx); +void acpigen_pop_len (struct acpi_ctx *ctx); +void acpigen_set_current (struct acpi_ctx *ctx,char *curr); +char *acpigen_get_current (struct acpi_ctx *ctx); +char *acpigen_write_package (struct acpi_ctx *ctx,int nr_el); +void acpigen_write_zero (struct acpi_ctx *ctx); +void acpigen_write_one (struct acpi_ctx *ctx); +void acpigen_write_ones (struct acpi_ctx *ctx); +void acpigen_write_byte (struct acpi_ctx *ctx,unsigned int data); +void acpigen_emit_byte (struct acpi_ctx *ctx,unsigned char data); +void acpigen_emit_ext_op (struct acpi_ctx *ctx,u8 op); +void acpigen_emit_word (struct acpi_ctx *ctx,unsigned int data); +void acpigen_emit_dword (struct acpi_ctx *ctx,unsigned int data); +void acpigen_emit_stream (struct acpi_ctx *ctx,const char *data,int size); +void acpigen_emit_string (struct acpi_ctx *ctx,const char *string); +void acpigen_emit_namestring (struct acpi_ctx *ctx,const char *namepath); +void acpigen_emit_eisaid (struct acpi_ctx *ctx,const char *eisaid); +void acpigen_write_word (struct acpi_ctx *ctx,unsigned int data); +void acpigen_write_dword (struct acpi_ctx *ctx,unsigned int data); +void acpigen_write_qword (struct acpi_ctx *ctx,u64 data); +void acpigen_write_integer (struct acpi_ctx *ctx,u64 data); +void acpigen_write_string (struct acpi_ctx *ctx,const char *string); +void acpigen_write_coreboot_hid (struct acpi_ctx *ctx, +enum coreboot_acpi_ids id); +void acpigen_write_name (struct acpi_ctx *ctx,const char *name); +void acpigen_write_name_zero (struct acpi_ctx *ctx,const char *name); +void acpigen_write_name_one (struct acpi_ctx *ctx,const char *name); +void acpigen_write_name_string (struct acpi_ctx *ctx,const char *name, +const char *string); +void acpigen_write_name_dword (struct acpi_ctx *ctx,const char *name,u32 val); +void acpigen_write_name_qword (struct acpi_ctx *ctx,const char *name,u64 val); +void acpigen_write_name_byte (struct acpi_ctx *ctx,const char *name,u8 val); +void acpigen_write_name_integer (struct acpi_ctx *ctx,const char *name, +u64 val); +void acpigen_write_scope (struct acpi_ctx *ctx,const char *name); +void acpigen_write_method (struct acpi_ctx *ctx,const char *name,int nargs); +void acpigen_write_method_serialized (struct acpi_ctx *ctx,const char *name, +int nargs); +void acpigen_write_device (struct acpi_ctx *ctx,const char *name); +void acpigen_write_ppc (struct acpi_ctx *ctx,u8 nr); +void acpigen_write_ppc_nvs (struct acpi_ctx *ctx); +void acpigen_write_empty_pct (struct acpi_ctx *ctx); +void acpigen_write_empty_ptc (struct acpi_ctx *ctx); +void acpigen_write_prw (struct acpi_ctx *ctx,u32 wake,u32 level); +void acpigen_write_sta (struct acpi_ctx *ctx,u8 status); +void acpigen_write_tpc (struct acpi_ctx *ctx,const char *gnvs_tpc_limit); +void acpigen_write_pss_package (struct acpi_ctx *ctx,u32 corefreq,u32 power, +u32 translat, +u32 busmlat,u32 control,u32 status); +enum psd_coord { +SW_ALL =0xfc , +SW_ANY =0xfd , +HW_ALL =0xfe +}; + +void acpigen_write_psd_package (struct acpi_ctx *ctx,u32 domain,u32 numprocs, +enum psd_coord coordtype); +void acpigen_write_cst_package_entry (struct acpi_ctx *ctx, +struct acpi_cstate *cstate); +void acpigen_write_cst_package (struct acpi_ctx *ctx,struct acpi_cstate *entry, +int nentries); + +enum csd_coord { +CSD_HW_ALL =0xfe , +}; + +void acpigen_write_CSD_package (struct acpi_ctx *ctx,u32 domain,u32 numprocs, +enum csd_coord coordtype,u32 index); +void acpigen_write_processor (struct acpi_ctx *ctx,u8 cpuindex,u32 pblock_addr, +u8 pblock_len); +void acpigen_write_processor_package (struct acpi_ctx *ctx,const char *name, +uint first_core,uint core_count); +void acpigen_write_processor_cnot (struct acpi_ctx *ctx,const uint num_cores); +void acpigen_write_tss_package (struct acpi_ctx *ctx,int entries, +struct acpi_tstate *tstate_list); +void acpigen_write_tsd_package (struct acpi_ctx *ctx,u32 domain,u32 numprocs, +enum psd_coord coordtype); +void acpigen_write_mem32fixed (struct acpi_ctx *ctx,int readwrite,u32 base, +u32 size); +void acpigen_write_register_resource (struct acpi_ctx *ctx, +const struct acpi_gen_regaddr *addr); +void acpigen_write_irq (struct acpi_ctx *ctx,u16 mask); +void acpigen_write_resourcetemplate_header (struct acpi_ctx *ctx); +void acpigen_write_resourcetemplate_footer (struct acpi_ctx *ctx); +int acpigen_write_uuid (struct acpi_ctx *ctx,const char *uuid); +void acpigen_write_power_res (struct acpi_ctx *ctx,const char *name,u8 level, +u16 order,const char *const dev_states[], +size_t dev_states_count); +void acpigen_write_sleep (struct acpi_ctx *ctx,u64 sleep_ms); +void acpigen_write_store (struct acpi_ctx *ctx); +void acpigen_write_store_ops (struct acpi_ctx *ctx,u8 src,u8 dst); +void acpigen_write_or (struct acpi_ctx *ctx,u8 arg1,u8 arg2,u8 res); +void acpigen_write_and (struct acpi_ctx *ctx,u8 arg1,u8 arg2,u8 res); +void acpigen_write_not (struct acpi_ctx *ctx,u8 arg,u8 res); +void acpigen_write_debug_string (struct acpi_ctx *ctx,const char *str); +void acpigen_write_debug_integer (struct acpi_ctx *ctx,u64 val); +void acpigen_write_debug_op (struct acpi_ctx *ctx,u8 op); +void acpigen_write_if (struct acpi_ctx *ctx); +void acpigen_write_if_and (struct acpi_ctx *ctx,u8 arg1,u8 arg2); +void acpigen_write_if_lequal_op_int (struct acpi_ctx *ctx,u8 op,u64 val); +void acpigen_write_else (struct acpi_ctx *ctx); +void acpigen_write_to_buffer (struct acpi_ctx *ctx,u8 src,u8 dst); +void acpigen_write_to_integer (struct acpi_ctx *ctx,u8 src,u8 dst); +void acpigen_write_byte_buffer (struct acpi_ctx *ctx,u8 *arr,size_t size); +void acpigen_write_return_byte_buffer (struct acpi_ctx *ctx,u8 *arr, +size_t size); +void acpigen_write_return_singleton_buffer (struct acpi_ctx *ctx,u8 arg); +void acpigen_write_return_byte (struct acpi_ctx *ctx,u8 arg); +void acpigen_write_upc (struct acpi_ctx *ctx,enum acpi_upc_type type); + +/* +* Generate ACPI AML code for _DSM method. +* This function takes as input uuid for the device, set of callbacks and +* argument to pass into the callbacks. Callbacks should ensure that Local0 and +* Local1 are left untouched. Use of Local2-Local7 is permitted in callbacks. +*/ +int acpigen_write_dsm (struct acpi_ctx *ctx,const char *uuid, +hid_callback_func callbacks[],size_t count,void *arg); +int acpigen_write_dsm_uuid_arr (struct acpi_ctx *ctx,struct dsm_uuid *ids, +size_t count); + +/* +* Generate ACPI AML code for _CPC (struct acpi_ctx *ctx, Continuous Perfmance +* Control). Execute the package function once to create a global table, then +* execute the method function within each processor object to +* create a method that points to the global table. +*/ +int acpigen_write_cppc_package (struct acpi_ctx *ctx, +const struct cppc_config *config); +void acpigen_write_cppc_method (struct acpi_ctx *ctx); + +/* +* Generate ACPI AML code for _ROM method. +* This function takes as input ROM data and ROM length. +* The ROM length has to be multiple of 4096 and has to be less +* than the current implementation limit of 0x40000. +*/ +int acpigen_write_rom (struct acpi_ctx *ctx,void *bios,const size_t length); +/* +* Generate ACPI AML code for OperationRegion +* This function takes input region name, region space, region offset & region +* length. +*/ +void acpigen_write_opregion (struct acpi_ctx *ctx,struct opregion *opreg); +/* +* Generate ACPI AML code for Field +* This function takes input region name, fieldlist, count & flags. +*/ +int acpigen_write_field (struct acpi_ctx *ctx,const char *name, +struct fieldlist *l,size_t count,uint flags); +/* +* Generate ACPI AML code for IndexField +* This function takes input index name, data name, fieldlist, count & flags. +*/ +int acpigen_write_indexfield (struct acpi_ctx *ctx,const char *idx, +const char *data,struct fieldlist *l, +size_t count,uint flags); + +/* +* Soc-implemented functions for generating ACPI AML code for GPIO handling. All +* these functions are expected to use only Local5, Local6 and Local7 +* variables. If the functions call into another ACPI method, then there is no +* restriction on the use of Local variables. In case of get/read functions, +* return value is expected to be stored in Local0 variable. +* +* All functions return 0 on success and -1 on error. +*/ + +/* Generate ACPI AML code to return Rx value of GPIO in Local0. */ +int acpigen_soc_read_rx_gpio (struct acpi_ctx *ctx,uint gpio_num); + +/* Generate ACPI AML code to return Tx value of GPIO in Local0. */ +int acpigen_soc_get_tx_gpio (struct acpi_ctx *ctx,uint gpio_num); + +/* Generate ACPI AML code to set Tx value of GPIO to 1. */ +int acpigen_soc_set_tx_gpio (struct acpi_ctx *ctx,uint gpio_num); + +/* Generate ACPI AML code to set Tx value of GPIO to 0. */ +int acpigen_soc_clear_tx_gpio (struct acpi_ctx *ctx,uint gpio_num); + +/* +* Helper functions for enabling/disabling Tx GPIOs based on the GPIO +* polarity. These functions end up calling acpigen_soc_{set,clear}_tx_gpio to +* make callbacks into SoC acpigen code. +* +* Returns 0 on success and -1 on error. +*/ +int acpigen_enable_tx_gpio (struct acpi_ctx *ctx,struct acpi_gpio *gpio); +int acpigen_disable_tx_gpio (struct acpi_ctx *ctx,struct acpi_gpio *gpio); + +#endif
include/dm/acpi.h +7 -0
@@ -22,6 +22,9 @@/* Length of an ACPI name string including nul terminator */ #define ACPI_NAME_MAX 5 +/* Number of nested objects supported */ +#define ACPIGEN_LENSTACK_SIZE 10 +#if !defined(__ACPI__)/**
@@ -34,12 +37,16 @@* adding a new table. The RSDP holds pointers to the RSDP and XSDT. * @rsdt: Pointer to the Root System Description Table * @xsdt: Pointer to the Extended System Description Table +* @len_stack: Stack of 'length' words to fix up later +* @ltop: Points to current top of stack (0 = empty) */ struct acpi_ctx {void *current;struct acpi_rsdp *rsdp;struct acpi_rsdt *rsdt;struct acpi_xsdt *xsdt; +char *len_stack[ACPIGEN_LENSTACK_SIZE ]; +int ltop; };/**
include/irq.h +2 -0
@@ -8,6 +8,8 @@#ifndef __irq_H#define __irq_H +struct ofnode_phandle_args ; +/* * Interupt controller types available. You can find a particular one with * irq_first_device_type()
include/log.h +2 -0
@@ -50,6 +50,8 @@ enum log_category_t {LOGC_SANDBOX ,/* Related to the sandbox board */ LOGC_BLOBLIST ,/* Bloblist */ LOGC_DEVRES ,/* Device resources (devres_... functions) */ +/* Intel Advanced Configuration and Power Interface (ACPI) */ +LOGC_ACPI ,LOGC_COUNT ,/* Number of log categories */ LOGC_END, /* Sentinel value for a list of log categories */
lib/acpi/Makefile +2 -0
@@ -1,4 +1,6 @@ # SPDX-License-Identifier: GPL-2.0+ # +obj-y += acpigen.o +obj-y += acpi_device.o obj-y += acpi_table.o
lib/acpi/acpigen.c new file +1683 -0
1,683 lines not on this page · raw message
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 31/108 gpio: Add a method to convert a GPIO to ACPI
In reply to Simon GlassWhen generating ACPI tables we need to convert GPIOs in U-Boot to the ACPI structures required by ACPI. This is a SoC-specific conversion and cannot be handled by generic code, so add a new GPIO method to do the conversion.
---
drivers/gpio/gpio-uclass.c | 21 +++++++++++++++++++++ include/acpi_device.h | 12 ++++++++++++ include/asm-generic/gpio.h | 27 +++++++++++++++++++++++++++ lib/acpi/acpi_device.c | 16 ++++++++++++++++ 4 files changed, 76 insertions(+)
drivers/gpio/gpio-uclass.c +21 -0
@@ -4,6 +4,7 @@*/ #include <common.h> +#include <acpi_device.h> #include <dm.h> #include <dm/device-internal.h> #include <dm/lists.h>
@@ -697,6 +698,26 @@ int gpio_get_status(struct udevice *dev, int offset, char *buf, int buffsize)return 0 ; } +#if CONFIG_IS_ENABLED (ACPIGEN ) +int gpio_get_acpi (const struct gpio_desc *desc,struct acpi_gpio *gpio) +{ +struct dm_gpio_ops *ops; + +if (!dm_gpio_is_valid (desc)) { +/* Indicate that the GPIO is not valid */ + gpio->pin_count =0 ; + gpio->pins[0 ] =0 ; +return -EINVAL ; + } + + ops =gpio_get_ops (desc->dev); +if (!ops->get_acpi) +return -ENOSYS ; + +return ops->get_acpi (desc, gpio); +} +#endif +int gpio_claim_vector (const int *gpio_num_array,const char *fmt) {int i, ret;
include/acpi_device.h +12 -0
@@ -533,6 +533,18 @@ size_t acpi_dp_add_property_list(struct acpi_dp *dp,*/ int acpi_dp_write (struct acpi_ctx *ctx,struct acpi_dp *table); +/** +* acpi_device_write_gpio_desc() - Write a GPIO to ACPI +* +* This creates a GPIO descriptor for a GPIO, including information ACPI needs +* to use it. The type is always ACPI_GPIO_TYPE_IO. +* +* @desc: GPIO to write +* @return 0 if OK, -ve on error +*/ +int acpi_device_write_gpio_desc (struct acpi_ctx *ctx, +const struct gpio_desc *desc); +/** * acpi_device_write_i2c_dev() - Write an I2C device to ACPI, including * information ACPI needs to use it.
include/asm-generic/gpio.h +27 -0
@@ -9,6 +9,7 @@#include <dm/ofnode.h> +struct acpi_gpio ;struct ofnode_phandle_args ;/*
@@ -290,6 +291,20 @@ struct dm_gpio_ops {*/ int (*xlate)(struct udevice *dev,struct gpio_desc *desc,struct ofnode_phandle_args *args); + +#if CONFIG_IS_ENABLED (ACPIGEN ) +/** +* get_acpi() - Get the ACPI info for a GPIO +* +* This converts a GPIO to an ACPI structure for adding to the ACPI +* tables. +* +* @desc: GPIO description to convert +* @gpio: Output ACPI GPIO information +* @return ACPI pin number or -ve on error +*/ +int (*get_acpi)(const struct gpio_desc *desc,struct acpi_gpio *gpio); +#endif };/**
@@ -657,4 +672,16 @@ int dm_gpio_set_dir_flags(struct gpio_desc *desc, ulong flags);*/ int gpio_get_number (const struct gpio_desc *desc); +/** +* gpio_get_acpi() - Get the ACPI pin for a GPIO +* +* This converts a GPIO to an ACPI pin number for adding to the ACPI +* tables. If the GPIO is invalid, the pin_count and pins[0] are set to 0 +* +* @desc: GPIO description to convert +* @gpio: Output ACPI GPIO information +* @return ACPI pin number or -ve on error +*/ +int gpio_get_acpi (const struct gpio_desc *desc,struct acpi_gpio *gpio); +#endif /* _ASM_GENERIC_GPIO_H_ */
lib/acpi/acpi_device.c +16 -0
@@ -287,6 +287,22 @@ int acpi_device_write_gpio(struct acpi_ctx *ctx, const struct acpi_gpio *gpio)return 0 ; } +int acpi_device_write_gpio_desc (struct acpi_ctx *ctx, +const struct gpio_desc *desc) +{ +struct acpi_gpio gpio; +int ret; + + ret =gpio_get_acpi (desc, &gpio); +if (ret) +return log_msg_ret ("desc" , ret); + ret =acpi_device_write_gpio (ctx, &gpio); +if (ret) +return log_msg_ret ("gpio" , ret); + +return 0 ; +} +/* ACPI 6.1 section 6.4.3.8.2.1 - I2cSerialBus() */ static void acpi_device_write_i2c (struct acpi_ctx *ctx,const struct acpi_i2c *i2c)
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 32/108 irq: Add a method to convert an interrupt to ACPI
In reply to Simon GlassWhen generating ACPI tables we need to convert IRQs in U-Boot to the ACPI structures required by ACPI. This is a SoC-specific conversion and cannot be handled by generic code, so add a new IRQ method to do the conversion.
---
drivers/misc/irq-uclass.c | 18 +++++++- include/acpi_device.h | 27 +++++++++++ include/irq.h | 41 +++++++++++++++++ lib/acpi/acpi_device.c | 94 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 178 insertions(+), 2 deletions(-)
drivers/misc/irq-uclass.c +16 -2
@@ -153,8 +153,6 @@ int irq_request(struct udevice *dev, struct irq *irq)const struct irq_ops *ops;log_debug ("(dev=%p, irq=%p)\n" , dev, irq); -if (!irq) -return 0 ; ops =irq_get_ops (dev); irq->dev = dev;
@@ -185,6 +183,22 @@ int irq_first_device_type(enum irq_dev_t type, struct udevice **devp)return -ENODEV ; } +#if CONFIG_IS_ENABLED (ACPIGEN ) +int irq_get_acpi (const struct irq *irq,struct acpi_irq *acpi_irq) +{ +struct irq_ops *ops; + +if (!irq_is_valid (irq)) +return -EINVAL ; + + ops =irq_get_ops (irq->dev); +if (!ops->get_acpi) +return -ENOSYS ; + +return ops->get_acpi (irq, acpi_irq); +} +#endif +UCLASS_DRIVER (irq) = { .id =UCLASS_IRQ , .name ="irq" ,
include/acpi_device.h +27 -0
@@ -545,6 +545,33 @@ int acpi_dp_write(struct acpi_ctx *ctx, struct acpi_dp *table);int acpi_device_write_gpio_desc (struct acpi_ctx *ctx,const struct gpio_desc *desc); +/** +* acpi_device_write_interrupt_irq() - Write an interrupt to ACPI +* +* This creates an interrupt descriptor for an interrupt, including information +* ACPI needs to use it. +* +* @req_irq: Interrupt to write +* @return 0 if OK, -ve on error +*/ +int acpi_device_write_interrupt_irq (struct acpi_ctx *ctx, +const struct irq *req_irq); + +/** +* acpi_device_write_interrupt_or_gpio() - Write interrupt or GPIO to ACPI +* +* This reads the an interrupt from the device tree, if available. If not it +* reads the first GPIO with the name @prop. +* +* If an interrupt is found, that is written to ACPI. If not, but an GPIO is +* found, that is written. +* +* @return 0 if OK, -ve if neither an interrupt nor a GPIO could be found, or +* some other error occurred +*/ +int acpi_device_write_interrupt_or_gpio (struct acpi_ctx *ctx, +struct udevice *dev,const char *prop); +/** * acpi_device_write_i2c_dev() - Write an I2C device to ACPI, including * information ACPI needs to use it.
include/irq.h +41 -0
71 lines not on this page · raw message
lib/acpi/acpi_device.c +94 -0
106 lines not on this page · raw message
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 33/108 acpi: Add support for SSDT generation
In reply to Simon GlassSome devices need to generate code for the Secondary System Descriptor Table (SSDT). Add a method to handle this.
---
arch/sandbox/dts/test.dts | 2 ++ drivers/core/acpi.c | 38 ++++++++++++++++++++++++++++++++++++ include/dm/acpi.h | 23 ++++++++++++++++++++++ test/dm/acpi.c | 41 ++++++++++++++++++++++++++++++++++++++- 4 files changed, 103 insertions(+), 1 deletion(-)
arch/sandbox/dts/test.dts +2 -0
@@ -208,10 +208,12 @@ acpi-test { compatible = "denx,u-boot-acpi-test"; + acpi-ssdt-test-data = "ab"; }; acpi-test2 { compatible = "denx,u-boot-acpi-test"; + acpi-ssdt-test-data = "cd"; }; clocks {
drivers/core/acpi.c +38 -0
@@ -11,6 +11,7 @@#include <common.h> #include <dm.h> #include <dm/acpi.h> +#include <dm/device-internal.h> #include <dm/root.h> int acpi_return_name (char *out_name,const char *name)
@@ -31,6 +32,43 @@ int acpi_get_name(const struct udevice *dev, char *out_name)return -ENOSYS ; } +int _acpi_fill_ssdt (struct acpi_ctx *ctx,struct udevice *parent) +{ +struct acpi_ops *aops; +struct udevice *dev; +int ret; + + aops =device_get_acpi_ops (parent); +if (aops && aops->fill_ssdt) { +log_debug ("\n- %s %p\n" , parent->name, + aops->fill_ssdt); + ret =device_ofdata_to_platdata (parent); +if (ret) +return log_msg_ret ("ofdata" , ret); + ret = aops->fill_ssdt (parent, ctx); +if (ret) +return log_msg_ret ("ssdt" , ret); + } + device_foreach_child(dev, parent) { + ret =_acpi_fill_ssdt (ctx, dev); +if (ret) +return log_msg_ret ("recurse" , ret); + } + +return 0 ; +} + +int acpi_fill_ssdt (struct acpi_ctx *ctx) +{ +int ret; + +log_debug ("Writing SSDT tables\n" ); + ret =_acpi_fill_ssdt (ctx,dm_root ()); +log_debug ("Writing SSDT finished, err=%d\n" , ret); + +return ret; +} +int _acpi_write_dev_tables (struct acpi_ctx *ctx,const struct udevice *parent) {struct acpi_ops *aops;
include/dm/acpi.h +23 -0
@@ -72,6 +72,19 @@ struct acpi_ops {* @return 0 if OK, -ve on error */ int (*write_tables)(const struct udevice *dev,struct acpi_ctx *ctx); + +/** +* fill_ssdt() - Generate SSDT code for a device +* +* This is called to create the SSDT code. THe method should write out +* whatever ACPI code is needed by this device. It will end up in the +* SSDT table. +* +* @dev: Device to write +* @ctx: ACPI context to use +* @return 0 if OK, -ve on error +*/ +int (*fill_ssdt)(const struct udevice *dev,struct acpi_ctx *ctx); };#define device_get_acpi_ops (dev) ((dev)->driver->acpi_ops)
@@ -116,6 +129,16 @@ int acpi_return_name(char *out_name, const char *name);*/ int acpi_write_dev_tables (struct acpi_ctx *ctx); +/** +* acpi_fill_ssdt() - Generate ACPI tables for SSDT +* +* This is called to create the SSDT code for all devices. +* +* @ctx: ACPI context to use +* @return 0 if OK, -ve on error +*/ +int acpi_fill_ssdt (struct acpi_ctx *ctx); +#endif /* __ACPI__ */ #endif
test/dm/acpi.c +40 -1
65 lines not on this page · raw message
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 34/108 x86: acpi: Move MADT up a bit
In reply to Simon GlassPut this table before MCFG so that it matches the order that coreboot uses when passing tables to Linux. This is a cosmetic change since the order of the tables does not otherwise matter.
---
arch/x86/lib/acpi_table.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
arch/x86/lib/acpi_table.c +6 -6
@@ -408,18 +408,18 @@ ulong write_acpi_tables(ulong start_addr)acpi_create_fadt (fadt, facs, dsdt);acpi_add_table (ctx, fadt); -debug ("ACPI: * MADT\n" ); - madt = ctx->current; -acpi_create_madt (madt); -acpi_inc_align (ctx, madt->header.length); -acpi_add_table (ctx, madt); -debug ("ACPI: * MCFG\n" ); mcfg = ctx->current;acpi_create_mcfg (mcfg);acpi_inc_align (ctx, mcfg->header.length);acpi_add_table (ctx, mcfg); +debug ("ACPI: * MADT\n" ); + madt = ctx->current; +acpi_create_madt (madt); +acpi_inc_align (ctx, madt->header.length); +acpi_add_table (ctx, madt); +debug ("ACPI: * CSRT\n" ); csrt = ctx->current;acpi_create_csrt (csrt);
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 34/108 x86: acpi: Move MADT up a bit
Quoted 3 lines · Simon Glass
Put this table before MCFG so that it matches the order that coreboot uses when passing tables to Linux. This is a cosmetic change since the order of the tables does not otherwise matter.
The patch looks like it's doing the opposite of what the commit message says. Rebasing issue, or am I being daft? (If this is a stack operation, use of stack terminology in the commit message would be more daft-friendly.)
/
Leif
Quoted 38 lines
Signed-off-by Simon Glass <[email protected]>---
arch/x86/lib/acpi_table.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)arch/x86/lib/acpi_table.c +6
-6@@ -408,18 +408,18 @@ ulong write_acpi_tables(ulong start_addr)acpi_create_fadt (fadt, facs, dsdt);acpi_add_table (ctx, fadt); -debug ("ACPI: * MADT\n" ); - madt = ctx->current; -acpi_create_madt (madt); -acpi_inc_align (ctx, madt->header.length); -acpi_add_table (ctx, madt); -debug ("ACPI: * MCFG\n" ); mcfg = ctx->current;acpi_create_mcfg (mcfg);acpi_inc_align (ctx, mcfg->header.length);acpi_add_table (ctx, mcfg); +debug ("ACPI: * MADT\n" ); + madt = ctx->current; +acpi_create_madt (madt); +acpi_inc_align (ctx, madt->header.length); +acpi_add_table (ctx, madt); +debug ("ACPI: * CSRT\n" ); csrt = ctx->current;acpi_create_csrt (csrt);Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 34/108 x86: acpi: Move MADT up a bit
Quoted 10 lines · Leif Lindholm
Quoted 3 lines · Simon Glass
Put this table before MCFG so that it matches the order that coreboot uses when passing tables to Linux. This is a cosmetic change since the order of the tables does not otherwise matter.
The patch looks like it's doing the opposite of what the commit message says. Rebasing issue, or am I being daft? (If this is a stack operation, use of stack terminology in the commit message would be more daft-friendly.)
Ooops, thanks, fixed!
- Simon
PATCH 35/108 acpi: Record the items added to SSDT
In reply to Simon GlassIt is useful to be able to control the order of data written to the SSDT so that we can compare the output against known-good kernel dumps.
Add code to record each item that is added along with the device that added it. That allows us to reorder things later if needed.
---
drivers/core/acpi.c | 70 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+)
drivers/core/acpi.c +70 -0
@@ -14,6 +14,32 @@#include <dm/device-internal.h> #include <dm/root.h> +#define MAX_ITEMS 100 + +/* Type of table that we collected */ +enum gen_type_t { +TYPE_SSDT , +}; + +/** +* struct acpi_item - Holds info about ACPI data generated by a driver method +* +* @dev: Device that generated this data +* @type: Table type it refers to +* @buf: Buffer containing the data +* @size: Size of the data in bytes +*/ +struct acpi_item { +struct udevice *dev; +enum gen_type_t type; +char *buf; +int size; +}; + +/* List of ACPI items collected */ +static struct acpi_item acpi_item[MAX_ITEMS ]; +static int item_count; +int acpi_return_name (char *out_name,const char *name) {strcpy (out_name, name);
@@ -32,6 +58,43 @@ int acpi_get_name(const struct udevice *dev, char *out_name)return -ENOSYS ; } +/** +* acpi_add_item() - Add a new item to the list of data collected +* +* @ctx: ACPI context +* @dev: Device that generated the data +* @type: Table type it refers to +* @start: The start of the data (the end is obtained from ctx->current) +* @return 0 if OK, -ENOSPC if too many items, -ENOMEM if out of memory +*/ +static int acpi_add_item (struct acpi_ctx *ctx,struct udevice *dev, +enum gen_type_t type,void *start) +{ +struct acpi_item *item; +void *end = ctx->current; + +if (item_count ==MAX_ITEMS ) { +log_err ("Too many items\n" ); +return log_msg_ret ("mem" , -ENOSPC ); + } + + item = &acpi_item[item_count]; + item->dev = dev; + item->type = type; + item->size = end - start; +if (!item->size) +return 0 ; + item->buf =malloc (item->size); +if (!item->buf) +return log_msg_ret ("mem" , -ENOMEM ); +memcpy (item->buf, start, item->size); + item_count++; +log_debug ("* %s: Added type %d, %p, size %x\n" , dev->name, type, start, + item->size); + +return 0 ; +} +int _acpi_fill_ssdt (struct acpi_ctx *ctx,struct udevice *parent) {struct acpi_ops *aops;
@@ -40,6 +103,8 @@ int _acpi_fill_ssdt(struct acpi_ctx *ctx, struct udevice *parent) aops =device_get_acpi_ops (parent);if (aops && aops->fill_ssdt) { +void *start = ctx->current; +log_debug ("\n- %s %p\n" , parent->name, aops->fill_ssdt); ret =device_ofdata_to_platdata (parent);
@@ -48,6 +113,11 @@ int _acpi_fill_ssdt(struct acpi_ctx *ctx, struct udevice *parent) ret = aops->fill_ssdt (parent, ctx);if (ret)return log_msg_ret ("ssdt" , ret); + +/* Add the item to the internal list */ + ret =acpi_add_item (ctx, parent,TYPE_SSDT , start); +if (ret) +return log_msg_ret ("add" , ret); } device_foreach_child(dev, parent) { ret =_acpi_fill_ssdt (ctx, dev);
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 36/108 acpi: Support ordering SSDT data by device
In reply to Simon GlassAdd a /chosen property to control the order in which the data appears in the SSDT. This allows matching up U-Boot's output from a dump of the known-good data obtained from within Linux.
---
arch/sandbox/dts/test.dts | 5 ++- doc/device-tree-bindings/chosen.txt | 9 +++++ drivers/core/acpi.c | 61 +++++++++++++++++++++++++++++ test/dm/acpi.c | 17 ++++---- 4 files changed, 83 insertions(+), 9 deletions(-)
arch/sandbox/dts/test.dts +3 -2
@@ -206,12 +206,12 @@ compatible = "denx,u-boot-devres-test"; }; - acpi-test { + acpi_test1: acpi-test { compatible = "denx,u-boot-acpi-test"; acpi-ssdt-test-data = "ab"; }; - acpi-test2 { + acpi_test2: acpi-test2 { compatible = "denx,u-boot-acpi-test"; acpi-ssdt-test-data = "cd"; };
@@ -822,6 +822,7 @@ chosen { #address-cells = <1>; #size-cells = <1>; + u-boot,acpi-ssdt-order = <&acpi_test2 &acpi_test1>; chosen-test { compatible = "denx,u-boot-fdt-test"; reg = <9 1>;
doc/device-tree-bindings/chosen.txt +9 -0
@@ -134,3 +134,12 @@ Example phandlepart = <&mmc 1>; }; }; + +u-boot,acpi-ssdt-order +---------------------- + +This provides the ordering to use when writing device data to the ACPI SSDT +(Secondary System Descriptor Table). Each cell is a phandle pointer to a device +node to add. The ACPI information is written in this order. + +If the ordering does not include all nodes, an error is generated.
drivers/core/acpi.c +61 -0
78 lines not on this page · raw message
test/dm/acpi.c +10 -7
@@ -336,16 +336,19 @@ static int dm_test_acpi_fill_ssdt(struct unit_test_state *uts)ut_assertnonnull (buf); ctx.current = buf; - buf[4 ] ='z' ;/* sentinal */ + buf[4 ] ='z' ;/* sentinel */ ut_assertok (acpi_fill_ssdt (&ctx)); -/* These values come from acpi-test's acpi-ssdt-test-data property */ -ut_asserteq ('a' , buf[0 ]); -ut_asserteq ('b' , buf[1 ]); +/* +* These values come from acpi-test2's acpi-ssdt-test-data property. +* This device comes first because of u-boot,acpi-ssdt-order +*/ +ut_asserteq ('c' , buf[0 ]); +ut_asserteq ('d' , buf[1 ]); -/* These values come from acpi-test2's acpi-ssdt-test-data property */ -ut_asserteq ('c' , buf[2 ]); -ut_asserteq ('d' , buf[3 ]); +/* These values come from acpi-test's acpi-ssdt-test-data property */ +ut_asserteq ('a' , buf[2 ]); +ut_asserteq ('b' , buf[3 ]);ut_asserteq ('z' , buf[4 ]);
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 37/108 x86: Allow devices to write an SSDT
In reply to Simon GlassCall the new core function to write the SSDT. This is made up of fragments generated by devices that have the fill_ssdt() method.
---
arch/x86/lib/acpi_table.c | 50 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+)
arch/x86/lib/acpi_table.c +50 -0
@@ -7,6 +7,7 @@*/ #include <common.h> +#include <acpigen.h> #include <cpu.h> #include <dm.h> #include <dm/uclass-internal.h>
@@ -344,6 +345,46 @@ static void acpi_create_spcr(struct acpi_spcr *spcr) header->checksum =table_compute_checksum ((void *)spcr, header->length); } +static void acpi_ssdt_write_cbtable (struct acpi_ctx *ctx) +{ +uintptr_t base; +u32 size; + + base =0 ; + size =0 ; + +acpigen_write_device (ctx,"CTBL" ); +acpigen_write_coreboot_hid (ctx,COREBOOT_ACPI_ID_CBTABLE ); +acpigen_write_name_integer (ctx,"_UID" ,0 ); +acpigen_write_sta (ctx,ACPI_STATUS_DEVICE_HIDDEN_ON ); +acpigen_write_name (ctx,"_CRS" ); +acpigen_write_resourcetemplate_header (ctx); +acpigen_write_mem32fixed (ctx,0 , base, size); +acpigen_write_resourcetemplate_footer (ctx); +acpigen_pop_len (ctx); +} + +void acpi_create_ssdt (struct acpi_ctx *ctx,struct acpi_table_header *ssdt, +const char *oem_table_id) +{ +memset ((void *)ssdt,'\0' ,sizeof (struct acpi_table_header )); + +acpi_fill_header (ssdt,"SSDT" ); + ssdt->revision =acpi_get_table_revision (ACPITAB_SSDT ); + ssdt->aslc_revision =1 ; + ssdt->length =sizeof (struct acpi_table_header ); + +acpi_inc (ctx,sizeof (struct acpi_table_header )); + +/* Write object to declare coreboot tables */ +acpi_ssdt_write_cbtable (ctx); +acpi_fill_ssdt (ctx); + +/* (Re)calculate length and checksum. */ + ssdt->length = ctx->current - (void *)ssdt; + ssdt->checksum =table_compute_checksum ((void *)ssdt, ssdt->length); +} +/* * QEMU's version of write_acpi_tables is defined in drivers/misc/qfw.c */
@@ -353,6 +394,7 @@ ulong write_acpi_tables(ulong start_addr)struct acpi_facs *facs;struct acpi_table_header *dsdt;struct acpi_fadt *fadt; +struct acpi_table_header *ssdt;struct acpi_mcfg *mcfg;struct acpi_madt *madt;struct acpi_csrt *csrt;
@@ -408,6 +450,14 @@ ulong write_acpi_tables(ulong start_addr)acpi_create_fadt (fadt, facs, dsdt);acpi_add_table (ctx, fadt); +debug ("ACPI: * SSDT\n" ); + ssdt = (struct acpi_table_header *)ctx->current; +acpi_create_ssdt (ctx, ssdt,ACPI_TABLE_CREATOR ); +if (ssdt->length >sizeof (struct acpi_table_header )) { +acpi_inc_align (ctx, ssdt->length); +acpi_add_table (ctx, ssdt); + } +debug ("ACPI: * MCFG\n" ); mcfg = ctx->current;acpi_create_mcfg (mcfg);
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 38/108 acpi: Add support for DSDT generation
In reply to Simon GlassSome devices need to inject extra code into the Differentiated System Descriptor Table (DSDT). Add a method to handle this.
---
arch/sandbox/dts/test.dts | 2 ++ drivers/core/acpi.c | 50 ++++++++++++++++++++++++++++++++++++++- include/dm/acpi.h | 23 ++++++++++++++++++ test/dm/acpi.c | 44 +++++++++++++++++++++++++++++++++- 4 files changed, 117 insertions(+), 2 deletions(-)
arch/sandbox/dts/test.dts +2 -0
@@ -209,11 +209,13 @@ acpi_test1: acpi-test { compatible = "denx,u-boot-acpi-test"; acpi-ssdt-test-data = "ab"; + acpi-dsdt-test-data = "hi"; }; acpi_test2: acpi-test2 { compatible = "denx,u-boot-acpi-test"; acpi-ssdt-test-data = "cd"; + acpi-dsdt-test-data = "jk"; }; clocks {
drivers/core/acpi.c +49 -1
68 lines not on this page · raw message
include/dm/acpi.h +23 -0
@@ -85,6 +85,19 @@ struct acpi_ops {* @return 0 if OK, -ve on error */ int (*fill_ssdt)(const struct udevice *dev,struct acpi_ctx *ctx); + +/** +* inject_dsdt() - Generate DSDT code for a device +* +* This is called to create the DSDT code. THe method should write out +* whatever ACPI code is needed by this device. It will end up in the +* DSDT table. +* +* @dev: Device to write +* @ctx: ACPI context to use +* @return 0 if OK, -ve on error +*/ +int (*inject_dsdt)(const struct udevice *dev,struct acpi_ctx *ctx); };#define device_get_acpi_ops (dev) ((dev)->driver->acpi_ops)
@@ -139,6 +152,16 @@ int acpi_write_dev_tables(struct acpi_ctx *ctx);*/ int acpi_fill_ssdt (struct acpi_ctx *ctx); +/** +* acpi_inject_dsdt() - Generate ACPI tables for DSDT +* +* This is called to create the DSDT code for all devices. +* +* @ctx: ACPI context to use +* @return 0 if OK, -ve on error +*/ +int acpi_inject_dsdt (struct acpi_ctx *ctx); +#endif /* __ACPI__ */ #endif
test/dm/acpi.c +43 -1
57 lines not on this page · raw message
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 39/108 x86: Allow devices to write to DSDT
In reply to Simon GlassCall the new core function to inject ASL programmatically into the DSDT. This is made up of fragments generated by devices that have the inject_dsdt() method. The normal, compiled ASL file is added after this.
---
arch/x86/lib/acpi_table.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
arch/x86/lib/acpi_table.c +14 -1
@@ -422,7 +422,20 @@ ulong write_acpi_tables(ulong start_addr)memcpy (ctx->current, (char *)&AmlCode +sizeof (struct acpi_table_header ), dsdt->length -sizeof (struct acpi_table_header )); -acpi_inc_align (ctx, dsdt->length -sizeof (struct acpi_table_header )); + +if (dsdt->length >=sizeof (struct acpi_table_header )) { +acpi_inject_dsdt (ctx); +memcpy (ctx->current, + (char *)AmlCode +sizeof (struct acpi_table_header ), + dsdt->length -sizeof (struct acpi_table_header )); +acpi_inc (ctx, dsdt->length -sizeof (struct acpi_table_header )); + +/* (Re)calculate length and checksum. */ + dsdt->length = ctx->current - (void *)dsdt; + dsdt->checksum =0 ; + dsdt->checksum =table_compute_checksum (dsdt, dsdt->length); + } +acpi_align (ctx);/* Pack GNVS into the ACPI table area */ for (i =0 ; i < dsdt->length; i++) {
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 40/108 dm: core: Add an ACPI name for the root node
In reply to Simon GlassThis always has a fixed ACPI name so add it as a driver function.
---
drivers/core/root.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/core/root.c +13 -0
@@ -11,6 +11,7 @@#include <fdtdec.h> #include <malloc.h> #include <linux/libfdt.h> +#include <dm/acpi.h> #include <dm/device.h> #include <dm/device-internal.h> #include <dm/lists.h>
@@ -390,10 +391,22 @@ int dm_init_and_scan(bool pre_reloc_only)return 0 ; } +#ifdef CONFIG_ACPIGEN +static int root_acpi_get_name (const struct udevice *dev,char *out_name) +{ +return acpi_return_name (out_name,"\\_SB" ); +} + +struct acpi_ops root_acpi_ops = { + .get_name = root_acpi_get_name, +}; +#endif +/* This is the root driver - all drivers are children of this */ U_BOOT_DRIVER (root_driver) = { .name ="root_driver" , .id =UCLASS_ROOT , +acpi_ops_ptr (&root_acpi_ops) };/* This is the root uclass */
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 41/108 dm: acpi: Enhance acpi_get_name()
In reply to Simon GlassFor many device types it is possible to figure out the name just by looking at its uclass or parent. Add a function to handle this, since it allows us to cover the vast majority of cases automatically.
However it is sometimes impossible to figure out an ACPI name for a device just by looking at its uclass. For example a touch device may have a vendor-specific name. Add a new "acpi,name" property to allow a custom name to be created.
---
arch/sandbox/dts/test.dts | 1 + doc/device-tree-bindings/device.txt | 13 +++++++++ drivers/core/acpi.c | 11 +++++++- include/dm/device.h | 2 +- test/dm/acpi.c | 42 ++++++++++++++++++++++++++++- 5 files changed, 66 insertions(+), 3 deletions(-)
arch/sandbox/dts/test.dts +1 -0
@@ -94,6 +94,7 @@ int-value = <1234>; uint-value = <(-1234)>; interrupts-extended = <&irq 3 0>; + acpi,name = "GHIJ"; }; junk {
doc/device-tree-bindings/device.txt +13 -0
@@ -18,6 +18,8 @@ U-Boot provides for some optional properties which are documented here. - acpi,hid-desc-reg-offset : HID register offset (for Human Interface Devices) - acpi,probed : Tells U-Boot to add 'linux,probed' to the ACPI tables so that Linux will not re-init the device + - 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
@@ -35,3 +37,14 @@ synaptics_touchpad: synaptics-touchpad at 2c { acpi,probed; acpi,hid-desc-reg-offset = <0x20>; }; + +pcie-a0 at 14,0 { + reg = <0x0000a000 0 0 0 0>; + acpi,name = "RP01"; + wifi: wifi { + compatible = "intel,generic-wifi"; + acpi,desc = "Intel WiFi"; + acpi,name = "WF00"; + interrupts-extended = <&acpi_gpe 0x3c 0>; + }; +};
drivers/core/acpi.c +10 -1
@@ -9,6 +9,7 @@#define LOG_CATEOGRY LOGC_ACPI#include <common.h> +#include <acpi_device.h> #include <dm.h> #include <dm/acpi.h> #include <dm/device-internal.h>
@@ -51,12 +52,20 @@ int acpi_return_name(char *out_name, const char *name)int acpi_get_name (const struct udevice *dev,char *out_name) {struct acpi_ops *aops; +const char *name; +int ret; aops =device_get_acpi_ops (dev);if (aops && aops->get_name)return aops->get_name (dev, out_name); + name =dev_read_string (dev,"acpi,name" ); +if (name) +return acpi_return_name (out_name, name); + ret =acpi_device_get_name (dev, out_name); +if (ret) +return log_msg_ret ("dev" , ret); -return -ENOSYS ; +return 0 ; }/**
include/dm/device.h +1 -1
@@ -713,7 +713,7 @@ int dev_enable_by_path(const char *path);*/ static inline bool device_is_on_pci_bus (const struct udevice *dev) { -return device_get_uclass_id (dev->parent) ==UCLASS_PCI ; +return dev->parent &&device_get_uclass_id (dev->parent) ==UCLASS_PCI ; }/**
test/dm/acpi.c +41 -1
53 lines not on this page · raw message
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 42/108 acpi: Add an acpi split command
In reply to Simon GlassAdd a command that shows the individual blocks of data generated by each device. This can be helpful for debugging.
---
cmd/acpi.c | 15 +++++++++++++-- drivers/core/acpi.c | 18 ++++++++++++++++++ include/dm/acpi.h | 10 ++++++++++ test/dm/acpi.c | 39 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+), 2 deletions(-)
cmd/acpi.c +13 -2
@@ -146,6 +146,17 @@ static int do_acpi_list(cmd_tbl_t *cmdtp, int flag, int argc,return 0 ; } +static int do_acpi_items (cmd_tbl_t *cmdtp,int flag,int argc, +char *const argv[]) +{ +bool dump; + + dump = argc >=2 && !strcmp ("-d" , argv[1 ]); +acpi_dump_items (dump); + +return 0 ; +} +static int do_acpi_dump (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) {
@@ -153,8 +164,6 @@ static int do_acpi_dump(cmd_tbl_t *cmdtp, int flag, int argc,char sig[ACPI_NAME_LEN ];int ret; -if (argc <2 ) -return CMD_RET_USAGE ; name = argv[1 ];if (strlen (name) !=ACPI_NAME_LEN ) {printf ("Table name '%s' must be four characters\n" , name);
@@ -172,8 +181,10 @@ static int do_acpi_dump(cmd_tbl_t *cmdtp, int flag, int argc,static char acpi_help_text[] ="list - list ACPI tables\n" +"acpi items [-d] - List/dump each piece of ACPI data from devices\n" "acpi dump <name> - Dump ACPI table" ;U_BOOT_CMD_WITH_SUBCMDS (acpi,"ACPI tables" , acpi_help_text,U_BOOT_SUBCMD_MKENT (list,1 ,1 , do_acpi_list), +U_BOOT_SUBCMD_MKENT (items,2 ,1 , do_acpi_items),U_BOOT_SUBCMD_MKENT (dump,2 ,1 , do_acpi_dump));
drivers/core/acpi.c +18 -0
@@ -105,6 +105,22 @@ static int acpi_add_item(struct acpi_ctx *ctx, struct udevice *dev,return 0 ; } +void acpi_dump_items (bool dump_contents) +{ +int i; + +for (i =0 ; i < item_count; i++) { +struct acpi_item *item = &acpi_item[i]; + +printf ("dev '%s', type %d, size %x\n" , item->dev->name, + item->type, item->size); +if (dump_contents) { +print_buffer (0 , item->buf,1 , item->size,0 ); +printf ("\n" ); + } + } +} +struct acpi_item *find_item (const char *devname) {int i;
@@ -203,6 +219,7 @@ int acpi_fill_ssdt(struct acpi_ctx *ctx)int ret;log_debug ("Writing SSDT tables\n" ); + item_count =0 ; ret =_acpi_fill_ssdt (ctx,dm_root ());log_debug ("Writing SSDT finished, err=%d\n" , ret); ret =build_type (ctx, start,TYPE_SSDT );
@@ -248,6 +265,7 @@ int acpi_inject_dsdt(struct acpi_ctx *ctx)int ret;log_debug ("Writing DSDT tables\n" ); + item_count =0 ; ret =_acpi_inject_dsdt (ctx,dm_root ());log_debug ("Writing DSDT finished, err=%d\n" , ret); ret =build_type (ctx, start,TYPE_DSDT );
include/dm/acpi.h +10 -0
@@ -162,6 +162,16 @@ int acpi_fill_ssdt(struct acpi_ctx *ctx);*/ int acpi_inject_dsdt (struct acpi_ctx *ctx); +/** +* acpi_dump_items() - Dump out the collected ACPI items +* +* This lists the ACPI DSDT and SSDT items generated by the various U-Boot +* drivers. +* +* @dump_contents: true to dump the binary contents, false to just show the list +*/ +void acpi_dump_items (bool dump_contents); +#endif /* __ACPI__ */ #endif
test/dm/acpi.c +39 -0
@@ -437,3 +437,42 @@ static int dm_test_acpi_inject_dsdt(struct unit_test_state *uts)return 0 ; }DM_TEST (dm_test_acpi_inject_dsdt,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT ); + +/* Test 'acpi items' command */ +static int dm_test_acpi_cmd_items (struct unit_test_state *uts) +{ +struct acpi_ctx ctx; +void *buf; + + buf =malloc (BUF_SIZE ); +ut_assertnonnull (buf); + + ctx.current = buf; +ut_assertok (acpi_fill_ssdt (&ctx)); +console_record_reset (); +run_command ("acpi items" ,0 ); +ut_assert_nextline ("dev 'acpi-test', type 1, size 2" ); +ut_assert_nextline ("dev 'acpi-test2', type 1, size 2" ); +ut_assert_console_end (); + + ctx.current = buf; +ut_assertok (acpi_inject_dsdt (&ctx)); +console_record_reset (); +run_command ("acpi items" ,0 ); +ut_assert_nextline ("dev 'acpi-test', type 0, size 2" ); +ut_assert_nextline ("dev 'acpi-test2', type 0, size 2" ); +ut_assert_console_end (); + +console_record_reset (); +run_command ("acpi items -d" ,0 ); +ut_assert_nextline ("dev 'acpi-test', type 0, size 2" ); +ut_assert_nextlines_are_dump (2 ); +ut_assert_nextline ("%s" ,"" ); +ut_assert_nextline ("dev 'acpi-test2', type 0, size 2" ); +ut_assert_nextlines_are_dump (2 ); +ut_assert_nextline ("%s" ,"" ); +ut_assert_console_end (); + +return 0 ; +} +DM_TEST (dm_test_acpi_cmd_items,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT );
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 43/108 acpi: Allow creating the GNVS to fail
In reply to Simon GlassIn some cases an internal error may prevent this from working. Update the function return value and report the error. At present the API for writing tables does not easily support reporting errors, but once it is fully updated to use a context pointer, this will be easier.
---
arch/x86/cpu/baytrail/acpi.c | 4 +++- arch/x86/cpu/quark/acpi.c | 4 +++- arch/x86/cpu/tangier/acpi.c | 4 +++- arch/x86/include/asm/acpi_table.h | 10 +++++++++- arch/x86/lib/acpi_table.c | 10 ++++++++-- 5 files changed, 26 insertions(+), 6 deletions(-)
arch/x86/cpu/baytrail/acpi.c +3 -1
@@ -138,7 +138,7 @@ void acpi_create_fadt(struct acpi_fadt *fadt, struct acpi_facs *facs, header->checksum =table_compute_checksum (fadt, header->length); } -void acpi_create_gnvs (struct acpi_global_nvs *gnvs) +int acpi_create_gnvs (struct acpi_global_nvs *gnvs) {struct udevice *dev;int ret;
@@ -158,6 +158,8 @@ void acpi_create_gnvs(struct acpi_global_nvs *gnvs) gnvs->iuart_en =1 ; else gnvs->iuart_en = 0; + +return 0 ; }#ifdef CONFIG_HAVE_ACPI_RESUME
arch/x86/cpu/quark/acpi.c +3 -1
@@ -133,8 +133,10 @@ void acpi_create_fadt(struct acpi_fadt *fadt, struct acpi_facs *facs, header->checksum =table_compute_checksum (fadt, header->length); } -void acpi_create_gnvs (struct acpi_global_nvs *gnvs) +int acpi_create_gnvs (struct acpi_global_nvs *gnvs) {/* quark is a uni-processor */ gnvs->pcnt =1 ; + +return 0 ; }
arch/x86/cpu/tangier/acpi.c +3 -1
@@ -107,7 +107,7 @@ u32 acpi_fill_csrt(u32 current)return current; } -void acpi_create_gnvs (struct acpi_global_nvs *gnvs) +int acpi_create_gnvs (struct acpi_global_nvs *gnvs) {struct udevice *dev;int ret;
@@ -122,4 +122,6 @@ void acpi_create_gnvs(struct acpi_global_nvs *gnvs)if (ret >0 ) gnvs->pcnt = ret; } + +return 0 ; }
arch/x86/include/asm/acpi_table.h +9 -1
@@ -26,7 +26,15 @@ int acpi_create_mcfg_mmconfig(struct acpi_mcfg_mmconfig *mmconfig, u32 base, u16 seg_nr, u8 start, u8 end);u32 acpi_fill_mcfg (u32 current);u32 acpi_fill_csrt (u32 current); -void acpi_create_gnvs (struct acpi_global_nvs *gnvs); + +/** +* acpi_create_gnvs() - Create a GNVS (Global Non Volatile Storage) table +* +* @gnvs: Table to fill in +* @return 0 if OK, -ve on error +*/ +int acpi_create_gnvs (struct acpi_global_nvs *gnvs); +ulong write_acpi_tables (ulong start);/**
arch/x86/lib/acpi_table.c +8 -2
@@ -453,8 +453,14 @@ ulong write_acpi_tables(ulong start_addr) dsdt->checksum =0 ; dsdt->checksum =table_compute_checksum ((void *)dsdt, dsdt->length); -/* Fill in platform-specific global NVS variables */ -acpi_create_gnvs (ctx->current); +/* +* Fill in platform-specific global NVS variables. If this fails we +* cannot return the error but this should only happen while debugging. +*/ + addr =acpi_create_gnvs (ctx->current); +if (IS_ERR_VALUE (addr)) +printf ("Error: Gailed to create GNVS\n" ); +acpi_inc_align (ctx,sizeof (struct acpi_global_nvs ));debug ("ACPI: * FADT\n" );
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 44/108 dtoc: Support ACPI paths in of-platdata
In reply to Simon GlassThe start of an ACPI path typically has backslashes in it. These are not preserved during the translation from device tree to C code, since dtc (correctly) uses the first backslash as an escape character, and dtoc therefore leaves it out of the C string.
Fix this with special-case handling.
---
tools/dtoc/dtb_platdata.py | 4 +++- tools/dtoc/dtoc_test_simple.dts | 1 + tools/dtoc/test_dtoc.py | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-)
tools/dtoc/dtb_platdata.py +3 -1
@@ -102,7 +102,9 @@ def get_value(ftype, value): elif ftype == fdt.TYPE_BYTE: return '%#x' % tools.ToByte(value[0]) elif ftype == fdt.TYPE_STRING: - return '"%s"' % value + # Handle evil ACPI backslashes by adding another backslash before them. + # So "\\_SB.GPO0" in the device tree effectively stays like that in C + return '"%s"' % value.replace('\\', '\\\\') elif ftype == fdt.TYPE_BOOL: return 'true' elif ftype == fdt.TYPE_INT64:
tools/dtoc/dtoc_test_simple.dts +1 -0
@@ -34,6 +34,7 @@ longbytearray = [09 0a 0b 0c]; stringval = "message2"; stringarray = "another", "multi-word", "message"; + acpi-name = "\\_SB.GPO0"; }; spl-test3 {
tools/dtoc/test_dtoc.py +3 -0
@@ -70,6 +70,7 @@ class TestDtoc(unittest.TestCase): @classmethod def setUpClass(cls): tools.PrepareOutputDir(None) + cls.maxDiff = None @classmethod def tearDownClass(cls):
@@ -181,6 +182,7 @@ struct dtd_sandbox_pmic_test { \tfdt64_t\t\treg[2]; }; struct dtd_sandbox_spl_test { +\tconst char * acpi_name; \tbool\t\tboolval; \tunsigned char\tbytearray[3]; \tunsigned char\tbyteval;
@@ -218,6 +220,7 @@ U_BOOT_DEVICE(spl_test) = { }; static const struct dtd_sandbox_spl_test dtv_spl_test2 = { +\t.acpi_name\t\t= "\\\\_SB.GPO0", \t.bytearray\t\t= {0x1, 0x23, 0x34}, \t.byteval\t\t= 0x8, \t.intarray\t\t= {0x5, 0x0, 0x0, 0x0},
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 45/108 acpi: mmc: Generate ACPI info for the PCI SD Card
In reply to Simon GlassWrite required information into the SSDT to describe the SD card card-detect pin. Since the required GPIO properties are not present in the device-tree binding, set them manually for now.
---
configs/sandbox_defconfig | 2 ++ drivers/mmc/pci_mmc.c | 76 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 77 insertions(+), 1 deletion(-)
configs/sandbox_defconfig +2 -0
@@ -137,7 +137,9 @@ CONFIG_P2SB=y CONFIG_PWRSEQ=y CONFIG_SPL_PWRSEQ=y CONFIG_I2C_EEPROM=y +CONFIG_MMC_PCI=y CONFIG_MMC_SANDBOX=y +CONFIG_MMC_SDHCI=y CONFIG_MTD=y CONFIG_SPI_FLASH_SANDBOX=y CONFIG_SPI_FLASH_ATMEL=y
drivers/mmc/pci_mmc.c +75 -1
113 lines not on this page · raw message
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 46/108 sound: Add an ACPI driver for Dialog Semicondutor da7219
In reply to Simon GlassThis chip is used on coral and we need to generate ACPI tables for sound to make it work. Add a driver that does just this (i.e. at present does not actually support playing sound).
---
configs/sandbox_defconfig | 1 + doc/device-tree-bindings/sound/da7219.txt | 113 +++++++++++++++++++++ drivers/sound/Kconfig | 9 ++ drivers/sound/Makefile | 1 + drivers/sound/da7219.c | 115 ++++++++++++++++++++++ 5 files changed, 239 insertions(+) create mode 100644 doc/device-tree-bindings/sound/da7219.txt create mode 100644 drivers/sound/da7219.c
configs/sandbox_defconfig +1 -0
@@ -196,6 +196,7 @@ CONFIG_SANDBOX_SERIAL=y CONFIG_SMEM=y CONFIG_SANDBOX_SMEM=y CONFIG_SOUND=y +CONFIG_SOUND_DA7219=y CONFIG_SOUND_SANDBOX=y CONFIG_SANDBOX_SPI=y CONFIG_SPMI=y
doc/device-tree-bindings/sound/da7219.txt new file +113 -0
113 lines not on this page · raw message
drivers/sound/Kconfig +9 -0
@@ -40,6 +40,15 @@ config I2S_SAMSUNG option provides an implementation for sound_init() and sound_play(). +config SOUND_DA7219 + bool "Dialog Semiconductor audio codec" + depends on SOUND + help + The DA7219 is an ultra-low-power audio codec with Advanced Accessory + Detection (AAD). This driver only supports generation of ACPI tables. + It does not support sound output or any of the other codec + features. + config SOUND_I8254 bool "Intel i8254 timer / beeper" depends on SOUND
drivers/sound/Makefile +1 -0
@@ -7,6 +7,7 @@ obj-$(CONFIG_SOUND) += sound.o obj-$(CONFIG_SOUND) += codec-uclass.o obj-$(CONFIG_SOUND) += i2s-uclass.o obj-$(CONFIG_SOUND) += sound-uclass.o +obj-$(CONFIG_SOUND_DA7219) += da7219.o obj-$(CONFIG_I2S_SAMSUNG) += samsung-i2s.o obj-$(CONFIG_SOUND_SANDBOX) += sandbox.o obj-$(CONFIG_I2S_ROCKCHIP) += rockchip_i2s.o rockchip_sound.o
drivers/sound/da7219.c new file +115 -0
115 lines not on this page · raw message
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 47/108 sound: Add an ACPI driver for Maxim MAX98357ac
In reply to Simon GlassThis chip is used on coral and we need to generate ACPI tables for sound to make it work. Add a driver that does just this (i.e. at present does not actually support playing sound).
---
configs/sandbox_defconfig | 1 + doc/device-tree-bindings/sound/max98357a.txt | 22 ++++ drivers/sound/Kconfig | 9 ++ drivers/sound/Makefile | 1 + drivers/sound/max98357a.c | 109 +++++++++++++++++++ 5 files changed, 142 insertions(+) create mode 100644 doc/device-tree-bindings/sound/max98357a.txt create mode 100644 drivers/sound/max98357a.c
configs/sandbox_defconfig +1 -0
@@ -197,6 +197,7 @@ CONFIG_SMEM=y CONFIG_SANDBOX_SMEM=y CONFIG_SOUND=y CONFIG_SOUND_DA7219=y +CONFIG_SOUND_MAX98357A=y CONFIG_SOUND_SANDBOX=y CONFIG_SANDBOX_SPI=y CONFIG_SPMI=y
doc/device-tree-bindings/sound/max98357a.txt new file +22 -0
@@ -0,0 +1,22 @@ +Maxim MAX98357A audio DAC + +This node models the Maxim MAX98357A DAC. + +Required properties: +- compatible : "maxim,max98357a" + +Optional properties: +- sdmode-gpios : GPIO specifier for the chip's SD_MODE pin. + If this option is not specified then driver does not manage + the pin state (e.g. chip is always on). +- sdmode-delay : specify delay time for SD_MODE pin. + If this option is specified, which means it's required i2s clocks + ready before SD_MODE is unmuted in order to avoid the speaker pop noise. + It's observed that 5ms is sufficient. + +Example: + +max98357a { + compatible = "maxim,max98357a"; + sdmode-gpios = <&qcom_pinmux 25 0>; +};
drivers/sound/Kconfig +9 -0
@@ -113,6 +113,15 @@ config SOUND_MAX98095 audio data and I2C for codec control. At present it only works with the Samsung I2S driver. +config SOUND_MAX98357A + bool "Support Maxim max98357a audio codec" + depends on PCI + help + Enable the max98357a audio codec. This is connected on PCI for + audio data codec control. This is currently only capable of providing + ACPI information. A full driver (with sound in U-Boot) is currently + not available. + config SOUND_RT5677 bool "Support Realtek RT5677 audio codec" depends on SOUND
drivers/sound/Makefile +1 -0
@@ -17,6 +17,7 @@ obj-$(CONFIG_SOUND_WM8994) += wm8994.o obj-$(CONFIG_SOUND_MAX98088) += max98088.o maxim_codec.o obj-$(CONFIG_SOUND_MAX98090) += max98090.o maxim_codec.o obj-$(CONFIG_SOUND_MAX98095) += max98095.o maxim_codec.o +obj-$(CONFIG_SOUND_MAX98357A) += max98357a.o obj-$(CONFIG_SOUND_INTEL_HDA) += hda_codec.o obj-$(CONFIG_SOUND_I8254) += i8254_beep.o obj-$(CONFIG_SOUND_RT5677) += rt5677.o
drivers/sound/max98357a.c new file +109 -0
109 lines not on this page · raw message
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 48/108 x86: pinctrl: Add a way to get the pinctrl reg address
In reply to Simon GlassAt present we can query the offset of a pinctrl register within the p2sb. For ACPI we need to get the actual address of the register. Add a function to handle this and rename the old one to more accurately reflect its purpose.
---
arch/x86/include/asm/intel_pinctrl.h | 16 ++++++++++++++-- drivers/gpio/intel_gpio.c | 15 +++++++++++---- drivers/misc/p2sb-uclass.c | 16 ++++++++-------- drivers/pinctrl/intel/pinctrl.c | 11 +++++++++-- include/p2sb.h | 9 +++++++++ 5 files changed, 51 insertions(+), 16 deletions(-)
arch/x86/include/asm/intel_pinctrl.h +14 -2
@@ -262,11 +262,23 @@ int pinctrl_read_pads(struct udevice *dev, ofnode node, const char *prop,int pinctrl_count_pads (struct udevice *dev,u32 *pads,int size);/** -* intel_pinctrl_get_config_reg_addr() - Get address of the pin config registers +* intel_pinctrl_get_config_reg_offset() - Get offset of pin config registers * +* This works out the register offset of a pin within the p2sb region. +* +* @dev: Pinctrl device +* @offset: GPIO offset within this device +* @return register offset of first register within the GPIO p2sb region +*/ +u32 intel_pinctrl_get_config_reg_offset (struct udevice *dev,uint offset); + +/** +* intel_pinctrl_get_config_reg_offset() - Get address of pin config registers +* +* This works out the absolute address of the registers for a pin * @dev: Pinctrl device * @offset: GPIO offset within this device -* @return register offset within the GPIO p2sb region +* @return register offset of first register within the GPIO p2sb region */ u32 intel_pinctrl_get_config_reg_addr (struct udevice *dev,uint offset);
drivers/gpio/intel_gpio.c +11 -4
@@ -23,7 +23,9 @@static int intel_gpio_direction_input (struct udevice *dev,uint offset) {struct udevice *pinctrl =dev_get_parent (dev); -uint config_offset =intel_pinctrl_get_config_reg_addr (pinctrl, offset); +uint config_offset; + + config_offset =intel_pinctrl_get_config_reg_offset (pinctrl, offset); pcr_clrsetbits32(pinctrl, config_offset, PAD_CFG0_MODE_MASK | PAD_CFG0_TX_STATE |
@@ -37,7 +39,9 @@ static int intel_gpio_direction_output(struct udevice *dev, uint offset, int value) {struct udevice *pinctrl =dev_get_parent (dev); -uint config_offset =intel_pinctrl_get_config_reg_addr (pinctrl, offset); +uint config_offset; + + config_offset =intel_pinctrl_get_config_reg_offset (pinctrl, offset); pcr_clrsetbits32(dev, config_offset, PAD_CFG0_MODE_MASK | PAD_CFG0_RX_STATE |
@@ -67,10 +71,13 @@ static int intel_gpio_get_value(struct udevice *dev, uint offset)return 0 ; } -static int intel_gpio_set_value (struct udevice *dev,unsigned offset,int value) +static int intel_gpio_set_value (struct udevice *dev,unsigned int offset, +int value) {struct udevice *pinctrl =dev_get_parent (dev); -uint config_offset =intel_pinctrl_get_config_reg_addr (pinctrl, offset); +uint config_offset; + + config_offset =intel_pinctrl_get_config_reg_offset (pinctrl, offset);pcr_clrsetbits32 (dev, config_offset,PAD_CFG0_TX_STATE , value ?PAD_CFG0_TX_STATE :0 );
drivers/misc/p2sb-uclass.c +8 -8
@@ -16,7 +16,7 @@#define PCR_COMMON_IOSF_1_0 1 -static void *_pcr_reg_address (struct udevice *dev,uint offset) +void *pcr_reg_address (struct udevice *dev,uint offset) {struct p2sb_child_platdata *pplat =dev_get_parent_platdata (dev);struct udevice *p2sb =dev_get_parent (dev);
@@ -53,7 +53,7 @@ uint pcr_read32(struct udevice *dev, uint offset)/* Ensure the PCR offset is correctly aligned */ assert (IS_ALIGNED (offset,sizeof (uint32_t ))); - ptr =_pcr_reg_address (dev, offset); + ptr =pcr_reg_address (dev, offset); val =readl (ptr);unmap_sysmem (ptr);
@@ -65,7 +65,7 @@ uint pcr_read16(struct udevice *dev, uint offset)/* Ensure the PCR offset is correctly aligned */ check_pcr_offset_align (offset,sizeof (uint16_t )); -return readw (_pcr_reg_address (dev, offset)); +return readw (pcr_reg_address (dev, offset)); }uint pcr_read8 (struct udevice *dev,uint offset)
@@ -73,7 +73,7 @@ uint pcr_read8(struct udevice *dev, uint offset)/* Ensure the PCR offset is correctly aligned */ check_pcr_offset_align (offset,sizeof (uint8_t )); -return readb (_pcr_reg_address (dev, offset)); +return readb (pcr_reg_address (dev, offset)); }/*
@@ -84,7 +84,7 @@ uint pcr_read8(struct udevice *dev, uint offset)*/ static void write_completion (struct udevice *dev,uint offset) { -readl (_pcr_reg_address (dev,ALIGN_DOWN (offset,sizeof (uint32_t )))); +readl (pcr_reg_address (dev,ALIGN_DOWN (offset,sizeof (uint32_t )))); }void pcr_write32 (struct udevice *dev,uint offset,uint indata)
@@ -92,7 +92,7 @@ void pcr_write32(struct udevice *dev, uint offset, uint indata)/* Ensure the PCR offset is correctly aligned */ assert (IS_ALIGNED (offset,sizeof (indata))); -writel (indata,_pcr_reg_address (dev, offset)); +writel (indata,pcr_reg_address (dev, offset));/* Ensure the writes complete */ write_completion (dev, offset); }
@@ -102,7 +102,7 @@ void pcr_write16(struct udevice *dev, uint offset, uint indata)/* Ensure the PCR offset is correctly aligned */ check_pcr_offset_align (offset,sizeof (uint16_t )); -writew (indata,_pcr_reg_address (dev, offset)); +writew (indata,pcr_reg_address (dev, offset));/* Ensure the writes complete */ write_completion (dev, offset); }
@@ -112,7 +112,7 @@ void pcr_write8(struct udevice *dev, uint offset, uint indata)/* Ensure the PCR offset is correctly aligned */ check_pcr_offset_align (offset,sizeof (uint8_t )); -writeb (indata,_pcr_reg_address (dev, offset)); +writeb (indata,pcr_reg_address (dev, offset));/* Ensure the writes complete */ write_completion (dev, offset); }
drivers/pinctrl/intel/pinctrl.c +9 -2
@@ -391,7 +391,7 @@ static int pinctrl_configure_pad(struct udevice *dev,return 0 ; } -u32 intel_pinctrl_get_config_reg_addr (struct udevice *dev,uint offset) +u32 intel_pinctrl_get_config_reg_offset (struct udevice *dev,uint offset) {struct intel_pinctrl_priv *priv =dev_get_priv (dev);const struct pad_community *comm = priv->comm;
@@ -404,9 +404,16 @@ u32 intel_pinctrl_get_config_reg_addr(struct udevice *dev, uint offset)return config_offset; } +u32 intel_pinctrl_get_config_reg_addr (struct udevice *dev,uint offset) +{ +uint config_offset =intel_pinctrl_get_config_reg_offset (dev, offset); + +return (u32 )(ulong )pcr_reg_address (dev, config_offset); +} +u32 intel_pinctrl_get_config_reg (struct udevice *dev,uint offset) { -uint config_offset =intel_pinctrl_get_config_reg_addr (dev, offset); +uint config_offset =intel_pinctrl_get_config_reg_offset (dev, offset);return pcr_read32 (dev, config_offset); }
include/p2sb.h +9 -0
@@ -132,4 +132,13 @@ int p2sb_set_port_id(struct udevice *dev, int portid);*/ int p2sb_get_port_id (struct udevice *dev); +/** +* pcr_reg_address() Convert an offset in p2sb space to an absolute address +* +* @dev: Child device (whose parent is UCLASS_P2SB) +* @offset: Offset within that child's address space +* @return pointer to that offset within the child's address space +*/ +void *pcr_reg_address (struct udevice *dev,uint offset); +#endif
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 49/108 x86: pinctrl: Update comment for intel_pinctrl_get_pad()
In reply to Simon GlassAdd information about what is returned on error.
---
arch/x86/include/asm/intel_pinctrl.h | 1 + 1 file changed, 1 insertion(+)
arch/x86/include/asm/intel_pinctrl.h +1 -0
@@ -299,6 +299,7 @@ u32 intel_pinctrl_get_config_reg(struct udevice *dev, uint offset);* @pad: Pad to check * @devp: Returns pinctrl device containing that pad * @offsetp: Returns offset of pad within that pinctrl device +* @return 0 if OK, -ENOTBLK if pad number is invalid */ int intel_pinctrl_get_pad (uint pad,struct udevice **devp,uint *offsetp);
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 50/108 x86: pinctrl: Add multi-ACPI control
In reply to Simon GlassAdd a Kconfig to control whether pinctrl is represented as a single ACPI device or as multiple devices. In the latter case (the default) we should return the pin number relative to the pinctrl device.
---
drivers/pinctrl/intel/Kconfig | 4 ++++ drivers/pinctrl/intel/pinctrl.c | 2 ++ 2 files changed, 6 insertions(+)
drivers/pinctrl/intel/Kconfig +4 -0
@@ -15,6 +15,10 @@ config INTEL_PINCTRL_IOSTANDBY bool default y +config INTEL_PINCTRL_MULTI_ACPI_DEVICES + bool + default y + config PINCTRL_INTEL_APL bool "Support Intel Apollo Lake (APL)" help
drivers/pinctrl/intel/pinctrl.c +2 -0
@@ -424,6 +424,8 @@ int intel_pinctrl_get_acpi_pin(struct udevice *dev, uint offset)const struct pad_community *comm = priv->comm;int group; +if (IS_ENABLED (CONFIG_INTEL_PINCTRL_MULTI_ACPI_DEVICES )) +return offset; group =pinctrl_group_index (comm, offset);/* If pad base is not set then use GPIO number as ACPI pin number */
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 51/108 x86: pinctrl: Set up itss in the probe() method
In reply to Simon GlassAt present the itss is probed in the ofdata_to_platdata() method. This is incorrect since itss is a child of p2sb which itself needs to probe the pinctrl device. This means that p2sb is effectively not probed when the itss is probed, so we get the wrong register address from p2sb.
Fix this by moving the itss probe to the correct place.
---
drivers/pinctrl/intel/pinctrl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/pinctrl/intel/pinctrl.c +4 -4
@@ -616,15 +616,11 @@ int intel_pinctrl_ofdata_to_platdata(struct udevice *dev, {struct p2sb_child_platdata *pplat =dev_get_parent_platdata (dev);struct intel_pinctrl_priv *priv =dev_get_priv (dev); -int ret;if (!comm) {log_err ("Cannot find community for pid %d\n" , pplat->pid);return -EDOM ; } - ret =irq_first_device_type (X86_IRQT_ITSS , &priv->itss); -if (ret) -return log_msg_ret ("Cannot find ITSS" , ret); priv->comm = comm; priv->num_cfgs = num_cfgs;
@@ -634,8 +630,12 @@ int intel_pinctrl_ofdata_to_platdata(struct udevice *dev,int intel_pinctrl_probe (struct udevice *dev) {struct intel_pinctrl_priv *priv =dev_get_priv (dev); +int ret; priv->itss_pol_cfg = true; + ret =irq_first_device_type (X86_IRQT_ITSS , &priv->itss); +if (ret) +return log_msg_ret ("Cannot find ITSS" , ret);return 0 ; }
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 52/108 x86: pinctrl: Drop the acpi_name member
In reply to Simon GlassThis is in the device tree now, so drop the unnecessary field here.
---
arch/x86/include/asm/intel_pinctrl.h | 2 -- drivers/pinctrl/intel/pinctrl_apl.c | 4 ---- 2 files changed, 6 deletions(-)
arch/x86/include/asm/intel_pinctrl.h +0 -2
@@ -98,7 +98,6 @@ struct pad_group {* groups exist inside a community * * @name: Community name -* @acpi_path: ACPI path * @num_gpi_regs: number of gpi registers in community * @max_pads_per_group: number of pads in each group; number of pads bit-mapped * in each GPI status/en and Host Own Reg
@@ -119,7 +118,6 @@ struct pad_group {*/ struct pad_community {const char *name; -const char *acpi_path;size_t num_gpi_regs;size_t max_pads_per_group;uint first_pad;
drivers/pinctrl/intel/pinctrl_apl.c +0 -4
@@ -74,7 +74,6 @@ static const struct pad_community apl_gpio_communities[] = { .gpi_smi_en_reg_0 = GPI_SMI_EN_0, .max_pads_per_group = GPIO_MAX_NUM_PER_GROUP, .name = "GPIO_GPE_N", - .acpi_path = "\\_SB.GPO0", .reset_map = rst_map, .num_reset_vals = ARRAY_SIZE(rst_map), .groups = apl_community_n_groups,
@@ -93,7 +92,6 @@ static const struct pad_community apl_gpio_communities[] = { .gpi_smi_en_reg_0 = GPI_SMI_EN_0, .max_pads_per_group = GPIO_MAX_NUM_PER_GROUP, .name = "GPIO_GPE_NW", - .acpi_path = "\\_SB.GPO1", .reset_map = rst_map, .num_reset_vals = ARRAY_SIZE(rst_map), .groups = apl_community_nw_groups,
@@ -112,7 +110,6 @@ static const struct pad_community apl_gpio_communities[] = { .gpi_smi_en_reg_0 = GPI_SMI_EN_0, .max_pads_per_group = GPIO_MAX_NUM_PER_GROUP, .name = "GPIO_GPE_W", - .acpi_path = "\\_SB.GPO2", .reset_map = rst_map, .num_reset_vals = ARRAY_SIZE(rst_map), .groups = apl_community_w_groups,
@@ -131,7 +128,6 @@ static const struct pad_community apl_gpio_communities[] = { .gpi_smi_en_reg_0 = GPI_SMI_EN_0, .max_pads_per_group = GPIO_MAX_NUM_PER_GROUP, .name = "GPIO_GPE_SW", - .acpi_path = "\\_SB.GPO3", .reset_map = rst_map, .num_reset_vals = ARRAY_SIZE(rst_map), .groups = apl_community_sw_groups,
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 53/108 dm: core: Add a way of overriding the ACPI device path
In reply to Simon GlassSome devices such as GPIO need to override the normal path that would be generated by driver model. Add a device-tree property for this.
---
doc/device-tree-bindings/device.txt | 23 +++++++++++++++++++++++ drivers/core/acpi.c | 19 +++++++++++++++++++ include/dm/acpi.h | 13 +++++++++++++ 3 files changed, 55 insertions(+)
doc/device-tree-bindings/device.txt +23 -0
@@ -16,6 +16,8 @@ U-Boot provides for some optional properties which are documented here. - acpi,hid : Contains the string to use as the HID (Human Interface Device) identifier _HID - acpi,hid-desc-reg-offset : HID register offset (for Human Interface Devices) + - acpi,path : Specifies the full ACPI path for a device. This overrides the + normal path built from the driver-model hierarchy - acpi,probed : Tells U-Boot to add 'linux,probed' to the ACPI tables so that Linux will not re-init the device - acpi,name : Provides the ACPI name for a device, which is a string consisting
@@ -48,3 +50,24 @@ pcie-a0 at 14,0 { interrupts-extended = <&acpi_gpe 0x3c 0>; }; }; + +p2sb: p2sb at d,0 { + u-boot,dm-pre-reloc; + reg = <0x02006810 0 0 0 0>; + compatible = "intel,apl-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"; + }; + };
drivers/core/acpi.c +19 -0
@@ -68,6 +68,25 @@ int acpi_get_name(const struct udevice *dev, char *out_name)return 0 ; } +int acpi_get_path (const struct udevice *dev,char *out_path,int maxlen) +{ +const char *path; +int ret; + + path =dev_read_string (dev,"acpi,path" ); +if (path) { +if (strlen (path) >= maxlen) +return -E2BIG ; +strcpy (out_path, path); +return 0 ; + } + ret =acpi_device_path (dev, out_path, maxlen); +if (ret) +return log_msg_ret ("dev" , ret); + +return 0 ; +} +/** * acpi_add_item() - Add a new item to the list of data collected *
include/dm/acpi.h +13 -0
@@ -172,6 +172,19 @@ int acpi_inject_dsdt(struct acpi_ctx *ctx);*/ void acpi_dump_items (bool dump_contents); +/** +* acpi_get_path() - Get the full ACPI path for a device +* +* This checks for any override in the device tree and calls acpi_device_path() +* if not +* +* @dev: Device to check +* @out_path: Buffer to place the path in (should be ACPI_PATH_MAX long) +* @maxlen: Size of buffer (typically ACPI_PATH_MAX) +* @return 0 if OK, -ve on error +*/ +int acpi_get_path (const struct udevice *dev,char *out_path,int maxlen); +#endif /* __ACPI__ */ #endif
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 54/108 x86: gpio: Add support for obtaining ACPI info for a GPIO
In reply to Simon GlassImplement the method that converts a GPIO into the form used by ACPI, so that GPIOs can be added to ACPI tables.
---
drivers/gpio/intel_gpio.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
drivers/gpio/intel_gpio.c +31 -0
@@ -4,6 +4,7 @@*/ #include <common.h> +#include <acpi_device.h> #include <dm.h> #include <errno.h> #include <fdtdec.h>
@@ -127,6 +128,33 @@ static int intel_gpio_xlate(struct udevice *orig_dev, struct gpio_desc *desc,return 0 ; } +#if CONFIG_IS_ENABLED (ACPIGEN ) +static int intel_gpio_get_acpi (const struct gpio_desc *desc, +struct acpi_gpio *gpio) +{ +struct udevice *pinctrl; +int ret; + +if (!dm_gpio_is_valid (desc)) +return -ENOENT ; + pinctrl =dev_get_parent (desc->dev); + +memset (gpio,'\0' ,sizeof (*gpio)); + + gpio->type =ACPI_GPIO_TYPE_IO ; + gpio->pull =ACPI_GPIO_PULL_DEFAULT ; + gpio->io_restrict =ACPI_GPIO_IO_RESTRICT_OUTPUT ; + gpio->polarity =ACPI_GPIO_ACTIVE_HIGH ; + gpio->pin_count =1 ; + gpio->pins[0 ] =intel_pinctrl_get_acpi_pin (pinctrl, desc->offset); + ret =acpi_device_path (pinctrl, gpio->resource,sizeof (gpio->resource)); +if (ret) +return log_msg_ret ("resource" , ret); + +return 0 ; +} +#endif +static int intel_gpio_probe (struct udevice *dev) {return 0 ;
@@ -151,6 +179,9 @@ static const struct dm_gpio_ops gpio_intel_ops = { .set_value = intel_gpio_set_value, .get_function = intel_gpio_get_function, .xlate = intel_gpio_xlate, +#if CONFIG_IS_ENABLED (ACPIGEN ) + .get_acpi = intel_gpio_get_acpi, +#endif };static const struct udevice_id intel_intel_gpio_ids[] = {
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 55/108 i2c: designware_i2c: Support ACPI table generation
In reply to Simon GlassUpdate the PCI driver to generate ACPI information so that Linux has the full information about each I2C bus.
---
drivers/i2c/designware_i2c.c | 25 ++++++++ drivers/i2c/designware_i2c.h | 15 +++++ drivers/i2c/designware_i2c_pci.c | 104 ++++++++++++++++++++++++++++++- 3 files changed, 143 insertions(+), 1 deletion(-)
drivers/i2c/designware_i2c.c +25 -0
@@ -298,6 +298,31 @@ static int _dw_i2c_set_bus_speed(struct dw_i2c *priv, struct i2c_regs *i2c_base,/* Restore back i2c now speed set */ if (ena ==IC_ENABLE_0B )dw_i2c_enable (i2c_base, true); +if (priv) + priv->config = config; +return 0 ; +} + +int dw_i2c_gen_speed_config (const struct udevice *dev,int speed_hz, +struct dw_i2c_speed_config *config) +{ +struct dw_i2c *priv =dev_get_priv (dev); +ulong rate; +int ret; + +if (CONFIG_IS_ENABLED (CLK )) { + rate =clk_get_rate (&priv->clk); +if (IS_ERR_VALUE (rate)) +return log_msg_ret ("clk" , -EINVAL ); + }else { + rate =IC_CLK ; + } + + ret =calc_bus_speed (priv, speed_hz, rate, config); +if (ret) +printf ("%s: ret=%d\n" , __func__, ret); +if (ret) +return log_msg_ret ("calc_bus_speed" , ret);return 0 ; }
drivers/i2c/designware_i2c.h +15 -0
@@ -198,6 +198,7 @@ struct dw_i2c {#if CONFIG_IS_ENABLED (CLK )struct clk clk;#endif +struct dw_i2c_speed_config config; };extern const struct dm_i2c_ops designware_i2c_ops;
@@ -206,4 +207,18 @@ int designware_i2c_probe(struct udevice *bus);int designware_i2c_remove (struct udevice *dev);int designware_i2c_ofdata_to_platdata (struct udevice *bus); +/** +* dw_i2c_gen_speed_config() - Calculate config info from requested speed1 +* +* Calculate the speed config from the given @speed_hz and return it so that +* it can be incorporated in ACPI tables +* +* @dev: I2C bus to check +* @speed_hz: Requested speed in Hz +* @config: Returns config to use for that speed +* @return 0 if OK, -ve on error +*/ +int dw_i2c_gen_speed_config (const struct udevice *dev,int speed_hz, +struct dw_i2c_speed_config *config); +#endif /* __DW_I2C_H_ */
drivers/i2c/designware_i2c_pci.c +103 -1
137 lines not on this page · raw message
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 56/108 i2c: Add a generic driver to generate ACPI info
In reply to Simon GlassMany 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.
---
doc/device-tree-bindings/i2c/generic-acpi.txt | 42 ++++ drivers/i2c/Makefile | 3 + drivers/i2c/acpi_i2c.c | 228 ++++++++++++++++++ drivers/i2c/acpi_i2c.h | 15 ++ drivers/i2c/i2c-uclass.c | 14 ++ include/i2c.h | 17 ++ 6 files changed, 319 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
@@ -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-m s: 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) + - acpi,hid-desc-reg-offset : HID register offset (for Human Interface Devices) + +Example +------- + + elan-touchscreen at 10 { + compatible = "i2c-chip"; + reg = <0x10>; + acpi,hid = "ELAN0001"; + acpi,desc = "ELAN Touchscreen"; + interrupts-extended = <&acpi_gpe GPIO_21_IRQ + IRQ_TYPE_EDGE_FALLING>; + acpi,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
@@ -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 +228 -0
228 lines not on this page · raw message
drivers/i2c/acpi_i2c.h new file +15 -0
@@ -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 +14 -0
@@ -4,16 +4,19 @@*/ #include <common.h> +#include <acpi_device.h> #include <dm.h> #include <errno.h> #include <i2c.h> #include <malloc.h> +#include <dm/acpi.h> #include <dm/device-internal.h> #include <dm/lists.h> #include <dm/pinctrl.h> #if CONFIG_IS_ENABLED (DM_GPIO )#include <asm/gpio.h> #endif +#include "acpi_i2c.h" #define I2C_MAX_OFFSET_LEN 4
@@ -728,7 +731,18 @@ UCLASS_DRIVER(i2c_generic) = { .name = "i2c_generic", }; +static const struct udevice_id generic_chip_i2c_ids[] = { + { .compatible ="i2c-chip" }, + { } +}; +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/i2c.h +17 -0
@@ -538,6 +538,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.25.0.341.g760bfbb309-goog
PATCH 57/108 p2sb: Add a method to hide the bus
In reply to Simon GlassThe P2SB bus needs to be hidden in some cases so that it does not get auto-configured by Linux. Add a method for this.
---
drivers/misc/p2sb-uclass.c | 10 ++++++++++ include/p2sb.h | 25 ++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-)
drivers/misc/p2sb-uclass.c +10 -0
@@ -16,6 +16,16 @@#define PCR_COMMON_IOSF_1_0 1 +int p2sb_set_hide (struct udevice *dev,bool hide) +{ +struct p2sb_ops *ops =p2sb_get_ops (dev); + +if (!ops->set_hide) +return -ENOSYS ; + +return ops->set_hide (dev, hide); +} +void *pcr_reg_address (struct udevice *dev,uint offset) {struct p2sb_child_platdata *pplat =dev_get_parent_platdata (dev);
include/p2sb.h +24 -1
@@ -31,13 +31,36 @@ struct p2sb_uc_priv { };/** -* struct p2sb_ops - Operations for the P2SB (none at present) +* struct p2sb_ops - Operations for the P2SB */ struct p2sb_ops { +/** +* set_hide() - Set/clear the 'hide' bit on the p2sb +* +* This device can be hidden from the PCI bus if needed. This method +* can be called before the p2sb is probed. +* +* @dev: P2SB device +* @hide: true to hide the device, false to show it +* @return 0 if OK, -ve on error +*/ +int (*set_hide)(struct udevice *dev,bool hide); };#define p2sb_get_ops (dev) ((struct p2sb_ops *)(dev)->driver->ops) +/** +* p2sb_set_hide() - Set/clear the 'hide' bit on the p2sb +* +* This device can be hidden from the PCI bus if needed. This method +* can be called before the p2sb is probed. +* +* @dev: P2SB device +* @hide: true to hide the device, false to show it +* @return 0 if OK, -ve on error +*/ +int p2sb_set_hide (struct udevice *dev,bool hide); +/** * pcr_read32/16/8() - Read from a PCR device *
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 58/108 x86: apl: Support set_hide() in p2sb driver
In reply to Simon GlassAdd support for this new method in the driver and in the fsp-s setup.
---
arch/x86/cpu/apollolake/fsp_s.c | 27 ++++++++++----------------- arch/x86/cpu/apollolake/p2sb.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 17 deletions(-)
arch/x86/cpu/apollolake/fsp_s.c +10 -17
@@ -9,6 +9,7 @@#include <binman.h> #include <dm.h> #include <irq.h> +#include <p2sb.h> #include <asm/intel_pinctrl.h> #include <asm/io.h> #include <asm/intel_regs.h>
@@ -19,9 +20,7 @@#include <asm/arch/systemagent.h> #include <asm/arch/fsp/fsp_configs.h> #include <asm/arch/fsp/fsp_s_upd.h> - -#define PCH_P2SB_E0 0xe0 -#define HIDE_BIT BIT(0) +#include <dm/uclass-internal.h> #define INTEL_GSPI_MAX 3#define MAX_USB2_PORTS 8
@@ -433,12 +432,6 @@ int fsps_update_config(struct udevice *dev, ulong rom_offset,return 0 ; } -static void p2sb_set_hide_bit (pci_dev_t dev,int hide) -{ -pci_x86_clrset_config (dev,PCH_P2SB_E0 +1 ,HIDE_BIT , - hide ?HIDE_BIT :0 ,PCI_SIZE_8 ); -} -/* Configure package power limits */ static int set_power_limits (struct udevice *dev) {
@@ -511,15 +504,15 @@ static int set_power_limits(struct udevice *dev)int p2sb_unhide (void ) { -pci_dev_t dev =PCI_BDF (0 ,0xd ,0 ); -ulong val; - -p2sb_set_hide_bit (dev,0 ); - -pci_x86_read_config (dev,PCI_VENDOR_ID , &val,PCI_SIZE_16 ); +struct udevice *dev; +int ret; -if (val !=PCI_VENDOR_ID_INTEL ) -return log_msg_ret ("p2sb unhide" , -EIO ); + ret =uclass_find_first_device (UCLASS_P2SB , &dev); +if (ret) +return log_msg_ret ("p2sb" , ret); + ret =p2sb_set_hide (dev, false); +if (ret) +return log_msg_ret ("hide" , ret);return 0 ; }
arch/x86/cpu/apollolake/p2sb.c +30 -0
@@ -14,6 +14,9 @@#include <spl.h> #include <asm/pci.h> +#define PCH_P2SB_E0 0xe0 +#define HIDE_BIT BIT(0) +struct p2sb_platdata {#if CONFIG_IS_ENABLED (OF_PLATDATA )struct dtd_intel_apl_p2sb dtplat;
@@ -125,6 +128,29 @@ static int apl_p2sb_probe(struct udevice *dev)return 0 ; } +static void p2sb_set_hide_bit (struct udevice *dev,bool hide) +{ +dm_pci_clrset_config8 (dev,PCH_P2SB_E0 +1 ,HIDE_BIT , + hide ?HIDE_BIT :0 ); +} + +static int apl_p2sb_set_hide (struct udevice *dev,bool hide) +{ +u16 vendor; + +if (!CONFIG_IS_ENABLED (PCI )) +return -EPERM ; +p2sb_set_hide_bit (dev, hide); + +dm_pci_read_config16 (dev,PCI_VENDOR_ID , &vendor); +if (hide && vendor !=0xffff ) +return log_msg_ret ("hide" , -EEXIST ); +else if (!hide && vendor !=PCI_VENDOR_ID_INTEL ) +return log_msg_ret ("unhide" , -ENOMEDIUM ); + +return 0 ; +} +static int p2sb_child_post_bind (struct udevice *dev) {#if !CONFIG_IS_ENABLED (OF_PLATDATA )
@@ -141,6 +167,10 @@ static int p2sb_child_post_bind(struct udevice *dev)return 0 ; } +struct p2sb_ops apl_p2sb_ops = { + .set_hide = apl_p2sb_set_hide, +}; +static const struct udevice_id apl_p2sb_ids[] = { { .compatible ="intel,apl-p2sb" }, { }
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 59/108 x86: apl: Hide the p2sb on exit from U-Boot
In reply to Simon GlassThis confuses Linux's PCI probing so needs to be hidden when booting Linux. Add a remove() method to handle this.
---
arch/x86/cpu/apollolake/p2sb.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
arch/x86/cpu/apollolake/p2sb.c +14 -0
@@ -151,6 +151,17 @@ static int apl_p2sb_set_hide(struct udevice *dev, bool hide)return 0 ; } +static int apl_p2sb_remove (struct udevice *dev) +{ +int ret; + + ret =apl_p2sb_set_hide (dev, true); +if (ret) +return log_msg_ret ("hide" , ret); + +return 0 ; +} +static int p2sb_child_post_bind (struct udevice *dev) {#if !CONFIG_IS_ENABLED (OF_PLATDATA )
@@ -181,9 +192,12 @@ U_BOOT_DRIVER(apl_p2sb_drv) = { .id = UCLASS_P2SB, .of_match = apl_p2sb_ids, .probe = apl_p2sb_probe, + .remove = apl_p2sb_remove, + .ops = &apl_p2sb_ops, .ofdata_to_platdata = apl_p2sb_ofdata_to_platdata, .platdata_auto_alloc_size = sizeof(struct p2sb_platdata), .per_child_platdata_auto_alloc_size = sizeof(struct p2sb_child_platdata), .child_post_bind = p2sb_child_post_bind, + .flags = DM_FLAG_OS_PREPARE, };
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 60/108 pmc: Move common registers to the header file
In reply to Simon GlassThese registers need to be accesses from ACPI code, so move them to the header file.
---
drivers/power/acpi_pmc/acpi-pmc-uclass.c | 9 --------- include/power/acpi_pmc.h | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 9 deletions(-)
drivers/power/acpi_pmc/acpi-pmc-uclass.c +0 -9
@@ -15,15 +15,6 @@#include <asm/io.h> #include <power/acpi_pmc.h> -enum { -PM1_STS =0x00 , -PM1_EN =0x02 , -PM1_CNT =0x04 , - -GPE0_STS =0x20 , -GPE0_EN =0x30 , -}; -struct tco_regs {u32 tco_rld;u32 tco_sts;
include/power/acpi_pmc.h +14 -0
@@ -6,10 +6,22 @@#ifndef __ACPI_PMC_H#define __ACPI_PMC_H +#ifndef __ACPI__ +enum {GPE0_REG_MAX =4 , }; +enum { +PM1_STS =0x00 , +PM1_EN =0x02 , +PM1_CNT =0x04 , +PM1_TMR =0x08 , + +GPE0_STS =0x20 , +GPE0_EN =0x30 , +}; +/** * struct acpi_pmc_upriv - holds common data for the x86 PMC *
@@ -182,4 +194,6 @@ void pmc_dump_info(struct udevice *dev);*/ int pmc_gpe_init (struct udevice *dev); +#endif /* !__ACPI__ */ +#endif
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 61/108 x86: irq: Support flags for acpi_gpe
In reply to Simon GlassThis binding currently has a flags cell but it is not used. Make use of it to create ACPI tables for interrupts.
---
arch/x86/cpu/acpi_gpe.c | 22 +++++++++++++++++++ .../interrupt-controller/x86-irq.h | 14 ++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 include/dt-bindings/interrupt-controller/x86-irq.h
arch/x86/cpu/acpi_gpe.c +22 -0
@@ -5,9 +5,12 @@*/ #include <common.h> +#include <acpi_device.h> #include <dm.h> #include <irq.h> #include <asm/io.h> +#include <dt-bindings/interrupt-controller/irq.h> +#include <dt-bindings/interrupt-controller/x86-irq.h> struct acpi_gpe_priv {ulong acpi_base;
@@ -56,6 +59,24 @@ static int acpi_gpe_ofdata_to_platdata(struct udevice *dev)static int acpi_gpe_of_xlate (struct irq *irq,struct ofnode_phandle_args *args) { irq->id = args->args[0 ]; + irq->flags = args->args[1 ]; + +return 0 ; +} + +static int acpi_gpe_get_acpi (const struct irq *irq,struct acpi_irq *acpi_irq) +{ +memset (acpi_irq,'\0' ,sizeof (*acpi_irq)); + acpi_irq->pin = irq->id; + acpi_irq->mode = irq->flags &IRQ_TYPE_EDGE_BOTH ? +ACPI_IRQ_EDGE_TRIGGERED :ACPI_IRQ_LEVEL_TRIGGERED ; + acpi_irq->polarity = irq->flags & + (IRQ_TYPE_EDGE_FALLING |IRQ_TYPE_LEVEL_LOW ) ? +ACPI_IRQ_ACTIVE_LOW :ACPI_IRQ_ACTIVE_HIGH ; + acpi_irq->shared = irq->flags &X86_IRQ_TYPE_SHARED ? +ACPI_IRQ_SHARED :ACPI_IRQ_EXCLUSIVE ; + acpi_irq->wake = irq->flags &X86_IRQ_TYPE_WAKE ?ACPI_IRQ_WAKE : +ACPI_IRQ_NO_WAKE ;return 0 ; }
@@ -63,6 +84,7 @@ static int acpi_gpe_of_xlate(struct irq *irq, struct ofnode_phandle_args *args)static const struct irq_ops acpi_gpe_ops = { .read_and_clear = acpi_gpe_read_and_clear, .of_xlate = acpi_gpe_of_xlate, + .get_acpi = acpi_gpe_get_acpi, };static const struct udevice_id acpi_gpe_ids[] = {
include/dt-bindings/interrupt-controller/x86-irq.h new file +14 -0
@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright 2019 Google LLC +* +* This provides additional flags used by x86. +*/ + +#ifndef _DT_BINDINGS_INTERRUPT_CONTROLLER_X86_IRQ_H +#define _DT_BINDINGS_INTERRUPT_CONTROLLER_X86_IRQ_H + +#define X86_IRQ_TYPE_SHARED (1 << 4) +#define X86_IRQ_TYPE_WAKE (1 << 5) + +#endif
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 62/108 x86: Add debugging to table writing
In reply to Simon GlassWriting tables is currently pretty opaque. Add a bit of debugging to the process so we can see what tables are written and where they start/end in memory.
---
arch/x86/lib/tables.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-)
arch/x86/lib/tables.c +26 -9
@@ -19,21 +19,32 @@*/ typedef ulong (*table_write )(ulong addr); -static table_write table_write_funcs[] = { +/** +* struct table_info - Information about each table to write +* +* @name: Name of table (for debugging) +* @write: Function to call to write this table +*/ +struct table_info { +const char *name; +table_write write; +}; + +static struct table_info table_list[] = { #ifdef CONFIG_GENERATE_PIRQ_TABLE - write_pirq_routing_table, + { "pirq", write_pirq_routing_table }, #endif #ifdef CONFIG_GENERATE_SFI_TABLE - write_sfi_table, + { "sfi", write_sfi_table, }, #endif #ifdef CONFIG_GENERATE_MP_TABLE - write_mp_table, + { "mp", write_mp_table, }, #endif #ifdef CONFIG_GENERATE_ACPI_TABLE - write_acpi_tables, + { "acpi", write_acpi_tables, }, #endif #ifdef CONFIG_GENERATE_SMBIOS_TABLE - write_smbios_table, + { "smbios", write_smbios_table, }, #endif };
@@ -61,15 +72,18 @@ void write_tables(void)#endif int i; -for (i =0 ; i <ARRAY_SIZE (table_write_funcs); i++) { - rom_table_end = table_write_funcs[i](rom_table_start); +debug ("Writing tables to %x:\n" , rom_table_start); +for (i =0 ; i <ARRAY_SIZE (table_list); i++) { +const struct table_info *table = &table_list[i]; + + rom_table_end = table->write (rom_table_start); rom_table_end =ALIGN (rom_table_end,ROM_TABLE_ALIGN );#ifdef CONFIG_SEABIOS table_size = rom_table_end - rom_table_start; high_table = (u32 )high_table_malloc (table_size);if (high_table) { - table_write_funcs[i](high_table); + table->write (high_table); cfg_tables[i].start = high_table; cfg_tables[i].size = table_size;
@@ -78,6 +92,8 @@ void write_tables(void) }#endif +debug ("- wrote '%s' to %x, end %x\n" , table->name, + rom_table_start, rom_table_end); rom_table_start = rom_table_end; }
@@ -86,4 +102,5 @@ void write_tables(void) cfg_tables[i].size =0 ;write_coreboot_table (CB_TABLE_ADDR , cfg_tables);#endif +debug ("- done writing tables\n" ); }
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 63/108 x86: Rename board_final_cleanup() to board_final_init()
In reply to Simon GlassThis function sounds like something that is called when U-Boot is about to jump to Linux. In fact it is an init function.
Rename it to reduce confusion.
---
arch/x86/cpu/coreboot/coreboot.c | 4 ++-- arch/x86/cpu/cpu.c | 8 ++++---- arch/x86/cpu/efi/app.c | 2 +- arch/x86/cpu/quark/quark.c | 2 +- arch/x86/lib/fsp/fsp_common.c | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-)
arch/x86/cpu/coreboot/coreboot.c +2 -2
@@ -40,7 +40,7 @@ int print_cpuinfo(void)return default_print_cpuinfo (); } -static void board_final_cleanup (void ) +static void board_final_init (void ) {/* * Un-cache the ROM so the kernel has one
@@ -78,7 +78,7 @@ int last_stage_init(void)if (CONFIG_IS_ENABLED (USB_KEYBOARD ))usb_init (); -board_final_cleanup (); +board_final_init ();return 0 ; }
arch/x86/cpu/cpu.c +4 -4
@@ -175,10 +175,10 @@ void show_boot_progress(int val)#if !defined(CONFIG_SYS_COREBOOT ) && !defined(CONFIG_EFI_STUB )/* -* Implement a weak default function for boards that optionally -* need to clean up the system before jumping to the kernel. +* Implement a weak default function for boards that need to do some final init +* before the system is ready. */ -__weak void board_final_cleanup (void ) +__weak void board_final_init (void ) { }
@@ -186,7 +186,7 @@ int last_stage_init(void) {struct acpi_fadt __maybe_unused *fadt; -board_final_cleanup (); +board_final_init ();#ifdef CONFIG_HAVE_ACPI_RESUME fadt =acpi_find_fadt ();
arch/x86/cpu/efi/app.c +1 -1
@@ -23,7 +23,7 @@ int print_cpuinfo(void)return default_print_cpuinfo (); } -void board_final_cleanup (void ) +void board_final_init (void ) { }
arch/x86/cpu/quark/quark.c +1 -1
@@ -360,7 +360,7 @@ int arch_misc_init(void)return 0 ; } -void board_final_cleanup (void ) +void board_final_init (void ) {struct quark_rcba *rcba;u32 base, val;
arch/x86/lib/fsp/fsp_common.c +1 -1
@@ -45,7 +45,7 @@ int fsp_init_phase_pci(void)return status ? -EPERM :0 ; } -void board_final_cleanup (void ) +void board_final_init (void ) {u32 status;
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 64/108 acpi: Enable ACPI table generation by default on x86
In reply to Simon GlassThis should ideally be used by all x86 boards in U-Boot. Enable it by default. If some boards don't use it, the cost is small.
---
arch/Kconfig | 1 + 1 file changed, 1 insertion(+)
arch/Kconfig +1 -0
@@ -187,6 +187,7 @@ config X86 imply PCH imply RTC_MC146818 imply IRQ + imply ACPIGEN # Thing to enable for when SPL/TPL are enabled: SPL imply SPL_DM
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 65/108 acpi: Add cros_ec tables
In reply to Simon GlassAdd ASL files for the Chrome OS EC, taken from coreboot.
---
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
@@ -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
@@ -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
@@ -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.25.0.341.g760bfbb309-goog
PATCH 66/108 x86: acpi: Add base asl files for common x86 devices
In reply to Simon GlassAdd common x86 ASL files, taken from coreboot.
---
arch/x86/include/asm/acpi/chromeos.asl | 110 +++++++++++++++++ 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, 445 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 +110 -0
@@ -0,0 +1,110 @@ +/* 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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.25.0.341.g760bfbb309-goog
PATCH 67/108 x86: acpi: apl: Add asl files for Apollo Lake
In reply to Simon GlassAdd Apollo Lake ASL files, taken from coreboot.
---
.../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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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.25.0.341.g760bfbb309-goog
PATCH 68/108 x86: acpi: Add DPTF asl files
In reply to Simon GlassAdd common DPTF (Intel Dynamic Performance and Thermal Framework) files, taken from coreboot.
---
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
@@ -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.25.0.341.g760bfbb309-goog
PATCH 69/108 x86: apl: Correct PCIE_ECAM_BASE
In reply to Simon GlassThis value is incorrect and causes problems booting Linux. Fix it.
---
board/google/chromebook_coral/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
board/google/chromebook_coral/Kconfig +1 -1
@@ -22,7 +22,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.25.0.341.g760bfbb309-goog
PATCH 70/108 x86: coral: Add ACPI tables for coral
In reply to Simon GlassThis device has a large set of ACPI tables. Bring these in from coreboot so that full functionality is available (apart from SMI).
---
board/google/chromebook_coral/Makefile | 1 + .../chromebook_coral/baseboard_dptf.asl | 71 ++++++++++++ board/google/chromebook_coral/coral.c | 104 ++++++++++++++++++ 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 +++++++++++ 7 files changed, 380 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
@@ -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 +104 -0
113 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
@@ -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
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 71/108 x86: acpi: Support external GNVS tables
In reply to Simon GlassAt present U-Boot puts a magic number in the ASL for the GNVS table and searches for 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.
---
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 | 47 ++++++++++++++------------ 4 files changed, 36 insertions(+), 22 deletions(-)
arch/x86/Kconfig +7 -0
@@ -755,6 +755,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
@@ -15,6 +15,7 @@ config INTEL_APOLLOLAKE select TPL_PCH_SUPPORT select PCH_SUPPORT select P2SB + select ACPI_GNVS_EXTERNAL imply ENABLE_MRC_CACHE imply AHCI_PCI imply SCSI
arch/x86/include/asm/acpi/global_nvs.h +3 -0
@@ -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 +25 -22
56 lines not on this page · raw message
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 72/108 x86: acpi: Expand the GNVS
In reply to Simon GlassExpand this to 4KB so that it is possible to add custom information to it. On Chromebooks this is used to pass verified-boot information.
---
arch/x86/include/asm/acpi/global_nvs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/acpi/global_nvs.h +1 -1
@@ -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_ */
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 73/108 x86: Add wake sources for the acpi_gpe driver
In reply to Simon GlassSome 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.
---
arch/x86/include/asm/arch-apollolake/gpe.h | 134 ++++++++++++++++++++ arch/x86/include/asm/arch-apollolake/gpio.h | 3 + doc/device-tree-bindings/device.txt | 4 + 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 +134 -0
@@ -0,0 +1,134 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright 2016 Intel Corporation. +* +* Taken from coreboot apl gpe.h +*/ + +#ifndef _SOC_GPE_H_ +#define _SOC_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 +#define GPE0A_ESPI_SCI_STS 20/* Present in GLK */ + +/* 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
@@ -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 +4 -0
@@ -23,6 +23,8 @@ U-Boot provides for some optional properties which are documented here. - 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 Example
@@ -36,6 +38,7 @@ synaptics_touchpad: synaptics-touchpad at 2c { acpi,desc = "Synaptics Touchpad"; interrupts-extended = <&acpi_gpe GPIO_18_IRQ IRQ_TYPE_EDGE_FALLING>; + acpi,wake = <GPE0_DW1_15>; acpi,probed; acpi,hid-desc-reg-offset = <0x20>; };
@@ -47,6 +50,7 @@ pcie-a0 at 14,0 { compatible = "intel,generic-wifi"; acpi,desc = "Intel WiFi"; acpi,name = "WF00"; + acpi,wake = <GPE0_DW3_00>; interrupts-extended = <&acpi_gpe 0x3c 0>; }; };
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 74/108 x86: Add a config for the systemagent PCIEX regions size
In reply to Simon GlassAdd a way to specify the required size for this region. This is used when generating ACPI tables.
---
arch/x86/Kconfig | 18 ++++++++++++++++++ arch/x86/cpu/apollolake/Kconfig | 1 + 2 files changed, 19 insertions(+)
arch/x86/Kconfig +18 -0
@@ -950,4 +950,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
@@ -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 ACPI_GNVS_EXTERNAL
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 75/108 x86: apl: Support writing the IntelGraphicsMem table
In reply to Simon GlassThis table is needed by the Linux graphics driver to handle graphics correctly. Write it to ACPI.
---
arch/x86/Kconfig | 8 + arch/x86/cpu/apollolake/Kconfig | 1 + arch/x86/cpu/intel_common/Makefile | 2 + arch/x86/cpu/intel_common/intel_opregion.c | 168 ++++++++++++++ arch/x86/include/asm/intel_opregion.h | 247 +++++++++++++++++++++ arch/x86/lib/fsp/fsp_graphics.c | 28 +++ include/bloblist.h | 1 + 7 files changed, 455 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
@@ -968,4 +968,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
@@ -45,6 +45,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 +2 -0
@@ -9,6 +9,8 @@ obj-$(CONFIG_$(SPL_TPL_)X86_32BIT_INIT) += report_platform.o obj-$(CONFIG_$(SPL_TPL_)X86_32BIT_INIT) += mrc.o endif +obj-$(CONFIG_INTEL_GMA_ACPI) += intel_opregion.o + 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 +28 -0
@@ -3,12 +3,17 @@* Copyright (C) 2017, Bin Meng <[email protected]> */ +#define LOG_CATEGORY UCLASS_VIDEO +#include <common.h> +#include <acpi_table.h> #include <dm.h> #include <vbe.h> #include <video.h> #include <asm/fsp/fsp_support.h> +#include <asm/intel_opregion.h> #include <asm/mtrr.h> +#include <dm/acpi.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -114,6 +119,28 @@ err:return ret; } +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 ; +} + +struct acpi_ops fsp_video_acpi_ops = { + .write_tables = fsp_video_acpi_write_tables, +}; +static const struct udevice_id fsp_video_ids[] = { { .compatible ="fsp-fb" }, { }
@@ -124,6 +151,7 @@ U_BOOT_DRIVER(fsp_video) = { .id = UCLASS_VIDEO, .of_match = fsp_video_ids, .probe = fsp_video_probe, + acpi_ops_ptr(&fsp_video_acpi_ops) };static struct pci_device_id fsp_video_supported[] = {
include/bloblist.h +1 -0
@@ -27,6 +27,7 @@ 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 */ + BLOBLISTT_INTEL_VBT, /* Intel Video-BIOS table */ };/**
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 76/108 x86: acpi: Add a common routine to write WiFi info
In reply to Simon GlassIntel WiFi chips can use a common routine to write the information needed by linux. Add an implementation of this.
Enable it for coral.
---
arch/x86/Kconfig | 8 ++ arch/x86/cpu/intel_common/Makefile | 1 + arch/x86/cpu/intel_common/generic_wifi.c | 119 +++++++++++++++++++++++ configs/chromebook_coral_defconfig | 3 +- 4 files changed, 129 insertions(+), 2 deletions(-) create mode 100644 arch/x86/cpu/intel_common/generic_wifi.c
arch/x86/Kconfig +8 -0
@@ -976,4 +976,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
@@ -22,6 +22,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 +119 -0
119 lines not on this page · raw message
configs/chromebook_coral_defconfig +1 -2
@@ -15,6 +15,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_SPL_TEXT_BASE=0xfef10000 CONFIG_BOOTSTAGE=y CONFIG_SPL_BOOTSTAGE=y
@@ -41,7 +42,6 @@ CONFIG_SPL_PCI=y CONFIG_HUSH_PARSER=y CONFIG_CMD_CPU=y CONFIG_CMD_PMC=y -# CONFIG_CMD_FLASH is not set CONFIG_CMD_GPIO=y CONFIG_CMD_I2C=y CONFIG_CMD_PART=y
@@ -89,7 +89,6 @@ CONFIG_SOUND_RT5677=y CONFIG_SPI=y CONFIG_ICH_SPI=y CONFIG_TPL_SYSRESET=y -CONFIG_TPM_TIS_LPC=y # CONFIG_TPM_V1 is not set CONFIG_TPM2_CR50_I2C=y CONFIG_USB_XHCI_HCD=y
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 77/108 x86: Add some definitions for SMM
In reply to Simon GlassU-Boot does not support SMM (System Management Mode) at present, but needs a few definitions to correctly set up the ACPI table. Add these.
---
arch/x86/include/asm/smm.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 arch/x86/include/asm/smm.h
arch/x86/include/asm/smm.h new file +36 -0
@@ -0,0 +1,36 @@ +/* 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 CPU_X86_SMM_H +#define CPU_X86_SMM_H + +#define SMM_DEFAULT_BASE 0x30000 +#define SMM_DEFAULT_SIZE 0x10000 + +/* used only by C programs so far */ +#define SMM_BASE 0xa0000 + +#define SMM_ENTRY_OFFSET 0x8000 +#define SMM_SAVE_STATE_BEGIN (x) (SMM_ENTRY_OFFSET + (x)) + +#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 /* CPU_X86_SMM_H */
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 78/108 x86: apl: Add power-management definitions
In reply to Simon GlassAdd SCI and power-state definitions required by ACPI tables.
Update the guard on acpi_pmc.h to avoid an error when buiding ASL.
---
arch/x86/include/asm/arch-apollolake/pm.h | 56 +++++++++++++++++++---- include/power/acpi_pmc.h | 4 +- 2 files changed, 49 insertions(+), 11 deletions(-)
arch/x86/include/asm/arch-apollolake/pm.h +47 -9
@@ -1,19 +1,57 @@ -/* 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 -#define PMC_GPE_SW_31_0 0 -#define PMC_GPE_SW_63_32 1 -#define PMC_GPE_NW_31_0 3 -#define PMC_GPE_NW_63_32 4 -#define PMC_GPE_NW_95_64 5 -#define PMC_GPE_N_31_0 6 -#define PMC_GPE_N_63_32 7 -#define PMC_GPE_W_31_0 9 +#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 +#define PMC_GPE_NW_63_32 4 +#define PMC_GPE_NW_95_64 5 +#define PMC_GPE_N_31_0 6 +#define PMC_GPE_N_63_32 7 +#define PMC_GPE_W_31_0 9 + +#define IRQ_REG 0x106C +#define SCI_IRQ_ADJUST 24 +#define SCI_IRQ_SEL (255 << SCI_IRQ_ADJUST) +#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
@@ -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.25.0.341.g760bfbb309-goog
PATCH 79/108 x86: Add a common global NVS structure
In reply to Simon GlassAdd the definition of this structure common to Intel devices. It includes some optional Chrome OS pieces which are used when vboot is integrated.
---
arch/x86/include/asm/intel_gnvs.h | 43 +++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 arch/x86/include/asm/intel_gnvs.h
arch/x86/include/asm/intel_gnvs.h new file +43 -0
@@ -0,0 +1,43 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) 2019 Intel Corporation. +* +* Taken from coreboot intelblocks/nvs.h +* Copyright 2019 Google LLC +*/ + +#ifndef _INTEL_GNVS_H_ +#define _INTEL_GNVS_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 - coreboot Memory 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 unused[195 ]; +#ifdef CONFIG_CHROMEOS +/* ChromeOS specific (0x100 - 0xfff) */ +struct chromeos_acpi chromeos; +#else +u8 unused2[0xf00 ]; +#endif +}; +#ifdef CONFIG_CHROMEOS +check_member (acpi_global_nvs, chromeos,GNVS_CHROMEOS_ACPI_OFFSET ); +#endif + +#endif /* _INTEL_GNVS_H_ */
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 80/108 cpu: Convert the methods to use a const udevice *
In reply to Simon GlassThese functions should not modify the device. Convert them to const so that callers don't need to cast if they have a const udevice *.
---
arch/nios2/cpu/cpu.c | 8 +++++--- arch/x86/cpu/apollolake/cpu.c | 4 ++-- arch/x86/cpu/baytrail/cpu.c | 4 ++-- arch/x86/cpu/broadwell/cpu_full.c | 4 ++-- arch/x86/cpu/cpu_x86.c | 6 +++--- arch/x86/cpu/ivybridge/model_206ax.c | 5 +++-- arch/x86/cpu/qemu/cpu.c | 4 ++-- arch/x86/include/asm/cpu_x86.h | 4 ++-- drivers/cpu/bmips_cpu.c | 8 ++++---- drivers/cpu/cpu-uclass.c | 8 ++++---- drivers/cpu/cpu_sandbox.c | 8 ++++---- drivers/cpu/imx8_cpu.c | 8 ++++---- drivers/cpu/mpc83xx_cpu.c | 17 +++++++++-------- drivers/cpu/riscv_cpu.c | 6 +++--- include/cpu.h | 16 ++++++++-------- 15 files changed, 57 insertions(+), 53 deletions(-)
arch/nios2/cpu/cpu.c +5 -3
@@ -76,7 +76,8 @@ int arch_cpu_init_dm(void)return 0 ; } -static int altera_nios2_get_desc (struct udevice *dev,char *buf,int size) +static int altera_nios2_get_desc (const struct udevice *dev,char *buf, +int size) {const char *cpu_name ="Nios-II" ;
@@ -87,7 +88,8 @@ static int altera_nios2_get_desc(struct udevice *dev, char *buf, int size)return 0 ; } -static int altera_nios2_get_info (struct udevice *dev,struct cpu_info *info) +static int altera_nios2_get_info (const struct udevice *dev, +struct cpu_info *info) { info->cpu_freq = gd->cpu_clk; info->features = (1 << CPU_FEAT_L1_CACHE) |
@@ -96,7 +98,7 @@ static int altera_nios2_get_info(struct udevice *dev, struct cpu_info *info)return 0 ; } -static int altera_nios2_get_count (struct udevice *dev) +static int altera_nios2_get_count (const struct udevice *dev) {return 1 ; }
arch/x86/cpu/apollolake/cpu.c +2 -2
@@ -9,12 +9,12 @@#include <asm/cpu_common.h> #include <asm/cpu_x86.h> -static int apl_get_info (struct udevice *dev,struct cpu_info *info) +static int apl_get_info (const struct udevice *dev,struct cpu_info *info) {return cpu_intel_get_info (info,INTEL_BCLK_MHZ ); } -static int apl_get_count (struct udevice *dev) +static int apl_get_count (const struct udevice *dev) {return 4 ; }
arch/x86/cpu/baytrail/cpu.c +2 -2
@@ -148,7 +148,7 @@ static unsigned long tsc_freq(void)return bclk * ((platform_info.lo >>8 ) &0xff ); } -static int baytrail_get_info (struct udevice *dev,struct cpu_info *info) +static int baytrail_get_info (const struct udevice *dev,struct cpu_info *info) { info->cpu_freq =tsc_freq (); info->features =1 <<CPU_FEAT_L1_CACHE |1 <<CPU_FEAT_MMU ;
@@ -156,7 +156,7 @@ static int baytrail_get_info(struct udevice *dev, struct cpu_info *info)return 0 ; } -static int baytrail_get_count (struct udevice *dev) +static int baytrail_get_count (const struct udevice *dev) {int ecx =0 ;
arch/x86/cpu/broadwell/cpu_full.c +2 -2
@@ -623,12 +623,12 @@ void cpu_set_power_limits(int power_limit_1_time) } } -static int broadwell_get_info (struct udevice *dev,struct cpu_info *info) +static int broadwell_get_info (const struct udevice *dev,struct cpu_info *info) {return cpu_intel_get_info (info,INTEL_BCLK_MHZ ); } -static int broadwell_get_count (struct udevice *dev) +static int broadwell_get_count (const struct udevice *dev) {return 4 ; }
arch/x86/cpu/cpu_x86.c +3 -3
@@ -26,7 +26,7 @@ int cpu_x86_bind(struct udevice *dev)return 0 ; } -int cpu_x86_get_vendor (struct udevice *dev,char *buf,int size) +int cpu_x86_get_vendor (const struct udevice *dev,char *buf,int size) {const char *vendor =cpu_vendor_name (gd->arch.x86_vendor);
@@ -38,7 +38,7 @@ int cpu_x86_get_vendor(struct udevice *dev, char *buf, int size)return 0 ; } -int cpu_x86_get_desc (struct udevice *dev,char *buf,int size) +int cpu_x86_get_desc (const struct udevice *dev,char *buf,int size) {char *ptr;
@@ -52,7 +52,7 @@ int cpu_x86_get_desc(struct udevice *dev, char *buf, int size)return 0 ; } -static int cpu_x86_get_count (struct udevice *dev) +static int cpu_x86_get_count (const struct udevice *dev) {int node, cpu;int num =0 ;
arch/x86/cpu/ivybridge/model_206ax.c +3 -2
@@ -409,14 +409,15 @@ static int model_206ax_init(struct udevice *dev)return 0 ; } -static int model_206ax_get_info (struct udevice *dev,struct cpu_info *info) +static int model_206ax_get_info (const struct udevice *dev, +struct cpu_info *info) {return cpu_intel_get_info (info,INTEL_BCLK_MHZ );return 0 ; } -static int model_206ax_get_count (struct udevice *dev) +static int model_206ax_get_count (const struct udevice *dev) {return 4 ; }
arch/x86/cpu/qemu/cpu.c +2 -2
@@ -10,7 +10,7 @@#include <qfw.h> #include <asm/cpu.h> -int cpu_qemu_get_desc (struct udevice *dev,char *buf,int size) +int cpu_qemu_get_desc (const struct udevice *dev,char *buf,int size) {if (size <CPU_MAX_NAME_LEN )return -ENOSPC ;
@@ -20,7 +20,7 @@ int cpu_qemu_get_desc(struct udevice *dev, char *buf, int size)return 0 ; } -static int cpu_qemu_get_count (struct udevice *dev) +static int cpu_qemu_get_count (const struct udevice *dev) {return qemu_fwcfg_online_cpus (); }
arch/x86/include/asm/cpu_x86.h +2 -2
@@ -28,7 +28,7 @@ int cpu_x86_bind(struct udevice *dev);* @size: Size of string space * @return: 0 if OK, -ENOSPC if buffer is too small, other -ve on error */ -int cpu_x86_get_desc (struct udevice *dev,char *buf,int size); +int cpu_x86_get_desc (const struct udevice *dev,char *buf,int size);/** * cpu_x86_get_vendor() - Get a vendor string for an x86 CPU
@@ -41,6 +41,6 @@ int cpu_x86_get_desc(struct udevice *dev, char *buf, int size);* @size: Size of string space * @return: 0 if OK, -ENOSPC if buffer is too small, other -ve on error */ -int cpu_x86_get_vendor (struct udevice *dev,char *buf,int size); +int cpu_x86_get_vendor (const struct udevice *dev,char *buf,int size);#endif /* _ASM_CPU_X86_H */
drivers/cpu/bmips_cpu.c +4 -4
@@ -377,7 +377,7 @@ static const struct bmips_cpu_hw bmips_cpu_bcm6838 = { };/* Generic CPU Ops */ -static int bmips_cpu_get_desc (struct udevice *dev,char *buf,int size) +static int bmips_cpu_get_desc (const struct udevice *dev,char *buf,int size) {struct bmips_cpu_priv *priv =dev_get_priv (dev);const struct bmips_cpu_hw *hw = priv->hw;
@@ -385,7 +385,7 @@ static int bmips_cpu_get_desc(struct udevice *dev, char *buf, int size)return hw->get_cpu_desc (priv, buf, size); } -static int bmips_cpu_get_info (struct udevice *dev,struct cpu_info *info) +static int bmips_cpu_get_info (const struct udevice *dev,struct cpu_info *info) {struct bmips_cpu_priv *priv =dev_get_priv (dev);const struct bmips_cpu_hw *hw = priv->hw;
@@ -398,7 +398,7 @@ static int bmips_cpu_get_info(struct udevice *dev, struct cpu_info *info)return 0 ; } -static int bmips_cpu_get_count (struct udevice *dev) +static int bmips_cpu_get_count (const struct udevice *dev) {struct bmips_cpu_priv *priv =dev_get_priv (dev);const struct bmips_cpu_hw *hw = priv->hw;
@@ -406,7 +406,7 @@ static int bmips_cpu_get_count(struct udevice *dev)return hw->get_cpu_count (priv); } -static int bmips_cpu_get_vendor (struct udevice *dev,char *buf,int size) +static int bmips_cpu_get_vendor (const struct udevice *dev,char *buf,int size) {snprintf (buf, size,"Broadcom" );
drivers/cpu/cpu-uclass.c +4 -4
@@ -34,7 +34,7 @@ int cpu_probe_all(void)return 0 ; } -int cpu_get_desc (struct udevice *dev,char *buf,int size) +int cpu_get_desc (const struct udevice *dev,char *buf,int size) {struct cpu_ops *ops =cpu_get_ops (dev);
@@ -44,7 +44,7 @@ int cpu_get_desc(struct udevice *dev, char *buf, int size)return ops->get_desc (dev, buf, size); } -int cpu_get_info (struct udevice *dev,struct cpu_info *info) +int cpu_get_info (const struct udevice *dev,struct cpu_info *info) {struct cpu_ops *ops =cpu_get_ops (dev);
@@ -54,7 +54,7 @@ int cpu_get_info(struct udevice *dev, struct cpu_info *info)return ops->get_info (dev, info); } -int cpu_get_count (struct udevice *dev) +int cpu_get_count (const struct udevice *dev) {struct cpu_ops *ops =cpu_get_ops (dev);
@@ -64,7 +64,7 @@ int cpu_get_count(struct udevice *dev)return ops->get_count (dev); } -int cpu_get_vendor (struct udevice *dev,char *buf,int size) +int cpu_get_vendor (const struct udevice *dev,char *buf,int size) {struct cpu_ops *ops =cpu_get_ops (dev);
drivers/cpu/cpu_sandbox.c +4 -4
@@ -8,14 +8,14 @@#include <dm.h> #include <cpu.h> -int cpu_sandbox_get_desc (struct udevice *dev,char *buf,int size) +int cpu_sandbox_get_desc (const struct udevice *dev,char *buf,int size) {snprintf (buf, size,"LEG Inc. SuperMegaUltraTurbo CPU No. 1" );return 0 ; } -int cpu_sandbox_get_info (struct udevice *dev,struct cpu_info *info) +int cpu_sandbox_get_info (const struct udevice *dev,struct cpu_info *info) { info->cpu_freq =42 *42 *42 *42 *42 ; info->features =0x42424242 ;
@@ -24,12 +24,12 @@ int cpu_sandbox_get_info(struct udevice *dev, struct cpu_info *info)return 0 ; } -int cpu_sandbox_get_count (struct udevice *dev) +int cpu_sandbox_get_count (const struct udevice *dev) {return 42 ; } -int cpu_sandbox_get_vendor (struct udevice *dev,char *buf,int size) +int cpu_sandbox_get_vendor (const struct udevice *dev,char *buf,int size) {snprintf (buf, size,"Languid Example Garbage Inc." );
drivers/cpu/imx8_cpu.c +4 -4
@@ -85,7 +85,7 @@ static int cpu_imx_get_temp(void) }#endif -int cpu_imx_get_desc (struct udevice *dev,char *buf,int size) +int cpu_imx_get_desc (const struct udevice *dev,char *buf,int size) {struct cpu_imx_platdata *plat =dev_get_platdata (dev);int ret;
@@ -107,7 +107,7 @@ int cpu_imx_get_desc(struct udevice *dev, char *buf, int size)return 0 ; } -static int cpu_imx_get_info (struct udevice *dev,struct cpu_info *info) +static int cpu_imx_get_info (const struct udevice *dev,struct cpu_info *info) {struct cpu_imx_platdata *plat =dev_get_platdata (dev);
@@ -116,12 +116,12 @@ static int cpu_imx_get_info(struct udevice *dev, struct cpu_info *info)return 0 ; } -static int cpu_imx_get_count (struct udevice *dev) +static int cpu_imx_get_count (const struct udevice *dev) {return 4 ; } -static int cpu_imx_get_vendor (struct udevice *dev,char *buf,int size) +static int cpu_imx_get_vendor (const struct udevice *dev,char *buf,int size) {snprintf (buf, size,"NXP" );return 0 ;
drivers/cpu/mpc83xx_cpu.c +9 -8
@@ -58,7 +58,7 @@ static inline u32 get_spridr(void)* determine_type() - Determine CPU family of MPC83xx device * @dev: CPU device from which to read CPU family from */ -static inline void determine_family (struct udevice *dev) +static inline void determine_family (const struct udevice *dev) {struct mpc83xx_cpu_priv *priv =dev_get_priv (dev);/* Upper 12 bits of PARTID field (bits 0-23 in SPRIDR) */
@@ -93,7 +93,7 @@ static inline void determine_family(struct udevice *dev)* determine_type() - Determine CPU type of MPC83xx device * @dev: CPU device from which to read CPU type from */ -static inline void determine_type (struct udevice *dev) +static inline void determine_type (const struct udevice *dev) {struct mpc83xx_cpu_priv *priv =dev_get_priv (dev);/* Upper 16 bits of PVR (Processor Version Register) */
@@ -167,7 +167,7 @@ static inline void determine_type(struct udevice *dev)* determine_e300_type() - Determine e300 core type of MPC83xx device * @dev: CPU device from which to read e300 core type from */ -static inline void determine_e300_type (struct udevice *dev) +static inline void determine_e300_type (const struct udevice *dev) {struct mpc83xx_cpu_priv *priv =dev_get_priv (dev);/* Upper 16 bits of PVR (Processor Version Register) */
@@ -196,7 +196,7 @@ static inline void determine_e300_type(struct udevice *dev)* determine_revid() - Determine revision ID of CPU device * @dev: CPU device from which to read revision ID */ -static inline void determine_revid (struct udevice *dev) +static inline void determine_revid (const struct udevice *dev) {struct mpc83xx_cpu_priv *priv =dev_get_priv (dev);u32 REVID_MAJOR_MASK ;
@@ -219,7 +219,7 @@ static inline void determine_revid(struct udevice *dev)* determine_cpu_data() - Determine CPU information from hardware * @dev: CPU device from which to read information */ -static void determine_cpu_data (struct udevice *dev) +static void determine_cpu_data (const struct udevice *dev) {struct mpc83xx_cpu_priv *priv =dev_get_priv (dev);const u32 E_FLAG_MASK =0x00010000 ;
@@ -237,7 +237,7 @@ static void determine_cpu_data(struct udevice *dev) priv->is_e_processor = !bitfield_extract_by_mask (spridr,E_FLAG_MASK ); } -static int mpc83xx_cpu_get_desc (struct udevice *dev,char *buf,int size) +static int mpc83xx_cpu_get_desc (const struct udevice *dev,char *buf,int size) {struct mpc83xx_cpu_priv *priv =dev_get_priv (dev);struct clk core_clk;
@@ -301,13 +301,14 @@ static int mpc83xx_cpu_get_info(struct udevice *dev, struct cpu_info *info)return 0 ; } -static int mpc83xx_cpu_get_count (struct udevice *dev) +static int mpc83xx_cpu_get_count (const struct udevice *dev) {/* We have one e300cX core */ return 1 ; } -static int mpc83xx_cpu_get_vendor (struct udevice *dev,char *buf,int size) +static int mpc83xx_cpu_get_vendor (const struct udevice *dev,char *buf, +int size) {snprintf (buf, size,"NXP" );
drivers/cpu/riscv_cpu.c +3 -3
@@ -12,7 +12,7 @@DECLARE_GLOBAL_DATA_PTR ; -static int riscv_cpu_get_desc (struct udevice *dev,char *buf,int size) +static int riscv_cpu_get_desc (const struct udevice *dev,char *buf,int size) {const char *isa;
@@ -25,7 +25,7 @@ static int riscv_cpu_get_desc(struct udevice *dev, char *buf, int size)return 0 ; } -static int riscv_cpu_get_info (struct udevice *dev,struct cpu_info *info) +static int riscv_cpu_get_info (const struct udevice *dev,struct cpu_info *info) {const char *mmu;
@@ -38,7 +38,7 @@ static int riscv_cpu_get_info(struct udevice *dev, struct cpu_info *info)return 0 ; } -static int riscv_cpu_get_count (struct udevice *dev) +static int riscv_cpu_get_count (const struct udevice *dev) {ofnode node;int num =0 ;
include/cpu.h +8 -8
@@ -61,7 +61,7 @@ struct cpu_ops {* @size: Size of string space * @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error */ -int (*get_desc)(struct udevice *dev,char *buf,int size); +int (*get_desc)(const struct udevice *dev,char *buf,int size);/** * get_info() - Get information about a CPU
@@ -70,7 +70,7 @@ struct cpu_ops {* @info: Returns CPU info * @return 0 if OK, -ve on error */ -int (*get_info)(struct udevice *dev,struct cpu_info *info); +int (*get_info)(const struct udevice *dev,struct cpu_info *info);/** * get_count() - Get number of CPUs
@@ -78,7 +78,7 @@ struct cpu_ops {* @dev: Device to check (UCLASS_CPU) * @return CPU count if OK, -ve on error */ -int (*get_count)(struct udevice *dev); +int (*get_count)(const struct udevice *dev);/** * get_vendor() - Get vendor name of a CPU
@@ -88,7 +88,7 @@ struct cpu_ops {* @size: Size of string space * @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error */ -int (*get_vendor)(struct udevice *dev,char *buf,int size); +int (*get_vendor)(const struct udevice *dev,char *buf,int size); };#define cpu_get_ops (dev) ((struct cpu_ops *)(dev)->driver->ops)
@@ -101,7 +101,7 @@ struct cpu_ops {* * Return: 0 if OK, -ENOSPC if buffer is too small, other -ve on error */ -int cpu_get_desc (struct udevice *dev,char *buf,int size); +int cpu_get_desc (const struct udevice *dev,char *buf,int size);/** * cpu_get_info() - Get information about a CPU
@@ -110,7 +110,7 @@ int cpu_get_desc(struct udevice *dev, char *buf, int size);* * Return: 0 if OK, -ve on error */ -int cpu_get_info (struct udevice *dev,struct cpu_info *info); +int cpu_get_info (const struct udevice *dev,struct cpu_info *info);/** * cpu_get_count() - Get number of CPUs
@@ -118,7 +118,7 @@ int cpu_get_info(struct udevice *dev, struct cpu_info *info);* * Return: CPU count if OK, -ve on error */ -int cpu_get_count (struct udevice *dev); +int cpu_get_count (const struct udevice *dev);/** * cpu_get_vendor() - Get vendor name of a CPU
@@ -128,7 +128,7 @@ int cpu_get_count(struct udevice *dev);* * Return: 0 if OK, -ENOSPC if buffer is too small, other -ve on error */ -int cpu_get_vendor (struct udevice *dev,char *buf,int size); +int cpu_get_vendor (const struct udevice *dev,char *buf,int size);/** * cpu_probe_all() - Probe all available CPUs
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 81/108 x86: apl: Update iomap for ACPI
In reply to Simon GlassAdd some more definitions to the iomap. These will be used by ACPI-generation code as well as the device tree.
---
arch/x86/include/asm/arch-apollolake/iomap.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
arch/x86/include/asm/arch-apollolake/iomap.h +17 -0
@@ -11,11 +11,28 @@/* 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 PMC_BAR0 0xfe042000 + +#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.25.0.341.g760bfbb309-goog
PATCH 82/108 x86: Add a few common Intel CPU functions
In reply to Simon GlassAdd functions to query CPU information, needed for ACPI.
---
arch/x86/cpu/intel_common/cpu.c | 59 +++++++++++++++++++++++++++++++ arch/x86/include/asm/cpu_common.h | 31 ++++++++++++++++ 2 files changed, 90 insertions(+)
arch/x86/cpu/intel_common/cpu.c +59 -0
@@ -8,6 +8,7 @@*/ #include <common.h> +#include <acpigen.h> #include <cpu.h> #include <dm.h> #include <errno.h>
@@ -226,3 +227,61 @@ 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 ; +} + +uint32_t 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 */ +} + +uint32_t 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; +} + +uint32_t cpu_get_bus_clock (void ) +{ +/* CPU bus clock is set by default here to 100MHz. +* This function returns the bus clock in KHz. +*/ +return INTEL_BCLK_MHZ *1000 ; +} + +uint32_t cpu_get_power_max (void ) +{ +msr_t msr; +int power_unit; + + 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; +} + +uint32_t 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 +31 -0
@@ -128,4 +128,35 @@ void cpu_set_eist(bool eist_status);*/ void cpu_set_p_state_to_turbo_ratio (void ); +/* +* cpu_get_bus_clock returns the bus clock frequency in KHz. +* This is the value the clock ratio is multiplied with. +*/ +uint32_t cpu_get_bus_clock (void ); + +int cpu_get_coord_type (void ); + +/* +* cpu_get_min_ratio returns the minimum frequency ratio that is supported +* by this processor +*/ +uint32_t cpu_get_min_ratio (void ); + +/* +* cpu_get_max_ratio returns the nominal TDP ratio if available or the +* maximum non turbo frequency ratio for this processor +*/ +uint32_t cpu_get_max_ratio (void ); + +/* +* cpu_get_power_max calculates CPU TDP in mW +*/ +uint32_t cpu_get_power_max (void ); + +/* +* cpu_get_max_turbo_ratio returns the maximum turbo ratio limit for the +* processor +*/ +uint32_t cpu_get_max_turbo_ratio (void ); +#endif
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 83/108 x86: acpi: Support generation of the HPET table
In reply to Simon GlassAdd an implementation of the HPET (High Precision Event Timer) ACPI table.
---
arch/x86/lib/acpi_table.c | 54 +++++++++++++++++++++++++++++++++++++++ include/acpi_table.h | 32 ++++++++++++++++------- 2 files changed, 77 insertions(+), 9 deletions(-)
arch/x86/lib/acpi_table.c +54 -0
@@ -32,6 +32,26 @@ extern const unsigned char AmlCode[];/* ACPI RSDP address to be used in boot parameters */ static ulong acpi_rsdp_addr; +int acpi_write_hpet (struct acpi_ctx *ctx,const struct udevice *dev) +{ +struct acpi_hpet *hpet; +int ret; + +/* +* We explicitly add these tables later on: +*/ +log_debug ("ACPI: * HPET\n" ); + + hpet = ctx->current; +acpi_inc_align (ctx,sizeof (struct acpi_hpet )); +acpi_create_hpet (hpet); + ret =acpi_add_table (ctx, hpet); +if (ret) +return log_msg_ret ("add" , ret); + +return 0 ; +} +static void acpi_create_facs (struct acpi_facs *facs) {memset ((void *)facs,0 ,sizeof (struct acpi_facs ));
@@ -385,6 +405,40 @@ void acpi_create_ssdt(struct acpi_ctx *ctx, struct acpi_table_header *ssdt, ssdt->checksum =table_compute_checksum ((void *)ssdt, ssdt->length); } +/* http://www.intel.com/hardwaredesign/hpetspec_1.pdf */ +int acpi_create_hpet (struct acpi_hpet *hpet) +{ +struct acpi_table_header *header = &hpet->header; +struct acpi_gen_regaddr *addr = &hpet->addr; + +memset ((void *)hpet,0 ,sizeof (struct acpi_hpet )); +if (!header) +return -EFAULT ; + +/* Fill out header fields. */ +acpi_fill_header (header,"HPET" ); + + header->aslc_revision =ASL_REVISION ; + header->length =sizeof (struct acpi_hpet ); + header->revision =acpi_get_table_revision (ACPITAB_HPET ); + +/* Fill out HPET address. */ + addr->space_id =0 ;/* Memory */ + addr->bit_width =64 ; + addr->bit_offset =0 ; + addr->addrl =CONFIG_HPET_ADDRESS &0xffffffff ; + addr->addrh = ((unsigned long long )CONFIG_HPET_ADDRESS ) >>32 ; + + hpet->id = *(unsigned int *)CONFIG_HPET_ADDRESS ; + hpet->number =0 ; + hpet->min_tick =0 ;/* HPET_MIN_TICKS */ + + header->checksum =table_compute_checksum ((void *)hpet, +sizeof (struct acpi_hpet )); + +return 0 ; +} +/* * QEMU's version of write_acpi_tables is defined in drivers/misc/qfw.c */
include/acpi_table.h +23 -9
@@ -70,6 +70,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
@@ -85,6 +94,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 ,
@@ -152,15 +171,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;
@@ -617,6 +627,10 @@ int acpi_add_table(struct acpi_ctx *ctx, void *table);*/ void acpi_setup_base_tables (struct acpi_ctx *ctx,void *start); +int acpi_write_hpet (struct acpi_ctx *ctx,const struct udevice *dev); + +int acpi_create_hpet (struct acpi_hpet *hpet); +#endif /* !__ACPI__*/ #include <asm/acpi_table.h>
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 84/108 x86: acpi: Support generation of the DBG2 table
In reply to Simon GlassAdd 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.
---
arch/x86/lib/acpi_table.c | 112 +++++++++++++++++++++++++++++++++++++- include/acpi_table.h | 31 +++++++++++ 2 files changed, 142 insertions(+), 1 deletion(-)
arch/x86/lib/acpi_table.c +111 -1
@@ -8,6 +8,8 @@#include <common.h> #include <acpigen.h> +#include <acpi_device.h> +#include <acpi_table.h> #include <cpu.h> #include <dm.h> #include <dm/uclass-internal.h>
@@ -15,7 +17,6 @@#include <serial.h> #include <version.h> #include <asm/acpi/global_nvs.h> -#include <acpi_table.h> #include <asm/ioapic.h> #include <asm/lapic.h> #include <asm/mpspec.h>
@@ -52,6 +53,50 @@ int acpi_write_hpet(struct acpi_ctx *ctx, const struct udevice *dev)return 0 ; } +int acpi_write_dbg2_pci_uart (struct acpi_ctx *ctx,struct udevice *dev, +uint access_size) +{ +struct acpi_dbg2_header *dbg2 = ctx->current; +char path[ACPI_PATH_MAX ]; +struct acpi_gen_regaddr address; +phys_addr_t addr; +int ret; + +if (!dev) { +log_err ("Device not found\n" ); +return -ENODEV ; + } +if (!device_active (dev)) { +log_info ("Device not enabled\n" ); +return -EACCES ; + } +/* +* PCI devices don't remember their resource allocation information in +* U-Boot at present. We assume that MMIO is used for the UART and that +* the address space is 32 bytes: ns16550 uses 8 registers of up to +* 32-bits each. This is only for debugging so it is not a big deal. +*/ + addr =dm_pci_read_bar32 (dev,0 ); +printf ("UART addr %lx\n" , (ulong )addr); + +memset (&address,'\0' ,sizeof (address)); + address.space_id =ACPI_ADDRESS_SPACE_MEMORY ; + address.addrl = (uint32_t )addr; + address.addrh = (uint32_t )((addr >>32 ) &0xffffffff ); + address.access_size = access_size; + + ret =acpi_device_path (dev, path,sizeof (path)); +if (ret) +return log_msg_ret ("path" , ret); +acpi_create_dbg2 (dbg2,ACPI_DBG2_SERIAL_PORT , +ACPI_DBG2_16550_COMPATIBLE , &address,0x1000 , path); + +acpi_inc_align (ctx, dbg2->header.length); +acpi_add_table (ctx, dbg2); + +return 0 ; +} +static void acpi_create_facs (struct acpi_facs *facs) {memset ((void *)facs,0 ,sizeof (struct acpi_facs ));
@@ -439,6 +484,71 @@ int acpi_create_hpet(struct acpi_hpet *hpet)return 0 ; } +void acpi_create_dbg2 (struct acpi_dbg2_header *dbg2, +int port_type,int port_subtype, +struct acpi_gen_regaddr *address,u32 address_size, +const char *device_path) +{ +uintptr_t current; +struct acpi_dbg2_device *device; +u32 *dbg2_addr_size; +struct acpi_table_header *header; +size_t path_len; +const char *path; +char *namespace; + +/* Fill out header fields. */ + current = (uintptr_t )dbg2; +memset (dbg2,'\0' ,sizeof (struct acpi_dbg2_header )); + header = &dbg2->header; + + header->revision =acpi_get_table_revision (ACPITAB_DBG2 ); +acpi_fill_header (header,"DBG2" ); + header->aslc_revision =ASL_REVISION ; + +/* One debug device defined */ + dbg2->devices_offset =sizeof (struct acpi_dbg2_header ); + dbg2->devices_count =1 ; + current +=sizeof (struct acpi_dbg2_header ); + +/* Device comes after the header */ + device = (struct acpi_dbg2_device *)current; +memset (device,0 ,sizeof (struct acpi_dbg2_device )); + current +=sizeof (struct acpi_dbg2_device ); + + device->revision =0 ; + device->address_count =1 ; + device->port_type = port_type; + device->port_subtype = port_subtype; + +/* Base Address comes after device structure */ +memcpy ((void *)current, address,sizeof (struct acpi_gen_regaddr )); + device->base_address_offset = current - (uintptr_t )device; + current +=sizeof (struct acpi_gen_regaddr ); + +/* Address Size comes after address structure */ + dbg2_addr_size = (uint32_t *)current; + device->address_size_offset = current - (uintptr_t )device; + *dbg2_addr_size = address_size; + current +=sizeof (uint32_t ); + +/* Namespace string comes last, use '.' if not provided */ + path = device_path ? :"." ; +/* Namespace string length includes NULL terminator */ + path_len =strlen (path) +1 ; + namespace = (char *)current; + device->namespace_string_length = path_len; + device->namespace_string_offset = current - (uintptr_t )device; +strncpy (namespace, path, path_len); + current += path_len; + +/* Update structure lengths and checksum */ + device->length = current - (uintptr_t )device; + header->length = current - (uintptr_t )dbg2; + header->checksum =table_compute_checksum ((uint8_t *)dbg2, + header->length); +} +/* * QEMU's version of write_acpi_tables is defined in drivers/misc/qfw.c */
include/acpi_table.h +31 -0
@@ -489,6 +489,29 @@ struct 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;
@@ -564,6 +587,11 @@ int acpi_get_table_revision(enum acpi_tables table);*/ int acpi_create_dmar (struct acpi_dmar *dmar,enum dmar_flags flags); +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 *
@@ -631,6 +659,9 @@ int acpi_write_hpet(struct acpi_ctx *ctx, const struct udevice *dev);int acpi_create_hpet (struct acpi_hpet *hpet); +int acpi_write_dbg2_pci_uart (struct acpi_ctx *ctx,struct udevice *dev, +uint access_size); +#endif /* !__ACPI__*/ #include <asm/acpi_table.h>
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 84/108 x86: acpi: Support generation of the DBG2 table
Hi Simon,
A portion of this set is very much not x86-specific. (more below)
Quoted 33 lines · 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.
Signed-off-by Simon Glass <[email protected]>---
arch/x86/lib/acpi_table.c | 112 +++++++++++++++++++++++++++++++++++++- include/acpi_table.h | 31 +++++++++++ 2 files changed, 142 insertions(+), 1 deletion(-)arch/x86/lib/acpi_table.c +2
-1@@ -8,6 +8,8 @@#include <common.h> #include <acpigen.h> +#include <acpi_device.h> +#include <acpi_table.h> #include <cpu.h> #include <dm.h> #include <dm/uclass-internal.h> @@ -15,7 +17,6 @@#include <serial.h> #include <version.h> #include <asm/acpi/global_nvs.h> -#include <acpi_table.h> #include <asm/ioapic.h> #include <asm/lapic.h> #include <asm/mpspec.h>
arch/x86/lib/acpi_table.c int acpi_write_hpet(struct acpi_ctx *ctx, const struct udevice *dev) · line 58
Quoted 6 lines
arch/x86/lib/acpi_table.c +3
-0@@ -52,6 +53,50 @@ int acpi_write_hpet(struct acpi_ctx *ctx, const struct udevice *dev)return 0 ; } +int acpi_write_dbg2_pci_uart (struct acpi_ctx *ctx,struct udevice *dev, +uint access_size) +{
So, this one could possibly be argued either way (it is certainly not fully generic).
Quoted 45 lines
arch/x86/lib/acpi_table.c +41
-0+struct acpi_dbg2_header *dbg2 = ctx->current; +char path[ACPI_PATH_MAX ]; +struct acpi_gen_regaddr address; +phys_addr_t addr; +int ret; + +if (!dev) { +log_err ("Device not found\n" ); +return -ENODEV ; + } +if (!device_active (dev)) { +log_info ("Device not enabled\n" ); +return -EACCES ; + } +/* +* PCI devices don't remember their resource allocation information in +* U-Boot at present. We assume that MMIO is used for the UART and that +* the address space is 32 bytes: ns16550 uses 8 registers of up to +* 32-bits each. This is only for debugging so it is not a big deal. +*/ + addr =dm_pci_read_bar32 (dev,0 ); +printf ("UART addr %lx\n" , (ulong )addr); + +memset (&address,'\0' ,sizeof (address)); + address.space_id =ACPI_ADDRESS_SPACE_MEMORY ; + address.addrl = (uint32_t )addr; + address.addrh = (uint32_t )((addr >>32 ) &0xffffffff ); + address.access_size = access_size; + + ret =acpi_device_path (dev, path,sizeof (path)); +if (ret) +return log_msg_ret ("path" , ret); +acpi_create_dbg2 (dbg2,ACPI_DBG2_SERIAL_PORT , +ACPI_DBG2_16550_COMPATIBLE , &address,0x1000 , path); + +acpi_inc_align (ctx, dbg2->header.length); +acpi_add_table (ctx, dbg2); + +return 0 ; +} +static void acpi_create_facs (struct acpi_facs *facs) {memset ((void *)facs,0 ,sizeof (struct acpi_facs ));
arch/x86/lib/acpi_table.c int acpi_create_hpet(struct acpi_hpet *hpet) · line 490
Quoted 7 lines
arch/x86/lib/acpi_table.c +4
-0@@ -439,6 +484,71 @@ int acpi_create_hpet(struct acpi_hpet *hpet)return 0 ; } +void acpi_create_dbg2 (struct acpi_dbg2_header *dbg2, +int port_type,int port_subtype, +struct acpi_gen_regaddr *address,u32 address_size, +const char *device_path)
But this one would be usable by any of the architectures supported by ACPI. Could the acpi_create_* functions be moved somewhere non-arch-specific, like a new lib/acpi?
/
Leif
Quoted 123 lines
arch/x86/lib/acpi_table.c +61
-0+{ +uintptr_t current; +struct acpi_dbg2_device *device; +u32 *dbg2_addr_size; +struct acpi_table_header *header; +size_t path_len; +const char *path; +char *namespace; + +/* Fill out header fields. */ + current = (uintptr_t )dbg2; +memset (dbg2,'\0' ,sizeof (struct acpi_dbg2_header )); + header = &dbg2->header; + + header->revision =acpi_get_table_revision (ACPITAB_DBG2 ); +acpi_fill_header (header,"DBG2" ); + header->aslc_revision =ASL_REVISION ; + +/* One debug device defined */ + dbg2->devices_offset =sizeof (struct acpi_dbg2_header ); + dbg2->devices_count =1 ; + current +=sizeof (struct acpi_dbg2_header ); + +/* Device comes after the header */ + device = (struct acpi_dbg2_device *)current; +memset (device,0 ,sizeof (struct acpi_dbg2_device )); + current +=sizeof (struct acpi_dbg2_device ); + + device->revision =0 ; + device->address_count =1 ; + device->port_type = port_type; + device->port_subtype = port_subtype; + +/* Base Address comes after device structure */ +memcpy ((void *)current, address,sizeof (struct acpi_gen_regaddr )); + device->base_address_offset = current - (uintptr_t )device; + current +=sizeof (struct acpi_gen_regaddr ); + +/* Address Size comes after address structure */ + dbg2_addr_size = (uint32_t *)current; + device->address_size_offset = current - (uintptr_t )device; + *dbg2_addr_size = address_size; + current +=sizeof (uint32_t ); + +/* Namespace string comes last, use '.' if not provided */ + path = device_path ? :"." ; +/* Namespace string length includes NULL terminator */ + path_len =strlen (path) +1 ; + namespace = (char *)current; + device->namespace_string_length = path_len; + device->namespace_string_offset = current - (uintptr_t )device; +strncpy (namespace, path, path_len); + current += path_len; + +/* Update structure lengths and checksum */ + device->length = current - (uintptr_t )device; + header->length = current - (uintptr_t )dbg2; + header->checksum =table_compute_checksum ((uint8_t *)dbg2, + header->length); +} +/* * QEMU's version of write_acpi_tables is defined in drivers/misc/qfw.c */ include/acpi_table.h +31
-0@@ -489,6 +489,29 @@ struct 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;@@ -564,6 +587,11 @@ int acpi_get_table_revision(enum acpi_tables table);*/ int acpi_create_dmar (struct acpi_dmar *dmar,enum dmar_flags flags); +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 * @@ -631,6 +659,9 @@ int acpi_write_hpet(struct acpi_ctx *ctx, const struct udevice *dev);int acpi_create_hpet (struct acpi_hpet *hpet); +int acpi_write_dbg2_pci_uart (struct acpi_ctx *ctx,struct udevice *dev, +uint access_size); +#endif /* !__ACPI__*/ #include <asm/acpi_table.h> Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 84/108 x86: acpi: Support generation of the DBG2 table
Hi Leif,
Quoted 17 lines · Leif Lindholm
Hi Simon,
A portion of this set is very much not x86-specific. (more below)
Quoted 11 lines · 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.
Signed-off-by Simon Glass <[email protected]>---
arch/x86/lib/acpi_table.c | 112 +++++++++++++++++++++++++++++++++++++- include/acpi_table.h | 31 +++++++++++ 2 files changed, 142 insertions(+), 1 deletion(-)
[..]
Quoted 11 lines
arch/x86/lib/acpi_table.c int acpi_create_hpet(struct acpi_hpet *hpet) · line 490
Quoted 4 lines
arch/x86/lib/acpi_table.c +4
-0+void acpi_create_dbg2 (struct acpi_dbg2_header *dbg2, +int port_type,int port_subtype, +struct acpi_gen_regaddr *address,u32 address_size, +const char *device_path)But this one would be usable by any of the architectures supported by ACPI. Could the acpi_create_* functions be moved somewhere non-arch-specific, like a new lib/acpi?
/
Leif
OK I'll move this one. In general I don't know which ones are generic and I'd rather keep them x86-specific unless we know.
Regards,
Simon
PATCH 85/108 x86: acpi: Add common Intel ACPI tables
In reply to Simon GlassAdd various tables that are common to Intel CPUs. These functions can be used by arch-specific CPU code.
---
arch/x86/cpu/intel_common/Makefile | 2 + arch/x86/cpu/intel_common/acpi.c | 441 +++++++++++++++++++++++++++++ arch/x86/include/asm/acpi_table.h | 5 + arch/x86/include/asm/cpu_common.h | 1 + arch/x86/include/asm/intel_acpi.h | 25 ++ include/bloblist.h | 5 + 6 files changed, 479 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
@@ -2,6 +2,8 @@ # # Copyright (c) 2016 Google, Inc +obj-y += 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 +441 -0
441 lines not on this page · raw message
arch/x86/include/asm/acpi_table.h +5 -0
@@ -46,4 +46,9 @@ ulong write_acpi_tables(ulong start);*/ ulong acpi_get_rsdp_addr (void ); +int arch_read_sci_irq_select (void ); +int arch_write_sci_irq_select (uint scis); +int arch_madt_sci_irq_polarity (int sci); +struct acpi_cstate *arch_get_cstate_map (size_t *entries); +#endif /* __ASM_ACPI_TABLE_H__ */
arch/x86/include/asm/cpu_common.h +1 -0
@@ -14,6 +14,7 @@ enum { };struct cpu_info ; +struct acpi_ctx ;/** * cpu_common_init() - Set up common CPU init
arch/x86/include/asm/intel_acpi.h new file +25 -0
@@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2018, Bin Meng <[email protected]> +*/ + +#ifndef __ASM_INTEL_ACPI_H__ +#define __ASM_INTEL_ACPI_H__ + +struct acpi_ctx ; +struct udevice ; + +int generate_cpu_entries (struct acpi_ctx *ctx,const struct udevice *device); +void soc_power_states_generation (struct acpi_ctx *ctx, +int core_id,int cores_per_package); + +void generate_p_state_entries (struct acpi_ctx *ctx,int core, +int cores_per_package); +void generate_t_state_entries (struct acpi_ctx *ctx,int core, +int cores_per_package); +int southbridge_inject_dsdt (const struct udevice *dev,struct acpi_ctx *ctx); + +int intel_southbridge_write_acpi_tables (const struct udevice *dev, +struct acpi_ctx *ctx); + +#endif /* __ASM_INTEL_ACPI_H__ */
include/bloblist.h +5 -0
@@ -28,6 +28,11 @@ enum bloblist_tag_t {BLOBLISTT_VBOOT_CTX ,/* Chromium OS verified boot context */ BLOBLISTT_VBOOT_HANDOFF ,/* Chromium OS internal handoff info */ BLOBLISTT_INTEL_VBT ,/* Intel Video-BIOS table */ +/* +* 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.25.0.341.g760bfbb309-goog
PATCH 86/108 x86: Support Atom SoCs using SWSMISCI rather than the SWSCI
In reply to Simon GlassSome Atom SoCs use SWSMISCI for SMI control. Add a Kconfig to select this. It is used on Apollo Lake.
---
arch/x86/Kconfig | 6 ++++++ arch/x86/cpu/apollolake/Kconfig | 1 + 2 files changed, 7 insertions(+)
arch/x86/Kconfig +6 -0
@@ -984,4 +984,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
@@ -16,6 +16,7 @@ config INTEL_APOLLOLAKE select PCIEX_LENGTH_256MB select PCH_SUPPORT select P2SB + select INTEL_GMA_SWSMISCI select ACPI_GNVS_EXTERNAL imply ENABLE_MRC_CACHE imply AHCI_PCI
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 87/108 x86: apl: Add a check for reading the FSP-S config
In reply to Simon GlassThis currently fails as two required items are commented out. Put them back in and add a check that reading the config succeeds.
Both of these items need a little more work to put them in an appropriate driver at some point.
---
arch/x86/cpu/apollolake/fsp_s.c | 6 ++++-- arch/x86/dts/chromebook_coral.dts | 12 ++++++------ 2 files changed, 10 insertions(+), 8 deletions(-)
arch/x86/cpu/apollolake/fsp_s.c +4 -2
@@ -350,8 +350,10 @@ int fsps_update_config(struct udevice *dev, ulong rom_offset, apl =malloc (sizeof (*apl));if (!apl) -return log_msg_ret ("config" , -ENOMEM ); -get_config (dev, apl); +return log_msg_ret ("alloc" , -ENOMEM ); + ret =get_config (dev, apl); +if (ret) +return log_msg_ret ("config" , ret); cfg->ish_enable =0 ; cfg->enable_sata =0 ;
arch/x86/dts/chromebook_coral.dts +6 -6
@@ -497,13 +497,13 @@ * If the Board has PERST_0 signal, assign the GPIO * If the Board does not have PERST_0, assign GPIO_PRT0_UDEF * - * This are not used yet, so comment them out for now. - * - * prt0-gpio = <GPIO_122>; - * - * GPIO for SD card detect - * sdcard-cd-gpio = <GPIO_177>; + * This should be converted to real GPIOs and ideally stored in the + * device they relate to. */ + prt0-gpio = <GPIO_122>; + + /* GPIO for SD card detect */ + sdcard-cd-gpio = <GPIO_177>; /* * Order is emmc-tx-data-cntl1, emmc-tx-data-cntl2,
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 88/108 x86: apl: Store FSP-S config for later use
In reply to Simon GlassSome ACPI tables need to include information from the FSP-S config. Rather than reading it again later, store a pointer to it for use by the ACPI code.
The FSP-S config is read just after relocation, so can be used during this phase of U-Boot.
---
arch/x86/cpu/apollolake/fsp_s.c | 213 +---------------- .../include/asm/arch-apollolake/soc_config.h | 221 ++++++++++++++++++ arch/x86/include/asm/global_data.h | 1 + 3 files changed, 224 insertions(+), 211 deletions(-) create mode 100644 arch/x86/include/asm/arch-apollolake/soc_config.h
arch/x86/cpu/apollolake/fsp_s.c +2 -211
@@ -17,222 +17,12 @@#include <asm/msr-index.h> #include <asm/pci.h> #include <asm/arch/cpu.h> +#include <asm/arch/soc_config.h> #include <asm/arch/systemagent.h> #include <asm/arch/fsp/fsp_configs.h> #include <asm/arch/fsp/fsp_s_upd.h> #include <dm/uclass-internal.h> -#define INTEL_GSPI_MAX 3 -#define MAX_USB2_PORTS 8 - -enum { -CHIPSET_LOCKDOWN_FSP =0 ,/* FSP handles locking per UPDs */ -CHIPSET_LOCKDOWN_COREBOOT ,/* coreboot handles locking */ -}; - -/* Serial IRQ control. SERIRQ_QUIET is the default (0) */ -enum serirq_mode { -SERIRQ_QUIET , -SERIRQ_CONTINUOUS , -SERIRQ_OFF , -}; - -struct gspi_cfg { -/* Bus speed in MHz */ -u32 speed_mhz; -/* Bus should be enabled prior to ramstage with temporary base */ -u8 early_init; -}; - -/* -* This structure will hold data required by common blocks. -* These are soc specific configurations which will be filled by soc. -* We'll fill this structure once during init and use the data in common block. -*/ -struct soc_intel_common_config { -int chipset_lockdown; -struct gspi_cfg gspi[INTEL_GSPI_MAX ]; -}; - -enum pnp_settings { -PNP_PERF , -PNP_POWER , -PNP_PERF_POWER , -}; - -struct usb2_eye_per_port { -u8 per_port_tx_pe_half; -u8 per_port_pe_txi_set; -u8 per_port_txi_set; -u8 hs_skew_sel; -u8 usb_tx_emphasis_en; -u8 per_port_rxi_set; -u8 hs_npre_drv_sel; -u8 override_en; -}; - -struct apl_config { -/* Common structure containing soc config data required by common code*/ -struct soc_intel_common_config common_soc_config; - -/* -* Mapping from PCIe root port to CLKREQ input on the SOC. The SOC has -* four CLKREQ inputs, but six root ports. Root ports without an -* associated CLKREQ signal must be marked with "CLKREQ_DISABLED" -*/ -u8 pcie_rp_clkreq_pin[MAX_PCIE_PORTS ]; - -/* Enable/disable hot-plug for root ports (0 = disable, 1 = enable) */ -u8 pcie_rp_hotplug_enable[MAX_PCIE_PORTS ]; - -/* De-emphasis enable configuration for each PCIe root port */ -u8 pcie_rp_deemphasis_enable[MAX_PCIE_PORTS ]; - -/* -* [14:8] DDR mode Number of dealy elements.Each = 125pSec. -* [6:0] SDR mode Number of dealy elements.Each = 125pSec. -*/ -u32 emmc_tx_cmd_cntl; - -/* -* [14:8] HS400 mode Number of dealy elements.Each = 125pSec. -* [6:0] SDR104/HS200 mode Number of dealy elements.Each = 125pSec. -*/ -u32 emmc_tx_data_cntl1; - -/* -* [30:24] SDR50 mode Number of dealy elements.Each = 125pSec. -* [22:16] DDR50 mode Number of dealy elements.Each = 125pSec. -* [14:8] SDR25/HS50 mode Number of dealy elements.Each = 125pSec. -* [6:0] SDR12/Compatibility mode Number of dealy elements. -* Each = 125pSec. -*/ -u32 emmc_tx_data_cntl2; - -/* -* [30:24] SDR50 mode Number of dealy elements.Each = 125pSec. -* [22:16] DDR50 mode Number of dealy elements.Each = 125pSec. -* [14:8] SDR25/HS50 mode Number of dealy elements.Each = 125pSec. -* [6:0] SDR12/Compatibility mode Number of dealy elements. -* Each = 125pSec. -*/ -u32 emmc_rx_cmd_data_cntl1; - -/* -* [14:8] HS400 mode 1 Number of dealy elements.Each = 125pSec. -* [6:0] HS400 mode 2 Number of dealy elements.Each = 125pSec. -*/ -u32 emmc_rx_strobe_cntl; - -/* -* [13:8] Auto Tuning mode Number of dealy elements.Each = 125pSec. -* [6:0] SDR104/HS200 Number of dealy elements.Each = 125pSec. -*/ -u32 emmc_rx_cmd_data_cntl2; - -/* Select the eMMC max speed allowed */ -u32 emmc_host_max_speed; - -/* Specifies on which IRQ the SCI will internally appear */ -u32 sci_irq; - -/* Configure serial IRQ (SERIRQ) line */ -enum serirq_mode serirq_mode; - -/* Configure LPSS S0ix Enable */ -bool lpss_s0ix_enable; - -/* Enable DPTF support */ -bool dptf_enable; - -/* TCC activation offset value in degrees Celsius */ -int tcc_offset; - -/* -* Configure Audio clk gate and power gate -* IOSF-SB port ID 92 offset 0x530 [5] and [3] -*/ -bool hdaudio_clk_gate_enable; -bool hdaudio_pwr_gate_enable; -bool hdaudio_bios_config_lockdown; - -/* SLP S3 minimum assertion width */ -int slp_s3_assertion_width_usecs; - -/* GPIO pin for PERST_0 */ -u32 prt0_gpio; - -/* USB2 eye diagram settings per port */ -struct usb2_eye_per_port usb2eye[MAX_USB2_PORTS ]; - -/* GPIO SD card detect pin */ -unsigned int sdcard_cd_gpio; - -/* -* PRMRR size setting with three options -* 0x02000000 - 32MiB -* 0x04000000 - 64MiB -* 0x08000000 - 128MiB -*/ -u32 PrmrrSize; - -/* -* Enable SGX feature. -* Enabling SGX feature is 2 step process, -* (1) set sgx_enable = 1 -* (2) set PrmrrSize to supported size -*/ -bool sgx_enable; - -/* -* Select PNP Settings. -* (0) Performance, -* (1) Power -* (2) Power & Performance -*/ -enum pnp_settings pnp_settings; - -/* -* PMIC PCH_PWROK delay configuration - IPC Configuration -* Upd for changing PCH_PWROK delay configuration : I2C_Slave_Address -* (31:24) + Register_Offset (23:16) + OR Value (15:8) + AND Value (7:0) -*/ -u32 pmic_pmc_ipc_ctrl; - -/* -* Options to disable XHCI Link Compliance Mode. Default is FALSE to not -* disable Compliance Mode. Set TRUE to disable Compliance Mode. -* 0:FALSE(Default), 1:True. -*/ -bool disable_compliance_mode; - -/* -* Options to change USB3 ModPhy setting for the Integrated Filter (IF) -* value. Default is 0 to not changing default IF value (0x12). Set -* value with the range from 0x01 to 0xff to change IF value. -*/ -u32 mod_phy_if_value; - -/* -* Options to bump USB3 LDO voltage. Default is FALSE to not increasing -* LDO voltage. Set TRUE to increase LDO voltage with 40mV. -* 0:FALSE (default), 1:True. -*/ -bool mod_phy_voltage_bump; - -/* -* Options to adjust PMIC Vdd2 voltage. Default is 0 to not adjusting -* the PMIC Vdd2 default voltage 1.20v. Upd for changing Vdd2 Voltage -* configuration: I2C_Slave_Address (31:23) + Register_Offset (23:16) -* + OR Value (15:8) + AND Value (7:0) through BUCK5_VID[3:2]: -* 00=1.10v, 01=1.15v, 10=1.24v, 11=1.20v (default). -*/ -u32 pmic_vdd2_voltage; - -/* Option to enable VTD feature */ -bool enable_vtd; -}; -static int get_config (struct udevice *dev,struct apl_config *apl) {const u8 *ptr;
@@ -354,6 +144,7 @@ int fsps_update_config(struct udevice *dev, ulong rom_offset, ret =get_config (dev, apl);if (ret)return log_msg_ret ("config" , ret); + gd->arch.soc_config = apl; cfg->ish_enable =0 ; cfg->enable_sata =0 ;
arch/x86/include/asm/arch-apollolake/soc_config.h new file +221 -0
221 lines not on this page · raw message
arch/x86/include/asm/global_data.h +1 -0
@@ -122,6 +122,7 @@ struct arch_global_data {#endif #ifdef CONFIG_FSP_VERSION2 struct fsp_header *fsp_s_hdr;/* Pointer to FSP-S header */ +const void *soc_config;/* SOC-specific configuration */ #endif ulong acpi_start;/* Start address of ACPI tables */ };
Signature · 1 line
2.25.0.341.g760bfbb309-goog
PATCH 89/108 p2sb: Add some definitions used for ACPI
In reply to Simon GlassAllow this header to be included in ASL files by adding a header guard and a few definitions that are needed.
---
include/p2sb.h | 8 ++++++++ 1 file changed, 8 insertions(+)
include/p2sb.h +8 -0
@@ -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.25.0.341.g760bfbb309-goog
PATCH 90/108 x86: apl: Add support for hostbridge ACPI generation
In reply to Simon GlassSupport generating a DMAR table and add a few helper routines as well.
---
arch/x86/cpu/apollolake/hostbridge.c | 104 ++++++++++++++++++ .../include/asm/arch-apollolake/systemagent.h | 6 + 2 files changed, 110 insertions(+)
arch/x86/cpu/apollolake/hostbridge.c +104 -0
@@ -1,16 +1,29 @@// 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 <acpi_table.h> #include <dm.h> #include <dt-structs.h> #include <spl.h> +#include <tables_csum.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 <dm/acpi.h> /** * struct apl_hostbridge_platdata - platform data for hostbridge
@@ -39,7 +52,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)
@@ -164,6 +179,92 @@ 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_return_name (out_name,"RHUB" ); +} + +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 ; +} + +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; + +/* 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 ); +} + +struct acpi_ops apl_hostbridge_acpi_ops = { + .get_name = apl_acpi_hb_get_name, + .write_tables = apl_acpi_hb_write_tables, +}; +static const struct udevice_id apl_hostbridge_ids[] = { { .compatible ="intel,apl-hostbridge" }, { }
@@ -175,5 +276,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, };
arch/x86/include/asm/arch-apollolake/systemagent.h +6 -0
@@ -34,4 +34,10 @@*/ void enable_bios_reset_cpl (void ); +/* API to get TOLUD base address */ +uintptr_t sa_get_tolud_base (struct udevice *dev); +/* API to get GSM base address */ +ulong sa_get_gsm_base (struct udevice *dev); +ulong sa_get_tseg_base (struct udevice *dev); +#endif
Signature · 1 line
2.25.0.341.g760bfbb309-goog