It's quite common to have an external watchdog which is serviced via flipping a GPIO, with the value of that GPIO being settable directly in a memory-mapped register. So add kconfig options defining the physical address of such a register as well as a mask to have the decompressor periodically xor into that register.
If and when other decompress_keepalive methods are added, this can be made into a "choice DECOMPRESS_KEEPALIVE". Since only LZ4 is wired up currently, this is "depends on KERNEL_LZ4" for now. Also, prevent this option from being shown to the average user. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- include/linux/decompress/keepalive.h | 8 +++++++ init/Kconfig | 33 ++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/include/linux/decompress/keepalive.h b/include/linux/decompress/keepalive.h index 39caa7693624..c62e49bee7cf 100644 --- a/include/linux/decompress/keepalive.h +++ b/include/linux/decompress/keepalive.h @@ -5,6 +5,14 @@ #ifdef PREBOOT +#ifdef CONFIG_DECOMPRESS_KEEPALIVE_TOGGLE +#define decompress_keepalive() do { \ + long addr = CONFIG_DECOMPRESS_KEEPALIVE_TOGGLE_REG; \ + volatile unsigned *reg = (volatile unsigned *)addr; \ + *reg ^= CONFIG_DECOMPRESS_KEEPALIVE_TOGGLE_MASK; \ +} while (0) +#endif + #endif #ifndef decompress_keepalive diff --git a/init/Kconfig b/init/Kconfig index b4daad2bac23..8a894d9fdd77 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -289,6 +289,39 @@ config KERNEL_UNCOMPRESSED endchoice +config DECOMPRESS_KEEPALIVE_TOGGLE + depends on KERNEL_LZ4 + depends on EXPERT + bool "Toggle some bits while decompressing" + help + Some embedded boards have an always-running hardware + watchdog with a timeout short enough that the board is reset + during decompression, thus preventing the board from ever + booting. + + Enable this to toggle certain bits in a memory register + while decompressing the kernel. This can for example be used + in the common case of an external watchdog serviced via a + memory-mapped GPIO. + + Say N unless you know you need this. + +if DECOMPRESS_KEEPALIVE_TOGGLE + +config DECOMPRESS_KEEPALIVE_TOGGLE_REG + hex "Address of register to modify while decompressing" + help + Set this to a physical address of a 32-bit memory word to + modify while decompressing. + +config DECOMPRESS_KEEPALIVE_TOGGLE_MASK + hex "Bit mask to toggle while decompressing" + help + The register selected above will periodically be xor'ed with + this value during decompression. + +endif + config DEFAULT_HOSTNAME string "Default hostname" default "(none)" -- 2.20.1