summaryrefslogtreecommitdiff
path: root/linux/linux-mtx-1-2.4.27/14-au1000-eth-link-beat.diff
blob: f848d2a224eb409538373957c590b0e0b2910508 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
--- 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@mvista.com or source@mvista.com
- *
+ *         Bjoern Riemer 2004
+ *           riemer@fokus.fraunhofer.de or riemer@riemer-nt.de
+ *             // 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;