Sync with Yocto project

This commit is contained in:
Rene Straub 2020-02-27 15:12:39 +01:00
parent 511ec4e72e
commit 5f9369c7a1
17 changed files with 347 additions and 161 deletions

View File

@ -258,6 +258,7 @@ static int _bd_init(void)
}
#ifdef CONFIG_NRSW_BUILD
/* TODO: Check if we can get rid of this descriptor and use eMMC partition table */
if (bd_get_context(&bdctx[2], BD_EEPROM_ADDR, PARTITION_ADDRESS) != 0) {
printf("%s() no valid partition table found\n", __func__);
return -1;
@ -818,6 +819,12 @@ static void init_gsm(void)
* 4.2.8 PWR_ON pin
* 4.2.9 RESET_N pin
*
* Functionality Yocto:
* - Leave GSM power enable as is (default at power up = off)
* - Set reset line inactive (note: inverter logic in HW present)
* - Leave button unpressed (note: inverter logic in HW present)
* - Modem shall be enabled by Linux system by enabling GSM power
* supply
*/
#ifdef CONFIG_NRSW_BUILD
int bus;
@ -896,9 +903,10 @@ int board_init(void)
init_leds();
set_status_led(1, 1); /* Orange */
set_indicator_led(0, 0); /* Off */
#ifndef CONFIG_NRSW_BUILD
ui_set_top_led(1, 1);
ui_set_bottom_led(1, 1);
ui_set_status_led(1, 1); /* Orange */
ui_set_indicator_led(0, 0); /* Off */
#endif
printf("OSC: %lu MHz\n", get_osclk()/1000000);
@ -956,6 +964,8 @@ static void get_variant_name(void)
printf("SYS: %s\n", hw_variant_name);
}
#ifdef CONFIG_NRSW_BUILD
static void get_hw_version(void)
{
char hw_versions[16];
@ -972,6 +982,18 @@ static void get_hw_version(void)
setenv("add_version_bootargs", new_env);
}
#else
static void get_hw_version(void)
{
bd_get_hw_version(&hw_ver, &hw_rev);
bd_get_hw_patch(&hw_patch);
printf("MB: V%d.%d\n", hw_ver, hw_rev);
}
#endif
static void get_pmic_version(void)
{
uint8_t val = 0x00;
@ -1060,20 +1082,22 @@ static void blink_led(int pulses)
{
const int pulse_width = 400*1000; /* 400ms */
#ifdef CONFIG_NRSW_BUILD
/* Assumes status LED is orange */
set_status_led(0, 0);
ui_set_top_led(0, 0);
#endif
while (pulses) {
udelay(pulse_width);
set_status_led(1, 1);
#ifndef CONFIG_NRSW_BUILD
ui_set_top_led(1, 1);
ui_set_status_led(1, 1);
#endif
udelay(pulse_width);
set_status_led(0, 0);
#ifndef CONFIG_NRSW_BUILD
ui_set_top_led(0, 0);
ui_set_status_led(0, 0);
#endif
pulses--;
}
@ -1081,7 +1105,7 @@ static void blink_led(int pulses)
udelay(pulse_width);
set_status_led(1, 1); /* Orange */
#ifndef CONFIG_NRSW_BUILD
ui_set_top_led(1, 1);
ui_set_status_led(1, 1);
#endif
}
@ -1222,8 +1246,8 @@ int board_late_init(void)
set_status_led(1, 1); /* Orange */
set_indicator_led(0, 0); /* Off */
#ifndef CONFIG_NRSW_BUILD
ui_set_top_led(1, 1); /* Orange */
ui_set_bottom_led(0, 0); /* Off */
set_status_led(1, 1); /* Orange */
set_indicator_led(0, 0); /* Off */
#endif
check_fct();

View File

@ -10,4 +10,4 @@ ifeq ($(CONFIG_SKIP_LOWLEVEL_INIT),)
obj-y := mux.o
endif
obj-y += board.o ../common/bdparser.o ../common/board_descriptor.o shield.o shield_can.o shield_comio.o fileaccess.o ../common/da9063.o
obj-y += board.o ../common/bdparser.o ../common/board_descriptor.o ../common/da9063.o shield.o shield_can.o shield_comio.o fileaccess.o

View File

@ -3,7 +3,7 @@
*
* Board functions for Netmodule NRHW 20, based on AM335x EVB
*
* Copyright (C) 2018-2019 NetModule AG - http://www.netmodule.com/
* Copyright (C) 2018-2020 NetModule AG - http://www.netmodule.com/
* Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
*
* SPDX-License-Identifier: GPL-2.0+
@ -40,8 +40,13 @@
#include "shield_comio.h"
#include "fileaccess.h"
DECLARE_GLOBAL_DATA_PTR;
/* TODO: place in proper header file */
extern void serial_set_console_index(int index);
extern int console_init_f(void);
DECLARE_GLOBAL_DATA_PTR;
/*
* CPU GPIOs
@ -133,6 +138,8 @@ DECLARE_GLOBAL_DATA_PTR;
#define IOEXT_LED4_GREEN_MASK (1U << 9)
#define IOEXT_LEDS_ALL_MASK (0x03FF)
#define NUM_INDICATOR_LEDS 5
#define DDR3_CLOCK_FREQUENCY (400)
@ -214,7 +221,7 @@ static void set_status_led(int red, int green)
da9063_release_i2c_bus(bus);
}
static void set_indicator(unsigned led, int red, int green)
static void set_indicator_led(unsigned led, int red, int green)
{
int old_bus;
uint led_red_mask = 0x1U << (2*led);
@ -295,17 +302,21 @@ static inline int __maybe_unused read_eeprom(void)
return _bd_init();
}
/* Selects console for SPL.
* U-Boot console is defined by CONSOLE_INDEX variable
* defined using serial_set_console_index(int index)
/*
* Selects console for SPL.
* U-Boot console is selected in set_console()
*/
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. */
if ((spl_boot_device() == BOOT_DEVICE_UART) ||
(spl_boot_device() == BOOT_DEVICE_JTAG)) {
/*
* 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
*/
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 {
@ -375,9 +386,10 @@ static void init_pmic_spl(void)
(void)da9063_set_reg(PMIC_REG_BUCK_ILIM_B, 0x50);
(void)da9063_set_reg(PMIC_REG_BUCK_ILIM_C, 0xFF);
/* TODO: C comments, not C++ */
// FB 57727 Use synchronous mode for buck converters
// This solves the occasional rail lock up problem
/*
* FB 57727 Use synchronous mode for buck converters
* This solves the occasional rail lock up problem
*/
(void)da9063_set_reg(PMIC_REG_BCORE1_CONF, 0x81);
(void)da9063_set_reg(PMIC_REG_BCORE2_CONF, 0x81);
(void)da9063_set_reg(PMIC_REG_BIO_CONF, 0x81);
@ -385,8 +397,7 @@ static void init_pmic_spl(void)
(void)da9063_set_reg(PMIC_REG_BPERI_CONF, 0x81);
/* Enable charging of RTC backup capacitor (1mA, 3.1V) */
(void)da9063_set_reg(PMIC_REG_BBAT_CONT, 0xCF);
/* TODO: Check documentation 1 mA correct ? */
(void)da9063_set_reg(PMIC_REG_BBAT_CONT, 0xAF);
da9063_release_i2c_bus(bus);
}
@ -396,6 +407,8 @@ struct reset_registers {
uint32_t value_crc;
};
#ifdef CONFIG_NRSW_BUILD
/* TODO: Move ethernet crc to dedicated file */
static uint32_t ether_crc(size_t len, uint8_t const *p)
{
@ -443,6 +456,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) */
@ -458,13 +473,19 @@ void am33xx_spl_board_init(void)
init_pmic_spl();
init_leds();
set_indicator(0, 1, 1); /* Orange */
#ifdef CONFIG_NRSW_BUILD
set_indicator_led(0, 1, 1); /* Orange */
#else
set_status_led(1, 0); /* Red */
set_indicator_led(0, 1, 0); /* Red */
#endif
/* Set MPU Frequency to what we detected now that voltages are set */
do_setup_dpll(&dpll_mpu_regs, &dpll_mpu_opp100);
/* TODO: Move to board_late_init? It is not urgent to have this in SPL. */
#ifdef CONFIG_NRSW_BUILD
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))
@ -599,16 +620,31 @@ static void init_pcie_slot(void)
static void init_gsm(void)
{
/*
* Perform power up sequence for Huawei ME909s.
* Perform power up sequence for TOBY-L2 modem.
*
* Modem is initially disabled and does not start automatically.
* Enable power and start modem by "pressing" POWER_ON_OFF input for 1.0s.
* TOBY-L2 series can be switched on in one of the following ways:
* - Rising edge on the VCC pin to a valid voltage for module supply,
* i.e. applying module supply
* - Low level on the PWR_ON pin, which is normally set high by an
* internal pull-up, for a valid time period when the applied VCC
* voltage is within the valid operating range (see section 4.2.8).
* - Low level on the RESET_N pin, which is normally set high by an
* internal pull-up, for a valid time period when the applied VCC
* voltage is within the valid operating range (see section 4.2.9).
*
* PWR_ON low time: 5 ms - Low time to switch-on the module
* RESET_N low time: 18..800 ms - Low time to switch-on the module
* 2.1..15 s - Low time to reset the module
* 16 s - Low time to switch-off the module
*
* References:
* - HUAWEI ME909s Series LTE LGA Module Hardware Guide, Issue 02, Date 2016-02-20
* 3.3.2 Power Supply VBAT Interface
* 3.4.2 Power-on/off Pin, Figure 3.7
* - uBlox TOBY-L2 Datasheet UBX-13004573 - R24
* 2.3.1 Module power-on
* 4.2.8 PWR_ON pin
* 4.2.9 RESET_N pin
*
*/
int bus;
puts("GSM: ");
@ -639,6 +675,15 @@ static void init_gsm(void)
puts("ready\n");
}
static void init_gnss(void)
{
/*
* Release GNSS reset line, so that module starts up early
*/
REQUEST_AND_SET_GPIO(GPIO_RST_GNSS);
}
#endif /* !defined(CONFIG_SPL_BUILD) */
@ -661,8 +706,12 @@ int board_init(void)
/* Let user know we're starting */
init_leds();
#ifdef CONFIG_NRSW_BUILD
set_status_led(1, 1); /* Orange */
#else
set_status_led(1, 1); /* Orange */
set_indicator_led(0, 0, 0); /* Off */
#endif
printf("OSC: %lu MHz\n", get_osclk()/1000000);
return 0;
@ -670,9 +719,6 @@ int board_init(void)
#if !defined(CONFIG_SPL_BUILD)
extern int console_init_f(void);
extern void serial_set_console_index(int index);
/*
* Set Linux console based on
* - Selection in /root/boot/consoledev
@ -706,12 +752,13 @@ void set_console(void)
}
}
/* If ttyS0 (COM_IO shield) is selected, make sure we really have
a COM_IO shield. Otherwise use the dummy tty. Actually this should
not happen. So it is just a sanity check to prevent the kernel from
crashing due to missing console, if something is configured wrong.
(Obviously thats just another hack, but there are no other options on
this platform because of a lot of conflicts between pins and uarts.)
/*
* If ttyS0 (COM_IO shield) is selected, make sure we really have
* a COM_IO shield. Otherwise use the dummy tty. Actually this should
* not happen. So it is just a sanity check to prevent the kernel from
* crashing due to missing console, if something is configured wrong.
* (Obviously thats just another hack, but there are no other options on
* this platform because of a lot of conflicts between pins and uarts.)
*/
if (strstr(defaultconsole, "ttyS0")) {
if (bd_get_shield(0) != SHIELD_COM_IO) {
@ -776,18 +823,22 @@ static void get_variant_name(void)
static void get_hw_version(void)
{
#ifdef CONFIG_NRSW_BUILD
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("HW20: V%d.%d\n", hw_ver, hw_rev);
#ifdef CONFIG_NRSW_BUILD
/* 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)
@ -825,7 +876,6 @@ static void check_jtag_boot(void)
}
}
static void check_fct(void)
{
/*
@ -872,7 +922,7 @@ static struct shield_command known_shield_commands[] = {
{
SHIELD_DUALCAN_PASSIVE,
"dualcan-passive",
"shield dualcan termination off off",
"shield dualcan-passive",
can_shield_passive_init
}
};
@ -952,20 +1002,24 @@ static bool get_button_state(void)
return pressed;
}
static void blink_led(int red)
static void blink_led(int red, int green)
{
int i;
const int pulse_width = 400*1000; /* 400ms */
int i;
/* Assumes status led is on (green), indicator off */
/* udelay(pulse_width); */
set_status_led(red, green);
for (i=0; i<NUM_INDICATOR_LEDS; i++) {
set_indicator_led(i, red, green);
}
/* Assumes green status LED is on */
udelay(pulse_width);
set_status_led(red, 1-red);
for (i=0; i<5; i++)
set_indicator(i, red, 1-red);
udelay(pulse_width);
set_status_led(0, 1);
for (i=0; i<5; i++)
set_indicator(i, 0, 0);
set_status_led(0, 1); /* Green */
for (i=0; i<NUM_INDICATOR_LEDS; i++) {
set_indicator_led(i, 0, 0);
}
}
static void check_reset_button(void)
@ -982,11 +1036,11 @@ static void check_reset_button(void)
if (counter == 2000) {
/* Indicate factory reset threshold */
blink_led(0);
blink_led(0, 1); /* Green */
}
else if (counter == 12000) {
/* Indicate recovery boot threshold */
blink_led(1);
blink_led(1, 0); /* Red */
}
} while (counter < 12000);
@ -1040,20 +1094,26 @@ int board_late_init(void)
/* Initialize pins */
REQUEST_AND_CLEAR_GPIO(GPIO_WLAN_EN);
REQUEST_AND_CLEAR_GPIO(GPIO_BT_EN);
REQUEST_AND_CLEAR_GPIO(GPIO_RST_GNSS);
REQUEST_AND_CLEAR_GPIO(GPIO_DIG_OUT);
init_ethernet_switch();
init_usb_hub();
init_pcie_slot();
init_gsm();
init_gnss();
/*
* Check if a user action is requested
* - Short press: factory reset
* - Long press: recovery boot
*/
check_reset_button();
set_console();
shield_init();
set_status_led(0, 0); /* WAN led off */
set_indicator(0, 0, 1); /* Green */
set_indicator_led(0, 0, 1); /* Green */
check_fct();
check_jtag_boot();
@ -1199,58 +1259,63 @@ static void ft_enable_node(void* blob, const char* name)
}
}
static void ft_dio(void *blob, int shield_type)
static void ft_shields(void* blob)
{
int shield_type = -1;
shield_type = bd_get_shield(0);
switch (shield_type) {
/* If COM/IO shield is present enable its I/Os */
case SHIELD_COM_IO:
ft_enable_node(blob, "/netbox_dio_comio");
break;
default:
ft_enable_node(blob, "/netbox_dio_default");
break;
}
}
static void ft_serial(void *blob, int shield_type)
{
switch (shield_type) {
case SHIELD_COM_IO:
/* TODO: Should use alias serial0 */
ft_enable_node(blob, "/ocp/serial@44e09000");
break;
default:
/* Do not enable ttyS0, if we have a DUALCAN shield as the
pins conflict with the CAN. */
break;
}
}
static void ft_dcan(void *blob, int shield_type)
{
switch (shield_type) {
/* If Dual CAN shield is present enable dcan0, dcan1N1 */
case SHIELD_DUALCAN:
case SHIELD_DUALCAN_PASSIVE:
/* TODO: Should use alias d_can0, d_can1 */
ft_enable_node(blob, "/ocp/can@481cc000");
ft_enable_node(blob, "/ocp/can@481d0000");
break;
default:
ft_enable_node(blob, "/netbox_dio_default");
break;
};
}
static void ft_bootloader_version(void *blob)
{
int node_offset;
static const char version_string[] = U_BOOT_VERSION_STRING;
node_offset = fdt_path_offset(blob, "/");
if (node_offset != -1) {
fdt_setprop_string(blob, node_offset, "nm,bootloader,version", version_string);
}
}
static void ft_hw_info(void *blob)
{
int node_offset;
char hw_version[16];
snprintf(hw_version, sizeof(hw_version), "%d.%d.%d", hw_ver, hw_rev, hw_patch);
node_offset = fdt_path_offset(blob, "/");
if (node_offset != -1) {
fdt_setprop_string(blob, node_offset, "model", hw_variant_name);
fdt_setprop_string(blob, node_offset, "nm,carrierboard,version", hw_version);
}
}
int ft_board_setup(void *blob, bd_t *bd)
{
int shield_type = -1;
ft_bootloader_version(blob);
ft_hw_info(blob);
shield_type = bd_get_shield(0);
ft_dio(blob, shield_type);
ft_serial(blob, shield_type);
ft_dcan(blob, shield_type);
ft_shields(blob);
return 0;
}

View File

@ -10,6 +10,7 @@
#ifndef _BOARD_H_
#define _BOARD_H_
/*
* We have three pin mux functions that must exist. We must be able to enable
* uart0, for initial output and i2c2 to read the main EEPROM. We then have a
@ -19,17 +20,9 @@
void enable_uart0_pin_mux(void);
void disable_uart0_pin_mux(void);
void enable_uart1_pin_mux(void);
void enable_uart3_pin_mux(void);
void enable_uart5_pin_mux(void);
/*
void enable_uart2_pin_mux(void);
void enable_uart3_pin_mux(void);
void enable_uart4_pin_mux(void);
void enable_uart5_pin_mux(void);
*/
void enable_i2c0_pin_mux(void);
void enable_i2c2_pin_mux(void);
void enable_board_pin_mux(void);
#define GPIO_TO_PIN(bank, gpio) (32 * (bank) + (gpio))
#endif

View File

@ -251,8 +251,8 @@ void enable_uart1_pin_mux(void)
configure_module_pin_mux(uart1_pin_mux);
}
void enable_uart5_pin_mux(void)
{
configure_module_pin_mux(uart5_pin_mux);
}

View File

@ -68,6 +68,7 @@ U_BOOT_CMD(
shield, 6, 1, do_shieldmode,
"Set the shield mode",
"dualcan termination [on|off] [on|off]\n"
"shield dualcan-passive\n"
"shield comio mode [rs232|rs485] termination [on|off]\n"
);

View File

@ -184,16 +184,18 @@ static int set_shieldmode(char * const argv[], int argc)
return configure_shieldmode(get_mode_from_args(argv, argc));
}
static int reject_shieldmode(char * const argv[], int argc)
static int no_options(char * const argv[], int argc)
{
printf("mode not allowed for this shield\n");
if (argc != 0) {
debug("Too many arguments\n");
return -1;
}
return 0;
}
/* TODO: Static ? */
struct shield_t can_shield = {
static struct shield_t can_shield = {
"dualcan", set_shieldmode
};
@ -202,8 +204,8 @@ void can_shield_init(void)
shield_register(&can_shield);
}
struct shield_t can_shield_passive = {
"dualcan-passive", reject_shieldmode
static struct shield_t can_shield_passive = {
"dualcan-passive", no_options
};
void can_shield_passive_init(void)

View File

@ -10,4 +10,4 @@ ifeq ($(CONFIG_SKIP_LOWLEVEL_INIT),)
obj-y := mux.o
endif
obj-y += board.o ../common/bdparser.o ../common/board_descriptor.o shield.o shield_can.o shield_comio.o fileaccess.o ../common/da9063.o
obj-y += board.o ../common/bdparser.o ../common/board_descriptor.o ../common/da9063.o shield.o shield_can.o shield_comio.o fileaccess.o

View File

@ -3,7 +3,7 @@
*
* Board functions for Netmodule NRHW 24, based on AM335x EVB
*
* Copyright (C) 2018-2019 NetModule AG - http://www.netmodule.com/
* Copyright (C) 2018-2020 NetModule AG - http://www.netmodule.com/
* Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
*
* SPDX-License-Identifier: GPL-2.0+
@ -40,6 +40,12 @@
#include "shield_comio.h"
#include "fileaccess.h"
/* TODO: place in proper header file */
extern void serial_set_console_index(int index);
extern int console_init_f(void);
DECLARE_GLOBAL_DATA_PTR;
/*
@ -47,7 +53,7 @@ DECLARE_GLOBAL_DATA_PTR;
*
* (A17) GPIO0_2: RST_GNSS~
* (A16) GPIO0_5: EXTINT_GNSS
* (???) GPIO0_6: TIMEPULSE_GNSS
* (C15) GPIO0_6: TIMEPULSE_GNSS
*
* (J18) GPIO0_16: RST_PHY~
* (U12) GPIO0_27: RST_SHIELD~
@ -142,7 +148,12 @@ err_free_gpio:
#endif
static void set_status_led(int on)
static void init_leds(void)
{
/* No init code required */
}
static void set_status_led(int red, int green)
{
int bus;
@ -151,17 +162,17 @@ static void set_status_led(int on)
* Enable LED when either red or green is desired.
*/
bus = da9063_claim_i2c_bus();
da9063_set_gpio(PMIC_LED1, on);
da9063_set_gpio(PMIC_LED1, red | green);
da9063_release_i2c_bus(bus);
}
static void set_indicator_led(int on)
static void set_indicator_led(int red, int green)
{
int bus;
/* See above */
bus = da9063_claim_i2c_bus();
da9063_set_gpio(PMIC_LED0, on);
da9063_set_gpio(PMIC_LED0, red | green);
da9063_release_i2c_bus(bus);
}
@ -225,21 +236,25 @@ static inline int __maybe_unused read_eeprom(void)
return _bd_init();
}
/* Selects console for SPL.
* U-Boot console is defined by CONSOLE_INDEX variable
* defined using serial_set_console_index(int index)
/*
* Selects console for SPL.
* U-Boot console is selected in set_console()
*/
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. */
if ((spl_boot_device() == BOOT_DEVICE_UART) ||
(spl_boot_device() == BOOT_DEVICE_JTAG)) {
/*
* 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
*/
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;
}
@ -247,10 +262,8 @@ struct serial_device *default_serial_console(void)
#ifndef CONFIG_SKIP_LOWLEVEL_INIT
// TODO: Double check !
static const struct ddr_data ddr3_data = {
/* Ratios were optimized by DDR3 training software from TI */
/* TODO: Evaluate new values and update */
.datardsratio0 = 0x39, /* 0x39 */
.datawdsratio0 = 0x3f, /* 0x40 */ /* 3f */
.datafwsratio0 = 0x98, /* 0x96 */ /* 98 */
@ -332,6 +345,7 @@ struct reset_registers {
uint32_t value_crc;
};
#ifdef CONFIG_NRSW_BUILD
/* TODO: Move ethernet crc to dedicated file */
static uint32_t ether_crc(size_t len, uint8_t const *p)
@ -380,6 +394,7 @@ void check_pmic_reset_reason(unsigned int reset_reason_shm_location)
da9063_release_i2c_bus(bus);
}
#endif
void am33xx_spl_board_init(void)
{
@ -395,10 +410,18 @@ void am33xx_spl_board_init(void)
/* Setup PMIC */
init_pmic_spl();
init_leds();
#ifndef CONFIG_NRSW_BUILD
set_status_led(1, 0); /* Red */
set_indicator_led(1, 0); /* Red */
#endif
/* Set MPU Frequency to what we detected now that voltages are set */
do_setup_dpll(&dpll_mpu_regs, &dpll_mpu_opp100);
#ifdef CONFIG_NRSW_BUILD
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))
@ -526,6 +549,12 @@ static void init_gsm(void)
* 4.2.8 PWR_ON pin
* 4.2.9 RESET_N pin
*
* Functionality Yocto:
* - Leave GSM power enable as is (default at power up = off)
* - Set reset line inactive (note: inverter logic in HW present)
* - Leave button unpressed (note: inverter logic in HW present)
* - Modem shall be enabled by Linux system by enabling GSM power
* supply
*/
#ifdef CONFIG_NRSW_BUILD
int bus;
@ -606,8 +635,9 @@ int board_init(void)
da9063_init(CONFIG_PMIC_I2C_BUS);
/* Let user know we're starting */
set_status_led(1);
set_indicator_led(0);
init_leds();
set_status_led(1, 1); /* Orange */
set_indicator_led(0, 0); /* Off */
printf("OSC: %lu MHz\n", get_osclk()/1000000);
@ -616,9 +646,6 @@ int board_init(void)
#if !defined(CONFIG_SPL_BUILD)
extern int console_init_f(void);
extern void serial_set_console_index(int index);
/*
* Set Linux console based on
* - Selection in /root/boot/consoledev
@ -664,6 +691,9 @@ void set_console(void)
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] <= ' ') {
@ -713,18 +743,22 @@ static void get_variant_name(void)
static void get_hw_version(void)
{
#ifdef CONFIG_NRSW_BUILD
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_BUILD
/* 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)
@ -808,7 +842,7 @@ static struct shield_command known_shield_commands[] = {
{
SHIELD_DUALCAN_PASSIVE,
"dualcan-passive",
"shield dualcan termination off off",
"shield dualcan-passive",
can_shield_passive_init
}
};
@ -892,20 +926,23 @@ static void blink_led(int pulses)
{
const int pulse_width = 400*1000; /* 400ms */
set_status_led(0);
/* Assumes status led on, indicator off */
set_status_led(0, 0);
while (pulses) {
udelay(pulse_width);
set_status_led(1);
set_indicator_led(1);
set_status_led(1, 1);
set_indicator_led(1, 1);
udelay(pulse_width);
set_status_led(0);
set_indicator_led(0);
set_status_led(0, 0);
set_indicator_led(0, 0);
pulses--;
}
udelay(pulse_width);
set_status_led(1);
set_status_led(1, 1); /* Orange */
}
static void check_reset_button(void)
@ -1155,6 +1192,7 @@ static void ft_shields(void* blob)
break;
case SHIELD_DUALCAN:
case SHIELD_DUALCAN_PASSIVE:
/* TODO: Should use alias d_can0, d_can1 */
ft_enable_node(blob, "/ocp/can@481cc000");
ft_enable_node(blob, "/ocp/can@481d0000");
@ -1171,11 +1209,37 @@ static void ft_shields(void* blob)
}
static void ft_bootloader_version(void *blob)
{
int node_offset;
static const char version_string[] = U_BOOT_VERSION_STRING;
node_offset = fdt_path_offset(blob, "/");
if (node_offset != -1) {
fdt_setprop_string(blob, node_offset, "nm,bootloader,version", version_string);
}
}
static void ft_hw_info(void *blob)
{
int node_offset;
char hw_version[16];
snprintf(hw_version, sizeof(hw_version), "%d.%d.%d", hw_ver, hw_rev, hw_patch);
node_offset = fdt_path_offset(blob, "/");
if (node_offset != -1) {
fdt_setprop_string(blob, node_offset, "model", hw_variant_name);
fdt_setprop_string(blob, node_offset, "nm,carrierboard,version", hw_version);
}
}
int ft_board_setup(void *blob, bd_t *bd)
{
ft_shields(blob);
ft_bootloader_version(blob);
ft_hw_info(blob);
ft_shields(blob);
return 0;
}

View File

@ -68,6 +68,7 @@ U_BOOT_CMD(
shield, 6, 1, do_shieldmode,
"Set the shield mode",
"dualcan termination [on|off] [on|off]\n"
"shield dualcan-passive\n"
"shield comio mode [rs232|rs485] termination [on|off]\n"
);

View File

@ -184,16 +184,18 @@ static int set_shieldmode(char * const argv[], int argc)
return configure_shieldmode(get_mode_from_args(argv, argc));
}
static int reject_shieldmode(char * const argv[], int argc)
static int no_options(char * const argv[], int argc)
{
printf("mode not allowed for this shield\n");
if (argc != 0) {
debug("Too many arguments\n");
return -1;
}
return 0;
}
/* TODO: Static ? */
struct shield_t can_shield = {
static struct shield_t can_shield = {
"dualcan", set_shieldmode
};
@ -202,8 +204,8 @@ void can_shield_init(void)
shield_register(&can_shield);
}
struct shield_t can_shield_passive = {
"dualcan-passive", reject_shieldmode
static struct shield_t can_shield_passive = {
"dualcan-passive", no_options
};
void can_shield_passive_init(void)

View File

@ -18,7 +18,10 @@
#include <malloc.h>
#include <dm/root.h>
#include <linux/compiler.h>
#ifdef CONFIG_NRSW_BUILD
#include <spl_version_autogenerated.h>
#endif
DECLARE_GLOBAL_DATA_PTR;
@ -454,7 +457,11 @@ void preloader_console_init(void)
gd->have_console = 1;
#ifdef CONFIG_NRSW_BUILD
puts("\n" SPL_VERSION "\n");
#else
puts("\n");
#endif
puts("U-Boot SPL " PLAIN_VERSION " (" U_BOOT_DATE " - " \
U_BOOT_TIME ")\n");
#ifdef CONFIG_SPL_DISPLAY_PRINT

View File

@ -420,8 +420,10 @@ static int omap24_i2c_read(struct i2c_adapter *adap, uchar chip, uint addr,
}
if (status == 0 || (status & I2C_STAT_NACK)) {
i2c_error = 1;
#ifdef CONFIG_NRSW_BUILD
printf("i2c_read: error waiting for addr ACK (status=0x%x)\n",
status);
#endif
goto rd_exit;
}
if (alen) {

View File

@ -269,6 +269,9 @@ int eth_phy_timeout(void);
#endif
/* Network. */
#define CONFIG_IP_DEFRAG /* so we can use large tftp blocks */
#define CONFIG_TFTP_TSIZE /* tftp transfer size, progress bar */
#define CONFIG_PHYLIB
#define CONFIG_PHY_SMSC

View File

@ -182,6 +182,7 @@ int eth_phy_timeout(void);
/* UART Configuration */
#define CONFIG_SYS_NS16550_COM1 0x44e09000 /* UART0: XModem Boot, Shield */
#define CONFIG_SYS_NS16550_COM2 0x48022000 /* UART1: eMMC Boot, User UART */
/* TODO: Can the following be removed, as they shouldn't be required for bootloader */
#define CONFIG_SYS_NS16550_COM3 0x48024000 /* Unused */
#define CONFIG_SYS_NS16550_COM4 0x481A6000 /* GNSS */
#define CONFIG_SYS_NS16550_COM5 0x481A8000 /* Unused */
@ -276,6 +277,9 @@ int eth_phy_timeout(void);
#endif
/* Network. */
#define CONFIG_IP_DEFRAG /* so we can use large tftp blocks */
#define CONFIG_TFTP_TSIZE /* tftp transfer size, progress bar */
#define CONFIG_PHYLIB
/* Ethernet Switch Support */

View File

@ -183,10 +183,6 @@ int eth_phy_timeout(void);
/* UART Configuration */
#define CONFIG_SYS_NS16550_COM1 0x44e09000 /* UART0: XModem Boot, Shield */
#define CONFIG_SYS_NS16550_COM2 0x48022000 /* UART1: Debug UART (Internal) */
#define CONFIG_SYS_NS16550_COM3 0x48024000 /* Unused */
#define CONFIG_SYS_NS16550_COM4 0x481A6000 /* GNSS */
#define CONFIG_SYS_NS16550_COM5 0x481A8000 /* Unused */
#define CONFIG_SYS_NS16550_COM6 0x481AA000 /* Bluetooth */
#define CONFIG_I2C
#define CONFIG_I2C_MULTI_BUS
@ -269,6 +265,9 @@ int eth_phy_timeout(void);
#endif
/* Network. */
#define CONFIG_IP_DEFRAG /* so we can use large tftp blocks */
#define CONFIG_TFTP_TSIZE /* tftp transfer size, progress bar */
#define CONFIG_PHYLIB
#define CONFIG_PHY_SMSC

View File

@ -12,7 +12,12 @@
#include <version.h>
#include <linux/ctype.h>
#include <asm/io.h>
#ifdef CONFIG_NRSW_BUILD
#include <version_autogenerated.h>
#endif
#ifdef CONFIG_NRSW_BUILD
int display_options (void)
{
@ -25,6 +30,20 @@ int display_options (void)
return 0;
}
#else /* CONFIG_NRSW_BUILD */
int display_options (void)
{
#if defined(BUILD_TAG)
printf ("\n\n%s, Build: %s\n\n", version_string, BUILD_TAG);
#else
printf ("\n\n%s\n\n", version_string);
#endif
return 0;
}
#endif /* CONFIG_NRSW_BUILD */
void print_freq(uint64_t freq, const char *s)
{
unsigned long m = 0;