From be8de642a1a86c73c6f3f4012840d7dce2f9bd93 Mon Sep 17 00:00:00 2001 From: Tomaz Zaman Date: Mon, 10 Aug 2026 15:38:37 +0200 Subject: [PATCH 08/72] layerscape: network defaults and INA234 support eth0-eth2 bridged as lan, eth3 DHCP wan, eth4 as lan2 (192.168.2.1/24, lan firewall zone, own DHCP pool). Board name matching covers the -sdboot suffix appended by 02_sysinfo_fixup. Port the meta-mono/Armbian ina2xx INA234 patch for the eight on-board power monitors. Co-Authored-By: Claude Fable 5 --- .../base-files/etc/board.d/02_network | 7 + .../etc/uci-defaults/99-mono-gateway-lan2 | 22 +++ .../300-hwmon-ina2xx-Add-INA234-support.patch | 128 ++++++++++++++++++ 3 files changed, 157 insertions(+) create mode 100644 target/linux/layerscape/base-files/etc/uci-defaults/99-mono-gateway-lan2 create mode 100644 target/linux/layerscape/patches-ask/300-hwmon-ina2xx-Add-INA234-support.patch diff --git a/target/linux/layerscape/base-files/etc/board.d/02_network b/target/linux/layerscape/base-files/etc/board.d/02_network index 0a42323801..7a2341b7ca 100644 --- a/target/linux/layerscape/base-files/etc/board.d/02_network +++ b/target/linux/layerscape/base-files/etc/board.d/02_network @@ -13,6 +13,13 @@ case "$(board_name)" in ucidef_set_interface_lan "eth0 eth1 eth2 eth3" ucidef_set_interface_wan "eth6" ;; + mono,gateway-dk|\ + mono,gateway-dk-sdboot) + ucidef_set_interface_lan "eth0 eth1 eth2" + ucidef_set_interface_wan "eth3" + ucidef_set_interface "lan2" device "eth4" protocol "static" \ + ipaddr "192.168.2.1" netmask "255.255.255.0" + ;; esac board_config_flush diff --git a/target/linux/layerscape/base-files/etc/uci-defaults/99-mono-gateway-lan2 b/target/linux/layerscape/base-files/etc/uci-defaults/99-mono-gateway-lan2 new file mode 100644 index 0000000000..6ac9154c16 --- /dev/null +++ b/target/linux/layerscape/base-files/etc/uci-defaults/99-mono-gateway-lan2 @@ -0,0 +1,22 @@ +#!/bin/sh +# Put the Mono Gateway's second LAN (eth4 / 192.168.2.1) into the lan +# firewall zone so it gets the same forwarding/NAT policy as br-lan. +. /lib/functions.sh + +[ "$(board_name)" = "mono,gateway-dk" ] || [ "$(board_name)" = "mono,gateway-dk-sdboot" ] || exit 0 + +uci -q get firewall.@zone[0] >/dev/null || exit 0 +uci add_list firewall.@zone[0].network='lan2' +uci commit firewall + +# DHCP pool for lan2 (br-lan gets the stock 'lan' pool already) +uci -q get dhcp.lan2 >/dev/null || { + uci set dhcp.lan2=dhcp + uci set dhcp.lan2.interface='lan2' + uci set dhcp.lan2.start='100' + uci set dhcp.lan2.limit='150' + uci set dhcp.lan2.leasetime='12h' + uci commit dhcp +} + +exit 0 diff --git a/target/linux/layerscape/patches-ask/300-hwmon-ina2xx-Add-INA234-support.patch b/target/linux/layerscape/patches-ask/300-hwmon-ina2xx-Add-INA234-support.patch new file mode 100644 index 0000000000..2b78f3fafe --- /dev/null +++ b/target/linux/layerscape/patches-ask/300-hwmon-ina2xx-Add-INA234-support.patch @@ -0,0 +1,128 @@ +From: Tomaz Zaman +Date: Tue, 21 Oct 2025 12:00:00 +0000 +Subject: [PATCH] hwmon: ina2xx: Add INA234 support as INA226 variant + +Add support for the Texas Instruments INA234 power monitor. + +The INA234 is a 12-bit device with similar register layout to INA226. +The key difference is the bus voltage LSB: INA234 uses 3.125mV which +becomes 1.6mV effective LSB due to the 12-bit format (data in bits +[15:4] with bits [3:0] reserved). + +Datasheet: https://www.ti.com/product/ina234 + +Upstream-Status: Inappropriate [embedded specific] +Signed-off-by: Tomaz Zaman +--- + drivers/hwmon/ina2xx.c | 27 ++++++++++++++++++++------- + 1 file changed, 20 insertions(+), 7 deletions(-) + +diff --git a/drivers/hwmon/ina2xx.c b/drivers/hwmon/ina2xx.c +index xxxxxxxx..xxxxxxxx 100644 +--- a/drivers/hwmon/ina2xx.c ++++ b/drivers/hwmon/ina2xx.c +@@ -125,7 +125,7 @@ + .writeable_reg = ina2xx_writeable_reg, + }; + +-enum ina2xx_ids { ina219, ina226 }; ++enum ina2xx_ids { ina219, ina226, ina234 }; + + struct ina2xx_config { + u16 config_default; +@@ -164,6 +164,14 @@ + .bus_voltage_lsb = 1250, + .power_lsb_factor = 25, + }, ++ [ina234] = { ++ .config_default = INA226_CONFIG_DEFAULT, ++ .calibration_value = 2048, ++ .shunt_div = 400, ++ .bus_voltage_shift = 4, ++ .bus_voltage_lsb = 25600, ++ .power_lsb_factor = 32, ++ }, + }; + + /* +@@ -633,12 +641,12 @@ + return 0444; + case hwmon_in_lcrit: + case hwmon_in_crit: +- if (chip == ina226) ++ if (chip == ina226 || chip == ina234) + return 0644; + break; + case hwmon_in_lcrit_alarm: + case hwmon_in_crit_alarm: +- if (chip == ina226) ++ if (chip == ina226 || chip == ina234) + return 0444; + break; + default: +@@ -651,12 +659,12 @@ + return 0444; + case hwmon_curr_lcrit: + case hwmon_curr_crit: +- if (chip == ina226) ++ if (chip == ina226 || chip == ina234) + return 0644; + break; + case hwmon_curr_lcrit_alarm: + case hwmon_curr_crit_alarm: +- if (chip == ina226) ++ if (chip == ina226 || chip == ina234) + return 0444; + break; + default: +@@ -668,11 +676,11 @@ + case hwmon_power_input: + return 0444; + case hwmon_power_crit: +- if (chip == ina226) ++ if (chip == ina226 || chip == ina234) + return 0644; + break; + case hwmon_power_crit_alarm: +- if (chip == ina226) ++ if (chip == ina226 || chip == ina234) + return 0444; + break; + default: +@@ -682,7 +690,7 @@ + case hwmon_chip: + switch (attr) { + case hwmon_chip_update_interval: +- if (chip == ina226) ++ if (chip == ina226 || chip == ina234) + return 0644; + break; + default: +@@ -802,7 +810,7 @@ + if (ret < 0) + return ret; + +- if (data->chip == ina226) { ++ if (data->chip == ina226 || data->chip == ina234) { + bool active_high = device_property_read_bool(dev, "ti,alert-polarity-active-high"); + + regmap_update_bits(regmap, INA226_MASK_ENABLE, +@@ -872,6 +880,7 @@ + { "ina226", ina226 }, + { "ina230", ina226 }, + { "ina231", ina226 }, ++ { "ina234", ina234 }, + { } + }; + MODULE_DEVICE_TABLE(i2c, ina2xx_id); +@@ -897,6 +906,10 @@ + .compatible = "ti,ina231", + .data = (void *)ina226 + }, ++ { ++ .compatible = "ti,ina234", ++ .data = (void *)ina234 ++ }, + { }, + }; + MODULE_DEVICE_TABLE(of, ina2xx_of_match); -- 2.47.3