1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-12-26 14:07:41 +02:00

Clean up the r6040 driver using checkpatch

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@9184 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
florian 2007-10-08 08:01:30 +00:00
parent f68eab92c4
commit cb792c90e6

View File

@ -13,10 +13,12 @@
Modification List Modification List
---------- ------------------------------------------------ ---------- ------------------------------------------------
10-07-2007 Clean up the driver using checkpatch
08-24-2006 Support at linux 2.6.10 above 08-24-2006 Support at linux 2.6.10 above
03-24-2006 Support NAPI 03-24-2006 Support NAPI
03-21-2006 By Charies,change spin_lock_irqsave(lp->lock, flags) to 03-21-2006 By Charies,change spin_lock_irqsave(lp->lock, flags)
spin_lock_irqsave(&lp->lock, flags) in set_multicast_list to spin_lock_irqsave(&lp->lock, flags)
in set_multicast_list
03-15-2006 Modify the set_multicast_list ,due to when re-plug the ethernet, 03-15-2006 Modify the set_multicast_list ,due to when re-plug the ethernet,
it will forget the previous setting it will forget the previous setting
07-12-2005 Tim, modify the set_multicast_list 07-12-2005 Tim, modify the set_multicast_list
@ -65,11 +67,14 @@
#define ALLOC_DESC_SIZE ((TX_DCNT+RX_DCNT)*sizeof(struct r6040_descriptor)+0x10) #define ALLOC_DESC_SIZE ((TX_DCNT+RX_DCNT)*sizeof(struct r6040_descriptor)+0x10)
#define MBCR_DEFAULT 0x012A /* MAC Bus Control Register */ #define MBCR_DEFAULT 0x012A /* MAC Bus Control Register */
/* PHY settings */
#define ICPLUS_PHY_ID 0x0243
/* Debug enable or not */ /* Debug enable or not */
#define RDC_DEBUG 0 #define RDC_DEBUG 0
#if RDC_DEBUG > 1 #if RDC_DEBUG > 1
#define RDC_DBUG(msg, value) printk("%s %x\n", msg, value); #define RDC_DBUG(msg, value) printk(KERN_ERR "%s %x\n", msg, value);
#else #else
#define RDC_DBUG(msg, value) #define RDC_DBUG(msg, value)
#endif #endif
@ -92,7 +97,7 @@
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/delay.h> /* for udelay() */ #include <linux/delay.h>
#include <linux/mii.h> #include <linux/mii.h>
#include <linux/ethtool.h> #include <linux/ethtool.h>
#include <linux/crc32.h> #include <linux/crc32.h>
@ -104,7 +109,7 @@
#include <asm/irq.h> #include <asm/irq.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
MODULE_AUTHOR("Sten Wang <sten.wang@rdc.com.tw>"); MODULE_AUTHOR("Sten Wang <sten.wang@rdc.com.tw>, Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us>, Florian Fainelli <florian@openwrt.org>");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
#ifdef CONFIG_R6040_NAPI #ifdef CONFIG_R6040_NAPI
MODULE_DESCRIPTION("RDC R6040 NAPI PCI FastEthernet Driver"); MODULE_DESCRIPTION("RDC R6040 NAPI PCI FastEthernet Driver");
@ -123,11 +128,11 @@ struct r6040_descriptor {
struct r6040_descriptor *vndescp; /* 14-17 */ struct r6040_descriptor *vndescp; /* 14-17 */
struct sk_buff *skb_ptr; /* 18-1B */ struct sk_buff *skb_ptr; /* 18-1B */
u32 rev2; /* 1C-1F */ u32 rev2; /* 1C-1F */
} __attribute__(( aligned(32) )); } __attribute__((aligned(32)));
struct r6040_private { struct r6040_private {
struct net_device_stats stats; struct net_device_stats stats;
spinlock_t lock; spinlock_t lock; /* driver lock */
struct timer_list timer; struct timer_list timer;
struct pci_dev *pdev; struct pci_dev *pdev;
@ -165,7 +170,7 @@ static struct r6040_chip_info r6040_chip_info[] __devinitdata =
{ {
{ "RDC R6040 Knight", R6040_PCI_CMD, R6040_IO_SIZE, 0} { "RDC R6040 Knight", R6040_PCI_CMD, R6040_IO_SIZE, 0}
}; };
static char *parent = NULL; static char *parent;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
static int NUM_MAC_TABLE = 2 ; static int NUM_MAC_TABLE = 2 ;
@ -176,7 +181,10 @@ MODULE_PARM(parent, "s");
MODULE_PARM_DESC(parent, "Parent network device name"); MODULE_PARM_DESC(parent, "Parent network device name");
static int phy_table[] = { 0x1, 0x2}; static int phy_table[] = { 0x1, 0x2};
static u8 adr_table[2][8] = {{0x00, 0x00, 0x60, 0x00, 0x00, 0x01}, {0x00, 0x00, 0x60, 0x00, 0x00, 0x02}}; static u8 adr_table[2][8] = {
{0x00, 0x00, 0x60, 0x00, 0x00, 0x01},
{0x00, 0x00, 0x60, 0x00, 0x00, 0x02}
};
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10) #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
module_param_array(adr_table, int, &NUM_MAC_TABLE, 0644); module_param_array(adr_table, int, &NUM_MAC_TABLE, 0644);
@ -203,7 +211,7 @@ static void r6040_timer(unsigned long);
static int phy_mode_chk(struct net_device *dev); static int phy_mode_chk(struct net_device *dev);
static int phy_read(int ioaddr, int phy_adr, int reg_idx); static int phy_read(int ioaddr, int phy_adr, int reg_idx);
static void phy_write(int ioaddr, int phy_adr, int reg_idx, int dat); static void phy_write(int ioaddr, int phy_adr, int reg_idx, int dat);
static void rx_buf_alloc(struct r6040_private *lp,struct net_device *dev); static void rx_buf_alloc(struct r6040_private *lp, struct net_device *dev);
#ifdef CONFIG_R6040_NAPI #ifdef CONFIG_R6040_NAPI
static int r6040_poll(struct net_device *netdev, int *budget); static int r6040_poll(struct net_device *netdev, int *budget);
#endif #endif
@ -221,9 +229,10 @@ static int __devinit r6040_init_one (struct pci_dev *pdev,
RDC_DBUG("r6040_init_one()", 0); RDC_DBUG("r6040_init_one()", 0);
if (printed_version++) if (printed_version++)
printk(version); printk(KERN_INFO version);
if ((err = pci_enable_device (pdev))) err = pci_enable_device(pdev);
if (err)
return err; return err;
/* this should always be supported */ /* this should always be supported */
@ -288,7 +297,8 @@ static int __devinit r6040_init_one (struct pci_dev *pdev,
#endif #endif
/* Register net device. After this dev->name assign */ /* Register net device. After this dev->name assign */
if ((err = register_netdev(dev))) { err = register_netdev(dev);
if (err) {
printk(KERN_ERR DRV_NAME ": Failed to register net device\n"); printk(KERN_ERR DRV_NAME ": Failed to register net device\n");
goto err_out_res; goto err_out_res;
} }
@ -331,14 +341,14 @@ r6040_open(struct net_device *dev)
/* Allocate Descriptor memory */ /* Allocate Descriptor memory */
lp->desc_pool = pci_alloc_consistent(lp->pdev, ALLOC_DESC_SIZE, &lp->desc_dma); lp->desc_pool = pci_alloc_consistent(lp->pdev, ALLOC_DESC_SIZE, &lp->desc_dma);
if (!lp->desc_pool) return -ENOMEM; if (!lp->desc_pool)
return -ENOMEM;
r6040_up(dev); r6040_up(dev);
netif_start_queue(dev); netif_start_queue(dev);
if (lp->switch_sig != 0x0243) if (lp->switch_sig != ICPLUS_PHY_ID) {
{
/* set and active a timer process */ /* set and active a timer process */
init_timer(&lp->timer); init_timer(&lp->timer);
lp->timer.expires = TIMER_WUT; lp->timer.expires = TIMER_WUT;
@ -353,8 +363,8 @@ static void
r6040_tx_timeout (struct net_device *dev) r6040_tx_timeout (struct net_device *dev)
{ {
struct r6040_private *lp = dev->priv; struct r6040_private *lp = dev->priv;
//int ioaddr = dev->base_addr; /* int ioaddr = dev->base_addr;
//struct r6040_descriptor *descptr = lp->tx_remove_ptr; struct r6040_descriptor *descptr = lp->tx_remove_ptr; */
RDC_DBUG("r6040_tx_timeout()", 0); RDC_DBUG("r6040_tx_timeout()", 0);
@ -404,8 +414,11 @@ r6040_start_xmit(struct sk_buff *skb, struct net_device *dev)
/* Set TX descriptor & Transmit it */ /* Set TX descriptor & Transmit it */
lp->tx_free_desc--; lp->tx_free_desc--;
descptr = lp->tx_insert_ptr; descptr = lp->tx_insert_ptr;
if (skb->len < 0x3c) descptr->len = 0x3c; if (skb->len < 0x3c)
else descptr->len = skb->len; descptr->len = 0x3c;
else
descptr->len = skb->len;
descptr->skb_ptr = skb; descptr->skb_ptr = skb;
descptr->buf = cpu_to_le32(pci_map_single(lp->pdev, skb->data, skb->len, PCI_DMA_TODEVICE)); descptr->buf = cpu_to_le32(pci_map_single(lp->pdev, skb->data, skb->len, PCI_DMA_TODEVICE));
descptr->status = 0x8000; descptr->status = 0x8000;
@ -457,10 +470,8 @@ r6040_interrupt(int irq, void *dev_id)
#ifdef CONFIG_R6040_NAPI #ifdef CONFIG_R6040_NAPI
if (netif_rx_schedule_prep(dev)) {
if(netif_rx_schedule_prep(dev)) NAPI_status = status;
{
NAPI_status = status ;
__netif_rx_schedule(dev); __netif_rx_schedule(dev);
} }
@ -471,8 +482,9 @@ r6040_interrupt(int irq, void *dev_id)
if (status & 0x10) { if (status & 0x10) {
handled = 1; handled = 1;
descptr = lp->tx_remove_ptr; descptr = lp->tx_remove_ptr;
while(lp->tx_free_desc < TX_DCNT) { while (lp->tx_free_desc < TX_DCNT) {
if (descptr->status & 0x8000) break; /* Not complte */ if (descptr->status & 0x8000)
break; /* Not complte */
skb_ptr = descptr->skb_ptr; skb_ptr = descptr->skb_ptr;
pci_unmap_single(lp->pdev, descptr->buf, skb_ptr->len, PCI_DMA_TODEVICE); pci_unmap_single(lp->pdev, descptr->buf, skb_ptr->len, PCI_DMA_TODEVICE);
dev_kfree_skb_irq(skb_ptr); /* Free buffer */ dev_kfree_skb_irq(skb_ptr); /* Free buffer */
@ -481,7 +493,8 @@ r6040_interrupt(int irq, void *dev_id)
lp->tx_free_desc++; lp->tx_free_desc++;
} }
lp->tx_remove_ptr = descptr; lp->tx_remove_ptr = descptr;
if (lp->tx_free_desc) netif_wake_queue(dev); if (lp->tx_free_desc)
netif_wake_queue(dev);
} }
/* RX interrupt request */ /* RX interrupt request */
@ -552,12 +565,13 @@ set_multicast_list(struct net_device *dev)
/* Promiscous Mode */ /* Promiscous Mode */
spin_lock_irqsave(&lp->lock, flags); spin_lock_irqsave(&lp->lock, flags);
i = inw(ioaddr) & ~0x0120; /* Clear AMCP & PROM */ i = inw(ioaddr) & ~0x0120; /* Clear AMCP & PROM */
if (dev->flags & IFF_PROMISC) if (dev->flags & IFF_PROMISC) {
{
i |= 0x0020; i |= 0x0020;
lp->mcr0 |= 0x0020 ; lp->mcr0 |= 0x0020;
} }
if (dev->mc_count > 4) i |= 0x0020; /* Too many multicast address */ if (dev->mc_count > 4)
i |= 0x0020; /* Too many multicast address */
outw(i, ioaddr); outw(i, ioaddr);
spin_unlock_irqrestore(&lp->lock, flags); spin_unlock_irqrestore(&lp->lock, flags);
@ -566,7 +580,7 @@ set_multicast_list(struct net_device *dev)
return; return;
/* Multicast Address 1~4 case */ /* Multicast Address 1~4 case */
for (i = 0, mcptr = dev->mc_list; (i<dev->mc_count) && (i<4); i++) { for (i = 0, mcptr = dev->mc_list; (i < dev->mc_count) && (i < 4); i++) {
adrp = (u16 *)mcptr->dmi_addr; adrp = (u16 *)mcptr->dmi_addr;
outw(adrp[0], ioaddr + 0x70 + 8*i); outw(adrp[0], ioaddr + 0x70 + 8*i);
outw(adrp[1], ioaddr + 0x72 + 8*i); outw(adrp[1], ioaddr + 0x72 + 8*i);
@ -622,8 +636,8 @@ static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
struct r6040_private *lp = dev->priv; struct r6040_private *lp = dev->priv;
RDC_DBUG("netdev_ioctl()", 0); RDC_DBUG("netdev_ioctl()", 0);
if (lp->switch_sig == 0x0243 && cmd == SIOCDEVPRIVATE)
{ if (lp->switch_sig == ICPLUS_PHY_ID && cmd == SIOCDEVPRIVATE) {
unsigned long *data = (unsigned long *)rq->ifr_data, args[4]; unsigned long *data = (unsigned long *)rq->ifr_data, args[4];
int ioaddr = dev->base_addr; int ioaddr = dev->base_addr;
unsigned int val; unsigned int val;
@ -633,10 +647,10 @@ static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
return -EFAULT; return -EFAULT;
/* port priority */ /* port priority */
if(args[0]&(1<<31))phy_write(ioaddr,29,19,(phy_read(ioaddr,29,19)|0x2000)); /* port 0 */ if(args[0]&(1<<31))phy_write(ioaddr, 29, 19, (phy_read(ioaddr, 29, 19) | 0x2000)); /* port 0 */
if(args[0]&(1<<29))phy_write(ioaddr,29,19,(phy_read(ioaddr,29,19)|0x0020)); /* port 1 */ if(args[0]&(1<<29))phy_write(ioaddr, 29, 19, (phy_read(ioaddr, 29, 19) | 0x0020)); /* port 1 */
if(args[0]&(1<<27))phy_write(ioaddr,29,20,(phy_read(ioaddr,29,20)|0x2000)); /* port 2 */ if(args[0]&(1<<27))phy_write(ioaddr, 29, 20, (phy_read(ioaddr, 29, 20) | 0x2000)); /* port 2 */
if(args[0]&(1<<25))phy_write(ioaddr,29,20,(phy_read(ioaddr,29,20)|0x0020)); /* port 3 */ if(args[0]&(1<<25))phy_write(ioaddr, 29, 20, (phy_read(ioaddr, 29, 20) | 0x0020)); /* port 3 */
} }
return -EOPNOTSUPP; return -EOPNOTSUPP;
@ -699,17 +713,16 @@ static int r6040_poll(struct net_device *dev, int *budget)
ioaddr = dev->base_addr; ioaddr = dev->base_addr;
lp = (struct r6040_private *)dev->priv; lp = (struct r6040_private *)dev->priv;
unsigned long rx_work = dev->quota ; unsigned long rx_work = dev->quota;
unsigned long rx ; unsigned long rx;
#if 1 #if 1
/* TX interrupt request */ /* TX interrupt request */
if (NAPI_status & 0x10) { if (NAPI_status & 0x10) {
descptr = lp->tx_remove_ptr; descptr = lp->tx_remove_ptr;
while(lp->tx_free_desc < TX_DCNT) { while (lp->tx_free_desc < TX_DCNT) {
if (descptr->status & 0x8000) break; /* Not complte */ if (descptr->status & 0x8000)
break; /* Not complte */
skb_ptr = descptr->skb_ptr; skb_ptr = descptr->skb_ptr;
pci_unmap_single(lp->pdev, descptr->buf, skb_ptr->len, PCI_DMA_TODEVICE); pci_unmap_single(lp->pdev, descptr->buf, skb_ptr->len, PCI_DMA_TODEVICE);
dev_kfree_skb_irq(skb_ptr); /* Free buffer */ dev_kfree_skb_irq(skb_ptr); /* Free buffer */
@ -724,10 +737,10 @@ static int r6040_poll(struct net_device *dev, int *budget)
#if 1 #if 1
/* RX interrupt request */ /* RX interrupt request */
if (NAPI_status & 0x01) { if (NAPI_status & 0x01) {
descptr = lp->rx_remove_ptr; descptr = lp->rx_remove_ptr;
while(lp->rx_free_desc) { while (lp->rx_free_desc) {
if (descptr->status & 0x8000) break; /* No Rx packet */ if (descptr->status & 0x8000)
break; /* No Rx packet */
skb_ptr = descptr->skb_ptr; skb_ptr = descptr->skb_ptr;
descptr->skb_ptr = 0; descptr->skb_ptr = 0;
skb_ptr->dev = dev; skb_ptr->dev = dev;
@ -741,14 +754,14 @@ static int r6040_poll(struct net_device *dev, int *budget)
lp->rx_free_desc--; lp->rx_free_desc--;
} }
lp->rx_remove_ptr = descptr; lp->rx_remove_ptr = descptr;
} }
/* Allocate new RX buffer */ /* Allocate new RX buffer */
if (lp->rx_free_desc < RX_DCNT) rx_buf_alloc(lp,dev); if (lp->rx_free_desc < RX_DCNT)
rx_buf_alloc(lp, dev);
local_irq_disable(); local_irq_disable();
netif_rx_complete(dev); netif_rx_complete(dev);
outw(R6040_INT_MASK,ioaddr + 0x40); outw(R6040_INT_MASK, ioaddr + 0x40);
local_irq_enable(); local_irq_enable();
return 0; return 0;
#endif #endif
@ -804,7 +817,7 @@ static void r6040_up(struct net_device *dev)
(descptr - 1)->vndescp = lp->rx_insert_ptr; (descptr - 1)->vndescp = lp->rx_insert_ptr;
/* Allocate buffer for RX descriptor */ /* Allocate buffer for RX descriptor */
rx_buf_alloc(lp,dev); rx_buf_alloc(lp, dev);
#if RDC_DEBUG #if RDC_DEBUG
descptr = lp->tx_insert_ptr; descptr = lp->tx_insert_ptr;
@ -821,8 +834,8 @@ for (i = 0; i < RX_DCNT; i++) {
/* MAC operation register */ /* MAC operation register */
outw(0x01, ioaddr+0x04); /* Reset MAC */ outw(0x01, ioaddr+0x04); /* Reset MAC */
outw(2 , ioaddr+0xAC); /* Reset internal state machine */ outw(2, ioaddr+0xAC); /* Reset internal state machine */
outw(0 , ioaddr+0xAC); outw(0, ioaddr+0xAC);
udelay(5000); udelay(5000);
/* TX and RX descriptor start Register */ /* TX and RX descriptor start Register */
@ -838,9 +851,8 @@ for (i = 0; i < RX_DCNT; i++) {
/* Buffer Size Register */ /* Buffer Size Register */
outw(MAX_BUF_SIZE, ioaddr+0x18); outw(MAX_BUF_SIZE, ioaddr+0x18);
if ((lp->switch_sig = phy_read(ioaddr, 0, 2)) == 0x0243) // ICPlus IP175C Signature if ((lp->switch_sig = phy_read(ioaddr, 0, 2)) == ICPLUS_PHY_ID) {
{ phy_write(ioaddr, 29,31, 0x175C); /* Enable registers */
phy_write(ioaddr, 29,31, 0x175C); //Enable registers
lp->phy_mode = 0x8000; lp->phy_mode = 0x8000;
} else { } else {
/* PHY Mode Check */ /* PHY Mode Check */
@ -864,10 +876,10 @@ for (i = 0; i < RX_DCNT; i++) {
outw(0x0802, ioaddr + 0x10); outw(0x0802, ioaddr + 0x10);
/* upgrade performance (by RDC guys) */ /* upgrade performance (by RDC guys) */
phy_write(ioaddr,30,17,(phy_read(ioaddr,30,17)|0x4000)); //bit 14=1 phy_write(ioaddr, 30, 17, (phy_read(ioaddr, 30, 17) | 0x4000)); //bit 14=1
phy_write(ioaddr,30,17,~((~phy_read(ioaddr,30,17))|0x2000)); //bit 13=0 phy_write(ioaddr, 30, 17, ~((~phy_read(ioaddr, 30, 17)) | 0x2000)); //bit 13=0
phy_write(ioaddr,0,19,0x0000); phy_write(ioaddr, 0, 19, 0x0000);
phy_write(ioaddr,0,30,0x01F0); phy_write(ioaddr, 0, 30, 0x01F0);
/* Interrupt Mask Register */ /* Interrupt Mask Register */
outw(R6040_INT_MASK, ioaddr + 0x40); outw(R6040_INT_MASK, ioaddr + 0x40);
@ -879,7 +891,7 @@ for (i = 0; i < RX_DCNT; i++) {
*/ */
static void r6040_timer(unsigned long data) static void r6040_timer(unsigned long data)
{ {
struct net_device *dev=(struct net_device *)data; struct net_device *dev = (struct net_device *)data;
struct r6040_private *lp = dev->priv; struct r6040_private *lp = dev->priv;
u16 ioaddr = dev->base_addr, phy_mode; u16 ioaddr = dev->base_addr, phy_mode;
@ -888,13 +900,14 @@ static void r6040_timer(unsigned long data)
/* Polling PHY Chip Status */ /* Polling PHY Chip Status */
if (PHY_MODE == 0x3100) if (PHY_MODE == 0x3100)
phy_mode = phy_mode_chk(dev); phy_mode = phy_mode_chk(dev);
else phy_mode = (PHY_MODE & 0x0100) ? 0x8000:0x0; else
phy_mode = (PHY_MODE & 0x0100) ? 0x8000:0x0;
if (phy_mode != lp->phy_mode) { if (phy_mode != lp->phy_mode) {
lp->phy_mode = phy_mode; lp->phy_mode = phy_mode;
lp->mcr0 = (lp->mcr0 & 0x7fff) | phy_mode; lp->mcr0 = (lp->mcr0 & 0x7fff) | phy_mode;
outw(lp->mcr0, ioaddr); outw(lp->mcr0, ioaddr);
printk("<RDC> Link Change %x \n", inw(ioaddr)); printk(KERN_INFO "Link Change %x \n", inw(ioaddr));
} }
/* Debug */ /* Debug */
@ -906,21 +919,24 @@ static void r6040_timer(unsigned long data)
} }
/* Allocate skb buffer for rx descriptor */ /* Allocate skb buffer for rx descriptor */
static void rx_buf_alloc(struct r6040_private *lp,struct net_device *dev) static void rx_buf_alloc(struct r6040_private *lp, struct net_device *dev)
{ {
struct r6040_descriptor *descptr; struct r6040_descriptor *descptr;
int ioaddr = dev->base_addr ; int ioaddr = dev->base_addr ;
RDC_DBUG("rx_buf_alloc()", 0); RDC_DBUG("rx_buf_alloc()", 0);
descptr = lp->rx_insert_ptr; descptr = lp->rx_insert_ptr;
while(lp->rx_free_desc < RX_DCNT){ while (lp->rx_free_desc < RX_DCNT) {
descptr->skb_ptr = dev_alloc_skb(MAX_BUF_SIZE); descptr->skb_ptr = dev_alloc_skb(MAX_BUF_SIZE);
if (!descptr->skb_ptr) break;
if (!descptr->skb_ptr)
break;
descptr->buf = cpu_to_le32(pci_map_single(lp->pdev, descptr->skb_ptr->tail, MAX_BUF_SIZE, PCI_DMA_FROMDEVICE)); descptr->buf = cpu_to_le32(pci_map_single(lp->pdev, descptr->skb_ptr->tail, MAX_BUF_SIZE, PCI_DMA_FROMDEVICE));
descptr->status = 0x8000; descptr->status = 0x8000;
descptr = descptr->vndescp; descptr = descptr->vndescp;
lp->rx_free_desc++; lp->rx_free_desc++;
outw(lp->mcr0 | 0x0002, ioaddr); //Trigger Rx DMA outw(lp->mcr0 | 0x0002, ioaddr); /* Trigger Rx DMA */
} }
lp->rx_insert_ptr = descptr; lp->rx_insert_ptr = descptr;
} }
@ -935,7 +951,8 @@ static int phy_mode_chk(struct net_device *dev)
/* PHY Link Status Check */ /* PHY Link Status Check */
phy_dat = phy_read(ioaddr, lp->phy_addr, 1); phy_dat = phy_read(ioaddr, lp->phy_addr, 1);
if (!(phy_dat & 0x4)) return 0x8000; /* Link Failed, full duplex */ if (!(phy_dat & 0x4))
return 0x8000; /* Link Failed, full duplex */
/* PHY Chip Auto-Negotiation Status */ /* PHY Chip Auto-Negotiation Status */
phy_dat = phy_read(ioaddr, lp->phy_addr, 1); phy_dat = phy_read(ioaddr, lp->phy_addr, 1);
@ -943,8 +960,10 @@ static int phy_mode_chk(struct net_device *dev)
/* Auto Negotiation Mode */ /* Auto Negotiation Mode */
phy_dat = phy_read(ioaddr, lp->phy_addr, 5); phy_dat = phy_read(ioaddr, lp->phy_addr, 5);
phy_dat &= phy_read(ioaddr, lp->phy_addr, 4); phy_dat &= phy_read(ioaddr, lp->phy_addr, 4);
if (phy_dat & 0x140) phy_dat = 0x8000; if (phy_dat & 0x140)
else phy_dat = 0; phy_dat = 0x8000;
else
phy_dat = 0;
} else { } else {
/* Force Mode */ /* Force Mode */
phy_dat = phy_read(ioaddr, lp->phy_addr, 0); phy_dat = phy_read(ioaddr, lp->phy_addr, 0);
@ -962,7 +981,7 @@ static int phy_read(int ioaddr, int phy_addr, int reg_idx)
RDC_DBUG("phy_read()", 0); RDC_DBUG("phy_read()", 0);
outw(0x2000 + reg_idx + (phy_addr << 8), ioaddr + 0x20); outw(0x2000 + reg_idx + (phy_addr << 8), ioaddr + 0x20);
do{}while( (i++ < 2048) && (inw(ioaddr + 0x20) & 0x2000) ); do {} while ((i++ < 2048) && (inw(ioaddr + 0x20) & 0x2000));
return inw(ioaddr + 0x24); return inw(ioaddr + 0x24);
} }
@ -984,8 +1003,9 @@ enum {
static struct pci_device_id r6040_pci_tbl[] = { static struct pci_device_id r6040_pci_tbl[] = {
{0x17F3, 0x6040, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RDC_6040}, {0x17F3, 0x6040, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RDC_6040},
//{0x1106, 0x3065, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RDC_6040}, /* {PCI_VENDOR_ID_RDC, PCI_DEVICE_ID_R6040, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RDC_6040},*/
{0,} /* terminate list */ /*{0x1106, 0x3065, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RDC_6040},*/
{0,}
}; };
MODULE_DEVICE_TABLE(pci, r6040_pci_tbl); MODULE_DEVICE_TABLE(pci, r6040_pci_tbl);
@ -1001,15 +1021,13 @@ static int __init r6040_init (void)
{ {
RDC_DBUG("r6040_init()", 0); RDC_DBUG("r6040_init()", 0);
printk(version); printk(KERN_INFO version);
printed_version = 1; printed_version = 1;
if (parent != NULL) if (parent != NULL) {
{
struct net_device *the_parent = dev_get_by_name(parent); struct net_device *the_parent = dev_get_by_name(parent);
if (the_parent == NULL) if (the_parent == NULL) {
{
printk (KERN_ERR DRV_NAME ": Unknown device \"%s\" specified.\n", parent); printk (KERN_ERR DRV_NAME ": Unknown device \"%s\" specified.\n", parent);
return -EINVAL; return -EINVAL;
} }
@ -1029,13 +1047,3 @@ static void __exit r6040_cleanup (void)
module_init(r6040_init); module_init(r6040_init);
module_exit(r6040_cleanup); module_exit(r6040_cleanup);
/*
* Local variables:
* compile-command: "gcc -DMODULE -D__KERNEL__ -I/usr/src/linux/net/inet -Wall -Wstrict-prototypes -O6 -c r6040.c `[ -f /usr/include/linux/modversions.h ] && echo -DMODVERSIONS`"
* c-indent-level: 4
* c-basic-offset: 4
* tab-width: 4
* End:
*/