netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch 0/3] KS8851 updates for -rc5
@ 2009-10-20  9:49 Ben Dooks
  2009-10-20  9:49 ` [patch 1/3] KS8851: Add soft reset at probe time Ben Dooks
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Ben Dooks @ 2009-10-20  9:49 UTC (permalink / raw)
  To: netdev; +Cc: Ping.Doong

Patches for some minor problems with the KS8851 SPI network driver
for inclusion into the kernel. This set is based on -rc5.

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

* [patch 1/3] KS8851: Add soft reset at probe time
  2009-10-20  9:49 [patch 0/3] KS8851 updates for -rc5 Ben Dooks
@ 2009-10-20  9:49 ` Ben Dooks
  2009-10-20  9:49 ` [patch 2/3] KS8851: Fix MAC address write order Ben Dooks
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Ben Dooks @ 2009-10-20  9:49 UTC (permalink / raw)
  To: netdev; +Cc: Ping.Doong

[-- Attachment #1: ks8851-reset-at-probe.patch --]
[-- Type: text/plain, Size: 984 bytes --]

Issue a full soft reset at probe time.

This was reported by Doong Ping of Micrel, but no explanation of why this
is necessary or what bug it is fixing. Add it as it does not seem to hurt
the current driver and ensures that the device is in a known state when we
start setting it up.

Signed-off-by: Ben Dooks <ben@simtec.co.uk>

---
 drivers/net/ks8851.c |    3 +++
 1 file changed, 3 insertions(+)

Index: b/drivers/net/ks8851.c
===================================================================
--- a/drivers/net/ks8851.c	2009-10-12 23:04:15.000000000 +0100
+++ b/drivers/net/ks8851.c	2009-10-13 13:28:43.000000000 +0100
@@ -1239,6 +1239,9 @@ static int __devinit ks8851_probe(struct
 	ndev->netdev_ops = &ks8851_netdev_ops;
 	ndev->irq = spi->irq;
 
+	/* issue a global soft reset to reset the device. */
+	ks8851_soft_reset(ks, GRR_GSR);
+
 	/* simple check for a valid chip being connected to the bus */
 
 	if ((ks8851_rdreg16(ks, KS_CIDER) & ~CIDER_REV_MASK) != CIDER_ID) {


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

* [patch 2/3] KS8851: Fix MAC address write order
  2009-10-20  9:49 [patch 0/3] KS8851 updates for -rc5 Ben Dooks
  2009-10-20  9:49 ` [patch 1/3] KS8851: Add soft reset at probe time Ben Dooks
@ 2009-10-20  9:49 ` Ben Dooks
  2009-10-20  9:49 ` [patch 3/3] KS8851: Fix ks8851_set_rx_mode() for IFF_MULTICAST Ben Dooks
  2009-10-20 17:53 ` [patch 0/3] KS8851 updates for -rc5 Doong, Ping
  3 siblings, 0 replies; 9+ messages in thread
From: Ben Dooks @ 2009-10-20  9:49 UTC (permalink / raw)
  To: netdev; +Cc: Ping.Doong

[-- Attachment #1: ks8851-fix-mac-order.patch --]
[-- Type: text/plain, Size: 2490 bytes --]

The MAC address register was being written in the wrong order, so add
a new address macro to convert mac-address byte to register address and
a ks8851_wrreg8() function to write each byte without having to worry
about any difficult byte swapping.

Fixes a bug reported by Doong, Ping of Micrel.

Signed-off-by: Ben Dooks <ben@simtec.co.uk>

---
 drivers/net/ks8851.c |   39 ++++++++++++++++++++++++++++++++++-----
 drivers/net/ks8851.h |    1 +
 2 files changed, 35 insertions(+), 5 deletions(-)

Index: b/drivers/net/ks8851.c
===================================================================
--- a/drivers/net/ks8851.c	2009-10-06 14:25:53.000000000 +0100
+++ b/drivers/net/ks8851.c	2009-10-06 14:42:39.000000000 +0100
@@ -171,6 +171,36 @@ static void ks8851_wrreg16(struct ks8851
 }
 
 /**
+ * ks8851_wrreg8 - write 8bit register value to chip
+ * @ks: The chip state
+ * @reg: The register address
+ * @val: The value to write
+ *
+ * Issue a write to put the value @val into the register specified in @reg.
+ */
+static void ks8851_wrreg8(struct ks8851_net *ks, unsigned reg, unsigned val)
+{
+	struct spi_transfer *xfer = &ks->spi_xfer1;
+	struct spi_message *msg = &ks->spi_msg1;
+	__le16 txb[2];
+	int ret;
+	int bit;
+
+	bit = 1 << (reg & 3);
+
+	txb[0] = cpu_to_le16(MK_OP(bit, reg) | KS_SPIOP_WR);
+	txb[1] = val;
+
+	xfer->tx_buf = txb;
+	xfer->rx_buf = NULL;
+	xfer->len = 3;
+
+	ret = spi_sync(ks->spidev, msg);
+	if (ret < 0)
+		ks_err(ks, "spi_sync() failed\n");
+}
+
+/**
  * ks8851_rx_1msg - select whether to use one or two messages for spi read
  * @ks: The device structure
  *
@@ -322,13 +352,12 @@ static void ks8851_soft_reset(struct ks8
 static int ks8851_write_mac_addr(struct net_device *dev)
 {
 	struct ks8851_net *ks = netdev_priv(dev);
-	u16 *mcp = (u16 *)dev->dev_addr;
+	int i;
 
 	mutex_lock(&ks->lock);
 
-	ks8851_wrreg16(ks, KS_MARL, mcp[0]);
-	ks8851_wrreg16(ks, KS_MARM, mcp[1]);
-	ks8851_wrreg16(ks, KS_MARH, mcp[2]);
+	for (i = 0; i < ETH_ALEN; i++)
+		ks8851_wrreg8(ks, KS_MAR(i), dev->dev_addr[i]);
 
 	mutex_unlock(&ks->lock);
 
Index: b/drivers/net/ks8851.h
===================================================================
--- a/drivers/net/ks8851.h	2009-10-06 14:34:32.000000000 +0100
+++ b/drivers/net/ks8851.h	2009-10-06 14:35:08.000000000 +0100
@@ -16,6 +16,7 @@
 #define CCR_32PIN				(1 << 0)
 
 /* MAC address registers */
+#define KS_MAR(_m)				0x15 - (_m)
 #define KS_MARL					0x10
 #define KS_MARM					0x12
 #define KS_MARH					0x14


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

* [patch 3/3] KS8851: Fix ks8851_set_rx_mode() for IFF_MULTICAST
  2009-10-20  9:49 [patch 0/3] KS8851 updates for -rc5 Ben Dooks
  2009-10-20  9:49 ` [patch 1/3] KS8851: Add soft reset at probe time Ben Dooks
  2009-10-20  9:49 ` [patch 2/3] KS8851: Fix MAC address write order Ben Dooks
@ 2009-10-20  9:49 ` Ben Dooks
  2009-10-20 17:53 ` [patch 0/3] KS8851 updates for -rc5 Doong, Ping
  3 siblings, 0 replies; 9+ messages in thread
From: Ben Dooks @ 2009-10-20  9:49 UTC (permalink / raw)
  To: netdev; +Cc: Ping.Doong

[-- Attachment #1: ks8851-fix-mc-rxmode.patch --]
[-- Type: text/plain, Size: 1096 bytes --]

In ks8851_set_rx_mode() the case handling IFF_MULTICAST was also setting
the RXCR1_AE bit by accident. This meant that all unicast frames where
being accepted by the device. Remove RXCR1_AE from this case.

Note, RXCR1_AE was also masking a problem with setting the MAC address
properly, so needs to be applied after fixing the MAC write order.

Fixes a bug reported by Doong, Ping of Micrel. This version of the
patch avoids setting RXCR1_ME for all cases.

Signed-off-by: Ben Dooks <ben@simtec.co.uk>

---
 drivers/net/ks8851.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: b/drivers/net/ks8851.c
===================================================================
--- a/drivers/net/ks8851.c	2009-10-13 13:28:50.000000000 +0100
+++ b/drivers/net/ks8851.c	2009-10-13 13:28:51.000000000 +0100
@@ -980,7 +980,7 @@ static void ks8851_set_rx_mode(struct ne
 			mcptr = mcptr->next;
 		}
 
-		rxctrl.rxcr1 = RXCR1_RXME | RXCR1_RXAE | RXCR1_RXPAFMA;
+		rxctrl.rxcr1 = RXCR1_RXME | RXCR1_RXPAFMA;
 	} else {
 		/* just accept broadcast / unicast */
 		rxctrl.rxcr1 = RXCR1_RXPAFMA;


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

* RE: [patch 0/3] KS8851 updates for -rc5
  2009-10-20  9:49 [patch 0/3] KS8851 updates for -rc5 Ben Dooks
                   ` (2 preceding siblings ...)
  2009-10-20  9:49 ` [patch 3/3] KS8851: Fix ks8851_set_rx_mode() for IFF_MULTICAST Ben Dooks
@ 2009-10-20 17:53 ` Doong, Ping
  2009-10-20 22:26   ` Ben Dooks
  3 siblings, 1 reply; 9+ messages in thread
From: Doong, Ping @ 2009-10-20 17:53 UTC (permalink / raw)
  To: Ben Dooks, netdev; +Cc: Li, Charles

Hi Ben,

I'm sorry. I am busy on other project, and have got the change to verify
your new patch on our side. I will do it soon.

Thank you,
Ping

-----Original Message-----
From: Ben Dooks [mailto:ben@simtec.co.uk] 
Sent: Tuesday, October 20, 2009 2:49 AM
To: netdev@vger.kernel.org
Cc: Doong, Ping
Subject: [patch 0/3] KS8851 updates for -rc5

Patches for some minor problems with the KS8851 SPI network driver
for inclusion into the kernel. This set is based on -rc5.

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

* Re: [patch 0/3] KS8851 updates for -rc5
  2009-10-20 17:53 ` [patch 0/3] KS8851 updates for -rc5 Doong, Ping
@ 2009-10-20 22:26   ` Ben Dooks
  2009-10-21  2:11     ` David Miller
  0 siblings, 1 reply; 9+ messages in thread
From: Ben Dooks @ 2009-10-20 22:26 UTC (permalink / raw)
  To: Doong, Ping; +Cc: netdev, Li, Charles

Doong, Ping wrote:
> Hi Ben,
> 
> I'm sorry. I am busy on other project, and have got the change to verify
> your new patch on our side. I will do it soon.

 From testing, these verify for me now that I've seen the
issues for myself. I belive they're ready for merging so
unless Dave (or someone else) objects, then I'd like to
see them in as soon as possible.

Thanks for the bug reports.

-- 
Ben Dooks, Software Engineer, Simtec Electronics

http://www.simtec.co.uk/

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

* Re: [patch 0/3] KS8851 updates for -rc5
  2009-10-20 22:26   ` Ben Dooks
@ 2009-10-21  2:11     ` David Miller
  2009-10-21  2:12       ` David Miller
  0 siblings, 1 reply; 9+ messages in thread
From: David Miller @ 2009-10-21  2:11 UTC (permalink / raw)
  To: ben; +Cc: Ping.Doong, netdev, Charles.Li

From: Ben Dooks <ben@simtec.co.uk>
Date: Tue, 20 Oct 2009 23:26:30 +0100

> Doong, Ping wrote:
>> Hi Ben,
>> I'm sorry. I am busy on other project, and have got the change to
>> verify
>> your new patch on our side. I will do it soon.
> 
> From testing, these verify for me now that I've seen the
> issues for myself. I belive they're ready for merging so
> unless Dave (or someone else) objects, then I'd like to
> see them in as soon as possible.

All applied to net-next-2.6, thanks.

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

* Re: [patch 0/3] KS8851 updates for -rc5
  2009-10-21  2:11     ` David Miller
@ 2009-10-21  2:12       ` David Miller
  2009-10-21 10:44         ` Ben Dooks
  0 siblings, 1 reply; 9+ messages in thread
From: David Miller @ 2009-10-21  2:12 UTC (permalink / raw)
  To: ben; +Cc: Ping.Doong, netdev, Charles.Li

From: David Miller <davem@davemloft.net>
Date: Tue, 20 Oct 2009 19:11:42 -0700 (PDT)

> From: Ben Dooks <ben@simtec.co.uk>
> Date: Tue, 20 Oct 2009 23:26:30 +0100
> 
>> Doong, Ping wrote:
>>> Hi Ben,
>>> I'm sorry. I am busy on other project, and have got the change to
>>> verify
>>> your new patch on our side. I will do it soon.
>> 
>> From testing, these verify for me now that I've seen the
>> issues for myself. I belive they're ready for merging so
>> unless Dave (or someone else) objects, then I'd like to
>> see them in as soon as possible.
> 
> All applied to net-next-2.6, thanks.

Sorry, I meant 'net-2.6'

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

* Re: [patch 0/3] KS8851 updates for -rc5
  2009-10-21  2:12       ` David Miller
@ 2009-10-21 10:44         ` Ben Dooks
  0 siblings, 0 replies; 9+ messages in thread
From: Ben Dooks @ 2009-10-21 10:44 UTC (permalink / raw)
  To: David Miller; +Cc: ben, Ping.Doong, netdev, Charles.Li

On Tue, Oct 20, 2009 at 07:12:04PM -0700, David Miller wrote:
> From: David Miller <davem@davemloft.net>
> Date: Tue, 20 Oct 2009 19:11:42 -0700 (PDT)

> > All applied to net-next-2.6, thanks.
> 
> Sorry, I meant 'net-2.6'

thanks.

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

end of thread, other threads:[~2009-10-21 10:44 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-20  9:49 [patch 0/3] KS8851 updates for -rc5 Ben Dooks
2009-10-20  9:49 ` [patch 1/3] KS8851: Add soft reset at probe time Ben Dooks
2009-10-20  9:49 ` [patch 2/3] KS8851: Fix MAC address write order Ben Dooks
2009-10-20  9:49 ` [patch 3/3] KS8851: Fix ks8851_set_rx_mode() for IFF_MULTICAST Ben Dooks
2009-10-20 17:53 ` [patch 0/3] KS8851 updates for -rc5 Doong, Ping
2009-10-20 22:26   ` Ben Dooks
2009-10-21  2:11     ` David Miller
2009-10-21  2:12       ` David Miller
2009-10-21 10:44         ` Ben Dooks

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).