aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/natsemi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/natsemi.c')
-rw-r--r--drivers/net/natsemi.c100
1 files changed, 49 insertions, 51 deletions
diff --git a/drivers/net/natsemi.c b/drivers/net/natsemi.c
index 2e4ecedba057..5657049c2160 100644
--- a/drivers/net/natsemi.c
+++ b/drivers/net/natsemi.c
@@ -226,7 +226,6 @@ static int full_duplex[MAX_UNITS];
226 NATSEMI_PG1_NREGS) 226 NATSEMI_PG1_NREGS)
227#define NATSEMI_REGS_VER 1 /* v1 added RFDR registers */ 227#define NATSEMI_REGS_VER 1 /* v1 added RFDR registers */
228#define NATSEMI_REGS_SIZE (NATSEMI_NREGS * sizeof(u32)) 228#define NATSEMI_REGS_SIZE (NATSEMI_NREGS * sizeof(u32))
229#define NATSEMI_DEF_EEPROM_SIZE 24 /* 12 16-bit values */
230 229
231/* Buffer sizes: 230/* Buffer sizes:
232 * The nic writes 32-bit values, even if the upper bytes of 231 * The nic writes 32-bit values, even if the upper bytes of
@@ -344,18 +343,6 @@ None characterised.
344 343
345 344
346 345
347enum pcistuff {
348 PCI_USES_IO = 0x01,
349 PCI_USES_MEM = 0x02,
350 PCI_USES_MASTER = 0x04,
351 PCI_ADDR0 = 0x08,
352 PCI_ADDR1 = 0x10,
353};
354
355/* MMIO operations required */
356#define PCI_IOTYPE (PCI_USES_MASTER | PCI_USES_MEM | PCI_ADDR1)
357
358
359/* 346/*
360 * Support for fibre connections on Am79C874: 347 * Support for fibre connections on Am79C874:
361 * This phy needs a special setup when connected to a fibre cable. 348 * This phy needs a special setup when connected to a fibre cable.
@@ -363,22 +350,25 @@ enum pcistuff {
363 */ 350 */
364#define PHYID_AM79C874 0x0022561b 351#define PHYID_AM79C874 0x0022561b
365 352
366#define MII_MCTRL 0x15 /* mode control register */ 353enum {
367#define MII_FX_SEL 0x0001 /* 100BASE-FX (fiber) */ 354 MII_MCTRL = 0x15, /* mode control register */
368#define MII_EN_SCRM 0x0004 /* enable scrambler (tp) */ 355 MII_FX_SEL = 0x0001, /* 100BASE-FX (fiber) */
356 MII_EN_SCRM = 0x0004, /* enable scrambler (tp) */
357};
369 358
370 359
371/* array of board data directly indexed by pci_tbl[x].driver_data */ 360/* array of board data directly indexed by pci_tbl[x].driver_data */
372static const struct { 361static const struct {
373 const char *name; 362 const char *name;
374 unsigned long flags; 363 unsigned long flags;
364 unsigned int eeprom_size;
375} natsemi_pci_info[] __devinitdata = { 365} natsemi_pci_info[] __devinitdata = {
376 { "NatSemi DP8381[56]", PCI_IOTYPE }, 366 { "NatSemi DP8381[56]", 0, 24 },
377}; 367};
378 368
379static struct pci_device_id natsemi_pci_tbl[] = { 369static const struct pci_device_id natsemi_pci_tbl[] __devinitdata = {
380 { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_83815, PCI_ANY_ID, PCI_ANY_ID, }, 370 { PCI_VENDOR_ID_NS, 0x0020, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
381 { 0, }, 371 { } /* terminate list */
382}; 372};
383MODULE_DEVICE_TABLE(pci, natsemi_pci_tbl); 373MODULE_DEVICE_TABLE(pci, natsemi_pci_tbl);
384 374
@@ -813,6 +803,42 @@ static void move_int_phy(struct net_device *dev, int addr)
813 udelay(1); 803 udelay(1);
814} 804}
815 805
806static void __devinit natsemi_init_media (struct net_device *dev)
807{
808 struct netdev_private *np = netdev_priv(dev);
809 u32 tmp;
810
811 netif_carrier_off(dev);
812
813 /* get the initial settings from hardware */
814 tmp = mdio_read(dev, MII_BMCR);
815 np->speed = (tmp & BMCR_SPEED100)? SPEED_100 : SPEED_10;
816 np->duplex = (tmp & BMCR_FULLDPLX)? DUPLEX_FULL : DUPLEX_HALF;
817 np->autoneg = (tmp & BMCR_ANENABLE)? AUTONEG_ENABLE: AUTONEG_DISABLE;
818 np->advertising= mdio_read(dev, MII_ADVERTISE);
819
820 if ((np->advertising & ADVERTISE_ALL) != ADVERTISE_ALL
821 && netif_msg_probe(np)) {
822 printk(KERN_INFO "natsemi %s: Transceiver default autonegotiation %s "
823 "10%s %s duplex.\n",
824 pci_name(np->pci_dev),
825 (mdio_read(dev, MII_BMCR) & BMCR_ANENABLE)?
826 "enabled, advertise" : "disabled, force",
827 (np->advertising &
828 (ADVERTISE_100FULL|ADVERTISE_100HALF))?
829 "0" : "",
830 (np->advertising &
831 (ADVERTISE_100FULL|ADVERTISE_10FULL))?
832 "full" : "half");
833 }
834 if (netif_msg_probe(np))
835 printk(KERN_INFO
836 "natsemi %s: Transceiver status %#04x advertising %#04x.\n",
837 pci_name(np->pci_dev), mdio_read(dev, MII_BMSR),
838 np->advertising);
839
840}
841
816static int __devinit natsemi_probe1 (struct pci_dev *pdev, 842static int __devinit natsemi_probe1 (struct pci_dev *pdev,
817 const struct pci_device_id *ent) 843 const struct pci_device_id *ent)
818{ 844{
@@ -852,8 +878,7 @@ static int __devinit natsemi_probe1 (struct pci_dev *pdev,
852 iosize = pci_resource_len(pdev, pcibar); 878 iosize = pci_resource_len(pdev, pcibar);
853 irq = pdev->irq; 879 irq = pdev->irq;
854 880
855 if (natsemi_pci_info[chip_idx].flags & PCI_USES_MASTER) 881 pci_set_master(pdev);
856 pci_set_master(pdev);
857 882
858 dev = alloc_etherdev(sizeof (struct netdev_private)); 883 dev = alloc_etherdev(sizeof (struct netdev_private));
859 if (!dev) 884 if (!dev)
@@ -892,7 +917,7 @@ static int __devinit natsemi_probe1 (struct pci_dev *pdev,
892 np->msg_enable = (debug >= 0) ? (1<<debug)-1 : NATSEMI_DEF_MSG; 917 np->msg_enable = (debug >= 0) ? (1<<debug)-1 : NATSEMI_DEF_MSG;
893 np->hands_off = 0; 918 np->hands_off = 0;
894 np->intr_status = 0; 919 np->intr_status = 0;
895 np->eeprom_size = NATSEMI_DEF_EEPROM_SIZE; 920 np->eeprom_size = natsemi_pci_info[chip_idx].eeprom_size;
896 921
897 /* Initial port: 922 /* Initial port:
898 * - If the nic was configured to use an external phy and if find_mii 923 * - If the nic was configured to use an external phy and if find_mii
@@ -957,34 +982,7 @@ static int __devinit natsemi_probe1 (struct pci_dev *pdev,
957 if (mtu) 982 if (mtu)
958 dev->mtu = mtu; 983 dev->mtu = mtu;
959 984
960 netif_carrier_off(dev); 985 natsemi_init_media(dev);
961
962 /* get the initial settings from hardware */
963 tmp = mdio_read(dev, MII_BMCR);
964 np->speed = (tmp & BMCR_SPEED100)? SPEED_100 : SPEED_10;
965 np->duplex = (tmp & BMCR_FULLDPLX)? DUPLEX_FULL : DUPLEX_HALF;
966 np->autoneg = (tmp & BMCR_ANENABLE)? AUTONEG_ENABLE: AUTONEG_DISABLE;
967 np->advertising= mdio_read(dev, MII_ADVERTISE);
968
969 if ((np->advertising & ADVERTISE_ALL) != ADVERTISE_ALL
970 && netif_msg_probe(np)) {
971 printk(KERN_INFO "natsemi %s: Transceiver default autonegotiation %s "
972 "10%s %s duplex.\n",
973 pci_name(np->pci_dev),
974 (mdio_read(dev, MII_BMCR) & BMCR_ANENABLE)?
975 "enabled, advertise" : "disabled, force",
976 (np->advertising &
977 (ADVERTISE_100FULL|ADVERTISE_100HALF))?
978 "0" : "",
979 (np->advertising &
980 (ADVERTISE_100FULL|ADVERTISE_10FULL))?
981 "full" : "half");
982 }
983 if (netif_msg_probe(np))
984 printk(KERN_INFO
985 "natsemi %s: Transceiver status %#04x advertising %#04x.\n",
986 pci_name(np->pci_dev), mdio_read(dev, MII_BMSR),
987 np->advertising);
988 986
989 /* save the silicon revision for later querying */ 987 /* save the silicon revision for later querying */
990 np->srr = readl(ioaddr + SiliconRev); 988 np->srr = readl(ioaddr + SiliconRev);