Patchwork [U-Boot,Drivers,13/19] net/macb: Add arch specific routine to get mdio control

login
register
mail settings
Submitter Vipin Kumar
Date Nov. 2, 2012, 5:39 p.m.
Message ID <1323a5c3ffd75d128e0e9ccddd32adb3a395d2a2.1351877124.git.vipin.kumar@st.com>
Download mbox | patch
Permalink /patch/196712/
State Superseded
Delegated to: Albert ARIBAUD
Headers show

Comments

Vipin Kumar - Nov. 2, 2012, 5:39 p.m.
From: Shiraz Hashim <shiraz.hashim@st.com>

SPEAr310 and SPEAr320 Ethernet interfaces share same MDIO lines to control their
respective phys. Currently their is a fixed configuration in which only a
particular MAC can use the MDIO lines.

Call an arch specific function to take control of specific mdio lines at
runtime.

Signed-off-by: Shiraz Hashim <shiraz.hashim@st.com>
Signed-off-by: Vipin Kumar <vipin.kumar@st.com>
---
 drivers/net/macb.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Patch

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 0e1ced7..ac25b52 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -165,6 +165,13 @@  static u16 macb_mdio_read(struct macb_device *macb, u8 reg)
 	return MACB_BFEXT(DATA, frame);
 }
 
+static void __def_arch_get_mdio_control(const char *name)
+{
+	return;
+}
+int arch_get_mdio_control(const char *name)
+	__attribute__((weak, alias("__def_arch_get_mdio_control")));
+
 #if defined(CONFIG_CMD_MII)
 
 int macb_miiphy_read(const char *devname, u8 phy_adr, u8 reg, u16 *value)
@@ -175,6 +182,7 @@  int macb_miiphy_read(const char *devname, u8 phy_adr, u8 reg, u16 *value)
 	if ( macb->phy_addr != phy_adr )
 		return -1;
 
+	arch_get_mdio_control(devname);
 	*value = macb_mdio_read(macb, reg);
 
 	return 0;
@@ -188,6 +196,7 @@  int macb_miiphy_write(const char *devname, u8 phy_adr, u8 reg, u16 value)
 	if ( macb->phy_addr != phy_adr )
 		return -1;
 
+	arch_get_mdio_control(devname);
 	macb_mdio_write(macb, reg, value);
 
 	return 0;
@@ -379,6 +388,7 @@  static int macb_phy_init(struct macb_device *macb)
 	int media, speed, duplex;
 	int i;
 
+	arch_get_mdio_control(netdev->name);
 #ifdef CONFIG_MACB_SEARCH_PHY
 	/* Auto-detect phy_addr */
 	if (!macb_phy_find(macb)) {