KS8851 updates for -rc5
Subsystems (2)
cover 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.
PATCH 1/3 KS8851: Add soft reset at probe time
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.
--- drivers/net/ks8851.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ks8851.c +3 -0
@@ -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 ) {
PATCH 2/3 KS8851: Fix MAC address write order
In reply to Ben DooksThe 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.
--- drivers/net/ks8851.c | 39 ++++++++++++++++++++++++++++++++++----- drivers/net/ks8851.h | 1 + 2 files changed, 35 insertions(+), 5 deletions(-)
drivers/net/ks8851.c +33 -4
@@ -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 ks8static 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);
drivers/net/ks8851.h +1 -0
@@ -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
PATCH 3/3 KS8851: Fix ks8851_set_rx_mode() for IFF_MULTICAST
In reply to Ben DooksIn 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.
--- drivers/net/ks8851.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ks8851.c +1 -1
@@ -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 ;
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:[email protected]]
Sent: Tuesday, October 20, 2009 2:49 AM
To: [email protected]
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.
Quoted 4 lines · Ping
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.
Signature · 3 lines
Ben Dooks, Software Engineer, Simtec Electronics http://www.simtec.co.uk/
David Miller
maintainerFrom: Ben Dooks <[email protected]>
Date: Tue, 20 Oct 2009 23:26:30 +0100
Quoted 10 lines
Quoted 4 lines · Ping
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.
David Miller
maintainerFrom: David Miller <[email protected]>
Date: Tue, 20 Oct 2009 19:11:42 -0700 (PDT)
Quoted 9 lines
From: Ben Dooks <[email protected]>
Date: Tue, 20 Oct 2009 23:26:30 +0100Quoted 6 lines
Quoted 4 lines · Ping
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.
Quoted 6 lines
Quoted 4 lines
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'
Quoted 6 lines · David Miller
From: David Miller <[email protected]>
Date: Tue, 20 Oct 2009 19:11:42 -0700 (PDT)Quoted 1 line
All applied to net-next-2.6, thanks.
Sorry, I meant 'net-2.6'
thanks.