Skip to contentSkip to conversation

SMC911x driver fixed for NFS boot

PATCH New Manikandan Pillai 5 participants 10 messages Apr 8, 2009 – Jul 10, 2009 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 SMC911x driver fixed for NFS boot

eth_halt() function in the smc911x drivers used to call the smc911x_reset() function. eth_halt() used to be called after tftp transfers. This used to put the ethernet chip in reset while the linux boots up resulting in the ethernet driver not coming up. NFS boot used to fail as a result.

This patch calls smc911x_shutdown() instead of smc911x_reset(). Some comments received has also been fixed.

---
 drivers/net/smc911x.c |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)
drivers/net/smc911x.c +22 -1
index 1ded8f0..5bc3914 100644
@@ -116,6 +116,27 @@ static int smc911x_phy_reset(void)
 	return 0;
 }
 
+static void smc911x_shutdown(void)
+{
+	unsigned int cr;
+
+	/* Turn of Rx and TX */
+	cr = smc911x_get_mac_csr(MAC_CR);
+	cr &= ~(MAC_CR_TXEN | MAC_CR_RXEN | MAC_CR_HBDIS);
+	smc911x_set_mac_csr(MAC_CR, cr);
+
+	/* Stop Transmission */
+	cr = smc911x_get_mac_csr(TX_CFG);
+	cr &= ~(TX_CFG_STOP_TX);
+	smc911x_set_mac_csr(TX_CFG, cr);
+	/* Stop receiving packets */
+	cr = smc911x_get_mac_csr(RX_CFG);
+	cr &= ~(RX_CFG_RXDOFF);
+	smc911x_set_mac_csr(RX_CFG, cr);
+
+}
+
+
 static void smc911x_phy_configure(void)
 {
 	int timeout;
@@ -224,7 +245,7 @@ int eth_send(volatile void *packet, int length)
 
 void eth_halt(void)
 {
-	smc911x_reset();
+	smc911x_shutdown();
 }
 
 int eth_rx(void)
Signature · 1 line
1.6.0.3
#1 lore raw

PATCH 1/1 SMC911x driver fixed for NFS boot

Dear Ben,

Quoted 6 lines · In message <[email protected]> Manikandan…

eth_halt() function in the smc911x drivers used to call the smc911x_reset() function. eth_halt() used to be called after tftp transfers. This used to put the ethernet chip in reset while the linux boots up resulting in the ethernet driver not coming up. NFS boot used to fail as a result.

Quoted 7 lines

This patch calls smc911x_shutdown() instead of smc911x_reset(). Some comments received has also been fixed.

---
 drivers/net/smc911x.c |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)

Any comments on this patch?

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"I haven't lost my mind - it's backed up on tape somewhere."
#2 lore raw

PATCH 1/1 SMC911x driver fixed for NFS boot

Quoted 13 lines · Wolfgang Denk

Dear Ben,

Quoted 9 lines · In message <[email protected]> Manikandan…

eth_halt() function in the smc911x drivers used to call the smc911x_reset() function. eth_halt() used to be called after tftp transfers. This used to put the ethernet chip in reset while the linux boots up resulting in the ethernet driver not coming up. NFS boot used to fail as a result.

This patch calls smc911x_shutdown() instead of smc911x_reset(). Some comments received has also been fixed.

Quoted 9 lines
Quoted 5 lines
---
 drivers/net/smc911x.c |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)

Any comments on this patch?

It's on my list of patches to pull into next.

regards,
Ben

#3 lore raw

PATCH 1/1 SMC911x driver fixed for NFS boot

In reply to Manikandan Pillai

Dear Manikandan Pillai,

Quoted 8 lines · In message <[email protected]> you wrote:

eth_halt() function in the smc911x drivers used to call the smc911x_reset() function. eth_halt() used to be called after tftp transfers. This used to put the ethernet chip in reset while the linux boots up resulting in the ethernet driver not coming up. NFS boot used to fail as a result.

This patch calls smc911x_shutdown() instead of smc911x_reset(). Some comments received has also been fixed.

This patch (commit ID ca9c8a1e in the master branch) causes compile warnings on all systems that use this driver, for example:

+ ./MAKEALL imx31_litekit
Configuring for imx31_litekit board...
smc911x.c: In function 'smc911x_shutdown':
smc911x.c:130: warning: large integer implicitly truncated to unsigned type smc911x.c:132: warning: large integer implicitly truncated to unsigned type smc911x.c:134: warning: large integer implicitly truncated to unsigned type smc911x.c:136: warning: large integer implicitly truncated to unsigned type
text data bss dec hex filename
114556 5228 24584 144368 233f0 /work/wd/tmp-arm/u-boot

The problem seems to come from this part of the code:

Quoted 7 lines
drivers/net/smc911x.c +7 -0
+static void smc911x_shutdown(void)
+{
+	unsigned int cr;
+
+	/* Turn of Rx and TX */
+	cr = smc911x_get_mac_csr(MAC_CR);
+	cr &= ~(MAC_CR_TXEN | MAC_CR_RXEN | MAC_CR_HBDIS);

drivers/net/smc911x.c static int smc911x_phy_reset(void) · line 135

Quoted 10 lines
drivers/net/smc911x.c +10 -0
+	smc911x_set_mac_csr(MAC_CR, cr);
+
+	/* Stop Transmission */
+	cr = smc911x_get_mac_csr(TX_CFG);
+	cr &= ~(TX_CFG_STOP_TX);
+	smc911x_set_mac_csr(TX_CFG, cr);
+	/* Stop receiving packets */
+	cr = smc911x_get_mac_csr(RX_CFG);
+	cr &= ~(RX_CFG_RXDOFF);
+	smc911x_set_mac_csr(RX_CFG, cr);

wher eyou ar epssing long constants (TX_CFG, RX_CFG) into smc911x_set_mac_csr(), but smc911x_set_mac_csr() is declared in "drivers/net/smc911x.h" to take an "unsigned character" argument only:

	static u32 smc911x_get_mac_csr(u8 reg)

Please check what's wrong.

Please either provide a fix, or I will have to consider to revert this patch for the upcoming release.

Thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"He was so narrow minded he could see through  a  keyhole  with  both
eyes ..."
#4 lore raw

PATCH 1/1 SMC911x driver fixed for NFS boot

Dear Manikandan Pillai,

Quoted 1 line · In message <[email protected]> I wrote:

...

Quoted 2 lines

This patch (commit ID ca9c8a1e in the master branch) causes compile warnings on all systems that use this driver, for example:

...

Quoted 2 lines

Please either provide a fix, or I will have to consider to revert this patch for the upcoming release.

Please respond urgently. Otherwise I will have to revert this patch.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Anything that is worth doing at all is worth doing well.
                                       -- Philip Earl of Chesterfield
#5 lore raw

PATCH 1/1 SMC911x driver fixed for NFS boot

Quoted 4 lines · Wolfgang Denk

Dear Manikandan Pillai,

Quoted 1 line · In message <[email protected]> I wrote:
Quoted 8 lines

...

Quoted 2 lines

This patch (commit ID ca9c8a1e in the master branch) causes compile warnings on all systems that use this driver, for example:

...

Quoted 2 lines

Please either provide a fix, or I will have to consider to revert this patch for the upcoming release.

Please respond urgently. Otherwise I will have to revert this patch.

the following fix this and a function implementation location

as I've no board with me currently with a smc911x I can not test it

but it's normaly work

Best Regards,
J.

#6 lore raw

PATCH 1/2 smc911x: fix warning: large integer implicitly truncated to unsigned type

use smc911x_reg_read/smc911x_reg_write instead of
smc911x_get_mac_csr/smc911x_set_mac_csr

---
 drivers/net/smc911x.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
drivers/net/smc911x.c +5 -5
index 455b055..0507a9a 100644
@@ -119,7 +119,7 @@ static int smc911x_phy_reset(void)
 
 static void smc911x_shutdown(void)
 {
-	unsigned int cr;
+	u32 cr;
 
 	/* Turn of Rx and TX */
 	cr = smc911x_get_mac_csr(MAC_CR);
@@ -127,13 +127,13 @@ static void smc911x_shutdown(void)
 	smc911x_set_mac_csr(MAC_CR, cr);
 
 	/* Stop Transmission */
-	cr = smc911x_get_mac_csr(TX_CFG);
+	cr = smc911x_reg_read(TX_CFG);
 	cr &= ~(TX_CFG_STOP_TX);
-	smc911x_set_mac_csr(TX_CFG, cr);
+	smc911x_reg_write(TX_CFG, cr);
 	/* Stop receiving packets */
-	cr = smc911x_get_mac_csr(RX_CFG);
+	cr = smc911x_reg_read(RX_CFG);
 	cr &= ~(RX_CFG_RXDOFF);
-	smc911x_set_mac_csr(RX_CFG, cr);
+	smc911x_reg_write(RX_CFG, cr);
 
 }
 
Signature · 1 line
1.6.3.1
#7 lore raw

PATCH 2/2 smc911x: move function implementation for header to c

---
 drivers/net/smc911x.c |   87 ++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/smc911x.h |   88 -------------------------------------------------
 2 files changed, 87 insertions(+), 88 deletions(-)
drivers/net/smc911x.c +87 -0
index 0507a9a..0b63676 100644
@@ -36,6 +36,93 @@ void pkt_data_push(u32 addr, u32 val) \
 
 #define mdelay(n)       udelay((n)*1000)
 
+static u32 smc911x_get_mac_csr(u8 reg)
+{
+	while (smc911x_reg_read(MAC_CSR_CMD) & MAC_CSR_CMD_CSR_BUSY)
+		;
+	smc911x_reg_write(MAC_CSR_CMD, MAC_CSR_CMD_CSR_BUSY | MAC_CSR_CMD_R_NOT_W | reg);
+	while (smc911x_reg_read(MAC_CSR_CMD) & MAC_CSR_CMD_CSR_BUSY)
+		;
+
+	return smc911x_reg_read(MAC_CSR_DATA);
+}
+
+static void smc911x_set_mac_csr(u8 reg, u32 data)
+{
+	while (smc911x_reg_read(MAC_CSR_CMD) & MAC_CSR_CMD_CSR_BUSY)
+		;
+	smc911x_reg_write(MAC_CSR_DATA, data);
+	smc911x_reg_write(MAC_CSR_CMD, MAC_CSR_CMD_CSR_BUSY | reg);
+	while (smc911x_reg_read(MAC_CSR_CMD) & MAC_CSR_CMD_CSR_BUSY)
+		;
+}
+
+static int smc911x_detect_chip(void)
+{
+	unsigned long val, i;
+
+	val = smc911x_reg_read(BYTE_TEST);
+	if (val != 0x87654321) {
+		printf(DRIVERNAME ": Invalid chip endian 0x%08lx\n", val);
+		return -1;
+	}
+
+	val = smc911x_reg_read(ID_REV) >> 16;
+	for (i = 0; chip_ids[i].id != 0; i++) {
+		if (chip_ids[i].id == val) break;
+	}
+	if (!chip_ids[i].id) {
+		printf(DRIVERNAME ": Unknown chip ID %04lx\n", val);
+		return -1;
+	}
+
+	printf(DRIVERNAME ": detected %s controller\n", chip_ids[i].name);
+
+	return 0;
+}
+
+static void smc911x_reset(void)
+{
+	int timeout;
+
+	/* Take out of PM setting first */
+	if (smc911x_reg_read(PMT_CTRL) & PMT_CTRL_READY) {
+		/* Write to the bytetest will take out of powerdown */
+		smc911x_reg_write(BYTE_TEST, 0x0);
+
+		timeout = 10;
+
+		while (timeout-- && !(smc911x_reg_read(PMT_CTRL) & PMT_CTRL_READY))
+			udelay(10);
+		if (!timeout) {
+			printf(DRIVERNAME
+				": timeout waiting for PM restore\n");
+			return;
+		}
+	}
+
+	/* Disable interrupts */
+	smc911x_reg_write(INT_EN, 0);
+
+	smc911x_reg_write(HW_CFG, HW_CFG_SRST);
+
+	timeout = 1000;
+	while (timeout-- && smc911x_reg_read(E2P_CMD) & E2P_CMD_EPC_BUSY)
+		udelay(10);
+
+	if (!timeout) {
+		printf(DRIVERNAME ": reset timeout\n");
+		return;
+	}
+
+	/* Reset the FIFO level and flow control settings */
+	smc911x_set_mac_csr(FLOW, FLOW_FCPT | FLOW_FCEN);
+	smc911x_reg_write(AFC_CFG, 0x0050287F);
+
+	/* Set to LED outputs */
+	smc911x_reg_write(GPIO_CFG, 0x70070000);
+}
+
 static int smx911x_handle_mac_address(bd_t *bd)
 {
 	unsigned long addrh, addrl;
drivers/net/smc911x.h +0 -88

94 lines not on this page · raw message

Signature · 1 line
1.6.3.1
#9 lore raw

PATCH 1/2 smc911x: fix warning: large integer implicitly truncated to unsigned type

In reply to Jean-Christophe PLAGNIOL-VILLARD
Quoted 30 lines · Jean-Christophe PLAGNIOL-VILLARD

use smc911x_reg_read/smc911x_reg_write instead of
smc911x_get_mac_csr/smc911x_set_mac_csr

---
 drivers/net/smc911x.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
drivers/net/smc911x.c +2 -3
index 455b055..0507a9a 100644
@@ -119,7 +119,7 @@ static int smc911x_phy_reset(void)
 
 static void smc911x_shutdown(void)
 {
-	unsigned int cr;
+	u32 cr;
 
 	/* Turn of Rx and TX */
 	cr = smc911x_get_mac_csr(MAC_CR);
@@ -127,13 +127,13 @@ static void smc911x_shutdown(void)
 	smc911x_set_mac_csr(MAC_CR, cr);
 
 	/* Stop Transmission */
-	cr = smc911x_get_mac_csr(TX_CFG);
+	cr = smc911x_reg_read(TX_CFG);
 	cr &= ~(TX_CFG_STOP_TX);
-	smc911x_set_mac_csr(TX_CFG, cr);

drivers/net/smc911x.c static void smc911x_shutdown(void) · line 139

Quoted 10 lines
drivers/net/smc911x.c +3 -2
+	smc911x_reg_write(TX_CFG, cr);
 	/* Stop receiving packets */
-	cr = smc911x_get_mac_csr(RX_CFG);
+	cr = smc911x_reg_read(RX_CFG);
 	cr &= ~(RX_CFG_RXDOFF);
-	smc911x_set_mac_csr(RX_CFG, cr);
+	smc911x_reg_write(RX_CFG, cr);
 
 }
 

This patch doesn't apply (there's no function 'smc911x_shutdown()' in either mainline or the net tree.

regards,
Ben