Skip to content

Commit

Permalink
Finished by hand
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Brown committed Apr 13, 2005
1 parent 3616de9 commit 9848135
Show file tree
Hide file tree
Showing 9 changed files with 192 additions and 177 deletions.
34 changes: 19 additions & 15 deletions src/drivers/net/natsemi.c
Expand Up @@ -181,6 +181,9 @@ enum desc_status_bits {

/* Globals */

static struct nic_operations natsemi_operations;
static struct pci_driver natsemi_driver;

static int natsemi_debug = 1; /* 1 normal messages, 0 quiet .. 7 verbose. */

const char *nic_name;
Expand Down Expand Up @@ -248,31 +251,32 @@ natsemi_probe ( struct dev *dev ) {
int i;
int prev_eedata;
u32 tmp;

if ( ! find_pci_device ( pci, &natsemi_driver ) )
return 0;

if (pci->ioaddr == 0)
return 0;

adjust_pci_device(pci);

/* initialize some commonly used globals */

nic->irqno = 0;
nic->ioaddr = pci->ioaddr & ~3;
nic->ioaddr = pci->ioaddr;

ioaddr = pci->ioaddr & ~3;
ioaddr = pci->ioaddr;
vendor = pci->vendor;
dev_id = pci->dev_id;
nic_name = pci->name;
nic_name = dev->name;

/* natsemi has a non-standard PM control register
* in PCI config space. Some boards apparently need
* to be brought to D0 in this manner.
*/
pcibios_read_config_dword(pci->bus, pci->devfn, PCIPM, &tmp);
pci_read_config_dword(pci, PCIPM, &tmp);
if (tmp & (0x03|0x100)) {
/* D0 state, disable PME assertion */
u32 newtmp = tmp & ~(0x03|0x100);
pcibios_write_config_dword(pci->bus, pci->devfn, PCIPM, newtmp);
pci_write_config_dword(pci, PCIPM, newtmp);
}

/* get MAC address */
Expand Down Expand Up @@ -316,14 +320,6 @@ natsemi_probe ( struct dev *dev ) {

/* initialize device */
natsemi_init(nic);
static struct nic_operations natsemi_operations;
static struct nic_operations natsemi_operations = {
.connect = dummy_connect,
.poll = natsemi_poll,
.transmit = natsemi_transmit,
.irq = natsemi_irq,
.disable = natsemi_disable,
};
nic->nic_op = &natsemi_operations;

return 1;
Expand Down Expand Up @@ -770,6 +766,14 @@ natsemi_irq(struct nic *nic __unused, irq_action_t action __unused)
}
}

static struct nic_operations natsemi_operations = {
.connect = dummy_connect,
.poll = natsemi_poll,
.transmit = natsemi_transmit,
.irq = natsemi_irq,
.disable = natsemi_disable,
};

static struct pci_id natsemi_nics[] = {
PCI_ROM(0x100b, 0x0020, "dp83815", "DP83815"),
};
Expand Down
44 changes: 23 additions & 21 deletions src/drivers/net/ns83820.c
Expand Up @@ -774,7 +774,7 @@ static void ns83820_disable ( struct nic *nic ) {

ns->up = 0;

ns83820_do_reset((struct nic *) dev, CR_RST);
ns83820_do_reset(nic, CR_RST);

ns->IMR_cache &=
~(ISR_RXOK | ISR_RXDESC | ISR_RXERR | ISR_RXEARLY |
Expand Down Expand Up @@ -804,26 +804,42 @@ static void ns83820_irq(struct nic *nic __unused, irq_action_t action __unused)
}
}

static struct nic_operations ns83820_operations = {
.connect = dummy_connect,
.poll = ns83820_poll,
.transmit = ns83820_transmit,
.irq = ns83820_irq,
.disable = ns83820_disable,
};

static struct pci_id ns83820_nics[] = {
PCI_ROM(0x100b, 0x0022, "ns83820", "National Semiconductor 83820"),
};

static struct pci_driver ns83820_driver =
PCI_DRIVER ( "NS83820/PCI", ns83820_nics, PCI_NO_CLASS );

/**************************************************************************
PROBE - Look for an adapter, this routine's visible to the outside
***************************************************************************/

#define board_found 1
#define valid_link 0
static int ns83820_probe ( struct dev *dev ) {

struct nic *nic = nic_device ( dev );

struct pci_device *pci = pci_device ( dev );
int sz;
long addr;
int using_dac = 0;

if ( ! find_pci_device ( pci, &ns83820_driver ) )
return 0;

if (pci->ioaddr == 0)
return 0;

printf("ns83820.c: Found %s, vendor=0x%hX, device=0x%hX\n",
pci->name, pci->vendor, pci->dev_id);
dev->name, pci->vendor, pci->dev_id);

/* point to private storage */
ns = &nsx;
Expand Down Expand Up @@ -863,12 +879,12 @@ static int ns83820_probe ( struct dev *dev ) {
ns->CFG_cache = readl(ns->base + CFG);

if ((ns->CFG_cache & CFG_PCI64_DET)) {
printf("%s: detected 64 bit PCI data bus.\n", pci->name);
printf("%s: detected 64 bit PCI data bus.\n", dev->name);
/*dev->CFG_cache |= CFG_DATA64_EN; */
if (!(ns->CFG_cache & CFG_DATA64_EN))
printf
("%s: EEPROM did not enable 64 bit bus. Disabled.\n",
pci->name);
dev->name);
} else
ns->CFG_cache &= ~(CFG_DATA64_EN);

Expand Down Expand Up @@ -1000,22 +1016,8 @@ static int ns83820_probe ( struct dev *dev ) {

ns83820_reset(nic);
/* point to NIC specific routines */
static struct nic_operations ns83820_operations;
static struct nic_operations ns83820_operations = {
.connect = dummy_connect,
.poll = ns83820_poll,
.transmit = ns83820_transmit,
.irq = ns83820_irq,
.disable = ns83820_disable,
}; nic->nic_op = &ns83820_operations;
nic->nic_op = &ns83820_operations;
return 1;
}

static struct pci_id ns83820_nics[] = {
PCI_ROM(0x100b, 0x0022, "ns83820", "National Semiconductor 83820"),
};

static struct pci_driver ns83820_driver =
PCI_DRIVER ( "NS83820/PCI", ns83820_nics, PCI_NO_CLASS );

BOOT_DRIVER ( "NS83820/PCI", ns83820_probe );
30 changes: 17 additions & 13 deletions src/drivers/net/pcnet32.c
Expand Up @@ -62,6 +62,8 @@ typedef unsigned int u32;
typedef signed int s32;

static u32 ioaddr; /* Globally used for the card's io address */
static struct nic_operations pcnet32_operations;
static struct pci_driver pcnet32_driver;

#ifdef EDEBUG
#define dprintf(x) printf x
Expand Down Expand Up @@ -665,25 +667,26 @@ PROBE - Look for an adapter, this routine's visible to the outside
You should omit the last argument struct pci_device * for a non-PCI NIC
***************************************************************************/
static int pcnet32_probe ( struct dev *dev ) {

struct nic *nic = nic_device ( dev );

struct pci_device *pci = pci_device ( dev );
int i, media;
int fdx, mii, fset, dxsuflo, ltint;
int chip_version;
char *chipname;
struct pcnet32_access *a = NULL;
u8 promaddr[6];

int shared = 1;

if ( ! find_pci_device ( pci, &pcnet32_driver ) )
return 0;

if (pci->ioaddr == 0)
return 0;

/* BASE is used throughout to address the card */
ioaddr = pci->ioaddr;
printf("pcnet32.c: Found %s, Vendor=0x%hX Device=0x%hX\n",
pci->name, pci->vendor, pci->dev_id);
dev->name, pci->vendor, pci->dev_id);

nic->irqno = 0;
nic->ioaddr = pci->ioaddr & ~3;
Expand Down Expand Up @@ -801,7 +804,7 @@ static int pcnet32_probe ( struct dev *dev ) {
nic->node_addr[i] = promaddr[i];
}
/* Print out some hardware info */
printf("%s: %! at ioaddr %hX, ", pci->name, nic->node_addr,
printf("%s: %! at ioaddr %hX, ", dev->name, nic->node_addr,
ioaddr);

/* Set to pci bus master */
Expand Down Expand Up @@ -945,14 +948,7 @@ static int pcnet32_probe ( struct dev *dev ) {
else
printf("\n");
}
static struct nic_operations pcnet32_operations;
static struct nic_operations pcnet32_operations = {
.connect = dummy_connect,
.poll = pcnet32_poll,
.transmit = pcnet32_transmit,
.irq = pcnet32_irq,
.disable = pcnet32_disable,
};

nic->nic_op = &pcnet32_operations;

return 1;
Expand Down Expand Up @@ -993,6 +989,14 @@ static void mdio_write(struct nic *nic __unused, int phy_id, int reg_num,
}
#endif

static struct nic_operations pcnet32_operations = {
.connect = dummy_connect,
.poll = pcnet32_poll,
.transmit = pcnet32_transmit,
.irq = pcnet32_irq,
.disable = pcnet32_disable,
};

static struct pci_id pcnet32_nics[] = {
PCI_ROM(0x1022, 0x2000, "lancepci", "AMD Lance/PCI"),
PCI_ROM(0x1022, 0x2625, "pcnetfastiii", "AMD Lance/PCI PCNet/32"),
Expand Down
42 changes: 22 additions & 20 deletions src/drivers/net/r8169.c
Expand Up @@ -702,24 +702,40 @@ static void r8169_disable ( struct nic *nic __unused ) {
}
}

static struct nic_operations r8169_operations = {
.connect = dummy_connect,
.poll = r8169_poll,
.transmit = r8169_transmit,
.irq = r8169_irq,
.disable = r8169_disable,
};

static struct pci_id r8169_nics[] = {
PCI_ROM(0x10ec, 0x8169, "r8169", "RealTek RTL8169 Gigabit Ethernet"),
};

static struct pci_driver r8169_driver =
PCI_DRIVER ( "r8169/PCI", r8169_nics, PCI_NO_CLASS );

/**************************************************************************
PROBE - Look for an adapter, this routine's visible to the outside
***************************************************************************/

#define board_found 1
#define valid_link 0
static int r8169_probe ( struct dev *dev ) {

struct nic *nic = nic_device ( dev );

struct pci_device *pci = pci_device ( dev );
static int board_idx = -1;
static int printed_version = 0;
int i, rc;
int option = -1, Cap10_100 = 0, Cap1000 = 0;

if ( ! find_pci_device ( pci, &r8169_driver ) )
return 0;

printf("r8169.c: Found %s, Vendor=%hX Device=%hX\n",
pci->name, pci->vendor, pci->dev_id);
dev->name, pci->vendor, pci->dev_id);

board_idx++;

Expand All @@ -737,7 +753,7 @@ static int r8169_probe ( struct dev *dev ) {
dprintf(("%s: Identified chip type is '%s'.\n", pci->name,
rtl_chip_info[tpc->chipset].name));
/* Print out some hardware info */
printf("%s: %! at ioaddr %hX, ", pci->name, nic->node_addr,
printf("%s: %! at ioaddr %hX, ", dev->name, nic->node_addr,
ioaddr);

/* if TBI is not endbled */
Expand Down Expand Up @@ -824,32 +840,18 @@ static int r8169_probe ( struct dev *dev ) {
udelay(100);
printf
("%s: 1000Mbps Full-duplex operation, TBI Link %s!\n",
pci->name,
dev->name,
(RTL_R32(TBICSR) & TBILinkOK) ? "OK" : "Failed");

}

r8169_reset(nic);
/* point to NIC specific routines */
static struct nic_operations r8169_operations;
static struct nic_operations r8169_operations = {
.connect = dummy_connect,
.poll = r8169_poll,
.transmit = r8169_transmit,
.irq = r8169_irq,
.disable = r8169_disable,
}; nic->nic_op = &r8169_operations;
nic->nic_op = &r8169_operations;
nic->irqno = pci->irq;
nic->ioaddr = ioaddr;
return 1;

}

static struct pci_id r8169_nics[] = {
PCI_ROM(0x10ec, 0x8169, "r8169", "RealTek RTL8169 Gigabit Ethernet"),
};

static struct pci_driver r8169_driver =
PCI_DRIVER ( "r8169/PCI", r8169_nics, PCI_NO_CLASS );

BOOT_DRIVER ( "r8169/PCI", r8169_probe );

0 comments on commit 9848135

Please sign in to comment.