From a78946751ff443a1d745d9965092d8fe1cf7a777 Mon Sep 17 00:00:00 2001 From: Philippe Simons Date: Sat, 28 Dec 2024 23:42:04 +0100 Subject: [PATCH] Allwinner/linux: rework suspend patch --- .../H700/SUPPORTED_EMULATORS_AND_CORES.md | 1 - .../H700/9999-Update-irq-sunxi-nmi.c.patch | 110 ------------------ ...999-irq-sunxi-nmi-add-missings-flags.patch | 40 +++++++ 3 files changed, 40 insertions(+), 111 deletions(-) delete mode 100644 projects/Allwinner/patches/linux/H700/9999-Update-irq-sunxi-nmi.c.patch create mode 100644 projects/Allwinner/patches/linux/H700/9999-irq-sunxi-nmi-add-missings-flags.patch diff --git a/documentation/PER_DEVICE_DOCUMENTATION/H700/SUPPORTED_EMULATORS_AND_CORES.md b/documentation/PER_DEVICE_DOCUMENTATION/H700/SUPPORTED_EMULATORS_AND_CORES.md index 2b76d264a..fbe5c2d6d 100644 --- a/documentation/PER_DEVICE_DOCUMENTATION/H700/SUPPORTED_EMULATORS_AND_CORES.md +++ b/documentation/PER_DEVICE_DOCUMENTATION/H700/SUPPORTED_EMULATORS_AND_CORES.md @@ -71,7 +71,6 @@ This document describes all available systems emulators and cores available for |Nintendo|Game Boy Color (gbc)|1998|`gbc`|.gb .gbc .zip .7z|**retroarch:** gambatte (default)
**retroarch:** sameboy
**retroarch:** gearboy
**retroarch:** tgbdual
**retroarch:** mgba
**retroarch:** vbam
**retroarch:** DoubleCherryGB
**mednafen:** gb
| |Nintendo|Game Boy Color (Hacks) (gbch)|1998|`gbch`|.gb .gbc .zip .7z|**retroarch:** gambatte (default)
**retroarch:** sameboy
**retroarch:** gearboy
**retroarch:** tgbdual
**retroarch:** mgba
**retroarch:** vbam
**retroarch:** DoubleCherryGB
**mednafen:** gb
| |Nintendo|NES (Hacks) (nesh)|1985|`nesh`|.nes .unif .unf .zip .7z|**retroarch:** nestopia (default)
**retroarch:** fceumm
**retroarch:** quicknes
**retroarch:** mesen
**mednafen:** nesh
| -|Nintendo|Nintendo 3DS (3ds)|2010|`3ds`|.3ds .3dsx .elf .axf .cci .cxi .app|**retroarch:** panda3ds (default)
| |Nintendo|Nintendo 64 (n64)|1996|`n64`|.z64 .n64 .v64 .zip .7z|**retroarch:** mupen64plus_next (default)
**retroarch:** mupen64plus
**retroarch:** parallel_n64
**mupen64plus:** mupen64plus-sa
| |Nintendo|Nintendo DS (nds)|2005|`nds`|.nds .zip .7z|**drastic:** drastic-sa (default)
**retroarch:** melonds
**retroarch:** melondsds
**retroarch:** desmume
| |Nintendo|Nintendo Entertainment System (nes)|1985|`nes`|.nes .unif .unf .zip .7z|**retroarch:** nestopia (default)
**retroarch:** fceumm
**retroarch:** quicknes
**retroarch:** mesen
**mednafen:** nes
| diff --git a/projects/Allwinner/patches/linux/H700/9999-Update-irq-sunxi-nmi.c.patch b/projects/Allwinner/patches/linux/H700/9999-Update-irq-sunxi-nmi.c.patch deleted file mode 100644 index 42591f8ea..000000000 --- a/projects/Allwinner/patches/linux/H700/9999-Update-irq-sunxi-nmi.c.patch +++ /dev/null @@ -1,110 +0,0 @@ -From 0610809d94588b41847928eec5e7e81ccc962798 Mon Sep 17 00:00:00 2001 -From: Philippe Simons -Date: Wed, 18 Dec 2024 21:29:59 +0100 -Subject: [PATCH] Update irq-sunxi-nmi.c - ---- - .../sun50i-h700-anbernic-rg35xx-2024.dts | 9 ++++ - drivers/irqchip/irq-sunxi-nmi.c | 45 ++++++++++++++++++- - 2 files changed, 53 insertions(+), 1 deletion(-) - -diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h700-anbernic-rg35xx-2024.dts b/arch/arm64/boot/dts/allwinner/sun50i-h700-anbernic-rg35xx-2024.dts -index 80ccab7b5..ff9b964cd 100644 ---- a/arch/arm64/boot/dts/allwinner/sun50i-h700-anbernic-rg35xx-2024.dts -+++ b/arch/arm64/boot/dts/allwinner/sun50i-h700-anbernic-rg35xx-2024.dts -@@ -207,6 +207,15 @@ &pio { - vcc-pi-supply = <®_cldo3>; - }; - -+&nmi_intc { -+ pad-control-v1 = <0x7000208>; -+ wakeup-source; -+}; -+ -+&crypto { -+ status = "disabled"; -+}; -+ - &r_i2c { - status = "okay"; - -diff --git a/drivers/irqchip/irq-sunxi-nmi.c b/drivers/irqchip/irq-sunxi-nmi.c -index bb92fd85e..c864f97ed 100644 ---- a/drivers/irqchip/irq-sunxi-nmi.c -+++ b/drivers/irqchip/irq-sunxi-nmi.c -@@ -21,6 +21,7 @@ - #include - #include - #include -+#include - - #define SUNXI_NMI_SRC_TYPE_MASK 0x00000003 - -@@ -142,6 +143,43 @@ static int sunxi_sc_nmi_set_type(struct irq_data *data, unsigned int flow_type) - return IRQ_SET_MASK_OK; - } - -+static void sunxi_nmi_pad_control(struct device_node *node) -+{ -+ u32 v; -+ u32 __iomem *pad; -+ -+ /* if we read pad-control-v1, the we use the addr to contorl nmi */ -+ if (of_property_read_u32(node, "pad-control-v1", &v)) -+ return; -+ -+ pad = ioremap(v, 4); -+ *pad = *pad & ~BIT(0); -+ iounmap(pad); -+} -+ -+/* -+ * on some standby, the prcm control register can lowpower down -+ * so it must resume the register value first -+ */ -+static struct irq_chip_generic *sys_gc; -+static struct sunxi_sc_nmi_reg_offs *sys_reg_offs; -+static uint32_t sys_vaule; -+static int sunxi_nmi_suspend(void) -+{ -+ sys_vaule = sunxi_sc_nmi_read(sys_gc, sys_reg_offs->enable); -+ return 0; -+} -+ -+static void sunxi_nmi_resume(void) -+{ -+ sunxi_sc_nmi_write(sys_gc, sys_reg_offs->enable, sys_vaule); -+} -+ -+static struct syscore_ops sunxi_nmi_syscore_ops = { -+ .suspend = sunxi_nmi_suspend, -+ .resume = sunxi_nmi_resume, -+}; -+ - static int __init sunxi_sc_nmi_irq_init(struct device_node *node, - const struct sunxi_sc_nmi_reg_offs *reg_offs) - { -@@ -186,7 +224,7 @@ static int __init sunxi_sc_nmi_irq_init(struct device_node *node, - gc->chip_types[0].chip.irq_unmask = irq_gc_mask_set_bit; - gc->chip_types[0].chip.irq_eoi = irq_gc_ack_set_bit; - gc->chip_types[0].chip.irq_set_type = sunxi_sc_nmi_set_type; -- gc->chip_types[0].chip.flags = IRQCHIP_EOI_THREADED | IRQCHIP_EOI_IF_HANDLED; -+ gc->chip_types[0].chip.flags = IRQCHIP_EOI_THREADED | IRQCHIP_EOI_IF_HANDLED | IRQCHIP_SKIP_SET_WAKE; - gc->chip_types[0].regs.ack = reg_offs->pend; - gc->chip_types[0].regs.mask = reg_offs->enable; - gc->chip_types[0].regs.type = reg_offs->ctrl; -@@ -207,6 +245,11 @@ static int __init sunxi_sc_nmi_irq_init(struct device_node *node, - /* Clear any pending NMI interrupts */ - sunxi_sc_nmi_write(gc, reg_offs->pend, SUNXI_NMI_IRQ_BIT); - -+ sunxi_nmi_pad_control(node); -+ sys_gc = gc; -+ sys_reg_offs = reg_offs; -+ register_syscore_ops(&sunxi_nmi_syscore_ops); -+ - irq_set_chained_handler_and_data(irq, sunxi_sc_nmi_handle_irq, domain); - - return 0; --- -2.47.1 - diff --git a/projects/Allwinner/patches/linux/H700/9999-irq-sunxi-nmi-add-missings-flags.patch b/projects/Allwinner/patches/linux/H700/9999-irq-sunxi-nmi-add-missings-flags.patch new file mode 100644 index 000000000..0fd4695a8 --- /dev/null +++ b/projects/Allwinner/patches/linux/H700/9999-irq-sunxi-nmi-add-missings-flags.patch @@ -0,0 +1,40 @@ +From 67b879faf1e3650cae0c8e5712bdb467014435e8 Mon Sep 17 00:00:00 2001 +From: Philippe Simons +Date: Sat, 28 Dec 2024 18:19:17 +0100 +Subject: [PATCH] irq-sunxi-nmi: add missings flags + +IRQCHIP_SKIP_SET_WAKE | IRQCHIP_MASK_ON_SUSPEND +--- + arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi | 1 + + drivers/irqchip/irq-sunxi-nmi.c | 3 ++- + 2 files changed, 3 insertions(+), 1 deletion(-) + +diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi +index e88c1fbac..9d4d7b2c6 100644 +--- a/arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi ++++ b/arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi +@@ -867,6 +867,7 @@ nmi_intc: interrupt-controller@7010320 { + interrupt-controller; + #interrupt-cells = <2>; + interrupts = ; ++ wakeup-source; + }; + + r_pio: pinctrl@7022000 { +diff --git a/drivers/irqchip/irq-sunxi-nmi.c b/drivers/irqchip/irq-sunxi-nmi.c +index bb92fd85e..b9a534ecd 100644 +--- a/drivers/irqchip/irq-sunxi-nmi.c ++++ b/drivers/irqchip/irq-sunxi-nmi.c +@@ -186,7 +186,8 @@ static int __init sunxi_sc_nmi_irq_init(struct device_node *node, + gc->chip_types[0].chip.irq_unmask = irq_gc_mask_set_bit; + gc->chip_types[0].chip.irq_eoi = irq_gc_ack_set_bit; + gc->chip_types[0].chip.irq_set_type = sunxi_sc_nmi_set_type; +- gc->chip_types[0].chip.flags = IRQCHIP_EOI_THREADED | IRQCHIP_EOI_IF_HANDLED; ++ gc->chip_types[0].chip.flags = IRQCHIP_EOI_THREADED | IRQCHIP_EOI_IF_HANDLED ++ | IRQCHIP_SKIP_SET_WAKE | IRQCHIP_MASK_ON_SUSPEND; + gc->chip_types[0].regs.ack = reg_offs->pend; + gc->chip_types[0].regs.mask = reg_offs->enable; + gc->chip_types[0].regs.type = reg_offs->ctrl; +-- +2.47.1 +