dm: Add programmatic generation of ACPI tables (part A)
v5 cover dm: Add programmatic generation of ACPI tables (part A)
This is split from the original series in an attempt to get things applied in chunks.
The first 20 or so patches here have been reviewed and the changes here incorporate those comments.
Changes in v5:
- Tweak unused naming and comments
- Capitalise ACPI_OPS_PTR since it includes a comma
- Capitalise ACPI_OPS_PTR since it includes a comma
- Update commit message to mention dropping the #ifdef CONFIG_X86
- Mess with the table ordering a little more
- Add #ifndef CONFIG_SANDBOX to maintain bisectability without merging patches
- Drop bisectability changes
Changes in v4:
- Fix indentation of unused
- Calculate the padding
- Put 'interrupts-extended' property on one line
- Rename acpi-probed to linux,probed
- Note that linux,probed is an out-of-tree feature
- Move ACPI makefile line outside the ifdef CONFIG_SPL_BUILD
- Add a comment about the MADT table version
- Add SPCR
- Update comment to include tables defined or reserved by ACPI
- Drop ASL_REVISION
- Separate out the log newline
- Update comment in acpi_inc_align() to show the alignment
- Put back cast on table_compute_checksum()
- Rename list_fact() to list_fadt()
- Add a comment to dump_hdr()
Changes in v3:
Drop acpi,name in example
- Fix indenting error mentioned by Andy Shevchenko
- Fix stray #endif
- Drop 'Intel' from 'Intel ACPI'
- Reword commit message to drop the bit about ACPI being complicated
- Compute ACPI_NAME_MAX from ACPI_NAME_LEN
- Rename acpi_return_name() to acpi_copy_name()
- Use strncpy() instead of strcpy() in acpi_copy_name()
- Split out hid-over-i2c into its own patch
- Drop mention of PRIC
- Rename acpi,desc to acpi,ddn
- Correct description of acpi,probed
- Drop hid-descr-addr
- Just add the device.txt binding file in this patch
- Change the example to ELAN
- Add a pointer to information about acpi,compatible
- Add new patch to move acpi_s3.h to include/acpi/
- Update commit message to say that we move most of its contents
- Move acpi_table.h to include/acpi
- Add forward declarations for the functions
- Fix file comment for acpi_table.c
- Fix a few typos
- Make use of BIT()
- Fix DMA_ typo
- Add missing error check in acpi_create_dmar()
- Drop duplicate assert
- Add new patch to add hexdump.h to the unit test header
- Rename acpi_align_large() to acpi_align64()
- Fix 'RSDP' typo
- Fix 'XDST' typo
- Move acpi_align_large() out of dm_test_acpi_setup_base_tables()
- Beef up the comment explaining how the unaligned address is used
Changes in v2:
- Don't bracket the definitions with DM_SPI
- Add trailing commas to enum
- Drop the other comment change since it is already applied
- Drop the Chrome OS pieces
- Rename the 'coreboot' console to 'U-Boot'
- Move LOGC_ACPI definition to this patch
- Fix definition of HID
- Infer hid-over-i2c CID value
- Add the hid-over-i2c binding document
- Add in the acpi_table.h header file to this patch
- Move the sandbox acpi_table.h header file to an earlier patch
- Use #defines for MADT and MCFG version numbers
- Drop two unnecessary __packed
- Move __packed to after struct
- Drop definition of ACPI_TABLE_CREATOR
- Make _acpi_write_dev_tables() static and switch argument order
- Generalise the ACPI function recursion with acpi_recurse_method()
Simon Glass (29):
cpu: Support querying the address width
spi: Add SPI mode enums
tpm: cr50: Release locality on exit
tpm: cr50: Add a comment for cr50_priv
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
dts: Add a binding for hid-over-i2c
acpi: Add a binding for ACPI settings in the device tree
acpi: Add a simple sandbox test
x86: Move acpi_s3.h to include/acpi/
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
test: Add hexdump.h to the unit test header
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
arch/sandbox/dts/test.dts | 8 +
arch/sandbox/include/asm/acpi_table.h | 9 +
arch/sandbox/include/asm/global_data.h | 1 +
arch/x86/cpu/apollolake/cpu_spl.c | 2 +-
arch/x86/cpu/apollolake/fsp_s.c | 2 +-
arch/x86/cpu/apollolake/pmc.c | 2 +-
arch/x86/cpu/baytrail/acpi.c | 6 +-
arch/x86/cpu/coreboot/timestamp.c | 4 +-
arch/x86/cpu/cpu.c | 4 +-
arch/x86/cpu/intel_common/p2sb.c | 33 +-
arch/x86/cpu/quark/acpi.c | 2 +-
arch/x86/cpu/tangier/acpi.c | 4 +-
arch/x86/cpu/wakeup.S | 2 +-
arch/x86/dts/chromebook_coral.dts | 2 +-
arch/x86/include/asm/acpi_table.h | 381 +-----------
.../include/asm/arch-apollolake/global_nvs.h | 36 ++
.../x86/include/asm/arch-coreboot/timestamp.h | 4 +-
arch/x86/include/asm/global_data.h | 1 +
arch/x86/include/asm/intel_pinctrl_defs.h | 2 -
arch/x86/lib/acpi.c | 2 +-
arch/x86/lib/acpi_s3.c | 4 +-
arch/x86/lib/acpi_table.c | 241 ++------
arch/x86/lib/coreboot_table.c | 2 +-
arch/x86/lib/fsp/fsp_common.c | 2 +-
arch/x86/lib/fsp1/fsp_common.c | 2 +-
arch/x86/lib/fsp2/fsp_dram.c | 2 +-
arch/x86/lib/tables.c | 2 +-
arch/x86/lib/zimage.c | 2 +-
cmd/Kconfig | 14 +
cmd/Makefile | 1 +
cmd/acpi.c | 186 ++++++
configs/tools-only_defconfig | 1 +
doc/device-tree-bindings/device.txt | 36 ++
.../gpio/intel,apl-gpio.txt | 2 +-
.../input/hid-over-i2c.txt | 44 ++
.../interrupt-controller/intel,acpi-gpe.txt | 2 +-
doc/device-tree-bindings/pci/x86-pci.txt | 23 +
drivers/core/Kconfig | 9 +
drivers/core/Makefile | 1 +
drivers/core/acpi.c | 95 +++
drivers/cpu/cpu_sandbox.c | 1 +
drivers/pci/pci-uclass.c | 11 +-
drivers/pci/pci_rom.c | 4 +-
drivers/power/acpi_pmc/acpi-pmc-uclass.c | 2 +-
drivers/sysreset/sysreset_x86.c | 2 +-
drivers/tpm/cr50_i2c.c | 24 +-
drivers/tpm/tpm-uclass.c | 13 +-
include/{ => acpi}/acpi_s3.h | 0
include/acpi/acpi_table.h | 577 ++++++++++++++++++
include/cpu.h | 2 +
include/dm/acpi.h | 114 ++++
include/dm/device.h | 5 +
include/dm/uclass-id.h | 1 +
include/log.h | 2 +
include/spi.h | 33 +
include/test/ut.h | 1 +
lib/Makefile | 1 +
lib/acpi/Makefile | 4 +
lib/acpi/acpi_table.c | 259 ++++++++
lib/efi_loader/efi_acpi.c | 2 +-
scripts/Makefile.lib | 4 +-
test/dm/Makefile | 1 +
test/dm/acpi.c | 317 ++++++++++
test/dm/cpu.c | 1 +
64 files changed, 1921 insertions(+), 638 deletions(-)
create mode 100644 arch/sandbox/include/asm/acpi_table.h
create mode 100644 arch/x86/include/asm/arch-apollolake/global_nvs.h
create mode 100644 cmd/acpi.c
create mode 100644 doc/device-tree-bindings/device.txt
create mode 100644 doc/device-tree-bindings/input/hid-over-i2c.txt
create mode 100644 drivers/core/acpi.c
rename include/{ => acpi}/acpi_s3.h (100%)
create mode 100644 include/acpi/acpi_table.h
create mode 100644 include/dm/acpi.h
create mode 100644 lib/acpi/Makefile
create mode 100644 lib/acpi/acpi_table.c
create mode 100644 test/dm/acpi.cSignature · 1 line
2.26.0.292.g33ef6b2f38-goog
PATCH v5 1/29 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.
---
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None
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.26.0.292.g33ef6b2f38-goog
PATCH v5 1/29 cpu: Support querying the address width
Quoted 13 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.Signed-off-by Simon Glass <[email protected]>Reviewed-by Bin Meng <[email protected]>---
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None
Quoted 5 lines
drivers/cpu/cpu_sandbox.c | 1 + include/cpu.h | 2 ++ test/dm/cpu.c | 1 + 3 files changed, 4 insertions(+)
applied to u-boot-x86, thanks!
PATCH v5 2/29 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.
---
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2:
- Don't bracket the definitions with DM_SPI
- Add trailing commas to enum
include/spi.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
include/spi.h +33 -0
@@ -66,6 +66,39 @@ struct dm_spi_slave_platdata {#endif /* CONFIG_DM_SPI */ +/** +* 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 , +}; +/** * struct spi_slave - Representation of a SPI slave *
Signature · 1 line
2.26.0.292.g33ef6b2f38-goog
PATCH v5 2/29 spi: Add SPI mode enums
Quoted 16 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]>Reviewed-by Bin Meng <[email protected]>Reviewed-by Wolfgang Wallner <[email protected]>---
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2:
- Don't bracket the definitions withDM_SPI
- Add trailing commas to enum
Quoted 3 lines
include/spi.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
applied to u-boot-x86, thanks!
PATCH v5 3/29 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.
---
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None
drivers/tpm/cr50_i2c.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/tpm/cr50_i2c.c +11 -2
@@ -206,7 +206,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 ; }
@@ -499,6 +499,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;
@@ -525,6 +526,7 @@ static int claim_locality(struct udevice *dev, int loc)return -EPERM ; }log_info ("Claimed locality %d\n" , loc); + priv->locality = loc;return 0 ; }
@@ -559,7 +561,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 ; }
@@ -631,6 +637,7 @@ static int cr50_i2c_probe(struct udevice *dev)return log_msg_ret ("vendor-id" , -EXDEV ); } priv->vendor = vendor; + priv->locality =-1 ;return 0 ; }
@@ -655,5 +662,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.26.0.292.g33ef6b2f38-goog
PATCH v5 3/29 tpm: cr50: Release locality on exit
Quoted 9 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]>Reviewed-by Bin Meng <[email protected]>---
Quoted 8 lines
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: Nonedrivers/tpm/cr50_i2c.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
applied to u-boot-x86, thanks!
PATCH v5 4/29 tpm: cr50: Add a comment for cr50_priv
In reply to Simon GlassAdd a comment for the private structure
---
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2:
- Drop the other comment change since it is already applied
drivers/tpm/cr50_i2c.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/tpm/cr50_i2c.c +9 -0
@@ -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;
Signature · 1 line
2.26.0.292.g33ef6b2f38-goog
PATCH v5 4/29 tpm: cr50: Add a comment for cr50_priv
Quoted 7 lines · Simon Glass
Add a comment for the private structure
Signed-off-by Simon Glass <[email protected]>Reviewed-by Bin Meng <[email protected]>---
Quoted 9 lines
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2:
- Drop the other comment change since it is already applieddrivers/tpm/cr50_i2c.c | 9 +++++++++ 1 file changed, 9 insertions(+)
applied to u-boot-x86, thanks!
PATCH v5 5/29 tpm: cr50: Use the correct GPIO binding
In reply to Simon GlassThis device should use ready-gpios rather than ready-gpio. Fix it.
---
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None
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
@@ -607,7 +607,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.26.0.292.g33ef6b2f38-goog
PATCH v5 5/29 tpm: cr50: Use the correct GPIO binding
Quoted 12 lines · Simon Glass
This device should use ready-gpios rather than ready-gpio. Fix it.
Signed-off-by Simon Glass <[email protected]>Reviewed-by Bin Meng <[email protected]>---
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None
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(-)
applied to u-boot-x86, thanks!
PATCH v5 6/29 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.
---
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None
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.26.0.292.g33ef6b2f38-goog
PATCH v5 6/29 tpm: Don't cleanup unless an error happens
Quoted 9 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]>Reviewed-by Bin Meng <[email protected]>---
Quoted 8 lines
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: Nonedrivers/tpm/tpm-uclass.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
applied to u-boot-x86, thanks!
PATCH v5 7/29 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.
---
Changes in v5: None
Changes in v4: None
Changes in v3:
Drop acpi,name in example
Changes in v2: None
doc/device-tree-bindings/pci/x86-pci.txt | 23 +++++++++++++++++++++++ drivers/pci/pci-uclass.c | 2 ++ 2 files changed, 25 insertions(+)
doc/device-tree-bindings/pci/x86-pci.txt +23 -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,16 @@ 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>; + pci,no-autoconfig; + }; };
drivers/pci/pci-uclass.c +2 -0
@@ -536,6 +536,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.26.0.292.g33ef6b2f38-goog
PATCH v5 7/29 dm: pci: Allow disabling auto-config for a device
Quoted 13 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.
Signed-off-by Simon Glass <[email protected]>Reviewed-by Bin Meng <[email protected]>---
Changes in v5: None
Changes in v4: None
Changes in v3:
Drop acpi,name in example
Quoted 6 lines
Changes in v2: None
doc/device-tree-bindings/pci/x86-pci.txt | 23 +++++++++++++++++++++++ drivers/pci/pci-uclass.c | 2 ++ 2 files changed, 25 insertions(+)
applied to u-boot-x86, thanks!
PATCH v5 8/29 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.
---
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None
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.26.0.292.g33ef6b2f38-goog
PATCH v5 8/29 x86: Correct wording of coreboot source code
Quoted 14 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.
Signed-off-by Simon Glass <[email protected]>Reviewed-by Bin Meng <[email protected]>Reviewed-by Wolfgang Wallner <[email protected]>---
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None
Quoted 5 lines
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(-)
applied to u-boot-x86, thanks!
PATCH v5 9/29 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.
---
Changes in v5: None
Changes in v4: None
Changes in v3:
- Fix indenting error mentioned by Andy Shevchenko
Changes in v2: None
arch/x86/cpu/intel_common/p2sb.c | 33 +++++++++++--------------------- 1 file changed, 11 insertions(+), 22 deletions(-)
arch/x86/cpu/intel_common/p2sb.c +11 -22
@@ -92,46 +92,35 @@ int 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); } + 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 ; }static int p2sb_probe (struct udevice *dev) { -if (spl_phase () ==PHASE_TPL ) { +if (spl_phase () ==PHASE_TPL )return 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 p2sb_spl_init (dev); - } +else if (spl_phase () ==PHASE_SPL ) +return p2sb_spl_init (dev);return 0 ; }
Signature · 1 line
2.26.0.292.g33ef6b2f38-goog
PATCH v5 9/29 x86: apl: Move p2sb ofdata reading to the correct method
Quoted 33 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]>Reviewed-by Wolfgang Wallner <[email protected]>Tested-by Wolfgang Wallner <[email protected]>---
Changes in v5: None
Changes in v4: None
Changes in v3:
- Fix indenting error mentioned by Andy Shevchenko
Quoted 5 lines
Changes in v2: None
arch/x86/cpu/intel_common/p2sb.c | 33 +++++++++++--------------------- 1 file changed, 11 insertions(+), 22 deletions(-)
applied to u-boot-x86, thanks!
PATCH v5 10/29 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.
---
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None
drivers/pci/pci-uclass.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/pci/pci-uclass.c +8 -1
@@ -1213,7 +1213,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.26.0.292.g33ef6b2f38-goog
PATCH v5 10/29 pci: Adjust dm_pci_read_bar32() to return errors correctly
Quoted 4 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.
If you insisting on the code, you may need to reword the commit message, at least by removing ambiguous "device not present", because this is not how PCI spec defines situations when device is not present.
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v5 10/29 pci: Adjust dm_pci_read_bar32() to return errors correctly
Quoted 5 lines
From: Andy Shevchenko <[email protected]>
Date: Thu, 9 Apr 2020 12:06:11 +0300Quoted 1 line · Simon Glass
Quoted 8 lines
Quoted 3 lines
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.If you insisting on the code, you may need to reword the commit message, at least by removing ambiguous "device not present", because this is not how PCI spec defines situations when device is not present.
In addition to that:
The 0xffffffff value is an artifact of how x86 systems handle aborted PCI transactions. Other architectures will probably generate a fault of some sorts. It looks like at least some of the pci drivers in u-boot emulate the x86 behaviour but I'm not sure all of them do.
PATCH v5 10/29 pci: Adjust dm_pci_read_bar32() to return errors correctly
Hi,
Quoted 15 lines · Mark Kettenis
Quoted 6 lines
From: Andy Shevchenko <[email protected]>
Date: Thu, 9 Apr 2020 12:06:11 +0300Quoted 1 line · Simon Glass
Quoted 8 lines
Quoted 3 lines
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.If you insisting on the code, you may need to reword the commit message, at least by removing ambiguous "device not present", because this is not how PCI spec defines situations when device is not present.
Quoted 6 lines
In addition to that:
The
0xffffffffvalue is an artifact of how x86 systems handle aborted PCI transactions. Other architectures will probably generate a fault of some sorts. It looks like at least some of the pci drivers in u-boot emulate the x86 behaviour but I'm not sure all of them do.
This is not intended to be used to detect missing devices. It's just that we should not be masking an obviously invalid value, to make it look more valid. It is very confusing.
I'll update the comment message.
Regards,
Simon
PATCH v5 11/29 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.
---
Changes in v5:
- Tweak unused naming and comments
Changes in v4:
- Fix indentation of unused
- Calculate the padding
Changes in v3:
- Fix stray #endif
Changes in v2:
- Drop the Chrome OS pieces
- Rename the 'coreboot' console to 'U-Boot'
.../include/asm/arch-apollolake/global_nvs.h | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 arch/x86/include/asm/arch-apollolake/global_nvs.h
arch/x86/include/asm/arch-apollolake/global_nvs.h new file +36 -0
@@ -0,0 +1,36 @@ +/* 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 - U-Boot Console */ +u64 pm1i;/* 0x09 - 0x10 - System Wake Source - PM1 Index */ +u64 gpei;/* 0x11 - 0x18 - GPE Wake Source */ +u64 nhla;/* 0x19 - 0x20 - NHLT Address */ +u32 nhll;/* 0x21 - 0x24 - NHLT Length */ +u32 prt0;/* 0x25 - 0x28 - PERST_0 Address */ +u8 scdp;/* 0x29 - SD_CD GPIO portid */ +u8 scdo;/* 0x2a - GPIO pad offset relative to the community */ +u8 uior;/* 0x2b - UART debug controller init on S3 resume */ +u8 ecps;/* 0x2c - SGX Enabled status */ +u64 emna;/* 0x2d - 0x34 EPC base address */ +u64 elng;/* 0x35 - 0x3c EPC Length */ +u8 unused1[0x100 -0x3d ];/* Pad out to 256 bytes */ +u8 unused2[0x1000 -0x100 ];/* Pad out to 4096 bytes */ +}; + +#endif /* _GLOBAL_NVS_H_ */
Signature · 1 line
2.26.0.292.g33ef6b2f38-goog
PATCH v5 11/29 x86: apl: Add Global NVS table header
Quoted 18 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]>Reviewed-by Wolfgang Wallner <[email protected]>---
Changes in v5:
- Tweak unused naming and commentsChanges in v4:
- Fix indentation of unused
- Calculate the paddingChanges in v3:
- Fix stray #endif
Quoted 8 lines
Changes in v2:
- Drop the Chrome OS pieces
- Rename the 'coreboot' console to 'U-Boot'.../include/asm/arch-apollolake/global_nvs.h | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 arch/x86/include/asm/arch-apollolake/global_nvs.h
applied to u-boot-x86, thanks!
PATCH v5 12/29 dm: core: Add basic ACPI support
In reply to Simon GlassACPI (Advanced Configuration and Power Interface) is a standard for specifying information about a platform. It is a little like device tree but the bindings are part of the specification and 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.
---
Changes in v5:
- Capitalise ACPI_OPS_PTR since it includes a comma
Changes in v4: None
Changes in v3:
- Drop 'Intel' from 'Intel ACPI'
- Reword commit message to drop the bit about ACPI being complicated
- Compute ACPI_NAME_MAX from ACPI_NAME_LEN
- Rename acpi_return_name() to acpi_copy_name()
- Use strncpy() instead of strcpy() in acpi_copy_name()
Changes in v2:
- Move LOGC_ACPI definition to this patch
configs/tools-only_defconfig | 1 + drivers/core/Kconfig | 9 +++++ drivers/core/Makefile | 1 + drivers/core/acpi.c | 33 ++++++++++++++++ include/dm/acpi.h | 73 ++++++++++++++++++++++++++++++++++++ include/dm/device.h | 5 +++ include/log.h | 2 + 7 files changed, 124 insertions(+) create mode 100644 drivers/core/acpi.c create mode 100644 include/dm/acpi.h
configs/tools-only_defconfig +1 -0
@@ -26,3 +26,4 @@ CONFIG_SYSRESET=y # CONFIG_VIRTIO_PCI is not set # CONFIG_VIRTIO_SANDBOX is not set # CONFIG_EFI_LOADER is not set +# CONFIG_ACPIGEN is not set
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 +33 -0
@@ -0,0 +1,33 @@ +// 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_copy_name (char *out_name,const char *name) +{ +strncpy (out_name, name,ACPI_NAME_MAX ); + out_name[ACPI_NAME_LEN ] ='\0' ; + +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
@@ -245,6 +245,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;
@@ -264,6 +266,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 */
include/log.h +2 -0
@@ -51,6 +51,8 @@ enum log_category_t {LOGC_SANDBOX ,/* Related to the sandbox board */ LOGC_BLOBLIST ,/* Bloblist */ LOGC_DEVRES ,/* Device resources (devres_... functions) */ +/* Advanced Configuration and Power Interface (ACPI) */ +LOGC_ACPI ,LOGC_COUNT ,/* Number of log categories */ LOGC_END, /* Sentinel value for a list of log categories */
Signature · 1 line
2.26.0.292.g33ef6b2f38-goog
PATCH v5 12/29 dm: core: Add basic ACPI support
Quoted 17 lines · Simon Glass
ACPI (Advanced Configuration and Power Interface) is a standard for specifying information about a platform. It is a little like device tree but the bindings are part of the specification and 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/acpi.c line 18
Quoted 3 lines
drivers/core/acpi.c new file +3
-0+int acpi_copy_name (char *out_name,const char *name) +{ +strncpy (out_name, name,ACPI_NAME_MAX );
_LEN.
The idea as I tried to explain that name can have only 4 bytes at the end of the page. I dunno what U-Boot does if you access out of the boundaries to the page which is not mapped to MMU (in OSes it will be page fault). Does U-Boot map all pages to MMU?
In any case, the code above has this subtle issue. We may live with it, but since it's a generic kinda function, better to be pedantic about it.
Quoted 4 lines
drivers/core/acpi.c new file +4
-0+ out_name[ACPI_NAME_LEN ] ='\0' ; + +return 0 ; +}
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v5 12/29 dm: core: Add basic ACPI support
Hi Andy,
Quoted 25 lines · Andy Shevchenko
Quoted 17 lines · Simon Glass
ACPI (Advanced Configuration and Power Interface) is a standard for specifying information about a platform. It is a little like device tree but the bindings are part of the specification and 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/acpi.c line 18
Quoted 3 lines
drivers/core/acpi.c new file +3
-0+int acpi_copy_name (char *out_name,const char *name) +{ +strncpy (out_name, name,ACPI_NAME_MAX );
_LEN.
Quoted 8 lines
The idea as I tried to explain that name can have only 4 bytes at the end of the page. I dunno what U-Boot does if you access out of the boundaries to the page which is not mapped to MMU (in OSes it will be page fault). Does U-Boot map all pages to MMU?
In any case, the code above has this subtle issue. We may live with it, but since it's a generic kinda function, better to be pedantic about it.
OK I will change it. The documentation is pretty clear on how to use this function, but I suppose people might not read it.
Regards,
Simon
PATCH v5 13/29 dts: Add a binding for hid-over-i2c
In reply to Simon GlassAdd this binding from Linux v5.4.
---
Changes in v5: None
Changes in v4: None
Changes in v3:
- Split out hid-over-i2c into its own patch
Changes in v2: None
.../input/hid-over-i2c.txt | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 doc/device-tree-bindings/input/hid-over-i2c.txt
doc/device-tree-bindings/input/hid-over-i2c.txt new file +44 -0
@@ -0,0 +1,44 @@ +* HID over I2C Device-Tree bindings + +HID over I2C provides support for various Human Interface Devices over the +I2C bus. These devices can be for example touchpads, keyboards, touch screens +or sensors. + +The specification has been written by Microsoft and is currently available here: +http://msdn.microsoft.com/en-us/library/windows/hardware/hh852380.aspx + +If this binding is used, the kernel module i2c-hid will handle the communication +with the device and the generic hid core layer will handle the protocol. + +Required properties: +- compatible: must be "hid-over-i2c" +- reg: i2c slave address +- hid-descr-addr: HID descriptor address +- interrupts: interrupt line + +Additional optional properties: + +Some devices may support additional optional properties to help with, e.g., +power sequencing. The following properties can be supported by one or more +device-specific compatible properties, which should be used in addition to the +"hid-over-i2c" string. + +- compatible: + * "wacom,w9013" (Wacom W9013 digitizer). Supports: + - vdd-supply (3.3V) + - vddl-supply (1.8V) + - post-power-on-delay-ms + +- vdd-supply: phandle of the regulator that provides the supply voltage. +- post-power-on-delay-ms: time required by the device after enabling its regulators + or powering it on, before it is ready for communication. + +Example: + + i2c-hid-dev at 2c { + compatible = "hid-over-i2c"; + reg = <0x2c>; + hid-descr-addr = <0x0020>; + interrupt-parent = <&gpx3>; + interrupts = <3 2>; + };
Signature · 1 line
2.26.0.292.g33ef6b2f38-goog
PATCH v5 13/29 dts: Add a binding for hid-over-i2c
Quoted 11 lines · Simon Glass
Add this binding from Linux v5.4.
Signed-off-by Simon Glass <[email protected]>---
Changes in v5: None
Changes in v4: None
Changes in v3:
- Split out hid-over-i2c into its own patch
Quoted 6 lines
Changes in v2: None
.../input/hid-over-i2c.txt | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 doc/device-tree-bindings/input/hid-over-i2c.txt
PATCH v5 13/29 dts: Add a binding for hid-over-i2c
Quoted 13 lines · Bin Meng
Quoted 11 lines · Simon Glass
Add this binding from Linux v5.4.
Signed-off-by Simon Glass <[email protected]>---
Changes in v5: None
Changes in v4: None
Changes in v3:
- Split out hid-over-i2c into its own patch
Quoted 8 lines
Quoted 6 lines
Changes in v2: None
.../input/hid-over-i2c.txt | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 doc/device-tree-bindings/input/hid-over-i2c.txtReviewed-by Bin Meng <[email protected]>
applied to u-boot-x86, thanks!
PATCH v5 14/29 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.
---
Changes in v5: None
Changes in v4:
- Put 'interrupts-extended' property on one line
- Rename acpi-probed to linux,probed
- Note that linux,probed is an out-of-tree feature
Changes in v3:
- Drop mention of PRIC
- Rename acpi,desc to acpi,ddn
- Correct description of acpi,probed
- Drop hid-descr-addr
- Just add the device.txt binding file in this patch
- Change the example to ELAN
- Add a pointer to information about acpi,compatible
Changes in v2:
- Fix definition of HID
- Infer hid-over-i2c CID value
- Add the hid-over-i2c binding document
doc/device-tree-bindings/device.txt | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 doc/device-tree-bindings/device.txt
doc/device-tree-bindings/device.txt new file +36 -0
@@ -0,0 +1,36 @@ +Devices +======= + +Device bindings are described by their own individual binding files. + +U-Boot provides for some optional properties which are documented here. See +also hid-over-i2c.txt which describes HID devices. See also +Documentation/firmware-guide/acpi/enumeration.rst in the Linux kernel for +the acpi,compatible property. + + - acpi,has-power-resource : (boolean) true if this device has a power resource. + This causes an 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,compatible : compatible string to report + - acpi,ddn : Contains the string to use as the _DDN (DOS (Disk Operating + System) Device Name) + - acpi,hid : Contains the string to use as the HID (Hardware ID) + identifier _HID + - acpi,uid : _UID value for device + - linux,probed : Tells U-Boot to add 'linux,probed' to the ACPI tables so that + Linux will only load the driver if the device can be detected (e.g. on I2C + bus). Note that this is an out-of-tree Linux feature. + + +Example +------- + +elan_touchscreen: elan-touchscreen at 10 { + compatible = "i2c-chip"; + reg = <0x10>; + acpi,hid = "ELAN0001"; + acpi,ddn = "ELAN Touchscreen"; + interrupts-extended = <&acpi_gpe GPIO_21_IRQ IRQ_TYPE_EDGE_FALLING>; + linux,probed; +};
Signature · 1 line
2.26.0.292.g33ef6b2f38-goog
Antwort: [PATCH v5 14/29] acpi: Add a binding for ACPI settings in the device tree
Hi Simon,
-----"Simon Glass" <[email protected]> schrieb: -----
Quoted 93 lines
Betreff: [PATCH v5 14/29] acpi: Add a binding for ACPI settings in the device tree
Devices 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.
Signed-off-by Simon Glass <[email protected]>---
Changes in v5: None
Changes in v4:
- Put 'interrupts-extended' property on one line
- Rename acpi-probed to linux,probed
- Note that linux,probed is an out-of-tree featureChanges in v3:
- Drop mention of PRIC
- Rename acpi,desc to acpi,ddn
- Correct description of acpi,probed
- Drop hid-descr-addr
- Just add the device.txt binding file in this patch
- Change the example to ELAN
- Add a pointer to information about acpi,compatibleChanges in v2:
- Fix definition of HID
- Infer hid-over-i2c CID value
- Add the hid-over-i2c binding document
doc/device-tree-bindings/device.txt| 36
+++++++++++++++++++++++++++++1 file changed, 36 insertions(+)create mode 100644
doc/device-tree-bindings/device.txtdoc/device-tree-bindings/device.txt new file +6
-0@@ -0,0 +1,36 @@ +Devices +======= + +Device bindings are described by their own individual binding files. + +U-Boot provides for some optional properties which are documentedhere. See
doc/device-tree-bindings/device.txt new file +2
-0+also hid-over-i2c.txt which describes HID devices. See also +Documentation/firmware-guide/acpi/enumeration.rst in the Linuxkernel for
doc/device-tree-bindings/device.txt new file +3
-0+the acpi,compatible property. + + - acpi,has-power-resource : (boolean) true if this device has apower resource.
+ This causes an 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,compatible : compatible string to report
+ - acpi,ddn : Contains the string to use as the_DDN(DOS (Disk Operatingdoc/device-tree-bindings/device.txt new file +5
-0+ System) Device Name) + - acpi,hid : Contains the string to use as the HID (Hardware ID) + identifier _HID + - acpi,uid : _UID value for device + - linux,probed : Tells U-Boot to add 'linux,probed' to the ACPItables so that
+ Linux will only load the driver if the device can be detected
(e.g. on I2Cdoc/device-tree-bindings/device.txt new file +12
-0+ bus). Note that this is an out-of-tree Linux feature. + + +Example +------- + +elan_touchscreen: elan-touchscreen at 10 { + compatible = "i2c-chip"; + reg = <0x10>; + acpi,hid = "ELAN0001"; + acpi,ddn = "ELAN Touchscreen"; + interrupts-extended = <&acpi_gpe GPIO_21_IRQ
IRQ_TYPE_EDGE_FALLING>;doc/device-tree-bindings/device.txt new file +2
-0+ linux,probed; +};Signature · 1 line
2.26.0.292.g33ef6b2f38-goog
I have learned through the previous review discussions aspects about this binding which are not captured in the current patch. I tried to incorporate these findings, the modified text is proposed below.
Additionally, I realized that I still don't understand how some parts of the proposed binding are intended to work. I have highlighted these aspects with a TODO note. Please have a look.
regards, Wolfgang
--------------------------------------------------------------------------
Devices
=======
Device bindings are described by their own individual binding files. U-Boot provides for some optional properties which are documented here.
ACPI-related properties:
- acpi,compatible : ACPI devices may report a _HID or _CID of "PRP0001", in which case they are expected to provide a _DSD object with a "compatible" property. The value of this "compatible" property is specified by "acpi,compatible".
See also section 6.2.5 of [1] as well as [2-3] for details.
TODO: will PRP0001 be used as _HID or as _CID?
Note: the value for "acpi,compatible" can be different from the "compatible" property used in Devicetree for certain devices, e.g. when a custom driver in U-Boot would not make sense. An example would be touch screen devices.
- acpi,ddn : Contains the string to use as the _DDN (DOS (Disk Operating System) Device Name)
- acpi,has-power-resource : (boolean) true if this device has a power resource. This causes an 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
TODO: a list of the required properties for this to work would be helpful
- acpi,hid : Contains the string to use as the HID (Hardware ID) identifier _HID
TODO: How does this work togheter with "acpi, compatible"? (assuming "acpi,compatible" implies a _HID of "PRP0001")
- acpi,uid : _UID value for the device
[1] https://uefi.org/sites/default/files/resources/ACPI_6_3_final_Jan30.pdf
[2] Documentation/firmware-guide/acpi/enumeration.rst in the Linux kernel
[3] http://www.uefi.org/sites/default/files/resources/_DSD-device-properties-UUID.pdf
Other properties:
- linux,probed : With this property Linux can be told to only load the driver if the device can be detected (e.g. on I2C bus).
When generating ACPI tables, this property is adopted into a device's _DSD object.
Note that this is an out-of-tree Linux feature.
Example
-------
elan_touchscreen: elan-touchscreen at 10 {
compatible = "i2c-chip";
reg = <0x10>;
acpi,hid = "ELAN0001";
acpi,ddn = "ELAN Touchscreen";
acpi,uid = 1;
interrupts-extended = <&acpi_gpe GPIO_21_IRQ IRQ_TYPE_EDGE_FALLING>;
linux,probed;
};The example above would result in an ACPI entry similar to the following:
Device(DEV1) // TODO: how is the name ("DEV1" in this example) selected?
{
Name (_HID, "ELAN0001")
Name (_DDN, "ELAN Touchscreen")
Name (_UID, 1)
Name (_DSD, Package (0x02)
{
ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
Package (0x01)
{
Package (0x02) { "linux,probed", Package (0x01) {1} },
}
})
}--------------------------------------------------------------------------
I have dropped the sentence "See also hid-over-i2c.txt which describes HID devices.", as I don't think it is still required. HID devices are not mentioned any more as the previous hid-over-i2c example was dropped.
PATCH v5 14/29 acpi: Add a binding for ACPI settings in the device tree
Quoted 18 lines · Wolfgang Wallner
I have learned through the previous review discussions aspects about this binding which are not captured in the current patch. I tried to incorporate these findings, the modified text is proposed below.
Additionally, I realized that I still don't understand how some parts of the proposed binding are intended to work. I have highlighted these aspects with a TODO note. Please have a look.
regards, Wolfgang
--------------------------------------------------------------------------
Devices
=======Device bindings are described by their own individual binding files. U-Boot provides for some optional properties which are documented here.
Quoted 6 lines
ACPI-related properties:
- acpi,compatible : ACPI devices may report a
_HIDor_CIDof "PRP0001", in which case they are expected to provide a_DSDobject with a "compatible" property.
No, this is simple incorrect.
PRP0001 should not be mentioned at all. _DSD() as I said in the other thread is orthogonal to the ACPI ID.
Quoted 6 lines
The value of this "compatible" property is specified by
"acpi,compatible".
See also section 6.2.5 of [1] as well as [2-3] for details.TODO: will PRP0001 be used as
_HIDor as_CID?
None. Please, forget about PRP0001.
Quoted 2 lines
TODO: How does this work togheter with "acpi, compatible"? (assuming "acpi,compatible" implies a
_HIDof "PRP0001")
Ditto.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Antwort: Re: [PATCH v5 14/29] acpi: Add a binding for ACPI settings in the device tree
Hi Andy,
-----"Andy Shevchenko" <[email protected]> schrieb: -----
Quoted 2 lines
Betreff: Re: [PATCH v5 14/29] acpi: Add a binding for ACPI settings in the device tree
[snip]
Quoted 9 lines
Quoted 1 line
- acpi,compatible : ACPI devices may report a
_HIDor_CIDof"PRP0001", in
Quoted 1 line
which case they are expected to provide a
_DSDobject with a"compatible"
Quoted 1 line
property.
No, this is simple incorrect.
PRP0001 should not be mentioned at all._DSD()as I said in the other thread is orthogonal to the ACPI ID.
Can "acpi,compatible" work in another way (without PRP0001)? Or do you mean that "acpi,compatible" can't work at all?
As far as I see PRP0001 would be the only way to pass a "compatible" property in ACPI.
[snip]
regards, Wolfgang
PATCH v5 14/29 acpi: Add a binding for ACPI settings in the device tree
Quoted 1 line · Wolfgang Wallner
-----"Andy Shevchenko" <[email protected]> schrieb: -----
[snip]
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
- acpi,compatible : ACPI devices may report a
_HIDor_CIDof"PRP0001", in
Quoted 1 line
which case they are expected to provide a
_DSDobject with a"compatible"
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
property.
No, this is simple incorrect.
PRP0001 should not be mentioned at all._DSD()as I said in the other thread is orthogonal to the ACPI ID.Can "acpi,compatible" work in another way (without PRP0001)? Or do you mean that "acpi,compatible" can't work at all?
Oh yeah, it can't work, unfortunately.
So, compatible enumeration depends on PRP0001, which may not be advertised for the products, while end users can do that on their own. So, we may only generate ACPI excerpts for the devices that have an official ID allocated.
Quoted 2 lines
As far as I see PRP0001 would be the only way to pass a "compatible" property in ACPI.
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v5 14/29 acpi: Add a binding for ACPI settings in the device tree
In reply to Simon GlassHi Simon,
Quoted 25 lines · Simon Glass
Devices 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.
Signed-off-by Simon Glass <[email protected]>---
Changes in v5: None
Changes in v4:
- Put 'interrupts-extended' property on one line
- Rename acpi-probed to linux,probed
- Note that linux,probed is an out-of-tree featureChanges in v3:
- Drop mention of PRIC
- Rename acpi,desc to acpi,ddn
- Correct description of acpi,probed
- Drop hid-descr-addr
- Just add the device.txt binding file in this patch
- Change the example to ELAN
- Add a pointer to information about acpi,compatible
Quoted 9 lines
Changes in v2:
- Fix definition of HID
- Infer hid-over-i2c CID value
- Add the hid-over-i2c binding documentdoc/device-tree-bindings/device.txt | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 doc/device-tree-bindings/device.txt
It looks that there is still unclosed issue about this patch. I will leave this patch un-applied.
Regards,
Bin
PATCH v5 15/29 acpi: Add a simple sandbox test
In reply to Simon GlassAdd a sandbox test for the basic ACPI functionality we have so far.
---
Changes in v5:
- Capitalise ACPI_OPS_PTR since it includes a comma
Changes in v4: None
Changes in v3: None
Changes in v2:
- Add in the acpi_table.h header file to this patch
arch/sandbox/dts/test.dts | 4 ++ arch/sandbox/include/asm/acpi_table.h | 9 +++++ include/dm/uclass-id.h | 1 + test/dm/Makefile | 1 + test/dm/acpi.c | 55 +++++++++++++++++++++++++++ 5 files changed, 70 insertions(+) create mode 100644 arch/sandbox/include/asm/acpi_table.h 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";
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/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.26.0.292.g33ef6b2f38-goog
PATCH v5 15/29 acpi: Add a simple sandbox test
Quoted 16 lines · Simon Glass
Add a sandbox test for the basic ACPI functionality we have so far.
Signed-off-by Simon Glass <[email protected]>Reviewed-by Bin Meng <[email protected]>Reviewed-by Wolfgang Wallner <[email protected]>---
Changes in v5:
- CapitaliseACPI_OPS_PTRsince it includes a commaChanges in v4: None
Changes in v3: None
Changes in v2:
- Add in theacpi_table.hheader file to this patch
Quoted 9 lines
arch/sandbox/dts/test.dts | 4 ++ arch/sandbox/include/asm/acpi_table.h | 9 +++++ include/dm/uclass-id.h | 1 + test/dm/Makefile | 1 + test/dm/acpi.c | 55 +++++++++++++++++++++++++++ 5 files changed, 70 insertions(+) create mode 100644 arch/sandbox/include/asm/acpi_table.h create mode 100644 test/dm/acpi.c
applied to u-boot-x86, thanks!
PATCH v5 16/29 x86: Move acpi_s3.h to include/acpi/
In reply to Simon GlassThis header relates to ACPI and we are about to add some more ACPI headers. Move this one into a new directory so they are together.
The header inclusion in pci_rom.c is not specific to x86 anymore, so drop the #ifdef CONFIG_X86.
---
Changes in v5:
- Update commit message to mention dropping the #ifdef CONFIG_X86
Changes in v4: None
Changes in v3:
- Add new patch to move acpi_s3.h to include/acpi/
Changes in v2: None
arch/x86/cpu/apollolake/cpu_spl.c | 2 +-
arch/x86/cpu/apollolake/fsp_s.c | 2 +-
arch/x86/cpu/apollolake/pmc.c | 2 +-
arch/x86/cpu/baytrail/acpi.c | 4 ++--
arch/x86/cpu/cpu.c | 2 +-
arch/x86/cpu/wakeup.S | 2 +-
arch/x86/lib/acpi_s3.c | 2 +-
arch/x86/lib/coreboot_table.c | 2 +-
arch/x86/lib/fsp/fsp_common.c | 2 +-
arch/x86/lib/fsp1/fsp_common.c | 2 +-
arch/x86/lib/fsp2/fsp_dram.c | 2 +-
drivers/pci/pci_rom.c | 4 +---
drivers/power/acpi_pmc/acpi-pmc-uclass.c | 2 +-
drivers/sysreset/sysreset_x86.c | 2 +-
include/{ => acpi}/acpi_s3.h | 0
15 files changed, 15 insertions(+), 17 deletions(-)
rename include/{ => acpi}/acpi_s3.h (100%)arch/x86/cpu/apollolake/cpu_spl.c +1 -1
@@ -6,13 +6,13 @@*/ #include <common.h> -#include <acpi_s3.h> #include <dm.h> #include <ec_commands.h> #include <log.h> #include <spi_flash.h> #include <spl.h> #include <syscon.h> +#include <acpi/acpi_s3.h> #include <asm/cpu.h> #include <asm/cpu_common.h> #include <asm/cpu_x86.h>
arch/x86/cpu/apollolake/fsp_s.c +1 -1
@@ -5,11 +5,11 @@*/ #include <common.h> -#include <acpi_s3.h> #include <binman.h> #include <dm.h> #include <irq.h> #include <malloc.h> +#include <acpi/acpi_s3.h> #include <asm/intel_pinctrl.h> #include <asm/io.h> #include <asm/intel_regs.h>
arch/x86/cpu/apollolake/pmc.c +1 -1
@@ -9,10 +9,10 @@#define LOG_CATEGORY UCLASS_ACPI_PMC#include <common.h> -#include <acpi_s3.h> #include <dt-structs.h> #include <dm.h> #include <spl.h> +#include <acpi/acpi_s3.h> #include <asm/io.h> #include <asm/pci.h> #include <power/acpi_pmc.h>
arch/x86/cpu/baytrail/acpi.c +2 -2
@@ -4,15 +4,15 @@*/ #include <common.h> -#include <acpi_s3.h> #include <cpu.h> #include <dm.h> -#include <dm/uclass-internal.h> +#include <acpi/acpi_s3.h> #include <asm/acpi_table.h> #include <asm/io.h> #include <asm/tables.h> #include <asm/arch/global_nvs.h> #include <asm/arch/iomap.h> +#include <dm/uclass-internal.h> void acpi_create_fadt (struct acpi_fadt *fadt,struct acpi_facs *facs,void *dsdt)
arch/x86/cpu/cpu.c +1 -1
@@ -19,7 +19,6 @@*/ #include <common.h> -#include <acpi_s3.h> #include <command.h> #include <cpu_func.h> #include <dm.h>
@@ -27,6 +26,7 @@#include <init.h> #include <malloc.h> #include <syscon.h> +#include <acpi/acpi_s3.h> #include <asm/acpi.h> #include <asm/acpi_table.h> #include <asm/control_regs.h>
arch/x86/cpu/wakeup.S +1 -1
@@ -5,7 +5,7 @@ * From coreboot src/arch/x86/wakeup.S */ -#include <acpi_s3.h> +#include <acpi/acpi_s3.h> #include <asm/processor.h> #include <asm/processor-flags.h>
arch/x86/lib/acpi_s3.c +1 -1
@@ -4,7 +4,7 @@*/ #include <common.h> -#include <acpi_s3.h> +#include <acpi/acpi_s3.h> #include <asm/acpi.h> #include <asm/acpi_table.h> #include <asm/post.h>
arch/x86/lib/coreboot_table.c +1 -1
@@ -4,9 +4,9 @@*/ #include <common.h> -#include <acpi_s3.h> #include <malloc.h> #include <vbe.h> +#include <acpi/acpi_s3.h> #include <asm/coreboot_tables.h> #include <asm/e820.h>
arch/x86/lib/fsp/fsp_common.c +1 -1
@@ -4,11 +4,11 @@*/ #include <common.h> -#include <acpi_s3.h> #include <cpu_func.h> #include <dm.h> #include <errno.h> #include <rtc.h> +#include <acpi/acpi_s3.h> #include <asm/cmos_layout.h> #include <asm/early_cmos.h> #include <asm/io.h>
arch/x86/lib/fsp1/fsp_common.c +1 -1
@@ -4,11 +4,11 @@*/ #include <common.h> -#include <acpi_s3.h> #include <dm.h> #include <errno.h> #include <malloc.h> #include <rtc.h> +#include <acpi/acpi_s3.h> #include <asm/cmos_layout.h> #include <asm/early_cmos.h> #include <asm/io.h>
arch/x86/lib/fsp2/fsp_dram.c +1 -1
@@ -5,9 +5,9 @@*/ #include <common.h> -#include <acpi_s3.h> #include <handoff.h> #include <spl.h> +#include <acpi/acpi_s3.h> #include <asm/arch/cpu.h> #include <asm/fsp/fsp_support.h> #include <asm/fsp2/fsp_api.h>
drivers/pci/pci_rom.c +1 -3
@@ -33,12 +33,10 @@#include <vbe.h> #include <video.h> #include <video_fb.h> +#include <acpi/acpi_s3.h> #include <linux/screen_info.h> -#ifdef CONFIG_X86 -#include <acpi_s3.h> DECLARE_GLOBAL_DATA_PTR ; -#endif __weak bool board_should_run_oprom (struct udevice *dev) {
drivers/power/acpi_pmc/acpi-pmc-uclass.c +1 -1
@@ -6,9 +6,9 @@#define LOG_CATEGORY UCLASS_ACPI_PMC#include <common.h> -#include <acpi_s3.h> #include <dm.h> #include <log.h> +#include <acpi/acpi_s3.h> #ifdef CONFIG_X86 #include <asm/intel_pinctrl.h> #endif
drivers/sysreset/sysreset_x86.c +1 -1
@@ -6,11 +6,11 @@*/ #include <common.h> -#include <acpi_s3.h> #include <dm.h> #include <efi_loader.h> #include <pch.h> #include <sysreset.h> +#include <acpi/acpi_s3.h> #include <asm/io.h> #include <asm/processor.h>
include/acpi/acpi_s3.h renamed from include/acpi_s3.h +0 -0
Signature · 1 line
2.26.0.292.g33ef6b2f38-goog
Antwort: [PATCH v5 16/29] x86: Move acpi_s3.h to include/acpi/
Hi Simon,
-----"Simon Glass" <[email protected]> schrieb: -----
Quoted 38 lines
Betreff: [PATCH v5 16/29] x86: Move
acpi_s3.htoinclude/acpi/This header relates to ACPI and we are about to add some more ACPI headers. Move this one into a new directory so they are together.
The header inclusion in
pci_rom.cis not specific to x86 anymore, so drop
the #ifdefCONFIG_X86.Signed-off-by Simon Glass <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>---
Changes in v5:
- Update commit message to mention dropping the #ifdefCONFIG_X86Changes in v4: None
Changes in v3:
- Add new patch to moveacpi_s3.htoinclude/acpi/Changes in v2: None
arch/x86/cpu/apollolake/cpu_spl.c | 2 +- arch/x86/cpu/apollolake/fsp_s.c | 2 +- arch/x86/cpu/apollolake/pmc.c | 2 +- arch/x86/cpu/baytrail/acpi.c | 4 ++-- arch/x86/cpu/cpu.c | 2 +- arch/x86/cpu/wakeup.S | 2 +- arch/x86/lib/acpi_s3.c | 2 +- arch/x86/lib/coreboot_table.c | 2 +- arch/x86/lib/fsp/fsp_common.c | 2 +- arch/x86/lib/fsp1/fsp_common.c | 2 +- arch/x86/lib/fsp2/fsp_dram.c | 2 +- drivers/pci/pci_rom.c | 4 +--- drivers/power/acpi_pmc/acpi-pmc-uclass.c | 2 +- drivers/sysreset/sysreset_x86.c | 2 +- include/{ => acpi}/acpi_s3.h | 0 15 files changed, 15 insertions(+), 17 deletions(-)
Quoted 2 lines
rename
include/{=>acpi}/acpi_s3.h(100%)
PATCH v5 16/29 x86: Move acpi_s3.h to include/acpi/
In reply to Simon GlassQuoted 29 lines · Simon Glass
This header relates to ACPI and we are about to add some more ACPI headers. Move this one into a new directory so they are together.
The header inclusion in
pci_rom.cis not specific to x86 anymore, so drop the #ifdefCONFIG_X86.Signed-off-by Simon Glass <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>---
Changes in v5:
- Update commit message to mention dropping the #ifdefCONFIG_X86Changes in v4: None
Changes in v3:
- Add new patch to moveacpi_s3.htoinclude/acpi/Changes in v2: None
arch/x86/cpu/apollolake/cpu_spl.c | 2 +- arch/x86/cpu/apollolake/fsp_s.c | 2 +- arch/x86/cpu/apollolake/pmc.c | 2 +- arch/x86/cpu/baytrail/acpi.c | 4 ++-- arch/x86/cpu/cpu.c | 2 +- arch/x86/cpu/wakeup.S | 2 +- arch/x86/lib/acpi_s3.c | 2 +- arch/x86/lib/coreboot_table.c | 2 +- arch/x86/lib/fsp/fsp_common.c | 2 +-
Quoted 9 lines
arch/x86/lib/fsp1/fsp_common.c | 2 +-
arch/x86/lib/fsp2/fsp_dram.c | 2 +-
drivers/pci/pci_rom.c | 4 +---
drivers/power/acpi_pmc/acpi-pmc-uclass.c | 2 +-
drivers/sysreset/sysreset_x86.c | 2 +-
include/{ => acpi}/acpi_s3.h | 0
15 files changed, 15 insertions(+), 17 deletions(-)
rename include/{ => acpi}/acpi_s3.h (100%)PATCH v5 16/29 x86: Move acpi_s3.h to include/acpi/
In reply to Simon GlassQuoted 29 lines · Simon Glass
This header relates to ACPI and we are about to add some more ACPI headers. Move this one into a new directory so they are together.
The header inclusion in
pci_rom.cis not specific to x86 anymore, so drop the #ifdefCONFIG_X86.Signed-off-by Simon Glass <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>---
Changes in v5:
- Update commit message to mention dropping the #ifdefCONFIG_X86Changes in v4: None
Changes in v3:
- Add new patch to moveacpi_s3.htoinclude/acpi/Changes in v2: None
arch/x86/cpu/apollolake/cpu_spl.c | 2 +- arch/x86/cpu/apollolake/fsp_s.c | 2 +- arch/x86/cpu/apollolake/pmc.c | 2 +- arch/x86/cpu/baytrail/acpi.c | 4 ++-- arch/x86/cpu/cpu.c | 2 +- arch/x86/cpu/wakeup.S | 2 +- arch/x86/lib/acpi_s3.c | 2 +- arch/x86/lib/coreboot_table.c | 2 +- arch/x86/lib/fsp/fsp_common.c | 2 +-
Quoted 9 lines
arch/x86/lib/fsp1/fsp_common.c | 2 +-
arch/x86/lib/fsp2/fsp_dram.c | 2 +-
drivers/pci/pci_rom.c | 4 +---
drivers/power/acpi_pmc/acpi-pmc-uclass.c | 2 +-
drivers/sysreset/sysreset_x86.c | 2 +-
include/{ => acpi}/acpi_s3.h | 0
15 files changed, 15 insertions(+), 17 deletions(-)
rename include/{ => acpi}/acpi_s3.h (100%)applied to u-boot-x86, thanks!
PATCH v5 17/29 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 most of its contents to a common location.
---
Changes in v5: None
Changes in v4: None
Changes in v3:
- Update commit message to say that we move most of its contents
- Move acpi_table.h to include/acpi
- Add forward declarations for the functions
Changes in v2: None
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 | 4 +- arch/x86/include/asm/acpi_table.h | 381 +---------------------------- 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/acpi_table.h | 394 ++++++++++++++++++++++++++++++ lib/efi_loader/efi_acpi.c | 2 +- 12 files changed, 412 insertions(+), 385 deletions(-) create mode 100644 include/acpi/acpi_table.h
arch/x86/cpu/baytrail/acpi.c +1 -1
@@ -7,7 +7,7 @@#include <cpu.h> #include <dm.h> #include <acpi/acpi_s3.h> -#include <asm/acpi_table.h> +#include <acpi/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,8 +27,8 @@#include <malloc.h> #include <syscon.h> #include <acpi/acpi_s3.h> +#include <acpi/acpi_table.h> #include <asm/acpi.h> -#include <asm/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/acpi_table.h> #include <asm/tables.h> #include <asm/arch/global_nvs.h> #include <asm/arch/iomap.h>
arch/x86/cpu/tangier/acpi.c +2 -2
@@ -8,13 +8,13 @@#include <common.h> #include <cpu.h> #include <dm.h> -#include <dm/uclass-internal.h> -#include <asm/acpi_table.h> +#include <acpi/acpi_table.h> #include <asm/ioapic.h> #include <asm/mpspec.h> #include <asm/tables.h> #include <asm/arch/global_nvs.h> #include <asm/arch/iomap.h> +#include <dm/uclass-internal.h> void acpi_create_fadt (struct acpi_fadt *fadt,struct acpi_facs *facs,void *dsdt)
arch/x86/include/asm/acpi_table.h +7 -374
388 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/acpi_table.h> #include <asm/io.h> #include <asm/tables.h>
arch/x86/lib/acpi_s3.c +1 -1
@@ -5,8 +5,8 @@#include <common.h> #include <acpi/acpi_s3.h> +#include <acpi/acpi_table.h> #include <asm/acpi.h> -#include <asm/acpi_table.h> #include <asm/post.h> #include <linux/linkage.h>
arch/x86/lib/acpi_table.c +1 -1
@@ -12,8 +12,8 @@#include <dm/uclass-internal.h> #include <serial.h> #include <version.h> +#include <acpi/acpi_table.h> #include <asm/acpi/global_nvs.h> -#include <asm/acpi_table.h> #include <asm/ioapic.h> #include <asm/lapic.h> #include <asm/mpspec.h>
arch/x86/lib/tables.c +1 -1
@@ -6,10 +6,10 @@#include <common.h> #include <malloc.h> #include <smbios.h> +#include <acpi/acpi_table.h> #include <asm/sfi.h> #include <asm/mpspec.h> #include <asm/tables.h> -#include <asm/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/acpi_table.h> #include <asm/io.h> #include <asm/ptrace.h> #include <asm/zimage.h>
include/acpi/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/acpi_table.h> static const efi_guid_t acpi_guid =EFI_ACPI_TABLE_GUID ;
Signature · 1 line
2.26.0.292.g33ef6b2f38-goog
PATCH v5 17/29 x86: Move acpi_table header to main include/ directory
Quoted 18 lines · Simon Glass
This file is potentially useful to other architectures saddled with ACPI so move most of its contents to a common location.
Signed-off-by Simon Glass <[email protected]>Reviewed-by Bin Meng <[email protected]>Reviewed-by Wolfgang Wallner <[email protected]>---
Changes in v5: None
Changes in v4: None
Changes in v3:
- Update commit message to say that we move most of its contents
- Moveacpi_table.htoinclude/acpi
- Add forward declarations for the functionsChanges in v2: None
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 | 4 +- arch/x86/include/asm/acpi_table.h | 381 +---------------------------- 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/acpi_table.h | 394 ++++++++++++++++++++++++++++++ lib/efi_loader/efi_acpi.c | 2 +- 12 files changed, 412 insertions(+), 385 deletions(-) create mode 100644 include/acpi/acpi_table.h
applied to u-boot-x86, thanks!
PATCH v5 18/29 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.
---
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None
include/acpi/acpi_table.h | 4 ++++ include/dm/acpi.h | 4 ++++ scripts/Makefile.lib | 4 ++-- 3 files changed, 10 insertions(+), 2 deletions(-)
include/acpi/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 (ACPI_NAME_LEN + 1) +#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_copy_name (char *out_name,const char *name); +#endif /* __ACPI__ */ +#endif
scripts/Makefile.lib +2 -2
@@ -413,8 +413,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.26.0.292.g33ef6b2f38-goog
PATCH v5 18/29 acpi: Add an __ACPI__ preprocessor symbol
Quoted 19 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.
Signed-off-by Simon Glass <[email protected]>Reviewed-by Bin Meng <[email protected]>Reviewed-by Wolfgang Wallner <[email protected]>---
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None
Quoted 5 lines
include/acpi/acpi_table.h | 4 ++++ include/dm/acpi.h | 4 ++++ scripts/Makefile.lib | 4 ++-- 3 files changed, 10 insertions(+), 2 deletions(-)
applied to u-boot-x86, thanks!
PATCH v5 19/29 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.
---
Changes in v5:
- Mess with the table ordering a little more
Changes in v4:
- Move ACPI makefile line outside the ifdef CONFIG_SPL_BUILD
- Add a comment about the MADT table version
- Add SPCR
- Update comment to include tables defined or reserved by ACPI
Changes in v3:
- Fix file comment for acpi_table.c
- Fix a few typos
Changes in v2:
- Move the sandbox acpi_table.h header file to an earlier patch
- Use #defines for MADT and MCFG version numbers
include/acpi/acpi_table.h | 60 +++++++++++++++++++++++++++++++++++++ lib/Makefile | 1 + lib/acpi/Makefile | 4 +++ lib/acpi/acpi_table.c | 62 +++++++++++++++++++++++++++++++++++++++ test/dm/acpi.c | 14 +++++++++ 5 files changed, 141 insertions(+) create mode 100644 lib/acpi/Makefile create mode 100644 lib/acpi/acpi_table.c
include/acpi/acpi_table.h +60 -0
@@ -202,6 +202,26 @@ struct __packed acpi_fadt {struct acpi_gen_regaddr x_gpe1_blk; }; +/* FADT TABLE Revision values - note these do not match the ACPI revision */ +#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 + +/* MADT TABLE Revision values - note these do not match the ACPI revision */ +#define ACPI_MADT_REV_ACPI_3_0 2 +#define ACPI_MADT_REV_ACPI_4_0 3 +#define ACPI_MADT_REV_ACPI_5_0 3 +#define ACPI_MADT_REV_ACPI_6_0 5 + +#define ACPI_MCFG_REV_ACPI_3_0 1 + +/* 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 +411,46 @@ struct __packed acpi_spcr { u32 reserved2; }; +/* Tables defined/reserved by ACPI and generated by U-Boot */ +enum acpi_tables { +ACPITAB_BERT , +ACPITAB_DBG2 , +ACPITAB_DMAR , +ACPITAB_DSDT , +ACPITAB_ECDT , +ACPITAB_FACS , +ACPITAB_FADT , +ACPITAB_HEST , +ACPITAB_HPET , +ACPITAB_IVRS , +ACPITAB_MADT , +ACPITAB_MCFG , +ACPITAB_NHLT , +ACPITAB_RSDP , +ACPITAB_RSDT , +ACPITAB_SLIT , +ACPITAB_SPCR , +ACPITAB_SPMI , +ACPITAB_SRAT , +ACPITAB_SSDT , +ACPITAB_TCPA , +ACPITAB_TPM2 , +ACPITAB_VFCT , +ACPITAB_XSDT , + +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
@@ -58,6 +58,7 @@ obj-$(CONFIG_TPM_V1) += tpm-v1.o obj-$(CONFIG_TPM_V2) += tpm-v2.o endif +obj-$(CONFIG_$(SPL_)ACPIGEN) += acpi/ obj-$(CONFIG_$(SPL_)RSA) += rsa/ obj-$(CONFIG_SHA1) += sha1.o obj-$(CONFIG_SHA256) += sha256.o
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 +62 -0
62 lines not on this page · raw message
test/dm/acpi.c +14 -0
@@ -8,6 +8,7 @@#include <common.h> #include <dm.h> +#include <acpi/acpi_table.h> #include <dm/acpi.h> #include <dm/test.h> #include <test/ut.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.26.0.292.g33ef6b2f38-goog
PATCH v5 19/29 acpi: Add a central location for table version numbers
Quoted 29 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]>Reviewed-by Wolfgang Wallner <[email protected]>---
Changes in v5:
- Mess with the table ordering a little moreChanges in v4:
- Move ACPI makefile line outside the ifdefCONFIG_SPL_BUILD
- Add a comment about the MADT table version
- Add SPCR
- Update comment to include tables defined or reserved by ACPIChanges in v3:
- Fix file comment foracpi_table.c
- Fix a few typosChanges in v2:
- Move the sandboxacpi_table.hheader file to an earlier patch
- Use #defines for MADT and MCFG version numbers
Quoted 9 lines
include/acpi/acpi_table.h | 60 +++++++++++++++++++++++++++++++++++++ lib/Makefile | 1 + lib/acpi/Makefile | 4 +++ lib/acpi/acpi_table.c | 62 +++++++++++++++++++++++++++++++++++++++ test/dm/acpi.c | 14 +++++++++ 5 files changed, 141 insertions(+) create mode 100644 lib/acpi/Makefile create mode 100644 lib/acpi/acpi_table.c
PATCH v5 19/29 acpi: Add a central location for table version numbers
In reply to Simon GlassQuoted 29 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]>Reviewed-by Wolfgang Wallner <[email protected]>---
Changes in v5:
- Mess with the table ordering a little moreChanges in v4:
- Move ACPI makefile line outside the ifdefCONFIG_SPL_BUILD
- Add a comment about the MADT table version
- Add SPCR
- Update comment to include tables defined or reserved by ACPIChanges in v3:
- Fix file comment foracpi_table.c
- Fix a few typosChanges in v2:
- Move the sandboxacpi_table.hheader file to an earlier patch
- Use #defines for MADT and MCFG version numbers
Quoted 9 lines
include/acpi/acpi_table.h | 60 +++++++++++++++++++++++++++++++++++++ lib/Makefile | 1 + lib/acpi/Makefile | 4 +++ lib/acpi/acpi_table.c | 62 +++++++++++++++++++++++++++++++++++++++ test/dm/acpi.c | 14 +++++++++ 5 files changed, 141 insertions(+) create mode 100644 lib/acpi/Makefile create mode 100644 lib/acpi/acpi_table.c
applied to u-boot-x86, thanks!
PATCH v5 20/29 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.
---
Changes in v5:
- Add #ifndef CONFIG_SANDBOX to maintain bisectability without merging patches
Changes in v4:
- Drop ASL_REVISION
Changes in v3:
- Make use of BIT()
- Fix DMA_ typo
- Add missing error check in acpi_create_dmar()
- Drop duplicate assert
Changes in v2:
- Drop two unnecessary __packed
- Move __packed to after struct
include/acpi/acpi_table.h | 54 +++++++++++++++++++++++++++++++++++++++ lib/acpi/acpi_table.c | 31 ++++++++++++++++++++++ test/dm/acpi.c | 16 ++++++++++++ 3 files changed, 101 insertions(+)
include/acpi/acpi_table.h +54 -0
@@ -360,6 +360,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 =BIT (0 ) +}; + +enum dmar_flags { +DMAR_INTR_REMAP =BIT (0 ), +DMAR_X2APIC_OPT_OUT =BIT (1 ), +DMAR_CTRL_PLATFORM_OPT_IN_FLAG =BIT (2 ), +}; + +struct dmar_entry { +u16 type; +u16 length; +u8 flags; +u8 reserved; +u16 segment; +u64 bar; +}; + +struct dmar_rmrr_entry { +u16 type; +u16 length; +u16 reserved; +u16 segment; +u64 bar; +u64 limit; +}; + +/* DMAR (DMA Remapping Reporting Structure) */ +struct __packed acpi_dmar { +struct acpi_table_header header; +u8 host_address_width; +u8 flags; +u8 reserved[10 ]; +struct dmar_entry structure[0 ]; +}; +/* DBG2 definitions are partially used for SPCR interface_type */ /* Types for port_type field */
@@ -451,6 +496,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 +31 -0
@@ -7,6 +7,37 @@#include <common.h> #include <acpi/acpi_table.h> +#include <dm.h> +#include <cpu.h> + +/* Temporary change to ensure bisectability */ +#ifndef CONFIG_SANDBOX +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); +if (ret) +return log_msg_ret ("info" , ret); +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 ; +} +#endif int acpi_get_table_revision (enum acpi_tables table) {
test/dm/acpi.c +16 -0
@@ -67,3 +67,19 @@ 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 ); + +/* Temporary change to ensure bisectability */ +#ifndef CONFIG_SANDBOX +/* 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 (32 -1 , dmar.host_address_width); + +return 0 ; +} +DM_TEST (dm_test_acpi_create_dmar,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT ); +#endif
Signature · 1 line
2.26.0.292.g33ef6b2f38-goog
PATCH v5 20/29 acpi: Add support for DMAR
Quoted 24 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.
Reviewed-by Bin Meng <[email protected]>Reviewed-by Wolfgang Wallner <[email protected]>Signed-off-by Simon Glass <[email protected]>---
Changes in v5:
- Add #ifndefCONFIG_SANDBOXto maintain bisectability without merging patchesChanges in v4:
- DropASL_REVISIONChanges in v3:
- Make use ofBIT()
- FixDMA_typo
- Add missing error check inacpi_create_dmar()
- Drop duplicate assert
Quoted 9 lines
Changes in v2:
- Drop two unnecessary__packed
- Move__packedto after structinclude/acpi/acpi_table.h | 54 +++++++++++++++++++++++++++++++++++++++ lib/acpi/acpi_table.c | 31 ++++++++++++++++++++++ test/dm/acpi.c | 16 ++++++++++++ 3 files changed, 101 insertions(+)
applied to u-boot-x86, thanks!
PATCH v5 21/29 test: Add hexdump.h to the unit test header
In reply to Simon GlassSince ut_asserteq_mem() uses bin2hex() we should include this header in ut.h to avoid errors. Add it.
---
Changes in v5: None
Changes in v4: None
Changes in v3:
- Add new patch to add hexdump.h to the unit test header
Changes in v2: None
include/test/ut.h | 1 + 1 file changed, 1 insertion(+)
include/test/ut.h +1 -0
@@ -8,6 +8,7 @@#ifndef __TEST_UT_H#define __TEST_UT_H +#include <hexdump.h> #include <linux/err.h> struct unit_test_state ;
Signature · 1 line
2.26.0.292.g33ef6b2f38-goog
PATCH v5 21/29 test: Add hexdump.h to the unit test header
Quoted 13 lines · Simon Glass
Since
ut_asserteq_mem()usesbin2hex()we should include this header inut.hto avoid errors. Add it.Signed-off-by Simon Glass <[email protected]>Reviewed-by Wolfgang Wallner <[email protected]>---
Changes in v5: None
Changes in v4: None
Changes in v3:
- Add new patch to addhexdump.hto the unit test header
Quoted 5 lines
Changes in v2: None
include/test/ut.h | 1 + 1 file changed, 1 insertion(+)
applied to u-boot-x86, thanks!
PATCH v5 22/29 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.
---
Changes in v5:
- Drop bisectability changes
Changes in v4:
- Separate out the log newline
Changes in v3: None
Changes in v2:
- Drop definition of ACPI_TABLE_CREATOR
- Make _acpi_write_dev_tables() static and switch argument order
- Generalise the ACPI function recursion with acpi_recurse_method()
arch/sandbox/dts/test.dts | 4 +++ arch/x86/lib/acpi_table.c | 9 ----- drivers/core/acpi.c | 62 ++++++++++++++++++++++++++++++++ include/acpi/acpi_table.h | 10 ++++++ include/dm/acpi.h | 30 ++++++++++++++++ lib/acpi/acpi_table.c | 13 +++++-- test/dm/acpi.c | 74 +++++++++++++++++++++++++++++++++++++-- 7 files changed, 187 insertions(+), 15 deletions(-)
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";
arch/x86/lib/acpi_table.c +0 -9
@@ -60,15 +60,6 @@ static void acpi_write_rsdp(struct acpi_rsdp *rsdp, struct acpi_rsdt *rsdt, 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);
drivers/core/acpi.c +62 -0
73 lines not on this page · raw message
include/acpi/acpi_table.h +10 -0
@@ -505,6 +505,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>
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_copy_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
lib/acpi/acpi_table.c +10 -3
@@ -9,9 +9,8 @@#include <acpi/acpi_table.h> #include <dm.h> #include <cpu.h> +#include <version.h> -/* Temporary change to ensure bisectability */ -#ifndef CONFIG_SANDBOX int acpi_create_dmar (struct acpi_dmar *dmar,enum dmar_flags flags) {struct acpi_table_header *header = &dmar->header;
@@ -37,7 +36,6 @@ int acpi_create_dmar(struct acpi_dmar *dmar, enum dmar_flags flags)return 0 ; } -#endif int acpi_get_table_revision (enum acpi_tables table) {
@@ -91,3 +89,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 +71 -3
101 lines not on this page · raw message
Signature · 1 line
2.26.0.292.g33ef6b2f38-goog
PATCH v5 22/29 acpi: Add a method to write tables for a device
Hi Simon,
Quoted 20 lines · Simon Glass
A device may want to write out ACPI tables to describe itself to Linux. Add a method to permit this.
Reviewed-by Wolfgang Wallner <[email protected]>Signed-off-by Simon Glass <[email protected]>---
Changes in v5:
- Drop bisectability changesChanges in v4:
- Separate out the log newlineChanges in v3: None
Changes in v2:
- Drop definition ofACPI_TABLE_CREATOR
- Make_acpi_write_dev_tables()static and switch argument order
- Generalise the ACPI function recursion withacpi_recurse_method()
Quoted 9 lines
arch/sandbox/dts/test.dts | 4 +++ arch/x86/lib/acpi_table.c | 9 ----- drivers/core/acpi.c | 62 ++++++++++++++++++++++++++++++++ include/acpi/acpi_table.h | 10 ++++++ include/dm/acpi.h | 30 ++++++++++++++++ lib/acpi/acpi_table.c | 13 +++++-- test/dm/acpi.c | 74 +++++++++++++++++++++++++++++++++++++-- 7 files changed, 187 insertions(+), 15 deletions(-)
This patch does not apply on top of u-boot-x86/master. Please rebase and resubmit. I will leave the rest of the patches in this series un-applied.
Regards,
Bin
PATCH v5 23/29 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.
---
Changes in v5: None
Changes in v4:
- Update comment in acpi_inc_align() to show the alignment
Changes in v3:
- Rename acpi_align_large() to acpi_align64()
Changes in v2: None
arch/x86/lib/acpi_table.c | 88 +++++++++++++++++++-------------------- include/acpi/acpi_table.h | 36 ++++++++++++++++ lib/acpi/acpi_table.c | 24 ++++++++++- test/dm/acpi.c | 28 +++++++++++++ 4 files changed, 130 insertions(+), 46 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 <acpi/acpi_table.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
@@ -469,9 +471,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;
@@ -482,60 +484,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_align64 (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 ; } }
@@ -545,51 +548,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/acpi_table.h +36 -0
@@ -23,6 +23,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
@@ -515,6 +517,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_align64() - Align the ACPI output pointer to a 64-byte boundary +* +* @ctx: ACPI context +*/ +void acpi_align64 (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 to a 16-byte boundary +* +* @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 +23 -1
@@ -6,10 +6,11 @@*/ #include <common.h> -#include <acpi/acpi_table.h> #include <dm.h> #include <cpu.h> #include <version.h> +#include <acpi/acpi_table.h> +#include <dm/acpi.h> int acpi_create_dmar (struct acpi_dmar *dmar,enum dmar_flags flags) {
@@ -98,3 +99,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_align64 (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
@@ -151,3 +151,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_align64 (&ctx); +ut_asserteq_ptr ((void *)64 , ctx.current); +acpi_align64 (&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.26.0.292.g33ef6b2f38-goog
PATCH v5 24/29 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.
---
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None
arch/x86/lib/acpi_table.c | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/lib/acpi_table.c +2 -0
@@ -581,6 +581,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.26.0.292.g33ef6b2f38-goog
PATCH v5 25/29 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.
---
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None
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.26.0.292.g33ef6b2f38-goog
PATCH v5 26/29 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.
---
Changes in v5: None
Changes in v4: None
Changes in v3:
- Fix 'RSDP' typo
Changes in v2: None
arch/x86/lib/acpi_table.c | 83 +++++---------------------------------- include/acpi/acpi_table.h | 9 +++++ include/dm/acpi.h | 5 +++ lib/acpi/acpi_table.c | 61 ++++++++++++++++++++++++++++ test/dm/acpi.c | 4 ++ 5 files changed, 89 insertions(+), 73 deletions(-)
arch/x86/lib/acpi_table.c +10 -73
@@ -83,67 +83,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; - -/* The RSDT is mandatory while the XSDT is not */ - rsdt = (struct acpi_rsdt *)rsdp->rsdt_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); - -/* The RSDT is mandatory while the XSDT is not */ -if (!rsdp->xsdt_address) -return ; - -/* -* 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 -*/ - xsdt = (struct acpi_xsdt *)((u32 )rsdp->xsdt_address); - -/* 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 ));
@@ -463,8 +402,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;
@@ -486,9 +423,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 ));
@@ -501,8 +438,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" );
@@ -544,38 +481,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/acpi_table.h +9 -0
@@ -551,6 +551,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 RSDT 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 +61 -0
70 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.26.0.292.g33ef6b2f38-goog
PATCH v5 27/29 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.
---
Changes in v5: None
Changes in v4:
- Put back cast on table_compute_checksum()
Changes in v3:
- Fix 'XDST' typo
- Move acpi_align_large() out of dm_test_acpi_setup_base_tables()
- Beef up the comment explaining how the unaligned address is used
Changes in v2: None
arch/x86/lib/acpi_table.c | 72 +----------------------------------- include/acpi/acpi_table.h | 10 +++++ lib/acpi/acpi_table.c | 77 +++++++++++++++++++++++++++++++++++++++ test/dm/acpi.c | 58 ++++++++++++++++++++++++++++- 4 files changed, 144 insertions(+), 73 deletions(-)
arch/x86/lib/acpi_table.c +1 -71
@@ -31,58 +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 )); -} - -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 ));
@@ -402,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;
@@ -415,33 +362,16 @@ 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 )); +acpi_setup_base_tables (ctx, start);/* * Per ACPI spec, the FACS table address must be aligned to a 64 byte * boundary (Windows checks this, but Linux does not). */ acpi_align64 (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); -debug ("ACPI: * FACS\n" ); facs = ctx->current;acpi_inc_align (ctx,sizeof (struct acpi_facs ));
include/acpi/acpi_table.h +10 -0
@@ -560,6 +560,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 XSDT +* +* 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 +77 -0
80 lines not on this page · raw message
test/dm/acpi.c +56 -2
80 lines not on this page · raw message
Signature · 1 line
2.26.0.292.g33ef6b2f38-goog
Antwort: [PATCH v5 27/29] acpi: Put table-setup code in its own function
Hi Simon,
-----"Simon Glass" <[email protected]> schrieb: -----
Quoted 29 lines
Betreff: [PATCH v5 27/29] acpi: Put table-setup code in its own function
We always write three basic tables to ACPI at the start. Move this into
its own function, along withacpi_fill_header(), so we can write a test
for this code.Signed-off-by Simon Glass <[email protected]>---
Changes in v5: None
Changes in v4:
- Put back cast ontable_compute_checksum()Changes in v3:
- Fix 'XDST' typo
- Moveacpi_align_large()out ofdm_test_acpi_setup_base_tables()
- Beef up the comment explaining how the unaligned address is usedChanges in v2: None
arch/x86/lib/acpi_table.c | 72 +----------------------------------- include/acpi/acpi_table.h | 10 +++++ lib/acpi/acpi_table.c | 77 +++++++++++++++++++++++++++++++++++++++ test/dm/acpi.c | 58 ++++++++++++++++++++++++++++- 4 files changed, 144 insertions(+), 73 deletions(-)
[snip]
Quoted 4 lines
test/dm/acpi.c +0
-0
[snip]
Quoted 21 lines
test/dm/acpi.c +2
-0+/* Test acpi_setup_base_tables */ +static int dm_test_acpi_setup_base_tables(struct unit_test_state*uts)
test/dm/acpi.c +18
-0+{ +struct acpi_rsdp *rsdp; +struct acpi_rsdt *rsdt; +struct acpi_xsdt *xsdt; +struct acpi_ctx ctx; +void *buf, *end; + +/* +* Use an unaligned address deliberately, by allocating an aligned +* address and then adding 4 to it +*/ + buf =memalign (64 ,BUF_SIZE ); +ut_assertnonnull (buf); +acpi_setup_base_tables (&ctx, buf +4 ); + + rsdp = buf +16 ; +ut_asserteq_ptr (rsdp, ctx.rsdp); + ut_assertok(memcmp(RSDP_SIG, rsdp->signature,
Quoted 1 line
sizeof(rsdp->signature)));
Nit: could we also use ut_assertmem_eq() here? Similar to patch 22.
test/dm/acpi.c static int dm_test_acpi_basic(struct unit_test_state *uts) · line 221
Quoted 7 lines
test/dm/acpi.c +7
-0+ut_asserteq (sizeof (*rsdp), rsdp->length); +ut_assertok (table_compute_checksum (rsdp,20 )); +ut_assertok (table_compute_checksum (rsdp,sizeof (*rsdp))); + + rsdt =PTR_ALIGN ((void *)rsdp +sizeof (*rsdp),16 ); +ut_asserteq_ptr (rsdt, ctx.rsdt); +ut_assertok (memcmp ("RSDT" , rsdt->header.signature,ACPI_NAME_LEN ));
same here
test/dm/acpi.c static int dm_test_acpi_basic(struct unit_test_state *uts) · line 226
Quoted 5 lines
test/dm/acpi.c +5
-0+ut_asserteq (sizeof (*rsdt), rsdt->header.length); +ut_assertok (table_compute_checksum (rsdt,sizeof (*rsdt))); + + xsdt =PTR_ALIGN ((void *)rsdt +sizeof (*rsdt),16 ); +ut_assertok (memcmp ("XSDT" , xsdt->header.signature,ACPI_NAME_LEN ));
and here
Quoted 16 lines
test/dm/acpi.c +13
-0+ut_asserteq (sizeof (*xsdt), xsdt->header.length); +ut_assertok (table_compute_checksum (xsdt,sizeof (*xsdt))); + + end =PTR_ALIGN ((void *)xsdt +sizeof (*xsdt),64 ); +ut_asserteq_ptr (end, ctx.current); + +ut_asserteq (map_to_sysmem (rsdt), rsdp->rsdt_address); +ut_asserteq (map_to_sysmem (xsdt), rsdp->xsdt_address); + +return 0 ; +} +DM_TEST (dm_test_acpi_setup_base_tables, +DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT );Signature · 1 line
2.26.0.292.g33ef6b2f38-goog
PATCH v5 28/29 acpi: Move the xsdt pointer to acpi_ctx
In reply to Simon GlassPut this in the context along with the other important pointers.
---
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None
include/dm/acpi.h | 2 ++ lib/acpi/acpi_table.c | 10 ++++------ test/dm/acpi.c | 5 +++++ 3 files changed, 11 insertions(+), 6 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 RSDT 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 +4 -6
@@ -165,7 +165,7 @@ 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 */ - xsdt = (struct acpi_xsdt *)((uintptr_t )ctx->rsdp->xsdt_address); + xsdt = ctx->xsdt;/* Add table to the XSDT */ xsdt->entry[i] =map_to_sysmem (table);
@@ -236,8 +236,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 */
@@ -248,13 +246,13 @@ 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 ));/* 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
@@ -160,6 +160,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 );
@@ -223,6 +227,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.26.0.292.g33ef6b2f38-goog
PATCH v5 29/29 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.
---
Changes in v5: None
Changes in v4:
- Rename list_fact() to list_fadt()
- Add a comment to dump_hdr()
Changes in v3: None
Changes in v2: None
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 | 186 +++++++++++++++++++++++++ lib/acpi/acpi_table.c | 1 + test/dm/acpi.c | 73 ++++++++++ 7 files changed, 277 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 +186 -0
186 lines not on this page · raw message
lib/acpi/acpi_table.c +1 -0
@@ -240,6 +240,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.26.0.292.g33ef6b2f38-goog
v5 cover dm: Add programmatic generation of ACPI tables (part A)
In reply to Simon GlassHi Bin,
Quoted 186 lines · Simon Glass
This is split from the original series in an attempt to get things applied in chunks.
The first 20 or so patches here have been reviewed and the changes here incorporate those comments.
Changes in v5:
- Tweak unused naming and comments
- CapitaliseACPI_OPS_PTRsince it includes a comma
- CapitaliseACPI_OPS_PTRsince it includes a comma
- Update commit message to mention dropping the #ifdefCONFIG_X86
- Mess with the table ordering a little more
- Add #ifndefCONFIG_SANDBOXto maintain bisectability without merging patches
- Drop bisectability changesChanges in v4:
- Fix indentation of unused
- Calculate the padding
- Put 'interrupts-extended' property on one line
- Rename acpi-probed to linux,probed
- Note that linux,probed is an out-of-tree feature
- Move ACPI makefile line outside the ifdefCONFIG_SPL_BUILD
- Add a comment about the MADT table version
- Add SPCR
- Update comment to include tables defined or reserved by ACPI
- DropASL_REVISION
- Separate out the log newline
- Update comment inacpi_inc_align()to show the alignment
- Put back cast ontable_compute_checksum()
- Renamelist_fact()tolist_fadt()
- Add a comment todump_hdr()Changes in v3:
Drop acpi,name in example
- Fix indenting error mentioned by Andy Shevchenko
- Fix stray #endif
- Drop 'Intel' from 'Intel ACPI'
- Reword commit message to drop the bit about ACPI being complicated
- ComputeACPI_NAME_MAXfromACPI_NAME_LEN
- Renameacpi_return_name()toacpi_copy_name()
- Usestrncpy()instead ofstrcpy()inacpi_copy_name()
- Split out hid-over-i2c into its own patch
- Drop mention of PRIC
- Rename acpi,desc to acpi,ddn
- Correct description of acpi,probed
- Drop hid-descr-addr
- Just add the device.txt binding file in this patch
- Change the example to ELAN
- Add a pointer to information about acpi,compatible
- Add new patch to moveacpi_s3.htoinclude/acpi/
- Update commit message to say that we move most of its contents
- Moveacpi_table.htoinclude/acpi
- Add forward declarations for the functions
- Fix file comment foracpi_table.c
- Fix a few typos
- Make use ofBIT()
- FixDMA_typo
- Add missing error check inacpi_create_dmar()
- Drop duplicate assert
- Add new patch to addhexdump.hto the unit test header
- Renameacpi_align_large()toacpi_align64()
- Fix 'RSDP' typo
- Fix 'XDST' typo
- Moveacpi_align_large()out ofdm_test_acpi_setup_base_tables()
- Beef up the comment explaining how the unaligned address is usedChanges in v2:
- Don't bracket the definitions withDM_SPI
- Add trailing commas to enum
- Drop the other comment change since it is already applied
- Drop the Chrome OS pieces
- Rename the 'coreboot' console to 'U-Boot'
- MoveLOGC_ACPIdefinition to this patch
- Fix definition of HID
- Infer hid-over-i2c CID value
- Add the hid-over-i2c binding document
- Add in theacpi_table.hheader file to this patch
- Move the sandboxacpi_table.hheader file to an earlier patch
- Use #defines for MADT and MCFG version numbers
- Drop two unnecessary__packed
- Move__packedto after struct
- Drop definition ofACPI_TABLE_CREATOR
- Make_acpi_write_dev_tables()static and switch argument order
- Generalise the ACPI function recursion withacpi_recurse_method()Simon Glass (29):
cpu: Support querying the address width
spi: Add SPI mode enums
tpm: cr50: Release locality on exit
tpm: cr50: Add a comment forcr50_priv
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: Adjustdm_pci_read_bar32()to return errors correctly
x86: apl: Add Global NVS table header
dm: core: Add basic ACPI support
dts: Add a binding for hid-over-i2c
acpi: Add a binding for ACPI settings in the device tree
acpi: Add a simple sandbox test
x86: Moveacpi_s3.htoinclude/acpi/
x86: Moveacpi_tableheader to maininclude/directory
acpi: Add an__ACPI__preprocessor symbol
acpi: Add a central location for table version numbers
acpi: Add support for DMAR
test: Addhexdump.hto the unit test header
acpi: Add a method to write tables for a device
acpi: Convert part ofacpi_tableto useacpi_ctx
x86: Allow devices to write ACPI tables
acpi: Drop code for missing XSDT fromacpi_write_rsdp()
acpi: Moveacpi_add_table()to generic code
acpi: Put table-setup code in its own function
acpi: Move the xsdt pointer toacpi_ctx
acpi: Add an acpi commandarch/sandbox/dts/test.dts | 8 + arch/sandbox/include/asm/acpi_table.h | 9 + arch/sandbox/include/asm/global_data.h | 1 + arch/x86/cpu/apollolake/cpu_spl.c | 2 +- arch/x86/cpu/apollolake/fsp_s.c | 2 +- arch/x86/cpu/apollolake/pmc.c | 2 +- arch/x86/cpu/baytrail/acpi.c | 6 +- arch/x86/cpu/coreboot/timestamp.c | 4 +- arch/x86/cpu/cpu.c | 4 +- arch/x86/cpu/intel_common/p2sb.c | 33 +- arch/x86/cpu/quark/acpi.c | 2 +- arch/x86/cpu/tangier/acpi.c | 4 +- arch/x86/cpu/wakeup.S | 2 +- arch/x86/dts/chromebook_coral.dts | 2 +- arch/x86/include/asm/acpi_table.h | 381 +----------- .../include/asm/arch-apollolake/global_nvs.h | 36 ++ .../x86/include/asm/arch-coreboot/timestamp.h | 4 +- arch/x86/include/asm/global_data.h | 1 + arch/x86/include/asm/intel_pinctrl_defs.h | 2 - arch/x86/lib/acpi.c | 2 +- arch/x86/lib/acpi_s3.c | 4 +- arch/x86/lib/acpi_table.c | 241 ++------ arch/x86/lib/coreboot_table.c | 2 +- arch/x86/lib/fsp/fsp_common.c | 2 +- arch/x86/lib/fsp1/fsp_common.c | 2 +- arch/x86/lib/fsp2/fsp_dram.c | 2 +- arch/x86/lib/tables.c | 2 +- arch/x86/lib/zimage.c | 2 +- cmd/Kconfig | 14 + cmd/Makefile | 1 + cmd/acpi.c | 186 ++++++ configs/tools-only_defconfig | 1 + doc/device-tree-bindings/device.txt | 36 ++ .../gpio/intel,apl-gpio.txt | 2 +- .../input/hid-over-i2c.txt | 44 ++ .../interrupt-controller/intel,acpi-gpe.txt | 2 +- doc/device-tree-bindings/pci/x86-pci.txt | 23 + drivers/core/Kconfig | 9 + drivers/core/Makefile | 1 + drivers/core/acpi.c | 95 +++ drivers/cpu/cpu_sandbox.c | 1 + drivers/pci/pci-uclass.c | 11 +- drivers/pci/pci_rom.c | 4 +- drivers/power/acpi_pmc/acpi-pmc-uclass.c | 2 +- drivers/sysreset/sysreset_x86.c | 2 +- drivers/tpm/cr50_i2c.c | 24 +- drivers/tpm/tpm-uclass.c | 13 +- include/{ => acpi}/acpi_s3.h | 0 include/acpi/acpi_table.h | 577 ++++++++++++++++++ include/cpu.h | 2 + include/dm/acpi.h | 114 ++++ include/dm/device.h | 5 + include/dm/uclass-id.h | 1 + include/log.h | 2 + include/spi.h | 33 + include/test/ut.h | 1 + lib/Makefile | 1 + lib/acpi/Makefile | 4 + lib/acpi/acpi_table.c | 259 ++++++++ lib/efi_loader/efi_acpi.c | 2 +- scripts/Makefile.lib | 4 +- test/dm/Makefile | 1 + test/dm/acpi.c | 317 ++++++++++ test/dm/cpu.c | 1 + 64 files changed, 1921 insertions(+), 638 deletions(-) create mode 100644 arch/sandbox/include/asm/acpi_table.h create mode 100644 arch/x86/include/asm/arch-apollolake/global_nvs.h create mode 100644 cmd/acpi.c create mode 100644 doc/device-tree-bindings/device.txt
Quoted 8 lines
create mode 100644 doc/device-tree-bindings/input/hid-over-i2c.txt
create mode 100644 drivers/core/acpi.c
rename include/{ => acpi}/acpi_s3.h (100%)
create mode 100644 include/acpi/acpi_table.h
create mode 100644 include/dm/acpi.h
create mode 100644 lib/acpi/Makefile
create mode 100644 lib/acpi/acpi_table.c
create mode 100644 test/dm/acpi.cAny thoughts on this series and the chain-loading one please?
I would like to move on to part B.
Regards,
SImon
v5 cover dm: Add programmatic generation of ACPI tables (part A)
Hi Simon,
Quoted 199 lines · Simon Glass
Hi Bin,
Quoted 186 lines · Simon Glass
This is split from the original series in an attempt to get things applied in chunks.
The first 20 or so patches here have been reviewed and the changes here incorporate those comments.
Changes in v5:
- Tweak unused naming and comments
- CapitaliseACPI_OPS_PTRsince it includes a comma
- CapitaliseACPI_OPS_PTRsince it includes a comma
- Update commit message to mention dropping the #ifdefCONFIG_X86
- Mess with the table ordering a little more
- Add #ifndefCONFIG_SANDBOXto maintain bisectability without merging patches
- Drop bisectability changesChanges in v4:
- Fix indentation of unused
- Calculate the padding
- Put 'interrupts-extended' property on one line
- Rename acpi-probed to linux,probed
- Note that linux,probed is an out-of-tree feature
- Move ACPI makefile line outside the ifdefCONFIG_SPL_BUILD
- Add a comment about the MADT table version
- Add SPCR
- Update comment to include tables defined or reserved by ACPI
- DropASL_REVISION
- Separate out the log newline
- Update comment inacpi_inc_align()to show the alignment
- Put back cast ontable_compute_checksum()
- Renamelist_fact()tolist_fadt()
- Add a comment todump_hdr()Changes in v3:
Drop acpi,name in example
- Fix indenting error mentioned by Andy Shevchenko
- Fix stray #endif
- Drop 'Intel' from 'Intel ACPI'
- Reword commit message to drop the bit about ACPI being complicated
- ComputeACPI_NAME_MAXfromACPI_NAME_LEN
- Renameacpi_return_name()toacpi_copy_name()
- Usestrncpy()instead ofstrcpy()inacpi_copy_name()
- Split out hid-over-i2c into its own patch
- Drop mention of PRIC
- Rename acpi,desc to acpi,ddn
- Correct description of acpi,probed
- Drop hid-descr-addr
- Just add the device.txt binding file in this patch
- Change the example to ELAN
- Add a pointer to information about acpi,compatible
- Add new patch to moveacpi_s3.htoinclude/acpi/
- Update commit message to say that we move most of its contents
- Moveacpi_table.htoinclude/acpi
- Add forward declarations for the functions
- Fix file comment foracpi_table.c
- Fix a few typos
- Make use ofBIT()
- FixDMA_typo
- Add missing error check inacpi_create_dmar()
- Drop duplicate assert
- Add new patch to addhexdump.hto the unit test header
- Renameacpi_align_large()toacpi_align64()
- Fix 'RSDP' typo
- Fix 'XDST' typo
- Moveacpi_align_large()out ofdm_test_acpi_setup_base_tables()
- Beef up the comment explaining how the unaligned address is usedChanges in v2:
- Don't bracket the definitions withDM_SPI
- Add trailing commas to enum
- Drop the other comment change since it is already applied
- Drop the Chrome OS pieces
- Rename the 'coreboot' console to 'U-Boot'
- MoveLOGC_ACPIdefinition to this patch
- Fix definition of HID
- Infer hid-over-i2c CID value
- Add the hid-over-i2c binding document
- Add in theacpi_table.hheader file to this patch
- Move the sandboxacpi_table.hheader file to an earlier patch
- Use #defines for MADT and MCFG version numbers
- Drop two unnecessary__packed
- Move__packedto after struct
- Drop definition ofACPI_TABLE_CREATOR
- Make_acpi_write_dev_tables()static and switch argument order
- Generalise the ACPI function recursion withacpi_recurse_method()Simon Glass (29):
cpu: Support querying the address width
spi: Add SPI mode enums
tpm: cr50: Release locality on exit
tpm: cr50: Add a comment forcr50_priv
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: Adjustdm_pci_read_bar32()to return errors correctly
x86: apl: Add Global NVS table header
dm: core: Add basic ACPI support
dts: Add a binding for hid-over-i2c
acpi: Add a binding for ACPI settings in the device tree
acpi: Add a simple sandbox test
x86: Moveacpi_s3.htoinclude/acpi/
x86: Moveacpi_tableheader to maininclude/directory
acpi: Add an__ACPI__preprocessor symbol
acpi: Add a central location for table version numbers
acpi: Add support for DMAR
test: Addhexdump.hto the unit test header
acpi: Add a method to write tables for a device
acpi: Convert part ofacpi_tableto useacpi_ctx
x86: Allow devices to write ACPI tables
acpi: Drop code for missing XSDT fromacpi_write_rsdp()
acpi: Moveacpi_add_table()to generic code
acpi: Put table-setup code in its own function
acpi: Move the xsdt pointer toacpi_ctx
acpi: Add an acpi commandarch/sandbox/dts/test.dts | 8 + arch/sandbox/include/asm/acpi_table.h | 9 + arch/sandbox/include/asm/global_data.h | 1 + arch/x86/cpu/apollolake/cpu_spl.c | 2 +- arch/x86/cpu/apollolake/fsp_s.c | 2 +- arch/x86/cpu/apollolake/pmc.c | 2 +- arch/x86/cpu/baytrail/acpi.c | 6 +- arch/x86/cpu/coreboot/timestamp.c | 4 +- arch/x86/cpu/cpu.c | 4 +- arch/x86/cpu/intel_common/p2sb.c | 33 +- arch/x86/cpu/quark/acpi.c | 2 +- arch/x86/cpu/tangier/acpi.c | 4 +- arch/x86/cpu/wakeup.S | 2 +- arch/x86/dts/chromebook_coral.dts | 2 +- arch/x86/include/asm/acpi_table.h | 381 +----------- .../include/asm/arch-apollolake/global_nvs.h | 36 ++ .../x86/include/asm/arch-coreboot/timestamp.h | 4 +- arch/x86/include/asm/global_data.h | 1 + arch/x86/include/asm/intel_pinctrl_defs.h | 2 - arch/x86/lib/acpi.c | 2 +- arch/x86/lib/acpi_s3.c | 4 +- arch/x86/lib/acpi_table.c | 241 ++------ arch/x86/lib/coreboot_table.c | 2 +- arch/x86/lib/fsp/fsp_common.c | 2 +- arch/x86/lib/fsp1/fsp_common.c | 2 +- arch/x86/lib/fsp2/fsp_dram.c | 2 +- arch/x86/lib/tables.c | 2 +- arch/x86/lib/zimage.c | 2 +- cmd/Kconfig | 14 + cmd/Makefile | 1 + cmd/acpi.c | 186 ++++++ configs/tools-only_defconfig | 1 + doc/device-tree-bindings/device.txt | 36 ++ .../gpio/intel,apl-gpio.txt | 2 +- .../input/hid-over-i2c.txt | 44 ++ .../interrupt-controller/intel,acpi-gpe.txt | 2 +- doc/device-tree-bindings/pci/x86-pci.txt | 23 + drivers/core/Kconfig | 9 + drivers/core/Makefile | 1 + drivers/core/acpi.c | 95 +++ drivers/cpu/cpu_sandbox.c | 1 + drivers/pci/pci-uclass.c | 11 +- drivers/pci/pci_rom.c | 4 +- drivers/power/acpi_pmc/acpi-pmc-uclass.c | 2 +- drivers/sysreset/sysreset_x86.c | 2 +- drivers/tpm/cr50_i2c.c | 24 +- drivers/tpm/tpm-uclass.c | 13 +- include/{ => acpi}/acpi_s3.h | 0 include/acpi/acpi_table.h | 577 ++++++++++++++++++ include/cpu.h | 2 + include/dm/acpi.h | 114 ++++ include/dm/device.h | 5 + include/dm/uclass-id.h | 1 + include/log.h | 2 + include/spi.h | 33 + include/test/ut.h | 1 + lib/Makefile | 1 + lib/acpi/Makefile | 4 + lib/acpi/acpi_table.c | 259 ++++++++ lib/efi_loader/efi_acpi.c | 2 +- scripts/Makefile.lib | 4 +- test/dm/Makefile | 1 + test/dm/acpi.c | 317 ++++++++++ test/dm/cpu.c | 1 + 64 files changed, 1921 insertions(+), 638 deletions(-) create mode 100644 arch/sandbox/include/asm/acpi_table.h create mode 100644 arch/x86/include/asm/arch-apollolake/global_nvs.h create mode 100644 cmd/acpi.c create mode 100644 doc/device-tree-bindings/device.txtQuoted 8 lines
create mode 100644 doc/device-tree-bindings/input/hid-over-i2c.txt create mode 100644 drivers/core/acpi.c rename include/{ => acpi}/acpi_s3.h (100%) create mode 100644 include/acpi/acpi_table.h create mode 100644 include/dm/acpi.h create mode 100644 lib/acpi/Makefile create mode 100644 lib/acpi/acpi_table.c create mode 100644 test/dm/acpi.c
Quoted 3 lines
Any thoughts on this series and the chain-loading one please?
I would like to move on to part B.
Yes, I am looking at this series. Please see my reply in another thread.
Regards,
Bin