]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/sis900.c
Input: spitzkbd - fix the reversed Address and Calender keys
[linux-2.6-omap-h63xx.git] / drivers / net / sis900.c
index 1d4d88680db197cb1caa0660360db9001c140090..b82191d2bee127415d14b3e65075af0d7f702421 100644 (file)
@@ -1,6 +1,6 @@
 /* sis900.c: A SiS 900/7016 PCI Fast Ethernet driver for Linux.
    Copyright 1999 Silicon Integrated System Corporation 
-   Revision:   1.08.08 Jan. 22 2005
+   Revision:   1.08.09 Sep. 19 2005
    
    Modified from the driver which is originally written by Donald Becker.
    
@@ -17,6 +17,7 @@
    SiS 7014 Single Chip 100BASE-TX/10BASE-T Physical Layer Solution,
    preliminary Rev. 1.0 Jan. 18, 1998
 
+   Rev 1.08.09 Sep. 19 2005 Daniele Venzano add Wake on LAN support
    Rev 1.08.08 Jan. 22 2005 Daniele Venzano use netif_msg for debugging messages
    Rev 1.08.07 Nov.  2 2003 Daniele Venzano <webvenza@libero.it> add suspend/resume support
    Rev 1.08.06 Sep. 24 2002 Mufasa Yang bug fix for Tx timeout & add SiS963 support
@@ -76,7 +77,7 @@
 #include "sis900.h"
 
 #define SIS900_MODULE_NAME "sis900"
-#define SIS900_DRV_VERSION "v1.08.08 Jan. 22 2005"
+#define SIS900_DRV_VERSION "v1.08.09 Sep. 19 2005"
 
 static char version[] __devinitdata =
 KERN_INFO "sis900.c: " SIS900_DRV_VERSION "\n";
@@ -99,7 +100,7 @@ enum {
        SIS_900 = 0,
        SIS_7016
 };
-static char * card_names[] = {
+static const char * card_names[] = {
        "SiS 900 PCI Fast Ethernet",
        "SiS 7016 PCI Fast Ethernet"
 };
@@ -114,7 +115,7 @@ MODULE_DEVICE_TABLE (pci, sis900_pci_tbl);
 
 static void sis900_read_mode(struct net_device *net_dev, int *speed, int *duplex);
 
-static struct mii_chip_info {
+static const struct mii_chip_info {
        const char * name;
        u16 phy_id0;
        u16 phy_id1;
@@ -127,6 +128,7 @@ static struct mii_chip_info {
        { "SiS 900 Internal MII PHY",           0x001d, 0x8000, LAN },
        { "SiS 7014 Physical Layer Solution",   0x0016, 0xf830, LAN },
        { "Altimata AC101LF PHY",               0x0022, 0x5520, LAN },
+       { "ADM 7001 LAN PHY",                   0x002e, 0xcc60, LAN },
        { "AMD 79C901 10BASE-T PHY",            0x0000, 0x6B70, LAN },
        { "AMD 79C901 HomePNA PHY",             0x0000, 0x6B90, HOME},
        { "ICS LAN PHY",                        0x0015, 0xF440, LAN },
@@ -399,7 +401,7 @@ static int __devinit sis900_probe(struct pci_dev *pci_dev,
        void *ring_space;
        long ioaddr;
        int i, ret;
-       char *card_name = card_names[pci_id->driver_data];
+       const char *card_name = card_names[pci_id->driver_data];
        const char *dev_name = pci_name(pci_dev);
 
 /* when built into the kernel, we only print version if device is found */
@@ -538,6 +540,11 @@ static int __devinit sis900_probe(struct pci_dev *pci_dev,
                printk("%2.2x:", (u8)net_dev->dev_addr[i]);
        printk("%2.2x.\n", net_dev->dev_addr[i]);
 
+       /* Detect Wake on Lan support */
+       ret = (inl(net_dev->base_addr + CFGPMC) & PMESP) >> 27;
+       if (netif_msg_probe(sis_priv) && (ret & PME_D3C) == 0)
+               printk(KERN_INFO "%s: Wake on LAN only available from suspend to RAM.", net_dev->name);
+
        return 0;
 
  err_unmap_rx:
@@ -1269,7 +1276,7 @@ static void sis900_timer(unsigned long data)
        struct net_device *net_dev = (struct net_device *)data;
        struct sis900_private *sis_priv = net_dev->priv;
        struct mii_phy *mii_phy = sis_priv->mii;
-       static int next_tick = 5*HZ;
+       static const int next_tick = 5*HZ;
        u16 status;
 
        if (!sis_priv->autong_complete){
@@ -1686,7 +1693,7 @@ static irqreturn_t sis900_interrupt(int irq, void *dev_instance, struct pt_regs
  *
  *     Process receive interrupt events, 
  *     put buffer to higher layer and refill buffer pool
- *     Note: This fucntion is called by interrupt handler, 
+ *     Note: This function is called by interrupt handler,
  *     don't do "too much" work here
  */
 
@@ -1833,7 +1840,7 @@ static int sis900_rx(struct net_device *net_dev)
  *
  *     Check for error condition and free socket buffer etc 
  *     schedule for more transmission as needed
- *     Note: This fucntion is called by interrupt handler, 
+ *     Note: This function is called by interrupt handler,
  *     don't do "too much" work here
  */
 
@@ -2015,6 +2022,67 @@ static int sis900_nway_reset(struct net_device *net_dev)
        return mii_nway_restart(&sis_priv->mii_info);
 }
 
+/**
+ *     sis900_set_wol - Set up Wake on Lan registers
+ *     @net_dev: the net device to probe
+ *     @wol: container for info passed to the driver
+ *
+ *     Process ethtool command "wol" to setup wake on lan features.
+ *     SiS900 supports sending WoL events if a correct packet is received,
+ *     but there is no simple way to filter them to only a subset (broadcast,
+ *     multicast, unicast or arp).
+ */
+static int sis900_set_wol(struct net_device *net_dev, struct ethtool_wolinfo *wol)
+{
+       struct sis900_private *sis_priv = net_dev->priv;
+       long pmctrl_addr = net_dev->base_addr + pmctrl;
+       u32 cfgpmcsr = 0, pmctrl_bits = 0;
+
+       if (wol->wolopts == 0) {
+               pci_read_config_dword(sis_priv->pci_dev, CFGPMCSR, &cfgpmcsr);
+               cfgpmcsr &= ~PME_EN;
+               pci_write_config_dword(sis_priv->pci_dev, CFGPMCSR, cfgpmcsr);
+               outl(pmctrl_bits, pmctrl_addr);
+               if (netif_msg_wol(sis_priv))
+                       printk(KERN_DEBUG "%s: Wake on LAN disabled\n", net_dev->name);
+               return 0;
+       }
+
+       if (wol->wolopts & (WAKE_MAGICSECURE | WAKE_UCAST | WAKE_MCAST
+                               | WAKE_BCAST | WAKE_ARP))
+               return -EINVAL;
+
+       if (wol->wolopts & WAKE_MAGIC)
+               pmctrl_bits |= MAGICPKT;
+       if (wol->wolopts & WAKE_PHY)
+               pmctrl_bits |= LINKON;
+       
+       outl(pmctrl_bits, pmctrl_addr);
+
+       pci_read_config_dword(sis_priv->pci_dev, CFGPMCSR, &cfgpmcsr);
+       cfgpmcsr |= PME_EN;
+       pci_write_config_dword(sis_priv->pci_dev, CFGPMCSR, cfgpmcsr);
+       if (netif_msg_wol(sis_priv))
+               printk(KERN_DEBUG "%s: Wake on LAN enabled\n", net_dev->name);
+
+       return 0;
+}
+
+static void sis900_get_wol(struct net_device *net_dev, struct ethtool_wolinfo *wol)
+{
+       long pmctrl_addr = net_dev->base_addr + pmctrl;
+       u32 pmctrl_bits;
+
+       pmctrl_bits = inl(pmctrl_addr);
+       if (pmctrl_bits & MAGICPKT)
+               wol->wolopts |= WAKE_MAGIC;
+       if (pmctrl_bits & LINKON)
+               wol->wolopts |= WAKE_PHY;
+
+       wol->supported = (WAKE_PHY | WAKE_MAGIC);
+}
+
 static struct ethtool_ops sis900_ethtool_ops = {
        .get_drvinfo    = sis900_get_drvinfo,
        .get_msglevel   = sis900_get_msglevel,
@@ -2023,6 +2091,8 @@ static struct ethtool_ops sis900_ethtool_ops = {
        .get_settings   = sis900_get_settings,
        .set_settings   = sis900_set_settings,
        .nway_reset     = sis900_nway_reset,
+       .get_wol        = sis900_get_wol,
+       .set_wol        = sis900_set_wol
 };
 
 /**
@@ -2213,7 +2283,7 @@ static void set_rx_mode(struct net_device *net_dev)
        int i, table_entries;
        u32 rx_mode;
 
-       /* 635 Hash Table entires = 256(2^16) */
+       /* 635 Hash Table entries = 256(2^16) */
        if((sis_priv->chipset_rev >= SIS635A_900_REV) ||
                        (sis_priv->chipset_rev == SIS900B_900_REV))
                table_entries = 16;