git://ftp.safe.ca
/
safe
/
jmp
/
linux-2.6
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ath5k: remove get_tx_stats() mac80211 op
[safe/jmp/linux-2.6]
/
drivers
/
net
/
r6040.c
diff --git
a/drivers/net/r6040.c
b/drivers/net/r6040.c
index
cc0f886
..
f03e2e4
100644
(file)
--- a/
drivers/net/r6040.c
+++ b/
drivers/net/r6040.c
@@
-49,12
+49,12
@@
#include <asm/processor.h>
#define DRV_NAME "r6040"
#include <asm/processor.h>
#define DRV_NAME "r6040"
-#define DRV_VERSION "0.2
1
"
-#define DRV_RELDATE "
09Jan
2009"
+#define DRV_VERSION "0.2
5
"
+#define DRV_RELDATE "
20Aug
2009"
/* PHY CHIP Address */
#define PHY1_ADDR 1 /* For MAC1 */
/* PHY CHIP Address */
#define PHY1_ADDR 1 /* For MAC1 */
-#define PHY2_ADDR
2
/* For MAC2 */
+#define PHY2_ADDR
3
/* For MAC2 */
#define PHY_MODE 0x3100 /* PHY CHIP Register 0 */
#define PHY_CAP 0x01E1 /* PHY CHIP Register 4 */
#define PHY_MODE 0x3100 /* PHY CHIP Register 0 */
#define PHY_CAP 0x01E1 /* PHY CHIP Register 4 */
@@
-160,6
+160,7
@@
MODULE_AUTHOR("Sten Wang <sten.wang@rdc.com.tw>,"
"Florian Fainelli <florian@openwrt.org>");
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("RDC R6040 NAPI PCI FastEthernet driver");
"Florian Fainelli <florian@openwrt.org>");
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("RDC R6040 NAPI PCI FastEthernet driver");
+MODULE_VERSION(DRV_VERSION " " DRV_RELDATE);
/* RX and TX interrupts that we handle */
#define RX_INTS (RX_FIFO_FULL | RX_NO_DESC | RX_FINISH)
/* RX and TX interrupts that we handle */
#define RX_INTS (RX_FIFO_FULL | RX_NO_DESC | RX_FINISH)
@@
-400,6
+401,9
@@
static void r6040_init_mac_regs(struct net_device *dev)
* we may got called by r6040_tx_timeout which has left
* some unsent tx buffers */
iowrite16(0x01, ioaddr + MTPR);
* 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)
}
static void r6040_tx_timeout(struct net_device *dev)
@@
-438,7
+442,6
@@
static void r6040_down(struct net_device *dev)
{
struct r6040_private *lp = netdev_priv(dev);
void __iomem *ioaddr = lp->base;
{
struct r6040_private *lp = netdev_priv(dev);
void __iomem *ioaddr = lp->base;
- struct pci_dev *pdev = lp->pdev;
int limit = 2048;
u16 *adrp;
u16 cmd;
int limit = 2048;
u16 *adrp;
u16 cmd;
@@
-485,12
+488,12
@@
static int r6040_close(struct net_device *dev)
/* Free Descriptor memory */
if (lp->rx_ring) {
pci_free_consistent(pdev, RX_DESC_SIZE, lp->rx_ring, lp->rx_ring_dma);
/* Free Descriptor memory */
if (lp->rx_ring) {
pci_free_consistent(pdev, RX_DESC_SIZE, lp->rx_ring, lp->rx_ring_dma);
- lp->rx_ring =
0
;
+ lp->rx_ring =
NULL
;
}
if (lp->tx_ring) {
pci_free_consistent(pdev, TX_DESC_SIZE, lp->tx_ring, lp->tx_ring_dma);
}
if (lp->tx_ring) {
pci_free_consistent(pdev, TX_DESC_SIZE, lp->tx_ring, lp->tx_ring_dma);
- lp->tx_ring =
0
;
+ lp->tx_ring =
NULL
;
}
return 0;
}
return 0;
@@
-528,6
+531,8
@@
static int r6040_phy_mode_chk(struct net_device *dev)
phy_dat = 0x0000;
}
phy_dat = 0x0000;
}
+ mii_check_media(&lp->mii_if, 0, 1);
+
return phy_dat;
};
return phy_dat;
};
@@
-699,8
+704,11
@@
static irqreturn_t r6040_interrupt(int irq, void *dev_id)
/* Read MISR status and clear */
status = ioread16(ioaddr + MISR);
/* Read MISR status and clear */
status = ioread16(ioaddr + MISR);
- if (status == 0x0000 || status == 0xffff)
+ if (status == 0x0000 || status == 0xffff) {
+ /* Restore RDC MAC interrupt */
+ iowrite16(misr, ioaddr + MIER);
return IRQ_NONE;
return IRQ_NONE;
+ }
/* RX interrupt request */
if (status & RX_INTS) {
/* RX interrupt request */
if (status & RX_INTS) {
@@
-802,7
+810,6
@@
static void r6040_timer(unsigned long data)
lp->phy_mode = phy_mode;
lp->mcr0 = (lp->mcr0 & 0x7fff) | phy_mode;
iowrite16(lp->mcr0, ioaddr);
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 */
}
/* Timer active again */
@@
-835,7
+842,7
@@
static int r6040_open(struct net_device *dev)
int ret;
/* Request IRQ and Register interrupt handler */
int ret;
/* Request IRQ and Register interrupt handler */
- ret = request_irq(dev->irq,
&
r6040_interrupt,
+ ret = request_irq(dev->irq, r6040_interrupt,
IRQF_SHARED, dev->name, dev);
if (ret)
return ret;
IRQF_SHARED, dev->name, dev);
if (ret)
return ret;
@@
-876,13
+883,13
@@
static int r6040_open(struct net_device *dev)
return 0;
}
return 0;
}
-static int r6040_start_xmit(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t r6040_start_xmit(struct sk_buff *skb,
+ struct net_device *dev)
{
struct r6040_private *lp = netdev_priv(dev);
struct r6040_descriptor *descptr;
void __iomem *ioaddr = lp->base;
unsigned long flags;
{
struct r6040_private *lp = netdev_priv(dev);
struct r6040_descriptor *descptr;
void __iomem *ioaddr = lp->base;
unsigned long flags;
- int ret = NETDEV_TX_OK;
/* Critical Section */
spin_lock_irqsave(&lp->lock, flags);
/* Critical Section */
spin_lock_irqsave(&lp->lock, flags);
@@
-892,8
+899,7
@@
static int r6040_start_xmit(struct sk_buff *skb, struct net_device *dev)
spin_unlock_irqrestore(&lp->lock, flags);
netif_stop_queue(dev);
printk(KERN_ERR DRV_NAME ": no tx descriptor\n");
spin_unlock_irqrestore(&lp->lock, flags);
netif_stop_queue(dev);
printk(KERN_ERR DRV_NAME ": no tx descriptor\n");
- ret = NETDEV_TX_BUSY;
- return ret;
+ return NETDEV_TX_BUSY;
}
/* Statistic Counter */
}
/* Statistic Counter */
@@
-921,7
+927,8
@@
static int r6040_start_xmit(struct sk_buff *skb, struct net_device *dev)
dev->trans_start = jiffies;
spin_unlock_irqrestore(&lp->lock, flags);
dev->trans_start = jiffies;
spin_unlock_irqrestore(&lp->lock, flags);
- return ret;
+
+ return NETDEV_TX_OK;
}
static void r6040_multicast_list(struct net_device *dev)
}
static void r6040_multicast_list(struct net_device *dev)
@@
-951,8
+958,7
@@
static void r6040_multicast_list(struct net_device *dev)
}
/* Too many multicast addresses
* accept all traffic */
}
/* Too many multicast addresses
* accept all traffic */
- else if ((dev->mc_count > MCAST_MAX)
- || (dev->flags & IFF_ALLMULTI))
+ else if ((dev->mc_count > MCAST_MAX) || (dev->flags & IFF_ALLMULTI))
reg |= 0x0020;
iowrite16(reg, ioaddr);
reg |= 0x0020;
iowrite16(reg, ioaddr);
@@
-1076,23
+1082,22
@@
static int __devinit r6040_init_one(struct pci_dev *pdev,
int err, io_size = R6040_IO_SIZE;
static int card_idx = -1;
int bar = 0;
int err, io_size = R6040_IO_SIZE;
static int card_idx = -1;
int bar = 0;
- long pioaddr;
u16 *adrp;
u16 *adrp;
- printk(
KERN_INFO
"%s\n", version);
+ printk("%s\n", version);
err = pci_enable_device(pdev);
if (err)
goto err_out;
/* this should always be supported */
err = pci_enable_device(pdev);
if (err)
goto err_out;
/* this should always be supported */
- err = pci_set_dma_mask(pdev, DMA_
32BIT_MASK
);
+ err = pci_set_dma_mask(pdev, DMA_
BIT_MASK(32)
);
if (err) {
printk(KERN_ERR DRV_NAME ": 32-bit PCI DMA addresses"
"not supported by the card\n");
goto err_out;
}
if (err) {
printk(KERN_ERR DRV_NAME ": 32-bit PCI DMA addresses"
"not supported by the card\n");
goto err_out;
}
- err = pci_set_consistent_dma_mask(pdev, DMA_
32BIT_MASK
);
+ err = pci_set_consistent_dma_mask(pdev, DMA_
BIT_MASK(32)
);
if (err) {
printk(KERN_ERR DRV_NAME ": 32-bit PCI DMA addresses"
"not supported by the card\n");
if (err) {
printk(KERN_ERR DRV_NAME ": 32-bit PCI DMA addresses"
"not supported by the card\n");
@@
-1100,13
+1105,12
@@
static int __devinit r6040_init_one(struct pci_dev *pdev,
}
/* IO Size check */
}
/* IO Size check */
- if (pci_resource_len(pdev,
0
) < io_size) {
+ if (pci_resource_len(pdev,
bar
) < io_size) {
printk(KERN_ERR DRV_NAME ": Insufficient PCI resources, aborting\n");
err = -EIO;
goto err_out;
}
printk(KERN_ERR DRV_NAME ": Insufficient PCI resources, aborting\n");
err = -EIO;
goto err_out;
}
- pioaddr = pci_resource_start(pdev, 0); /* IO map base address */
pci_set_master(pdev);
dev = alloc_etherdev(sizeof(struct r6040_private));
pci_set_master(pdev);
dev = alloc_etherdev(sizeof(struct r6040_private));
@@
-1181,6
+1185,13
@@
static int __devinit r6040_init_one(struct pci_dev *pdev,
lp->mii_if.phy_id_mask = 0x1f;
lp->mii_if.reg_num_mask = 0x1f;
lp->mii_if.phy_id_mask = 0x1f;
lp->mii_if.reg_num_mask = 0x1f;
+ /* Check the vendor ID on the PHY, if 0xffff assume none attached */
+ if (r6040_phy_read(ioaddr, lp->phy_addr, 2) == 0xffff) {
+ printk(KERN_ERR DRV_NAME ": Failed to detect an attached PHY\n");
+ err = -ENODEV;
+ goto err_out_unmap;
+ }
+
/* Register net device. After this dev->name assign */
err = register_netdev(dev);
if (err) {
/* Register net device. After this dev->name assign */
err = register_netdev(dev);
if (err) {