da850evm: basic MII EMAC support
Subsystems (2)
PATCH 1/1 da850evm: basic MII EMAC support
The current da850evm support in u-boot/master [1] omits any use of the davinci EMAC. This patch adds basic support for the EMAC using the MII PHY found on the baseboard of the EVM. The MAC address is read from the environment variable 'ethadd'. Note that this is different from the da850evm support in the u-boot omapl1 tree where the MAC address is read from SPI flash [2].
[1] http://git.denx.de/?p=u-boot.git
[2] http://arago-project.org/git/projects/?p=u-boot-omapl1.git
---
I am submitting this patch for inclusion in v2010.12, not v2010.09 since it introduces a new feature.
--- board/davinci/da8xxevm/da850evm.c | 60 +++++++++++++++++++++++++++++++++++++ include/configs/da850evm.h | 15 +++++++++ 2 files changed, 75 insertions(+), 0 deletions(-)
board/davinci/da8xxevm/da850evm.c +60 -0
@@ -23,7 +23,11 @@#include <common.h> #include <i2c.h> +#include <net.h> +#include <netdev.h> #include <asm/arch/hardware.h> +#include <asm/arch/emif_defs.h> +#include <asm/arch/emac_defs.h> #include <asm/io.h> #include "../common/misc.h" #include "common.h"
@@ -48,6 +52,28 @@ static const struct pinmux_config uart_pins[] = { { pinmux(4), 2, 5 } }; +#ifdef CONFIG_DRIVER_TI_EMAC +const struct pinmux_config emac_pins[] = { + {pinmux (2 ),8 ,1 }, + {pinmux (2 ),8 ,2 }, + {pinmux (2 ),8 ,3 }, + {pinmux (2 ),8 ,4 }, + {pinmux (2 ),8 ,5 }, + {pinmux (2 ),8 ,6 }, + {pinmux (2 ),8 ,7 }, + {pinmux (3 ),8 ,0 }, + {pinmux (3 ),8 ,1 }, + {pinmux (3 ),8 ,2 }, + {pinmux (3 ),8 ,3 }, + {pinmux (3 ),8 ,4 }, + {pinmux (3 ),8 ,5 }, + {pinmux (3 ),8 ,6 }, + {pinmux (3 ),8 ,7 }, + {pinmux (4 ),8 ,0 }, + {pinmux (4 ),8 ,1 } +}; +#endif /* CONFIG_DRIVER_TI_EMAC */ +/* I2C pin muxer settings */ static const struct pinmux_config i2c_pins[] = { {pinmux (4 ),2 ,2 },
@@ -102,6 +128,14 @@ int board_init(void)if (davinci_configure_pin_mux_items (pinmuxes,ARRAY_SIZE (pinmuxes)))return 1 ; +#ifdef CONFIG_DRIVER_TI_EMAC +if (davinci_configure_pin_mux (emac_pins,ARRAY_SIZE (emac_pins)) !=0 ) +return 1 ; +/* set cfgchip3 to select MII */ +writel (readl (&davinci_syscfg_regs->cfgchip3) & ~(1 <<8 ), + &davinci_syscfg_regs->cfgchip3); +#endif /* CONFIG_DRIVER_TI_EMAC */ +/* enable the console UART */ writel((DAVINCI_UART_PWREMU_MGMT_FREE | DAVINCI_UART_PWREMU_MGMT_URRST | DAVINCI_UART_PWREMU_MGMT_UTRST),
@@ -109,3 +143,29 @@ int board_init(void)return 0 ; } + +#ifdef CONFIG_DRIVER_TI_EMAC + +/* +* Initializes on-board ethernet controllers. +*/ +int board_eth_init (bd_t *bis) +{ +u_int8_t mac_addr[6 ]; + +/* read the address from env */ +if (!eth_getenv_enetaddr ("ethaddr" , mac_addr)) +return -1 ; + +/* provide the resulting addr to the driver */ +davinci_eth_set_mac_addr (mac_addr); + +/* finally, initialise the driver */ +if (!davinci_emac_initialize ()) { +printf ("Error: Ethernet init failed!\n" ); +return -1 ; + } + +return 0 ; +} +#endif /* CONFIG_DRIVER_TI_EMAC */
include/configs/da850evm.h +15 -0
@@ -26,6 +26,7 @@/* * Board */ +#define CONFIG_DRIVER_TI_EMAC /* * SoC Configuration
@@ -79,6 +80,20 @@#define CONFIG_SYS_I2C_SLAVE 10/* Bogus, master-only in U-Boot */ /* +* Network & Ethernet Configuration +*/ +#ifdef CONFIG_DRIVER_TI_EMAC +#define CONFIG_EMAC_MDIO_PHY_NUM 0 +#define CONFIG_MII +#define CONFIG_BOOTP_DEFAULT +#define CONFIG_BOOTP_DNS +#define CONFIG_BOOTP_DNS2 +#define CONFIG_BOOTP_SEND_HOSTNAME +#define CONFIG_NET_RETRY_COUNT 10 +#define CONFIG_NET_MULTI +#endif + +/* * U-Boot general configuration */ #define CONFIG_BOOTFILE "uImage"/* Boot file name */
Signature · 1 line
1.7.0.4
PATCH 1/1 da850evm: basic MII EMAC support
Quoted 9 lines · On Friday, September 10, 2010 16:10:16 Ben Gardiner wrote:
The current da850evm support in u-boot/master [1] omits any use of the davinci EMAC. This patch adds basic support for the EMAC using the MII PHY found on the baseboard of the EVM. The MAC address is read from the environment variable 'ethadd'. Note that this is different from the da850evm support in the u-boot omapl1 tree where the MAC address is read from SPI flash [2].
CC Sandeep Paulraj <[email protected]>CC Sudhakar Rajashekhara <[email protected]>
where is your sign-off-by ? patches cant be merged without it.
Quoted 2 lines
[1] http://git.denx.de/?p=u-boot.git
[2] http://arago-project.org/git/projects/?p=u-boot-omapl1.git
these URLs are useless. just drop them.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20100911/c179caaa/attachment.pgp
PATCH 1/1 da850evm: basic MII EMAC support
Hi Mike,
Quoted 8 lines · Mike Frysinger
Quoted 7 lines · On Friday, September 10, 2010 16:10:16 Ben Gardiner wrote:
The current da850evm support in u-boot/master [1] omits any use of the davinci EMAC. This patch adds basic support for the EMAC using the MII PHY found on the baseboard of the EVM. The MAC address is read from the environment variable 'ethadd'. Note that this is different from the da850evm support in the u-boot omapl1 tree where the MAC address is read from SPI flash [2].
Quoted 4 lines
Quoted 2 lines
CC Sandeep Paulraj <[email protected]>CC Sudhakar Rajashekhara <[email protected]>where is your sign-off-by ? ?patches cant be merged without it.
Right. My mistake, sorry.
Quoted 4 lines
Quoted 2 lines
[1] http://git.denx.de/?p=u-boot.git
[2] http://arago-project.org/git/projects/?p=u-boot-omapl1.gitthese URLs are useless. ?just drop them.
Thanks for the feedback on these -- I have been wondering whether URL footnotes were desirable in commit messages. I put them there since I can remember that it is sometimes difficult to find the trees that are being referred to when you are a newcomer. Would SHA1's and/or git URLs be more acceptable? Or is the point that nothing before the '---' should have links?
Best Regards,
Ben Gardiner
---
Nanometrics Inc.
http://www.nanometrics.ca
PATCH 1/1 da850evm: basic MII EMAC support
Quoted 12 lines · On Monday, September 13, 2010 08:55:47 Ben Gardiner wrote:
Quoted 11 lines · Mike Frysinger
Quoted 9 lines · On Friday, September 10, 2010 16:10:16 Ben Gardiner wrote:
The current da850evm support in u-boot/master [1] omits any use of the davinci EMAC. This patch adds basic support for the EMAC using the MII PHY found on the baseboard of the EVM. The MAC address is read from the environment variable 'ethadd'. Note that this is different from the da850evm support in the u-boot omapl1 tree where the MAC address is read from SPI flash [2].
[1] http://git.denx.de/?p=u-boot.git
[2] http://arago-project.org/git/projects/?p=u-boot-omapl1.git
Quoted 8 lines
Quoted 1 line
these URLs are useless. just drop them.
Thanks for the feedback on these -- I have been wondering whether URL footnotes were desirable in commit messages. I put them there since I can remember that it is sometimes difficult to find the trees that are being referred to when you are a newcomer. Would SHA1's and/or git URLs be more acceptable? Or is the point that nothing before the '---' should have links?
it depends on the URLs. i dont think referring to the mainline git tree is useful at all considering that's what they're using if they have this patch in their tree. as for the omap1 reference, i'm not sure mentioning at all is useful in the commit. presumably the tree in question will drop its code and move to the mainline stuff one yours is merged. imo, that would make it a "note" which goes below the "---".
if the URL is generally useful, then some people use a dedicated tag in the "s-o-b" section such as "URL: xxx". this isnt exactly standardized.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20100914/714c8fe8/attachment.pgp
PATCH 1/1 da850evm: basic MII EMAC support
Hi Mike,
Thanks for following-up.
Quoted 3 lines · Mike Frysinger
it depends on the URLs. ?i dont think referring to the mainline git tree is useful at all considering that's what they're using if they have this patch in
Yes, I see your point: the mainline tree's URL is superfluous.
Quoted 4 lines
their tree. as for the omap1 reference, i'm not sure mentioning at all is useful in the commit. presumably the tree in question will drop its code and move to the mainline stuff one yours is merged. imo, that would make it a "note" which goes below the "---".
Ok -- I hadn't fully considered the ramifications of the fact that the commit message would be around long after the state of the omap-l1 tree had changed. I agree that this URL would be a note below the '---', if included at all.
Quoted 2 lines
if the URL is generally useful, then some people use a dedicated tag in the "s-o-b" section such as "URL: xxx". this isnt exactly standardized.
Neat. I'll keep that one in mind too, but not for external commits -- you have convinced me that it is not useful to include these in he commit message.
Best Regards,
Ben Gardiner
---
Nanometrics Inc.
http://www.nanometrics.ca
PATCH 1/1 da850evm: basic MII EMAC support
In reply to Ben GardinerHi Ben,
Quoted 100 lines · Ben Gardiner
The current da850evm support in u-boot/master [1] omits any use of the davinci EMAC. This patch adds basic support for the EMAC using the MII PHY found on the baseboard of the EVM. The MAC address is read from the environment variable 'ethadd'. Note that this is different from the da850evm support in the u-boot omapl1 tree where the MAC address is read from SPI flash [2].
CC Sandeep Paulraj<[email protected]>CC Sudhakar Rajashekhara<[email protected]>[1] http://git.denx.de/?p=u-boot.git
[2] http://arago-project.org/git/projects/?p=u-boot-omapl1.git---
I am submitting this patch for inclusion in v2010.12, not v2010.09 since it introduces a new feature.
--- board/davinci/da8xxevm/da850evm.c | 60 +++++++++++++++++++++++++++++++++++++ include/configs/da850evm.h | 15 +++++++++ 2 files changed, 75 insertions(+), 0 deletions(-)board/davinci/da8xxevm/da850evm.c +47
-0@@ -23,7 +23,11 @@#include <common.h> #include <i2c.h> +#include <net.h> +#include <netdev.h> #include <asm/arch/hardware.h> +#include <asm/arch/emif_defs.h> +#include <asm/arch/emac_defs.h> #include <asm/io.h> #include "../common/misc.h" #include "common.h" @@ -48,6 +52,28 @@ static const struct pinmux_config uart_pins[] = { { pinmux(4), 2, 5 } }; +#ifdef CONFIG_DRIVER_TI_EMAC +const struct pinmux_config emac_pins[] = { + {pinmux (2 ),8 ,1 }, + {pinmux (2 ),8 ,2 }, + {pinmux (2 ),8 ,3 }, + {pinmux (2 ),8 ,4 }, + {pinmux (2 ),8 ,5 }, + {pinmux (2 ),8 ,6 }, + {pinmux (2 ),8 ,7 }, + {pinmux (3 ),8 ,0 }, + {pinmux (3 ),8 ,1 }, + {pinmux (3 ),8 ,2 }, + {pinmux (3 ),8 ,3 }, + {pinmux (3 ),8 ,4 }, + {pinmux (3 ),8 ,5 }, + {pinmux (3 ),8 ,6 }, + {pinmux (3 ),8 ,7 }, + {pinmux (4 ),8 ,0 }, + {pinmux (4 ),8 ,1 } +}; +#endif /* CONFIG_DRIVER_TI_EMAC */ +/* I2C pin muxer settings */ static const struct pinmux_config i2c_pins[] = { {pinmux (4 ),2 ,2 },@@ -102,6 +128,14 @@ int board_init(void)if (davinci_configure_pin_mux_items (pinmuxes,ARRAY_SIZE (pinmuxes)))return 1 ; +#ifdef CONFIG_DRIVER_TI_EMAC +if (davinci_configure_pin_mux (emac_pins,ARRAY_SIZE (emac_pins)) !=0 ) +return 1 ; +/* set cfgchip3 to select MII */ +writel (readl (&davinci_syscfg_regs->cfgchip3)& ~(1 <<8 ), + &davinci_syscfg_regs->cfgchip3); +#endif /* CONFIG_DRIVER_TI_EMAC */ +/* enable the console UART */ writel((DAVINCI_UART_PWREMU_MGMT_FREE | DAVINCI_UART_PWREMU_MGMT_URRST | DAVINCI_UART_PWREMU_MGMT_UTRST),@@ -109,3 +143,29 @@ int board_init(void)return 0 ; } + +#ifdef CONFIG_DRIVER_TI_EMAC + +/* +* Initializes on-board ethernet controllers. +*/ +int board_eth_init (bd_t *bis) +{ +u_int8_t mac_addr[6 ]; + +/* read the address from env */ +if (!eth_getenv_enetaddr ("ethaddr" , mac_addr)) +return -1 ;
board/davinci/da8xxevm/da850evm.c int board_init(void) · line 168
Quoted 10 lines
board/davinci/da8xxevm/da850evm.c +10
-0+ +/* provide the resulting addr to the driver */ +davinci_eth_set_mac_addr (mac_addr); + +/* finally, initialise the driver */ +if (!davinci_emac_initialize ()) { +printf ("Error: Ethernet init failed!\n" ); +return -1 ; + } +
Please consider doing this differently. If you change the driver to make 'davinci_eth_set_mac_addr()' meet the signature of 'eth_device->write_hwaddr()', all the environment handling is done automagically. Let me know if you're confused and I'll provide more guidance.
Quoted 26 lines
board/davinci/da8xxevm/da850evm.c +3
-0+ return 0; +} +#endif /* CONFIG_DRIVER_TI_EMAC */ include/configs/da850evm.h +8
-0@@ -26,6 +26,7 @@/* * Board */ +#define CONFIG_DRIVER_TI_EMAC /* * SoC Configuration @@ -79,6 +80,20 @@#define CONFIG_SYS_I2C_SLAVE 10/* Bogus, master-only in U-Boot */ /* +* Network& Ethernet Configuration +*/ +#ifdef CONFIG_DRIVER_TI_EMAC +#define CONFIG_EMAC_MDIO_PHY_NUM 0 +#define CONFIG_MII +#define CONFIG_BOOTP_DEFAULT +#define CONFIG_BOOTP_DNS
include/configs/da850evm.h line 99
Quoted 10 lines
include/configs/da850evm.h +7
-0+#define CONFIG_BOOTP_DNS2 +#define CONFIG_BOOTP_SEND_HOSTNAME +#define CONFIG_NET_RETRY_COUNT 10 +#define CONFIG_NET_MULTI +#endif + +/* * U-Boot general configuration */ #define CONFIG_BOOTFILE "uImage"/* Boot file name */
regards,
Ben W.
PATCH 1/1 da850evm: basic MII EMAC support
Hi Ben,
Quoted 5 lines · Ben Warren
Please consider doing this differently. ?If you change the driver to make '
davinci_eth_set_mac_addr()' meet the signature of 'eth_device->write_hwaddr()', all the environment handling is done automagically. ?Let me know if you're confused and I'll provide more guidance.
Thanks for pointing me in the right direction here. I think I get it now; please correct me if I am wrong: board_eth_init should assign the eth_device->write_hwaddr() function pointer then eth_initialize() will handle calling board_eth_init and will set the MAC address from the ethaddr env var if the MAC address in the eth_device struct is all-zeroes.
Best Regards,
Ben Gardiner
---
Nanometrics Inc.
http://www.nanometrics.ca
PATCH 1/1 da850evm: basic MII EMAC support
Hi Ben,
Quoted 9 lines · Ben Gardiner
Hi Ben,
Quoted 5 lines · Ben Warren
Please consider doing this differently. ?If you change the driver to make '
davinci_eth_set_mac_addr()' meet the signature of 'eth_device->write_hwaddr()', all the environment handling is done automagically. ?Let me know if you're confused and I'll provide more guidance.
Quoted 7 lines
Thanks for pointing me in the right direction here. I think I get it now; please correct me if I am wrong:
board_eth_initshould assign theeth_device->write_hwaddr()function pointer theneth_initialize()will handle callingboard_eth_initand will set the MAC address from the ethaddr env var if the MAC address in theeth_devicestruct is all-zeroes.
Almost. The driver should set the function pointer, just as it does 'send()', 'init()', 'halt()', etc. This is a recent feature and the davinci driver hasn't been updated yet
Quoted 6 lines
Best Regards,
Ben Gardiner---
Nanometrics Inc.
http://www.nanometrics.ca
Regards,
Ben
v2 cover da850evm basic MII EMAC support
This patch series proposes to add basic MII support to the da850evm; the first patch in the series refactors davinci EMAC setup. The second patch in the series enables MII support.
Ben Gardiner (2):
davinci_emac: davinci_eth_set_mac_addr to ->write_hwaddr
da850evm: basic MII EMAC support
arch/arm/include/asm/arch-davinci/emac_defs.h | 1 - arch/arm/lib/board.c | 9 --- board/davinci/common/misc.c | 41 +++---------- board/davinci/common/misc.h | 2 +- board/davinci/da8xxevm/da830evm.c | 15 ++++- board/davinci/da8xxevm/da850evm.c | 50 +++++++++++++++ board/davinci/dm365evm/dm365evm.c | 2 +- board/davinci/dvevm/dvevm.c | 2 +- board/davinci/sffsdr/sffsdr.c | 2 +- board/davinci/sonata/sonata.c | 2 +- drivers/net/davinci_emac.c | 80 ++++++++++++------------- include/configs/da850evm.h | 15 +++++ 12 files changed, 129 insertions(+), 92 deletions(-)
---
I am submitting this patch for inclusion in v2010.12, not v2010.09.
V2:
* added patch 1/2 to refactor davinci_emac setup
* added SOB to 2/2
./MAKEALL ARM9 showed no errors or additional warnings.
Tested on da850evm with MII PHY on baseboard.
PATCH v2 1/2 davinci_emac: davinci_eth_set_mac_addr to ->write_hwaddr
This patch proposes to migrate the davinci_emac driver to using the eth_device->write_hwaddr function pointer as suggested by Ben Warren.
All the davinci boards had the behaviour, prior to this patch, of sync'ing the environment variable enetaddr with the MAC address read from non-volatile storage on boot -- when the two locations disagreed, the environment variable value took precendence. This patch keeps the same behaviour but makes eth_initialize take care of it.
This patch refactors davinci_emac setup in the boards so that the MAC address is read from non-volatile storage into the environment variable and then the environment variable value is use in eth_intialize. The only exception is the direct call to davinci_eth_set_mac_addr made by the da830evm board init which was changed into an assignment of the enetaddr field.
---
V2:
* introduced this patch
--- arch/arm/include/asm/arch-davinci/emac_defs.h | 1 - arch/arm/lib/board.c | 9 --- board/davinci/common/misc.c | 41 +++---------- board/davinci/common/misc.h | 2 +- board/davinci/da8xxevm/da830evm.c | 15 ++++- board/davinci/dm365evm/dm365evm.c | 2 +- board/davinci/dvevm/dvevm.c | 2 +- board/davinci/sffsdr/sffsdr.c | 2 +- board/davinci/sonata/sonata.c | 2 +- drivers/net/davinci_emac.c | 80 ++++++++++++------------- 10 files changed, 64 insertions(+), 92 deletions(-)
arch/arm/include/asm/arch-davinci/emac_defs.h +0 -1
@@ -367,7 +367,6 @@ typedef struct {int davinci_eth_phy_read (u_int8_t phy_addr,u_int8_t reg_num,u_int16_t *data);int davinci_eth_phy_write (u_int8_t phy_addr,u_int8_t reg_num,u_int16_t data); -void davinci_eth_set_mac_addr (const u_int8_t *addr); typedef struct {
arch/arm/lib/board.c +0 -9
@@ -386,15 +386,6 @@ void start_armboot (void)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 */
board/davinci/common/misc.c +9 -32
54 lines not on this page · raw message
board/davinci/common/misc.h +1 -1
@@ -46,7 +46,7 @@ struct pinmux_resource { }int dvevm_read_mac_address (uint8_t *buf); -void dv_configure_mac_address (uint8_t *rom_enetaddr); +void davinci_sync_env_enetaddr (uint8_t *rom_enetaddr);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/da8xxevm/da830evm.c +11 -4
@@ -196,19 +196,17 @@ int board_eth_init(bd_t *bis) {u_int8_t mac_addr[6 ];u_int8_t switch_start_cmd[2 ] = {0x01 ,0x23 }; +struct eth_device *dev;/* Read Ethernet MAC address from EEPROM */ if (dvevm_read_mac_address (mac_addr))/* set address env if not already set */ -dv_configure_mac_address (mac_addr); +davinci_sync_env_enetaddr (mac_addr);/* read the address back from env */ if (!eth_getenv_enetaddr ("ethaddr" , mac_addr))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 , switch_start_cmd,sizeof (switch_start_cmd))) {
@@ -222,6 +220,15 @@ int board_eth_init(bd_t *bis) return -1; } + dev =eth_get_dev (); + +/* provide the resulting addr to the driver */ +memcpy (dev->enetaddr, mac_addr,6 ); +if (!dev->write_hwaddr (dev)) { +printf ("Error: Could not set MAC address\n" ); +return -1 ; + } +return 0 ; }#endif /* CONFIG_DRIVER_TI_EMAC */
board/davinci/dm365evm/dm365evm.c +1 -1
@@ -68,7 +68,7 @@ int board_eth_init(bd_t *bis)/* Read Ethernet MAC address from EEPROM */ if (dvevm_read_mac_address (eeprom_enetaddr)) -dv_configure_mac_address (eeprom_enetaddr); +davinci_sync_env_enetaddr (eeprom_enetaddr);davinci_emac_initialize ();
board/davinci/dvevm/dvevm.c +1 -1
@@ -71,7 +71,7 @@ int misc_init_r(void)/* Read Ethernet MAC address from EEPROM if available. */ if (dvevm_read_mac_address (eeprom_enetaddr)) -dv_configure_mac_address (eeprom_enetaddr); +davinci_sync_env_enetaddr (eeprom_enetaddr);i2c_read (0x39 ,0x00 ,1 , &video_mode,1 );
board/davinci/sffsdr/sffsdr.c +1 -1
@@ -141,7 +141,7 @@ int misc_init_r(void)/* Read Ethernet MAC address from EEPROM if available. */ if (sffsdr_read_mac_address (eeprom_enetaddr)) -dv_configure_mac_address (eeprom_enetaddr); +davinci_sync_env_enetaddr (eeprom_enetaddr);return (0 ); }
board/davinci/sonata/sonata.c +1 -1
@@ -70,7 +70,7 @@ int misc_init_r(void)/* Read Ethernet MAC address from EEPROM if available. */ if (dvevm_read_mac_address (eeprom_enetaddr)) -dv_configure_mac_address (eeprom_enetaddr); +davinci_sync_env_enetaddr (eeprom_enetaddr);return (0 ); }
drivers/net/davinci_emac.c +39 -41
110 lines not on this page · raw message
Signature · 1 line
1.7.0.4
PATCH v2 1/2 davinci_emac: davinci_eth_set_mac_addr to ->write_hwaddr
Quoted 16 lines · Ben Gardiner
This patch proposes to migrate the
davinci_emacdriver to using theeth_device->write_hwaddrfunction pointer as suggested by Ben Warren.All the davinci boards had the behaviour, prior to this patch, of sync'ing the environment variable enetaddr with the MAC address read from non-volatile storage on boot -- when the two locations disagreed, the environment variable value took precendence. This patch keeps the same behaviour but makes
eth_initializetake care of it.This patch refactors
davinci_emacsetup in the boards so that the MAC address is read from non-volatile storage into the environment variable and then the environment variable value is use ineth_intialize. The only exception is the direct call todavinci_eth_set_mac_addrmade by the da830evm board init which was changed into an assignment of the enetaddr field.
Quoted 3 lines
Signed-off-by Ben Gardiner <[email protected]>CC Ben Warren <[email protected]>CC Nick Thompson <[email protected]>
This change seem reasonable to me from the da830evm point of view. I don't have access to hardware for the next week or so, so I can't test it now, but the da830 specific changes are minor.
PATCH v2 2/2 da850evm: basic MII EMAC support
In reply to Ben GardinerThe current da850evm support in u-boot/master omits any use of the davinci EMAC. This patch adds basic support for the EMAC using the MII PHY found on the baseboard of the EVM. The MAC address is read from the environment variable 'ethadd'. Note that this is different from the da850evm support in the u-boot omapl1 tree where the MAC address is read from SPI flash.
---
V2:
* added SOB
* renumbered this patch from 1/1 to 2/2
* just initialize the driver and let eth_initialize() take care of setting the MAC address from the environment variable enetaddr
--- board/davinci/da8xxevm/da850evm.c | 50 +++++++++++++++++++++++++++++++++++++ include/configs/da850evm.h | 15 +++++++++++ 2 files changed, 65 insertions(+), 0 deletions(-)
board/davinci/da8xxevm/da850evm.c +50 -0
@@ -23,7 +23,11 @@#include <common.h> #include <i2c.h> +#include <net.h> +#include <netdev.h> #include <asm/arch/hardware.h> +#include <asm/arch/emif_defs.h> +#include <asm/arch/emac_defs.h> #include <asm/io.h> #include "../common/misc.h" #include "common.h"
@@ -48,6 +52,28 @@ static const struct pinmux_config uart_pins[] = { { pinmux(4), 2, 5 } }; +#ifdef CONFIG_DRIVER_TI_EMAC +const struct pinmux_config emac_pins[] = { + {pinmux (2 ),8 ,1 }, + {pinmux (2 ),8 ,2 }, + {pinmux (2 ),8 ,3 }, + {pinmux (2 ),8 ,4 }, + {pinmux (2 ),8 ,5 }, + {pinmux (2 ),8 ,6 }, + {pinmux (2 ),8 ,7 }, + {pinmux (3 ),8 ,0 }, + {pinmux (3 ),8 ,1 }, + {pinmux (3 ),8 ,2 }, + {pinmux (3 ),8 ,3 }, + {pinmux (3 ),8 ,4 }, + {pinmux (3 ),8 ,5 }, + {pinmux (3 ),8 ,6 }, + {pinmux (3 ),8 ,7 }, + {pinmux (4 ),8 ,0 }, + {pinmux (4 ),8 ,1 } +}; +#endif /* CONFIG_DRIVER_TI_EMAC */ +/* I2C pin muxer settings */ static const struct pinmux_config i2c_pins[] = { {pinmux (4 ),2 ,2 },
@@ -102,6 +128,14 @@ int board_init(void)if (davinci_configure_pin_mux_items (pinmuxes,ARRAY_SIZE (pinmuxes)))return 1 ; +#ifdef CONFIG_DRIVER_TI_EMAC +if (davinci_configure_pin_mux (emac_pins,ARRAY_SIZE (emac_pins)) !=0 ) +return 1 ; +/* set cfgchip3 to select MII */ +writel (readl (&davinci_syscfg_regs->cfgchip3) & ~(1 <<8 ), + &davinci_syscfg_regs->cfgchip3); +#endif /* CONFIG_DRIVER_TI_EMAC */ +/* enable the console UART */ writel((DAVINCI_UART_PWREMU_MGMT_FREE | DAVINCI_UART_PWREMU_MGMT_URRST | DAVINCI_UART_PWREMU_MGMT_UTRST),
@@ -109,3 +143,19 @@ int board_init(void)return 0 ; } + +#ifdef CONFIG_DRIVER_TI_EMAC + +/* +* Initializes on-board ethernet controllers. +*/ +int board_eth_init (bd_t *bis) +{ +if (!davinci_emac_initialize ()) { +printf ("Error: Ethernet init failed!\n" ); +return -1 ; + } + +return 0 ; +} +#endif /* CONFIG_DRIVER_TI_EMAC */
include/configs/da850evm.h +15 -0
@@ -26,6 +26,7 @@/* * Board */ +#define CONFIG_DRIVER_TI_EMAC /* * SoC Configuration
@@ -79,6 +80,20 @@#define CONFIG_SYS_I2C_SLAVE 10/* Bogus, master-only in U-Boot */ /* +* Network & Ethernet Configuration +*/ +#ifdef CONFIG_DRIVER_TI_EMAC +#define CONFIG_EMAC_MDIO_PHY_NUM 0 +#define CONFIG_MII +#define CONFIG_BOOTP_DEFAULT +#define CONFIG_BOOTP_DNS +#define CONFIG_BOOTP_DNS2 +#define CONFIG_BOOTP_SEND_HOSTNAME +#define CONFIG_NET_RETRY_COUNT 10 +#define CONFIG_NET_MULTI +#endif + +/* * U-Boot general configuration */ #define CONFIG_BOOTFILE "uImage"/* Boot file name */
Signature · 1 line
1.7.0.4
v3 cover da850evm basic MII EMAC support
In reply to Ben GardinerThis patch series proposes to add basic MII support to the da850evm; the first patch in the series refactors davinci EMAC setup. The second patch in the series enables MII support.
Ben Gardiner (2):
[NEXT] davinci_emac: davinci_eth_set_mac_addr to ->write_hwaddr [NEXT] da850evm: basic MII EMAC support
arch/arm/include/asm/arch-davinci/emac_defs.h | 1 - arch/arm/lib/board.c | 19 ------ board/davinci/common/misc.c | 41 +++---------- board/davinci/common/misc.h | 2 +- board/davinci/da8xxevm/da830evm.c | 15 ++++- board/davinci/da8xxevm/da850evm.c | 50 +++++++++++++++ board/davinci/dm365evm/dm365evm.c | 2 +- board/davinci/dvevm/dvevm.c | 2 +- board/davinci/sffsdr/sffsdr.c | 2 +- board/davinci/sonata/sonata.c | 2 +- drivers/net/davinci_emac.c | 80 ++++++++++++------------- include/configs/da850evm.h | 15 +++++ 12 files changed, 129 insertions(+), 102 deletions(-)
---
V3:
* rebased to u-boot/next
* removed additional direct call of davinci_eth_set_mac_addr added to board_init_r by Heiko's relocation patches
V2:
* added patch 1/2 to refactor davinci_emac setup
* added SOB to 2/2
Tested on da850evm with MII PHY on baseboard.
PATCH v3 1/2 davinci_emac: davinci_eth_set_mac_addr to ->write_hwaddr
This patch proposes to migrate the davinci_emac driver to using the eth_device->write_hwaddr function pointer as suggested by Ben Warren.
All the davinci boards had the behaviour, prior to this patch, of sync'ing the environment variable enetaddr with the MAC address read from non-volatile storage on boot -- when the two locations disagreed, the environment variable value took precendence. This patch keeps the same behaviour but lets eth_initialize take care of it.
This patch refactors davinci_emac setup in the boards so that the MAC address is read from non-volatile storage into the environment variable and then the environment variable value is use in eth_intialize. The only exception is the direct call to davinci_eth_set_mac_addr made by the da830evm board init which was changed into an assignment of the enetaddr field.
--
V3:
* rebased to u-boot/next, removed additional direct call of davinci_eth_set_mac_addr added to board_init_r by Heiko's relocation patches
V2:
* introduced this patch
--- arch/arm/include/asm/arch-davinci/emac_defs.h | 1 - arch/arm/lib/board.c | 19 ------ board/davinci/common/misc.c | 41 +++---------- board/davinci/common/misc.h | 2 +- board/davinci/da8xxevm/da830evm.c | 15 ++++- board/davinci/dm365evm/dm365evm.c | 2 +- board/davinci/dvevm/dvevm.c | 2 +- board/davinci/sffsdr/sffsdr.c | 2 +- board/davinci/sonata/sonata.c | 2 +- drivers/net/davinci_emac.c | 80 ++++++++++++------------- 10 files changed, 64 insertions(+), 102 deletions(-)
arch/arm/include/asm/arch-davinci/emac_defs.h +0 -1
@@ -367,7 +367,6 @@ typedef struct {int davinci_eth_phy_read (u_int8_t phy_addr,u_int8_t reg_num,u_int16_t *data);int davinci_eth_phy_write (u_int8_t phy_addr,u_int8_t reg_num,u_int16_t data); -void davinci_eth_set_mac_addr (const u_int8_t *addr); typedef struct {
arch/arm/lib/board.c +0 -19
@@ -409,15 +409,6 @@ void start_armboot (void)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 */
@@ -821,16 +812,6 @@ void board_init_r (gd_t *id, ulong dest_addr)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 +9 -32
54 lines not on this page · raw message
board/davinci/common/misc.h +1 -1
@@ -46,7 +46,7 @@ struct pinmux_resource { }int dvevm_read_mac_address (uint8_t *buf); -void dv_configure_mac_address (uint8_t *rom_enetaddr); +void davinci_sync_env_enetaddr (uint8_t *rom_enetaddr);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/da8xxevm/da830evm.c +11 -4
@@ -196,19 +196,17 @@ int board_eth_init(bd_t *bis) {u_int8_t mac_addr[6 ];u_int8_t switch_start_cmd[2 ] = {0x01 ,0x23 }; +struct eth_device *dev;/* Read Ethernet MAC address from EEPROM */ if (dvevm_read_mac_address (mac_addr))/* set address env if not already set */ -dv_configure_mac_address (mac_addr); +davinci_sync_env_enetaddr (mac_addr);/* read the address back from env */ if (!eth_getenv_enetaddr ("ethaddr" , mac_addr))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 , switch_start_cmd,sizeof (switch_start_cmd))) {
@@ -222,6 +220,15 @@ int board_eth_init(bd_t *bis) return -1; } + dev =eth_get_dev (); + +/* provide the resulting addr to the driver */ +memcpy (dev->enetaddr, mac_addr,6 ); +if (!dev->write_hwaddr (dev)) { +printf ("Error: Could not set MAC address\n" ); +return -1 ; + } +return 0 ; }#endif /* CONFIG_DRIVER_TI_EMAC */
board/davinci/dm365evm/dm365evm.c +1 -1
@@ -68,7 +68,7 @@ int board_eth_init(bd_t *bis)/* Read Ethernet MAC address from EEPROM */ if (dvevm_read_mac_address (eeprom_enetaddr)) -dv_configure_mac_address (eeprom_enetaddr); +davinci_sync_env_enetaddr (eeprom_enetaddr);davinci_emac_initialize ();
board/davinci/dvevm/dvevm.c +1 -1
@@ -71,7 +71,7 @@ int misc_init_r(void)/* Read Ethernet MAC address from EEPROM if available. */ if (dvevm_read_mac_address (eeprom_enetaddr)) -dv_configure_mac_address (eeprom_enetaddr); +davinci_sync_env_enetaddr (eeprom_enetaddr);i2c_read (0x39 ,0x00 ,1 , &video_mode,1 );
board/davinci/sffsdr/sffsdr.c +1 -1
@@ -141,7 +141,7 @@ int misc_init_r(void)/* Read Ethernet MAC address from EEPROM if available. */ if (sffsdr_read_mac_address (eeprom_enetaddr)) -dv_configure_mac_address (eeprom_enetaddr); +davinci_sync_env_enetaddr (eeprom_enetaddr);return (0 ); }
board/davinci/sonata/sonata.c +1 -1
@@ -70,7 +70,7 @@ int misc_init_r(void)/* Read Ethernet MAC address from EEPROM if available. */ if (dvevm_read_mac_address (eeprom_enetaddr)) -dv_configure_mac_address (eeprom_enetaddr); +davinci_sync_env_enetaddr (eeprom_enetaddr);return (0 ); }
drivers/net/davinci_emac.c +39 -41
110 lines not on this page · raw message
Signature · 1 line
1.7.0.4
PATCH v3 2/2 da850evm: basic MII EMAC support
In reply to Ben GardinerThe current da850evm support in u-boot/master omits any use of the davinci EMAC. This patch adds basic support for the EMAC using the MII PHY found on the baseboard of the EVM. The MAC address is read from the environment variable 'ethadd'. Note that this is different from the da850evm support in the u-boot omapl1 tree where the MAC address is read from SPI flash.
---
V3:
* rebased to u-boot/next
V2:
* added SOB
* renumbered this patch from 1/1 to 2/2
* just initialize the driver and let eth_initialize() take care of setting the MAC address from the environment variable enetaddr
--- board/davinci/da8xxevm/da850evm.c | 50 +++++++++++++++++++++++++++++++++++++ include/configs/da850evm.h | 15 +++++++++++ 2 files changed, 65 insertions(+), 0 deletions(-)
board/davinci/da8xxevm/da850evm.c +50 -0
@@ -23,7 +23,11 @@#include <common.h> #include <i2c.h> +#include <net.h> +#include <netdev.h> #include <asm/arch/hardware.h> +#include <asm/arch/emif_defs.h> +#include <asm/arch/emac_defs.h> #include <asm/io.h> #include "../common/misc.h" #include "common.h"
@@ -48,6 +52,28 @@ static const struct pinmux_config uart_pins[] = { { pinmux(4), 2, 5 } }; +#ifdef CONFIG_DRIVER_TI_EMAC +const struct pinmux_config emac_pins[] = { + {pinmux (2 ),8 ,1 }, + {pinmux (2 ),8 ,2 }, + {pinmux (2 ),8 ,3 }, + {pinmux (2 ),8 ,4 }, + {pinmux (2 ),8 ,5 }, + {pinmux (2 ),8 ,6 }, + {pinmux (2 ),8 ,7 }, + {pinmux (3 ),8 ,0 }, + {pinmux (3 ),8 ,1 }, + {pinmux (3 ),8 ,2 }, + {pinmux (3 ),8 ,3 }, + {pinmux (3 ),8 ,4 }, + {pinmux (3 ),8 ,5 }, + {pinmux (3 ),8 ,6 }, + {pinmux (3 ),8 ,7 }, + {pinmux (4 ),8 ,0 }, + {pinmux (4 ),8 ,1 } +}; +#endif /* CONFIG_DRIVER_TI_EMAC */ +/* I2C pin muxer settings */ static const struct pinmux_config i2c_pins[] = { {pinmux (4 ),2 ,2 },
@@ -102,6 +128,14 @@ int board_init(void)if (davinci_configure_pin_mux_items (pinmuxes,ARRAY_SIZE (pinmuxes)))return 1 ; +#ifdef CONFIG_DRIVER_TI_EMAC +if (davinci_configure_pin_mux (emac_pins,ARRAY_SIZE (emac_pins)) !=0 ) +return 1 ; +/* set cfgchip3 to select MII */ +writel (readl (&davinci_syscfg_regs->cfgchip3) & ~(1 <<8 ), + &davinci_syscfg_regs->cfgchip3); +#endif /* CONFIG_DRIVER_TI_EMAC */ +/* enable the console UART */ writel((DAVINCI_UART_PWREMU_MGMT_FREE | DAVINCI_UART_PWREMU_MGMT_URRST | DAVINCI_UART_PWREMU_MGMT_UTRST),
@@ -109,3 +143,19 @@ int board_init(void)return 0 ; } + +#ifdef CONFIG_DRIVER_TI_EMAC + +/* +* Initializes on-board ethernet controllers. +*/ +int board_eth_init (bd_t *bis) +{ +if (!davinci_emac_initialize ()) { +printf ("Error: Ethernet init failed!\n" ); +return -1 ; + } + +return 0 ; +} +#endif /* CONFIG_DRIVER_TI_EMAC */
include/configs/da850evm.h +15 -0
@@ -26,6 +26,7 @@/* * Board */ +#define CONFIG_DRIVER_TI_EMAC /* * SoC Configuration
@@ -79,6 +80,20 @@#define CONFIG_SYS_I2C_SLAVE 10/* Bogus, master-only in U-Boot */ /* +* Network & Ethernet Configuration +*/ +#ifdef CONFIG_DRIVER_TI_EMAC +#define CONFIG_EMAC_MDIO_PHY_NUM 0 +#define CONFIG_MII +#define CONFIG_BOOTP_DEFAULT +#define CONFIG_BOOTP_DNS +#define CONFIG_BOOTP_DNS2 +#define CONFIG_BOOTP_SEND_HOSTNAME +#define CONFIG_NET_RETRY_COUNT 10 +#define CONFIG_NET_MULTI +#endif + +/* * U-Boot general configuration */ #define CONFIG_BOOTFILE "uImage"/* Boot file name */
Signature · 1 line
1.7.0.4
PATCH v3 2/2 da850evm: basic MII EMAC support
Quoted 1 line · On Wednesday, September 22, 2010 13:16:49 Ben Gardiner wrote:
+const struct
pinmux_configemac_pins[] = {
seems to only be used in this file ? mark it static too ?
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20100922/aaa13354/attachment.pgp
PATCH v3 2/2 da850evm: basic MII EMAC support
Hi Mike,
Quoted 5 lines · Mike Frysinger
Quoted 1 line · On Wednesday, September 22, 2010 13:16:49 Ben Gardiner wrote:
+const struct
pinmux_configemac_pins[] = {seems to only be used in this file ? ?mark it static too ? -mike
Good catch. It definitely should be static.
Best Regards,
Ben Gardiner
---
Nanometrics Inc.
http://www.nanometrics.ca
v4 cover da850evm basic MII EMAC support
In reply to Ben GardinerThis patch series proposes to add basic MII support to the da850evm; the first patch in the series refactors davinci EMAC setup. The second patch in the series enables MII support.
Ben Gardiner (2):
[NEXT] davinci_emac: davinci_eth_set_mac_addr to ->write_hwaddr [NEXT] da850evm: basic MII EMAC support
arch/arm/include/asm/arch-davinci/emac_defs.h | 1 - arch/arm/lib/board.c | 19 ------ board/davinci/common/misc.c | 41 +++---------- board/davinci/common/misc.h | 2 +- board/davinci/da8xxevm/da830evm.c | 15 ++++- board/davinci/da8xxevm/da850evm.c | 50 +++++++++++++++ board/davinci/dm365evm/dm365evm.c | 2 +- board/davinci/dvevm/dvevm.c | 2 +- board/davinci/sffsdr/sffsdr.c | 2 +- board/davinci/sonata/sonata.c | 2 +- drivers/net/davinci_emac.c | 80 ++++++++++++------------- include/configs/da850evm.h | 15 +++++ 12 files changed, 129 insertions(+), 102 deletions(-)
---
V4:
* make the emac_pins static
V3:
* rebased to u-boot/next
* removed additional direct call of davinci_eth_set_mac_addr added to board_init_r by Heiko's relocation patches
V2:
* added patch 1/2 to refactor davinci_emac setup
* added SOB to 2/2
Tested on da850evm with MII PHY on baseboard.
PATCH v4 1/2 davinci_emac: davinci_eth_set_mac_addr to ->write_hwaddr
This patch proposes to migrate the davinci_emac driver to using the eth_device->write_hwaddr function pointer as suggested by Ben Warren.
All the davinci boards had the behaviour, prior to this patch, of sync'ing the environment variable enetaddr with the MAC address read from non-volatile storage on boot -- when the two locations disagreed, the environment variable value took precendence. This patch keeps the same behaviour but lets eth_initialize take care of it.
This patch refactors davinci_emac setup in the boards so that the MAC address is read from non-volatile storage into the environment variable and then the environment variable value is use in eth_intialize. The only exception is the direct call to davinci_eth_set_mac_addr made by the da830evm board init which was changed into an assignment of the enetaddr field.
--
V4:
* no changes
V3:
* rebased to u-boot/next, removed additional direct call of davinci_eth_set_mac_addr added to board_init_r by Heiko's relocation patches
V2:
* introduced this patch
--- arch/arm/include/asm/arch-davinci/emac_defs.h | 1 - arch/arm/lib/board.c | 19 ------ board/davinci/common/misc.c | 41 +++---------- board/davinci/common/misc.h | 2 +- board/davinci/da8xxevm/da830evm.c | 15 ++++- board/davinci/dm365evm/dm365evm.c | 2 +- board/davinci/dvevm/dvevm.c | 2 +- board/davinci/sffsdr/sffsdr.c | 2 +- board/davinci/sonata/sonata.c | 2 +- drivers/net/davinci_emac.c | 80 ++++++++++++------------- 10 files changed, 64 insertions(+), 102 deletions(-)
arch/arm/include/asm/arch-davinci/emac_defs.h +0 -1
@@ -367,7 +367,6 @@ typedef struct {int davinci_eth_phy_read (u_int8_t phy_addr,u_int8_t reg_num,u_int16_t *data);int davinci_eth_phy_write (u_int8_t phy_addr,u_int8_t reg_num,u_int16_t data); -void davinci_eth_set_mac_addr (const u_int8_t *addr); typedef struct {
arch/arm/lib/board.c +0 -19
@@ -409,15 +409,6 @@ void start_armboot (void)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 */
@@ -821,16 +812,6 @@ void board_init_r (gd_t *id, ulong dest_addr)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 +9 -32
54 lines not on this page · raw message
board/davinci/common/misc.h +1 -1
@@ -46,7 +46,7 @@ struct pinmux_resource { }int dvevm_read_mac_address (uint8_t *buf); -void dv_configure_mac_address (uint8_t *rom_enetaddr); +void davinci_sync_env_enetaddr (uint8_t *rom_enetaddr);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/da8xxevm/da830evm.c +11 -4
@@ -196,19 +196,17 @@ int board_eth_init(bd_t *bis) {u_int8_t mac_addr[6 ];u_int8_t switch_start_cmd[2 ] = {0x01 ,0x23 }; +struct eth_device *dev;/* Read Ethernet MAC address from EEPROM */ if (dvevm_read_mac_address (mac_addr))/* set address env if not already set */ -dv_configure_mac_address (mac_addr); +davinci_sync_env_enetaddr (mac_addr);/* read the address back from env */ if (!eth_getenv_enetaddr ("ethaddr" , mac_addr))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 , switch_start_cmd,sizeof (switch_start_cmd))) {
@@ -222,6 +220,15 @@ int board_eth_init(bd_t *bis) return -1; } + dev =eth_get_dev (); + +/* provide the resulting addr to the driver */ +memcpy (dev->enetaddr, mac_addr,6 ); +if (!dev->write_hwaddr (dev)) { +printf ("Error: Could not set MAC address\n" ); +return -1 ; + } +return 0 ; }#endif /* CONFIG_DRIVER_TI_EMAC */
board/davinci/dm365evm/dm365evm.c +1 -1
@@ -68,7 +68,7 @@ int board_eth_init(bd_t *bis)/* Read Ethernet MAC address from EEPROM */ if (dvevm_read_mac_address (eeprom_enetaddr)) -dv_configure_mac_address (eeprom_enetaddr); +davinci_sync_env_enetaddr (eeprom_enetaddr);davinci_emac_initialize ();
board/davinci/dvevm/dvevm.c +1 -1
@@ -71,7 +71,7 @@ int misc_init_r(void)/* Read Ethernet MAC address from EEPROM if available. */ if (dvevm_read_mac_address (eeprom_enetaddr)) -dv_configure_mac_address (eeprom_enetaddr); +davinci_sync_env_enetaddr (eeprom_enetaddr);i2c_read (0x39 ,0x00 ,1 , &video_mode,1 );
board/davinci/sffsdr/sffsdr.c +1 -1
@@ -141,7 +141,7 @@ int misc_init_r(void)/* Read Ethernet MAC address from EEPROM if available. */ if (sffsdr_read_mac_address (eeprom_enetaddr)) -dv_configure_mac_address (eeprom_enetaddr); +davinci_sync_env_enetaddr (eeprom_enetaddr);return (0 ); }
board/davinci/sonata/sonata.c +1 -1
@@ -70,7 +70,7 @@ int misc_init_r(void)/* Read Ethernet MAC address from EEPROM if available. */ if (dvevm_read_mac_address (eeprom_enetaddr)) -dv_configure_mac_address (eeprom_enetaddr); +davinci_sync_env_enetaddr (eeprom_enetaddr);return (0 ); }
drivers/net/davinci_emac.c +39 -41
110 lines not on this page · raw message
Signature · 1 line
1.7.0.4
PATCH v4 1/2 davinci_emac: davinci_eth_set_mac_addr to ->write_hwaddr
Quoted 43 lines · Ben Gardiner
This patch proposes to migrate the
davinci_emacdriver to using theeth_device->write_hwaddrfunction pointer as suggested by Ben Warren.All the davinci boards had the behaviour, prior to this patch, of sync'ing the environment variable enetaddr with the MAC address read from non-volatile storage on boot -- when the two locations disagreed, the environment variable value took precendence. This patch keeps the same behaviour but lets
eth_initializetake care of it.This patch refactors
davinci_emacsetup in the boards so that the MAC address is read from non-volatile storage into the environment variable and then the environment variable value is use ineth_intialize. The only exception is the direct call todavinci_eth_set_mac_addrmade by the da830evm board init which was changed into an assignment of the enetaddr field.Signed-off-by Ben Gardiner <[email protected]>CC Ben Warren <[email protected]>CC Nick Thompson <[email protected]>--
V4:
* no changes
V3:
* rebased to u-boot/next, removed additional direct call ofdavinci_eth_set_mac_addradded toboard_init_rby Heiko's relocation patches
V2:
* introduced this patch--- arch/arm/include/asm/arch-davinci/emac_defs.h | 1 - arch/arm/lib/board.c | 19 ------ board/davinci/common/misc.c | 41 +++---------- board/davinci/common/misc.h | 2 +- board/davinci/da8xxevm/da830evm.c | 15 ++++- board/davinci/dm365evm/dm365evm.c | 2 +- board/davinci/dvevm/dvevm.c | 2 +- board/davinci/sffsdr/sffsdr.c | 2 +- board/davinci/sonata/sonata.c | 2 +- drivers/net/davinci_emac.c | 80 ++++++++++++------------- 10 files changed, 64 insertions(+), 102 deletions(-)
[snip]
Quoted 32 lines
board/davinci/da8xxevm/da830evm.c +4
-4@@ -196,19 +196,17 @@ int board_eth_init(bd_t *bis) {u_int8_t mac_addr[6 ];u_int8_t switch_start_cmd[2 ] = {0x01 ,0x23 }; +struct eth_device *dev;/* Read Ethernet MAC address from EEPROM */ if (dvevm_read_mac_address (mac_addr))/* set address env if not already set */ -dv_configure_mac_address (mac_addr); +davinci_sync_env_enetaddr (mac_addr);/* read the address back from env */ if (!eth_getenv_enetaddr ("ethaddr" , mac_addr))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 , switch_start_cmd,sizeof (switch_start_cmd))) {@@ -222,6 +220,15 @@ int board_eth_init(bd_t *bis)return -1 ; } + dev =eth_get_dev (); +
board/davinci/da8xxevm/da830evm.c int board_eth_init(bd_t *bis) · line 234
Quoted 10 lines
board/davinci/da8xxevm/da830evm.c +7
-0+/* provide the resulting addr to the driver */ +memcpy (dev->enetaddr, mac_addr,6 ); +if (!dev->write_hwaddr (dev)) { +printf ("Error: Could not set MAC address\n" ); +return -1 ; + } + return 0; }#endif /* CONFIG_DRIVER_TI_EMAC */
Hi Ben,
davinci_eth_set_mac_addr() always returns zero, so "if (!dev->write_hwaddr(dev))" always appears to fail here.
In net/eth.c the return code is not checked, so da830 should probably ignore it to:
board/davinci/da8xxevm/da830evm.c +1 -4
@@ -224,10 +224,7 @@ int board_eth_init(bd_t *bis)/* provide the resulting addr to the driver */ memcpy (dev->enetaddr, mac_addr,6 ); -if (!dev->write_hwaddr (dev)) { -printf ("Error: Could not set MAC address\n" ); -return -1 ; - } + dev->write_hwaddr (dev);return 0 ; }
With this change, this patch works on da830. I'll retest when you resubmit.
Nick.
PATCH v4 1/2 davinci_emac: davinci_eth_set_mac_addr to ->write_hwaddr
Quoted 4 lines · Nick Thompson
davinci_eth_set_mac_addr()always returns zero, so "if (!dev->write_hwaddr(dev))" always appears to fail here.In
net/eth.cthe return code is not checked, so da830 should probably ignore it to:
You're absolutely right, Nick. Thanks for the review and testing; patch coming.
Best Regards,
Ben Gardiner
---
Nanometrics Inc.
http://www.nanometrics.ca
PATCH v4 2/2 da850evm: basic MII EMAC support
In reply to Ben GardinerThe current da850evm support in u-boot/master omits any use of the davinci EMAC. This patch adds basic support for the EMAC using the MII PHY found on the baseboard of the EVM. The MAC address is read from the environment variable 'ethadd'. Note that this is different from the da850evm support in the u-boot omapl1 tree where the MAC address is read from SPI flash.
---
V4:
* make the emac_pins static
V3:
* rebased to u-boot/next
V2:
* added SOB
* renumbered this patch from 1/1 to 2/2
* just initialize the driver and let eth_initialize() take care of setting the MAC address from the environment variable enetaddr
--- board/davinci/da8xxevm/da850evm.c | 50 +++++++++++++++++++++++++++++++++++++ include/configs/da850evm.h | 15 +++++++++++ 2 files changed, 65 insertions(+), 0 deletions(-)
board/davinci/da8xxevm/da850evm.c +50 -0
@@ -23,7 +23,11 @@#include <common.h> #include <i2c.h> +#include <net.h> +#include <netdev.h> #include <asm/arch/hardware.h> +#include <asm/arch/emif_defs.h> +#include <asm/arch/emac_defs.h> #include <asm/io.h> #include "../common/misc.h" #include "common.h"
@@ -48,6 +52,28 @@ static const struct pinmux_config uart_pins[] = { { pinmux(4), 2, 5 } }; +#ifdef CONFIG_DRIVER_TI_EMAC +static const struct pinmux_config emac_pins[] = { + {pinmux (2 ),8 ,1 }, + {pinmux (2 ),8 ,2 }, + {pinmux (2 ),8 ,3 }, + {pinmux (2 ),8 ,4 }, + {pinmux (2 ),8 ,5 }, + {pinmux (2 ),8 ,6 }, + {pinmux (2 ),8 ,7 }, + {pinmux (3 ),8 ,0 }, + {pinmux (3 ),8 ,1 }, + {pinmux (3 ),8 ,2 }, + {pinmux (3 ),8 ,3 }, + {pinmux (3 ),8 ,4 }, + {pinmux (3 ),8 ,5 }, + {pinmux (3 ),8 ,6 }, + {pinmux (3 ),8 ,7 }, + {pinmux (4 ),8 ,0 }, + {pinmux (4 ),8 ,1 } +}; +#endif /* CONFIG_DRIVER_TI_EMAC */ +/* I2C pin muxer settings */ static const struct pinmux_config i2c_pins[] = { {pinmux (4 ),2 ,2 },
@@ -102,6 +128,14 @@ int board_init(void)if (davinci_configure_pin_mux_items (pinmuxes,ARRAY_SIZE (pinmuxes)))return 1 ; +#ifdef CONFIG_DRIVER_TI_EMAC +if (davinci_configure_pin_mux (emac_pins,ARRAY_SIZE (emac_pins)) !=0 ) +return 1 ; +/* set cfgchip3 to select MII */ +writel (readl (&davinci_syscfg_regs->cfgchip3) & ~(1 <<8 ), + &davinci_syscfg_regs->cfgchip3); +#endif /* CONFIG_DRIVER_TI_EMAC */ +/* enable the console UART */ writel((DAVINCI_UART_PWREMU_MGMT_FREE | DAVINCI_UART_PWREMU_MGMT_URRST | DAVINCI_UART_PWREMU_MGMT_UTRST),
@@ -109,3 +143,19 @@ int board_init(void)return 0 ; } + +#ifdef CONFIG_DRIVER_TI_EMAC + +/* +* Initializes on-board ethernet controllers. +*/ +int board_eth_init (bd_t *bis) +{ +if (!davinci_emac_initialize ()) { +printf ("Error: Ethernet init failed!\n" ); +return -1 ; + } + +return 0 ; +} +#endif /* CONFIG_DRIVER_TI_EMAC */
include/configs/da850evm.h +15 -0
@@ -26,6 +26,7 @@/* * Board */ +#define CONFIG_DRIVER_TI_EMAC /* * SoC Configuration
@@ -79,6 +80,20 @@#define CONFIG_SYS_I2C_SLAVE 10/* Bogus, master-only in U-Boot */ /* +* Network & Ethernet Configuration +*/ +#ifdef CONFIG_DRIVER_TI_EMAC +#define CONFIG_EMAC_MDIO_PHY_NUM 0 +#define CONFIG_MII +#define CONFIG_BOOTP_DEFAULT +#define CONFIG_BOOTP_DNS +#define CONFIG_BOOTP_DNS2 +#define CONFIG_BOOTP_SEND_HOSTNAME +#define CONFIG_NET_RETRY_COUNT 10 +#define CONFIG_NET_MULTI +#endif + +/* * U-Boot general configuration */ #define CONFIG_BOOTFILE "uImage"/* Boot file name */
Signature · 1 line
1.7.0.4
v5 cover da850evm basic MII EMAC support
In reply to Ben GardinerThis patch series proposes to add basic MII support to the da850evm; the first patch in the series refactors davinci EMAC setup. The second patch in the series enables MII support.
Ben Gardiner (2):
[NEXT] davinci_emac: davinci_eth_set_mac_addr to ->write_hwaddr [NEXT] da850evm: basic MII EMAC support
arch/arm/include/asm/arch-davinci/emac_defs.h | 1 - arch/arm/lib/board.c | 19 ------ board/davinci/common/misc.c | 41 +++---------- board/davinci/common/misc.h | 2 +- board/davinci/da8xxevm/da830evm.c | 12 +++- board/davinci/da8xxevm/da850evm.c | 50 +++++++++++++++ board/davinci/dm365evm/dm365evm.c | 2 +- board/davinci/dvevm/dvevm.c | 2 +- board/davinci/sffsdr/sffsdr.c | 2 +- board/davinci/sonata/sonata.c | 2 +- drivers/net/davinci_emac.c | 80 ++++++++++++------------- include/configs/da850evm.h | 15 +++++ 12 files changed, 126 insertions(+), 102 deletions(-)
---
V5:
* don't check return code of write_hwaddr in da830 board setup
V4:
* make the emac_pins static
V3:
* rebased to u-boot/next
* removed additional direct call of davinci_eth_set_mac_addr added to board_init_r by Heiko's relocation patches
V2:
* added patch 1/2 to refactor davinci_emac setup
* added SOB to 2/2
Tested on da850evm with MII PHY on baseboard.
PATCH v5 1/2 davinci_emac: davinci_eth_set_mac_addr to ->write_hwaddr
This patch proposes to migrate the davinci_emac driver to using the eth_device->write_hwaddr function pointer as suggested by Ben Warren.
All the davinci boards had the behaviour, prior to this patch, of sync'ing the environment variable enetaddr with the MAC address read from non-volatile storage on boot -- when the two locations disagreed, the environment variable value took precendence. This patch keeps the same behaviour but lets eth_initialize take care of it.
This patch refactors davinci_emac setup in the boards so that the MAC address is read from non-volatile storage into the environment variable and then the environment variable value is use in eth_intialize. The only exception is the direct call to davinci_eth_set_mac_addr made by the da830evm board init which was changed into an assignment of the enetaddr field.
--
V5:
* don't check return code of write_hwaddr in da830 board setup
V4:
* No change
V3:
* rebased to u-boot/next, removed additional direct call of davinci_eth_set_mac_addr added to board_init_r by Heiko's relocation patches
V2:
* introduced this patch
--- arch/arm/include/asm/arch-davinci/emac_defs.h | 1 - arch/arm/lib/board.c | 19 ------ board/davinci/common/misc.c | 41 +++---------- board/davinci/common/misc.h | 2 +- board/davinci/da8xxevm/da830evm.c | 12 +++- board/davinci/dm365evm/dm365evm.c | 2 +- board/davinci/dvevm/dvevm.c | 2 +- board/davinci/sffsdr/sffsdr.c | 2 +- board/davinci/sonata/sonata.c | 2 +- drivers/net/davinci_emac.c | 80 ++++++++++++------------- 10 files changed, 61 insertions(+), 102 deletions(-)
arch/arm/include/asm/arch-davinci/emac_defs.h +0 -1
@@ -367,7 +367,6 @@ typedef struct {int davinci_eth_phy_read (u_int8_t phy_addr,u_int8_t reg_num,u_int16_t *data);int davinci_eth_phy_write (u_int8_t phy_addr,u_int8_t reg_num,u_int16_t data); -void davinci_eth_set_mac_addr (const u_int8_t *addr); typedef struct {
arch/arm/lib/board.c +0 -19
@@ -409,15 +409,6 @@ void start_armboot (void)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 */
@@ -821,16 +812,6 @@ void board_init_r (gd_t *id, ulong dest_addr)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 +9 -32
54 lines not on this page · raw message
board/davinci/common/misc.h +1 -1
@@ -46,7 +46,7 @@ struct pinmux_resource { }int dvevm_read_mac_address (uint8_t *buf); -void dv_configure_mac_address (uint8_t *rom_enetaddr); +void davinci_sync_env_enetaddr (uint8_t *rom_enetaddr);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/da8xxevm/da830evm.c +8 -4
@@ -196,19 +196,17 @@ int board_eth_init(bd_t *bis) {u_int8_t mac_addr[6 ];u_int8_t switch_start_cmd[2 ] = {0x01 ,0x23 }; +struct eth_device *dev;/* Read Ethernet MAC address from EEPROM */ if (dvevm_read_mac_address (mac_addr))/* set address env if not already set */ -dv_configure_mac_address (mac_addr); +davinci_sync_env_enetaddr (mac_addr);/* read the address back from env */ if (!eth_getenv_enetaddr ("ethaddr" , mac_addr))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 , switch_start_cmd,sizeof (switch_start_cmd))) {
@@ -222,6 +220,12 @@ int board_eth_init(bd_t *bis) return -1; } + dev =eth_get_dev (); + +/* provide the resulting addr to the driver */ +memcpy (dev->enetaddr, mac_addr,6 ); + dev->write_hwaddr (dev); +return 0 ; }#endif /* CONFIG_DRIVER_TI_EMAC */
board/davinci/dm365evm/dm365evm.c +1 -1
@@ -68,7 +68,7 @@ int board_eth_init(bd_t *bis)/* Read Ethernet MAC address from EEPROM */ if (dvevm_read_mac_address (eeprom_enetaddr)) -dv_configure_mac_address (eeprom_enetaddr); +davinci_sync_env_enetaddr (eeprom_enetaddr);davinci_emac_initialize ();
board/davinci/dvevm/dvevm.c +1 -1
@@ -71,7 +71,7 @@ int misc_init_r(void)/* Read Ethernet MAC address from EEPROM if available. */ if (dvevm_read_mac_address (eeprom_enetaddr)) -dv_configure_mac_address (eeprom_enetaddr); +davinci_sync_env_enetaddr (eeprom_enetaddr);i2c_read (0x39 ,0x00 ,1 , &video_mode,1 );
board/davinci/sffsdr/sffsdr.c +1 -1
@@ -141,7 +141,7 @@ int misc_init_r(void)/* Read Ethernet MAC address from EEPROM if available. */ if (sffsdr_read_mac_address (eeprom_enetaddr)) -dv_configure_mac_address (eeprom_enetaddr); +davinci_sync_env_enetaddr (eeprom_enetaddr);return (0 ); }
board/davinci/sonata/sonata.c +1 -1
@@ -70,7 +70,7 @@ int misc_init_r(void)/* Read Ethernet MAC address from EEPROM if available. */ if (dvevm_read_mac_address (eeprom_enetaddr)) -dv_configure_mac_address (eeprom_enetaddr); +davinci_sync_env_enetaddr (eeprom_enetaddr);return (0 ); }
drivers/net/davinci_emac.c +39 -41
110 lines not on this page · raw message
Signature · 1 line
1.7.0.4
PATCH v5 1/2 davinci_emac: davinci_eth_set_mac_addr to ->write_hwaddr
Quoted 20 lines · Ben Gardiner
This patch proposes to migrate the
davinci_emacdriver to using theeth_device->write_hwaddrfunction pointer as suggested by Ben Warren.All the davinci boards had the behaviour, prior to this patch, of sync'ing the environment variable enetaddr with the MAC address read from non-volatile storage on boot -- when the two locations disagreed, the environment variable value took precendence. This patch keeps the same behaviour but lets
eth_initializetake care of it.This patch refactors
davinci_emacsetup in the boards so that the MAC address is read from non-volatile storage into the environment variable and then the environment variable value is use ineth_intialize. The only exception is the direct call todavinci_eth_set_mac_addrmade by the da830evm board init which was changed into an assignment of the enetaddr field.Signed-off-by Ben Gardiner <[email protected]>CC Ben Warren <[email protected]>CC Nick Thompson <[email protected]>
Quoted 12 lines
--
V5:
* don't check return code ofwrite_hwaddrin da830 board setup
V4:
* No change
V3:
* rebased to u-boot/next, removed additional direct call ofdavinci_eth_set_mac_addradded toboard_init_rby Heiko's relocation patches
V2:
* introduced this patch
---
Shouldn't this version information go below the '---' line. As it is, it appears in the log message after using 'git am' to apply. Sorry, I should have noticed that earlier.
Patch works correctly on da830evm.
Thanks,
Nick.
PATCH v5 1/2 davinci_emac: davinci_eth_set_mac_addr to ->write_hwaddr
Quoted 3 lines · Nick Thompson
Shouldn't this version information go below the '---' line. As it is, it appears in the log message after using 'git am' to apply. Sorry, I should have noticed that earlier.
Yeah, I'm missing a third '-' there.
No need to apologize -- I appreciate the thorough review. One more update on the way.
Best Regards,
Ben Gardiner
---
Nanometrics Inc.
http://www.nanometrics.ca
PATCH v5 2/2 da850evm: basic MII EMAC support
In reply to Ben GardinerThe current da850evm support in u-boot/master omits any use of the davinci EMAC. This patch adds basic support for the EMAC using the MII PHY found on the baseboard of the EVM. The MAC address is read from the environment variable 'ethadd'. Note that this is different from the da850evm support in the u-boot omapl1 tree where the MAC address is read from SPI flash.
---
V5:
* no changes
V4:
* make the emac_pins static
V3:
* rebased to u-boot/next
V2:
* added SOB
* renumbered this patch from 1/1 to 2/2
* just initialize the driver and let eth_initialize() take care of setting the MAC address from the environment variable enetaddr
--- board/davinci/da8xxevm/da850evm.c | 50 +++++++++++++++++++++++++++++++++++++ include/configs/da850evm.h | 15 +++++++++++ 2 files changed, 65 insertions(+), 0 deletions(-)
board/davinci/da8xxevm/da850evm.c +50 -0
@@ -23,7 +23,11 @@#include <common.h> #include <i2c.h> +#include <net.h> +#include <netdev.h> #include <asm/arch/hardware.h> +#include <asm/arch/emif_defs.h> +#include <asm/arch/emac_defs.h> #include <asm/io.h> #include "../common/misc.h" #include "common.h"
@@ -48,6 +52,28 @@ static const struct pinmux_config uart_pins[] = { { pinmux(4), 2, 5 } }; +#ifdef CONFIG_DRIVER_TI_EMAC +static const struct pinmux_config emac_pins[] = { + {pinmux (2 ),8 ,1 }, + {pinmux (2 ),8 ,2 }, + {pinmux (2 ),8 ,3 }, + {pinmux (2 ),8 ,4 }, + {pinmux (2 ),8 ,5 }, + {pinmux (2 ),8 ,6 }, + {pinmux (2 ),8 ,7 }, + {pinmux (3 ),8 ,0 }, + {pinmux (3 ),8 ,1 }, + {pinmux (3 ),8 ,2 }, + {pinmux (3 ),8 ,3 }, + {pinmux (3 ),8 ,4 }, + {pinmux (3 ),8 ,5 }, + {pinmux (3 ),8 ,6 }, + {pinmux (3 ),8 ,7 }, + {pinmux (4 ),8 ,0 }, + {pinmux (4 ),8 ,1 } +}; +#endif /* CONFIG_DRIVER_TI_EMAC */ +/* I2C pin muxer settings */ static const struct pinmux_config i2c_pins[] = { {pinmux (4 ),2 ,2 },
@@ -102,6 +128,14 @@ int board_init(void)if (davinci_configure_pin_mux_items (pinmuxes,ARRAY_SIZE (pinmuxes)))return 1 ; +#ifdef CONFIG_DRIVER_TI_EMAC +if (davinci_configure_pin_mux (emac_pins,ARRAY_SIZE (emac_pins)) !=0 ) +return 1 ; +/* set cfgchip3 to select MII */ +writel (readl (&davinci_syscfg_regs->cfgchip3) & ~(1 <<8 ), + &davinci_syscfg_regs->cfgchip3); +#endif /* CONFIG_DRIVER_TI_EMAC */ +/* enable the console UART */ writel((DAVINCI_UART_PWREMU_MGMT_FREE | DAVINCI_UART_PWREMU_MGMT_URRST | DAVINCI_UART_PWREMU_MGMT_UTRST),
@@ -109,3 +143,19 @@ int board_init(void)return 0 ; } + +#ifdef CONFIG_DRIVER_TI_EMAC + +/* +* Initializes on-board ethernet controllers. +*/ +int board_eth_init (bd_t *bis) +{ +if (!davinci_emac_initialize ()) { +printf ("Error: Ethernet init failed!\n" ); +return -1 ; + } + +return 0 ; +} +#endif /* CONFIG_DRIVER_TI_EMAC */
include/configs/da850evm.h +15 -0
@@ -26,6 +26,7 @@/* * Board */ +#define CONFIG_DRIVER_TI_EMAC /* * SoC Configuration
@@ -79,6 +80,20 @@#define CONFIG_SYS_I2C_SLAVE 10/* Bogus, master-only in U-Boot */ /* +* Network & Ethernet Configuration +*/ +#ifdef CONFIG_DRIVER_TI_EMAC +#define CONFIG_EMAC_MDIO_PHY_NUM 0 +#define CONFIG_MII +#define CONFIG_BOOTP_DEFAULT +#define CONFIG_BOOTP_DNS +#define CONFIG_BOOTP_DNS2 +#define CONFIG_BOOTP_SEND_HOSTNAME +#define CONFIG_NET_RETRY_COUNT 10 +#define CONFIG_NET_MULTI +#endif + +/* * U-Boot general configuration */ #define CONFIG_BOOTFILE "uImage"/* Boot file name */
Signature · 1 line
1.7.0.4
v6 cover da850evm basic MII EMAC support
In reply to Ben GardinerThis patch series proposes to add basic MII support to the da850evm; the first patch in the series refactors davinci EMAC setup. The second patch in the series enables MII support.
Ben Gardiner (2):
[NEXT] davinci_emac: davinci_eth_set_mac_addr to ->write_hwaddr [NEXT] da850evm: basic MII EMAC support
arch/arm/include/asm/arch-davinci/emac_defs.h | 1 - arch/arm/lib/board.c | 19 ------ board/davinci/common/misc.c | 41 +++---------- board/davinci/common/misc.h | 2 +- board/davinci/da8xxevm/da830evm.c | 12 +++- board/davinci/da8xxevm/da850evm.c | 50 +++++++++++++++ board/davinci/dm365evm/dm365evm.c | 2 +- board/davinci/dvevm/dvevm.c | 2 +- board/davinci/sffsdr/sffsdr.c | 2 +- board/davinci/sonata/sonata.c | 2 +- drivers/net/davinci_emac.c | 80 ++++++++++++------------- include/configs/da850evm.h | 15 +++++ 12 files changed, 126 insertions(+), 102 deletions(-)
---
V6:
* fix tear-line
V5:
* don't check return code of write_hwaddr in da830 board setup
V4:
* make the emac_pins static
V3:
* rebased to u-boot/next
* removed additional direct call of davinci_eth_set_mac_addr added to board_init_r by Heiko's relocation patches
V2:
* added patch 1/2 to refactor davinci_emac setup
* added SOB to 2/2
Tested on da850evm with MII PHY on baseboard.
PATCH v6 1/2 davinci_emac: davinci_eth_set_mac_addr to ->write_hwaddr
This patch proposes to migrate the davinci_emac driver to using the eth_device->write_hwaddr function pointer as suggested by Ben Warren.
All the davinci boards had the behaviour, prior to this patch, of sync'ing the environment variable enetaddr with the MAC address read from non-volatile storage on boot -- when the two locations disagreed, the environment variable value took precendence. This patch keeps the same behaviour but lets eth_initialize take care of it.
This patch refactors davinci_emac setup in the boards so that the MAC address is read from non-volatile storage into the environment variable and then the environment variable value is use in eth_intialize. The only exception is the direct call to davinci_eth_set_mac_addr made by the da830evm board init which was changed into an assignment of the enetaddr field.
---
V6:
* fix tear-line
V5:
* don't check return code of write_hwaddr in da830 board setup
V4:
* No change
V3:
* rebased to u-boot/next, removed additional direct call of davinci_eth_set_mac_addr added to board_init_r by Heiko's relocation patches
V2:
* introduced this patch
--- arch/arm/include/asm/arch-davinci/emac_defs.h | 1 - arch/arm/lib/board.c | 19 ------ board/davinci/common/misc.c | 41 +++---------- board/davinci/common/misc.h | 2 +- board/davinci/da8xxevm/da830evm.c | 12 +++- board/davinci/dm365evm/dm365evm.c | 2 +- board/davinci/dvevm/dvevm.c | 2 +- board/davinci/sffsdr/sffsdr.c | 2 +- board/davinci/sonata/sonata.c | 2 +- drivers/net/davinci_emac.c | 80 ++++++++++++------------- 10 files changed, 61 insertions(+), 102 deletions(-)
arch/arm/include/asm/arch-davinci/emac_defs.h +0 -1
@@ -367,7 +367,6 @@ typedef struct {int davinci_eth_phy_read (u_int8_t phy_addr,u_int8_t reg_num,u_int16_t *data);int davinci_eth_phy_write (u_int8_t phy_addr,u_int8_t reg_num,u_int16_t data); -void davinci_eth_set_mac_addr (const u_int8_t *addr); typedef struct {
arch/arm/lib/board.c +0 -19
@@ -409,15 +409,6 @@ void start_armboot (void)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 */
@@ -821,16 +812,6 @@ void board_init_r (gd_t *id, ulong dest_addr)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 +9 -32
54 lines not on this page · raw message
board/davinci/common/misc.h +1 -1
@@ -46,7 +46,7 @@ struct pinmux_resource { }int dvevm_read_mac_address (uint8_t *buf); -void dv_configure_mac_address (uint8_t *rom_enetaddr); +void davinci_sync_env_enetaddr (uint8_t *rom_enetaddr);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/da8xxevm/da830evm.c +8 -4
@@ -196,19 +196,17 @@ int board_eth_init(bd_t *bis) {u_int8_t mac_addr[6 ];u_int8_t switch_start_cmd[2 ] = {0x01 ,0x23 }; +struct eth_device *dev;/* Read Ethernet MAC address from EEPROM */ if (dvevm_read_mac_address (mac_addr))/* set address env if not already set */ -dv_configure_mac_address (mac_addr); +davinci_sync_env_enetaddr (mac_addr);/* read the address back from env */ if (!eth_getenv_enetaddr ("ethaddr" , mac_addr))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 , switch_start_cmd,sizeof (switch_start_cmd))) {
@@ -222,6 +220,12 @@ int board_eth_init(bd_t *bis) return -1; } + dev =eth_get_dev (); + +/* provide the resulting addr to the driver */ +memcpy (dev->enetaddr, mac_addr,6 ); + dev->write_hwaddr (dev); +return 0 ; }#endif /* CONFIG_DRIVER_TI_EMAC */
board/davinci/dm365evm/dm365evm.c +1 -1
@@ -68,7 +68,7 @@ int board_eth_init(bd_t *bis)/* Read Ethernet MAC address from EEPROM */ if (dvevm_read_mac_address (eeprom_enetaddr)) -dv_configure_mac_address (eeprom_enetaddr); +davinci_sync_env_enetaddr (eeprom_enetaddr);davinci_emac_initialize ();
board/davinci/dvevm/dvevm.c +1 -1
@@ -71,7 +71,7 @@ int misc_init_r(void)/* Read Ethernet MAC address from EEPROM if available. */ if (dvevm_read_mac_address (eeprom_enetaddr)) -dv_configure_mac_address (eeprom_enetaddr); +davinci_sync_env_enetaddr (eeprom_enetaddr);i2c_read (0x39 ,0x00 ,1 , &video_mode,1 );
board/davinci/sffsdr/sffsdr.c +1 -1
@@ -141,7 +141,7 @@ int misc_init_r(void)/* Read Ethernet MAC address from EEPROM if available. */ if (sffsdr_read_mac_address (eeprom_enetaddr)) -dv_configure_mac_address (eeprom_enetaddr); +davinci_sync_env_enetaddr (eeprom_enetaddr);return (0 ); }
board/davinci/sonata/sonata.c +1 -1
@@ -70,7 +70,7 @@ int misc_init_r(void)/* Read Ethernet MAC address from EEPROM if available. */ if (dvevm_read_mac_address (eeprom_enetaddr)) -dv_configure_mac_address (eeprom_enetaddr); +davinci_sync_env_enetaddr (eeprom_enetaddr);return (0 ); }
drivers/net/davinci_emac.c +39 -41
110 lines not on this page · raw message
Signature · 1 line
1.7.0.4
PATCH v6 1/2 davinci_emac: davinci_eth_set_mac_addr to ->write_hwaddr
Hi Ben,
Quoted 16 lines · Ben Gardiner
This patch proposes to migrate the
davinci_emacdriver to using theeth_device->write_hwaddrfunction pointer as suggested by Ben Warren.All the davinci boards had the behaviour, prior to this patch, of sync'ing the environment variable enetaddr with the MAC address read from non-volatile storage on boot -- when the two locations disagreed, the environment variable value took precendence. This patch keeps the same behaviour but lets
eth_initializetake care of it.This patch refactors
davinci_emacsetup in the boards so that the MAC address is read from non-volatile storage into the environment variable and then the environment variable value is use ineth_intialize. The only exception is the direct call todavinci_eth_set_mac_addrmade by the da830evm board init which was changed into an assignment of the enetaddr field.
Quoted 4 lines
Signed-off-by Ben Gardiner<[email protected]>Tested-by Nick Thompson<[email protected]>CC Ben Warren<[email protected]>
Added to net repo.
regards,
Ben
PATCH v6 2/2 da850evm: basic MII EMAC support
In reply to Ben GardinerThe current da850evm support in u-boot/master omits any use of the davinci EMAC. This patch adds basic support for the EMAC using the MII PHY found on the baseboard of the EVM. The MAC address is read from the environment variable 'ethadd'. Note that this is different from the da850evm support in the u-boot omapl1 tree where the MAC address is read from SPI flash.
---
V6:
* no change
V5:
* no change
V4:
* make the emac_pins static
V3:
* rebased to u-boot/next
V2:
* added SOB
* renumbered this patch from 1/1 to 2/2
* just initialize the driver and let eth_initialize() take care of setting the MAC address from the environment variable enetaddr
--- board/davinci/da8xxevm/da850evm.c | 50 +++++++++++++++++++++++++++++++++++++ include/configs/da850evm.h | 15 +++++++++++ 2 files changed, 65 insertions(+), 0 deletions(-)
board/davinci/da8xxevm/da850evm.c +50 -0
@@ -23,7 +23,11 @@#include <common.h> #include <i2c.h> +#include <net.h> +#include <netdev.h> #include <asm/arch/hardware.h> +#include <asm/arch/emif_defs.h> +#include <asm/arch/emac_defs.h> #include <asm/io.h> #include "../common/misc.h" #include "common.h"
@@ -48,6 +52,28 @@ static const struct pinmux_config uart_pins[] = { { pinmux(4), 2, 5 } }; +#ifdef CONFIG_DRIVER_TI_EMAC +static const struct pinmux_config emac_pins[] = { + {pinmux (2 ),8 ,1 }, + {pinmux (2 ),8 ,2 }, + {pinmux (2 ),8 ,3 }, + {pinmux (2 ),8 ,4 }, + {pinmux (2 ),8 ,5 }, + {pinmux (2 ),8 ,6 }, + {pinmux (2 ),8 ,7 }, + {pinmux (3 ),8 ,0 }, + {pinmux (3 ),8 ,1 }, + {pinmux (3 ),8 ,2 }, + {pinmux (3 ),8 ,3 }, + {pinmux (3 ),8 ,4 }, + {pinmux (3 ),8 ,5 }, + {pinmux (3 ),8 ,6 }, + {pinmux (3 ),8 ,7 }, + {pinmux (4 ),8 ,0 }, + {pinmux (4 ),8 ,1 } +}; +#endif /* CONFIG_DRIVER_TI_EMAC */ +/* I2C pin muxer settings */ static const struct pinmux_config i2c_pins[] = { {pinmux (4 ),2 ,2 },
@@ -102,6 +128,14 @@ int board_init(void)if (davinci_configure_pin_mux_items (pinmuxes,ARRAY_SIZE (pinmuxes)))return 1 ; +#ifdef CONFIG_DRIVER_TI_EMAC +if (davinci_configure_pin_mux (emac_pins,ARRAY_SIZE (emac_pins)) !=0 ) +return 1 ; +/* set cfgchip3 to select MII */ +writel (readl (&davinci_syscfg_regs->cfgchip3) & ~(1 <<8 ), + &davinci_syscfg_regs->cfgchip3); +#endif /* CONFIG_DRIVER_TI_EMAC */ +/* enable the console UART */ writel((DAVINCI_UART_PWREMU_MGMT_FREE | DAVINCI_UART_PWREMU_MGMT_URRST | DAVINCI_UART_PWREMU_MGMT_UTRST),
@@ -109,3 +143,19 @@ int board_init(void)return 0 ; } + +#ifdef CONFIG_DRIVER_TI_EMAC + +/* +* Initializes on-board ethernet controllers. +*/ +int board_eth_init (bd_t *bis) +{ +if (!davinci_emac_initialize ()) { +printf ("Error: Ethernet init failed!\n" ); +return -1 ; + } + +return 0 ; +} +#endif /* CONFIG_DRIVER_TI_EMAC */
include/configs/da850evm.h +15 -0
@@ -26,6 +26,7 @@/* * Board */ +#define CONFIG_DRIVER_TI_EMAC /* * SoC Configuration
@@ -79,6 +80,20 @@#define CONFIG_SYS_I2C_SLAVE 10/* Bogus, master-only in U-Boot */ /* +* Network & Ethernet Configuration +*/ +#ifdef CONFIG_DRIVER_TI_EMAC +#define CONFIG_EMAC_MDIO_PHY_NUM 0 +#define CONFIG_MII +#define CONFIG_BOOTP_DEFAULT +#define CONFIG_BOOTP_DNS +#define CONFIG_BOOTP_DNS2 +#define CONFIG_BOOTP_SEND_HOSTNAME +#define CONFIG_NET_RETRY_COUNT 10 +#define CONFIG_NET_MULTI +#endif + +/* * U-Boot general configuration */ #define CONFIG_BOOTFILE "uImage"/* Boot file name */
Signature · 1 line
1.7.0.4