* [patch 0/4] natsemi: Aculab E1/T1 PMXc Carrier Card support
@ 2006-03-12 19:22 Mark Brown
2006-03-12 19:23 ` [patch 1/4] natsemi: Add support for using MII port with no PHY Mark Brown
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Mark Brown @ 2006-03-12 19:22 UTC (permalink / raw)
To: Tim Hockin, Jeff Garzik; +Cc: netdev, linux-kernel
This patch series against the upstream branch of netdev-2.6 adds support
for these boards to the natsemi driver. It implements some new
functionality required by the boards and enables the appropriate
settings when such a board is detected.
--
"You grabbed my hand and we fell into it, like a daydream - or a fever."
^ permalink raw reply [flat|nested] 10+ messages in thread
* [patch 1/4] natsemi: Add support for using MII port with no PHY
2006-03-12 19:22 [patch 0/4] natsemi: Aculab E1/T1 PMXc Carrier Card support Mark Brown
@ 2006-03-12 19:23 ` Mark Brown
2006-03-12 21:41 ` thockin
2006-03-16 9:09 ` Andrew Morton
2006-03-12 19:23 ` [patch 2/4] natsemi: Support oversized EEPROMs Mark Brown
` (2 subsequent siblings)
3 siblings, 2 replies; 10+ messages in thread
From: Mark Brown @ 2006-03-12 19:23 UTC (permalink / raw)
To: Tim Hockin, Jeff Garzik; +Cc: netdev, linux-kernel
[-- Attachment #1: natsemi-ignore-phy.patch --]
[-- Type: text/plain, Size: 6510 bytes --]
This patch provides a module option which configures the natsemi driver
to use the external MII port on the chip but ignore any PHYs that may be
attached to it. The link state will be left as it was when the driver
started and can be configured via ethtool. Any PHYs that are present
can be accessed via the MII ioctl()s.
This is useful for systems where the device is connected without a PHY
or where either information or actions outside the scope of the driver
are required in order to use the PHYs.
Signed-Off-By: Mark Brown <broonie@sirena.org.uk>
Index: natsemi-queue/drivers/net/natsemi.c
===================================================================
--- natsemi-queue.orig/drivers/net/natsemi.c 2006-02-25 13:38:34.000000000 +0000
+++ natsemi-queue/drivers/net/natsemi.c 2006-02-25 13:50:51.000000000 +0000
@@ -259,7 +259,7 @@ MODULE_PARM_DESC(debug, "DP8381x default
MODULE_PARM_DESC(rx_copybreak,
"DP8381x copy breakpoint for copy-only-tiny-frames");
MODULE_PARM_DESC(options,
- "DP8381x: Bits 0-3: media type, bit 17: full duplex");
+ "DP8381x: Bits 0-3: media type, bit 17: full duplex, bit 18: ignore PHY");
MODULE_PARM_DESC(full_duplex, "DP8381x full duplex setting(s) (1)");
/*
@@ -690,6 +690,8 @@ struct netdev_private {
u32 intr_status;
/* Do not touch the nic registers */
int hands_off;
+ /* Don't pay attention to the reported link state. */
+ int ignore_phy;
/* external phy that is used: only valid if dev->if_port != PORT_TP */
int mii;
int phy_addr_external;
@@ -891,7 +893,19 @@ static int __devinit natsemi_probe1 (str
np->hands_off = 0;
np->intr_status = 0;
+ option = find_cnt < MAX_UNITS ? options[find_cnt] : 0;
+ if (dev->mem_start)
+ option = dev->mem_start;
+
+ /* Ignore the PHY status? */
+ if (option & 0x400) {
+ np->ignore_phy = 1;
+ } else {
+ np->ignore_phy = 0;
+ }
+
/* Initial port:
+ * - If configured to ignore the PHY set up for external.
* - If the nic was configured to use an external phy and if find_mii
* finds a phy: use external port, first phy that replies.
* - Otherwise: internal port.
@@ -899,7 +913,7 @@ static int __devinit natsemi_probe1 (str
* The address would be used to access a phy over the mii bus, but
* the internal phy is accessed through mapped registers.
*/
- if (readl(ioaddr + ChipConfig) & CfgExtPhy)
+ if (np->ignore_phy || readl(ioaddr + ChipConfig) & CfgExtPhy)
dev->if_port = PORT_MII;
else
dev->if_port = PORT_TP;
@@ -909,7 +923,9 @@ static int __devinit natsemi_probe1 (str
if (dev->if_port != PORT_TP) {
np->phy_addr_external = find_mii(dev);
- if (np->phy_addr_external == PHY_ADDR_NONE) {
+ /* If we're ignoring the PHY it doesn't matter if we can't
+ * find one. */
+ if (!np->ignore_phy && np->phy_addr_external == PHY_ADDR_NONE) {
dev->if_port = PORT_TP;
np->phy_addr_external = PHY_ADDR_INTERNAL;
}
@@ -917,10 +933,6 @@ static int __devinit natsemi_probe1 (str
np->phy_addr_external = PHY_ADDR_INTERNAL;
}
- option = find_cnt < MAX_UNITS ? options[find_cnt] : 0;
- if (dev->mem_start)
- option = dev->mem_start;
-
/* The lower four bits are the media type. */
if (option) {
if (option & 0x200)
@@ -954,7 +966,10 @@ static int __devinit natsemi_probe1 (str
if (mtu)
dev->mtu = mtu;
- netif_carrier_off(dev);
+ if (np->ignore_phy)
+ netif_carrier_on(dev);
+ else
+ netif_carrier_off(dev);
/* get the initial settings from hardware */
tmp = mdio_read(dev, MII_BMCR);
@@ -1002,6 +1017,8 @@ static int __devinit natsemi_probe1 (str
printk("%02x, IRQ %d", dev->dev_addr[i], irq);
if (dev->if_port == PORT_TP)
printk(", port TP.\n");
+ else if (np->ignore_phy)
+ printk(", port MII, ignoring PHY\n");
else
printk(", port MII, phy ad %d.\n", np->phy_addr_external);
}
@@ -1682,42 +1699,44 @@ static void check_link(struct net_device
{
struct netdev_private *np = netdev_priv(dev);
void __iomem * ioaddr = ns_ioaddr(dev);
- int duplex;
+ int duplex = np->full_duplex;
u16 bmsr;
-
- /* The link status field is latched: it remains low after a temporary
- * link failure until it's read. We need the current link status,
- * thus read twice.
- */
- mdio_read(dev, MII_BMSR);
- bmsr = mdio_read(dev, MII_BMSR);
- if (!(bmsr & BMSR_LSTATUS)) {
- if (netif_carrier_ok(dev)) {
+ /* If we're not paying attention to the PHY status then don't check. */
+ if (!np->ignore_phy) {
+ /* The link status field is latched: it remains low
+ * after a temporary link failure until it's read. We
+ * need the current link status, thus read twice.
+ */
+ mdio_read(dev, MII_BMSR);
+ bmsr = mdio_read(dev, MII_BMSR);
+
+ if (!(bmsr & BMSR_LSTATUS)) {
+ if (netif_carrier_ok(dev)) {
+ if (netif_msg_link(np))
+ printk(KERN_NOTICE "%s: link down.\n",
+ dev->name);
+ netif_carrier_off(dev);
+ undo_cable_magic(dev);
+ }
+ return;
+ }
+ if (!netif_carrier_ok(dev)) {
if (netif_msg_link(np))
- printk(KERN_NOTICE "%s: link down.\n",
- dev->name);
- netif_carrier_off(dev);
- undo_cable_magic(dev);
+ printk(KERN_NOTICE "%s: link up.\n", dev->name);
+ netif_carrier_on(dev);
+ do_cable_magic(dev);
}
- return;
- }
- if (!netif_carrier_ok(dev)) {
- if (netif_msg_link(np))
- printk(KERN_NOTICE "%s: link up.\n", dev->name);
- netif_carrier_on(dev);
- do_cable_magic(dev);
- }
- duplex = np->full_duplex;
- if (!duplex) {
- if (bmsr & BMSR_ANEGCOMPLETE) {
- int tmp = mii_nway_result(
- np->advertising & mdio_read(dev, MII_LPA));
- if (tmp == LPA_100FULL || tmp == LPA_10FULL)
+ if (!duplex) {
+ if (bmsr & BMSR_ANEGCOMPLETE) {
+ int tmp = mii_nway_result(
+ np->advertising & mdio_read(dev, MII_LPA));
+ if (tmp == LPA_100FULL || tmp == LPA_10FULL)
+ duplex = 1;
+ } else if (mdio_read(dev, MII_BMCR) & BMCR_FULLDPLX)
duplex = 1;
- } else if (mdio_read(dev, MII_BMCR) & BMCR_FULLDPLX)
- duplex = 1;
+ }
}
/* if duplex is set then bit 28 must be set, too */
@@ -2927,6 +2946,16 @@ static int netdev_set_ecmd(struct net_de
}
/*
+ * If we're ignoring the PHY then autoneg and the internal
+ * transciever are really not going to work so don't let the
+ * user select them.
+ */
+ if (np->ignore_phy && (ecmd->autoneg == AUTONEG_ENABLE ||
+ ecmd->port == PORT_INTERNAL)) {
+ return -EINVAL;
+ }
+
+ /*
* maxtxpkt, maxrxpkt: ignored for now.
*
* transceiver:
--
"You grabbed my hand and we fell into it, like a daydream - or a fever."
^ permalink raw reply [flat|nested] 10+ messages in thread
* [patch 2/4] natsemi: Support oversized EEPROMs
2006-03-12 19:22 [patch 0/4] natsemi: Aculab E1/T1 PMXc Carrier Card support Mark Brown
2006-03-12 19:23 ` [patch 1/4] natsemi: Add support for using MII port with no PHY Mark Brown
@ 2006-03-12 19:23 ` Mark Brown
2006-03-12 19:23 ` [patch 3/4] Add a PCI vendor ID definition for Aculab Mark Brown
2006-03-12 19:23 ` [patch 4/4] natsemi: Add quirks for Aculab E1/T1 PMXc cPCI carrier cards Mark Brown
3 siblings, 0 replies; 10+ messages in thread
From: Mark Brown @ 2006-03-12 19:23 UTC (permalink / raw)
To: Tim Hockin, Jeff Garzik; +Cc: netdev, linux-kernel
[-- Attachment #1: natsemi-variable-eeprom-size.patch --]
[-- Type: text/plain, Size: 2871 bytes --]
The natsemi chip can have a larger EEPROM attached than it itself uses
for configuration. This patch adds support for user space access
to such an EEPROM.
Signed-off-by: Mark Brown <broonie@sirena.org.uk>
Index: natsemi-queue/drivers/net/natsemi.c
===================================================================
--- natsemi-queue.orig/drivers/net/natsemi.c 2006-02-25 17:40:15.000000000 +0000
+++ natsemi-queue/drivers/net/natsemi.c 2006-02-25 17:40:39.000000000 +0000
@@ -226,7 +226,7 @@ static int full_duplex[MAX_UNITS];
NATSEMI_PG1_NREGS)
#define NATSEMI_REGS_VER 1 /* v1 added RFDR registers */
#define NATSEMI_REGS_SIZE (NATSEMI_NREGS * sizeof(u32))
-#define NATSEMI_EEPROM_SIZE 24 /* 12 16-bit values */
+#define NATSEMI_DEF_EEPROM_SIZE 24 /* 12 16-bit values */
/* Buffer sizes:
* The nic writes 32-bit values, even if the upper bytes of
@@ -716,6 +716,8 @@ struct netdev_private {
unsigned int iosize;
spinlock_t lock;
u32 msg_enable;
+ /* EEPROM data */
+ int eeprom_size;
};
static void move_int_phy(struct net_device *dev, int addr);
@@ -892,6 +894,7 @@ static int __devinit natsemi_probe1 (str
np->msg_enable = (debug >= 0) ? (1<<debug)-1 : NATSEMI_DEF_MSG;
np->hands_off = 0;
np->intr_status = 0;
+ np->eeprom_size = NATSEMI_DEF_EEPROM_SIZE;
option = find_cnt < MAX_UNITS ? options[find_cnt] : 0;
if (dev->mem_start)
@@ -2601,7 +2604,8 @@ static int get_regs_len(struct net_devic
static int get_eeprom_len(struct net_device *dev)
{
- return NATSEMI_EEPROM_SIZE;
+ struct netdev_private *np = netdev_priv(dev);
+ return np->eeprom_size;
}
static int get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
@@ -2688,15 +2692,20 @@ static u32 get_link(struct net_device *d
static int get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, u8 *data)
{
struct netdev_private *np = netdev_priv(dev);
- u8 eebuf[NATSEMI_EEPROM_SIZE];
+ u8 *eebuf;
int res;
+ eebuf = kmalloc(np->eeprom_size, GFP_KERNEL);
+ if (!eebuf)
+ return -ENOMEM;
+
eeprom->magic = PCI_VENDOR_ID_NS | (PCI_DEVICE_ID_NS_83815<<16);
spin_lock_irq(&np->lock);
res = netdev_get_eeprom(dev, eebuf);
spin_unlock_irq(&np->lock);
if (!res)
memcpy(data, eebuf+eeprom->offset, eeprom->len);
+ kfree(eebuf);
return res;
}
@@ -3062,9 +3071,10 @@ static int netdev_get_eeprom(struct net_
int i;
u16 *ebuf = (u16 *)buf;
void __iomem * ioaddr = ns_ioaddr(dev);
+ struct netdev_private *np = netdev_priv(dev);
/* eeprom_read reads 16 bits, and indexes by 16 bits */
- for (i = 0; i < NATSEMI_EEPROM_SIZE/2; i++) {
+ for (i = 0; i < np->eeprom_size/2; i++) {
ebuf[i] = eeprom_read(ioaddr, i);
/* The EEPROM itself stores data bit-swapped, but eeprom_read
* reads it back "sanely". So we swap it back here in order to
--
"You grabbed my hand and we fell into it, like a daydream - or a fever."
^ permalink raw reply [flat|nested] 10+ messages in thread
* [patch 3/4] Add a PCI vendor ID definition for Aculab
2006-03-12 19:22 [patch 0/4] natsemi: Aculab E1/T1 PMXc Carrier Card support Mark Brown
2006-03-12 19:23 ` [patch 1/4] natsemi: Add support for using MII port with no PHY Mark Brown
2006-03-12 19:23 ` [patch 2/4] natsemi: Support oversized EEPROMs Mark Brown
@ 2006-03-12 19:23 ` Mark Brown
2006-03-12 19:23 ` [patch 4/4] natsemi: Add quirks for Aculab E1/T1 PMXc cPCI carrier cards Mark Brown
3 siblings, 0 replies; 10+ messages in thread
From: Mark Brown @ 2006-03-12 19:23 UTC (permalink / raw)
To: Tim Hockin, Jeff Garzik; +Cc: netdev, linux-kernel
[-- Attachment #1: pci-vendor-aculab.patch --]
[-- Type: text/plain, Size: 735 bytes --]
Add a vendor ID definition for Aculab.
Signed-Off-By: Mark Brown <broonie@sirena.org.uk>
Index: e1000-queue/include/linux/pci_ids.h
===================================================================
--- e1000-queue.orig/include/linux/pci_ids.h 2006-02-25 12:50:12.000000000 +0000
+++ e1000-queue/include/linux/pci_ids.h 2006-02-25 12:51:51.000000000 +0000
@@ -1572,6 +1572,8 @@
#define PCI_VENDOR_ID_NVIDIA_SGS 0x12d2
#define PCI_DEVICE_ID_NVIDIA_SGS_RIVA128 0x0018
+#define PCI_VENDOR_ID_ACULAB 0x12d9
+
#define PCI_SUBVENDOR_ID_CHASE_PCIFAST 0x12E0
#define PCI_SUBDEVICE_ID_CHASE_PCIFAST4 0x0031
#define PCI_SUBDEVICE_ID_CHASE_PCIFAST8 0x0021
--
"You grabbed my hand and we fell into it, like a daydream - or a fever."
^ permalink raw reply [flat|nested] 10+ messages in thread
* [patch 4/4] natsemi: Add quirks for Aculab E1/T1 PMXc cPCI carrier cards
2006-03-12 19:22 [patch 0/4] natsemi: Aculab E1/T1 PMXc Carrier Card support Mark Brown
` (2 preceding siblings ...)
2006-03-12 19:23 ` [patch 3/4] Add a PCI vendor ID definition for Aculab Mark Brown
@ 2006-03-12 19:23 ` Mark Brown
3 siblings, 0 replies; 10+ messages in thread
From: Mark Brown @ 2006-03-12 19:23 UTC (permalink / raw)
To: Tim Hockin, Jeff Garzik; +Cc: netdev, linux-kernel
[-- Attachment #1: natsemi-aculab-cpci-carrier.patch --]
[-- Type: text/plain, Size: 6563 bytes --]
Aculab E1/T1 PMXc cPCI carrier card cards present a natsemi on the cPCI
bus wired up in a non-standard fashion. This patch provides support in
the natsemi driver for these cards by implementing a quirk mechanism and
using that to configure appropriate settings for the card: forcing 100M
full duplex, having a large EEPROM and using the MII port while ignoring
PHYs.
Signed-off-by: Mark Brown <broonie@sirena.org.uk>
Index: natsemi-queue/drivers/net/natsemi.c
===================================================================
--- natsemi-queue.orig/drivers/net/natsemi.c 2006-02-25 17:41:59.000000000 +0000
+++ natsemi-queue/drivers/net/natsemi.c 2006-03-08 21:44:12.000000000 +0000
@@ -226,7 +226,6 @@ static int full_duplex[MAX_UNITS];
NATSEMI_PG1_NREGS)
#define NATSEMI_REGS_VER 1 /* v1 added RFDR registers */
#define NATSEMI_REGS_SIZE (NATSEMI_NREGS * sizeof(u32))
-#define NATSEMI_DEF_EEPROM_SIZE 24 /* 12 16-bit values */
/* Buffer sizes:
* The nic writes 32-bit values, even if the upper bytes of
@@ -344,12 +343,14 @@ None characterised.
-enum pcistuff {
+enum natsemi_quirks {
PCI_USES_IO = 0x01,
PCI_USES_MEM = 0x02,
PCI_USES_MASTER = 0x04,
PCI_ADDR0 = 0x08,
PCI_ADDR1 = 0x10,
+ MEDIA_FORCE_100FD = 0x20,
+ MEDIA_IGNORE_PHY = 0x40,
};
/* MMIO operations required */
@@ -367,17 +368,21 @@ enum pcistuff {
#define MII_FX_SEL 0x0001 /* 100BASE-FX (fiber) */
#define MII_EN_SCRM 0x0004 /* enable scrambler (tp) */
-
/* array of board data directly indexed by pci_tbl[x].driver_data */
static const struct {
const char *name;
unsigned long flags;
+ int quirks;
+ int eeprom_size;
} natsemi_pci_info[] __devinitdata = {
- { "NatSemi DP8381[56]", PCI_IOTYPE },
+ { "NatSemi DP8381[56]", PCI_IOTYPE, 0, 24 },
+ { "Aculab E1/T1 PMXc cPCI carrier card", PCI_IOTYPE,
+ MEDIA_FORCE_100FD | MEDIA_IGNORE_PHY, 128 },
};
static struct pci_device_id natsemi_pci_tbl[] = {
- { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_83815, PCI_ANY_ID, PCI_ANY_ID, },
+ { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_83815, PCI_VENDOR_ID_ACULAB, PCI_SUBDEVICE_ID_ACULAB_174, 0, 0, 1 },
+ { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_83815, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
{ 0, },
};
MODULE_DEVICE_TABLE(pci, natsemi_pci_tbl);
@@ -815,6 +820,39 @@ static void move_int_phy(struct net_devi
udelay(1);
}
+static void __devinit natsemi_init_media (struct net_device *dev)
+{
+ struct netdev_private *np = netdev_priv(dev);
+ u32 tmp;
+
+ tmp = mdio_read(dev, MII_BMCR);
+ np->speed = (tmp & BMCR_SPEED100)? SPEED_100 : SPEED_10;
+ np->duplex = (tmp & BMCR_FULLDPLX)? DUPLEX_FULL : DUPLEX_HALF;
+ np->autoneg = (tmp & BMCR_ANENABLE)? AUTONEG_ENABLE: AUTONEG_DISABLE;
+ np->advertising= mdio_read(dev, MII_ADVERTISE);
+
+ if ((np->advertising & ADVERTISE_ALL) != ADVERTISE_ALL
+ && netif_msg_probe(np)) {
+ printk(KERN_INFO "natsemi %s: Transceiver default autonegotiation %s "
+ "10%s %s duplex.\n",
+ pci_name(np->pci_dev),
+ (mdio_read(dev, MII_BMCR) & BMCR_ANENABLE)?
+ "enabled, advertise" : "disabled, force",
+ (np->advertising &
+ (ADVERTISE_100FULL|ADVERTISE_100HALF))?
+ "0" : "",
+ (np->advertising &
+ (ADVERTISE_100FULL|ADVERTISE_10FULL))?
+ "full" : "half");
+ }
+ if (netif_msg_probe(np))
+ printk(KERN_INFO
+ "natsemi %s: Transceiver status %#04x advertising %#04x.\n",
+ pci_name(np->pci_dev), mdio_read(dev, MII_BMSR),
+ np->advertising);
+
+}
+
static int __devinit natsemi_probe1 (struct pci_dev *pdev,
const struct pci_device_id *ent)
{
@@ -894,17 +932,21 @@ static int __devinit natsemi_probe1 (str
np->msg_enable = (debug >= 0) ? (1<<debug)-1 : NATSEMI_DEF_MSG;
np->hands_off = 0;
np->intr_status = 0;
- np->eeprom_size = NATSEMI_DEF_EEPROM_SIZE;
+ np->eeprom_size = natsemi_pci_info[chip_idx].eeprom_size;
option = find_cnt < MAX_UNITS ? options[find_cnt] : 0;
if (dev->mem_start)
option = dev->mem_start;
/* Ignore the PHY status? */
- if (option & 0x400) {
+ if (natsemi_pci_info[chip_idx].quirks & MEDIA_IGNORE_PHY) {
np->ignore_phy = 1;
} else {
- np->ignore_phy = 0;
+ if (option & 0x400) {
+ np->ignore_phy = 1;
+ } else {
+ np->ignore_phy = 0;
+ }
}
/* Initial port:
@@ -936,6 +978,12 @@ static int __devinit natsemi_probe1 (str
np->phy_addr_external = PHY_ADDR_INTERNAL;
}
+ /* Apply any speed quirks. */
+ if (natsemi_pci_info[chip_idx].quirks & MEDIA_FORCE_100FD) {
+ np->speed = 100;
+ np->duplex = 1;
+ }
+
/* The lower four bits are the media type. */
if (option) {
if (option & 0x200)
@@ -974,32 +1022,10 @@ static int __devinit natsemi_probe1 (str
else
netif_carrier_off(dev);
- /* get the initial settings from hardware */
- tmp = mdio_read(dev, MII_BMCR);
- np->speed = (tmp & BMCR_SPEED100)? SPEED_100 : SPEED_10;
- np->duplex = (tmp & BMCR_FULLDPLX)? DUPLEX_FULL : DUPLEX_HALF;
- np->autoneg = (tmp & BMCR_ANENABLE)? AUTONEG_ENABLE: AUTONEG_DISABLE;
- np->advertising= mdio_read(dev, MII_ADVERTISE);
-
- if ((np->advertising & ADVERTISE_ALL) != ADVERTISE_ALL
- && netif_msg_probe(np)) {
- printk(KERN_INFO "natsemi %s: Transceiver default autonegotiation %s "
- "10%s %s duplex.\n",
- pci_name(np->pci_dev),
- (mdio_read(dev, MII_BMCR) & BMCR_ANENABLE)?
- "enabled, advertise" : "disabled, force",
- (np->advertising &
- (ADVERTISE_100FULL|ADVERTISE_100HALF))?
- "0" : "",
- (np->advertising &
- (ADVERTISE_100FULL|ADVERTISE_10FULL))?
- "full" : "half");
- }
- if (netif_msg_probe(np))
- printk(KERN_INFO
- "natsemi %s: Transceiver status %#04x advertising %#04x.\n",
- pci_name(np->pci_dev), mdio_read(dev, MII_BMSR),
- np->advertising);
+ /* get the initial settings from hardware if we don't have any
+ * already */
+ if (!np->speed)
+ natsemi_init_media(dev);
/* save the silicon revision for later querying */
np->srr = readl(ioaddr + SiliconRev);
Index: natsemi-queue/include/linux/pci_ids.h
===================================================================
--- natsemi-queue.orig/include/linux/pci_ids.h 2006-02-25 19:19:55.000000000 +0000
+++ natsemi-queue/include/linux/pci_ids.h 2006-02-25 19:21:28.000000000 +0000
@@ -1573,6 +1573,7 @@
#define PCI_DEVICE_ID_NVIDIA_SGS_RIVA128 0x0018
#define PCI_VENDOR_ID_ACULAB 0x12d9
+#define PCI_SUBDEVICE_ID_ACULAB_174 0x000c
#define PCI_SUBVENDOR_ID_CHASE_PCIFAST 0x12E0
#define PCI_SUBDEVICE_ID_CHASE_PCIFAST4 0x0031
--
"You grabbed my hand and we fell into it, like a daydream - or a fever."
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch 1/4] natsemi: Add support for using MII port with no PHY
2006-03-12 19:23 ` [patch 1/4] natsemi: Add support for using MII port with no PHY Mark Brown
@ 2006-03-12 21:41 ` thockin
2006-03-13 18:23 ` Mark Brown
2006-03-16 9:09 ` Andrew Morton
1 sibling, 1 reply; 10+ messages in thread
From: thockin @ 2006-03-12 21:41 UTC (permalink / raw)
To: Mark Brown; +Cc: Jeff Garzik, netdev, linux-kernel
On Sun, Mar 12, 2006 at 07:23:00PM +0000, Mark Brown wrote:
> This patch provides a module option which configures the natsemi driver
> to use the external MII port on the chip but ignore any PHYs that may be
> attached to it. The link state will be left as it was when the driver
> started and can be configured via ethtool. Any PHYs that are present
> can be accessed via the MII ioctl()s.
>
> This is useful for systems where the device is connected without a PHY
> or where either information or actions outside the scope of the driver
> are required in order to use the PHYs.
Not that my opinion should hold much weight, having been absent from the
driver for some time, but yuck. Is there no better way to do this thatn
sprinkling poo all over it?
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch 1/4] natsemi: Add support for using MII port with no PHY
2006-03-12 21:41 ` thockin
@ 2006-03-13 18:23 ` Mark Brown
2006-03-13 18:41 ` thockin
0 siblings, 1 reply; 10+ messages in thread
From: Mark Brown @ 2006-03-13 18:23 UTC (permalink / raw)
To: thockin; +Cc: Jeff Garzik, netdev, linux-kernel
On Sun, Mar 12, 2006 at 01:41:13PM -0800, thockin@hockin.org wrote:
> Not that my opinion should hold much weight, having been absent from the
> driver for some time, but yuck. Is there no better way to do this thatn
> sprinkling poo all over it?
The changes are mostly isolated into check_link(), the fact that half
the function gets placed inside a conditional but diff sees it as a
bunch of smaller changes makes the changes look a lot more invasive than
they actually are. I guess that could be helped by splitting the PHY
access code out of check_link() into check_phy_status() or something but
I'm not sure how much that really helps.
--
"You grabbed my hand and we fell into it, like a daydream - or a fever."
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch 1/4] natsemi: Add support for using MII port with no PHY
2006-03-13 18:23 ` Mark Brown
@ 2006-03-13 18:41 ` thockin
0 siblings, 0 replies; 10+ messages in thread
From: thockin @ 2006-03-13 18:41 UTC (permalink / raw)
To: Jeff Garzik, netdev, linux-kernel
On Mon, Mar 13, 2006 at 06:23:31PM +0000, Mark Brown wrote:
> On Sun, Mar 12, 2006 at 01:41:13PM -0800, thockin@hockin.org wrote:
>
> > Not that my opinion should hold much weight, having been absent from the
> > driver for some time, but yuck. Is there no better way to do this thatn
> > sprinkling poo all over it?
>
> The changes are mostly isolated into check_link(), the fact that half
> the function gets placed inside a conditional but diff sees it as a
> bunch of smaller changes makes the changes look a lot more invasive than
> they actually are. I guess that could be helped by splitting the PHY
> access code out of check_link() into check_phy_status() or something but
> I'm not sure how much that really helps.
It's not terribly offensive it just seems like a hack. :) I'm not sure I
really understand the reasoning, so I can't offer anythign better or more
general purpose.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch 1/4] natsemi: Add support for using MII port with no PHY
2006-03-12 19:23 ` [patch 1/4] natsemi: Add support for using MII port with no PHY Mark Brown
2006-03-12 21:41 ` thockin
@ 2006-03-16 9:09 ` Andrew Morton
2006-03-16 9:26 ` Mark Brown
1 sibling, 1 reply; 10+ messages in thread
From: Andrew Morton @ 2006-03-16 9:09 UTC (permalink / raw)
To: Mark Brown; +Cc: thockin, jgarzik, netdev, linux-kernel
Mark Brown <broonie@sirena.org.uk> wrote:
>
> + if (np->ignore_phy && (ecmd->autoneg == AUTONEG_ENABLE ||
> + ecmd->port == PORT_INTERNAL)) {
What's PORT_INTERNAL? ethtool doesn't appear to define that.
drivers/net/natsemi.c: In function `netdev_set_ecmd':
drivers/net/natsemi.c:2989: `PORT_INTERNAL' undeclared (first use in this function)
drivers/net/natsemi.c:2989: (Each undeclared identifier is reported only once
drivers/net/natsemi.c:2989: for each function it appears in.)
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch 1/4] natsemi: Add support for using MII port with no PHY
2006-03-16 9:09 ` Andrew Morton
@ 2006-03-16 9:26 ` Mark Brown
0 siblings, 0 replies; 10+ messages in thread
From: Mark Brown @ 2006-03-16 9:26 UTC (permalink / raw)
To: Andrew Morton; +Cc: thockin, jgarzik, netdev, linux-kernel
On Thu, Mar 16, 2006 at 01:09:02AM -0800, Andrew Morton wrote:
> Mark Brown <broonie@sirena.org.uk> wrote:
> > + if (np->ignore_phy && (ecmd->autoneg == AUTONEG_ENABLE ||
> > + ecmd->port == PORT_INTERNAL)) {
> What's PORT_INTERNAL? ethtool doesn't appear to define that.
It should be PORT_TP, sorry:
This patch provides a module option which configures the natsemi driver
to use the external MII port on the chip but ignore any PHYs that may be
attached to it. The link state will be left as it was when the driver
started and can be configured via ethtool. Any PHYs that are present
can be accessed via the MII ioctl()s.
This is useful for systems where the device is connected without a PHY
or where either information or actions outside the scope of the driver
are required in order to use the PHYs.
Signed-Off-By: Mark Brown <broonie@sirena.org.uk>
Index: natsemi-queue/drivers/net/natsemi.c
===================================================================
--- natsemi-queue.orig/drivers/net/natsemi.c 2006-02-25 13:38:34.000000000 +0000
+++ natsemi-queue/drivers/net/natsemi.c 2006-02-25 13:50:51.000000000 +0000
@@ -259,7 +259,7 @@ MODULE_PARM_DESC(debug, "DP8381x default
MODULE_PARM_DESC(rx_copybreak,
"DP8381x copy breakpoint for copy-only-tiny-frames");
MODULE_PARM_DESC(options,
- "DP8381x: Bits 0-3: media type, bit 17: full duplex");
+ "DP8381x: Bits 0-3: media type, bit 17: full duplex, bit 18: ignore PHY");
MODULE_PARM_DESC(full_duplex, "DP8381x full duplex setting(s) (1)");
/*
@@ -690,6 +690,8 @@ struct netdev_private {
u32 intr_status;
/* Do not touch the nic registers */
int hands_off;
+ /* Don't pay attention to the reported link state. */
+ int ignore_phy;
/* external phy that is used: only valid if dev->if_port != PORT_TP */
int mii;
int phy_addr_external;
@@ -891,7 +893,19 @@ static int __devinit natsemi_probe1 (str
np->hands_off = 0;
np->intr_status = 0;
+ option = find_cnt < MAX_UNITS ? options[find_cnt] : 0;
+ if (dev->mem_start)
+ option = dev->mem_start;
+
+ /* Ignore the PHY status? */
+ if (option & 0x400) {
+ np->ignore_phy = 1;
+ } else {
+ np->ignore_phy = 0;
+ }
+
/* Initial port:
+ * - If configured to ignore the PHY set up for external.
* - If the nic was configured to use an external phy and if find_mii
* finds a phy: use external port, first phy that replies.
* - Otherwise: internal port.
@@ -899,7 +913,7 @@ static int __devinit natsemi_probe1 (str
* The address would be used to access a phy over the mii bus, but
* the internal phy is accessed through mapped registers.
*/
- if (readl(ioaddr + ChipConfig) & CfgExtPhy)
+ if (np->ignore_phy || readl(ioaddr + ChipConfig) & CfgExtPhy)
dev->if_port = PORT_MII;
else
dev->if_port = PORT_TP;
@@ -909,7 +923,9 @@ static int __devinit natsemi_probe1 (str
if (dev->if_port != PORT_TP) {
np->phy_addr_external = find_mii(dev);
- if (np->phy_addr_external == PHY_ADDR_NONE) {
+ /* If we're ignoring the PHY it doesn't matter if we can't
+ * find one. */
+ if (!np->ignore_phy && np->phy_addr_external == PHY_ADDR_NONE) {
dev->if_port = PORT_TP;
np->phy_addr_external = PHY_ADDR_INTERNAL;
}
@@ -917,10 +933,6 @@ static int __devinit natsemi_probe1 (str
np->phy_addr_external = PHY_ADDR_INTERNAL;
}
- option = find_cnt < MAX_UNITS ? options[find_cnt] : 0;
- if (dev->mem_start)
- option = dev->mem_start;
-
/* The lower four bits are the media type. */
if (option) {
if (option & 0x200)
@@ -954,7 +966,10 @@ static int __devinit natsemi_probe1 (str
if (mtu)
dev->mtu = mtu;
- netif_carrier_off(dev);
+ if (np->ignore_phy)
+ netif_carrier_on(dev);
+ else
+ netif_carrier_off(dev);
/* get the initial settings from hardware */
tmp = mdio_read(dev, MII_BMCR);
@@ -1002,6 +1017,8 @@ static int __devinit natsemi_probe1 (str
printk("%02x, IRQ %d", dev->dev_addr[i], irq);
if (dev->if_port == PORT_TP)
printk(", port TP.\n");
+ else if (np->ignore_phy)
+ printk(", port MII, ignoring PHY\n");
else
printk(", port MII, phy ad %d.\n", np->phy_addr_external);
}
@@ -1682,42 +1699,44 @@ static void check_link(struct net_device
{
struct netdev_private *np = netdev_priv(dev);
void __iomem * ioaddr = ns_ioaddr(dev);
- int duplex;
+ int duplex = np->full_duplex;
u16 bmsr;
-
- /* The link status field is latched: it remains low after a temporary
- * link failure until it's read. We need the current link status,
- * thus read twice.
- */
- mdio_read(dev, MII_BMSR);
- bmsr = mdio_read(dev, MII_BMSR);
- if (!(bmsr & BMSR_LSTATUS)) {
- if (netif_carrier_ok(dev)) {
+ /* If we're not paying attention to the PHY status then don't check. */
+ if (!np->ignore_phy) {
+ /* The link status field is latched: it remains low
+ * after a temporary link failure until it's read. We
+ * need the current link status, thus read twice.
+ */
+ mdio_read(dev, MII_BMSR);
+ bmsr = mdio_read(dev, MII_BMSR);
+
+ if (!(bmsr & BMSR_LSTATUS)) {
+ if (netif_carrier_ok(dev)) {
+ if (netif_msg_link(np))
+ printk(KERN_NOTICE "%s: link down.\n",
+ dev->name);
+ netif_carrier_off(dev);
+ undo_cable_magic(dev);
+ }
+ return;
+ }
+ if (!netif_carrier_ok(dev)) {
if (netif_msg_link(np))
- printk(KERN_NOTICE "%s: link down.\n",
- dev->name);
- netif_carrier_off(dev);
- undo_cable_magic(dev);
+ printk(KERN_NOTICE "%s: link up.\n", dev->name);
+ netif_carrier_on(dev);
+ do_cable_magic(dev);
}
- return;
- }
- if (!netif_carrier_ok(dev)) {
- if (netif_msg_link(np))
- printk(KERN_NOTICE "%s: link up.\n", dev->name);
- netif_carrier_on(dev);
- do_cable_magic(dev);
- }
- duplex = np->full_duplex;
- if (!duplex) {
- if (bmsr & BMSR_ANEGCOMPLETE) {
- int tmp = mii_nway_result(
- np->advertising & mdio_read(dev, MII_LPA));
- if (tmp == LPA_100FULL || tmp == LPA_10FULL)
+ if (!duplex) {
+ if (bmsr & BMSR_ANEGCOMPLETE) {
+ int tmp = mii_nway_result(
+ np->advertising & mdio_read(dev, MII_LPA));
+ if (tmp == LPA_100FULL || tmp == LPA_10FULL)
+ duplex = 1;
+ } else if (mdio_read(dev, MII_BMCR) & BMCR_FULLDPLX)
duplex = 1;
- } else if (mdio_read(dev, MII_BMCR) & BMCR_FULLDPLX)
- duplex = 1;
+ }
}
/* if duplex is set then bit 28 must be set, too */
@@ -2927,6 +2946,16 @@ static int netdev_set_ecmd(struct net_de
}
/*
+ * If we're ignoring the PHY then autoneg and the internal
+ * transciever are really not going to work so don't let the
+ * user select them.
+ */
+ if (np->ignore_phy && (ecmd->autoneg == AUTONEG_ENABLE ||
+ ecmd->port == PORT_TP)) {
+ return -EINVAL;
+ }
+
+ /*
* maxtxpkt, maxrxpkt: ignored for now.
*
* transceiver:
--
"You grabbed my hand and we fell into it, like a daydream - or a fever."
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2006-03-16 9:26 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-12 19:22 [patch 0/4] natsemi: Aculab E1/T1 PMXc Carrier Card support Mark Brown
2006-03-12 19:23 ` [patch 1/4] natsemi: Add support for using MII port with no PHY Mark Brown
2006-03-12 21:41 ` thockin
2006-03-13 18:23 ` Mark Brown
2006-03-13 18:41 ` thockin
2006-03-16 9:09 ` Andrew Morton
2006-03-16 9:26 ` Mark Brown
2006-03-12 19:23 ` [patch 2/4] natsemi: Support oversized EEPROMs Mark Brown
2006-03-12 19:23 ` [patch 3/4] Add a PCI vendor ID definition for Aculab Mark Brown
2006-03-12 19:23 ` [patch 4/4] natsemi: Add quirks for Aculab E1/T1 PMXc cPCI carrier cards Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).