Save arguments from uboot at the very beginning in odroid_start.S supporting

both the `bootm' as the `go' method. While here, also implement the mac
address passing and parsing for the usmsc0 device.
This commit is contained in:
reinoud 2014-08-04 18:14:43 +00:00
parent 6dc8db112b
commit 948b1351c2
3 changed files with 123 additions and 6 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: genassym.cf,v 1.1 2014/04/13 02:26:26 matt Exp $ # $NetBSD: genassym.cf,v 1.2 2014/08/04 18:14:43 reinoud Exp $
#- #-
# Copyright (c) 2013 The NetBSD Foundation, Inc. # Copyright (c) 2013 The NetBSD Foundation, Inc.
@ -30,8 +30,10 @@
# #
include <arch/arm/samsung/sscom_reg.h> include <arch/arm/samsung/sscom_reg.h>
include <arch/evbarm/include/bootconfig.h>
define UTRSTAT_TXEMPTY UTRSTAT_TXEMPTY define UTRSTAT_TXEMPTY UTRSTAT_TXEMPTY
define UTRSTAT_TXSHIFTER_EMPTY UTRSTAT_TXSHIFTER_EMPTY define UTRSTAT_TXSHIFTER_EMPTY UTRSTAT_TXSHIFTER_EMPTY
define SSCOM_UTXH SSCOM_UTXH define SSCOM_UTXH SSCOM_UTXH
define SSCOM_UTRSTAT SSCOM_UTRSTAT define SSCOM_UTRSTAT SSCOM_UTRSTAT
define MAX_BOOT_STRING MAX_BOOT_STRING

View File

@ -1,4 +1,4 @@
/* $NetBSD: odroid_machdep.c,v 1.23 2014/08/04 11:32:27 reinoud Exp $ */ /* $NetBSD: odroid_machdep.c,v 1.24 2014/08/04 18:14:43 reinoud Exp $ */
/* /*
* Copyright (c) 2014 The NetBSD Foundation, Inc. * Copyright (c) 2014 The NetBSD Foundation, Inc.
@ -31,7 +31,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: odroid_machdep.c,v 1.23 2014/08/04 11:32:27 reinoud Exp $"); __KERNEL_RCSID(0, "$NetBSD: odroid_machdep.c,v 1.24 2014/08/04 18:14:43 reinoud Exp $");
#include "opt_evbarm_boardtype.h" #include "opt_evbarm_boardtype.h"
#include "opt_exynos.h" #include "opt_exynos.h"
@ -92,6 +92,7 @@ __KERNEL_RCSID(0, "$NetBSD: odroid_machdep.c,v 1.23 2014/08/04 11:32:27 reinoud
#include <dev/i2c/ddcreg.h> #include <dev/i2c/ddcreg.h>
#include <dev/usb/ukbdvar.h> #include <dev/usb/ukbdvar.h>
#include <net/if_ether.h>
/* serial console stuff */ /* serial console stuff */
#include "sscom.h" #include "sscom.h"
@ -178,9 +179,10 @@ uintptr_t uboot_args[4] = { 0 };
* argument and boot configure storage * argument and boot configure storage
*/ */
BootConfig bootconfig; /* for pmap's sake */ BootConfig bootconfig; /* for pmap's sake */
//static char bootargs[MAX_BOOT_STRING]; /* copied string from uboot */ char bootargs[MAX_BOOT_STRING] = ""; /* copied string from uboot */
char *boot_args = NULL; /* MI bootargs */ char *boot_args = NULL; /* MI bootargs */
char *boot_file = NULL; /* MI bootfile */ char *boot_file = NULL; /* MI bootfile */
uint8_t uboot_enaddr[ETHER_ADDR_LEN] = {};
/* /*
@ -203,6 +205,7 @@ void consinit(void);
static void kgdb_port_init(void); static void kgdb_port_init(void);
#endif #endif
static void exynos_usb_powercycle_lan9730(device_t self); static void exynos_usb_powercycle_lan9730(device_t self);
static void exynos_extract_mac_adress(void);
void odroid_device_register(device_t self, void *aux); void odroid_device_register(device_t self, void *aux);
void odroid_device_register_post_config(device_t self, void *aux); void odroid_device_register_post_config(device_t self, void *aux);
@ -356,6 +359,9 @@ curcpu()->ci_data.cpu_cc_freq = 1*1000*1000*1000; /* XXX hack XXX */
char mi_bootargs[] = BOOT_ARGS; char mi_bootargs[] = BOOT_ARGS;
parse_mi_bootargs(mi_bootargs); parse_mi_bootargs(mi_bootargs);
#endif #endif
boot_args = bootargs;
parse_mi_bootargs(boot_args);
exynos_extract_mac_adress();
/* /*
* Determine physical memory by looking at the PoP package. This PoP * Determine physical memory by looking at the PoP package. This PoP
@ -474,6 +480,48 @@ consinit(void)
} }
/* extract ethernet mac address from bootargs */
static void
exynos_extract_mac_adress(void)
{
char *str, *ptr;
int i, v1, v2, val;
#define EXPECT_COLON() {\
v1 = *ptr++; \
if (v1 != ':') break; \
}
#define EXPECT_HEX(v) {\
(v) = (v) >= '0' && (v) <= '9'? (v) - '0' : \
(v) >= 'a' && (v) <= 'f'? (v) - 'a' + 10 : \
(v) >= 'A' && (v) <= 'F'? (v) - 'A' + 10 : -1; \
if ((v) < 0) break; \
}
#define EXPECT_2HEX(val) {\
v1 = *ptr++; EXPECT_HEX(v1); \
v2 = *ptr++; EXPECT_HEX(v2); \
val = (v1 << 4) | v2; \
}
if (get_bootconf_option(boot_args, "ethaddr",
BOOTOPT_TYPE_STRING, &str)) {
for (i = 0, ptr = str; i < sizeof(uboot_enaddr); i++) {
if (i)
EXPECT_COLON();
EXPECT_2HEX(val);
uboot_enaddr[i] = val;
}
if (i != sizeof(uboot_enaddr)) {
printf( "Ignoring invalid MAC address '%s' passed "
"as boot paramter `ethaddr'\n", str);
memset((char *) uboot_enaddr, 0, sizeof(uboot_enaddr));
}
}
#undef EXPECT_2HEX
#undef EXPECT_HEX
#undef EXPECT_COLON
}
#ifdef EXYNOS4 #ifdef EXYNOS4
static void static void
odroid_exynos4_gpio_ncs(device_t self, prop_dictionary_t dict) { odroid_exynos4_gpio_ncs(device_t self, prop_dictionary_t dict) {
@ -574,6 +622,16 @@ odroid_device_register(device_t self, void *aux)
prop_dictionary_set_cstring(dict, "lan_power", "p3v3_en"); prop_dictionary_set_cstring(dict, "lan_power", "p3v3_en");
} }
if (device_is_a(self, "usmsc")) {
prop_data_t blob =
prop_data_create_data(uboot_enaddr, ETHER_ADDR_LEN);
if (prop_dictionary_set(dict, "mac-address", blob) == false) {
aprint_error_dev(self,
"WARNING: unable to set mac-address property\n");
}
prop_object_release(blob);
}
#ifdef EXYNOS4 #ifdef EXYNOS4
if (device_is_a(self, "exyogpio") && (IS_EXYNOS4_P())) { if (device_is_a(self, "exyogpio") && (IS_EXYNOS4_P())) {
/* unused bits */ /* unused bits */

View File

@ -1,4 +1,4 @@
/* $NetBSD: odroid_start.S,v 1.2 2014/04/14 19:45:40 reinoud Exp $ */ /* $NetBSD: odroid_start.S,v 1.3 2014/08/04 18:14:43 reinoud Exp $ */
/*- /*-
* Copyright (c) 2014 The NetBSD Foundation, Inc. * Copyright (c) 2014 The NetBSD Foundation, Inc.
@ -46,7 +46,7 @@
#include <evbarm/odroid/platform.h> #include <evbarm/odroid/platform.h>
RCSID("$NetBSD: odroid_start.S,v 1.2 2014/04/14 19:45:40 reinoud Exp $") RCSID("$NetBSD: odroid_start.S,v 1.3 2014/08/04 18:14:43 reinoud Exp $")
#if defined(VERBOSE_INIT_ARM) #if defined(VERBOSE_INIT_ARM)
@ -94,6 +94,63 @@ _C_LABEL(odroid_start):
sub r4, r4, #KERNEL_BASE_VOFFSET sub r4, r4, #KERNEL_BASE_VOFFSET
stmia r4, {r0-r3} // Save the arguments stmia r4, {r0-r3} // Save the arguments
/*
* Rescue passed "bootargs" env variable. This is not trivial
* since we can be booted using either `go' or trough `bootm'.
*
* 'go' passes R0 = argc, R1 = argv
* 'bootm' passes R0 = uboot_bootinfo, R3 = bootargs
*/
movw r4, #:lower16:bootargs
movt r4, #:upper16:bootargs
sub r4, r4, #KERNEL_BASE_VOFFSET
cmp r0, #0
beq 1f
cmp r0, #MAX_BOOT_STRING
bge 1f
/* `go' method */
cmp r0, #1 // extra argument?
beq 3f
ldr r5, [r1, #4] // load argv[1]
2:
ldrb r0, [r5], #1
strb r0, [r4], #1
teq r0, #0
bne 2b
b 3f
1:
/* `bootm' method */
mov r6, r0 // save binfo pointer
cmp r3, #0
beq 1f
2:
ldrb r0, [r3], #1
strb r0, [r4], #1
teq r0, #0
bne 2b
1:
cmp r6, #0 // binfo passed?
beq 3f
add r6, r6, #0x250 // to eth addr
movw r4, #:lower16:uboot_enaddr
movt r4, #:upper16:uboot_enaddr
mov r2, #6
2:
ldrb r0, [r6], #1
strb r0, [r4], #1
subs r2, r2, #1
bne 2b
3:
/* /*
* For easy and early SoC / PoP dependency, retrieve the IDs * For easy and early SoC / PoP dependency, retrieve the IDs
*/ */