diff --git a/board/nm/nmhw21/board.c b/board/nm/nmhw21/board.c index cd87c63715..1ba63a67ce 100644 --- a/board/nm/nmhw21/board.c +++ b/board/nm/nmhw21/board.c @@ -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; @@ -796,28 +797,34 @@ static void init_gsm(void) { /* * Perform power up sequence for TOBY-L2 modem. - * + * * 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, + * - 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 + * - 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.9). - * + * 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: * - 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 - * + * + * 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(); diff --git a/board/nm/nrhw20/Makefile b/board/nm/nrhw20/Makefile index c9e59635af..813f0b8103 100644 --- a/board/nm/nrhw20/Makefile +++ b/board/nm/nrhw20/Makefile @@ -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 diff --git a/board/nm/nrhw20/board.c b/board/nm/nrhw20/board.c index c6d5cca1ed..ebe87ca040 100644 --- a/board/nm/nrhw20/board.c +++ b/board/nm/nrhw20/board.c @@ -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. - * - * Modem is initially disabled and does not start automatically. - * Enable power and start modem by "pressing" POWER_ON_OFF input for 1.0s. - * + * Perform power up sequence for TOBY-L2 modem. + * + * 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,13 +752,14 @@ 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) { setenv("defaultconsole", "ttyNull"); @@ -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 3) { + 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 #include #include + +#ifdef CONFIG_NRSW_BUILD #include +#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 diff --git a/drivers/i2c/omap24xx_i2c.c b/drivers/i2c/omap24xx_i2c.c index a7f3fb4a79..3e33c522e2 100644 --- a/drivers/i2c/omap24xx_i2c.c +++ b/drivers/i2c/omap24xx_i2c.c @@ -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) { diff --git a/include/configs/am335x_nmhw21.h b/include/configs/am335x_nmhw21.h index 9957e3013d..74cfdf8c1a 100644 --- a/include/configs/am335x_nmhw21.h +++ b/include/configs/am335x_nmhw21.h @@ -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 diff --git a/include/configs/am335x_nrhw20.h b/include/configs/am335x_nrhw20.h index b56873fb2f..acc599dfa3 100644 --- a/include/configs/am335x_nrhw20.h +++ b/include/configs/am335x_nrhw20.h @@ -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 */ diff --git a/include/configs/am335x_nrhw24.h b/include/configs/am335x_nrhw24.h index a9191e93d6..a0e71e816b 100644 --- a/include/configs/am335x_nrhw24.h +++ b/include/configs/am335x_nrhw24.h @@ -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 diff --git a/lib/display_options.c b/lib/display_options.c index c966fe815c..f0063abdd0 100755 --- a/lib/display_options.c +++ b/lib/display_options.c @@ -12,7 +12,12 @@ #include #include #include + +#ifdef CONFIG_NRSW_BUILD #include +#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;