Skip to contentSkip to conversation

provide ethernet support for ar9344 and ar9331

PATCH Superseded Oleksij Rempel 2 participants 12 messages Sep 13, 2017 – Sep 14, 2017

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#4 lore raw

PATCH v2 3/10 MIPS: dts: ar9344: add mac0 node

In reply to Oleksij Rempel

this node is supported by ag71xx driver

---
 arch/mips/dts/ar9344.dtsi | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/mips/dts/ar9344.dtsi +10 -0
index 0838e8d7f..858751112 100644
@@ -40,6 +40,16 @@
 			status = "disabled";
 		};
 
+		mac0: mac@19000000 {
+			compatible = "qca,ar9344-gmac0";
+			reg = <0x18070000 0x00000100>,
+			      <0x19000000 0x01000000>;
+			reg-names = "gmac", "ge0";
+			phy-mode = "rgmii";
+
+			status = "disabled";
+		};
+
 		spi: spi@1f000000 {
 			compatible = "qca,ar7100-spi", "qca,ar9344-spi";
 			reg = <0x1f000000 0x1c>;
Signature · 7 lines
2.11.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#11 lore raw

PATCH v2 10/10 MIPS: dts: ar9344: add APB bus

In reply to Oleksij Rempel

and move nodes which belong to APB.

---
 arch/mips/dts/ar9344.dtsi | 42 +++++++++++++++++++++++++-----------------
 1 file changed, 25 insertions(+), 17 deletions(-)
arch/mips/dts/ar9344.dtsi +25 -17
index 858751112..3e105174d 100644
@@ -29,15 +29,33 @@
 		#address-cells = <1>;
 		#size-cells = <1>;
 
-		uart0: uart@18020000 {
-			compatible = "ns16550a", "qca,ar9344-uart0";
-			reg = <0x18020000 0x20>;
+		apb {
+			compatible = "simple-bus";
+			ranges;
 
-			reg-shift = <2>;
-			reg-io-width = <4>;
-			big-endian;
+			#address-cells = <1>;
+			#size-cells = <1>;
 
-			status = "disabled";
+			uart0: uart@18020000 {
+				compatible = "ns16550a", "qca,ar9344-uart0";
+				reg = <0x18020000 0x20>;
+
+				reg-shift = <2>;
+				reg-io-width = <4>;
+				big-endian;
+
+				status = "disabled";
+			};
+
+			spi: spi@1f000000 {
+				compatible = "qca,ar7100-spi", "qca,ar9344-spi";
+				reg = <0x1f000000 0x1c>;
+
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+				status = "disabled";
+			};
 		};
 
 		mac0: mac@19000000 {
@@ -49,15 +67,5 @@
 
 			status = "disabled";
 		};
-
-		spi: spi@1f000000 {
-			compatible = "qca,ar7100-spi", "qca,ar9344-spi";
-			reg = <0x1f000000 0x1c>;
-
-			#address-cells = <1>;
-			#size-cells = <0>;
-
-			status = "disabled";
-		};
 	};
 };
Signature · 7 lines
2.11.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#0 lore raw

v2 cover provide ethernet support for ar9344 and ar9331

changes v2:
- merge all ag71xx in to one patch
- make sere all new driver use dev_* instead of printk
- rework miibus functions.
- use it_timedout instead of own implementation
- add comments to the patches.

Oleksij Rempel (9):
add ar9331.dtsi and enable mac0
MIPS: dts: ar9344: add mac0 node
MIPS: dts: tl_wdr4300: enable mac0
MIPS: dts: tl_wdr4300: add alias for spiflash
MIPS: dts: tl_wdr4300: remove RO flag from barebox partition add phy: ar8327 driver
MIPS: dts: tl_wdr4300: rename it to tl_wdr4300 v1.7
MIPS: tplink-wdr4300_defconfig: add network support
MIPS: dts: ar9344: add APB bus

Yegor Yefremov (1):
net: ath79: add ag71xx Ethernet driver

 arch/mips/configs/tplink-wdr4300_defconfig         |  12 +-
 arch/mips/dts/ar9331.dtsi                          |  12 +
 ...4_tl_wdr4300.dts => ar9344-tl-wdr4300-v1.7.dts} |  10 +-
 arch/mips/dts/ar9344.dtsi                          |  44 +-
 arch/mips/dts/tplink-mr3020.dts                    |   5 +
 arch/mips/mach-ath79/include/mach/ar71xx_regs.h    |  12 +
 drivers/net/Kconfig                                |   7 +
 drivers/net/Makefile                               |   1 +
 drivers/net/ag71xx.c                               | 673 +++++++++++++++++++++
 drivers/net/phy/Kconfig                            |   5 +
 drivers/net/phy/Makefile                           |   1 +
 drivers/net/phy/ar8327.c                           | 280 +++++++++
 12 files changed, 1042 insertions(+), 20 deletions(-)
 create mode 100644 arch/mips/dts/ar9331.dtsi
 rename arch/mips/dts/{ar9344_tl_wdr4300.dts => ar9344-tl-wdr4300-v1.7.dts} (85%)
 create mode 100644 drivers/net/ag71xx.c
 create mode 100644 drivers/net/phy/ar8327.c
Signature · 7 lines
2.11.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw

PATCH v2 2/10 add ar9331.dtsi and enable mac0

---
 arch/mips/dts/ar9331.dtsi       | 12 ++++++++++++
 arch/mips/dts/tplink-mr3020.dts |  5 +++++
 2 files changed, 17 insertions(+)
 create mode 100644 arch/mips/dts/ar9331.dtsi
arch/mips/dts/ar9331.dtsi new file +12 -0
new file mode 100644
index 000000000..b4b8b766b
@@ -0,0 +1,12 @@
+/ {
+	ahb {
+		mac0: mac@19000000 {
+			compatible = "qca,ar9331-ge0";
+			reg = <0x18070000 0x00000100>,
+			      <0x19000000 0x01000000>;
+			reg-names = "gmac", "ge0";
+			phy-mode = "mii";
+			status = "disabled";
+               };
+	};
+};
arch/mips/dts/tplink-mr3020.dts +5 -0
index eaae11edd..6f1ad1350 100644
@@ -1,4 +1,5 @@
 #include <mips/qca/ar9331_tl_mr3020.dts>
+#include "ar9331.dtsi"
 
 / {
 	aliases {
@@ -24,3 +25,7 @@
 		reg = <0x80000 0x10000>;
 	};
 };
+
+&mac0 {
+	status = "okay";
+};
Signature · 7 lines
2.11.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#10 lore raw

PATCH v2 9/10 MIPS: tplink-wdr4300_defconfig: add network support

In reply to Oleksij Rempel
---
 arch/mips/configs/tplink-wdr4300_defconfig | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
arch/mips/configs/tplink-wdr4300_defconfig +7 -3
index b5be221f6..46093d243 100644
@@ -32,6 +32,10 @@ CONFIG_CMD_LET=y
 CONFIG_CMD_MSLEEP=y
 CONFIG_CMD_READF=y
 CONFIG_CMD_SLEEP=y
+CONFIG_CMD_DHCP=y
+CONFIG_CMD_HOST=y
+CONFIG_CMD_MIITOOL=y
+CONFIG_CMD_PING=y
 CONFIG_CMD_ECHO_E=y
 CONFIG_CMD_EDIT=y
 CONFIG_CMD_READLINE=y
@@ -55,15 +59,13 @@ CONFIG_CMD_TIME=y
 CONFIG_NET=y
 CONFIG_NET_NFS=y
 CONFIG_NET_NETCONSOLE=y
-CONFIG_NET_RESOLV=y
-CONFIG_NET_DHCP=y
 CONFIG_NET_SNTP=y
 CONFIG_OFDEVICE=y
 CONFIG_OF_BAREBOX_DRIVERS=y
 CONFIG_OF_BAREBOX_ENV_IN_FS=y
 CONFIG_DRIVER_SERIAL_NS16550=y
 CONFIG_DRIVER_NET_AG71XX=y
-CONFIG_AT803X_PHY=y
+CONFIG_AR8327N_PHY=y
 CONFIG_MDIO_BITBANG=y
 CONFIG_MDIO_GPIO=y
 CONFIG_DRIVER_SPI_ATH79=y
@@ -74,5 +76,7 @@ CONFIG_LED=y
 CONFIG_LED_GPIO=y
 CONFIG_LED_GPIO_OF=y
 CONFIG_LED_TRIGGERS=y
+CONFIG_FS_TFTP=y
+CONFIG_FS_NFS=y
 CONFIG_DIGEST_SHA224_GENERIC=y
 CONFIG_DIGEST_SHA256_GENERIC=y
Signature · 7 lines
2.11.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#5 lore raw

PATCH v2 4/10 MIPS: dts: tl_wdr4300: enable mac0

In reply to Oleksij Rempel
---
 arch/mips/dts/ar9344_tl_wdr4300.dts | 4 ++++
 1 file changed, 4 insertions(+)
arch/mips/dts/ar9344_tl_wdr4300.dts +4 -0
index b02c1d730..5a4a6f379 100644
@@ -61,3 +61,7 @@
 		};
 	};
 };
+
+&mac0 {
+	status = "okay";
+};
Signature · 7 lines
2.11.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#6 lore raw

PATCH v2 5/10 MIPS: dts: tl_wdr4300: add alias for spiflash

In reply to Oleksij Rempel

to unify the naming with TP-Link TL-MR3020.

---
 arch/mips/dts/ar9344_tl_wdr4300.dts | 1 +
 1 file changed, 1 insertion(+)
arch/mips/dts/ar9344_tl_wdr4300.dts +1 -0
index 5a4a6f379..c784e6cb4 100644
@@ -11,6 +11,7 @@
 
 	aliases {
 		serial0 = &uart0;
+		spiflash = &spiflash;
 	};
 
 	memory@0 {
Signature · 7 lines
2.11.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#9 lore raw

PATCH v2 8/10 MIPS: dts: tl_wdr4300: rename it to tl_wdr4300 v1.7

In reply to Oleksij Rempel

The minor version of TP-Link are usually big enough that it need extra vendor partition on the flash with additional configurations like PLL, CPU and RAM freqs.

Visually I was able to confirm at least different SPI Flash and RAM chips.

---
 arch/mips/configs/tplink-wdr4300_defconfig                          | 2 +-
 arch/mips/dts/{ar9344_tl_wdr4300.dts => ar9344-tl-wdr4300-v1.7.dts} | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
 rename arch/mips/dts/{ar9344_tl_wdr4300.dts => ar9344-tl-wdr4300-v1.7.dts} (91%)
arch/mips/configs/tplink-wdr4300_defconfig +1 -1
index 63189b754..b5be221f6 100644
@@ -1,5 +1,5 @@
 CONFIG_BUILTIN_DTB=y
-CONFIG_BUILTIN_DTB_NAME="ar9344_tl_wdr4300"
+CONFIG_BUILTIN_DTB_NAME="ar9344-tl-wdr4300-v1.7"
 CONFIG_MACH_MIPS_ATH79=y
 CONFIG_BOARD_TPLINK_WDR4300=y
 CONFIG_PBL_IMAGE=y
arch/mips/dts/ar9344-tl-wdr4300-v1.7.dts renamed from arch/mips/dts/ar9344_tl_wdr4300.dts +2 -2
similarity index 91%
rename from arch/mips/dts/ar9344_tl_wdr4300.dts
rename to arch/mips/dts/ar9344-tl-wdr4300-v1.7.dts
index 139717a6b..d16cab005 100644
@@ -6,8 +6,8 @@
 #include "ar9344.dtsi"
 
 / {
-	model = "TP-Link WDR4300";
-	compatible = "tplink,tl-wdr4300";
+	model = "TP-Link WDR4300 v1.7";
+	compatible = "tplink,tl-wdr4300", "tplink,tl-wdr4300-v1.7";
 
 	aliases {
 		serial0 = &uart0;
Signature · 7 lines
2.11.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#7 lore raw

PATCH v2 6/10 MIPS: dts: tl_wdr4300: remove RO flag from barebox partition

In reply to Oleksij Rempel

we need it RW for barebox updates.

---
 arch/mips/dts/ar9344_tl_wdr4300.dts | 1 -
 1 file changed, 1 deletion(-)
arch/mips/dts/ar9344_tl_wdr4300.dts +0 -1
index c784e6cb4..139717a6b 100644
@@ -53,7 +53,6 @@
 		partition@0 {
 			label = "barebox";
 			reg = <0 0x80000>;
-			read-only;
 		};
 
 		partition@80000 {
Signature · 7 lines
2.11.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#8 lore raw

PATCH v2 7/10 add phy: ar8327 driver

In reply to Oleksij Rempel
---
 drivers/net/phy/Kconfig  |   5 +
 drivers/net/phy/Makefile |   1 +
 drivers/net/phy/ar8327.c | 280 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 286 insertions(+)
 create mode 100644 drivers/net/phy/ar8327.c
drivers/net/phy/Kconfig +5 -0
index d30f65b8e..ea2e06265 100644
@@ -8,6 +8,11 @@ if PHYLIB
 
 comment "MII PHY device drivers"
 
+config AR8327N_PHY
+	bool "Driver for QCA AR8327N PHYs"
+	---help---
+	  Currently supports the AR8327N PHY.
+
 config AT803X_PHY
 	bool "Driver for Atheros AT803X PHYs"
 	---help---
drivers/net/phy/Makefile +1 -0
index 10732f807..13b8f6545 100644
@@ -1,4 +1,5 @@
 obj-y += phy.o mdio_bus.o
+obj-$(CONFIG_AR8327N_PHY)	+= ar8327.o
 obj-$(CONFIG_AT803X_PHY)	+= at803x.o
 obj-$(CONFIG_LXT_PHY)		+= lxt.o
 obj-$(CONFIG_MARVELL_PHY)	+= marvell.o
drivers/net/phy/ar8327.c new file +280 -0

280 lines not on this page · raw message

Signature · 7 lines
2.11.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

PATCH v2 1/10 net: ath79: add ag71xx Ethernet driver

In reply to Oleksij Rempel

From: Yegor Yefremov <[email protected]>

---
 arch/mips/mach-ath79/include/mach/ar71xx_regs.h |  12 +
 drivers/net/Kconfig                             |   7 +
 drivers/net/Makefile                            |   1 +
 drivers/net/ag71xx.c                            | 673 ++++++++++++++++++++++++
 4 files changed, 693 insertions(+)
 create mode 100644 drivers/net/ag71xx.c
arch/mips/mach-ath79/include/mach/ar71xx_regs.h +12 -0
index f56c3f724..31d33b3c4 100644
@@ -102,6 +102,8 @@
 #define AR933X_PLL_CLOCK_CTRL_REG	0x08
 #define AR933X_PLL_DITHER_FRAC_REG	0x10
 #define AR933X_PLL_DITHER_REG		0x14
+#define AR933X_ETHSW_CLOCK_CONTROL_REG	0x24
+#define AR933X_ETH_XMII_CONTROL_REG	0x2c
 
 #define AR933X_PLL_CPU_CONFIG_NINT_SHIFT	10
 #define AR933X_PLL_CPU_CONFIG_NINT_MASK		0x3f
@@ -125,6 +127,16 @@
 #define AR933X_RESET_REG_RESET_MODULE		0x1c
 #define AR933X_RESET_REG_BOOTSTRAP		0xac
 
+#define AR933X_RESET_GE1_MDIO           BIT(23)
+#define AR933X_RESET_GE0_MDIO           BIT(22)
+#define AR933X_RESET_GE1_MAC            BIT(13)
+#define AR933X_RESET_WMAC               BIT(11)
+#define AR933X_RESET_GE0_MAC            BIT(9)
+#define AR933X_RESET_SWITCH             BIT(8)
+#define AR933X_RESET_USB_HOST           BIT(5)
+#define AR933X_RESET_USB_PHY            BIT(4)
+#define AR933X_RESET_USBSUS_OVERRIDE    BIT(3)
+
 #define AR71XX_RESET_FULL_CHIP		BIT(24)
 
 #define AR933X_BOOTSTRAP_REF_CLK_40	BIT(0)
drivers/net/Kconfig +7 -0
index c3980e78f..9d69b6aeb 100644
@@ -204,6 +204,13 @@ config DRIVER_NET_EFI_SNP
 	bool "EFI SNP ethernet driver"
 	depends on EFI_BOOTUP
 
+config DRIVER_NET_AG71XX
+	bool "Atheros AG71xx ethernet driver"
+	depends on MACH_MIPS_ATH79
+	select PHYLIB
+	help
+	  This option enables support for Atheros AG71XX ethernet chip.
+
 config DRIVER_NET_TSE
 	depends on NIOS2
 	bool "Altera TSE ethernet driver"
drivers/net/Makefile +1 -0
index 42ea208e3..86c8ac32f 100644
@@ -30,3 +30,4 @@ obj-$(CONFIG_DRIVER_NET_SMC91111)	+= smc91111.o
 obj-$(CONFIG_DRIVER_NET_TAP)		+= tap.o
 obj-$(CONFIG_DRIVER_NET_TSE)		+= altera_tse.o
 obj-$(CONFIG_DRIVER_NET_EFI_SNP)	+= efi-snp.o
+obj-$(CONFIG_DRIVER_NET_AG71XX)		+= ag71xx.o
drivers/net/ag71xx.c new file +673 -0

673 lines not on this page · raw message

Signature · 7 lines
2.11.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

Re: [PATCH v2 01/10] net: ath79: add ag71xx Ethernet driver

drivers/net/ag71xx.c line 384

Quoted 11 lines · Oleksij Rempel
drivers/net/ag71xx.c new file +11 -0
+static void ag71xx_ether_halt(struct eth_device *edev)
+{
+	struct ag71xx *priv = edev->priv;
+	struct device_d *dev = priv->dev;
+	uint64_t start;
+
+	ag71xx_wr(priv, AG71XX_REG_RX_CTRL, 0);
+	start = get_time_ns();
+	while (ag71xx_rr(priv, AG71XX_REG_RX_CTRL)) {
+		if (!is_timeout_non_interruptible(start, 100 * USECOND)) {
+			dev_err(dev, "error: filed to stop device!\n");

s/filed/failed/

Also the test seems to be the wrong way round.

Quoted 21 lines
drivers/net/ag71xx.c new file +21 -0
+static int ag71xx_ether_init(struct eth_device *edev)
+{
+	struct ag71xx *priv = edev->priv;
+	int i;
+	void *rxbuf = priv->rx_buffer;
+
+	priv->next_rx = 0;
+
+	for (i = 0; i < NO_OF_RX_FIFOS; i++) {
+		ag7240_desc_t *fr = &priv->fifo_rx[i];
+
+		priv->rx_pkt[i] = rxbuf;
+		fr->pkt_start_addr = virt_to_phys(rxbuf);
+		fr->pkt_size = MAX_RBUFF_SZ;
+		fr->is_empty = 1;
+		fr->next_desc = virt_to_phys(&priv->fifo_rx[(i + 1) % NO_OF_RX_FIFOS]);
+
+		/* invalidate */
+		dma_sync_single_for_device((unsigned long)rxbuf, MAX_RBUFF_SZ,
+					DMA_FROM_DEVICE);
+

drivers/net/ag71xx.c line 509

Quoted 10 lines
drivers/net/ag71xx.c new file +10 -0
+		rxbuf += MAX_RBUFF_SZ;
+	}
+
+	/* Clean Tx BD's */
+	memset(priv->fifo_tx, 0, TX_RING_SZ);
+
+	ag71xx_wr(priv, AG71XX_REG_RX_DESC, virt_to_phys(priv->fifo_rx));
+	ag71xx_wr(priv, AG71XX_REG_RX_CTRL, RX_CTRL_RXE);
+
+	return 1;

Although the return code is not tested by the caller, this function should return 0 for success.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox