nbhw18: fix set_console to allow actually switching it
This commit is contained in:
parent
b5b6a3c344
commit
865c49bcf9
|
|
@ -24,10 +24,6 @@
|
|||
ethernet3 = ð2;
|
||||
};
|
||||
|
||||
chosen {
|
||||
stdout-path = "serial0:115200n8";
|
||||
};
|
||||
|
||||
memory {
|
||||
device_type = "memory";
|
||||
reg = <0x00000000 0x40000000>; /* 1 GB */
|
||||
|
|
@ -141,7 +137,6 @@
|
|||
pinctrl-names = "default";
|
||||
pinctrl-0 = <&uart0_pins>;
|
||||
status = "okay";
|
||||
u-boot,dm-pre-reloc;
|
||||
};
|
||||
|
||||
serial@12100 {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Device Tree file for the NetModule NBHW17 (NB2800) base variant
|
||||
*
|
||||
* Copyright (C) 2016 NetModule
|
||||
*
|
||||
* Stefan Eichenberger <stefan.eichenberger@netmodule.com>
|
||||
*
|
||||
* This file is licensed under the terms of the GNU General Public
|
||||
* License version 2. This program is licensed "as is" without any
|
||||
* warranty of any kind, whether express or implied.
|
||||
*/
|
||||
|
||||
/dts-v1/;
|
||||
#include "armada-385-nbhw18-common.dtsi"
|
||||
|
||||
/ {
|
||||
model = "NetModule Router NBHW18 with Armada A385 (NB2800)";
|
||||
chosen {
|
||||
stdout-path = "serial0:115200n8";
|
||||
};
|
||||
|
||||
|
||||
soc {
|
||||
internal-regs {
|
||||
serial@12000 {
|
||||
u-boot,dm-spl;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
ð0 {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
// SFP-Port
|
||||
ð1 {
|
||||
status = "disabled";
|
||||
fixed-link {
|
||||
speed = <1000>;
|
||||
full-duplex;
|
||||
};
|
||||
};
|
||||
|
||||
ð2 {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
|
|
@ -1,14 +1,14 @@
|
|||
#include <common.h>
|
||||
|
||||
#include "fs.h"
|
||||
#include "nbhw_fileaccess.h"
|
||||
#include "nbhw_bd.h"
|
||||
|
||||
#define MAX_PARTITION_ENTRIES 8
|
||||
|
||||
void find_and_set_active_partition(void)
|
||||
{
|
||||
u8 boot_partition = bd_get_boot_partition();
|
||||
if (boot_partition > 1) {
|
||||
u8 boot_partition = bd_get_boot_partition();
|
||||
if (boot_partition > 1) {
|
||||
boot_partition = 0;
|
||||
}
|
||||
|
||||
|
|
@ -18,41 +18,23 @@ void find_and_set_active_partition(void)
|
|||
|
||||
void set_console(void)
|
||||
{
|
||||
char buf[50] = "\n";
|
||||
char buf[50] = "\0";
|
||||
char *defaultconsole = env_get("defaultconsole");
|
||||
|
||||
if (defaultconsole == 0) {
|
||||
/* This is the default console that should be used for e.g. recovery boot */
|
||||
#if 0
|
||||
/* TODO: fix this */
|
||||
sprintf(buf, "ttyS%d", CONFIG_SYS_DUART_CHAN);
|
||||
#endif
|
||||
env_set("defaultconsole", buf);
|
||||
}
|
||||
|
||||
int len = 0;
|
||||
|
||||
#if defined(CONFIG_PRE_CONSOLE_BUFFER)
|
||||
/* If consoldev is set take this as productive conosle instead of default console */
|
||||
if (fs_set_blk_dev("mmc", "0:3", FS_TYPE_EXT) != 0) {
|
||||
puts("Error, can not set blk device\n");
|
||||
goto use_default_console;
|
||||
}
|
||||
read_file_set_blk_dev("mmc", "0:3", FS_TYPE_EXT);
|
||||
|
||||
len = fs_read("/root/boot/consoledev", (ulong)buf, 0, 5);
|
||||
len = read_file("/root/boot/consoledev", buf, 16);
|
||||
if ((len != 5) || (strstr(buf, "tty")!=buf) || ((buf[4]<'0') && (buf[4]>'1'))) {
|
||||
puts("Using default console\n");
|
||||
goto use_default_console;
|
||||
}
|
||||
|
||||
if (buf[4]=='1') {
|
||||
CONFIG_SYS_DUART_CHAN = 1;
|
||||
} else {
|
||||
CONFIG_SYS_DUART_CHAN = 0;
|
||||
buf[0] = 0;
|
||||
}
|
||||
|
||||
use_default_console:
|
||||
|
||||
sprintf(buf, "ttyS%d", CONFIG_SYS_DUART_CHAN);
|
||||
if (buf[0] == 0) {
|
||||
strncpy(buf, defaultconsole, sizeof(buf));
|
||||
}
|
||||
printf("consoledev: %s\n", buf);
|
||||
env_set("consoledev", buf);
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,47 @@
|
|||
#include <fs.h>
|
||||
#include <common.h>
|
||||
|
||||
char l_ifname[32];
|
||||
char l_dev_part_str[32];
|
||||
int l_fstype;
|
||||
|
||||
|
||||
void read_file_set_blk_dev(const char *ifname,
|
||||
const char *dev_part_str, int fstype)
|
||||
{
|
||||
strncpy(l_ifname, ifname, sizeof(l_ifname));
|
||||
strncpy(l_dev_part_str, dev_part_str, sizeof(l_dev_part_str));
|
||||
l_fstype = fstype;
|
||||
}
|
||||
|
||||
int read_file(const char* filename, char *buf, int size)
|
||||
{
|
||||
loff_t filesize = 0;
|
||||
loff_t len;
|
||||
int ret;
|
||||
|
||||
if (fs_set_blk_dev("mmc", "0:3", FS_TYPE_EXT) != 0) {
|
||||
puts("Error, can not set blk device\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* U-Boot returns an error if size != len therefore
|
||||
* get first the length... */
|
||||
if (fs_size(filename, &filesize)) {
|
||||
puts("Can't get filesize\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (filesize < size)
|
||||
if (filesize < size){
|
||||
size = filesize;
|
||||
len = filesize;
|
||||
}
|
||||
|
||||
/* U-Boot forgets the block device after an action, so do it again ...*/
|
||||
if (fs_set_blk_dev("mmc", "0:3", FS_TYPE_EXT) != 0) {
|
||||
puts("Error, can not set blk device\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((ret = fs_read(filename, (ulong)buf, 0, size, &len))) {
|
||||
printf("Can't read file %s (size %d, len %lld, ret %d)\n", filename, size, len, ret);
|
||||
|
|
|
|||
|
|
@ -10,5 +10,7 @@
|
|||
#include <fs.h>
|
||||
|
||||
int read_file(const char* filename, char *buf, int size);
|
||||
void read_file_set_blk_dev(const char *ifname,
|
||||
const char *dev_part_str, int fstype);
|
||||
|
||||
#endif // FILEACCESS_H
|
||||
|
|
|
|||
|
|
@ -25,4 +25,3 @@ obj-y := board.o nbhw_gpio.o \
|
|||
../common/nbhw_bd.o
|
||||
endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
#include <linux/mbus.h>
|
||||
#include <environment.h>
|
||||
#include <fdt_support.h>
|
||||
#include <dm.h>
|
||||
|
||||
#include <asm/gpio.h>
|
||||
|
||||
|
|
@ -86,6 +87,45 @@ static inline int __maybe_unused read_eeprom(void)
|
|||
return _bd_init();
|
||||
}
|
||||
|
||||
|
||||
extern int console_init_f(void);
|
||||
|
||||
static int init_console(void)
|
||||
{
|
||||
int ret;
|
||||
struct udevice *dev;
|
||||
char *consoledev;
|
||||
char buf[16] = "serial@12100";
|
||||
|
||||
debug("init console\n");
|
||||
|
||||
/* Make sure all devices are probed, it seems
|
||||
* that this stuff is buggy in U-Boot */
|
||||
ret = uclass_first_device(UCLASS_SERIAL, &dev);
|
||||
if (ret) {
|
||||
printf("Could not find any serial device\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
while (list_is_last(&dev->uclass_node, &dev->uclass->dev_head) == 0) {
|
||||
uclass_next_device(&dev);
|
||||
}
|
||||
|
||||
|
||||
set_console();
|
||||
|
||||
consoledev = env_get("consoledev");
|
||||
if (strncmp(consoledev, "ttyS0", 5) == 0) {
|
||||
strncpy(buf, "serial@12000", sizeof(buf));
|
||||
}
|
||||
|
||||
env_set("stdin", buf);
|
||||
env_set("stdout", buf);
|
||||
env_set("stderr", buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hws_board_topology_load(struct serdes_map **serdes_map_array, u8 *count)
|
||||
{
|
||||
int i;
|
||||
|
|
@ -199,13 +239,13 @@ void spl_board_init(void)
|
|||
if (err)
|
||||
return;
|
||||
|
||||
puts("SPL: select partition\n");
|
||||
debug("SPL: select partition\n");
|
||||
mmcp = find_mmc_device(0);
|
||||
mmc_init(mmcp);
|
||||
printf("Partition found: %p\n", mmcp);
|
||||
/* select boot0 as bootpart */
|
||||
mmcp->part_config |= (1 << 3);
|
||||
puts("Partition switched to boot0\n");
|
||||
debug("Partition switched to boot0\n");
|
||||
}
|
||||
|
||||
static void set_gpios(void)
|
||||
|
|
@ -250,8 +290,6 @@ int board_init(void)
|
|||
if (read_eeprom() < 0)
|
||||
puts("Could not get board ID.\n");
|
||||
|
||||
set_console();
|
||||
|
||||
set_gpios();
|
||||
|
||||
/* @@se: With this call we disable a debug feature, that allows one to read out the memory
|
||||
|
|
@ -265,6 +303,29 @@ int board_init(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int board_early_init_r(void)
|
||||
{
|
||||
/* We need to force mmc_initialization here, so that
|
||||
* we have mmc available for read of /boot/consoledev */
|
||||
mmc_initialize(gd->bd);
|
||||
/* We need to force the env relocation so that it won't overwritte the
|
||||
* serial devices that we set in init_console */
|
||||
env_relocate();
|
||||
gd->env_valid = ENV_VALID;
|
||||
init_console();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int misc_init_r(void)
|
||||
{
|
||||
/* Because U-Boot is buggy, we need to call this funktion again
|
||||
* it will print the pre console buffer */
|
||||
console_init_f();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void set_phy_page(const char *miidev, int phy_addr, int page)
|
||||
{
|
||||
miiphy_write(miidev, phy_addr, 22, page);
|
||||
|
|
@ -284,7 +345,6 @@ static void set_phy_fast_blink_mode(int phy_addr)
|
|||
|
||||
int board_late_init(void)
|
||||
{
|
||||
|
||||
gpio_request(21, "RST_ETH_PHY_N");
|
||||
gpio_direction_output(21, 0);
|
||||
|
||||
|
|
@ -313,18 +373,30 @@ int board_network_enable(struct mii_dev *bus)
|
|||
|
||||
int checkboard(void)
|
||||
{
|
||||
puts("Board: NetModule NBHW18\n");
|
||||
debug("Board: NetModule NBHW18\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int board_fit_config_name_match(const char *name)
|
||||
{
|
||||
#ifdef CONFIG_SPL_BUILD
|
||||
/* SPL has enabled serial0 per default and will output everything
|
||||
* independend of /boot/consoledev */
|
||||
#define DEFAULT_DTB_NAME "armada-385-nbhw18-spl"
|
||||
#else
|
||||
/* U-Boot will read /boot/consoledev and based on that it
|
||||
* enables its own serial console */
|
||||
#define DEFAULT_DTB_NAME "armada-385-nbhw18-v1"
|
||||
#endif
|
||||
|
||||
/* Check if name fits our dts */
|
||||
return 0;
|
||||
return strcmp(DEFAULT_DTB_NAME, name);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_OF_BOARD_FIXUP
|
||||
|
||||
|
||||
int fdt_enable_by_ofname(void *rw_fdt_blob, char *ofname)
|
||||
{
|
||||
int offset = fdt_path_offset(rw_fdt_blob, ofname);
|
||||
|
|
@ -334,7 +406,9 @@ int fdt_enable_by_ofname(void *rw_fdt_blob, char *ofname)
|
|||
|
||||
int board_fix_fdt(void *fdt_blob)
|
||||
{
|
||||
puts("Enable SFP Port\n");
|
||||
debug("Enable SFP Port\n");
|
||||
|
||||
return fdt_enable_by_ofname(fdt_blob, "/soc/internal-regs/ethernet@30000");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#define DEBUG
|
||||
#undef DEBUG
|
||||
#include <common.h>
|
||||
#include <dm.h>
|
||||
#include <dm/device.h>
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@
|
|||
"eth2addr=00:11:22:33:44:56\0" \
|
||||
"eth3addr=00:11:22:33:44:57\0" \
|
||||
"ethact=ethernet@34000\0" \
|
||||
"add_sd_bootargs=setenv bootargs $bootargs root=/dev/mmcblk0p$root_part rootfstype=ext4 console=ttyS1,115200 rootwait loglevel=4\0" \
|
||||
"add_sd_bootargs=setenv bootargs $bootargs root=/dev/mmcblk0p$root_part rootfstype=ext4 console=$consoledev,115200 rootwait loglevel=4\0" \
|
||||
"add_version_bootargs=setenv bootargs $bootargs\0" \
|
||||
"fdt_skip_update=yes\0" \
|
||||
"sdbringup=echo Try bringup boot && ext4load mmc 0:$root_part $kernel_addr /boot/zImage && " \
|
||||
|
|
@ -114,7 +114,8 @@
|
|||
"tftptimeoutcountmax=5\0" \
|
||||
"bootpretryperiod=2000\0" \
|
||||
"autoload=false\0" \
|
||||
"tftp_recovery=tftpboot $kernel_addr recovery-image; tftpboot $fdt_addr recovery-dtb; setenv bootargs rdinit=/etc/preinit console=ttyO1,115200 debug; bootz $kernel_addr - $fdt_addr\0" \
|
||||
"defaultconsole=ttyS1\0" \
|
||||
"tftp_recovery=tftpboot $kernel_addr recovery-image; tftpboot $fdt_addr recovery-dtb; setenv bootargs rdinit=/etc/preinit console=$defaultconsole,115200 debug; bootz $kernel_addr - $fdt_addr\0" \
|
||||
"pxe_recovery=sleep 3 && dhcp && pxe get && pxe boot\0" \
|
||||
"load_fpga=ext4load mmc 0:$root_part $kernel_addr /logic/LG00000000 && nbhw_fpga program lattice 0xffffffff $kernel_addr $filesize && nbhw_fpga configure\0" \
|
||||
"recovery=run pxe_recovery || setenv ipaddr $ipaddr; setenv serverip $serverip; run tftp_recovery\0" /* setenv ipaddr and serverip is necessary, because dhclient can destroy the IPs inernally */
|
||||
|
|
@ -145,6 +146,7 @@
|
|||
|
||||
#ifdef CONFIG_SPL_BUILD
|
||||
#define CONFIG_SYS_MALLOC_SIMPLE
|
||||
#define CONFIG_OF_STDOUT_VIA_ALIAS
|
||||
#endif
|
||||
|
||||
#define CONFIG_SPL_STACK (0x40000000 + ((192 - 16) << 10))
|
||||
|
|
@ -189,6 +191,12 @@
|
|||
#undef CONFIG_AUTOBOOT_DELAY_STR
|
||||
#define CONFIG_AUTOBOOT_STOP_STR "s"
|
||||
|
||||
#define CONFIG_OF_BOARD_FIXUP
|
||||
#ifndef CONFIG_SPL_BUILD
|
||||
#undef CONFIG_REQUIRE_SERIAL_CONSOLE
|
||||
/* Wee need early init r to actually print the pre console buffer
|
||||
* because u-boot is buggy */
|
||||
#define CONFIG_BOARD_EARLY_INIT_R
|
||||
#define CONFIG_MISC_INIT_R
|
||||
#endif
|
||||
|
||||
#endif /* _CONFIG_DB_88F6820_GP_H */
|
||||
|
|
|
|||
Loading…
Reference in New Issue