Commit dc02bada authored by Heiko Schocher's avatar Heiko Schocher Committed by Albert ARIBAUD

arm, davinci_emac: fix driver bug if more then 3 PHYs are detected

since commits:
davinci: emac: add support for more than 1 PHYs
062fe7d3

davinci: remove obsolete macro CONFIG_EMAC_MDIO_PHY_NUM
fb1d6332

I get following warning on the enbw_cmc board:

Err:   serial
Net:    5 ETH PHY detected
miiphy_register: non unique device name 'KSZ8873 @ 0x01'
DaVinci-EMAC
Hit any key to stop autoboot:  0

Also I see some debug printfs:

=> run load
+ emac_close
+ emac_ch_teardown
- emac_ch_teardown
+ emac_ch_teardown
- emac_ch_teardown
- emac_close
+ emac_open
- emac_open
Using DaVinci-EMAC device

reason is 062fe7d3 new define MAX_PHY.
This is set to 3! I get on this board 5 active phys, so
this leads in wrong memory writes ...

so I changed:

- define CONFIG_SYS_DAVINCI_EMAC_PHY_COUNT to set
  the MAX_PHY value, add a description in README
  for the new CONFIG_SYS option.
- print an error message if more then MAX_PHYs are
  detected.
- fill the active_phy_addr array in a for loop with
  0xff
- changed printf() in debug_emac()
Signed-off-by: 's avatarHeiko Schocher <hs@denx.de>
Cc: Sandeep Paulraj <s-paulraj@ti.com>
Cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Manjunath Hadli <manjunath.hadli@ti.com>
Cc: Prabhakar Lad <prabhakar.csengg@gmail.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Cc: Tom Rini <tom.rini@gmail.com>
Signed-off-by: 's avatarSandeep Paulraj <s-paulraj@ti.com>
parent f3c149d6
...@@ -1027,6 +1027,12 @@ The following options need to be configured: ...@@ -1027,6 +1027,12 @@ The following options need to be configured:
Define this to use i/o functions instead of macros Define this to use i/o functions instead of macros
(some hardware wont work with macros) (some hardware wont work with macros)
CONFIG_DRIVER_TI_EMAC
Support for davinci emac
CONFIG_SYS_DAVINCI_EMAC_PHY_COUNT
Define this if you have more then 3 PHYs.
CONFIG_FTGMAC100 CONFIG_FTGMAC100
Support for Faraday's FTGMAC100 Gigabit SoC Ethernet Support for Faraday's FTGMAC100 Gigabit SoC Ethernet
......
...@@ -85,15 +85,17 @@ static int emac_rx_queue_active = 0; ...@@ -85,15 +85,17 @@ static int emac_rx_queue_active = 0;
/* Receive packet buffers */ /* Receive packet buffers */
static unsigned char emac_rx_buffers[EMAC_MAX_RX_BUFFERS * (EMAC_MAX_ETHERNET_PKT_SIZE + EMAC_PKT_ALIGN)]; static unsigned char emac_rx_buffers[EMAC_MAX_RX_BUFFERS * (EMAC_MAX_ETHERNET_PKT_SIZE + EMAC_PKT_ALIGN)];
#define MAX_PHY 3 #ifndef CONFIG_SYS_DAVINCI_EMAC_PHY_COUNT
#define CONFIG_SYS_DAVINCI_EMAC_PHY_COUNT 3
#endif
/* PHY address for a discovered PHY (0xff - not found) */ /* PHY address for a discovered PHY (0xff - not found) */
static u_int8_t active_phy_addr[MAX_PHY] = { 0xff, 0xff, 0xff }; static u_int8_t active_phy_addr[CONFIG_SYS_DAVINCI_EMAC_PHY_COUNT];
/* number of PHY found active */ /* number of PHY found active */
static u_int8_t num_phy; static u_int8_t num_phy;
phy_t phy[MAX_PHY]; phy_t phy[CONFIG_SYS_DAVINCI_EMAC_PHY_COUNT];
static int davinci_eth_set_mac_addr(struct eth_device *dev) static int davinci_eth_set_mac_addr(struct eth_device *dev)
{ {
...@@ -160,9 +162,8 @@ static int davinci_eth_phy_detect(void) ...@@ -160,9 +162,8 @@ static int davinci_eth_phy_detect(void)
int j; int j;
unsigned int count = 0; unsigned int count = 0;
active_phy_addr[0] = 0xff; for (i = 0; i < CONFIG_SYS_DAVINCI_EMAC_PHY_COUNT; i++)
active_phy_addr[1] = 0xff; active_phy_addr[i] = 0xff;
active_phy_addr[2] = 0xff;
udelay(1000); udelay(1000);
phy_act_state = readl(&adap_mdio->ALIVE); phy_act_state = readl(&adap_mdio->ALIVE);
...@@ -175,7 +176,14 @@ static int davinci_eth_phy_detect(void) ...@@ -175,7 +176,14 @@ static int davinci_eth_phy_detect(void)
for (i = 0, j = 0; i < 32; i++) for (i = 0, j = 0; i < 32; i++)
if (phy_act_state & (1 << i)) { if (phy_act_state & (1 << i)) {
count++; count++;
if (count < CONFIG_SYS_DAVINCI_EMAC_PHY_COUNT) {
active_phy_addr[j++] = i; active_phy_addr[j++] = i;
} else {
printf("%s: to many PHYs detected.\n",
__func__);
count = 0;
break;
}
} }
num_phy = count; num_phy = count;
...@@ -752,7 +760,7 @@ int davinci_emac_initialize(void) ...@@ -752,7 +760,7 @@ int davinci_emac_initialize(void)
if (!ret) if (!ret)
return(0); return(0);
else else
printf(" %d ETH PHY detected\n", ret); debug_emac(" %d ETH PHY detected\n", ret);
/* Get PHY ID and initialize phy_ops for a detected PHY */ /* Get PHY ID and initialize phy_ops for a detected PHY */
for (i = 0; i < num_phy; i++) { for (i = 0; i < num_phy; i++) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment