Skip to content

dm: Add programmatic generation of ACPI tables (part B)

Simon Glass u-boot 5 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest35 patches 0 repliesNew
  2. v335 patches 0 repliesSuperseded
  3. v2 posting 2/20 of 35 patches 0 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v2 posting 1/235 patches11 repliesSuperseded
v135 patches2 repliesSuperseded

Changes in v4 from the cover letter · 53 lines

- Add a comment about sandbox to dm_test_irq_get_acpi()
- Setup ctx->base as well as ctx->current in acpi_setup_base_tables()
- Add a comment about little-endian in acpigen_emit_dword()
- Add a #define for the context size in alloc_context()
- Rename the length-writing functions to indicate they are for large resources
- Use memset() to zero struct acpi_gpio in gpio_get_acpi()
- Move common code about the if...else in sb_gpio_get_acpi()
- Don't set zero fields in sb_gpio_get_acpi(), and add a comment about it
- Update acpi_device_write_interrupt_irq() to return IRQ pin number
- Use NULL instead of NUL and drop the 'NUL character' comment
- Drop comment about the type always being ACPI_GPIO_TYPE_IO
- Rename the length-writing functions to indicate they are for large resources
- Update functions to return a GPIO pin number
- Update functions to return GPIO/IRQ pin number
- Move SPI macros to next patch
- Rename the length-writing functions to indicate they are for large
- Update functions to return GPIO/IRQ pin number
- Move SPI macros to next patch
- Rename the length-writing functions to indicate they are for large resources
- Add a note about the hard-coded 3-byte length used
- Fix 'gas' typo
- Use 'null' instead of 'nul'
- Use 'writing' instead of emitting in test comment
- Use 'writing' instead of emitting in test comment
- Change 'nul' to 'null' in commit message and acpigen_write_string()
- Move emit->write comment changes to previous patches
- s/nul/null/ in the comment
- Drop embedded // comments in file comment
- Correct return value comment in acpi_dp_add_child()
- Rename acpi_dp_write_() to acpi_dp_write_internal() and make static
- Use a #define for the test context size
- Add a header file for test to allow sharing the context init function
- Rename and get_length() into a shared test file
- Add missing arg to comment for acpi_dp_write()
- Correct reference to device tree in the commit message
- Squash in comment change to an earlier patch
- Rename acpigen_write_method_()
- Use acpi_test_get_length() instead of get_length()
- Use acpi_test_get_length() instead of get_length()
- Update functions to return GPIO/IRQ pin number
- Use a separate variables for reading and writing DW0
- Correct bug in acpigen_set_gpio_val() by putting tx_state_val in LOCAL0
- Fix up the comment for acpigen_set_enable_tx_gpio()
- Explain access to DW0 register a bit better and provide a sample
- Expand the comments for acpigen_get_dw0_in_local5()
- Fix 'diabl' typo
- Use new shared acpi_test_alloc_context_size() in test
- Update functions to return GPIO/IRQ pin number
- Use a separate variables for reading and writing DW0
- Explain in sort_acpi_item_type() why ctx->current is not updated
- Explain why 'fill' is used for one method and 'inject' for another
- Mention that acpi_device_infer_name() only supports x86
- Add a comment about only supporting USB3.0

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/35dm: core: Add an ACPI name for the root nodedrivers/core/root.c+13 -00 replies
2/35acpi: Add a function to get a device path and scopearch/sandbox/dts/test.dts include/acpi/acpi_device.h lib/acpi/Makefile +2 more+213 -130 replies
3/35acpi: Add a way to check device statusinclude/acpi/acpi_device.h lib/acpi/acpi_device.c test/dm/acpi.c+45 -00 replies
4/35irq: Add a method to convert an interrupt to ACPIdrivers/misc/irq-uclass.c drivers/misc/irq_sandbox.c include/acpi/acpi_device.h +2 more+157 -20 replies
5/35acpi: Support generation of ACPI codeinclude/acpi/acpigen.h include/dm/acpi.h lib/acpi/Makefile +4 more+165 -01 reply
6/35acpi: Support generation of interrupt descriptorinclude/acpi/acpi_device.h lib/acpi/acpi_device.c test/dm/acpigen.c+166 -01 reply
7/35gpio: Add a method to convert a GPIO to ACPIdrivers/gpio/gpio-uclass.c drivers/gpio/sandbox.c include/acpi/acpi_device.h +2 more+278 -01 reply
8/35acpi: Support string outputinclude/acpi/acpigen.h lib/acpi/acpigen.c test/dm/acpigen.c+75 -00 replies
9/35acpi: Support generation of GPIO descriptorinclude/acpi/acpi_device.h lib/acpi/acpi_device.c test/dm/acpigen.c+264 -02 replies
10/35acpi: Support generation of a GPIO/irq for a deviceinclude/acpi/acpi_device.h lib/acpi/acpi_device.c test/dm/acpigen.c+86 -10 replies
11/35acpi: Support generation of I2C descriptordrivers/i2c/sandbox_i2c.c drivers/rtc/sandbox_rtc.c include/acpi/acpi_device.h +2 more+196 -00 replies
12/35acpi: Support generation of SPI descriptordrivers/spi/sandbox_spi.c include/acpi/acpi_device.h include/spi.h +2 more+212 -22 replies
12/35acpi: Support generation of SPI descriptor+0 -00 replies
13/35acpigen: Support writing a lengthinclude/acpi/acpigen.h include/dm/acpi.h lib/acpi/acpigen.c +1 more+144 -31 reply
14/35acpigen: Support writing a packageinclude/acpi/acpigen.h lib/acpi/acpigen.c test/dm/acpigen.c+71 -00 replies
15/35acpi: Support writing an integerinclude/acpi/acpigen.h lib/acpi/acpigen.c test/dm/acpigen.c+114 -00 replies
16/35acpi: Support writing a stringinclude/acpi/acpigen.h lib/acpi/acpigen.c test/dm/acpigen.c+44 -00 replies
17/35acpi: Support writing a nameinclude/acpi/acpigen.h include/test/ut.h lib/acpi/acpigen.c +1 more+231 -00 replies
18/35acpi: Support writing a UUIDinclude/acpi/acpigen.h lib/acpi/acpigen.c test/dm/acpigen.c+84 -00 replies
19/35acpi: Support writing Device Properties objects via _DSDinclude/acpi/acpi_dp.h include/acpi/acpigen.h lib/acpi/Makefile +5 more+974 -221 reply
20/35acpi: Support writing a GPIOinclude/acpi/acpi_dp.h lib/acpi/acpi_dp.c test/dm/acpi_dp.c+83 -00 replies
21/35acpi: Support copying properties from device tree to ACPIarch/sandbox/dts/test.dts include/acpi/acpi_dp.h lib/acpi/acpi_dp.c +1 more+174 -00 replies
22/35acpi: Add support for various misc ACPI opcodesinclude/acpi/acpigen.h lib/acpi/acpigen.c test/dm/acpigen.c+278 -00 replies
23/35acpi: Add support for writing a Power Resourceinclude/acpi/acpigen.h lib/acpi/acpigen.c test/dm/acpigen.c+85 -00 replies
24/35acpi: Add support for writing a GPIO power sequenceinclude/acpi/acpigen.h lib/acpi/acpigen.c test/dm/acpigen.c+205 -01 reply
25/35acpi: Add support for a generic power sequenceinclude/acpi/acpi_device.h lib/acpi/acpi_device.c test/dm/acpigen.c+209 -01 reply
26/35acpi: Add support for SSDT generationarch/sandbox/dts/test.dts drivers/core/acpi.c include/dm/acpi.h +1 more+81 -00 replies
27/35x86: acpi: Move MADT down a bitarch/x86/lib/acpi_table.c+6 -60 replies
28/35acpi: Record the items added to SSDTdrivers/core/acpi.c+79 -40 replies
29/35acpi: Support ordering SSDT data by devicearch/sandbox/dts/test.dts doc/device-tree-bindings/chosen.txt drivers/core/acpi.c +1 more+105 -82 replies
30/35x86: Allow devices to write an SSDTarch/x86/lib/acpi_table.c+29 -00 replies
31/35acpi: Add support for DSDT generationarch/sandbox/dts/test.dts drivers/core/acpi.c include/dm/acpi.h +1 more+100 -12 replies
32/35x86: Allow devices to write to DSDTarch/x86/lib/acpi_table.c+15 -10 replies
33/35pci: Avoid a crash in device_is_on_pci_bus()include/dm/device.h test/dm/pci.c+15 -10 replies
34/35dm: acpi: Enhance acpi_get_name()arch/sandbox/dts/test.dts doc/device-tree-bindings/device.txt drivers/core/acpi.c +5 more+190 -231 reply
35/35acpi: Add an acpi command to list/dump generated ACPI itemscmd/acpi.c drivers/core/acpi.c include/dm/acpi.h +1 more+84 -20 replies

Reviews trailers per patch

All 36 patches have a Reviewed-by or Acked-by.

PatchWolfgang WallnerBin Meng
1/35R-b R-b
2/35R-b R-b
3/35R-b R-b
4/35R-b R-b
5/35R-b R-b
6/35R-b R-b
7/35R-b R-b
8/35R-b R-b
9/35R-b R-b
10/35R-b R-b
11/35R-b R-b
12/35R-b R-b
12/35R-b R-b
13/35R-b R-b
14/35R-b R-b
15/35R-b R-b
16/35R-b R-b
17/35R-b R-b
18/35R-b R-b
19/35R-b R-b
20/35R-b R-b
21/35R-b R-b
22/35R-b R-b
23/35R-b R-b
24/35R-b R-b
25/35R-b R-b
26/35R-b R-b
27/35R-b R-b
28/35R-b R-b
29/35R-b R-b
30/35R-b R-b
31/35R-b R-b
32/35R-b R-b
33/35R-b R-b
34/35R-b R-b
35/35R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [PATCH v4 00/35] dm: Add programmatic generation of ACPI tables (part B)

This is split from the original series in an attempt to get things applied in chunks.

This part includes:
- writing basic ACPI code for integers, strings, names, packages
- writing descriptors for GPIO, I2C, interrupts, SPI
- writing code to enable/disable ACPI peripherals via GPIOs
- writing SSDT and DSDT tables
- additional ways to determine ACPI device names

Much of this code is taken from coreboot and I have tried to avoid changing the original code for no reason. Changes include:
- splitting the acpi_dp functions into their own file
- adding tests
- adding (lots of) comments
- using a context pointer instead of global variables
- tidying up some code where couldn't resist (e.g. acpigen_emit_namestring())

Changes in v4:
- Add a comment about sandbox to dm_test_irq_get_acpi()
- Setup ctx->base as well as ctx->current in acpi_setup_base_tables()
- Add a comment about little-endian in acpigen_emit_dword()
- Add a #define for the context size in alloc_context()
- Rename the length-writing functions to indicate they are for large resources
- Use memset() to zero struct acpi_gpio in gpio_get_acpi()
- Move common code about the if...else in sb_gpio_get_acpi()
- Don't set zero fields in sb_gpio_get_acpi(), and add a comment about it
- Update acpi_device_write_interrupt_irq() to return IRQ pin number
- Use NULL instead of NUL and drop the 'NUL character' comment
- Drop comment about the type always being ACPI_GPIO_TYPE_IO
- Rename the length-writing functions to indicate they are for large resources
- Update functions to return a GPIO pin number
- Update functions to return GPIO/IRQ pin number
- Move SPI macros to next patch
- Rename the length-writing functions to indicate they are for large
- Update functions to return GPIO/IRQ pin number
- Move SPI macros to next patch
- Rename the length-writing functions to indicate they are for large resources
- Add a note about the hard-coded 3-byte length used
- Fix 'gas' typo
- Use 'null' instead of 'nul'
- Use 'writing' instead of emitting in test comment
- Use 'writing' instead of emitting in test comment
- Change 'nul' to 'null' in commit message and acpigen_write_string()
- Move emit->write comment changes to previous patches
- s/nul/null/ in the comment
- Drop embedded // comments in file comment
- Correct return value comment in acpi_dp_add_child()
- Rename acpi_dp_write_() to acpi_dp_write_internal() and make static
- Use a #define for the test context size
- Add a header file for test to allow sharing the context init function
- Rename and get_length() into a shared test file
- Add missing arg to comment for acpi_dp_write()
- Correct reference to device tree in the commit message
- Squash in comment change to an earlier patch
- Rename acpigen_write_method_()
- Use acpi_test_get_length() instead of get_length()
- Use acpi_test_get_length() instead of get_length()
- Update functions to return GPIO/IRQ pin number
- Use a separate variables for reading and writing DW0
- Correct bug in acpigen_set_gpio_val() by putting tx_state_val in LOCAL0
- Fix up the comment for acpigen_set_enable_tx_gpio()
- Explain access to DW0 register a bit better and provide a sample
- Expand the comments for acpigen_get_dw0_in_local5()
- Fix 'diabl' typo
- Use new shared acpi_test_alloc_context_size() in test
- Update functions to return GPIO/IRQ pin number
- Use a separate variables for reading and writing DW0
- Explain in sort_acpi_item_type() why ctx->current is not updated
- Explain why 'fill' is used for one method and 'inject' for another
- Mention that acpi_device_infer_name() only supports x86
- Add a comment about only supporting USB3.0

Changes in v3:
- s/NUL/NULL/ for the NUL character, since that is in more common use
- Fix 'an GPIO is found' typo
- Update comment in acpi_device_set_i2c() to talk about scope parameter
- Make acpi_device_write_spi() static
- Add an extra comment about scope to acpi_device_set_spi()
- Use BIT() in a few places
- Resist the temptation to go to >80 characters
- Add a reference to the ACPI spec
- Add a define for the 0x80 constant
- Move the function comments into this patch
- Fix 'easy of testing' typo
- Move two function comments into the previous patch
- Allow the name parameter to be NULL
- Add error checking to acpi_dp_add_integer_array()
- Fix 'acpi_device.v' typo
- Drop unused ACPI_CPU_STRING
- Use an enum for the GPIO priority
- Add error checking
- Fix incorrect function names and arguments in commments
- Add error checking for acpi_dp_add...() functions
- Fix function name in comment for acpigen_write_not()
- Use #defines for the mask values
- Fix 'THe' typo
- Rename MAX_ITEMS to MAX_ACPI_ITEMS
- Make find_item() static and rename to find_acpi_item()
- Rename build_type() and add a comment
Drop coreboot_acpi_ids enum
- Fix 'THe' typo
- Rename build_type() to sort_acpi_item_type()
- Refactor the code to remove the extra memcpy()
- Recalculate the DSDT checksum only once
- Add a comment as to why the checksum byte is set to 0
- Fix 'of' typo
- Update acpi_dump_items() to take an enum
- Update commit message and subject for clarity

Changes in v2:
- Update to add a new 'base' field to struct acpi_ctx
- Free the memory allocated to the table and context
- Fix memset of I2C descriptor
- Fix memset of SPI descriptor

Changes in v1:
- Capitalise ACPI_OPS_PTR
- Split into more patches for review
- Add tests
- Rebase on top of common.h series
- Fix 'the an' typo
- Move header definitions into this patch
- Update sandbox driver slightly for testing
- Switch parameter order of _acpi_fill_ssdt() and make it static
- Fix 'sentinal' and 'METHOD_FILL_SDDT' typos
- Correct the commit subject
- Generalise the ACPI function recursion with acpi_recurse_method()
- Generalise the ACPI function recursion with acpi_recurse_method()
- Use OEM_TABLE_ID instead of ACPI_TABLE_CREATOR
- Update ACPI_DSTATUS enum
- Drop writing of coreboot tables
- Generalise the ACPI function recursion with acpi_recurse_method()
- Use acpi,ddn instead of acpi,desc
- Rename to acpi_device_infer_name()
- Update newly created sandbox tests

Simon Glass (35):
dm: core: Add an ACPI name for the root node
acpi: Add a function to get a device path and scope
acpi: Add a way to check device status
irq: Add a method to convert an interrupt to ACPI
acpi: Support generation of ACPI code
acpi: Support generation of interrupt descriptor
gpio: Add a method to convert a GPIO to ACPI
acpi: Support string output
acpi: Support generation of GPIO descriptor
acpi: Support generation of a GPIO/irq for a device
acpi: Support generation of I2C descriptor
acpi: Support generation of SPI descriptor
acpigen: Support writing a length
acpigen: Support writing a package
acpi: Support writing an integer
acpi: Support writing a string
acpi: Support writing a name
acpi: Support writing a UUID
acpi: Support writing Device Properties objects via _DSD
acpi: Support writing a GPIO
acpi: Support copying properties from device tree to ACPI
acpi: Add support for various misc ACPI opcodes
acpi: Add support for writing a Power Resource
acpi: Add support for writing a GPIO power sequence
acpi: Add support for a generic power sequence
acpi: Add support for SSDT generation
x86: acpi: Move MADT down a bit
acpi: Record the items added to SSDT
acpi: Support ordering SSDT data by device
x86: Allow devices to write an SSDT
acpi: Add support for DSDT generation
x86: Allow devices to write to DSDT
pci: Avoid a crash in device_is_on_pci_bus()
dm: acpi: Enhance acpi_get_name()
acpi: Add an acpi command to list/dump generated ACPI items

 arch/sandbox/dts/test.dts           |  14 +-
 arch/x86/lib/acpi_table.c           |  55 +-
 cmd/acpi.c                          |  15 +-
 doc/device-tree-bindings/chosen.txt |   9 +
 doc/device-tree-bindings/device.txt |  13 +
 drivers/core/acpi.c                 | 229 +++++++-
 drivers/core/root.c                 |  13 +
 drivers/gpio/gpio-uclass.c          |  22 +
 drivers/gpio/sandbox.c              |  77 +++
 drivers/i2c/sandbox_i2c.c           |   1 +
 drivers/misc/irq-uclass.c           |  18 +-
 drivers/misc/irq_sandbox.c          |  16 +
 drivers/rtc/sandbox_rtc.c           |  13 +
 drivers/spi/sandbox_spi.c           |   1 +
 include/acpi/acpi_device.h          | 405 +++++++++++++
 include/acpi/acpi_dp.h              | 287 +++++++++
 include/acpi/acpigen.h              | 402 +++++++++++++
 include/asm-generic/gpio.h          |  27 +
 include/dm/acpi.h                   |  80 ++-
 include/dm/device.h                 |   2 +-
 include/irq.h                       |  43 ++
 include/spi.h                       |   4 +-
 include/test/ut.h                   |  17 +
 lib/acpi/Makefile                   |   3 +
 lib/acpi/acpi_device.c              | 823 ++++++++++++++++++++++++++
 lib/acpi/acpi_dp.c                  | 402 +++++++++++++
 lib/acpi/acpi_table.c               |   1 +
 lib/acpi/acpigen.c                  | 482 +++++++++++++++
 test/dm/Makefile                    |   2 +
 test/dm/acpi.c                      | 277 ++++++++-
 test/dm/acpi.h                      |  29 +
 test/dm/acpi_dp.c                   | 492 ++++++++++++++++
 test/dm/acpigen.c                   | 876 ++++++++++++++++++++++++++++
 test/dm/gpio.c                      |  62 ++
 test/dm/irq.c                       |  23 +
 test/dm/pci.c                       |  14 +
 36 files changed, 5215 insertions(+), 34 deletions(-)
 create mode 100644 include/acpi/acpi_device.h
 create mode 100644 include/acpi/acpi_dp.h
 create mode 100644 include/acpi/acpigen.h
 create mode 100644 lib/acpi/acpi_device.c
 create mode 100644 lib/acpi/acpi_dp.c
 create mode 100644 lib/acpi/acpigen.c
 create mode 100644 test/dm/acpi.h
 create mode 100644 test/dm/acpi_dp.c
 create mode 100644 test/dm/acpigen.c
Signature · 1 line
2.27.0.383.g050319c2ae-goog