patch: au1000 eth link detection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hello!

this is actually bjoern riemer's patch, in a better diff format, which i hope 
you will accept. it adds the "link beat detection" ioctls to the au1000 
ethernet driver to make it work with ifplugd.

bruno

--- linux/drivers/net/au1000_eth.c.orig 2004-11-23 12:01:00.551663672 +0100
+++ linux/drivers/net/au1000_eth.c 2004-11-23 12:08:36.795304096 +0100
@@ -6,7 +6,9 @@
  * Copyright 2002 TimeSys Corp.
  * Author: MontaVista Software, Inc.
  *          ppopov@xxxxxxxxxx or source@xxxxxxxxxx
- *
+ *         Bjoern Riemer 2004
+ *           riemer@xxxxxxxxxxxxxxxxxxx or riemer@xxxxxxxxxxxx
+ *             // fixed the link beat detection with ioctls (SIOCGMIIPHY)
  * ########################################################################
  *
  *  This program is free software; you can distribute it and/or modify it
@@ -1383,6 +1385,10 @@
  aup->phy_ops->phy_status(dev, aup->phy_addr, &link, &speed);
  control = MAC_DISABLE_RX_OWN | MAC_RX_ENABLE | MAC_TX_ENABLE;
 #ifndef CONFIG_CPU_LITTLE_ENDIAN
+ /*riemer: fix for startup without cable */
+ if (!link) 
+  dev->flags &= ~IFF_RUNNING;
+
  control |= MAC_BIG_ENDIAN;
 #endif
  if (link && (dev->if_port == IF_PORT_100BASEFX)) {
@@ -1841,17 +1847,35 @@
 
 static int au1000_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
- //u16 *data = (u16 *)&rq->ifr_data;
+/*
+// This structure is used in all SIOCxMIIxxx ioctl calls 
+struct mii_ioctl_data {
+ 0      u16             phy_id;
+ 1      u16             reg_num;
+ 2      u16             val_in;
+ 3      u16             val_out;
+};*/
+ u16 *data = (u16 *)&rq->ifr_data;
+ struct au1000_private *aup = (struct au1000_private *) dev->priv;
+ //struct mii_ioctl_data *data = (struct mii_ioctl_data *) & rq->ifr_data;
 
  /* fixme */
  switch(cmd) { 
   case SIOCDEVPRIVATE: /* Get the address of the PHY in use. */
-  //data[0] = PHY_ADDRESS;
+  case SIOCGMIIPHY:
+          if (!netif_running(dev))
+                  return -EINVAL;
+   data[0] = aup->phy_addr;
   case SIOCDEVPRIVATE+1: /* Read the specified MII register. */
-  //data[3] = mdio_read(ioaddr, data[0], data[1]); 
+  case SIOCGMIIREG:
+   data[3] =  mdio_read(dev, data[0], data[1]); 
+   //data->val_out = mdio_read(dev,data->phy_id,data->reg_num);
   return 0;
   case SIOCDEVPRIVATE+2: /* Write the specified MII register */
-  //mdio_write(ioaddr, data[0], data[1], data[2]);
+  case SIOCSMIIREG: 
+   if (!capable(CAP_NET_ADMIN))
+    return -EPERM;
+   mdio_write(dev, data[0], data[1],data[2]);
   return 0;
   default:
   return -EOPNOTSUPP;

Attachment: pgpp3ksmQtxqn.pgp
Description: PGP signature


[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux