summaryrefslogtreecommitdiff
path: root/drivers/eepro100.c
diff options
context:
space:
mode:
authorWolfgang Denk <wd@pollux.(none)>2005-09-26 00:39:59 +0200
committerWolfgang Denk <wd@pollux.(none)>2005-09-26 00:39:59 +0200
commita912733e9b86f787f8efe6c805662476be9c1e24 (patch)
tree7af69f7eefc34fed0d97cb1bc93d3498a8754e82 /drivers/eepro100.c
parentf2af3eb55ec53f4c050fcf10653a8df450ca7298 (diff)
downloadu-boot-imx-a912733e9b86f787f8efe6c805662476be9c1e24.zip
u-boot-imx-a912733e9b86f787f8efe6c805662476be9c1e24.tar.gz
u-boot-imx-a912733e9b86f787f8efe6c805662476be9c1e24.tar.bz2
Add support for MII in eepro100 driver.
Patch by Gleb Natapov, 21 Mar 2005
Diffstat (limited to 'drivers/eepro100.c')
-rw-r--r--drivers/eepro100.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/drivers/eepro100.c b/drivers/eepro100.c
index 906159e..9db7bd8 100644
--- a/drivers/eepro100.c
+++ b/drivers/eepro100.c
@@ -271,6 +271,47 @@ static inline void OUTL (struct eth_device *dev, int command, u_long addr)
*(volatile u32 *) ((addr + dev->iobase)) = cpu_to_le32 (command);
}
+#if defined (CONFIG_MII) || (CONFIG_COMMANDS & CFG_CMD_MII)
+static inline int INL (struct eth_device *dev, u_long addr)
+{
+ return le32_to_cpu (*(volatile u32 *) (addr + dev->iobase));
+}
+
+int miiphy_read (unsigned char addr,
+ unsigned char reg,
+ unsigned short *value)
+{
+ int cmd = (2 << 26) | ((addr & 0x1f) << 21) | ((reg & 0x1f) << 16);
+
+ struct eth_device *dev = eth_get_dev ();
+
+ OUTL (dev, cmd, SCBCtrlMDI);
+
+ do {
+ cmd = INL (dev, SCBCtrlMDI);
+ } while (!(cmd & (1 << 28)));
+
+ *value = (unsigned short) (cmd & 0xffff);
+
+ return 0;
+}
+
+int miiphy_write (unsigned char addr,
+ unsigned char reg,
+ unsigned short value)
+{
+ int cmd = (1 << 26) | ((addr & 0x1f) << 21) | ((reg & 0x1f) << 16);
+
+ struct eth_device *dev = eth_get_dev ();
+
+ OUTL (dev, cmd | value, SCBCtrlMDI);
+
+ while (!(INL (dev, SCBCtrlMDI) & (1 << 28)));
+
+ return 0;
+}
+#endif /* (CONFIG_MII) || (CONFIG_COMMANDS & CFG_CMD_MII) */
+
/* Wait for the chip get the command.
*/
static int wait_for_eepro100 (struct eth_device *dev)