u-boot/arch/sandbox/include/asm
Miquel Raynal 9086b64ca0 power-domain: Add support for refcounting (again)
It is very surprising that such an uclass, specifically designed to
handle resources that may be shared by different devices, is not keeping
the count of the number of times a power domain has been
enabled/disabled to avoid shutting it down unexpectedly or disabling it
several times.

Doing this causes troubles on eg. i.MX8MP because disabling power
domains can be done in recursive loops were the same power domain
disabled up to 4 times in a row. PGCs seem to have tight FSM internal
timings to respect and it is easy to produce a race condition that puts
the power domains in an unstable state, leading to ADB400 errors and
later crashes in Linux.

Some drivers implement their own mechanism for that, but it is probably
best to add this feature in the uclass and share the common code across
drivers. In order to avoid breaking existing drivers, refcounting is
only enabled if the number of subdomains a device node supports is
explicitly set in the probe function. ->xlate() callbacks will return
the power domain ID which is then being used as the array index to reach
the correct refcounter.

As we do not want to break existing users while stile getting
interesting error codes, the implementation is split between:
- a low-level helper reporting error codes if the requested transition
  could not be operated,
- a higher-level helper ignoring the "non error" codes, like EALREADY and
  EBUSY.

CI tests using power domains are slightly updated to make sure the count
of on/off calls is even and the results match what we *now* expect. They
are also extended to test the low-level functions.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
2025-04-28 10:41:19 -03:00
..
acpi_table.h acpi: Move acpi_write_tables() to a generic header 2022-02-11 11:29:23 -05:00
axi.h axi: fix definition of axi_sandbox_get_emul() 2023-06-01 12:32:03 -04:00
barrier.h sandbox: Add <asm/barrier.h> 2023-11-07 14:49:40 -05:00
bitops.h sandbox: Use the generic bitops headers 2015-11-05 10:52:14 -05:00
byteorder.h sandbox: Remove duplicate newlines 2024-07-15 12:12:18 -06:00
cache.h Finish converting CONFIG_SYS_CACHELINE_SIZE to Kconfig 2021-08-31 17:47:49 -04:00
clk.h clk: Remove rfree 2024-01-29 22:35:02 -05:00
config.h sandbox: Finish migration to Kconfig 2022-12-22 10:31:48 -05:00
cpu.h sandbox: Add a way to show the sandbox memory-mapping 2024-11-03 21:27:12 -06:00
dma-mapping.h dma-mapping: add <asm/dma-mapping.h> for all architectures 2020-02-20 15:09:54 +08:00
eth-raw-os.h sandbox: eth-raw: Add a SIMPLE_BUS to enumerate host interfaces 2018-07-26 14:08:19 -05:00
eth.h test/cmd/wget: fix the test 2024-12-28 11:59:42 -06:00
fuzzing_engine.h sandbox: Add libfuzzer integration 2022-06-23 12:58:18 -04:00
getopt.h sandbox: Rename getopt sections 2022-06-23 12:58:18 -04:00
global_data.h Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet" 2024-05-20 13:35:03 -06:00
gpio.h doc: replace @return by Return: 2022-01-19 18:11:34 +01:00
handoff.h spl: Add support for passing handoff info to U-Boot proper 2018-11-26 08:25:37 -05:00
i2c.h sandbox: i2c: Move platdata structs to header files 2021-03-26 17:03:08 +13:00
io.h sandbox: Correct guard around readq/writeq 2024-12-31 10:58:30 -06:00
irq.h irq: Tidy up of-platdata irq support 2021-09-25 09:46:15 -06:00
linkage.h efi: Use asmlinkage for EFIAPI 2016-10-19 09:01:53 +02:00
main.h sandbox: Decouple program entry from sandbox init 2022-06-23 12:58:18 -04:00
malloc.h test: Support testing malloc() failures 2022-09-29 16:07:58 -04:00
mbox.h sandbox: Drop <common.h> 2023-11-07 14:50:52 -05:00
posix_types.h sandbox: correct posix_types.h define 2023-04-28 11:30:18 -06:00
power-domain.h power-domain: Add support for refcounting (again) 2025-04-28 10:41:19 -03:00
processor.h SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
ptrace.h SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
reset.h sandbox: Drop <common.h> 2023-11-07 14:50:52 -05:00
rtc.h sandbox: Tidy up RTC options 2023-03-02 17:45:58 -05:00
sandbox_arm_ffa_priv.h arm_ffa: introduce sandbox FF-A support 2023-08-08 10:22:03 -04:00
sandbox_arm_ffa.h arm_ffa: introduce sandbox FF-A support 2023-08-08 10:22:03 -04:00
scmi_test.h sandbox: add SCMI power domain protocol support for testing 2023-10-24 17:05:24 -04:00
sdl.h sandbox: fix a compilation error 2023-07-20 14:10:57 -06:00
sections.h sandbox: Add missing header file 2024-10-03 11:52:16 -06:00
serial.h membuf: Rename struct 2025-04-03 16:54:49 -06:00
setjmp.h common: clean up setjmp.h 2025-03-10 07:41:16 +01:00
spi.h sandbox: spi: Drop unused sandbox_spi_parse_spec function 2020-12-22 20:39:25 -07:00
spl.h sandbox: Add an SPL loader for UPL 2024-08-09 16:03:20 -06:00
state.h sandbox: Add a -N flag to control on-host behaviour 2024-11-09 10:00:15 +01:00
string.h SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
system.h SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
test.h sandbox: iommu: remove lmb allocation in the driver 2024-09-03 14:08:50 -06:00
types.h sandbox: Correctly define BITS_PER_LONG 2023-03-01 11:22:27 -07:00
u-boot-sandbox.h sandbox: mark sandbox_exit() as no return. 2023-04-28 11:30:17 -06:00
u-boot.h SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
unaligned.h SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00