Skip to contentSkip to conversation

smsc911x: add fifo byteswap support V2

PATCH Applied Magnus Damm 3 participants 3 messages Apr 28, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 smsc911x: add fifo byteswap support V2

From: Magnus Damm <[email protected]>

This is V2 of the smsc911x fifo byteswap patch.

The smsc911x hardware supports both big and little and endian hardware configurations, and the linux smsc911x driver currently detects word order.

For correct operation on big endian platforms lacking swapped byte lanes the following patch is needed. Only fifo data is swapped, register data does not require any swapping.

---

Changes since V1:
- Added SMSC911X_SWAP_FIFO comment to header file, thanks Steve!

Platform data for the rsk7203 board will be posted separately to the linux-sh list in the near future.

 drivers/net/smsc911x.c   |   13 +++++++++++++
 include/linux/smsc911x.h |   10 ++++++++++
 2 files changed, 23 insertions(+)
drivers/net/smsc911x.c +13 -0
@@ -47,6 +47,7 @@
 #include <linux/bitops.h>
 #include <linux/irq.h>
 #include <linux/io.h>
+#include <linux/swab.h>
 #include <linux/phy.h>
 #include <linux/smsc911x.h>
 #include "smsc911x.h"
@@ -175,6 +176,12 @@ static inline void
 smsc911x_tx_writefifo(struct smsc911x_data *pdata, unsigned int *buf,
 		      unsigned int wordcount)
 {
+	if (pdata->config.flags & SMSC911X_SWAP_FIFO) {
+		while (wordcount--)
+			smsc911x_reg_write(pdata, TX_DATA_FIFO, swab32(*buf++));
+		return;
+	}
+
 	if (pdata->config.flags & SMSC911X_USE_32BIT) {
 		writesl(pdata->ioaddr + TX_DATA_FIFO, buf, wordcount);
 		return;
@@ -194,6 +201,12 @@ static inline void
 smsc911x_rx_readfifo(struct smsc911x_data *pdata, unsigned int *buf,
 		     unsigned int wordcount)
 {
+	if (pdata->config.flags & SMSC911X_SWAP_FIFO) {
+		while (wordcount--)
+			*buf++ = swab32(smsc911x_reg_read(pdata, RX_DATA_FIFO));
+		return;
+	}
+
 	if (pdata->config.flags & SMSC911X_USE_32BIT) {
 		readsl(pdata->ioaddr + RX_DATA_FIFO, buf, wordcount);
 		return;
include/linux/smsc911x.h +10 -0
@@ -47,4 +47,14 @@ struct smsc911x_platform_config {
 #define SMSC911X_FORCE_EXTERNAL_PHY 		(BIT(3))
 #define SMSC911X_SAVE_MAC_ADDRESS		(BIT(4))
 
+/*
+ * SMSC911X_SWAP_FIFO:
+ * Enables software byte swap for fifo data. Should only be used as a
+ * "last resort" in the case of big endian mode on boards with incorrectly
+ * routed data bus to older devices such as LAN9118. Newer devices such as
+ * LAN9221 can handle this in hardware, there are registers to control
+ * this swapping but the driver doesn't currently use them.
+ */
+#define SMSC911X_SWAP_FIFO			(BIT(5))
+
 #endif /* __LINUX_SMSC911X_H__ */
Acked-by on v1 1/1
#1 lore raw

Magnus Damm <[email protected]> wrote on 28/04/2009 08:32:16:

Quoted 8 lines

From: Magnus Damm <[email protected]>

This is V2 of the smsc911x fifo byteswap patch.

The smsc911x hardware supports both big and little and endian hardware configurations, and the linux smsc911x driver currently detects word order.

Quoted 6 lines

For correct operation on big endian platforms lacking swapped byte lanes the following patch is needed. Only fifo data is swapped, register data does not require any swapping.

---

maintainer Applied
#2 lore raw

From: [email protected]
Date: Tue, 28 Apr 2009 09:21:42 +0100

Quoted 10 lines

Magnus Damm <[email protected]> wrote on 28/04/2009 08:32:16:

Quoted 8 lines

From: Magnus Damm <[email protected]>

This is V2 of the smsc911x fifo byteswap patch.

The smsc911x hardware supports both big and little and endian hardware configurations, and the linux smsc911x driver currently detects word order.

Quoted 8 lines
Quoted 6 lines

For correct operation on big endian platforms lacking swapped byte lanes the following patch is needed. Only fifo data is swapped, register data does not require any swapping.

---

Applied.