* [U-Boot] [PATCH 0/2] board: ti: am57xx: Set ethernet MAC addresses from EEPROM to env
@ 2016-03-18 11:18 Roger Quadros
2016-03-18 11:18 ` [U-Boot] [PATCH 1/2] net: export eth_setenv_enetaddr_by_index() to net.h Roger Quadros
2016-03-18 11:18 ` [U-Boot] [PATCH 2/2] board: ti: am57xx: Set ethernet MAC addresses from EEPROM to env Roger Quadros
0 siblings, 2 replies; 7+ messages in thread
From: Roger Quadros @ 2016-03-18 11:18 UTC (permalink / raw)
To: u-boot
Hi,
The MAC addresses for the PRU Ethernet ports will be available in the
board EEPROM as an address range. Populate those MAC addresses (if valid)
into the u-boot environment so that they can be passed on to the
device tree during fdt_fixup_ethernet().
cheers,
-roger
Roger Quadros (2):
net: export eth_setenv_enetaddr_by_index() to net.h
board: ti: am57xx: Set ethernet MAC addresses from EEPROM to env
board/ti/am57xx/board.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++
include/net.h | 17 ++++++++++++++++
2 files changed, 70 insertions(+)
--
2.5.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH 1/2] net: export eth_setenv_enetaddr_by_index() to net.h
2016-03-18 11:18 [U-Boot] [PATCH 0/2] board: ti: am57xx: Set ethernet MAC addresses from EEPROM to env Roger Quadros
@ 2016-03-18 11:18 ` Roger Quadros
2016-03-18 13:26 ` Tom Rini
2016-03-27 22:27 ` [U-Boot] [U-Boot, " Tom Rini
2016-03-18 11:18 ` [U-Boot] [PATCH 2/2] board: ti: am57xx: Set ethernet MAC addresses from EEPROM to env Roger Quadros
1 sibling, 2 replies; 7+ messages in thread
From: Roger Quadros @ 2016-03-18 11:18 UTC (permalink / raw)
To: u-boot
Some TI boards (e.g. IDK) have 4 to 6 ethernet ports and
this function is handy at board.c to configure the
MAC address of the ports.
Signed-off-by: Roger Quadros <rogerq@ti.com>
---
include/net.h | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/include/net.h b/include/net.h
index a739f45..03ae232 100644
--- a/include/net.h
+++ b/include/net.h
@@ -237,6 +237,23 @@ void eth_parse_enetaddr(const char *addr, uchar *enetaddr);
int eth_getenv_enetaddr(const char *name, uchar *enetaddr);
int eth_setenv_enetaddr(const char *name, const uchar *enetaddr);
+/**
+ * eth_setenv_enetaddr_by_index() - set the MAC address envrionment variable
+ *
+ * This sets up an environment variable with the given MAC address (@enetaddr).
+ * The environment variable to be set is defined by <@base_name><@index>addr.
+ * If @index is 0 it is omitted. For common Ethernet this means ethaddr,
+ * eth1addr, etc.
+ *
+ * @base_name: Base name for variable, typically "eth"
+ * @index: Index of interface being updated (>=0)
+ * @enetaddr: Pointer to MAC address to put into the variable
+ * @return 0 if OK, other value on error
+ */
+int eth_setenv_enetaddr_by_index(const char *base_name, int index,
+ uchar *enetaddr);
+
+
/*
* Get the hardware address for an ethernet interface .
* Args:
--
2.5.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH 2/2] board: ti: am57xx: Set ethernet MAC addresses from EEPROM to env
2016-03-18 11:18 [U-Boot] [PATCH 0/2] board: ti: am57xx: Set ethernet MAC addresses from EEPROM to env Roger Quadros
2016-03-18 11:18 ` [U-Boot] [PATCH 1/2] net: export eth_setenv_enetaddr_by_index() to net.h Roger Quadros
@ 2016-03-18 11:18 ` Roger Quadros
2016-03-18 13:26 ` Tom Rini
2016-03-27 22:28 ` [U-Boot] [U-Boot, " Tom Rini
1 sibling, 2 replies; 7+ messages in thread
From: Roger Quadros @ 2016-03-18 11:18 UTC (permalink / raw)
To: u-boot
The MAC addresses for the PRU Ethernet ports will be available in the
board EEPROM as an address range. Populate those MAC addresses (if valid)
into the u-boot environment so that they can be passed on to the
device tree during fdt_fixup_ethernet().
Signed-off-by: Roger Quadros <rogerq@ti.com>
---
board/ti/am57xx/board.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 53 insertions(+)
diff --git a/board/ti/am57xx/board.c b/board/ti/am57xx/board.c
index 67191af..18416ef 100644
--- a/board/ti/am57xx/board.c
+++ b/board/ti/am57xx/board.c
@@ -537,12 +537,39 @@ static struct cpsw_platform_data cpsw_data = {
.version = CPSW_CTRL_VERSION_2,
};
+static u64 mac_to_u64(u8 mac[6])
+{
+ int i;
+ u64 addr = 0;
+
+ for (i = 0; i < 6; i++) {
+ addr <<= 8;
+ addr |= mac[i];
+ }
+
+ return addr;
+}
+
+static void u64_to_mac(u64 addr, u8 mac[6])
+{
+ mac[5] = addr;
+ mac[4] = addr >> 8;
+ mac[3] = addr >> 16;
+ mac[2] = addr >> 24;
+ mac[1] = addr >> 32;
+ mac[0] = addr >> 40;
+}
+
int board_eth_init(bd_t *bis)
{
int ret;
uint8_t mac_addr[6];
uint32_t mac_hi, mac_lo;
uint32_t ctrl_val;
+ int i;
+ u64 mac1, mac2;
+ u8 mac_addr1[6], mac_addr2[6];
+ int num_macs;
/* try reading mac address from efuse */
mac_lo = readl((*ctrl)->control_core_mac_id_0_lo);
@@ -583,6 +610,32 @@ int board_eth_init(bd_t *bis)
if (ret < 0)
printf("Error %d registering CPSW switch\n", ret);
+ /*
+ * Export any Ethernet MAC addresses from EEPROM.
+ * On AM57xx the 2 MAC addresses define the address range
+ */
+ board_ti_get_eth_mac_addr(0, mac_addr1);
+ board_ti_get_eth_mac_addr(1, mac_addr2);
+
+ if (is_valid_ethaddr(mac_addr1) && is_valid_ethaddr(mac_addr2)) {
+ mac1 = mac_to_u64(mac_addr1);
+ mac2 = mac_to_u64(mac_addr2);
+
+ /* must contain an address range */
+ num_macs = mac2 - mac1 + 1;
+ /* <= 50 to protect against user programming error */
+ if (num_macs > 0 && num_macs <= 50) {
+ for (i = 0; i < num_macs; i++) {
+ u64_to_mac(mac1 + i, mac_addr);
+ if (is_valid_ethaddr(mac_addr)) {
+ eth_setenv_enetaddr_by_index("eth",
+ i + 2,
+ mac_addr);
+ }
+ }
+ }
+ }
+
return ret;
}
#endif
--
2.5.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH 1/2] net: export eth_setenv_enetaddr_by_index() to net.h
2016-03-18 11:18 ` [U-Boot] [PATCH 1/2] net: export eth_setenv_enetaddr_by_index() to net.h Roger Quadros
@ 2016-03-18 13:26 ` Tom Rini
2016-03-27 22:27 ` [U-Boot] [U-Boot, " Tom Rini
1 sibling, 0 replies; 7+ messages in thread
From: Tom Rini @ 2016-03-18 13:26 UTC (permalink / raw)
To: u-boot
On Fri, Mar 18, 2016 at 01:18:11PM +0200, Roger Quadros wrote:
> Some TI boards (e.g. IDK) have 4 to 6 ethernet ports and
> this function is handy at board.c to configure the
> MAC address of the ports.
>
> Signed-off-by: Roger Quadros <rogerq@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160318/83a5a96a/attachment.sig>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH 2/2] board: ti: am57xx: Set ethernet MAC addresses from EEPROM to env
2016-03-18 11:18 ` [U-Boot] [PATCH 2/2] board: ti: am57xx: Set ethernet MAC addresses from EEPROM to env Roger Quadros
@ 2016-03-18 13:26 ` Tom Rini
2016-03-27 22:28 ` [U-Boot] [U-Boot, " Tom Rini
1 sibling, 0 replies; 7+ messages in thread
From: Tom Rini @ 2016-03-18 13:26 UTC (permalink / raw)
To: u-boot
On Fri, Mar 18, 2016 at 01:18:12PM +0200, Roger Quadros wrote:
> The MAC addresses for the PRU Ethernet ports will be available in the
> board EEPROM as an address range. Populate those MAC addresses (if valid)
> into the u-boot environment so that they can be passed on to the
> device tree during fdt_fixup_ethernet().
>
> Signed-off-by: Roger Quadros <rogerq@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160318/2263b2dc/attachment.sig>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [U-Boot, 1/2] net: export eth_setenv_enetaddr_by_index() to net.h
2016-03-18 11:18 ` [U-Boot] [PATCH 1/2] net: export eth_setenv_enetaddr_by_index() to net.h Roger Quadros
2016-03-18 13:26 ` Tom Rini
@ 2016-03-27 22:27 ` Tom Rini
1 sibling, 0 replies; 7+ messages in thread
From: Tom Rini @ 2016-03-27 22:27 UTC (permalink / raw)
To: u-boot
On Fri, Mar 18, 2016 at 01:18:11PM +0200, Roger Quadros wrote:
> Some TI boards (e.g. IDK) have 4 to 6 ethernet ports and
> this function is handy at board.c to configure the
> MAC address of the ports.
>
> Signed-off-by: Roger Quadros <rogerq@ti.com>
> Reviewed-by: Tom Rini <trini@konsulko.com>
Applied to u-boot/master, thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160327/435b7eb6/attachment.sig>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [U-Boot, 2/2] board: ti: am57xx: Set ethernet MAC addresses from EEPROM to env
2016-03-18 11:18 ` [U-Boot] [PATCH 2/2] board: ti: am57xx: Set ethernet MAC addresses from EEPROM to env Roger Quadros
2016-03-18 13:26 ` Tom Rini
@ 2016-03-27 22:28 ` Tom Rini
1 sibling, 0 replies; 7+ messages in thread
From: Tom Rini @ 2016-03-27 22:28 UTC (permalink / raw)
To: u-boot
On Fri, Mar 18, 2016 at 01:18:12PM +0200, Roger Quadros wrote:
> The MAC addresses for the PRU Ethernet ports will be available in the
> board EEPROM as an address range. Populate those MAC addresses (if valid)
> into the u-boot environment so that they can be passed on to the
> device tree during fdt_fixup_ethernet().
>
> Signed-off-by: Roger Quadros <rogerq@ti.com>
> Reviewed-by: Tom Rini <trini@konsulko.com>
Applied to u-boot/master, thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160327/37a4e9d8/attachment.sig>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-03-27 22:28 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-18 11:18 [U-Boot] [PATCH 0/2] board: ti: am57xx: Set ethernet MAC addresses from EEPROM to env Roger Quadros
2016-03-18 11:18 ` [U-Boot] [PATCH 1/2] net: export eth_setenv_enetaddr_by_index() to net.h Roger Quadros
2016-03-18 13:26 ` Tom Rini
2016-03-27 22:27 ` [U-Boot] [U-Boot, " Tom Rini
2016-03-18 11:18 ` [U-Boot] [PATCH 2/2] board: ti: am57xx: Set ethernet MAC addresses from EEPROM to env Roger Quadros
2016-03-18 13:26 ` Tom Rini
2016-03-27 22:28 ` [U-Boot] [U-Boot, " Tom Rini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.