Commit cbda6df4 authored by Ralf Bächle's avatar Ralf Bächle

[PATCH] GT96100 update

Move GT-64240 NIC definitions which previously did live elsewhere into
a new header file.  Mostly cosmetic cleanup and microfixes for gt64240.c.
parent 8e231e72
This diff is collapsed.
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
* gt96100_cleanup_module(), and other general code cleanups * gt96100_cleanup_module(), and other general code cleanups
* <stevel@mvista.com>. * <stevel@mvista.com>.
*/ */
#include <linux/config.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/string.h> #include <linux/string.h>
...@@ -66,10 +65,6 @@ static int gt96100_add_hash_entry(struct net_device *dev, ...@@ -66,10 +65,6 @@ static int gt96100_add_hash_entry(struct net_device *dev,
static void read_mib_counters(struct gt96100_private *gp); static void read_mib_counters(struct gt96100_private *gp);
static int read_MII(int phy_addr, u32 reg); static int read_MII(int phy_addr, u32 reg);
static int write_MII(int phy_addr, u32 reg, u16 data); static int write_MII(int phy_addr, u32 reg, u16 data);
#if 0
static void dump_tx_ring(struct net_device *dev);
static void dump_rx_ring(struct net_device *dev);
#endif
static int gt96100_init_module(void); static int gt96100_init_module(void);
static void gt96100_cleanup_module(void); static void gt96100_cleanup_module(void);
static void dump_MII(int dbg_lvl, struct net_device *dev); static void dump_MII(int dbg_lvl, struct net_device *dev);
...@@ -84,7 +79,7 @@ static void abort(struct net_device *dev, u32 abort_bits); ...@@ -84,7 +79,7 @@ static void abort(struct net_device *dev, u32 abort_bits);
static void hard_stop(struct net_device *dev); static void hard_stop(struct net_device *dev);
static void enable_ether_irq(struct net_device *dev); static void enable_ether_irq(struct net_device *dev);
static void disable_ether_irq(struct net_device *dev); static void disable_ether_irq(struct net_device *dev);
static int gt96100_probe1(int port_num); static int gt96100_probe1(struct pci_dev *pci, int port_num);
static void reset_tx(struct net_device *dev); static void reset_tx(struct net_device *dev);
static void reset_rx(struct net_device *dev); static void reset_rx(struct net_device *dev);
static int gt96100_check_tx_consistent(struct gt96100_private *gp); static int gt96100_check_tx_consistent(struct gt96100_private *gp);
...@@ -164,13 +159,11 @@ chip_name(int chip_rev) ...@@ -164,13 +159,11 @@ chip_name(int chip_rev)
/* /*
DMA memory allocation, derived from pci_alloc_consistent. DMA memory allocation, derived from pci_alloc_consistent.
*/ */
static void * static void * dmaalloc(size_t size, dma_addr_t *dma_handle)
dmaalloc(size_t size, dma_addr_t *dma_handle)
{ {
void *ret; void *ret;
ret = (void *)__get_free_pages(GFP_ATOMIC | GFP_DMA, ret = (void *)__get_free_pages(GFP_ATOMIC | GFP_DMA, get_order(size));
get_order(size));
if (ret != NULL) { if (ret != NULL) {
dma_cache_inv((unsigned long)ret, size); dma_cache_inv((unsigned long)ret, size);
...@@ -184,17 +177,13 @@ dmaalloc(size_t size, dma_addr_t *dma_handle) ...@@ -184,17 +177,13 @@ dmaalloc(size_t size, dma_addr_t *dma_handle)
return ret; return ret;
} }
static void static void dmafree(size_t size, void *vaddr)
dmafree(size_t size, void *vaddr)
{ {
vaddr = (void*)KSEG0ADDR(vaddr); vaddr = (void*)KSEG0ADDR(vaddr);
free_pages((unsigned long)vaddr, get_order(size)); free_pages((unsigned long)vaddr, get_order(size));
} }
static void gt96100_delay(int ms)
static void
gt96100_delay(int ms)
{ {
if (in_interrupt()) if (in_interrupt())
return; return;
...@@ -327,34 +316,6 @@ write_MII(int phy_addr, u32 reg, u16 data) ...@@ -327,34 +316,6 @@ write_MII(int phy_addr, u32 reg, u16 data)
return 0; return 0;
} }
#if 0
// These routines work, just disabled to avoid compile warnings
static void
dump_tx_ring(struct net_device *dev)
{
struct gt96100_private *gp = netdev_priv(dev);
int i;
dbg(0, "%s: txno/txni/cnt=%d/%d/%d\n", __FUNCTION__,
gp->tx_next_out, gp->tx_next_in, gp->tx_count);
for (i=0; i<TX_RING_SIZE; i++)
dump_tx_desc(0, dev, i);
}
static void
dump_rx_ring(struct net_device *dev)
{
struct gt96100_private *gp = netdev_priv(dev);
int i;
dbg(0, "%s: rxno=%d\n", __FUNCTION__, gp->rx_next_out);
for (i=0; i<RX_RING_SIZE; i++)
dump_rx_desc(0, dev, i);
}
#endif
static void static void
dump_MII(int dbg_lvl, struct net_device *dev) dump_MII(int dbg_lvl, struct net_device *dev)
{ {
...@@ -647,23 +608,19 @@ disable_ether_irq(struct net_device *dev) ...@@ -647,23 +608,19 @@ disable_ether_irq(struct net_device *dev)
/* /*
* Init GT96100 ethernet controller driver * Init GT96100 ethernet controller driver
*/ */
int gt96100_init_module(void) static int gt96100_init_module(void)
{ {
struct pci_dev *pci;
int i, retval=0; int i, retval=0;
u16 vendor_id, device_id;
u32 cpuConfig; u32 cpuConfig;
#ifndef CONFIG_MIPS_GT96100ETH /*
return -ENODEV; * Stupid probe because this really isn't a PCI device
#endif */
if (!(pci = pci_find_device(PCI_VENDOR_ID_MARVELL,
// probe for GT96100 by reading PCI0 vendor/device ID register PCI_DEVICE_ID_MARVELL_GT96100, NULL)) &&
pcibios_read_config_word(0, 0, PCI_VENDOR_ID, &vendor_id); !(pci = pci_find_device(PCI_VENDOR_ID_MARVELL,
pcibios_read_config_word(0, 0, PCI_DEVICE_ID, &device_id); PCI_DEVICE_ID_MARVELL_GT96100A, NULL))) {
if (vendor_id != PCI_VENDOR_ID_MARVELL ||
(device_id != PCI_DEVICE_ID_MARVELL_GT96100 &&
device_id != PCI_DEVICE_ID_MARVELL_GT96100A)) {
printk(KERN_ERR __FILE__ ": GT96100 not found!\n"); printk(KERN_ERR __FILE__ ": GT96100 not found!\n");
return -ENODEV; return -ENODEV;
} }
...@@ -675,17 +632,13 @@ int gt96100_init_module(void) ...@@ -675,17 +632,13 @@ int gt96100_init_module(void)
return -ENODEV; return -ENODEV;
} }
for (i=0; i < NUM_INTERFACES; i++) { for (i=0; i < NUM_INTERFACES; i++)
retval |= gt96100_probe1(i); retval |= gt96100_probe1(pci, i);
}
return retval; return retval;
} }
static int __init gt96100_probe1(struct pci_dev *pci, int port_num)
static int __init
gt96100_probe1(int port_num)
{ {
struct gt96100_private *gp = NULL; struct gt96100_private *gp = NULL;
struct gt96100_if_t *gtif = &gt96100_iflist[port_num]; struct gt96100_if_t *gtif = &gt96100_iflist[port_num];
...@@ -696,19 +649,19 @@ gt96100_probe1(int port_num) ...@@ -696,19 +649,19 @@ gt96100_probe1(int port_num)
struct net_device *dev = NULL; struct net_device *dev = NULL;
if (gtif->irq < 0) { if (gtif->irq < 0) {
printk(KERN_ERR "%s: irq unknown - probing not supported\n", __FUNCTION_); printk(KERN_ERR "%s: irq unknown - probing not supported\n",
__FUNCTION__);
return -ENODEV; return -ENODEV;
} }
pcibios_read_config_byte(0, 0, PCI_REVISION_ID, &chip_rev); pci_read_config_byte(pci, PCI_REVISION_ID, &chip_rev);
if (chip_rev >= REV_GT96100A_1) { if (chip_rev >= REV_GT96100A_1) {
phyAD = GT96100_READ(GT96100_ETH_PHY_ADDR_REG); phyAD = GT96100_READ(GT96100_ETH_PHY_ADDR_REG);
phy_addr = (phyAD >> (5*port_num)) & 0x1f; phy_addr = (phyAD >> (5*port_num)) & 0x1f;
} else { } else {
/* /*
* not sure what's this about -- probably * not sure what's this about -- probably a gt bug
* a gt bug
*/ */
phy_addr = port_num; phy_addr = port_num;
phyAD = GT96100_READ(GT96100_ETH_PHY_ADDR_REG); phyAD = GT96100_READ(GT96100_ETH_PHY_ADDR_REG);
...@@ -831,6 +784,7 @@ gt96100_probe1(int port_num) ...@@ -831,6 +784,7 @@ gt96100_probe1(int port_num)
free_netdev (dev); free_netdev (dev);
out: out:
release_region(gtif->iobase, GT96100_ETH_IO_SIZE); release_region(gtif->iobase, GT96100_ETH_IO_SIZE);
err("%s failed. Returns %d\n", __FUNCTION__, retval); err("%s failed. Returns %d\n", __FUNCTION__, retval);
return retval; return retval;
} }
...@@ -1102,6 +1056,7 @@ gt96100_close(struct net_device *dev) ...@@ -1102,6 +1056,7 @@ gt96100_close(struct net_device *dev)
} }
free_irq(dev->irq, dev); free_irq(dev->irq, dev);
return 0; return 0;
} }
...@@ -1312,10 +1267,11 @@ gt96100_tx_complete(struct net_device *dev, u32 status) ...@@ -1312,10 +1267,11 @@ gt96100_tx_complete(struct net_device *dev, u32 status)
cmdstat, nextOut); cmdstat, nextOut);
if (cmdstat & (u32)txOwn) { if (cmdstat & (u32)txOwn) {
//dump_tx_ring(dev); /*
// DMA is not finished writing descriptor??? * DMA is not finished writing descriptor???
// Leave and come back later to pick-up where * Leave and come back later to pick-up where
// we left off. * we left off.
*/
break; break;
} }
...@@ -1342,7 +1298,8 @@ gt96100_tx_complete(struct net_device *dev, u32 status) ...@@ -1342,7 +1298,8 @@ gt96100_tx_complete(struct net_device *dev, u32 status)
gp->tx_full = 0; gp->tx_full = 0;
if (gp->last_psr & psrLink) { if (gp->last_psr & psrLink) {
netif_wake_queue(dev); netif_wake_queue(dev);
dbg(2, "%s: Tx Ring was full, queue waked\n", __FUNCTION_); dbg(2, "%s: Tx Ring was full, queue waked\n",
__FUNCTION__);
} }
} }
...@@ -1425,12 +1382,12 @@ gt96100_interrupt(int irq, void *dev_id, struct pt_regs *regs) ...@@ -1425,12 +1382,12 @@ gt96100_interrupt(int irq, void *dev_id, struct pt_regs *regs)
if ((psr & psrLink) && !gp->tx_full && if ((psr & psrLink) && !gp->tx_full &&
netif_queue_stopped(dev)) { netif_queue_stopped(dev)) {
dbg(0, ": Link up, waking queue.\n", dbg(0, "%s: Link up, waking queue.\n",
__FUNCTION_); __FUNCTION__);
netif_wake_queue(dev); netif_wake_queue(dev);
} else if (!(psr & psrLink) && } else if (!(psr & psrLink) &&
!netif_queue_stopped(dev)) { !netif_queue_stopped(dev)) {
dbg(0, "Link down, stopping queue.\n", dbg(0, "%s: Link down, stopping queue.\n",
__FUNCTION__); __FUNCTION__);
netif_stop_queue(dev); netif_stop_queue(dev);
} }
...@@ -1569,8 +1526,8 @@ static void gt96100_cleanup_module(void) ...@@ -1569,8 +1526,8 @@ static void gt96100_cleanup_module(void)
for (i=0; i<NUM_INTERFACES; i++) { for (i=0; i<NUM_INTERFACES; i++) {
struct gt96100_if_t *gtif = &gt96100_iflist[i]; struct gt96100_if_t *gtif = &gt96100_iflist[i];
if (gtif->dev != NULL) { if (gtif->dev != NULL) {
struct gt96100_private *gp = struct gt96100_private *gp = (struct gt96100_private *)
(struct gt96100_private *)gtif->dev->priv; netdev_priv(gtif->dev);
unregister_netdev(gtif->dev); unregister_netdev(gtif->dev);
dmafree(RX_HASH_TABLE_SIZE, gp->hash_table_dma); dmafree(RX_HASH_TABLE_SIZE, gp->hash_table_dma);
dmafree(PKT_BUF_SZ*RX_RING_SIZE, gp->rx_buff); dmafree(PKT_BUF_SZ*RX_RING_SIZE, gp->rx_buff);
...@@ -1583,9 +1540,6 @@ static void gt96100_cleanup_module(void) ...@@ -1583,9 +1540,6 @@ static void gt96100_cleanup_module(void)
} }
} }
#ifndef MODULE
static int __init gt96100_setup(char *options) static int __init gt96100_setup(char *options)
{ {
char *this_opt; char *this_opt;
...@@ -1610,9 +1564,6 @@ static int __init gt96100_setup(char *options) ...@@ -1610,9 +1564,6 @@ static int __init gt96100_setup(char *options)
__setup("gt96100eth=", gt96100_setup); __setup("gt96100eth=", gt96100_setup);
#endif /* !MODULE */
module_init(gt96100_init_module); module_init(gt96100_init_module);
module_exit(gt96100_cleanup_module); module_exit(gt96100_cleanup_module);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment