Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys add u-boot argument parser for Marvell ARMADA XP/370.
details: https://anonhg.NetBSD.org/src/rev/36dbecdd6e10
branches: trunk
changeset: 337461:36dbecdd6e10
user: hsuenaga <hsuenaga%NetBSD.org@localhost>
date: Wed Apr 15 10:15:40 2015 +0000
description:
add u-boot argument parser for Marvell ARMADA XP/370.
use 'ethaddr' and 'eth1addr' in u-boot argument to setup MAC address of mvgbe.
diffstat:
sys/arch/evbarm/armadaxp/armadaxp_machdep.c | 45 +++++++++++++++++++++++++++-
sys/arch/evbarm/armadaxp/armadaxp_start.S | 12 ++++++-
sys/dev/marvell/if_mvgbe.c | 32 +++++++++++++++++++-
3 files changed, 83 insertions(+), 6 deletions(-)
diffs (203 lines):
diff -r 857ce254b5bb -r 36dbecdd6e10 sys/arch/evbarm/armadaxp/armadaxp_machdep.c
--- a/sys/arch/evbarm/armadaxp/armadaxp_machdep.c Wed Apr 15 08:47:28 2015 +0000
+++ b/sys/arch/evbarm/armadaxp/armadaxp_machdep.c Wed Apr 15 10:15:40 2015 +0000
@@ -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 @@
*******************************************************************************/
#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 @@
#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 @@
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 @@
/* 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 @@
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
}
diff -r 857ce254b5bb -r 36dbecdd6e10 sys/arch/evbarm/armadaxp/armadaxp_start.S
--- a/sys/arch/evbarm/armadaxp/armadaxp_start.S Wed Apr 15 08:47:28 2015 +0000
+++ b/sys/arch/evbarm/armadaxp/armadaxp_start.S Wed Apr 15 10:15:40 2015 +0000
@@ -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 @@
#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 @@
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 @@
/* 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) ; \
diff -r 857ce254b5bb -r 36dbecdd6e10 sys/dev/marvell/if_mvgbe.c
--- a/sys/dev/marvell/if_mvgbe.c Wed Apr 15 08:47:28 2015 +0000
+++ b/sys/dev/marvell/if_mvgbe.c Wed Apr 15 10:15:40 2015 +0000
@@ -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 @@
{
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 @@
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 @@
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;
Home |
Main Index |
Thread Index |
Old Index