Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions arch/arm/boot/dts/allwinner/sun8i-r40-wirenboard72x.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,34 @@
stdout-path = "serial0:115200n8";
};

/* Fixed-address pstore/ramoops region; survives a warm reset so the
* same kernel can harvest it even under an old U-Boot with no shuttle.
* The base MUST match U-Boot WB_RAMOOPS_BASE (0x43800000).
*
* The address was chosen for the arm64/H616 boot map but is reused
* here for R40. On R40 it clears the used load addresses (fdt
* 0x43000000, overlay 0x43300000) and sits ~4 MiB above the stock
* RAMDISK_ADDR_R (0x43400000). WB firmware boots without an initrd
* (bootz "... - ..."), so ramdisk_addr_r is unused; if that ever
* changes, an initrd >4 MiB would overlap this region. There is no
* build-time guard on the R40 side (the U-Boot static_asserts are
* WB8-only). Pending: retention validation on real WB7 hardware.
*/
reserved-memory {
#address-cells = <1>;
#size-cells = <1>;
ranges;

ramoops@43800000 {
compatible = "ramoops";
reg = <0x43800000 0x100000>;
record-size = <0x20000>;
console-size = <0x40000>;
ecc-size = <32>;
no-map;
};
};

regulators {
compatible = "simple-bus";
#address-cells = <1>;
Expand Down
28 changes: 28 additions & 0 deletions arch/arm/boot/dts/allwinner/sun8i-r40-wirenboard74x.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,34 @@
stdout-path = "serial0:115200n8";
};

/* Fixed-address pstore/ramoops region; survives a warm reset so the
* same kernel can harvest it even under an old U-Boot with no shuttle.
* The base MUST match U-Boot WB_RAMOOPS_BASE (0x43800000).
*
* The address was chosen for the arm64/H616 boot map but is reused
* here for R40. On R40 it clears the used load addresses (fdt
* 0x43000000, overlay 0x43300000) and sits ~4 MiB above the stock
* RAMDISK_ADDR_R (0x43400000). WB firmware boots without an initrd
* (bootz "... - ..."), so ramdisk_addr_r is unused; if that ever
* changes, an initrd >4 MiB would overlap this region. There is no
* build-time guard on the R40 side (the U-Boot static_asserts are
* WB8-only). Pending: retention validation on real WB7 hardware.
*/
reserved-memory {
#address-cells = <1>;
#size-cells = <1>;
ranges;

ramoops@43800000 {
compatible = "ramoops";
reg = <0x43800000 0x100000>;
record-size = <0x20000>;
console-size = <0x40000>;
ecc-size = <32>;
no-map;
};
};

regulators {
compatible = "simple-bus";
#address-cells = <1>;
Expand Down
9 changes: 9 additions & 0 deletions arch/arm/configs/wirenboard7_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -591,3 +591,12 @@ CONFIG_PREEMPTIRQ_DELAY_TEST=m
CONFIG_STRICT_DEVMEM=y
CONFIG_DEBUG_USER=y
CONFIG_CONFIGFS_FS=y

# Pstore/ramoops: persist kernel panic + console logs in a RAM region
# across warm resets. The reserved-memory "ramoops" node is injected by
# the Wiren Board U-Boot DT fixup (WIRENBOARD_RAMOOPS_FIXUP); without it
# these options are inert. PSTORE_RAM auto-selects REED_SOLOMON*.
CONFIG_PSTORE=y
CONFIG_PSTORE_RAM=y
CONFIG_PSTORE_CONSOLE=y
CONFIG_WB_RAMOOPS_PANIC_RESET=y
19 changes: 19 additions & 0 deletions arch/arm64/boot/dts/allwinner/sun50i-h616-wirenboard84x.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,25 @@
rtc_onboard = &rtc_onboard;
};

/* Fixed-address pstore/ramoops region; survives a warm reset so the
* same kernel can harvest it even under an old U-Boot with no shuttle.
* The base MUST match U-Boot WB_RAMOOPS_BASE (0x43800000).
*/
reserved-memory {
#address-cells = <2>;
#size-cells = <2>;
ranges;

ramoops@43800000 {
compatible = "ramoops";
reg = <0x0 0x43800000 0x0 0x100000>;
record-size = <0x20000>;
console-size = <0x40000>;
ecc-size = <32>;
no-map;
};
};

wirenboard {
adc-type = <3>;
pwm-buzzer = <1>;
Expand Down
15 changes: 15 additions & 0 deletions arch/arm64/boot/dts/allwinner/sun50i-h616-wirenboard85x.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,21 @@
alloc-ranges = <0x0 0x00000000 0x0 0x80000000>;
linux,cma-default;
};

/* Fixed-address pstore/ramoops region; survives a warm reset so
* the same kernel can harvest it even under an old U-Boot with no
* shuttle. The base MUST match U-Boot WB_RAMOOPS_BASE (0x43800000).
* #address-cells/#size-cells/ranges (2/2) are inherited from the
* /reserved-memory node in sun50i-h616.dtsi that this merges into.
*/
ramoops@43800000 {
compatible = "ramoops";
reg = <0x0 0x43800000 0x0 0x100000>;
record-size = <0x20000>;
console-size = <0x40000>;
ecc-size = <32>;
no-map;
};
};

soc {
Expand Down
9 changes: 9 additions & 0 deletions arch/arm64/configs/wb8.config
Original file line number Diff line number Diff line change
Expand Up @@ -382,3 +382,12 @@ CONFIG_SUN50I_H6_PRCM_PPU=y

#SOUND
CONFIG_SND_HDA_PREALLOC_SIZE=2048

# Pstore/ramoops: persist kernel panic + console logs in a RAM region
# across warm resets. The reserved-memory "ramoops" node is injected by
# the Wiren Board U-Boot DT fixup (WIRENBOARD_RAMOOPS_FIXUP); without it
# these options are inert. PSTORE_RAM auto-selects REED_SOLOMON*.
CONFIG_PSTORE=y
CONFIG_PSTORE_RAM=y
CONFIG_PSTORE_CONSOLE=y
CONFIG_WB_RAMOOPS_PANIC_RESET=y
29 changes: 21 additions & 8 deletions drivers/mfd/wbec.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,21 @@
/* For power off WBEC activates PWON pin on PMIC for 6s */
#define WBEC_POWER_RESET_DELAY_MS 10000

/*
* Mirrors LINUX_POWERON_REASON in wb-embedded-controller src/wbec.c;
* append-only ABI.
*/
static const char * const wbec_poweron_reason[] = {
"Power supply on",
"Power button",
"RTC alarm",
"Reboot",
"Reboot instead of poweroff",
"Watchdog",
"PMIC is unexpectedly off",
[0] = "Power supply on",
[1] = "Power button",
[2] = "RTC alarm",
[3] = "Reboot",
[4] = "Reboot instead of poweroff",
[5] = "Watchdog",
[6] = "PMIC is unexpectedly off",
[7] = "Unknown",
[8] = "Watchdog (warm reset)",
[9] = "Full power cycle request",
};

static const struct regmap_config wbec_regmap_config_v1 = {
Expand Down Expand Up @@ -354,7 +361,13 @@ static int wbec_probe(struct spi_device *spi)

ret = wbec_check_present(wbec);
if (ret == -ENODEV) {
dev_info(wbec->dev, "WBEC not found with v2 protocol, trying v1\n");
/*
* Expected on every board that speaks the v1 protocol (the v2
* pad-word protocol is a newer-EC feature): probe v2 first, then
* fall back to v1. Keep this at debug level so a normal v1 board
* does not log a scary "not found" line during ordinary probing.
*/
dev_dbg(wbec->dev, "no WBEC on v2 protocol, falling back to v1\n");
/* don't worry about memory leak, previous regmap will be freed by devm */
wbec->regmap = devm_regmap_init_spi(spi, &wbec_regmap_config_v1);

Expand Down
11 changes: 11 additions & 0 deletions drivers/soc/sunxi/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,14 @@ config SUNXI_SRAM
Say y here to enable the SRAM controller support. This
device is responsible on mapping the SRAM in the sunXi SoCs
whether to the CPU/DMA, or to the devices.

config WB_RAMOOPS_PANIC_RESET
bool "Wiren Board: SoC watchdog warm reset on panic when ramoops is present"
depends on ARCH_SUNXI && PSTORE_RAM
help
On panic, arm the (otherwise idle) SoC watchdog so a Wiren
Board 7 (Allwinner R40/A40i) or Wiren Board 8 (Allwinner
T507/H616) takes a DRAM-preserving warm reset and the panic
log survives in the ramoops region for the bootloader to
persist. Arms itself only when a ramoops reserved-memory
node is present.
1 change: 1 addition & 0 deletions drivers/soc/sunxi/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# SPDX-License-Identifier: GPL-2.0-only
obj-$(CONFIG_SUNXI_MBUS) += sunxi_mbus.o
obj-$(CONFIG_SUNXI_SRAM) += sunxi_sram.o
obj-$(CONFIG_WB_RAMOOPS_PANIC_RESET) += wb-ramoops-panic-reset.o
Loading