#include <common.h>
#include <malloc.h>
#include <net.h>
+#include <netdev.h>
#include <asm/io.h>
#include <pci.h>
-#if 0
#define PCNET_DEBUG_LEVEL 0 /* 0=off, 1=init, 2=rx/tx */
-#endif
-
-#if PCNET_DEBUG_LEVEL > 0
-#define PCNET_DEBUG1(fmt,args...) printf (fmt ,##args)
-#if PCNET_DEBUG_LEVEL > 1
-#define PCNET_DEBUG2(fmt,args...) printf (fmt ,##args)
-#else
-#define PCNET_DEBUG2(fmt,args...)
-#endif
-#else
-#define PCNET_DEBUG1(fmt,args...)
-#define PCNET_DEBUG2(fmt,args...)
-#endif
-#if defined(CONFIG_CMD_NET) \
- && defined(CONFIG_NET_MULTI) && defined(CONFIG_PCNET)
+#define PCNET_DEBUG1(fmt,args...) \
+ debug_cond(PCNET_DEBUG_LEVEL > 0, fmt ,##args)
+#define PCNET_DEBUG2(fmt,args...) \
+ debug_cond(PCNET_DEBUG_LEVEL > 1, fmt ,##args)
#if !defined(CONF_PCNET_79C973) && defined(CONF_PCNET_79C975)
#error "Macro for PCnet chip version is not defined!"
}
static int pcnet_init (struct eth_device *dev, bd_t * bis);
-static int pcnet_send (struct eth_device *dev, volatile void *packet,
- int length);
+static int pcnet_send(struct eth_device *dev, void *packet, int length);
static int pcnet_recv (struct eth_device *dev);
static void pcnet_halt (struct eth_device *dev);
static int pcnet_probe (struct eth_device *dev, bd_t * bis, int dev_num);
int pcnet_initialize (bd_t * bis)
{
-<<<<<<< HEAD:drivers/net/pcnet.c
pci_dev_t devbusfn;
struct eth_device *dev;
u16 command, status;
* Allocate and pre-fill the device structure.
*/
dev = (struct eth_device *) malloc (sizeof *dev);
+ if (!dev) {
+ printf("pcnet: Can not allocate memory\n");
+ break;
+ }
+ memset(dev, 0, sizeof(*dev));
dev->priv = (void *) devbusfn;
sprintf (dev->name, "pcnet#%d", dev_nr);
dev->recv = pcnet_recv;
eth_register (dev);
-=======
- pci_dev_t devbusfn;
- struct eth_device* dev;
- u16 command, status;
- int dev_nr = 0;
-
- PCNET_DEBUG1("\npcnet_initialize...\n");
-
- for (dev_nr = 0; ; dev_nr++) {
-
- /*
- * Find the PCnet PCI device(s).
- */
- if ((devbusfn = pci_find_devices(supported, dev_nr)) < 0) {
- break;
- }
-
- /*
- * Allocate and pre-fill the device structure.
- */
- dev = (struct eth_device*) malloc(sizeof *dev);
- dev->priv = (void *)devbusfn;
- sprintf(dev->name, "pcnet#%d", dev_nr);
-
- /*
- * Setup the PCI device.
- */
- pci_read_config_dword(devbusfn, PCI_BASE_ADDRESS_0, (unsigned int *)&dev->iobase);
- dev->iobase=pci_io_to_phys(devbusfn,dev->iobase);
- dev->iobase &= ~0xf;
-
- PCNET_DEBUG1("%s: devbusfn=0x%x iobase=0x%x: ",
- dev->name, devbusfn, dev->iobase);
-
- command = PCI_COMMAND_IO | PCI_COMMAND_MASTER;
- pci_write_config_word(devbusfn, PCI_COMMAND, command);
- pci_read_config_word(devbusfn, PCI_COMMAND, &status);
- if ((status & command) != command) {
- printf("%s: Couldn't enable IO access or Bus Mastering\n",
- dev->name);
- free(dev);
- continue;
- }
-
- pci_write_config_byte(devbusfn, PCI_LATENCY_TIMER, 0x40);
-
- /*
- * Probe the PCnet chip.
- */
- if (pcnet_probe(dev, bis, dev_nr) < 0) {
- free(dev);
- continue;
->>>>>>> Fixed pcnet io_base:drivers/net/pcnet.c
}
udelay (10 * 1000);
return 0;
}
-static int pcnet_send (struct eth_device *dev, volatile void *packet,
- int pkt_len)
+static int pcnet_send(struct eth_device *dev, void *packet, int pkt_len)
{
int i, status;
struct pcnet_tx_head *entry = &lp->tx_ring[lp->cur_tx];
printf ("%s: TIMEOUT: controller reset failed\n", dev->name);
}
}
-#endif