Fix networking on DM365EVM
Subsystems (2)
cover Fix networking on DM365EVM
From: Andreas Gaeer <[email protected]>
Network did not work on my DM365EVM because of a wrong PHY mask and wrong initialization of the MAC address when ethaddr was not already present in the environment.
The first patch fixes the mask definition, the second moves MAC address init to a proper place in the board setup.
Andreas Gaeer (2):
Davinci: Fixed wrong EMAC_MDIO_PHY_MASK
Davinci: Move config of MAC address to board setup
arch/arm/include/asm/arch-davinci/emac_defs.h | 2 +- arch/arm/lib/board.c | 11 ----------- board/davinci/common/misc.c | 16 ++++++++++++++++ board/davinci/common/misc.h | 1 + board/davinci/da830evm/da830evm.c | 8 +++----- board/davinci/dm365evm/dm365evm.c | 10 +++++++++- board/davinci/dvevm/dvevm.c | 5 +++++ board/davinci/sffsdr/sffsdr.c | 5 +++++ board/davinci/sonata/sonata.c | 5 +++++ drivers/net/davinci_emac.c | 3 +++ 10 files changed, 48 insertions(+), 18 deletions(-)
PATCH 1/2 Davinci: Fixed wrong EMAC_MDIO_PHY_MASK
From: Andreas Gaeer <[email protected]>
--- arch/arm/include/asm/arch-davinci/emac_defs.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
arch/arm/include/asm/arch-davinci/emac_defs.h +1 -1
@@ -86,7 +86,7 @@/* PHY mask - set only those phy number bits where phy is/can be connected */ #define EMAC_MDIO_PHY_NUM 1 -#define EMAC_MDIO_PHY_MASK (1 << EMAC_MDIO_PHY_NUM) +#define EMAC_MDIO_PHY_MASK ((1 << EMAC_MDIO_PHY_NUM)-1)/* Ethernet Min/Max packet size */ #define EMAC_MIN_ETHERNET_PKT_SIZE 60
Signature · 1 line
1.7.0.3
PATCH 2/2 Davinci: Move config of MAC address to board setup
In reply to andreas.gaer at baslerweb.comFrom: Andreas Gaeer <[email protected]>
Without this change the MAC address only gets properly set when the ethaddr is already set in u-boot environment.
Now the board setup should do the following:
1. Put a valid ethaddr into environment (eg. by I2C EEPROM)
2. Call dv_set_mac_address() to set the address in TI EMAC driver
--- arch/arm/lib/board.c | 11 ----------- board/davinci/common/misc.c | 16 ++++++++++++++++ board/davinci/common/misc.h | 1 + board/davinci/da830evm/da830evm.c | 8 +++----- board/davinci/dm365evm/dm365evm.c | 10 +++++++++- board/davinci/dvevm/dvevm.c | 5 +++++ board/davinci/sffsdr/sffsdr.c | 5 +++++ board/davinci/sonata/sonata.c | 5 +++++ drivers/net/davinci_emac.c | 3 +++ 9 files changed, 47 insertions(+), 17 deletions(-)
arch/arm/lib/board.c +0 -11
@@ -385,17 +385,6 @@ void start_armboot (void)/* enable exceptions */ enable_interrupts (); -/* Perform network card initialisation if necessary */ -#ifdef CONFIG_DRIVER_TI_EMAC -/* XXX: this needs to be moved to board init */ -extern void davinci_eth_set_mac_addr (const u_int8_t *addr); -if (getenv ("ethaddr" )) { -uchar enetaddr[6 ]; -eth_getenv_enetaddr ("ethaddr" , enetaddr); -davinci_eth_set_mac_addr (enetaddr); - } -#endif -#if defined(CONFIG_DRIVER_SMC91111 ) || defined (CONFIG_DRIVER_LAN91C96 )/* XXX: this needs to be moved to board init */ if (getenv ("ethaddr" )) {
board/davinci/common/misc.c +16 -0
@@ -110,6 +110,22 @@ void dv_configure_mac_address(uint8_t *rom_enetaddr) } } +/* Get the MAC address from the environment and set it in the TI EMAC driver +* Returns 1 when MAC could be set, 0 otherwise +*/ +int dv_set_mac_address () { + +uchar enetaddr[6 ]; +if (getenv ("ethaddr" )) { +if (eth_getenv_enetaddr ("ethaddr" , enetaddr)) { +davinci_eth_set_mac_addr (enetaddr); +return 1 ; + } + } +printf ("Warning: Could not set MAC address!\n" ); +return 0 ; +} +#endif /* DAVINCI_EMAC */ /*
board/davinci/common/misc.h +1 -0
@@ -47,6 +47,7 @@ struct pinmux_resource {int dvevm_read_mac_address (uint8_t *buf);void dv_configure_mac_address (uint8_t *rom_enetaddr); +int dv_set_mac_address ();int davinci_configure_pin_mux (const struct pinmux_config *pins,int n_pins);int davinci_configure_pin_mux_items (const struct pinmux_resource *item,int n_items);
board/davinci/da830evm/da830evm.c +3 -5
@@ -207,12 +207,10 @@ int board_eth_init(bd_t *bis)/* set address env if not already set */ dv_configure_mac_address (mac_addr); -/* read the address back from env */ -if (!eth_getenv_enetaddr ("ethaddr" , mac_addr)) +/* Set the MAC address from environment */ +if (!dv_set_mac_address ()) {return -1 ; - -/* provide the resulting addr to the driver */ -davinci_eth_set_mac_addr (mac_addr); + }/* enable the Ethernet switch in the 3 port PHY */ if (i2c_write(PHY_SW_I2C_ADDR, 0, 0,
board/davinci/dm365evm/dm365evm.c +9 -1
@@ -70,7 +70,15 @@ int board_eth_init(bd_t *bis)if (dvevm_read_mac_address (eeprom_enetaddr))dv_configure_mac_address (eeprom_enetaddr); -davinci_emac_initialize (); +/* Set the MAC address from environment */ +if (!dv_set_mac_address ()) { +return -1 ; + } + +if (davinci_emac_initialize () <=0 ) { +printf ("davinci_emac_initialize failed!\n" ); +return -1 ; + }return 0 ; }
board/davinci/dvevm/dvevm.c +5 -0
@@ -73,6 +73,11 @@ int misc_init_r(void)if (dvevm_read_mac_address (eeprom_enetaddr))dv_configure_mac_address (eeprom_enetaddr); +/* Set the MAC address from environment */ +if (!dv_set_mac_address ()) { +return -1 ; + } +i2c_read (0x39 ,0x00 ,1 , &video_mode,1 );setenv ("videostd" , ((video_mode &0x80 ) ?"pal" :"ntsc" ));
board/davinci/sffsdr/sffsdr.c +5 -0
@@ -143,5 +143,10 @@ int misc_init_r(void)if (sffsdr_read_mac_address (eeprom_enetaddr))dv_configure_mac_address (eeprom_enetaddr); +/* Set the MAC address from environment */ +if (!dv_set_mac_address ()) { +return -1 ; + } +return (0 ); }
board/davinci/sonata/sonata.c +5 -0
@@ -72,6 +72,11 @@ int misc_init_r(void)if (dvevm_read_mac_address (eeprom_enetaddr))dv_configure_mac_address (eeprom_enetaddr); +/* Set the MAC address from environment */ +if (!dv_set_mac_address ()) { +return -1 ; + } +return (0 ); }
drivers/net/davinci_emac.c +3 -0
@@ -75,9 +75,12 @@ void davinci_eth_set_mac_addr(const u_int8_t *addr) {int i; +debug_emac ("davinci_eth_set_mac_addr(), MAC = " );for (i =0 ; i <sizeof (davinci_eth_mac_addr); i++) { +debug_emac (i ?":%02x" :"%02x" , addr[i]); davinci_eth_mac_addr[i] = addr[i]; } +debug_emac ("\n" ); }/* EMAC Addresses */
Signature · 1 line
1.7.0.3
PATCH 2/2 Davinci: Move config of MAC address to board setup
Andreas,
Quoted 10 lines · andreas.gaer at baslerweb.com
From: Andreas Gaeer<[email protected]>
Without this change the MAC address only gets properly set when the ethaddr is already set in u-boot environment.
Now the board setup should do the following:
1. Put a valid ethaddr into environment (eg. by I2C EEPROM)
2. Calldv_set_mac_address()to set the address in TI EMAC driver
Please read the documentation. This is not how it's done. The programming of MAC addresses is currently in flux. I suggest you wait a few days and then see if changes are needed.
regards,
Ben
Gaer
PATCH 2/2 Davinci: Move config of MAC address to board setup
Hi Ben,
Quoted 2 lines
Please read the documentation.
This is not how it's done.
Ok, thanks for the info.
After reading doc/README.enetaddr I think I understand how it's done right. I already have reworked my patch that way. I'll wait with re-submitting until things have settled.
Regards,
Andreas.