nmhw24: align board file with nrsw implementation
This commit is contained in:
parent
05a415b524
commit
bb120c7271
|
|
@ -40,6 +40,11 @@
|
|||
#include "shield_comio.h"
|
||||
#include "fileaccess.h"
|
||||
|
||||
|
||||
/* TODO: place in proper header file */
|
||||
extern void serial_set_console_index(int index);
|
||||
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
/*
|
||||
|
|
@ -238,26 +243,22 @@ static inline int __maybe_unused read_eeprom(void)
|
|||
*/
|
||||
struct serial_device *default_serial_console(void)
|
||||
{
|
||||
/* Mux pins for selected UART properly.
|
||||
* Note: uart indexes start at 0 while
|
||||
* eserial indexes start at 1.
|
||||
/*
|
||||
* Mux pins for selected UART properly.
|
||||
* Note: UART indexes start at 0 while eserial indexes start at 1.
|
||||
*
|
||||
* Provide console on internal UART1 regardless of boot mode.
|
||||
* This only has a side effect when using X-Modem boot
|
||||
*/
|
||||
|
||||
/* Provide UART on UART2 regardless of boot mode */
|
||||
enable_uart1_pin_mux();
|
||||
return &eserial2_device;
|
||||
|
||||
#if 0 /* TODO: Check whether really required */
|
||||
if ((spl_boot_device() == BOOT_DEVICE_UART) ||
|
||||
(spl_boot_device() == BOOT_DEVICE_JTAG)) {
|
||||
if (spl_boot_device() == BOOT_DEVICE_UART) {
|
||||
/* Continue booting from UART in case of serial (xmodem) boot */
|
||||
enable_uart0_pin_mux();
|
||||
return &eserial1_device;
|
||||
} else {
|
||||
/* Use internal uart, if no output shall be seen. */
|
||||
/* Regular and JTAG boot use internal UART1 */
|
||||
enable_uart1_pin_mux();
|
||||
return &eserial2_device;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef CONFIG_SKIP_LOWLEVEL_INIT
|
||||
|
|
@ -347,6 +348,8 @@ struct reset_registers {
|
|||
uint32_t value_crc;
|
||||
};
|
||||
|
||||
#ifdef CONFIG_NRSW
|
||||
|
||||
/* TODO: Move ethernet crc to dedicated file */
|
||||
static uint32_t ether_crc(size_t len, uint8_t const *p)
|
||||
{
|
||||
|
|
@ -394,6 +397,8 @@ void check_pmic_reset_reason(unsigned int reset_reason_shm_location)
|
|||
da9063_release_i2c_bus(bus);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void am33xx_spl_board_init(void)
|
||||
{
|
||||
/* Set CPU speed to 600 MHz (fix) */
|
||||
|
|
@ -415,7 +420,10 @@ void am33xx_spl_board_init(void)
|
|||
/* Set MPU Frequency to what we detected now that voltages are set */
|
||||
do_setup_dpll(&dpll_mpu_regs, &dpll_mpu_opp100);
|
||||
|
||||
#ifdef CONFIG_NRSW
|
||||
/* TODO: Move to board_late_init? It is not urgent to have this in SPL. */
|
||||
check_pmic_reset_reason(RESET_REASON_SHM_LOCATION);
|
||||
#endif
|
||||
|
||||
/* Debugger can place marker at end of SRAM to stop boot here */
|
||||
if (is_jtag_boot(CONFIG_JTAG_MARKER_SPL))
|
||||
|
|
@ -567,6 +575,7 @@ static void init_gnss(void)
|
|||
REQUEST_AND_SET_GPIO(GPIO_RST_GNSS);
|
||||
}
|
||||
|
||||
/* TODO: Double Check - WiFi is enabled by sequencer already */
|
||||
static void init_wifi(void)
|
||||
{
|
||||
int bus;
|
||||
|
|
@ -600,7 +609,7 @@ int board_init(void)
|
|||
/* Let user know we're starting */
|
||||
init_leds();
|
||||
set_status_led(1, 1); /* Orange */
|
||||
set_indicator_led(1, 1); /* Orange */
|
||||
set_indicator_led(0, 0); /* Off */
|
||||
|
||||
printf("OSC: %lu MHz\n", get_osclk()/1000000);
|
||||
|
||||
|
|
@ -609,32 +618,31 @@ int board_init(void)
|
|||
|
||||
#if !defined(CONFIG_SPL_BUILD)
|
||||
|
||||
/* TODO: Move to top of file or place into header file */
|
||||
extern int console_init_f(void);
|
||||
extern void serial_set_console_index(int index);
|
||||
|
||||
/*
|
||||
* Set Linux console based on
|
||||
* - Selection in /root/boot/consoledev
|
||||
* - Available tty interfaces
|
||||
* - ttyS1: standard console (default, internal only)
|
||||
* - ttyS0: COMIO shield (or used as console by kernel,
|
||||
* - ttyS0: COM/IO shield (or used as console by kernel,
|
||||
* when no other console available)
|
||||
* - ttyNull0: Dummy device if no real UART is available
|
||||
*/
|
||||
void set_console(void)
|
||||
{
|
||||
const char *defaultconsole = getenv("defaultconsole");
|
||||
int shield_id = bd_get_shield(0);
|
||||
|
||||
/* Set default console to ttyS1 if not yet defined in env */
|
||||
if (defaultconsole == 0) {
|
||||
setenv("defaultconsole", "ttyS1");
|
||||
}
|
||||
|
||||
/* Always use internal console for u-boot
|
||||
as comio shield is not ready at that time.
|
||||
(Needs to be initialized first using the
|
||||
shieldcmd that is run by bootcmd.) */
|
||||
/*
|
||||
* Always use internal console for u-boot
|
||||
* as COM/IO shield is not ready at that time.
|
||||
* (Needs to be initialized first using the
|
||||
* shieldcmd that is run by bootcmd.)
|
||||
*/
|
||||
serial_set_console_index(1);
|
||||
|
||||
#if defined(CONFIG_PRE_CONSOLE_BUFFER)
|
||||
|
|
@ -642,23 +650,25 @@ void set_console(void)
|
|||
console_init_f(); /* stage 1 init of console */
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
if (shield_id != SHIELD_COM_IO) {
|
||||
/* Don't allow changing to ttyS0 for the kernel console, because
|
||||
* ttyS0 is not available if no comio shield is populated. */
|
||||
return;
|
||||
}
|
||||
if (shield_id == SHIELD_COM_IO) {
|
||||
char buf[20];
|
||||
|
||||
/* With comio shield the defaultconsole for the kernel should
|
||||
be ttyS0 and not ttyS1 */
|
||||
/*
|
||||
* With COM/IO shield the defaultconsole for the kernel should
|
||||
* be ttyS0 (external port).
|
||||
* If consoledev file is present, take the tty defined in it as console
|
||||
*/
|
||||
setenv("defaultconsole", "ttyS0");
|
||||
|
||||
/* If consoledev file is present, take the tty defined in it as console */
|
||||
if (read_file("/root/boot/consoledev",buf, sizeof(buf)) > 3) {
|
||||
if (strstr(buf, "tty") == buf) {
|
||||
int i;
|
||||
/* TODO: What is this code doing? */
|
||||
/* Truncating after whitespace? */
|
||||
/* are there broken consoledev files around ? */
|
||||
buf[sizeof(buf)-1] = 0;
|
||||
for (i=0; i<sizeof(buf); i++) {
|
||||
if (buf[i]<=' ') {
|
||||
if (buf[i] <= ' ') {
|
||||
buf[i] = 0;
|
||||
break;
|
||||
}
|
||||
|
|
@ -666,7 +676,7 @@ void set_console(void)
|
|||
setenv("defaultconsole", buf);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static void set_devicetree_name(void)
|
||||
|
|
@ -705,10 +715,22 @@ static void get_variant_name(void)
|
|||
|
||||
static void get_hw_version(void)
|
||||
{
|
||||
#ifdef CONFIG_NRSW
|
||||
char hw_versions[16];
|
||||
char new_env[256]; /* current bootargs = 84 bytes */
|
||||
#endif
|
||||
|
||||
bd_get_hw_version(&hw_ver, &hw_rev);
|
||||
bd_get_hw_patch(&hw_patch);
|
||||
|
||||
printf("HW24: V%d.%d\n", hw_ver, hw_rev);
|
||||
|
||||
#ifdef CONFIG_NRSW
|
||||
/* add hardware versions to environment */
|
||||
snprintf(hw_versions, sizeof(hw_versions), "CP=%d.%d", hw_ver, hw_rev);
|
||||
snprintf(new_env, sizeof(new_env), "setenv bootargs $bootargs %s", hw_versions);
|
||||
setenv("add_version_bootargs", new_env);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void get_pmic_version(void)
|
||||
|
|
@ -806,20 +828,20 @@ static void shield_config(void)
|
|||
#define MAX_SHIELD_CMD_LEN 128
|
||||
|
||||
char shieldcmd_linux[MAX_SHIELD_CMD_LEN];
|
||||
const char *shieldcmd;
|
||||
const char *shieldcmd = ";"; /* default shield command is empty */
|
||||
const struct shield_command *cmd;
|
||||
int len;
|
||||
|
||||
int shield_id = bd_get_shield(0);
|
||||
if (shield_id < 0) {
|
||||
debug("No shield found in bd\n");
|
||||
return;
|
||||
goto end;
|
||||
}
|
||||
|
||||
cmd = get_shield_command(shield_id);
|
||||
if (cmd == NULL) {
|
||||
printf ("Unknown shield id %d\n", shield_id);
|
||||
return;
|
||||
goto end;
|
||||
}
|
||||
|
||||
printf("Shield:%s\n", cmd->name);
|
||||
|
|
@ -836,6 +858,7 @@ static void shield_config(void)
|
|||
shieldcmd = shieldcmd_linux;
|
||||
}
|
||||
|
||||
end:
|
||||
setenv("shieldcmd", shieldcmd);
|
||||
}
|
||||
|
||||
|
|
@ -862,13 +885,24 @@ static bool get_button_state(void)
|
|||
return pressed;
|
||||
}
|
||||
|
||||
static void blink_led(void)
|
||||
static void blink_led(int pulses)
|
||||
{
|
||||
const int pulse_width = 400*1000; /* 400ms */
|
||||
|
||||
/* Assumes status LED is orange */
|
||||
/* Assumed status led on, indicator off */
|
||||
set_status_led(0, 0);
|
||||
|
||||
while (pulses) {
|
||||
udelay(pulse_width);
|
||||
set_status_led(0, 0); /* Off */
|
||||
set_status_led(1, 1);
|
||||
set_indicator_led(1, 1);
|
||||
|
||||
udelay(pulse_width);
|
||||
set_status_led(0, 0);
|
||||
set_indicator_led(0, 0);
|
||||
|
||||
pulses--;
|
||||
}
|
||||
|
||||
udelay(pulse_width);
|
||||
set_status_led(1, 1); /* Orange */
|
||||
|
|
@ -888,12 +922,11 @@ static void check_reset_button(void)
|
|||
|
||||
if (counter == 2000) {
|
||||
/* Indicate factory reset threshold */
|
||||
blink_led();
|
||||
blink_led(1);
|
||||
}
|
||||
else if (counter == 12000) {
|
||||
/* Indicate recovery boot threshold */
|
||||
blink_led();
|
||||
blink_led();
|
||||
blink_led(2);
|
||||
}
|
||||
} while (counter < 12000);
|
||||
|
||||
|
|
@ -920,6 +953,7 @@ static void check_reset_button(void)
|
|||
/* Boot into recovery for duration > 12s */
|
||||
puts("Booting recovery image...\n");
|
||||
|
||||
/* TODO: ... internal .. port on HW24 */
|
||||
/* Set consoledev to external port */
|
||||
setenv("defaultconsole", "ttyS1");
|
||||
|
||||
|
|
@ -964,9 +998,6 @@ int board_late_init(void)
|
|||
set_console();
|
||||
shield_init();
|
||||
|
||||
set_status_led(1, 1); /* Orange */
|
||||
set_indicator_led(0, 0); /* Off */
|
||||
|
||||
check_fct();
|
||||
check_jtag_boot();
|
||||
#endif
|
||||
|
|
@ -1165,8 +1196,15 @@ int ft_board_setup(void *blob, bd_t *bd)
|
|||
{
|
||||
ft_bootloader_version(blob);
|
||||
ft_hw_info(blob);
|
||||
|
||||
ft_shields(blob);
|
||||
|
||||
/*
|
||||
* Enable uart1 (ttyS0) always as kernel needs it as fallback console,
|
||||
* if (ttyS1) is not available as console.
|
||||
*/
|
||||
ft_enable_node(blob, "/ocp/serial@44e09000");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ int eth_phy_timeout(void);
|
|||
*/
|
||||
|
||||
#define KERNEL_ADDR "0x80000000"
|
||||
/*#define FDT_ADDR "0x82000000" /* /* NRSW, trying to use FDT_ADDR_R = 0x83F00000 instead */
|
||||
/*#define FDT_ADDR "0x82000000" */ /* NRSW, trying to use FDT_ADDR_R = 0x83F00000 instead */
|
||||
#define FDT_ADDR_R "0x83F00000"
|
||||
#define PXE_ADDR "0x8BE00000"
|
||||
#define LOAD_ADDR "0x8C000000"
|
||||
|
|
|
|||
Loading…
Reference in New Issue