Re: [PATCH] firewall3: fix locking issue

2021-11-24 Thread Florian Eckert

Hello

I found an interesting article about this topic on stackoverflow.

https://stackoverflow.com/questions/17708885/flock-removing-locked-file-without-race-condition

Beset regards
Florian

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [PATCH v4 0/5] realtek: Use WDT for system restart

2021-11-24 Thread Sander Vanheule
On Wed, 2021-11-24 at 21:33 +0200, Stijn Tintel wrote:
> On 14/11/2021 20:45, Sander Vanheule wrote:
> > Backport and enable the Realtek Otto watchdog driver for enhanced system
> > reliability. The watchdog driver can also be used to restart the system,
> > but that requires the _machine_restart to be removed.
> > 
> > Removing _machine_restart has the added benefit of enabling the use of other
> > restart handlers in addition to the watchdog restart, such as gpio-restart,
> > which may be more reliable than the SoCs internal reset circuitry. Removing
> > the
> > override also brings the current target closer to upstream, which will
> > become
> > relevant when switching to the next LTS kernel.
> > 
> > This series contains the watchdog driver as currently submitted upstream,
> > without the devicetree bindings. If the driver gets accepted before this
> > series
> > is merged, I can already update it with the final version. Otherwise, a
> > follow-up will be sent to replace the patch.
> > 
> > The WDT driver was previously tested on my Netgear GS110TPPv1, Zyxel GS1900-
> > 8,
> > and Zyxel XGS1250-12. Testers with other devices should ensure that their
> > system can still restart after applying the complete series.
> > 
> > Main changes in v4:
> > - Use cold restart (full SoC reset) on all devices by default
> 
> Thanks, will merge these soon.
> 
> Tested-by: Stijn Tintel 
> 

Great, thanks!

Best,
Sander

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [PATCH v4 0/5] realtek: Use WDT for system restart

2021-11-24 Thread Stijn Tintel
On 14/11/2021 20:45, Sander Vanheule wrote:
> Backport and enable the Realtek Otto watchdog driver for enhanced system
> reliability. The watchdog driver can also be used to restart the system,
> but that requires the _machine_restart to be removed.
>
> Removing _machine_restart has the added benefit of enabling the use of other
> restart handlers in addition to the watchdog restart, such as gpio-restart,
> which may be more reliable than the SoCs internal reset circuitry. Removing 
> the
> override also brings the current target closer to upstream, which will become
> relevant when switching to the next LTS kernel.
>
> This series contains the watchdog driver as currently submitted upstream,
> without the devicetree bindings. If the driver gets accepted before this 
> series
> is merged, I can already update it with the final version. Otherwise, a
> follow-up will be sent to replace the patch.
>
> The WDT driver was previously tested on my Netgear GS110TPPv1, Zyxel GS1900-8,
> and Zyxel XGS1250-12. Testers with other devices should ensure that their
> system can still restart after applying the complete series.
>
> Main changes in v4:
> - Use cold restart (full SoC reset) on all devices by default

Thanks, will merge these soon.

Tested-by: Stijn Tintel 


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [PATCH v2] realtek: reset both ethernet NIC and queues

2021-11-24 Thread Stijn Tintel
On 18/11/2021 19:39, Sander Vanheule wrote:
> Recent versions of Realtek's SDK reset both the ethernet NIC and queues
> (SW_NIC_RST and SW_Q_RST bits) when initialising the hardware.
>
> Furthermore, when issuing a CPU reset on the Zyxel GS1900-8 (not
> supported by any current driver), the networking part of the SoC is not
> reset. This leads to unresponsive network after the restart. By
> resetting both the ethernet NIC and queues, networking always comes up
> reliably.
>
Thanks, will merge this soon.

Tested-by: Stijn Tintel 


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH 0/1] build: scripts/config - update to kconfig-v5.14

2021-11-24 Thread Eneas U de Queiroz
I'm updating the Kconfig programs in scripts/config, from Linux 5.6 to
5.14.  The changes are not crytical to openwrt, but regular updates
ease the transition to an eventual newer version with more desirable
features.

The biggest impact here is the removal of obsolete ---help--- symbol,
which had been deprecated in favor of plain 'help'.

This has been menuconfig-tested with different targets for almost a
month without problems.

The changed I made to the upstream kconfig to this version can be seen
at https://github.com/cotequeiroz/linux/commits/openwrt-5.14/scripts/kconfig

Eneas U de Queiroz (1):
  build: scripts/config - update to kconfig-v5.14

 Config.in  |2 +-
 scripts/config/.gitignore  |   30 +-
 scripts/config/Makefile|   62 +-
 scripts/config/README  |9 +-
 scripts/config/conf.c  |  451 --
 scripts/config/confdata.c  |  279 +---
 scripts/config/expr.h  |6 -
 scripts/config/images.c|   30 +-
 scripts/config/images.h|   30 +-
 scripts/config/internal.h  |9 +
 scripts/config/lexer.l |8 +-
 scripts/config/lexer.lex.c | 2468 ++--
 scripts/config/lkc.h   |   68 +-
 scripts/config/lkc_proto.h |   15 +-
 scripts/config/lxdialog/util.c |4 +-
 scripts/config/mconf-cfg.sh|4 +-
 scripts/config/mconf.c |   15 +-
 scripts/config/menu.c  |   26 +-
 scripts/config/nconf.c |   59 +-
 scripts/config/nconf.gui.c |  284 ++--
 scripts/config/nconf.h |   51 +-
 scripts/config/parser.tab.c| 1804 ++-
 scripts/config/parser.tab.h|  120 +-
 scripts/config/parser.y|   57 +-
 scripts/config/preprocess.c|2 +-
 scripts/config/qconf-cfg.sh|   14 +-
 scripts/config/qconf.cc| 1056 +++---
 scripts/config/qconf.h |  160 +--
 scripts/config/symbol.c|   30 +-
 target/sdk/files/Config.in |2 +-
 30 files changed, 3221 insertions(+), 3934 deletions(-)
 create mode 100644 scripts/config/internal.h


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH 3/6] bcm27xx: enable dt-overlay

2021-11-24 Thread Daniel Golle
Enable 'dt-overlay' feature for bcm27xx target.

Signed-off-by: Daniel Golle 
---
 target/linux/bcm27xx/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/linux/bcm27xx/Makefile b/target/linux/bcm27xx/Makefile
index 29546049ed..e72fe5e963 100644
--- a/target/linux/bcm27xx/Makefile
+++ b/target/linux/bcm27xx/Makefile
@@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk
 ARCH:=arm
 BOARD:=bcm27xx
 BOARDNAME:=Broadcom BCM27xx
-FEATURES:=ext4 audio usb usbgadget display gpio fpu squashfs rootfs-part 
boot-part
+FEATURES:=dt-overlay ext4 audio usb usbgadget display gpio fpu squashfs 
rootfs-part boot-part
 SUBTARGETS:=bcm2708 bcm2709 bcm2710 bcm2711
 
 KERNEL_PATCHVER=5.10
-- 
2.34.0


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH 2/6] base-files: preinit: load device-tree overlays

2021-11-24 Thread Daniel Golle
Add new boot hooklist 'preinit_late'
'preinit_main' returns once initramfs is detected and skips all later
hooks, hence it cannot be used e.g. for loading device tree overlays
which should work independently of running in initramfs of not, but
needs to happen after rootfs is mounted in the "regular"
squashfs+overlayfs case.

Hence introduce new hooklist 'preinit_late' which is run after
'preinit_main' has completed.

Introduce preinit_late hook to mount configfs and apply device tree
overlays from /lib/firmware/device-tree/overlays/*.dtbo on targets
which got the 'dt-overlay' feature set.
Device tree overlay blobs placed into that folder will be loaded
early on boot before AutoProbing kernel modules.

Signed-off-by: Daniel Golle 
---
 package/base-files/Makefile   |  6 ++
 package/base-files/files/etc/preinit  |  2 ++
 .../files/lib/preinit/90_apply_dt_overlays| 19 +++
 3 files changed, 27 insertions(+)
 create mode 100644 package/base-files/files/lib/preinit/90_apply_dt_overlays

diff --git a/package/base-files/Makefile b/package/base-files/Makefile
index af5c0e6b00..b347eb4143 100644
--- a/package/base-files/Makefile
+++ b/package/base-files/Makefile
@@ -22,6 +22,7 @@ PKG_LICENSE:=GPL-2.0
 # Extend depends from version.mk
 PKG_CONFIG_DEPENDS += \
CONFIG_SIGNED_PACKAGES CONFIG_TARGET_INIT_PATH 
CONFIG_TARGET_PREINIT_DISABLE_FAILSAFE \
+   CONFIG_HAS_DT_OVERLAY_SUPPORT \
CONFIG_NAND_SUPPORT \
CONFIG_LEGACY_SDCARD_SUPPORT \
CONFIG_CLEAN_IPKG \
@@ -189,6 +190,11 @@ else
mkdir -p $(1)/var
$(LN) /tmp/run $(1)/var/run
 endif
+
+ifneq ($(CONFIG_HAS_DT_OVERLAY_SUPPORT),y)
+   rm $(1)/lib/preinit/90_apply_dt_overlays
+endif
+
$(LN) /tmp/resolv.conf /tmp/TZ /tmp/localtime $(1)/etc/
 
chmod 0600 $(1)/etc/shadow
diff --git a/package/base-files/files/etc/preinit 
b/package/base-files/files/etc/preinit
index 829574f5f1..04c11f8833 100755
--- a/package/base-files/files/etc/preinit
+++ b/package/base-files/files/etc/preinit
@@ -15,6 +15,7 @@ boot_hook_init preinit_main
 boot_hook_init failsafe
 boot_hook_init initramfs
 boot_hook_init preinit_mount_root
+boot_hook_init preinit_late
 
 for pi_source_file in /lib/preinit/*; do
. $pi_source_file
@@ -27,3 +28,4 @@ pi_jffs2_mount_success=false
 pi_failsafe_net_message=false
 
 boot_run_hook preinit_main
+boot_run_hook preinit_late
diff --git a/package/base-files/files/lib/preinit/90_apply_dt_overlays 
b/package/base-files/files/lib/preinit/90_apply_dt_overlays
new file mode 100644
index 00..7d17947e1c
--- /dev/null
+++ b/package/base-files/files/lib/preinit/90_apply_dt_overlays
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+do_apply_dt_overlays() {
+   grep -q configfs /proc/filesystems || return 0
+   mount configfs -t configfs /sys/kernel/config
+   local overlays_dir="/sys/kernel/config/device-tree/overlays"
+   [ -d "$overlays_dir" ] || return 0
+   local dto dtoname
+   for dto in /lib/firmware/device-tree/overlays/*.dto ; do
+   [ -r "$dto" ] || continue
+   dtoname="$(basename "$dtbo" .dtbo)"
+   [ -e "$overlays_dir/$dtoname" ] && continue
+   echo " - applying device-tree overlay '$dtoname' - "
+   mkdir "$overlays_dir/$dtoname"
+   echo "$dto" > "$overlays_dir/$dtoname/path"
+   done
+}
+
+boot_hook_add preinit_late do_apply_dt_overlays
-- 
2.34.0


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH 1/6] kernel: import dt-overlay configfs patches for 5.10

2021-11-24 Thread Daniel Golle
Import patchset allowing loading and applying device tree overlays at
run-time via configfs.

This will allow for packaging DTOs for hardware add-ons such as the
various HATs (Hardware Attached on Top) common for SBCs.
A new kernel config option CONFIG_OF_CONFIGFS is introduced and some
additional sysfs attributes are added in case CONFIG_OF_OVERLAY is
enabled.

To make use of this feature, both CONFIG_OF_CONFIGFS and
CONFIG_OF_OVERLAY need to be enabled in a targets kernel config.
This is currently already the case for mediatek/mt7622 and
mediatek/mt7623 as it has already been enabled by commit 401d7ebf2c
("mediatek: enable configfs for DT overlay on mt7622 and mt7623").

Signed-off-by: Daniel Golle 
---
 target/linux/generic/config-5.10  |   1 +
 .../hack-5.10/230-openwrt_lzma_options.patch  |   2 +-
 ...-OF-DT-Overlay-configfs-interface-v7.patch | 395 ++
 ...f-overlay-kobjectify-overlay-objects.patch | 157 +++
 ...verlay-global-sysfs-enable-attribute.patch | 105 +
 ...ation-ABI-overlays-global-attributes.patch |  40 ++
 ...ocument-of_overlay_disable-parameter.patch |  23 +
 ...lay-add-per-overlay-sysfs-attributes.patch | 243 +++
 ...tation-ABI-overlays-per-overlay-docs.patch |  46 ++
 ...-of-rename-_node_sysfs-to-_node_post.patch | 150 +++
 ...-symbols-when-CONFIG_OF_OVERLAY-is-u.patch |  27 ++
 11 files changed, 1188 insertions(+), 1 deletion(-)
 create mode 100644 
target/linux/generic/pending-5.10/060-OF-DT-Overlay-configfs-interface-v7.patch
 create mode 100644 
target/linux/generic/pending-5.10/061-of-overlay-kobjectify-overlay-objects.patch
 create mode 100644 
target/linux/generic/pending-5.10/062-of-overlay-global-sysfs-enable-attribute.patch
 create mode 100644 
target/linux/generic/pending-5.10/063-Documentation-ABI-overlays-global-attributes.patch
 create mode 100644 
target/linux/generic/pending-5.10/064-Documentation-document-of_overlay_disable-parameter.patch
 create mode 100644 
target/linux/generic/pending-5.10/065-of-overlay-add-per-overlay-sysfs-attributes.patch
 create mode 100644 
target/linux/generic/pending-5.10/066-Documentation-ABI-overlays-per-overlay-docs.patch
 create mode 100644 
target/linux/generic/pending-5.10/067-of-rename-_node_sysfs-to-_node_post.patch
 create mode 100644 
target/linux/generic/pending-5.10/068-kbuild-Enable-DT-symbols-when-CONFIG_OF_OVERLAY-is-u.patch

diff --git a/target/linux/generic/config-5.10 b/target/linux/generic/config-5.10
index 4554dc22e3..c1b14443e7 100644
--- a/target/linux/generic/config-5.10
+++ b/target/linux/generic/config-5.10
@@ -4210,6 +4210,7 @@ CONFIG_NMI_LOG_BUF_SHIFT=13
 # CONFIG_OCFS2_FS is not set
 # CONFIG_OCTEONTX2_AF is not set
 # CONFIG_OCTEONTX2_PF is not set
+# CONFIG_OF_CONFIGFS is not set
 # CONFIG_OF_OVERLAY is not set
 CONFIG_OF_RESERVED_MEM=y
 # CONFIG_OF_UNITTEST is not set
diff --git a/target/linux/generic/hack-5.10/230-openwrt_lzma_options.patch 
b/target/linux/generic/hack-5.10/230-openwrt_lzma_options.patch
index 906527faf9..0e80d1ad2a 100644
--- a/target/linux/generic/hack-5.10/230-openwrt_lzma_options.patch
+++ b/target/linux/generic/hack-5.10/230-openwrt_lzma_options.patch
@@ -23,7 +23,7 @@ Signed-off-by: Imre Kaloz 
{ {0x02, 0x21}, "lz4", unlz4 },
 --- a/scripts/Makefile.lib
 +++ b/scripts/Makefile.lib
-@@ -370,7 +370,7 @@ quiet_cmd_bzip2 = BZIP2   $@
+@@ -374,7 +374,7 @@ quiet_cmd_bzip2 = BZIP2   $@
  # ---
  
  quiet_cmd_lzma = LZMA$@
diff --git 
a/target/linux/generic/pending-5.10/060-OF-DT-Overlay-configfs-interface-v7.patch
 
b/target/linux/generic/pending-5.10/060-OF-DT-Overlay-configfs-interface-v7.patch
new file mode 100644
index 00..570dd6b4aa
--- /dev/null
+++ 
b/target/linux/generic/pending-5.10/060-OF-DT-Overlay-configfs-interface-v7.patch
@@ -0,0 +1,395 @@
+From 073f612de406b949af513c9ebf4ab0e745ffa969 Mon Sep 17 00:00:00 2001
+From: Pantelis Antoniou 
+Date: Wed, 4 Dec 2013 19:32:00 +0200
+Subject: [PATCH 01/10] OF: DT-Overlay configfs interface (v7)
+
+Add a runtime interface to using configfs for generic device tree overlay
+usage. With it its possible to use device tree overlays without having
+to use a per-platform overlay manager.
+
+Please see Documentation/devicetree/configfs-overlays.txt for more info.
+
+Changes since v6:
+- Default groups properties API changed.
+
+Changes since v5:
+- New style configfs.
+
+Changes since v4:
+- Loading fix for multiple overlays as found out by
+  Geert Uytterhoeven 
+
+Changes since v3:
+- Fixed compilation on SPARC & Xtensa
+
+Changes since v2:
+- Removed ifdef CONFIG_OF_OVERLAY (since for now it's required)
+- Created a documentation entry
+- Slight rewording in Kconfig
+
+Changes since v1:
+- of_resolve() -> of_resolve_phandles().
+
+Signed-off-by: Pantelis Antoniou 
+[geert: Use %zu to format size_t]
+[geert: Rebase to v4.15-rc1]
+[geert: Make cfs_overlay_item_dtbo_{read,write}() and
+   of_cfs_overlay_gro

[PATCH 4/6] rockchip: enable dt-overlay

2021-11-24 Thread Daniel Golle
Enable 'dt-overlay' feature for rockchip target.

Signed-off-by: Daniel Golle 
---
 target/linux/rockchip/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/linux/rockchip/Makefile b/target/linux/rockchip/Makefile
index 0245f02eac..891bd14d94 100644
--- a/target/linux/rockchip/Makefile
+++ b/target/linux/rockchip/Makefile
@@ -4,7 +4,7 @@ include $(TOPDIR)/rules.mk
 
 BOARD:=rockchip
 BOARDNAME:=Rockchip
-FEATURES:=ext4 audio usb usbgadget display gpio fpu pci pcie rootfs-part 
boot-part squashfs
+FEATURES:=dt-overlay ext4 audio usb usbgadget display gpio fpu pci pcie 
rootfs-part boot-part squashfs
 SUBTARGETS:=armv8
 
 KERNEL_PATCHVER=5.10
-- 
2.34.0


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH 6/6] tegra: enable dt-overlay

2021-11-24 Thread Daniel Golle
Enable 'dt-overlay' feature for tegra target.

Signed-off-by: Daniel Golle 
---
 target/linux/tegra/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/linux/tegra/Makefile b/target/linux/tegra/Makefile
index 76dfeab402..db7bf42c84 100644
--- a/target/linux/tegra/Makefile
+++ b/target/linux/tegra/Makefile
@@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
 ARCH := arm
 BOARD := tegra
 BOARDNAME := NVIDIA Tegra
-FEATURES := audio boot-part display ext4 fpu gpio pci pcie rootfs-part rtc 
squashfs usb
+FEATURES := dt-overlay audio boot-part display ext4 fpu gpio pci pcie 
rootfs-part rtc squashfs usb
 CPU_TYPE := cortex-a9
 CPU_SUBTYPE := vfpv3-d16
 
-- 
2.34.0


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH 5/6] sunxi: enable dt-overlay

2021-11-24 Thread Daniel Golle
Enable 'dt-overlay' feature for sunxi target.

Signed-off-by: Daniel Golle 
---
 target/linux/sunxi/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/linux/sunxi/Makefile b/target/linux/sunxi/Makefile
index 1c94c6eaaf..bdb982efcc 100644
--- a/target/linux/sunxi/Makefile
+++ b/target/linux/sunxi/Makefile
@@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
 ARCH:=arm
 BOARD:=sunxi
 BOARDNAME:=Allwinner A1x/A20/A3x/H3/H5/R40
-FEATURES:=fpu usb ext4 display rtc squashfs
+FEATURES:=dt-overlay fpu usb ext4 display rtc squashfs
 SUBTARGETS:=cortexa8 cortexa7 cortexa53
 
 KERNEL_PATCHVER:=5.10
-- 
2.34.0


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH] realtek: add missing GPIO irq properties

2021-11-24 Thread Sander Vanheule
The internal GPIO controller on RTL838x is also an IRQ controller, which
requires the 'interrupt-controller' and '#interrupts-cells' properties
to be present in the device tree.

Reported-by: INAGAKI Hiroshi 
Signed-off-by: Sander Vanheule 
---
 target/linux/realtek/dts-5.10/rtl838x.dtsi | 4 
 1 file changed, 4 insertions(+)

diff --git a/target/linux/realtek/dts-5.10/rtl838x.dtsi 
b/target/linux/realtek/dts-5.10/rtl838x.dtsi
index f356f8fcde09..899c1731fb51 100644
--- a/target/linux/realtek/dts-5.10/rtl838x.dtsi
+++ b/target/linux/realtek/dts-5.10/rtl838x.dtsi
@@ -170,9 +170,13 @@
gpio0: gpio-controller@3500 {
compatible = "realtek,rtl8380-gpio", 
"realtek,otto-gpio";
reg = <0x3500 0x20>;
+
gpio-controller;
#gpio-cells = <2>;
ngpios = <24>;
+
+   interrupt-controller;
+   #interrupt-cells = <2>;
interrupt-parent = <&intc>;
interrupts = <23>;
};
-- 
2.33.1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH 0/2] gpio-restart for Netgear switches

2021-11-24 Thread Sander Vanheule
Now that _machine_restart has been removed for the realtek target, gpio-restart
can be enabled and used on devices that support it. These patches enable the
driver, and set up the correct GPIO on supported Realtek-based switches from
Netgear.

Sander Vanheule (2):
  realtek: Enable gpio-restart driver
  realtek: netgear-gigabit: Add gpio-restart node

 target/linux/realtek/config-5.10   | 1 +
 target/linux/realtek/dts-5.10/rtl8380_netgear_gigabit.dtsi | 6 ++
 2 files changed, 7 insertions(+)

-- 
2.33.1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH 1/2] realtek: Enable gpio-restart driver

2021-11-24 Thread Sander Vanheule
Add the gpio-restart driver to the realtek build. This way devices,
which cannot reliably perform resets using the SoC's internal reset
logic, can use a GPIO line to drive the SoC's hard reset input.

Signed-off-by: Sander Vanheule 
---
 target/linux/realtek/config-5.10 | 1 +
 1 file changed, 1 insertion(+)

diff --git a/target/linux/realtek/config-5.10 b/target/linux/realtek/config-5.10
index 00f2a6af13ba..f75cf92897ad 100644
--- a/target/linux/realtek/config-5.10
+++ b/target/linux/realtek/config-5.10
@@ -158,6 +158,7 @@ CONFIG_PHYLIB=y
 CONFIG_PHYLINK=y
 CONFIG_PINCTRL=y
 CONFIG_POWER_RESET=y
+CONFIG_POWER_RESET_GPIO_RESTART=y
 CONFIG_POWER_RESET_SYSCON=y
 CONFIG_RATIONAL=y
 CONFIG_REALTEK_OTTO_WDT=y
-- 
2.33.1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH 2/2] realtek: netgear-gigabit: Add gpio-restart node

2021-11-24 Thread Sander Vanheule
The Netgear GS110TPP v1 switch cannot reliably perform cold reboots
using the system's internal reset controller.

On this device, and the other supported Netgear switches, internal GPIO
line 13 is connected to the system's hard reset logic. Expose this GPIO
on all systems to ensure restarts work properly.

Cc: Raylynn Knight 
Cc: Michael Mohr 
Cc: Stijn Segers 
Cc: Stijn Tintel 
Signed-off-by: Sander Vanheule 
---
 target/linux/realtek/dts-5.10/rtl8380_netgear_gigabit.dtsi | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/target/linux/realtek/dts-5.10/rtl8380_netgear_gigabit.dtsi 
b/target/linux/realtek/dts-5.10/rtl8380_netgear_gigabit.dtsi
index 6eb316231b47..72956359d18b 100644
--- a/target/linux/realtek/dts-5.10/rtl8380_netgear_gigabit.dtsi
+++ b/target/linux/realtek/dts-5.10/rtl8380_netgear_gigabit.dtsi
@@ -22,6 +22,12 @@
linux,code = ;
};
};
+
+   gpio-restart {
+   compatible = "gpio-restart";
+   gpios = <&gpio0 13 GPIO_ACTIVE_LOW>;
+   open-source;
+   };
 };
 
 &gpio0 {
-- 
2.33.1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH 0/2] External GPIO improvements for Netgear GS1xx and GS3xx

2021-11-24 Thread Sander Vanheule
Although all supported Netgear GS1xx/GS3xx switches have an RTL8231 GPIO
expander, this is not yet enabled on these devices. These patches fix the
device tree, and then expose the status LEDs on the GS110TPP v1.

Sander Vanheule (2):
  realtek: netgear-gigabit: Enable RTL8231
  realtek: netgear-gs110tpp: Add system LEDs

 .../dts-5.10/rtl8380_netgear_gigabit.dtsi |  6 ++--
 .../dts-5.10/rtl8380_netgear_gs110tpp-v1.dts  | 33 +++
 2 files changed, 37 insertions(+), 2 deletions(-)

-- 
2.33.1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH 1/2] realtek: netgear-gigabit: Enable RTL8231

2021-11-24 Thread Sander Vanheule
Since the move to 5.10, there are now two GPIO drivers. The gpio0 node
refers to the internal GPIOs, so the indirect-access-bus-id is no longer
relevant for that node.

Set indirect-access-bus-id to the correct value (31) on the correct node
(gpio1) and enable the device.

Cc: Raylynn Knight 
Cc: Michael Mohr 
Cc: Stijn Segers 
Cc: Stijn Tintel 
Signed-off-by: Sander Vanheule 
---
To everyone in CC, could you please verify that the RTL8231 is present
in your device(s) at address 31. On my GS110TPP the status LEDs are
located on external GPIOs 31, 32, and 34. Other devices configure the
same pins as outputs, so it is possible the status LED(s) is (are) also
present on these pins on other devices. For the GS310TP, external GPIO
functionality can also be tested through the lines for the SFP cages.

This applies to the following Netgear devices, see the links for vendor
GPIO info:
- GS108T v3 (https://biot.com/switches/gs108tv3)
- GS110TPP v1 (device status LEDs, tested by myself)
- GS308T v1 (https://biot.com/switches/gs308t)
- GS310TP v1 (https://biot.com/switches/gs310tp)
---
 target/linux/realtek/dts-5.10/rtl8380_netgear_gigabit.dtsi | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/target/linux/realtek/dts-5.10/rtl8380_netgear_gigabit.dtsi 
b/target/linux/realtek/dts-5.10/rtl8380_netgear_gigabit.dtsi
index 6eb316231b47..06e56032da1d 100644
--- a/target/linux/realtek/dts-5.10/rtl8380_netgear_gigabit.dtsi
+++ b/target/linux/realtek/dts-5.10/rtl8380_netgear_gigabit.dtsi
@@ -24,8 +24,10 @@
};
 };
 
-&gpio0 {
-   indirect-access-bus-id = <0>;
+&gpio1 {
+   status = "okay";
+
+   indirect-access-bus-id = <31>;
 };
 
 ðernet0 {
-- 
2.33.1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH 2/2] realtek: netgear-gs110tpp: Add system LEDs

2021-11-24 Thread Sander Vanheule
The GS110TPP has an RGB LED used for system status indication. Expose
all three components as separate GPIO LEDs connected via the device's
RTL8231.

Signed-off-by: Sander Vanheule 
---
 .../dts-5.10/rtl8380_netgear_gs110tpp-v1.dts  | 33 +++
 1 file changed, 33 insertions(+)

diff --git a/target/linux/realtek/dts-5.10/rtl8380_netgear_gs110tpp-v1.dts 
b/target/linux/realtek/dts-5.10/rtl8380_netgear_gs110tpp-v1.dts
index 8382d35a9da1..1ff209cee363 100644
--- a/target/linux/realtek/dts-5.10/rtl8380_netgear_gs110tpp-v1.dts
+++ b/target/linux/realtek/dts-5.10/rtl8380_netgear_gs110tpp-v1.dts
@@ -1,10 +1,43 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 
 #include "rtl8380_netgear_gigabit_1xx.dtsi"
+#include 
 
 / {
compatible = "netgear,gs110tpp-v1", "realtek,rtl838x-soc";
model = "Netgear GS110TPP v1";
+
+   aliases {
+   led-boot = &led_status_green;
+   led-failsafe = &led_status_red;
+   led-running = &led_status_green;
+   led-upgrade = &led_status_blue;
+   };
+
+   leds {
+   compatible = "gpio-leds";
+
+   led_status_red: led-0 {
+   label = "red:status";
+   color = ;
+   function = LED_FUNCTION_STATUS;
+   gpios = <&gpio1 31 GPIO_ACTIVE_LOW>;
+   };
+
+   led_status_green: led-1 {
+   label = "green:status";
+   color = ;
+   function = LED_FUNCTION_STATUS;
+   gpios = <&gpio1 32 GPIO_ACTIVE_LOW>;
+   };
+
+   led_status_blue: led-2 {
+   label = "blue:status";
+   color = ;
+   function = LED_FUNCTION_STATUS;
+   gpios = <&gpio1 34 GPIO_ACTIVE_LOW>;
+   };
+   };
 };
 
 &uart1 {
-- 
2.33.1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel