Skip to content
Merged
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
6 changes: 6 additions & 0 deletions config/boards/gateway-dk.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ KERNEL_TEST_TARGET="current"
HAS_VIDEO_OUTPUT="no"
BOOT_FDT_FILE="freescale/mono-gateway-dk.dtb"
BOOTENV_FILE="gateway-dk.txt"
# Remove fake-hwclock: we have a real pcf2131 RTC, util-linux-extra handles sync via udev
PACKAGE_LIST_BOARD_REMOVE="fake-hwclock"
INTRODUCED="2026"

# U-Boot, ATF, and RCW — Mono forks with custom DDR4 config and SERDES
declare -g BOOTSOURCE="https://github.com/we-are-mono/u-boot"
Expand Down Expand Up @@ -55,6 +58,9 @@ function post_family_tweaks__gateway_dk_services() {
display_alert "Installing fancontrol" "emc2305 + cluster_thermal" "info"
chroot_sdcard_apt_get_install fancontrol lm-sensors

# hwclock for RTC management (pcf2131 on I2C)
chroot_sdcard_apt_get_install util-linux-extra

chroot_sdcard systemctl enable gateway-dk-leds.service
chroot_sdcard systemctl enable generate-fancontrol-conf.service
chroot_sdcard systemctl enable fancontrol.service
Expand Down
1 change: 1 addition & 0 deletions config/kernel/linux-ls1046a-current.config
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ CONFIG_GPIO_SYSFS=y
CONFIG_GPIO_MPC8XXX=y
CONFIG_GPIO_SYSCON=y
CONFIG_GPIO_PCA953X=y
CONFIG_POWER_RESET_GPIO=y
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, let's check if we have the DTS patch mentioned in the review
find . -name "*002-arm64-dts-Add-Mono-Gateway-DK-device-tree.patch" -o -name "*ls1046a*" | head -20

Repository: armbian/build

Length of output: 394


🏁 Script executed:

# Check the current config file to understand the context
find . -name "linux-ls1046a-current.config" -type f

Repository: armbian/build

Length of output: 101


🏁 Script executed:

# Search for POWER_RESET in any existing config files
rg "CONFIG_POWER_RESET" --type txt

Repository: armbian/build

Length of output: 39


🏁 Script executed:

# Search for references to ARCH_LAYERSCAPE in the repo
rg "ARCH_LAYERSCAPE" --type txt

Repository: armbian/build

Length of output: 39


🏁 Script executed:

# Check the DTS patch to see what it adds
cat -n patch/kernel/archive/ls1046a-6.12/002-arm64-dts-Add-Mono-Gateway-DK-device-tree.patch | sed -n '60,70p'

Repository: armbian/build

Length of output: 338


🏁 Script executed:

# Check the config file around line 446
cat -n config/kernel/linux-ls1046a-current.config | sed -n '440,455p'

Repository: armbian/build

Length of output: 554


🏁 Script executed:

# Look for any other references to POWER_RESET in patches or configs
rg "POWER_RESET" --type-list | head -5

Repository: armbian/build

Length of output: 446


🏁 Script executed:

# Search in all files, not just txt
rg "POWER_RESET" 2>/dev/null | head -20

Repository: armbian/build

Length of output: 2643


🌐 Web query:

Linux 6.12 kernel POWER_RESET Kconfig POWER_RESET_GPIO dependency

💡 Result:

In Linux kernel 6.12, CONFIG_POWER_RESET_GPIO is the Kconfig option for the GPIO power-off driver (drivers/power/reset/gpio-poweroff.c), which toggles a GPIO pin to power off the board. It is located under the "Board level reset or power off" menu in drivers/power/reset/Kconfig. It depends on CONFIG_POWER_RESET (the menuconfig enabling the board-level poweroff/reset drivers) and CONFIG_OF_GPIO (for Device Tree GPIO support). Sources indicate this dependency structure has been consistent from kernels 3.8 through 6.19. Note: There is a separate CONFIG_POWER_RESET_GPIO_RESTART for GPIO-based restart (gpio-restart.c), and RESET_GPIO in drivers/reset/Kconfig (depends on GPIOLIB) for the generic reset controller framework, which is distinct from poweroff.

Citations:


Add CONFIG_POWER_RESET=y to enable the gpio-poweroff functionality.

CONFIG_POWER_RESET_GPIO depends on the parent CONFIG_POWER_RESET option in Linux 6.12. The DTS patch adds a gpio-poweroff device node, but without the parent symbol enabled, this node will be non-functional. This follows the established pattern in Armbian across other boards (filogic-6.16, sunxi kernels) where both symbols are explicitly enabled together.

🔧 Suggested config change
+CONFIG_POWER_RESET=y
 CONFIG_POWER_RESET_GPIO=y
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@config/kernel/linux-ls1046a-current.config` at line 446, The config enables
CONFIG_POWER_RESET_GPIO but omits its required parent CONFIG_POWER_RESET; update
the kernel config to also enable CONFIG_POWER_RESET so the gpio-poweroff DTS
node becomes functional—ensure both CONFIG_POWER_RESET and
CONFIG_POWER_RESET_GPIO are set to y (mirror the pattern used for other boards)
by adding CONFIG_POWER_RESET=y alongside the existing CONFIG_POWER_RESET_GPIO=y.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tomazzaman can you run ./compile.sh rewrite-kernel-config BOARD=gateway-dk BRANCH=current and check if the added config persists? Else the suggestion from coderabbit might need to be applied.

This comment was marked as off-topic.

CONFIG_SENSORS_LM75=y
CONFIG_SENSORS_EMC2103=y
CONFIG_SENSORS_EMC2305=y
Expand Down
69 changes: 51 additions & 18 deletions extensions/gateway-dk-ask.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# Source repos and refs (pinned to match Yocto)
# For local testing: set ASK_REPO="file:///path/to/ASK" — the Docker mount hook below handles it
declare -g ASK_REPO="https://github.com/we-are-mono/ASK.git"
declare -g ASK_BRANCH="commit:44883f88b26478fa2c9beea81702023cbc057f94"
declare -g ASK_BRANCH="commit:252b6db5a274383917c7a7688c931d61409978c2"
declare -g FMLIB_REPO="https://github.com/nxp-qoriq/fmlib.git"
declare -g FMLIB_COMMIT="7a58ecaf0d90d71d6b78d3ac7998282a472c4394"
declare -g FMC_REPO="https://github.com/nxp-qoriq/fmc.git"
Expand Down Expand Up @@ -162,18 +162,22 @@ function post_install_kernel_debs__ask_module_autoload() {
# Copy patches into chroot before patched library builds (runs before build_ask_userspace)
function pre_customize_image__000_prepare_ask_patches() {
mkdir -p "${SDCARD}/tmp/ask-patches"
local patch_dirs=("libnetfilter-conntrack" "libnfnetlink" "iptables")
local patch_dirs=("libnetfilter-conntrack" "libnfnetlink")
for pdir in "${patch_dirs[@]}"; do
[[ -d "${ASK_CACHE_DIR}/patches/${pdir}" ]] || exit_with_error "ASK patch directory missing" "${ASK_CACHE_DIR}/patches/${pdir}"
cp "${ASK_CACHE_DIR}/patches/${pdir}/"*.patch "${SDCARD}/tmp/ask-patches/"
done

# Enable deb-src for apt-get source
chroot_sdcard "if [ -f /etc/apt/sources.list.d/debian.sources ]; then \
sed -i 's/^Types: deb\$/Types: deb deb-src/' /etc/apt/sources.list.d/debian.sources; \
elif [ -f /etc/apt/sources.list ]; then \
sed -i 's/^#\\s*deb-src/deb-src/' /etc/apt/sources.list; \
fi && apt-get update -qq"
# Enable deb-src for apt-get source (handles both Debian and Ubuntu)
# deb822 format: *.sources files (Debian bookworm+, Ubuntu noble+)
# Legacy format: sources.list (older Debian/Ubuntu)
chroot_sdcard "shopt -s nullglob; \
for f in /etc/apt/sources.list.d/*.sources; do \
sed -i 's/^Types: deb\$/Types: deb deb-src/' \"\$f\"; \
done; \
if [ -f /etc/apt/sources.list ]; then \
sed -i 's/^#\\s*deb-src/deb-src/' /etc/apt/sources.list; \
fi && apt-get update -qq"
chroot_sdcard_apt_get_install dpkg-dev devscripts
}

Expand All @@ -186,10 +190,12 @@ function pre_customize_image__001_build_ask_userspace() {
[[ -z "${kernel_ver}" ]] && exit_with_error "No kernel version found in ${SDCARD}/lib/modules/"
local kdir="/usr/src/linux-headers-${kernel_ver}"

# Install build dependencies in chroot
# Install build dependencies and runtime packages in chroot
# iptables is a runtime dep — CMM uses QOSMARK rules via our xtables extensions
display_alert "ASK extension" "installing build dependencies" "info"
chroot_sdcard_apt_get_install build-essential \
pkg-config libxml2-dev libpcap-dev libcrypt-dev libtclap-dev
pkg-config libxml2-dev libpcap-dev libcrypt-dev libtclap-dev libxtables-dev \
iptables

# Copy sources into chroot
mkdir -p "${SDCARD}/tmp/ask-userspace"
Expand Down Expand Up @@ -269,6 +275,27 @@ function pre_customize_image__001_build_ask_userspace() {
cp "${ASK_CACHE_DIR}/${ASK_DPA_APP_DIR}/files/etc/cdx_pcd.xml" "${SDCARD}/etc/"
cp "${ASK_CACHE_DIR}/${ASK_DPA_APP_DIR}/files/etc/cdx_sp.xml" "${SDCARD}/etc/"

# --- xtables extensions (standalone .so files, not patching iptables) ---
# Note: we don't use pkg-config for libxtables here. These are dlopen()-loaded
# extensions — they don't link against libxtables.so, they use symbols resolved
# from the iptables process that loads them. The -I./include picks up our local
# xt_QOSMARK.h etc. UAPI headers which aren't in libxtables-dev (they're our
# additions). Adding -lxtables would cause duplicate symbol issues at load time.
local ask_xtables_modules=(libxt_qosmark libxt_QOSMARK libxt_qosconnmark libxt_QOSCONNMARK)
display_alert "ASK extension" "building xtables extensions" "info"
cp -a "${ASK_CACHE_DIR}/iptables-extensions" "${SDCARD}/tmp/ask-userspace/iptables-extensions"
chroot_sdcard "cd /tmp/ask-userspace/iptables-extensions && \
for name in ${ask_xtables_modules[*]}; do \
gcc -shared -fPIC -O2 \
-I./include \
-o \"\${name}.so\" \"\${name}.c\" || exit 1; \
done && \
install -d /usr/lib/${ASK_HOST_TRIPLET}/xtables && \
for name in ${ask_xtables_modules[*]}; do \
install -m 644 \"\${name}.so\" /usr/lib/${ASK_HOST_TRIPLET}/xtables/ || exit 1; \
done" \
|| exit_with_error "xtables extensions build failed"

# --- Patched system libraries (must be before CMM which depends on patched libnetfilter-conntrack) ---
build_ask_patched_libraries

Expand Down Expand Up @@ -307,7 +334,7 @@ function pre_customize_image__001_build_ask_userspace() {
# The postinst re-applies holds on every upgrade. Security updates must be
# tracked and re-patched manually.
display_alert "ASK extension" "pinning patched packages" "info"
chroot_sdcard "apt-mark hold libnetfilter-conntrack3 libnfnetlink0 iptables"
chroot_sdcard "apt-mark hold libnetfilter-conntrack3 libnfnetlink0"

# Install sysctl tuning for conntrack
install -Dm 644 "${SRC}/packages/bsp/gateway-dk/99-ls1046a-conntrack.conf" \
Expand Down Expand Up @@ -359,6 +386,15 @@ function pre_customize_image__001_build_ask_userspace() {
done
done

# xtables extensions — use the same explicit list as the build step
local ask_xtables_modules=(libxt_qosmark libxt_QOSMARK libxt_qosconnmark libxt_QOSCONNMARK)
mkdir -p "${pkgdir}/usr/lib/${ASK_HOST_TRIPLET}/xtables"
for name in "${ask_xtables_modules[@]}"; do
local src="${SDCARD}/usr/lib/${ASK_HOST_TRIPLET}/xtables/${name}.so"
[[ -f "${src}" ]] || exit_with_error "xtables extension missing" "${name}.so"
cp -a "${src}" "${pkgdir}/usr/lib/${ASK_HOST_TRIPLET}/xtables/"
done

# Version: kernel version + build date — allows bugfix rebuilds without kernel change
local ask_version="${kernel_ver}+$(date +%Y%m%d)"

Expand All @@ -374,7 +410,7 @@ Architecture: arm64
Section: net
Priority: optional
Maintainer: Mono Technologies <support@mono.si>
Depends: linux-image-${BRANCH}-${LINUXFAMILY} (>= ${kernel_ver}), libxml2, libpcap0.8
Depends: linux-image-${BRANCH}-${LINUXFAMILY} (>= ${kernel_ver}), libxml2, libpcap0.8, iptables
Description: NXP ASK hardware offloading userspace for Mono Gateway DK
Userspace tools (fmlib, fmc, libfci, libcli, dpa-app, cmm) and configuration
for NXP ASK data-plane acceleration on the LS1046A Gateway DK.
Expand All @@ -391,7 +427,7 @@ if command -v systemctl >/dev/null 2>&1; then
systemctl enable cmm.service 2>/dev/null || true
fi
# Re-pin patched ASK libraries — vanilla Debian versions break CMM/CDX offloading
apt-mark hold libnetfilter-conntrack3 libnfnetlink0 iptables 2>/dev/null || true
apt-mark hold libnetfilter-conntrack3 libnfnetlink0 2>/dev/null || true
EOF
chmod 755 "${pkgdir}/DEBIAN/postinst"

Expand All @@ -406,7 +442,7 @@ EOF
ldconfig || true
systemctl daemon-reload || true
if [ "\$1" = "remove" ] || [ "\$1" = "purge" ]; then
apt-mark unhold libnetfilter-conntrack3 libnfnetlink0 iptables 2>/dev/null || true
apt-mark unhold libnetfilter-conntrack3 libnfnetlink0 2>/dev/null || true
fi
EOF
chmod 755 "${pkgdir}/DEBIAN/postrm"
Expand Down Expand Up @@ -438,7 +474,7 @@ function build_ask_patched_libraries() {
# Install all build dependencies upfront
display_alert "ASK extension" "installing build deps for patched libraries" "info"
chroot_sdcard "DEBIAN_FRONTEND=noninteractive apt-get -y build-dep \
libnetfilter-conntrack libnfnetlink iptables"
libnetfilter-conntrack libnfnetlink"

# Staging dir for patched .debs (saved to output later)
mkdir -p "${SDCARD}/tmp/ask-patched-debs"
Expand All @@ -452,9 +488,6 @@ function build_ask_patched_libraries() {
"01-nxp-ask-nonblocking-heap-buffer.patch" \
"libnfnetlink0_*.deb libnfnetlink-dev_*.deb"

rebuild_patched_deb "iptables" \
"001-qosmark-extensions.patch" \
"libip4tc2_*.deb libip6tc2_*.deb libxtables12_*.deb iptables_*.deb"

# Copy patched .debs to output for distribution
mkdir -p "${SRC}/output/debs"
Expand Down
52 changes: 30 additions & 22 deletions packages/bsp/gateway-dk/sfp-led.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,19 @@
* sfp0: sfp-0 {
* compatible = "sff,sfp";
* i2c-bus = <&sfp0_i2c>;
* leds = <&led_sfp0_link>, <&led_sfp0_activity>;
* };
*
* sfp-led-controller {
* compatible = "mono,sfp-led";
* sfp-ports = <&sfp0>, <&sfp1>;
*
* port@0 {
* sfp = <&sfp0>;
* leds = <&led_sfp0_link>, <&led_sfp0_activity>;
* };
* port@1 {
* sfp = <&sfp1>;
* leds = <&led_sfp1_link>, <&led_sfp1_activity>;
* };
* };
*
* // MAC node must reference SFP for netdev association
Expand Down Expand Up @@ -483,14 +490,21 @@ static void sfp_led_poll_work_handler(struct work_struct *work)
}

static int sfp_led_register_port(struct sfp_led_priv *priv,
struct device_node *sfp_np, int index)
struct device_node *port_np, int index)
{
struct sfp_led_port *port = &priv->ports[index];
struct device_node *i2c_np;
struct device_node *sfp_np, *i2c_np;

/* Parse SFP node from port child node */
sfp_np = of_parse_phandle(port_np, "sfp", 0);
if (!sfp_np) {
dev_err(priv->dev, "port %d: missing sfp phandle\n", index);
return -ENODEV;
}

port->priv = priv;
port->sfp_np = sfp_np;
of_node_get(sfp_np);
/* sfp_np has ref from of_parse_phandle — don't add of_node_get */

/* Get I2C adapter for module detection */
i2c_np = of_parse_phandle(sfp_np, "i2c-bus", 0);
Expand All @@ -510,15 +524,15 @@ static int sfp_led_register_port(struct sfp_led_priv *priv,
return ret ? ret : -ENODEV;
}

/* Get LEDs */
port->link_led = of_led_get(sfp_np, 0);
/* Get LEDs from port child node */
port->link_led = of_led_get(port_np, 0);
if (IS_ERR(port->link_led)) {
dev_dbg(priv->dev, "port %d: link LED not in DT: %ld\n",
index, PTR_ERR(port->link_led));
port->link_led = NULL;
}

port->activity_led = of_led_get(sfp_np, 1);
port->activity_led = of_led_get(port_np, 1);
if (IS_ERR(port->activity_led)) {
dev_dbg(priv->dev, "port %d: activity LED not in DT: %ld\n",
index, PTR_ERR(port->activity_led));
Expand Down Expand Up @@ -589,7 +603,7 @@ static void sfp_led_cleanup_port(struct sfp_led_port *port)
static int sfp_led_probe(struct platform_device *pdev)
{
struct sfp_led_priv *priv;
struct device_node *np;
struct device_node *child;
int count, i, registered = 0;

priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
Expand All @@ -599,9 +613,9 @@ static int sfp_led_probe(struct platform_device *pdev)
priv->dev = &pdev->dev;
platform_set_drvdata(pdev, priv);

count = of_count_phandle_with_args(pdev->dev.of_node, "sfp-ports", NULL);
if (count <= 0) {
dev_err(&pdev->dev, "no sfp-ports specified\n");
count = of_get_child_count(pdev->dev.of_node);
if (count == 0) {
dev_err(&pdev->dev, "no port child nodes specified\n");
return -ENODEV;
}

Expand All @@ -612,17 +626,11 @@ static int sfp_led_probe(struct platform_device *pdev)

priv->num_ports = count;

for (i = 0; i < count; i++) {
np = of_parse_phandle(pdev->dev.of_node, "sfp-ports", i);
if (!np) {
dev_warn(&pdev->dev, "failed to parse sfp-ports[%d]\n", i);
continue;
}

if (sfp_led_register_port(priv, np, i) == 0)
i = 0;
for_each_child_of_node(pdev->dev.of_node, child) {
if (sfp_led_register_port(priv, child, i) == 0)
registered++;

of_node_put(np);
i++;
}

if (registered == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ diff --git a/arch/arm64/boot/dts/freescale/mono-gateway-dk.dts b/arch/arm64/boot
new file mode 100644
--- /dev/null
+++ b/arch/arm64/boot/dts/freescale/mono-gateway-dk.dts
@@ -0,0 +1,1021 @@
@@ -0,0 +1,1030 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Device Tree file for Mono Gateway DK (NXP LS1046A).
Expand Down Expand Up @@ -60,6 +60,12 @@ new file mode 100644
+ stdout-path = "serial0:115200n8";
+ };
+
+ gpio-poweroff {
+ compatible = "gpio-poweroff";
+ gpios = <&gpio2 21 GPIO_ACTIVE_HIGH>;
+ timeout-ms = <1000>;
+ };
+
+ leds {
+ compatible = "gpio-leds";
+
Expand Down Expand Up @@ -98,7 +104,6 @@ new file mode 100644
+ mod-def0-gpios = <&gpio2 12 GPIO_ACTIVE_LOW>;
+ los-gpios = <&gpio2 11 GPIO_ACTIVE_HIGH>;
+ maximum-power-milliwatt = <3000>;
+ leds = <&led_sfp0_link>, <&led_sfp0_activity>;
+ };
+
+ /* SFP 2 */
Expand All @@ -109,13 +114,22 @@ new file mode 100644
+ mod-def0-gpios = <&gpio2 10 GPIO_ACTIVE_LOW>;
+ los-gpios = <&gpio2 9 GPIO_ACTIVE_HIGH>;
+ maximum-power-milliwatt = <3000>;
+ leds = <&led_sfp1_link>, <&led_sfp1_activity>;
+ };
+
+ /* SFP LED Controller */
+ /* SFP LED Controller — LEDs are on the controller node, not SFP nodes
+ * (sff,sfp binding has additionalProperties: false) */
+ sfp_led_controller: sfp-led-controller {
+ compatible = "mono,sfp-led";
+ sfp-ports = <&sfp_xfi0>, <&sfp_xfi1>;
+
+ port@0 {
+ sfp = <&sfp_xfi0>;
+ leds = <&led_sfp0_link>, <&led_sfp0_activity>;
+ };
+
+ port@1 {
+ sfp = <&sfp_xfi1>;
+ leds = <&led_sfp1_link>, <&led_sfp1_activity>;
+ };
+ };
+
+ /* Boot memory regions for SDK DPAA driver */
Expand Down Expand Up @@ -599,11 +613,6 @@ new file mode 100644
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ partition@flash {
+ label = "flash";
+ reg = <0x0 0x4000000>;
+ };
+
+ partition@0 {
+ label = "rcw-bl2";
+ reg = <0x0 0x100000>;
Expand Down
Loading