All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] WOL for sis900
@ 2004-10-30 15:43 Malte Schröder
  2004-10-30 16:13 ` Jeff Garzik
  2004-11-10  2:58 ` Rusty Russell
  0 siblings, 2 replies; 8+ messages in thread
From: Malte Schröder @ 2004-10-30 15:43 UTC (permalink / raw)
  To: linux-kernel


[-- Attachment #1.1: Type: text/plain, Size: 323 bytes --]

Hello,
I have applied the patch from http://lkml.org/lkml/2003/7/16/88 manually 
to 2.6.7 (also works on 2.6.{8,9}) and have been using it since then.
Attached is a diff against 2.6.9.

Greets
-- 
---------------------------------------
Malte Schröder
MalteSch@gmx.de
ICQ# 68121508
---------------------------------------


[-- Attachment #1.2: sis900_wol.diff --]
[-- Type: text/x-patch, Size: 2720 bytes --]

--- drivers/net/sis900.c.orig	2004-10-18 23:53:51.000000000 +0200
+++ drivers/net/sis900.c	2004-10-30 17:35:49.000000000 +0200
@@ -74,12 +74,14 @@
 
 #define SIS900_MODULE_NAME "sis900"
 #define SIS900_DRV_VERSION "v1.08.07 11/02/2003"
+#define SIS900_WOL_DEFAULT 0
 
 static char version[] __devinitdata =
 KERN_INFO "sis900.c: " SIS900_DRV_VERSION "\n";
 
 static int max_interrupt_work = 40;
 static int multicast_filter_limit = 128;
+static int enable_wol = SIS900_WOL_DEFAULT;
 
 #define sis900_debug debug
 static int sis900_debug;
@@ -182,9 +184,11 @@
 MODULE_PARM(multicast_filter_limit, "i");
 MODULE_PARM(max_interrupt_work, "i");
 MODULE_PARM(debug, "i");
+MODULE_PARM(enable_wol, "i");
 MODULE_PARM_DESC(multicast_filter_limit, "SiS 900/7016 maximum number of filtered multicast addresses");
 MODULE_PARM_DESC(max_interrupt_work, "SiS 900/7016 maximum events handled per interrupt");
 MODULE_PARM_DESC(debug, "SiS 900/7016 debug level (2-4)");
+MODULE_PARM_DESC(enable_wol, "Enable Wake-on-LAN support (0/1)");
 
 static int sis900_open(struct net_device *net_dev);
 static int sis900_mii_probe (struct net_device * net_dev);
@@ -930,6 +934,7 @@
 {
 	struct sis900_private *sis_priv = net_dev->priv;
 	long ioaddr = net_dev->base_addr;
+	u32 cfgpmcsr;
 	u8 revision;
 	int ret;
 
@@ -956,6 +961,15 @@
 	/* Workaround for EDB */
 	sis900_set_mode(ioaddr, HW_SPEED_10_MBPS, FDX_CAPABLE_HALF_SELECTED);
 
+	/* Enable Wake-on-LAN if requested. */
+	if (enable_wol) {
+		pci_read_config_dword(sis_priv->pci_dev, CFGPMCSR, &cfgpmcsr);
+		cfgpmcsr |= PME_EN;
+		pci_write_config_dword(sis_priv->pci_dev, CFGPMCSR, cfgpmcsr);
+		outl(inl(ioaddr + pmctrl) | MAGICPKT | ALGORITHM, ioaddr + pmctrl);
+	} else
+		outl(inl(ioaddr + pmctrl) & ~MAGICPKT, ioaddr + pmctrl);
+
 	/* Enable all known interrupts by setting the interrupt mask. */
 	outl((RxSOVR|RxORN|RxERR|RxOK|TxURN|TxERR|TxIDLE), ioaddr + imr);
 	outl(RxENA | inl(ioaddr + cr), ioaddr + cr);
--- drivers/net/sis900.h.orig	2004-10-30 17:35:42.000000000 +0200
+++ drivers/net/sis900.h	2004-10-30 17:35:49.000000000 +0200
@@ -140,6 +140,25 @@
 	EEREQ = 0x00000400, EEDONE = 0x00000200, EEGNT = 0x00000100
 };
 
+/* Wake-on-LAN support. */
+enum sis900_power_management_control_register_bits {
+	LINKLOSS  = 0x00000001,
+	LINKON    = 0x00000002,
+	MAGICPKT  = 0x00000400,
+	ALGORITHM = 0x00000800,
+	FRM1EN    = 0x00100000,
+	FRM2EN    = 0x00200000,
+	FRM3EN    = 0x00400000,
+	FRM1ACS   = 0x01000000,
+	FRM2ACS   = 0x02000000,
+	FRM3ACS   = 0x04000000,
+	WAKEALL   = 0x40000000,
+	GATECLK   = 0x80000000
+};
+
+#define CFGPMCSR 0x44
+#define PME_EN 0x100
+
 /* Management Data I/O (mdio) frame */
 #define MIIread         0x6000
 #define MIIwrite        0x5002

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 256 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] WOL for sis900
  2004-10-30 15:43 [PATCH] WOL for sis900 Malte Schröder
@ 2004-10-30 16:13 ` Jeff Garzik
  2004-10-30 19:00   ` Daniele Venzano
  2004-11-10  2:58 ` Rusty Russell
  1 sibling, 1 reply; 8+ messages in thread
From: Jeff Garzik @ 2004-10-30 16:13 UTC (permalink / raw)
  To: Malte Schröder; +Cc: linux-kernel, Daniele Venzano

Malte Schröder wrote:
> Hello,
> I have applied the patch from http://lkml.org/lkml/2003/7/16/88 manually 
> to 2.6.7 (also works on 2.6.{8,9}) and have been using it since then.
> Attached is a diff against 2.6.9.

Two comments:

1) Please include a signed-off-by line, as per

	http://linux.yyz.us/patch-format.html
		and
	http://www.zip.com.au/~akpm/linux/patches/stuff/tpp.txt

2) Please use ethtool to enable/disable WOL.  No need for a module option.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] WOL for sis900
  2004-10-30 16:13 ` Jeff Garzik
@ 2004-10-30 19:00   ` Daniele Venzano
  2004-10-31 13:08     ` Malte Schröder
  0 siblings, 1 reply; 8+ messages in thread
From: Daniele Venzano @ 2004-10-30 19:00 UTC (permalink / raw)
  To: NetDev; +Cc: Malte Schröder, Jeff Garzik

[-- Attachment #1: Type: text/plain, Size: 1165 bytes --]

On Sat, Oct 30, 2004 at 12:13:39PM -0400, Jeff Garzik wrote:
> Malte Schröder wrote:
> >Hello,
> >I have applied the patch from http://lkml.org/lkml/2003/7/16/88 manually 
> >to 2.6.7 (also works on 2.6.{8,9}) and have been using it since then.
> >Attached is a diff against 2.6.9.
> 
> 2) Please use ethtool to enable/disable WOL.  No need for a module option.

Attached is a first try at this wol via ethtool thing. I don't think to
have got it right, but here it is.

I tried to test WoL on my laptop, obvioulsy it didn't work, but I don't
even know if I have the hardware support for it.
On this page:
http://www.sis.com/products/connectivity/900.htm
it says that the magic packet feature is optional.

I would really like to have some way to check if WoL is supported by the
hardware before thinking to include this. I didn't find any
documentation of some use for this.

Finally, I have never realized the sorry state of sis900 wrt ethtool,
I'll try to get some more support...

The attached patch is against clean 2.6.9 and is NOT for inclusion.

-- 
------------------------------
Daniele Venzano
Web: http://teg.homeunix.org

[-- Attachment #2: sis900_wol_ethtool.diff --]
[-- Type: text/plain, Size: 2516 bytes --]

Index: sis900.c
===================================================================
--- sis900.c	(revision 13)
+++ sis900.c	(working copy)
@@ -120,6 +120,7 @@
 } mii_chip_table[] = {
 	{ "SiS 900 Internal MII PHY", 		0x001d, 0x8000, LAN },
 	{ "SiS 7014 Physical Layer Solution", 	0x0016, 0xf830, LAN },
+	{ "Altimata AC101LF PHY",               0x0022, 0x5520, LAN },
 	{ "AMD 79C901 10BASE-T PHY",  		0x0000, 0x6B70, LAN },
 	{ "AMD 79C901 HomePNA PHY",		0x0000, 0x6B90, HOME},
 	{ "ICS LAN PHY",			0x0015, 0xF440, LAN },
@@ -1903,8 +1904,41 @@
 	strcpy (info->bus_info, pci_name(sis_priv->pci_dev));
 }
 
+static int sis900_set_wol(struct net_device *net_dev, struct ethtool_wolinfo *wol)
+{
+	struct sis900_private *sis_priv = net_dev->priv;
+	long ioaddr = net_dev->base_addr;
+	u32 cfgpmcsr;
+	
+	if (wol->wolopts & WAKE_MAGIC) {
+		pci_read_config_dword(sis_priv->pci_dev, CFGPMCSR, &cfgpmcsr);
+		cfgpmcsr |= PME_EN;
+		pci_write_config_dword(sis_priv->pci_dev, CFGPMCSR, cfgpmcsr);
+		outl(inl(ioaddr + pmctrl) | MAGICPKT | ALGORITHM, ioaddr + pmctrl);
+	} else if (wol->wolopts) {
+		return -EINVAL;
+	} else {
+		pci_read_config_dword(sis_priv->pci_dev, CFGPMCSR, &cfgpmcsr);
+		cfgpmcsr |= ~PME_EN;
+		pci_write_config_dword(sis_priv->pci_dev, CFGPMCSR, cfgpmcsr);
+		outl(inl(ioaddr + pmctrl) & ~MAGICPKT, ioaddr + pmctrl);
+	}
+
+	return 0;
+}
+
+static void sis900_get_wol(struct net_device *net_dev, struct ethtool_wolinfo *wol)
+{
+	long ioaddr = net_dev->base_addr;
+
+	if (inl(ioaddr + pmctrl) & MAGICPKT, ioaddr + pmctrl)
+		wol->wolopts |= WAKE_MAGIC;
+}
+
 static struct ethtool_ops sis900_ethtool_ops = {
 	.get_drvinfo =		sis900_get_drvinfo,
+	.get_wol =		sis900_get_wol,
+	.set_wol =		sis900_set_wol,	
 };
 
 /**
Index: sis900.h
===================================================================
--- sis900.h	(revision 13)
+++ sis900.h	(working copy)
@@ -140,6 +140,25 @@
 	EEREQ = 0x00000400, EEDONE = 0x00000200, EEGNT = 0x00000100
 };
 
+/* Wake-on-LAN support. */
+enum sis900_power_management_control_register_bits {
+	LINKLOSS  = 0x00000001,
+	LINKON    = 0x00000002,
+	MAGICPKT  = 0x00000400,
+	ALGORITHM = 0x00000800,
+	FRM1EN    = 0x00100000,
+	FRM2EN    = 0x00200000,
+	FRM3EN    = 0x00400000,
+	FRM1ACS   = 0x01000000,
+	FRM2ACS   = 0x02000000,
+	FRM3ACS   = 0x04000000,
+	WAKEALL   = 0x40000000,
+	GATECLK   = 0x80000000
+};
+
+#define CFGPMCSR 0x44
+#define PME_EN 0x100
+
 /* Management Data I/O (mdio) frame */
 #define MIIread         0x6000
 #define MIIwrite        0x5002

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] WOL for sis900
  2004-10-30 19:00   ` Daniele Venzano
@ 2004-10-31 13:08     ` Malte Schröder
  0 siblings, 0 replies; 8+ messages in thread
From: Malte Schröder @ 2004-10-31 13:08 UTC (permalink / raw)
  To: Daniele Venzano; +Cc: NetDev, Jeff Garzik

[-- Attachment #1: Type: text/plain, Size: 1356 bytes --]

Daniele Venzano wrote:
> On Sat, Oct 30, 2004 at 12:13:39PM -0400, Jeff Garzik wrote:
> 
>>Malte Schröder wrote:
>>
>>>Hello,
>>>I have applied the patch from http://lkml.org/lkml/2003/7/16/88 manually 
>>>to 2.6.7 (also works on 2.6.{8,9}) and have been using it since then.
>>>Attached is a diff against 2.6.9.
>>
>>2) Please use ethtool to enable/disable WOL.  No need for a module option.
> 
> 
> Attached is a first try at this wol via ethtool thing. I don't think to
> have got it right, but here it is.
> 
> I tried to test WoL on my laptop, obvioulsy it didn't work, but I don't
> even know if I have the hardware support for it.
> On this page:
> http://www.sis.com/products/connectivity/900.htm
> it says that the magic packet feature is optional.
> 
> I would really like to have some way to check if WoL is supported by the
> hardware before thinking to include this. I didn't find any
> documentation of some use for this.
> 
> Finally, I have never realized the sorry state of sis900 wrt ethtool,
> I'll try to get some more support...
> 
> The attached patch is against clean 2.6.9 and is NOT for inclusion.

I just tried your patch and it works for me :)
My sis900 is on-board component of the sis746 chipset.
-- 
---------------------------------------
Malte Schröder
MalteSch@gmx.de
ICQ# 68121508
---------------------------------------


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 256 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] WOL for sis900
  2004-10-30 15:43 [PATCH] WOL for sis900 Malte Schröder
  2004-10-30 16:13 ` Jeff Garzik
@ 2004-11-10  2:58 ` Rusty Russell
  2004-11-10  5:21   ` Malte Schröder
  2004-11-10 20:40   ` Daniele Venzano
  1 sibling, 2 replies; 8+ messages in thread
From: Rusty Russell @ 2004-11-10  2:58 UTC (permalink / raw)
  To: Malte Schröder; +Cc: linux-kernel

On Sat, 2004-10-30 at 17:43 +0200, Malte Schröder wrote:
> Hello,
> I have applied the patch from http://lkml.org/lkml/2003/7/16/88 manually 
> to 2.6.7 (also works on 2.6.{8,9}) and have been using it since then.
> Attached is a diff against 2.6.9.

Want to change the MODULE_PARM to new-style module_param() calls, too?

Thanks,
Rusty.
-- 
A bad analogy is like a leaky screwdriver -- Richard Braakman


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] WOL for sis900
  2004-11-10  2:58 ` Rusty Russell
@ 2004-11-10  5:21   ` Malte Schröder
  2004-11-10 20:40   ` Daniele Venzano
  1 sibling, 0 replies; 8+ messages in thread
From: Malte Schröder @ 2004-11-10  5:21 UTC (permalink / raw)
  To: Rusty Russell; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 869 bytes --]

Rusty Russell wrote:
> On Sat, 2004-10-30 at 17:43 +0200, Malte Schröder wrote:
> 
>>Hello,
>>I have applied the patch from http://lkml.org/lkml/2003/7/16/88 manually 
>>to 2.6.7 (also works on 2.6.{8,9}) and have been using it since then.
>>Attached is a diff against 2.6.9.
> 
> 
> Want to change the MODULE_PARM to new-style module_param() calls, too?

Since I don't exactly know what this means and currently don't have the 
time to find out I don't think so.
And if WoL should be done using ethtool, my patch should be ignored and 
the one of Daniele Venzano (posted to netdev@oss.sgi.com) should be 
considered.

(Will gather some more background information before posting a patch 
next time ;) )

Greets :)
> 
> Thanks,
> Rusty.


-- 
---------------------------------------
Malte Schröder
MalteSch@gmx.de
ICQ# 68121508
---------------------------------------


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 256 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] WOL for sis900
  2004-11-10  2:58 ` Rusty Russell
  2004-11-10  5:21   ` Malte Schröder
@ 2004-11-10 20:40   ` Daniele Venzano
  2004-11-10 21:24     ` Jeff Garzik
  1 sibling, 1 reply; 8+ messages in thread
From: Daniele Venzano @ 2004-11-10 20:40 UTC (permalink / raw)
  To: Rusty Russell; +Cc: Linux Kernel Mailing List

On Wed, Nov 10, 2004 at 01:58:52PM +1100, Rusty Russell wrote:
> On Sat, 2004-10-30 at 17:43 +0200, Malte Schröder wrote:
> > Hello,
> > I have applied the patch from http://lkml.org/lkml/2003/7/16/88 manually 
> > to 2.6.7 (also works on 2.6.{8,9}) and have been using it since then.
> > Attached is a diff against 2.6.9.
> 
> Want to change the MODULE_PARM to new-style module_param() calls, too?

Just added to the TODO list ;-)
I'm acting as maintainer for the sis900 driver and the list of the TODO
os growing at an awesome speed.

What I'm really lacking is some piece of technical documentation for the
chip. The WoL support depends on this, because I don't know how to check
for the hardware support for it.
For now I'll make available my patch on the sis900 page[1] that uses
ethtool and seems to work.

[1] http://teg.homeunix.org/sis900.html

-- 
-----------------------------
Daniele Venzano
Web: http://teg.homeunix.org


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] WOL for sis900
  2004-11-10 20:40   ` Daniele Venzano
@ 2004-11-10 21:24     ` Jeff Garzik
  0 siblings, 0 replies; 8+ messages in thread
From: Jeff Garzik @ 2004-11-10 21:24 UTC (permalink / raw)
  To: Daniele Venzano; +Cc: Rusty Russell, Linux Kernel Mailing List

Daniele Venzano wrote:
> What I'm really lacking is some piece of technical documentation for the
> chip. The WoL support depends on this, because I don't know how to check
> for the hardware support for it.

The sis900 hardware is based on the NatSemi register layout:
http://gkernel.sourceforge.net/specs/national_semi/DP83815.pdf.bz2


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2004-11-10 21:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-30 15:43 [PATCH] WOL for sis900 Malte Schröder
2004-10-30 16:13 ` Jeff Garzik
2004-10-30 19:00   ` Daniele Venzano
2004-10-31 13:08     ` Malte Schröder
2004-11-10  2:58 ` Rusty Russell
2004-11-10  5:21   ` Malte Schröder
2004-11-10 20:40   ` Daniele Venzano
2004-11-10 21:24     ` Jeff Garzik

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.