AR-150 Gl.Inet #define AR933X_ETH_CFG_SW_ONLY_MODE BIT(6)

Hi there ,

I am trying to reproduce [Solved] Swconfig router and switch gl.inet ar150 . Setting both RJ45 Ethernet plugs working under the switch present in the minirouter: AR-150 Gl.Inet. (I guess it was OpenWRT 18.x.x).

First step with thev new Device Tree (DT) system is adding to ar9330_glinet_gl-ar150.dts (openwrt-main\target\linux\ath79\dts)

a line that says switch-only-mode = <1>; somewhere near where the device is descripted:

&eth1 {
	status = "okay";

	nvmem-cells = <&macaddr_art_0>;
	nvmem-cell-names = "mac-address";

	gmac-config {
		device = <&gmac>;

		switch-phy-addr-swap = <0>;
		switch-phy-swap = <0>;
		switch-only-mode = <1>;
	};
};

I don't know if it will work or not, but before that I have to add :

ag71xx_of_bit(np, "switch-only-mode", &val, AR933X_ETH_CFG_SW_ONLY_MODE);

into static void ag71xx_setup_gmac_933x(.........)

of ag71xx_gmac.c (\openwrt-main\target\linux\ath79\files\drivers\net\ethernet\atheros\ag71xx)

and #define AR933X_ETH_CFG_SW_ONLY_MODE BIT(6) into the * AR933X GMAC interface block of ag71xx_regs.h (\openwrt-main\target\linux\ath79\files\drivers\net\ethernet\atheros\ag71xx).

My problem so far is that using this approach will raise an [error: AR933X_ETH_CFG_SW_ONLY_MODE ‘undeclared' (first use in this function)] during compile/build; Function being ag71xx_setup_gmac_933x of ag71xx_gmac.c

while all the others #define don't throw any error at all.

I can get the Build process to terminate without error, adding #define AR933X_ETH_CFG_SW_ONLY_MODE BIT(6) into
ag71xx_gmac.c (\openwrt-main\target\linux\ath79\files\drivers\net\ethernet\atheros\ag71xx)
directly, but this makes me feel uneasy.

What am I getting wrong? Why is that?

ag71xx_gmac.c has a line with #include "ag71xx.h"

and ag71xx.h (openwrt-main\target\linux\ath79\files\drivers\net\ethernet\atheros\ag71xx) has a line that says #include <asm/mach-ath79/ar71xx_regs.h>

Why do I get the undecleared error ?

And what does #include <asm/mach-ath79/ar71xx_regs.h>, actually do ?

The entries/lines

#include <asm/mach-ath79/ar71xx_regs.h>
#include <asm/mach-ath79/ath79.h>

are little bit tricky to find ..

these are in

arch/mips/include/asm/mach-ath79

in you favorite linux source tree.

You have to create a patch and copy this into

target/linux/ath79/patches-6.12/

If you know how, this work of one minute :grinning_face:

can you test ?

1 Like

I cant understand your answer, my question is

given that ar71xx_regs.h is in openwrt\target\linux\ath79\image\lzma-loader\src

why I have #include <asm/mach-ath79/ar71xx_regs.h>

instead of #include <target\linux\ath79\image\lzma-loader\src/ar71xx_regs.h> ?

Or am I missing something about how compile build works ?

please read here

Your target” directory will be at

build_dir/target-mips_24kc_musl/linux-ath79_generic/linux-6.12.57/

after “prepare” do here

git init
git add -A
git commit -m "root commit"

add the disiredt patches, i.e your BIT() thingy here, in

#include <asm/mach-ath79/ar71xx_regs.h>

commit with proper message

now do, for one patch

git format-patch -1 or better

copy the resulting "0001*” file to (note the nameing scheme there)

target/linux/ath79/patches-6.12

Voilà

1 Like

I edited the sources and used make clean but the compiler still complained about the include were missing

make clean

will delete all you work

with the above instructions I’ve created this

$ cat 380-MIPS-ath79-AR933x-GMAC-add-missing-switch-only-bit.patch 
From 46b49461c37d5d0deaa49f257309eb9213a72a63 Mon Sep 17 00:00:00 2001
From: Hans Ulli Kroll <linux@ulli-kroll.de>
Date: Thu, 20 Nov 2025 20:27:22 +0100
Subject: [PATCH] MIPS: ath79: AR933x GMAC add missing switch only bit

This adds missing switch only GMAC register definition for the
Qualcomm Atheros AR933X series MIPS SoCs.

Signed-off-by: Hans Ulli Kroll <linux@ulli-kroll.de>
---
 arch/mips/include/asm/mach-ath79/ar71xx_regs.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
index 38177c16a..3357169dd 100644
--- a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
+++ b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
@@ -1204,6 +1204,7 @@
 #define AR933X_ETH_CFG_MII_GE0_MASTER	BIT(3)
 #define AR933X_ETH_CFG_MII_GE0_SLAVE	BIT(4)
 #define AR933X_ETH_CFG_MII_GE0_ERR_EN	BIT(5)
+#define AR933X_ETH_CFG_SW_ONLY_MODE	BIT(6)
 #define AR933X_ETH_CFG_SW_PHY_SWAP	BIT(7)
 #define AR933X_ETH_CFG_SW_PHY_ADDR_SWAP	BIT(8)
 #define AR933X_ETH_CFG_RMII_GE0		BIT(9)
-- 
2.51.2

If you read the instruction carefully, you should know in which directory the patch belongs.

And yes this is compile tested with your ""switch-only-mode".

1 Like

ok got that , but if I want to add the define in source code where should I put it ?

My first question was wrong, can't edit anymore. I added the define to

openwrt\target\linux\ath79\image\lzma-loader\src\ar71xx_regs.h.

But the compiler was throwing the error. I get the all patching stuff, but why changing

ar71xx_regs.h doesnt get somehow into final build. I would expect that definitions to get somehow into build_dir ........

why ag71xx_gmac.c imports from ag71xx.h but not from ar71xx_regs.h ?

Ok think I got it because imports are to be considered at build_dir not source:

Is it ? Or am I wrong again ? Not sure my ar71xx_regs.h. in build_dir doesnt get the define SW_ONLY_MODE line , think I have to try clean rebuild again .....
..... not getting it, all other modified file keep modification in build_dir .......
unlesss some patch is reverting my changes ...

yes

I thougt your where not stupid ..

Your have too combine the last two post from me.

Now the simpler solution,

openwrt $ cat target/linux/ath79/patches-6.12/380-MIPS-ath79-AR933x-GMAC-add-missing-switch-only-bit.patch

From 46b49461c37d5d0deaa49f257309eb9213a72a63 Mon Sep 17 00:00:00 2001
From: Hans Ulli Kroll <linux@ulli-kroll.de>
Date: Thu, 20 Nov 2025 20:27:22 +0100
Subject: [PATCH] MIPS: ath79: AR933x GMAC add missing switch only bit

This adds missing switch only GMAC register definition for the
Qualcomm Atheros AR933X series MIPS SoCs.

Signed-off-by: Hans Ulli Kroll <linux@ulli-kroll.de>
---
 arch/mips/include/asm/mach-ath79/ar71xx_regs.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
index 38177c16a..3357169dd 100644
--- a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
+++ b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
@@ -1204,6 +1204,7 @@
 #define AR933X_ETH_CFG_MII_GE0_MASTER	BIT(3)
 #define AR933X_ETH_CFG_MII_GE0_SLAVE	BIT(4)
 #define AR933X_ETH_CFG_MII_GE0_ERR_EN	BIT(5)
+#define AR933X_ETH_CFG_SW_ONLY_MODE	BIT(6)
 #define AR933X_ETH_CFG_SW_PHY_SWAP	BIT(7)
 #define AR933X_ETH_CFG_SW_PHY_ADDR_SWAP	BIT(8)
 #define AR933X_ETH_CFG_RMII_GE0		BIT(9)
-- 
2.51.2

read carefully the first line and verify this with your openwrt tree.

Did you see something ?

maybe something missing ?

1 Like

yep went thorough QUILT, not brave enough to try git for the same purpose. Instructions seems clear here https://openwrt.org/docs/guide-developer/toolchain/use-patches-with-buildsystem#adding_or_editing_kernel_patches but they are not , a lot of try & redo. Are patches numbered with a precise pattern or just the last one get the higher number ?

Good you have found the solution, this was my idea

the quitl thing is for editing patches for a new version …

for numbering look here

Take the “closest” one

If you do a pull request it is very normal, that someone is arguing about your code ..

Make a good commit message,

1 Like

inside openwrt (source top level, cloned by git, let's say Documents/openwrt) --> make target/linux/{clean,prepare} V=s QUILT=1

then same dir --> cd build_dir/target-mips_24kc_musl/linux-ath79_generic/linux-X.X.XXX

then --> quilt series

then --> quilt push -a

then --> quilt new platform/380-MIPS-ath79-AR933x-GMAC-add-missing-switch-only-bit.patch

then --> in editor add the modification to the file in your configured editor (sudo update- alternatives --config editor stuff)

quilt edit arch/mips/include/asm/mach-ath79/ar71xx_regs.h

then --> quilt diff

Checks the patch results as an example for my needs:

         				Index: linux-6.6.114/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
				===================================================================
				--- linux-X.X.XXX.orig/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
				+++ linux-X.X.X/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
				@@ -1204,12 +1204,17 @@
 				#define AR933X_ETH_CFG_MII_GE0_MASTER	BIT(3)
 				#define AR933X_ETH_CFG_MII_GE0_SLAVE	BIT(4)
 				#define AR933X_ETH_CFG_MII_GE0_ERR_EN	BIT(5)
				+
				+#define AR933X_ETH_CFG_SW_ONLY_MODE	BIT(6)
				+
 				#define AR933X_ETH_CFG_SW_PHY_SWAP	BIT(7)
 				#define AR933X_ETH_CFG_SW_PHY_ADDR_SWAP	BIT(8)
 				#define AR933X_ETH_CFG_RMII_GE0		BIT(9)
 				#define AR933X_ETH_CFG_RMII_GE0_SPD_10	0
 				#define AR933X_ETH_CFG_RMII_GE0_SPD_100	BIT(10)
 				
				+#define AR933X_RESET_GE0_MDIO		BIT(22)
				+
 				/*
  				* AR934X GMAC Interface
  				*/

then --> quilt refresh

then --> Change back to the toplevel directory of the buildroot (source top level, cloned by git; for me, as above: Documents/openwrt)

then --> make target/linux/update package/index V=s

should appear patch in :

      ~/Documents/OpenWRT/openwrt/target/linux/ath79/patches-X.X/380-MIPS-ath79-AR933x-GMAC-add-missing-switch-only-bit.patch

then --> make js=1 or make js=1 V=s or make clean js=1 V=s (it will recompile everything though) to get the new build openwrt.bin with patch 480

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.