Module Name: src
Committed By: hsuenaga
Date: Wed Apr 15 10:15:40 UTC 2015
Modified Files:
src/sys/arch/evbarm/armadaxp: armadaxp_machdep.c armadaxp_start.S
src/sys/dev/marvell: if_mvgbe.c
Log Message:
add u-boot argument parser for Marvell ARMADA XP/370.
use 'ethaddr' and 'eth1addr' in u-boot argument to setup MAC address of mvgbe.
To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/evbarm/armadaxp/armadaxp_machdep.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/evbarm/armadaxp/armadaxp_start.S
cvs rdiff -u -r1.40 -r1.41 src/sys/dev/marvell/if_mvgbe.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/evbarm/armadaxp/armadaxp_machdep.c
diff -u src/sys/arch/evbarm/armadaxp/armadaxp_machdep.c:1.8 src/sys/arch/evbarm/armadaxp/armadaxp_machdep.c:1.9
--- src/sys/arch/evbarm/armadaxp/armadaxp_machdep.c:1.8 Sat Mar 29 15:00:07 2014
+++ src/sys/arch/evbarm/armadaxp/armadaxp_machdep.c Wed Apr 15 10:15:40 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: armadaxp_machdep.c,v 1.8 2014/03/29 15:00:07 matt Exp $ */
+/* $NetBSD: armadaxp_machdep.c,v 1.9 2015/04/15 10:15:40 hsuenaga Exp $ */
/*******************************************************************************
Copyright (C) Marvell International Ltd. and its affiliates
@@ -37,7 +37,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBI
*******************************************************************************/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: armadaxp_machdep.c,v 1.8 2014/03/29 15:00:07 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: armadaxp_machdep.c,v 1.9 2015/04/15 10:15:40 hsuenaga Exp $");
#include "opt_machdep.h"
#include "opt_mvsoc.h"
@@ -100,6 +100,8 @@ __KERNEL_RCSID(0, "$NetBSD: armadaxp_mac
#include <dev/ic/comvar.h>
#endif
+#include <net/if_ether.h>
+
/*
* Address to call from cpu_reset() to reset the machine.
* This is machine architecture dependent as it varies depending
@@ -110,6 +112,13 @@ BootConfig bootconfig; /* Boot config s
char *boot_args = NULL;
char *boot_file = NULL;
+/*
+ * U-Boot argument buffer
+ */
+extern unsigned int uboot_regs_pa[]; /* saved r0, r1, r2, r3 */
+unsigned int *uboot_regs_va;
+char boot_argbuf[MAX_BOOT_STRING];
+
extern int KERNEL_BASE_phys[];
/*
@@ -393,6 +402,13 @@ initarm(void *arg)
/* we've a specific device_register routine */
evbarm_device_register = axp_device_register;
+ /* copy U-Boot args from U-Boot heap to kernel memory */
+ uboot_regs_va = (int *)((unsigned int)uboot_regs_pa + KERNEL_BASE);
+ boot_args = (char *)(uboot_regs_va[3] + KERNEL_BASE);
+ strlcpy(boot_argbuf, (char *)boot_args, sizeof(boot_argbuf));
+ boot_args = boot_argbuf;
+ parse_mi_bootargs(boot_args);
+
return initarm_common(KERNEL_VM_BASE, KERNEL_VM_SIZE, NULL, 0);
}
@@ -584,5 +600,30 @@ axp_device_register(device_t dev, void *
prop_dictionary_set_uint32(dict,
"cache-line-size", arm_dcache_align);
}
+ if (device_is_a(dev, "mvgbec")) {
+ uint8_t enaddr[ETHER_ADDR_LEN];
+ char optname[9];
+ int unit = device_unit(dev);
+
+ if (unit > 9)
+ return;
+ switch (unit) {
+ case 0:
+ strlcpy(optname, "ethaddr", sizeof(optname));
+ break;
+ default:
+ /* eth1addr ... eth9addr */
+ snprintf(optname, sizeof(optname),
+ "eth%daddr", unit);
+ break;
+ }
+ if (get_bootconf_option(boot_args, optname,
+ BOOTOPT_TYPE_MACADDR, enaddr)) {
+ prop_data_t pd =
+ prop_data_create_data(enaddr, sizeof(enaddr));
+
+ prop_dictionary_set(dict, "mac-address", pd);
+ }
+ }
#endif
}
Index: src/sys/arch/evbarm/armadaxp/armadaxp_start.S
diff -u src/sys/arch/evbarm/armadaxp/armadaxp_start.S:1.3 src/sys/arch/evbarm/armadaxp/armadaxp_start.S:1.4
--- src/sys/arch/evbarm/armadaxp/armadaxp_start.S:1.3 Sat Mar 29 14:53:57 2014
+++ src/sys/arch/evbarm/armadaxp/armadaxp_start.S Wed Apr 15 10:15:40 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: armadaxp_start.S,v 1.3 2014/03/29 14:53:57 matt Exp $ */
+/* $NetBSD: armadaxp_start.S,v 1.4 2015/04/15 10:15:40 hsuenaga Exp $ */
/*******************************************************************************
Copyright (C) Marvell International Ltd. and its affiliates
@@ -44,7 +44,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBI
#include <evbarm/marvell/marvellvar.h>
#include "assym.h"
-RCSID("$NetBSD: armadaxp_start.S,v 1.3 2014/03/29 14:53:57 matt Exp $")
+RCSID("$NetBSD: armadaxp_start.S,v 1.4 2015/04/15 10:15:40 hsuenaga Exp $")
#ifdef KERNEL_BASES_EQUAL
#error KERNEL_BASE_VIRT should not equal KERNEL_BASE_PHYS
@@ -78,6 +78,10 @@ _C_LABEL(armadaxp_start):
dsb
isb
+ /* Save U-Boot arguments */
+ adr r4, uboot_regs_pa
+ stmia r4!, {r0, r1, r2, r3}
+
/* build page table from scratch */
movw r0, #:lower16:STARTUP_PAGETABLE_ADDR
movt r0, #:upper16:STARTUP_PAGETABLE_ADDR
@@ -133,6 +137,10 @@ _C_LABEL(armadaxp_start):
/* NOTREACHED */
+ .global _C_LABEL(uboot_regs_pa)
+uboot_regs_pa:
+ .space 16 /* r0, r1, r2, r3 */
+
#define MMU_INIT(va,pa,n_sec,attr) \
.word n_sec ; \
.word 4*((va)>>L1_S_SHIFT) ; \
Index: src/sys/dev/marvell/if_mvgbe.c
diff -u src/sys/dev/marvell/if_mvgbe.c:1.40 src/sys/dev/marvell/if_mvgbe.c:1.41
--- src/sys/dev/marvell/if_mvgbe.c:1.40 Mon Apr 13 16:33:24 2015
+++ src/sys/dev/marvell/if_mvgbe.c Wed Apr 15 10:15:40 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: if_mvgbe.c,v 1.40 2015/04/13 16:33:24 riastradh Exp $ */
+/* $NetBSD: if_mvgbe.c,v 1.41 2015/04/15 10:15:40 hsuenaga Exp $ */
/*
* Copyright (c) 2007, 2008, 2013 KIYOHARA Takashi
* All rights reserved.
@@ -25,7 +25,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_mvgbe.c,v 1.40 2015/04/13 16:33:24 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_mvgbe.c,v 1.41 2015/04/15 10:15:40 hsuenaga Exp $");
#include "opt_multiprocessor.h"
@@ -674,6 +674,13 @@ mvgbe_match(device_t parent, cfdata_t ma
{
struct marvell_attach_args *mva = aux;
uint32_t pbase, maddrh, maddrl;
+ prop_dictionary_t dict;
+
+ dict = device_properties(parent);
+ if (dict) {
+ if (prop_dictionary_get(dict, "mac-address"))
+ return 1;
+ }
pbase = MVGBE_PORTR_BASE + mva->mva_unit * MVGBE_PORTR_SIZE;
maddrh =
@@ -694,16 +701,25 @@ mvgbe_attach(device_t parent, device_t s
struct mvgbe_softc *sc = device_private(self);
struct marvell_attach_args *mva = aux;
struct mvgbe_txmap_entry *entry;
+ prop_dictionary_t dict;
+ prop_data_t enaddrp;
struct ifnet *ifp;
bus_dma_segment_t seg;
bus_dmamap_t dmamap;
int rseg, i;
uint32_t maddrh, maddrl;
+ uint8_t enaddr[ETHER_ADDR_LEN];
void *kva;
aprint_naive("\n");
aprint_normal("\n");
+ dict = device_properties(parent);
+ if (dict)
+ enaddrp = prop_dictionary_get(dict, "mac-address");
+ else
+ enaddrp = NULL;
+
sc->sc_dev = self;
sc->sc_port = mva->mva_unit;
sc->sc_iot = mva->mva_iot;
@@ -751,6 +767,18 @@ mvgbe_attach(device_t parent, device_t s
sc->sc_linkup.bit = MVGBE_PS_LINKUP;
}
+ if (enaddrp) {
+ memcpy(enaddr, prop_data_data_nocopy(enaddrp), ETHER_ADDR_LEN);
+ maddrh = enaddr[0] << 24;
+ maddrh |= enaddr[1] << 16;
+ maddrh |= enaddr[2] << 8;
+ maddrh |= enaddr[3];
+ maddrl = enaddr[4] << 8;
+ maddrl |= enaddr[5];
+ MVGBE_WRITE(sc, MVGBE_MACAH, maddrh);
+ MVGBE_WRITE(sc, MVGBE_MACAL, maddrl);
+ }
+
maddrh = MVGBE_READ(sc, MVGBE_MACAH);
maddrl = MVGBE_READ(sc, MVGBE_MACAL);
sc->sc_enaddr[0] = maddrh >> 24;