[U-Boot] [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.
Signed-off-by: Manikandan Pillai mani.pillai@ti.com --- drivers/net/smc911x.c | 23 ++++++++++++++++++++++- 1 files changed, 22 insertions(+), 1 deletions(-)
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c index 1ded8f0..5bc3914 100644 --- a/drivers/net/smc911x.c +++ b/drivers/net/smc911x.c @@ -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)

Dear Ben,
In message 1239162275-13087-1-git-send-email-mani.pillai@ti.com Manikandan Pillai 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.
Signed-off-by: Manikandan Pillai mani.pillai@ti.com
drivers/net/smc911x.c | 23 ++++++++++++++++++++++- 1 files changed, 22 insertions(+), 1 deletions(-)
Any comments on this patch?
Best regards,
Wolfgang Denk

Wolfgang Denk wrote:
Dear Ben,
In message 1239162275-13087-1-git-send-email-mani.pillai@ti.com Manikandan Pillai 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.
Signed-off-by: Manikandan Pillai mani.pillai@ti.com
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

Dear Manikandan Pillai,
In message 1239162275-13087-1-git-send-email-mani.pillai@ti.com 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:
+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);
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

Dear Manikandan Pillai,
In message 20090609220854.A1377832E416@gemini.denx.de I wrote:
...
This patch (commit ID ca9c8a1e in the master branch) causes compile warnings on all systems that use this driver, for example:
...
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

On 23:04 Fri 12 Jun , Wolfgang Denk wrote:
Dear Manikandan Pillai,
In message 20090609220854.A1377832E416@gemini.denx.de I wrote:
...
This patch (commit ID ca9c8a1e in the master branch) causes compile warnings on all systems that use this driver, for example:
...
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.

use smc911x_reg_read/smc911x_reg_write instead of smc911x_get_mac_csr/smc911x_set_mac_csr
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagnioj@jcrosoft.com --- drivers/net/smc911x.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c index 455b055..0507a9a 100644 --- a/drivers/net/smc911x.c +++ b/drivers/net/smc911x.c @@ -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);
}

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagnioj@jcrosoft.com --- drivers/net/smc911x.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++++ drivers/net/smc911x.h | 88 ------------------------------------------------- 2 files changed, 87 insertions(+), 88 deletions(-)
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c index 0507a9a..0b63676 100644 --- a/drivers/net/smc911x.c +++ b/drivers/net/smc911x.c @@ -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; diff --git a/drivers/net/smc911x.h b/drivers/net/smc911x.h index 80d2ce0..9176448 100644 --- a/drivers/net/smc911x.h +++ b/drivers/net/smc911x.h @@ -401,94 +401,6 @@ static const struct chip_id chip_ids[] = { { 0, NULL }, };
- #define DRIVERNAME "smc911x"
-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); -} - #endif

uhh, NACK -- changelog/comment as to why you're doing this and you just broke the smc911x_eeprom -mike

Jean-Christophe PLAGNIOL-VILLARD wrote:
use smc911x_reg_read/smc911x_reg_write instead of smc911x_get_mac_csr/smc911x_set_mac_csr
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagnioj@jcrosoft.com
drivers/net/smc911x.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c index 455b055..0507a9a 100644 --- a/drivers/net/smc911x.c +++ b/drivers/net/smc911x.c @@ -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);
}
This patch doesn't apply (there's no function 'smc911x_shutdown()' in either mainline or the net tree.
regards, Ben
participants (5)
-
Ben Warren
-
Jean-Christophe PLAGNIOL-VILLARD
-
Manikandan Pillai
-
Mike Frysinger
-
Wolfgang Denk