---- linux-2.6.28.9/drivers/net/r6040.c 2009-03-23 22:55:52.000000000 +0100
-+++ linux-2.6.28.9.new/drivers/net/r6040.c 2009-04-24 14:24:51.000000000 +0200
+--- a/drivers/net/r6040.c
++++ b/drivers/net/r6040.c
@@ -49,12 +49,12 @@
#include <asm/processor.h>
#define PHY_MODE 0x3100 /* PHY CHIP Register 0 */
#define PHY_CAP 0x01E1 /* PHY CHIP Register 4 */
-@@ -160,6 +160,7 @@
+@@ -160,6 +160,7 @@ MODULE_AUTHOR("Sten Wang <sten.wang@rdc.
"Florian Fainelli <florian@openwrt.org>");
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("RDC R6040 NAPI PCI FastEthernet driver");
/* RX and TX interrupts that we handle */
#define RX_INTS (RX_FIFO_FULL | RX_NO_DESC | RX_FINISH)
-@@ -200,7 +201,7 @@
+@@ -200,7 +201,7 @@ struct r6040_private {
static char version[] __devinitdata = KERN_INFO DRV_NAME
": RDC R6040 NAPI net driver,"
static int phy_table[] = { PHY1_ADDR, PHY2_ADDR };
-@@ -330,7 +331,7 @@
+@@ -330,7 +331,7 @@ static int r6040_alloc_rxbufs(struct net
do {
skb = netdev_alloc_skb(dev, MAX_BUF_SIZE);
if (!skb) {
rc = -ENOMEM;
goto err_exit;
}
-@@ -438,7 +439,6 @@
+@@ -438,7 +439,6 @@ static void r6040_down(struct net_device
{
struct r6040_private *lp = netdev_priv(dev);
void __iomem *ioaddr = lp->base;
int limit = 2048;
u16 *adrp;
u16 cmd;
-@@ -457,22 +457,12 @@
+@@ -457,22 +457,12 @@ static void r6040_down(struct net_device
iowrite16(adrp[0], ioaddr + MID_0L);
iowrite16(adrp[1], ioaddr + MID_0M);
iowrite16(adrp[2], ioaddr + MID_0H);
/* deleted timer */
del_timer_sync(&lp->timer);
-@@ -481,8 +471,28 @@
+@@ -481,8 +471,28 @@ static int r6040_close(struct net_device
napi_disable(&lp->napi);
netif_stop_queue(dev);
r6040_down(dev);
return 0;
}
-@@ -598,7 +608,6 @@
+@@ -598,7 +608,6 @@ static int r6040_rx(struct net_device *d
/* Send to upper layer */
netif_receive_skb(skb_ptr);
dev->stats.rx_packets++;
dev->stats.rx_bytes += descptr->len - 4;
-@@ -668,7 +677,7 @@
+@@ -668,7 +677,7 @@ static int r6040_poll(struct napi_struct
work_done = r6040_rx(dev, budget);
if (work_done < budget) {
/* Enable RX interrupt */
iowrite16(ioread16(ioaddr + MIER) | RX_INTS, ioaddr + MIER);
}
-@@ -705,7 +714,7 @@
+@@ -705,7 +714,7 @@ static irqreturn_t r6040_interrupt(int i
/* Mask off RX interrupt */
misr &= ~RX_INTS;
}
/* TX interrupt request */
-@@ -1063,20 +1088,20 @@
+@@ -1063,20 +1072,20 @@ static int __devinit r6040_init_one(stru
/* this should always be supported */
err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
if (err) {
err = -EIO;
goto err_out;
}
-@@ -1086,7 +1111,7 @@
+@@ -1086,7 +1095,7 @@ static int __devinit r6040_init_one(stru
dev = alloc_etherdev(sizeof(struct r6040_private));
if (!dev) {
err = -ENOMEM;
goto err_out;
}
-@@ -1102,11 +1127,15 @@
+@@ -1102,11 +1111,15 @@ static int __devinit r6040_init_one(stru
ioaddr = pci_iomap(pdev, bar, io_size);
if (!ioaddr) {
/* Init system & device */
lp->base = ioaddr;
-@@ -1123,6 +1152,13 @@
+@@ -1123,6 +1136,13 @@ static int __devinit r6040_init_one(stru
adrp[1] = ioread16(ioaddr + MID_0M);
adrp[2] = ioread16(ioaddr + MID_0H);
/* Link new device into r6040_root_dev */
lp->pdev = pdev;
lp->dev = dev;
+--- a/drivers/net/r6040.c
++++ b/drivers/net/r6040.c
+@@ -742,6 +742,14 @@ static int r6040_up(struct net_device *d
+ struct r6040_private *lp = netdev_priv(dev);
+ void __iomem *ioaddr = lp->base;
+ int ret;
++ u16 val;
++
++ /* Check presence of a second PHY */
++ val = r6040_phy_read(ioaddr, lp->phy_addr, 2);
++ if (val == 0xFFFF) {
++ printk(KERN_ERR DRV_NAME " no second PHY attached\n");
++ return -EIO;
++ }
+
+ /* Initialise and alloc RX/TX buffers */
+ r6040_init_txbufs(dev);
+--- a/drivers/net/r6040.c
++++ b/drivers/net/r6040.c
+@@ -401,6 +401,9 @@ static void r6040_init_mac_regs(struct n
+ * we may got called by r6040_tx_timeout which has left
+ * some unsent tx buffers */
+ iowrite16(0x01, ioaddr + MTPR);
++
++ /* Check media */
++ mii_check_media(&lp->mii_if, 1, 1);
+ }
+
+ static void r6040_tx_timeout(struct net_device *dev)
+@@ -528,6 +531,8 @@ static int r6040_phy_mode_chk(struct net
+ phy_dat = 0x0000;
+ }
+
++ mii_check_media(&lp->mii_if, 0, 1);
++
+ return phy_dat;
+ };
+
+@@ -810,7 +815,6 @@ static void r6040_timer(unsigned long da
+ lp->phy_mode = phy_mode;
+ lp->mcr0 = (lp->mcr0 & 0x7fff) | phy_mode;
+ iowrite16(lp->mcr0, ioaddr);
+- printk(KERN_INFO "Link Change %x \n", ioread16(ioaddr));
+ }
+
+ /* Timer active again */