Modify

Opened 7 years ago

Closed 7 years ago

Last modified 4 years ago

#9071 closed defect (fixed)

[PATCH] Ralink RT305x Ethernet Switch Driver (ramips_esw) Problems

Reported by: Layne Edwards <ledwards76@…> Owned by: developers
Priority: high Milestone: Barrier Breaker 14.07
Component: packages Version: Trunk
Keywords: ramips esw rt305x hw550-3g Cc:

Description

The following patch fixes the ethernet switch on some Ralink rt305x boards (such as the Aztech HW550-3G). Apparently the GPIO mode must be set to MDIO (in GPIO Purpose Register) during MII writes. I believe this is how the original Ralink SDK driver behaved, but was removed by changeset r24332. Without this patch, the Aztech HW550-3G has no switch connectivity (no ethernet).

Signed-off-by: Layne Edwards <ledwards76@…>

Index: target/linux/ramips/files/drivers/net/ramips_esw.c
===================================================================
--- target/linux/ramips/files/drivers/net/ramips_esw.c	(revision 26187)
+++ target/linux/ramips/files/drivers/net/ramips_esw.c	(working copy)
@@ -1,5 +1,17 @@
+/*
+ *   Ralink RT305x Ethernet Switch Driver (ramips_esw)
+ *
+ *   This program is free software; you can redistribute it and/or modify it
+ *   under the terms of the GNU General Public License version 2 as published
+ *   by the Free Software Foundation.
+ *
+ *   Copyright (C) 2009 John Crispin <blogic@openwrt.org>
+ *   Copyright (C) 2011 Layne Edwards <ledwards76@gmail.com>
+ */
+
 #include <linux/ioport.h>
 
+#include <rt305x.h>
 #include <rt305x_regs.h>
 #include <rt305x_esw_platform.h>
 
@@ -111,6 +123,17 @@
 	spin_unlock_irqrestore(&esw->reg_rw_lock, flags);
 }
 
+static void
+ramips_enable_mdio(int s)
+{
+	u32 gpio = rt305x_sysc_rr(SYSC_REG_GPIO_MODE);
+	if(s)
+		gpio &= ~RT305X_GPIO_MODE_MDIO;
+	else
+		gpio |= RT305X_GPIO_MODE_MDIO;
+	rt305x_sysc_wr(gpio, SYSC_REG_GPIO_MODE);
+}
+
 static u32
 rt305x_mii_write(struct rt305x_esw *esw, u32 phy_addr, u32 phy_register,
 		 u32 write_data)
@@ -118,6 +141,7 @@
 	unsigned long t_start = jiffies;
 	int ret = 0;
 
+	ramips_enable_mdio(1);
 	while (1) {
 		if (!(rt305x_esw_rr(esw, RT305X_ESW_REG_PCR1) &
 		      RT305X_ESW_PCR1_WT_DONE))
@@ -147,8 +171,9 @@
 		}
 	}
 out:
+	ramips_enable_mdio(0);
 	if (ret)
-		printk(KERN_ERR "ramips_eth: MDIO timeout\n");
+		printk(KERN_ERR "ramips_esw: MDIO timeout\n");
 	return ret;
 }
 

Same patch attached.

Thanks,
Layne Edwards

Attachments (1)

ramips_esw.patch (1.5 KB) - added by Layne Edwards <ledwards76@…> 7 years ago.
Ralink Ethernet Switch Driver (ramips_esw) Patch

Download all attachments as: .zip

Change History (4)

Changed 7 years ago by Layne Edwards <ledwards76@…>

Ralink Ethernet Switch Driver (ramips_esw) Patch

comment:1 Changed 7 years ago by Layne Edwards <ledwards@…>

This was fixed by r26321. Thanks.

comment:2 Changed 7 years ago by juhosg

  • Resolution set to fixed
  • Status changed from new to closed

comment:3 Changed 4 years ago by jow

  • Milestone changed from Attitude Adjustment 12.09 to Barrier Breaker 14.07

Milestone Attitude Adjustment 12.09 deleted

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.