From a8cc1f2d854be15dc8a006beabbd21ae3a3d29a7 Mon Sep 17 00:00:00 2001 From: Rene Straub Date: Thu, 26 Sep 2019 18:38:57 +0200 Subject: [PATCH] da9063: move driver to common netmodule codebase - change nmhw21, nrhw24 makefiles/include - change nrhw20 to use improved da9063 code (bus claim/release) --- board/nm/{nmhw21 => common}/da9063.c | 0 board/nm/{nmhw21 => common}/da9063.h | 0 board/nm/nmhw21/Makefile | 2 +- board/nm/nmhw21/board.c | 2 +- board/nm/nrhw20/Makefile | 2 +- board/nm/nrhw20/board.c | 604 +++++++++++++++++++-------- board/nm/nrhw20/board.h | 5 +- board/nm/nrhw20/da9063.c | 92 ---- board/nm/nrhw20/da9063.h | 36 -- board/nm/nrhw20/mux.c | 9 + board/nm/nrhw24/Makefile | 2 +- board/nm/nrhw24/board.c | 3 +- board/nm/nrhw24/da9063.c | 139 ------ board/nm/nrhw24/da9063.h | 82 ---- include/configs/am335x_nmhw21.h | 3 + include/configs/am335x_nrhw20.h | 49 ++- 16 files changed, 471 insertions(+), 559 deletions(-) rename board/nm/{nmhw21 => common}/da9063.c (100%) rename board/nm/{nmhw21 => common}/da9063.h (100%) delete mode 100644 board/nm/nrhw20/da9063.c delete mode 100644 board/nm/nrhw20/da9063.h delete mode 100644 board/nm/nrhw24/da9063.c delete mode 100644 board/nm/nrhw24/da9063.h diff --git a/board/nm/nmhw21/da9063.c b/board/nm/common/da9063.c similarity index 100% rename from board/nm/nmhw21/da9063.c rename to board/nm/common/da9063.c diff --git a/board/nm/nmhw21/da9063.h b/board/nm/common/da9063.h similarity index 100% rename from board/nm/nmhw21/da9063.h rename to board/nm/common/da9063.h diff --git a/board/nm/nmhw21/Makefile b/board/nm/nmhw21/Makefile index 0d7b2e0299..98c6bf7e80 100644 --- a/board/nm/nmhw21/Makefile +++ b/board/nm/nmhw21/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 fileaccess.o da9063.o sja1105.o ui.o um.o +obj-y += board.o ../common/bdparser.o ../common/board_descriptor.o ../common/da9063.o fileaccess.o sja1105.o ui.o um.o diff --git a/board/nm/nmhw21/board.c b/board/nm/nmhw21/board.c index 036c683f38..6eda658736 100644 --- a/board/nm/nmhw21/board.c +++ b/board/nm/nmhw21/board.c @@ -40,8 +40,8 @@ #include "../common/bdparser.h" #include "../common/board_descriptor.h" +#include "../common/da9063.h" #include "board.h" -#include "da9063.h" #include "sja1105.h" #include "ui.h" #include "um.h" diff --git a/board/nm/nrhw20/Makefile b/board/nm/nrhw20/Makefile index 9c4b04f561..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 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 2326bd017b..cf7ce889a8 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 NetModule AG - http://www.netmodule.com/ + * Copyright (C) 2018-2019 NetModule AG - http://www.netmodule.com/ * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/ * * SPDX-License-Identifier: GPL-2.0+ @@ -21,10 +21,6 @@ #include #include #include -#include -#include -#include -#include #include #include #include @@ -33,11 +29,12 @@ #include #include #include +#include #include "../common/bdparser.h" #include "../common/board_descriptor.h" +#include "../common/da9063.h" #include "board.h" -#include "da9063.h" #include "shield.h" #include "shield_can.h" #include "shield_comio.h" @@ -45,7 +42,6 @@ DECLARE_GLOBAL_DATA_PTR; - /* * CPU GPIOs * @@ -78,25 +74,24 @@ DECLARE_GLOBAL_DATA_PTR; #define GPIO_TO_PIN(bank, gpio) (32 * (bank) + (gpio)) -#define NETBIRD_GPIO_RST_PHY_N GPIO_TO_PIN(0, 16) -#define NETBIRD_GPIO_RST_USB_HUB_N GPIO_TO_PIN(3, 21) +#define GPIO_RST_PHY_N GPIO_TO_PIN(0, 16) +#define GPIO_RST_USB_HUB_N GPIO_TO_PIN(3, 21) -#define NETBIRD_GPIO_RST_GNSS GPIO_TO_PIN(0, 2) -#define NETBIRD_GPIO_RST_PCI GPIO_TO_PIN(3, 10) +#define GPIO_RST_GNSS GPIO_TO_PIN(0, 2) +#define GPIO_RST_PCI GPIO_TO_PIN(3, 10) -#define NETBIRD_GPIO_RST_GSM GPIO_TO_PIN(1, 25) -#define NETBIRD_GPIO_PWR_GSM GPIO_TO_PIN(1, 21) -#define NETBIRD_GPIO_WAKE_GSM GPIO_TO_PIN(0, 31) -#define NETBIRD_GPIO_SIM_SEL GPIO_TO_PIN(3, 17) +#define GPIO_RST_GSM GPIO_TO_PIN(1, 25) +#define GPIO_PWR_GSM GPIO_TO_PIN(1, 21) +#define GPIO_WAKE_GSM GPIO_TO_PIN(0, 31) +#define GPIO_SIM_SEL GPIO_TO_PIN(3, 17) -#define NETBIRD_GPIO_WLAN_EN GPIO_TO_PIN(1, 26) -#define NETBIRD_GPIO_BT_EN GPIO_TO_PIN(1, 20) +#define GPIO_WLAN_EN GPIO_TO_PIN(1, 26) +#define GPIO_BT_EN GPIO_TO_PIN(1, 20) -#define NETBIRD_GPIO_DIG_OUT GPIO_TO_PIN(1, 14) -#define NETBIRD_GPIO_DIG_IN GPIO_TO_PIN(1, 15) - -#define NETBIRD_GPIO_PCI_WDIS GPIO_TO_PIN(3, 9) +#define GPIO_DIG_OUT GPIO_TO_PIN(1, 14) +#define GPIO_DIG_IN GPIO_TO_PIN(1, 15) +#define GPIO_PCI_WDIS GPIO_TO_PIN(3, 9) /* * PMIC GPIOs @@ -141,6 +136,15 @@ DECLARE_GLOBAL_DATA_PTR; #define DDR3_CLOCK_FREQUENCY (400) + +#if !defined(CONFIG_SPL_BUILD) +/* Hardware version information of mainboard, loaded by get_hw_version() */ +static int hw_ver = -1; +static int hw_rev = -1; +static int hw_patch = -1; +static char hw_variant_name[64]; +#endif + #if !defined(CONFIG_SPL_BUILD) static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE; #endif @@ -158,6 +162,84 @@ static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE; static BD_Context bdctx[3]; /* The descriptor contexts */ +#if !defined(CONFIG_SPL_BUILD) + +static void request_and_set_gpio(int gpio, const char *name, int value) +{ + int ret; + + ret = gpio_request(gpio, name); + if (ret < 0) { + printf("%s: Unable to request %s\n", __func__, name); + return; + } + + ret = gpio_direction_output(gpio, value); + if (ret < 0) { + printf("%s: Unable to set %s as output\n", __func__, name); + goto err_free_gpio; + } + + return; + +err_free_gpio: + gpio_free(gpio); +} + +#define REQUEST_AND_SET_GPIO(N) request_and_set_gpio(N, #N, 1); +#define REQUEST_AND_CLEAR_GPIO(N) request_and_set_gpio(N, #N, 0); + +#endif + +static void init_leds(void) +{ + int old_bus; + + old_bus = i2c_get_bus_num(); + i2c_set_bus_num(CONFIG_SYS_I2C_PCA953X_BUS); + + /* Set all IOs as output */ + (void)pca953x_set_dir(CONFIG_SYS_I2C_PCA953X_ADDR, IOEXT_LEDS_ALL_MASK, PCA953X_DIR_OUT); + + /* Set all LEDs off */ + (void)pca953x_set_val(CONFIG_SYS_I2C_PCA953X_ADDR, IOEXT_LEDS_ALL_MASK, IOEXT_LEDS_ALL_MASK); + + i2c_set_bus_num(old_bus); +} + +static void set_status_led(int red, int green) +{ + int bus; + + /* LED outputs are active low, invert state */ + bus = da9063_claim_i2c_bus(); + (void)da9063_set_gpio(PMIC_LED0_RED, !red); + (void)da9063_set_gpio(PMIC_LED0_GREEN, !green); + da9063_release_i2c_bus(bus); +} + +static void set_indicator(unsigned led, int red, int green) +{ + int old_bus; + uint led_red_mask = 0x1U << (2*led); + uint led_green_mask = 0x2U << (2*led); + uint led_val = 0; + + old_bus = i2c_get_bus_num(); + i2c_set_bus_num(CONFIG_SYS_I2C_PCA953X_BUS); + + if (!red) + led_val |= led_red_mask; + + if (!green) + led_val |= led_green_mask; + + (void)pca953x_set_val(CONFIG_SYS_I2C_PCA953X_ADDR, led_red_mask | led_green_mask, led_val); + + i2c_set_bus_num(old_bus); +} + + static void init_i2c(void) { i2c_set_bus_num(0); @@ -180,7 +262,7 @@ static int _bd_init(void) } if (bd_get_context(&bdctx[1], BD_EEPROM_ADDR, PD_ADDRESS) != 0) { - printf("%s() no valid pd found (legacy support)\n", __func__); + printf("%s() no valid pd found\n", __func__); return -1; } @@ -196,41 +278,17 @@ static int _bd_init(void) return 0; } -static void init_indicator_leds(void) +static bool is_jtag_boot(uint32_t address) { - int old_bus; + char* jtag_token = (char*)address; - old_bus = i2c_get_bus_num(); - i2c_set_bus_num(CONFIG_SYS_I2C_PCA953X_BUS); - - /* Set all IOs as output */ - (void)pca953x_set_dir(CONFIG_SYS_I2C_PCA953X_ADDR, IOEXT_LEDS_ALL_MASK, PCA953X_DIR_OUT); - - /* Set all LEDs off */ - (void)pca953x_set_val(CONFIG_SYS_I2C_PCA953X_ADDR, IOEXT_LEDS_ALL_MASK, IOEXT_LEDS_ALL_MASK); - - i2c_set_bus_num(old_bus); -} - -static void set_indicator(unsigned led, int red, int green) -{ - int old_bus; - uint led_red_mask = 0x1U << (2*led); - uint led_green_mask = 0x2U << (2*led); - uint led_val = 0; - - old_bus = i2c_get_bus_num(); - i2c_set_bus_num(CONFIG_SYS_I2C_PCA953X_BUS); - - if (!red) - led_val |= led_red_mask; - - if (!green) - led_val |= led_green_mask; - - (void)pca953x_set_val(CONFIG_SYS_I2C_PCA953X_ADDR, led_red_mask | led_green_mask, led_val); - - i2c_set_bus_num(old_bus); + if (strcmp(jtag_token, "JTAGBOOT") == 0) { + strcpy(jtag_token, "jtagboot"); + return true; + } + else { + return false; + } } /* @@ -241,24 +299,33 @@ static inline int __maybe_unused read_eeprom(void) return _bd_init(); } -/* Selects console for SPL. - * U-Boot console is defined by CONFIG_CONS_INDEX (via menuconfig) +/* + * Selects console for SPL. + * U-Boot console is selected in set_console() */ struct serial_device *default_serial_console(void) { - if (spl_boot_device() == BOOT_DEVICE_UART) { + /* 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)) { enable_uart0_pin_mux(); return &eserial1_device; + } else { + /* Use bluetooth uart, if no ouput shall be seen. */ + /* TODO: Sorry, what are we doing here.... */ + /* This is at least dangerous if not completely wrong */ + enable_uart5_pin_mux(); + return &eserial6_device; } - else { - enable_uart1_pin_mux(); - return &eserial2_device; - } } #ifndef CONFIG_SKIP_LOWLEVEL_INIT -static const struct ddr_data ddr3_netbird_data = { +static const struct ddr_data ddr3_data = { /* Ratios were optimized by DDR3 training software from TI */ .datardsratio0 = 0x39, .datawdsratio0 = 0x3f, @@ -266,7 +333,7 @@ static const struct ddr_data ddr3_netbird_data = { .datawrsratio0 = 0x7d, }; -static const struct cmd_control ddr3_netbird_cmd_ctrl_data = { +static const struct cmd_control ddr3_cmd_ctrl_data = { .cmd0csratio = MT41K256M16HA125E_RATIO, .cmd0iclkout = MT41K256M16HA125E_INVERT_CLKOUT, @@ -290,11 +357,54 @@ static struct emif_regs ddr3_emif_reg_data = { #define OSC (V_OSCK/1000000) -struct dpll_params dpll_ddr_nrhw20 = { +struct dpll_params dpll_ddr = { DDR3_CLOCK_FREQUENCY, OSC-1, 1, -1, -1, -1, -1 }; +static void init_pmic_spl(void) +{ + int bus; + + /* PMIC basic configuration */ + da9063_init(CONFIG_PMIC_I2C_BUS); + + bus = da9063_claim_i2c_bus(); + + /* TODO: Move to init_pmic_spl() */ + + /* Configure default PMIC current limits. Will be overridden in Linux. + * MEM = 1.5A (0.55A) + * IO = 1.5A (0.5A) + * PERI = 2.0A (1.0A) + * PRO = 0.5A (unused) + * CORE2 = 2.0A (0.55A) + * CORE1 = 2.0A (0.25A, seems too low) + */ + (void)da9063_set_reg(PMIC_REG_BUCK_ILIM_A, 0x00); + (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 + (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); + (void)da9063_set_reg(PMIC_REG_BMEM_CONF, 0x81); + (void)da9063_set_reg(PMIC_REG_BPERI_CONF, 0x81); + + /* TODO: Enable later */ + /* da9063_reset_reason_update(RESET_REASON_SHM_LOCATION); */ + /* TODO: Move code from below to here */ + + /* Enable charging of RTC backup capacitor (1mA, 3.1V) */ + (void)da9063_set_reg(PMIC_REG_BBAT_CONT, 0xCF); + /* TODO: Check documentation 1 mA correct ? */ + + da9063_release_i2c_bus(bus); +} + void am33xx_spl_board_init(void) { /* Set CPU speed to 600 MHz (fix) */ @@ -303,42 +413,40 @@ void am33xx_spl_board_init(void) /* Set CORE Frequencies to OPP100 (600MHz) */ do_setup_dpll(&dpll_core_regs, &dpll_core_opp100); - /* Configure both I2C buses used in NRHW20 */ + /* Configure both I2C buses used */ init_i2c(); - /* Configure default PMIC current limits. Will be overridden in Linux. - * MEM = 1.5A (0.55A) - * IO = 1.5A (0.5A) - * PERI = 2.0A (1.0A) - * PRO = 0.5A (unused) - * CORE2 = 2.0A (0.55A) - * CORE1 = 2.0A (0.25A, seems too low) - */ - da9063_init(CONFIG_PMIC_I2C_BUS); - da9063_set_reg(PMIC_REG_BUCK_ILIM_A, 0x00); - da9063_set_reg(PMIC_REG_BUCK_ILIM_B, 0x50); - da9063_set_reg(PMIC_REG_BUCK_ILIM_C, 0xFF); + /* Setup PMIC */ + init_pmic_spl(); - init_indicator_leds(); + init_leds(); +#if 0 /* TODO: missing ? */ + set_status_led(1, 0); /* Red */ +#endif set_indicator(0, 1, 1); /* Orange */ /* Set MPU Frequency to what we detected now that voltages are set */ do_setup_dpll(&dpll_mpu_regs, &dpll_mpu_opp100); + + /* Debugger can place marker at end of SRAM to stop boot here */ + if (is_jtag_boot(CONFIG_JTAG_MARKER_SPL)) + { + puts("Detected JTAG boot, executing bkpt #0\n"); + + __asm__ __volatile__ ("bkpt #0"); + } } const struct dpll_params *get_dpll_ddr_params(void) { - dpll_ddr_nrhw20.n = (get_osclk() / 1000000) - 1; - return &dpll_ddr_nrhw20; + dpll_ddr.n = (get_osclk() / 1000000) - 1; + return &dpll_ddr; } void set_uart_mux_conf(void) { enable_uart0_pin_mux(); enable_uart1_pin_mux(); - /* TODO: Who calls this method when ? */ - /* disable_uart0_pin_mux(); */ - /* enable_uart1_pin_mux(); */ } void set_mux_conf_regs(void) @@ -347,20 +455,19 @@ void set_mux_conf_regs(void) } -const struct ctrl_ioregs ioregs_netbird = { +const struct ctrl_ioregs ioregs = { .cm0ioctl = MT41K256M16HA125E_IOCTRL_VALUE, .cm1ioctl = MT41K256M16HA125E_IOCTRL_VALUE, .cm2ioctl = MT41K256M16HA125E_IOCTRL_VALUE, .dt0ioctl = MT41K256M16HA125E_IOCTRL_VALUE, - .dt1ioctl = MT41K256M16HA125E_IOCTRL_VALUE, + .dt1ioctl = MT41K256M16HA125E_IOCTRL_VALUE }; - void sdram_init(void) { - config_ddr(DDR3_CLOCK_FREQUENCY, &ioregs_netbird, - &ddr3_netbird_data, - &ddr3_netbird_cmd_ctrl_data, + config_ddr(DDR3_CLOCK_FREQUENCY, &ioregs, + &ddr3_data, + &ddr3_cmd_ctrl_data, &ddr3_emif_reg_data, 0); } @@ -368,54 +475,47 @@ void sdram_init(void) #if !defined(CONFIG_SPL_BUILD) -static void request_and_set_gpio(int gpio, const char *name, int value) +/* + * Override for Ethernet link timeout definition, + * with option to specify via environment variable linktimeout + */ +int eth_phy_timeout(void) { - int ret; + const char* timeout_env = NULL; + int timeout; - ret = gpio_request(gpio, name); - if (ret < 0) { - printf("%s: Unable to request %s\n", __func__, name); - return; + timeout = PHY_ANEG_DEFAULT_TIMEOUT; + + /* + * Check if timeout has been defined by environment. + * Valid range: 1000..10000 milliseconds + */ + timeout_env = getenv("linktimeout"); + if (timeout_env != NULL) { + timeout = simple_strtoul(timeout_env, NULL, 10); + if (timeout == 0) { + timeout = PHY_ANEG_DEFAULT_TIMEOUT; + } else if (timeout < 1000) { + timeout = 1000; + } else if (timeout > 10000) { + timeout = 10000; + } } - /* TODO: Set value here, remove later call gpio_set_value */ - ret = gpio_direction_output(gpio, 0); - if (ret < 0) { - printf("%s: Unable to set %s as output\n", __func__, name); - goto err_free_gpio; - } - - gpio_set_value(gpio, value); - - return; - -err_free_gpio: - gpio_free(gpio); + return timeout; } -#define REQUEST_AND_SET_GPIO(N) request_and_set_gpio(N, #N, 1); -#define REQUEST_AND_CLEAR_GPIO(N) request_and_set_gpio(N, #N, 0); - -#endif - - - -static void set_status_led(int red, int green) -{ - /* LED outputs are active low, invert state */ - da9063_set_gpio(PMIC_LED0_RED, !red); - da9063_set_gpio(PMIC_LED0_GREEN, !green); -} +#endif /* !defined(CONFIG_SPL_BUILD) */ #if !defined(CONFIG_SPL_BUILD) static void init_ethernet_switch(void) { - REQUEST_AND_CLEAR_GPIO(NETBIRD_GPIO_RST_PHY_N); + REQUEST_AND_CLEAR_GPIO(GPIO_RST_PHY_N); mdelay(1); /* OMAP3 does not feature open drain pins, thus configure pin as input */ - gpio_direction_input(NETBIRD_GPIO_RST_PHY_N); + gpio_direction_input(GPIO_RST_PHY_N); /* When the Ethernet switch senses reset, it drives reset for 8..14ms * Wait longer than this time to avoid IO congestion later on. @@ -425,17 +525,21 @@ static void init_ethernet_switch(void) static void init_usb_hub(void) { - REQUEST_AND_CLEAR_GPIO(NETBIRD_GPIO_RST_USB_HUB_N); + REQUEST_AND_CLEAR_GPIO(GPIO_RST_USB_HUB_N); /* Minimum Reset Pulse = 1us */ mdelay(2); - gpio_set_value(NETBIRD_GPIO_RST_USB_HUB_N, 1); + gpio_set_value(GPIO_RST_USB_HUB_N, 1); } static void init_pcie_slot(void) { + int bus; + puts("PCIe: "); - REQUEST_AND_SET_GPIO(NETBIRD_GPIO_RST_PCI); /* Assert reset (active high) */ + bus = da9063_claim_i2c_bus(); + + REQUEST_AND_SET_GPIO(GPIO_RST_PCI); /* Assert reset (active high) */ da9063_set_gpio(PMIC_PCIe_SUPPLY_EN_IO, 0); /* Switch PCIe Supply off */ mdelay(30); /* Give time to discharge output */ @@ -445,15 +549,18 @@ static void init_pcie_slot(void) da9063_set_gpio(PMIC_PCIe_SUPPLY_EN_IO, 1); /* Enable Supply */ mdelay(10); /* PCIe requires at least 1ms delay between power on and reset release */ - gpio_set_value(NETBIRD_GPIO_RST_PCI, 0); /* Release reset */ + gpio_set_value(GPIO_RST_PCI, 0); /* Release reset */ - REQUEST_AND_CLEAR_GPIO(NETBIRD_GPIO_PCI_WDIS); /* Allow wireless operation */ + REQUEST_AND_CLEAR_GPIO(GPIO_PCI_WDIS); /* Allow wireless operation */ + + da9063_release_i2c_bus(bus); puts("ready\n"); } static void init_gsm(void) { + /* TODO: Check and update for Toby-L2 */ /* * Perform power up sequence for Huawei ME909s. * @@ -465,13 +572,16 @@ static void init_gsm(void) * 3.3.2 Power Supply VBAT Interface * 3.4.2 Power-on/off Pin, Figure 3.7 */ + int bus; puts("GSM: "); + bus = da9063_claim_i2c_bus(); + /* TODO: Keep Power-On and use GSM Modem Reset Signal to restart */ - REQUEST_AND_SET_GPIO(NETBIRD_GPIO_RST_GSM); /* Assert reset (active high) */ - REQUEST_AND_CLEAR_GPIO(NETBIRD_GPIO_PWR_GSM); /* Keep power switch inactive (released) */ + REQUEST_AND_SET_GPIO(GPIO_RST_GSM); /* Assert reset (active high) */ + REQUEST_AND_CLEAR_GPIO(GPIO_PWR_GSM); /* Keep power switch inactive (released) */ da9063_set_gpio(PMIC_GSM_SUPPLY_EN_IO, 0); /* Switch GSM Supply off */ mdelay(30+100); /* Give time to discharge supply */ @@ -480,12 +590,14 @@ static void init_gsm(void) da9063_set_gpio(PMIC_GSM_SUPPLY_EN_IO, 1); /* Enable GSM supply */ mdelay(10); - gpio_set_value(NETBIRD_GPIO_RST_GSM, 0); /* Take modem out of reset */ + gpio_set_value(GPIO_RST_GSM, 0); /* Take modem out of reset */ mdelay(300); /* Wait for power to stabilizy, #3.4.2 */ - gpio_set_value(NETBIRD_GPIO_PWR_GSM, 1); /* Generate power on event, #3.4.2 */ + gpio_set_value(GPIO_PWR_GSM, 1); /* Generate power on event, #3.4.2 */ mdelay(1200); - gpio_set_value(NETBIRD_GPIO_PWR_GSM, 0); + gpio_set_value(GPIO_PWR_GSM, 0); + + da9063_release_i2c_bus(bus); puts("ready\n"); } @@ -493,9 +605,9 @@ static void init_gsm(void) static void init_gnss(void) { /* - * Release GNSS reset line, so that modem starts up early + * Release GNSS reset line, so that module starts up early */ - REQUEST_AND_SET_GPIO(NETBIRD_GPIO_RST_GNSS); + REQUEST_AND_SET_GPIO(GPIO_RST_GNSS); } @@ -514,14 +626,15 @@ int board_init(void) gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100; - /* Configure both I2C buses used in NRHW20 */ + /* Configure both I2C buses used */ init_i2c(); da9063_init(CONFIG_PMIC_I2C_BUS); /* Let user know we're starting */ - init_indicator_leds(); + init_leds(); set_status_led(1, 1); /* Orange */ + /* TODO: Status LED correct? */ printf("OSC: %lu MHz\n", get_osclk()/1000000); @@ -530,6 +643,10 @@ 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 @@ -540,7 +657,8 @@ int board_init(void) void set_console(void) { const char *defaultconsole = getenv("defaultconsole"); - char buf[8]; + char buf[20]; + int i; /* Set default console to ttyS1 if not yet defined in env */ if (defaultconsole == 0) { @@ -548,12 +666,38 @@ void set_console(void) } /* If consoledev file is present, take the tty defined in it as console */ - if (read_file("/root/boot/consoledev",buf, 5) == 5) { + if (read_file("/root/boot/consoledev",buf, sizeof(buf)) > 3) { if (strstr(buf, "tty") == buf) { - buf[5] = 0; + buf[sizeof(buf)-1] = 0; + for (i=0; i> 4) & 0xF; + rev = (val >> 0) & 0xF; + } else { + ver = 0; + rev = 0; + } + + da9063_release_i2c_bus(bus); + + printf("PMIC: V%d.%d\n", ver, rev); +} + + +static void check_jtag_boot(void) +{ + if (is_jtag_boot(CONFIG_JTAG_MARKER_UBOOT)) { + setenv ("bootcmd", ""); + puts("Detected JTAG boot. Waiting on command line\n"); + } +} + static void check_fct(void) { - /* Check whether an I2C device (EEPROM) is present at address 0xA2/0x51 + /* + * Check whether an I2C device (EEPROM) is present at address 0xA2/0x51 * In this case we are connected to the factory test station. * Clear the bootcmd, so that test system can easily connect. */ @@ -612,8 +798,8 @@ static void check_fct(void) /* If probe fails we are sure no eeprom is connected */ if (i2c_probe(0x51) == 0) { - printf("Entering fct mode\n"); setenv ("bootcmd", ""); + puts("Detected factory test system. Waiting on command line\n"); } i2c_set_bus_num(old_bus); @@ -700,11 +886,20 @@ static void shield_init(void) static bool get_button_state(void) { - u8 state = 0x00; + uint8_t state = 0x00; + bool pressed = false; + int bus; + int rc; - (void)da9063_get_reg(PMIC_REG_STATUS_A, &state); + bus = da9063_claim_i2c_bus(); + rc = da9063_get_reg(PMIC_REG_STATUS_A, &state); + da9063_release_i2c_bus(bus); - return (state & 0x01) == 0x01; + if (!rc) { + pressed = (state & 0x01) == 0x01; + } + + return pressed; } static void blink_led(void) @@ -713,7 +908,8 @@ static void blink_led(void) /* Assumes green status LED is on */ udelay(pulse_width); - set_status_led(0, 0); + set_status_led(0, 0); /* Off */ + udelay(pulse_width); set_status_led(0, 1); } @@ -750,9 +946,9 @@ static void check_reset_button(void) char new_bootargs[512]; char *bootargs = getenv("bootargs"); - if (bootargs == 0) bootargs=""; + if (bootargs == 0) bootargs = ""; - printf("Do factory reset during boot...\n"); + puts("Do factory reset during boot...\n"); strncpy(new_bootargs, bootargs, sizeof(new_bootargs)); strncat(new_bootargs, " factory-reset", sizeof(new_bootargs)); @@ -762,8 +958,7 @@ static void check_reset_button(void) else { /* Boot into recovery for duration > 12s */ - - printf("Booting recovery image...\n"); + puts("Booting recovery image...\n"); /* Set consoledev to external port */ setenv("defaultconsole", "ttyS1"); @@ -772,23 +967,27 @@ static void check_reset_button(void) setenv("bootcmd", "run recovery"); } } -#endif /* !defined(CONFIG_SPL_BUILD) */ +#endif /* !defined(CONFIG_SPL_BUILD) */ int board_late_init(void) { #if !defined(CONFIG_SPL_BUILD) - if (read_eeprom() < 0) + if (read_eeprom() < 0) { puts("Could not get board ID.\n"); + } + get_variant_name(); get_hw_version(); + get_pmic_version(); + set_root_partition(); set_devicetree_name(); /* Initialize pins */ - REQUEST_AND_CLEAR_GPIO(NETBIRD_GPIO_WLAN_EN); - REQUEST_AND_CLEAR_GPIO(NETBIRD_GPIO_BT_EN); - REQUEST_AND_CLEAR_GPIO(NETBIRD_GPIO_DIG_OUT); + REQUEST_AND_CLEAR_GPIO(GPIO_WLAN_EN); + REQUEST_AND_CLEAR_GPIO(GPIO_BT_EN); + REQUEST_AND_CLEAR_GPIO(GPIO_DIG_OUT); init_ethernet_switch(); init_usb_hub(); @@ -796,9 +995,11 @@ int board_late_init(void) init_gsm(); init_gnss(); - /* Enable charging of RTC backup capacitor (1mA, 3.1V) */ - (void)da9063_set_reg(PMIC_REG_BBAT_CONT, 0xCF); - + /* + * Check if a user action is requested + * - Short press: factory reset + * - Long press: recovery boot + */ check_reset_button(); set_console(); @@ -808,6 +1009,7 @@ int board_late_init(void) set_indicator(0, 0, 1); /* Green */ check_fct(); + check_jtag_boot(); #endif return 0; @@ -885,39 +1087,46 @@ static void set_mac_address(int index, uchar mac[6]) */ int board_eth_init(bd_t *bis) { - int rv, n = 0; - uint8_t mac_addr0[6] = {02,00,00,00,00,01}; - __maybe_unused struct ti_am_eeprom *header; - + int n = 0; + __maybe_unused uint8_t mac_addr0[6] = {02,00,00,00,00,01}; #if !defined(CONFIG_SPL_BUILD) #ifdef CONFIG_DRIVER_TI_CPSW - cpsw_data.mdio_div = 0x3E; bd_get_mac(0, mac_addr0, sizeof(mac_addr0)); set_mac_address(0, mac_addr0); writel(RMII_MODE_ENABLE | RMII_CHIPCKL_ENABLE, &cdev->miisel); - - rv = cpsw_register(&cpsw_data); - if (rv < 0) - printf("Error %d registering CPSW switch\n", rv); - else - n += rv; + + { + int rv = cpsw_register(&cpsw_data); + if (rv < 0) + { + printf("Error %d registering CPSW switch\n", rv); + } else { + n += rv; + } + } #endif #endif #if defined(CONFIG_USB_ETHER) && \ (!defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_USBETH_SUPPORT)) - if (is_valid_ethaddr(mac_addr0)) + if (is_valid_ethaddr(mac_addr0)) { eth_setenv_enetaddr("usbnet_devaddr", mac_addr0); + } - rv = usb_eth_initialize(bis); - if (rv < 0) - printf("Error %d registering USB_ETHER\n", rv); - else - n += rv; + { + int rv = usb_eth_initialize(bis); + if (rv < 0) + { + printf("Error %d registering USB_ETHER\n", rv); + } else { + n += rv; + } + } #endif + return n; } #endif @@ -931,7 +1140,7 @@ int board_fit_config_name_match(const char *name) } #endif -#if defined(CONFIG_OF_BOARD_SETUP) +#if defined(CONFIG_OF_BOARD_SETUP) && !defined(CONFIG_SPL_BUILD) static void ft_enable_node(void* blob, const char* name) { @@ -960,13 +1169,12 @@ static void ft_dio(void *blob, int shield_type) static void ft_serial(void *blob, int shield_type) { switch (shield_type) { - /* If COM/IO shield is present enable uart1 (ttyS0) */ - case SHIELD_COM_IO: - /* TODO: Should use alias serial0 */ - ft_enable_node(blob, "/ocp/serial@44e09000"); - break; + /* Enable uart1 (ttyS0) always as kernel needs it as fallback + console, if (ttyS1) is not available as console. */ default: + /* TODO: Should use alias serial0 */ + ft_enable_node(blob, "/ocp/serial@44e09000"); break; } } @@ -986,10 +1194,38 @@ static void ft_dcan(void *blob, int shield_type) } } +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); @@ -999,4 +1235,4 @@ int ft_board_setup(void *blob, bd_t *bd) return 0; } -#endif +#endif /* defined(CONFIG_OF_BOARD_SETUP) && !defined(CONFIG_SPL_BUILD) */ diff --git a/board/nm/nrhw20/board.h b/board/nm/nrhw20/board.h index d0bff8ee8a..40d879576a 100644 --- a/board/nm/nrhw20/board.h +++ b/board/nm/nrhw20/board.h @@ -19,12 +19,9 @@ void enable_uart0_pin_mux(void); void disable_uart0_pin_mux(void); void enable_uart1_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); diff --git a/board/nm/nrhw20/da9063.c b/board/nm/nrhw20/da9063.c deleted file mode 100644 index 092ebb074c..0000000000 --- a/board/nm/nrhw20/da9063.c +++ /dev/null @@ -1,92 +0,0 @@ -/* - * da9063.c - * - * Dialog DA9063 PMIC - * - * Copyright (C) 2018 NetModule AG - http://www.netmodule.com/ - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#include -#include -#include - -#include "da9063.h" - - -static int da9063_i2c_bus = 0; - - -void da9063_init(int i2c_bus) -{ - da9063_i2c_bus = i2c_bus; -} - -int da9063_get_reg(int reg, u8* val) -{ - int ret; - int old_bus; - u8 temp; - - /* TODO: Check whether switching is required */ - old_bus = i2c_get_bus_num(); - i2c_set_bus_num(da9063_i2c_bus); - - /* TODO: Use CONFIG_PMIC_I2C_ADDR+1 if reg > 0xFF */ - *val = 0; - ret = i2c_read(CONFIG_PMIC_I2C_ADDR, reg, 1, &temp, 1); - if (ret == 0) - *val = temp; - - i2c_set_bus_num(old_bus); - - return ret; -} - -int da9063_set_reg(int reg, u8 val) -{ - int ret; - int old_bus; - - /* TODO: Check whether switching is required */ - old_bus = i2c_get_bus_num(); - i2c_set_bus_num(da9063_i2c_bus); - - /* TODO: Use CONFIG_PMIC_I2C_ADDR+1 if reg > 0xFF */ - ret = i2c_write(CONFIG_PMIC_I2C_ADDR, reg, 1, &val, 1); - if (ret != 0) - puts("da9063 write error\n"); - - i2c_set_bus_num(old_bus); - - return ret; -} - -void da9063_set_gpio(unsigned bit, int state) -{ - int pmic_reg; - int ret; - u8 bitmask; - u8 reg = 0x00; - - if (bit <= 7) { - pmic_reg = PMIC_REG_GPIO_MODE0_7; - bitmask = 1U << (bit-0); - } - else { - pmic_reg = PMIC_REG_GPIO_MODE8_15; - bitmask = 1U << (bit-8); - } - -/* printf("da9063_set_gpio %d 0x%04x\n", pmic_reg, bitmask); */ - ret = da9063_get_reg(pmic_reg, ®); - - if (ret == 0) { - if (state) reg |= bitmask; - else reg &= ~bitmask; - - (void)da9063_set_reg(pmic_reg, reg); - } -} - diff --git a/board/nm/nrhw20/da9063.h b/board/nm/nrhw20/da9063.h deleted file mode 100644 index 481e7e4280..0000000000 --- a/board/nm/nrhw20/da9063.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * da9063.c - * - * Dialog DA9063 PMIC - * - * Copyright (C) 2018 NetModule AG - http://www.netmodule.com/ - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#ifndef DA9063_H -#define DA9063_H - - -#define CONFIG_PMIC_I2C_BUS 0 -#define CONFIG_PMIC_I2C_ADDR 0x58 /* Pages 0 and 1, Pages 2 and 3 -> 0x59 */ - -#define PMIC_REG_STATUS_A 0x01 /* Status of ON_KEY, WAKE, COMP1V2, DVC */ -#define PMIC_REG_GPIO_MODE0_7 0x1D /* Control register for GPIOs 0..7 */ -#define PMIC_REG_GPIO_MODE8_15 0x1E /* Control register for GPIOs 8..15 */ - -#define PMIC_REG_BBAT_CONT 0xC5 /* Control register for backup battery */ - -#define PMIC_REG_BUCK_ILIM_A 0x9A -#define PMIC_REG_BUCK_ILIM_B 0x9B -#define PMIC_REG_BUCK_ILIM_C 0x9C - - -extern void da9063_init(int i2c_bus); -extern int da9063_get_reg(int reg, u8* val); -extern int da9063_set_reg(int reg, u8 val); - -extern void da9063_set_gpio(unsigned bit, int state); - - -#endif /* DA9063_H */ diff --git a/board/nm/nrhw20/mux.c b/board/nm/nrhw20/mux.c index 82a3fbead7..a2f69abb06 100644 --- a/board/nm/nrhw20/mux.c +++ b/board/nm/nrhw20/mux.c @@ -249,3 +249,12 @@ void enable_uart1_pin_mux(void) configure_module_pin_mux(uart1_pin_mux); } +void enable_uart3_pin_mux(void) +{ + configure_module_pin_mux(uart3_pin_mux); +} + +void enable_uart5_pin_mux(void) +{ + configure_module_pin_mux(uart5_pin_mux); +} diff --git a/board/nm/nrhw24/Makefile b/board/nm/nrhw24/Makefile index 9c4b04f561..813f0b8103 100644 --- a/board/nm/nrhw24/Makefile +++ b/board/nm/nrhw24/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 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/nrhw24/board.c b/board/nm/nrhw24/board.c index 9c82da0226..81e7be67f0 100644 --- a/board/nm/nrhw24/board.c +++ b/board/nm/nrhw24/board.c @@ -33,8 +33,8 @@ #include "../common/bdparser.h" #include "../common/board_descriptor.h" +#include "../common/da9063.h" #include "board.h" -#include "da9063.h" #include "shield.h" #include "shield_can.h" #include "shield_comio.h" @@ -338,6 +338,7 @@ static void init_pmic_spl(void) /* Enable charging of RTC backup capacitor (1mA, 3.1V) */ (void)da9063_set_reg(PMIC_REG_BBAT_CONT, 0xAF); + /* TODO: Check documentation 1 mA correct ? */ da9063_release_i2c_bus(bus); } diff --git a/board/nm/nrhw24/da9063.c b/board/nm/nrhw24/da9063.c deleted file mode 100644 index 1499593647..0000000000 --- a/board/nm/nrhw24/da9063.c +++ /dev/null @@ -1,139 +0,0 @@ -/* - * da9063.c - * - * Dialog DA9063 PMIC - * - * Copyright (C) 2018-2019 NetModule AG - http://www.netmodule.com/ - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#include -#include -#include - -#include "da9063.h" - - -static int da9063_i2c_bus = 0; -static int bus_claimed = 0; - - -static int switch_i2c_bus(void) -{ - int old_bus; - - old_bus = i2c_get_bus_num(); - if (old_bus != da9063_i2c_bus) { - i2c_set_bus_num(da9063_i2c_bus); - } - - bus_claimed++; - - return old_bus; -} - -static void revert_i2c_bus(int bus) -{ - if (da9063_i2c_bus != bus) { - i2c_set_bus_num(bus); - } - - bus_claimed--; -} - - -void da9063_init(int i2c_bus) -{ - da9063_i2c_bus = i2c_bus; -} - -int da9063_claim_i2c_bus(void) -{ - return switch_i2c_bus(); -} - -void da9063_release_i2c_bus(int bus) -{ - revert_i2c_bus(bus); -} - -int da9063_get_reg(uint32_t reg, uint8_t* val) -{ - int ret; - uint8_t temp; - - /* Argument check */ - if ((reg >= 0x200) || (val==0)) { - return -1; - } - - /* State check. Has bus been claimed */ - if (bus_claimed == 0) { - return -2; - } - - *val = 0; - if (reg < 0x100) { - ret = i2c_read(CONFIG_PMIC_I2C_ADDR+0, reg & 0xFF, 1, &temp, 1); - } else { - ret = i2c_read(CONFIG_PMIC_I2C_ADDR+1, reg & 0xFF, 1, &temp, 1); - } - - if (ret == 0) - *val = temp; - - return ret; -} - -int da9063_set_reg(uint32_t reg, uint8_t val) -{ - int ret; - - /* Argument check */ - if (reg >= 0x200) { - return -1; - } - - /* State check. Has bus been claimed */ - if (bus_claimed == 0) { - return -2; - } - - if (reg < 0x100) { - ret = i2c_write(CONFIG_PMIC_I2C_ADDR+0, reg & 0xFF, 1, &val, 1); - } else { - ret = i2c_write(CONFIG_PMIC_I2C_ADDR+1, reg & 0xFF, 1, &val, 1); - } - - if (ret != 0) - puts("da9063 write error\n"); - - return ret; -} - -void da9063_set_gpio(unsigned bit, int state) -{ - int pmic_reg; - int ret; - uint8_t bitmask; - uint8_t reg = 0x00; - - if (bit <= 7) { - pmic_reg = PMIC_REG_GPIO_MODE0_7; - bitmask = 1U << (bit-0); - } - else { - pmic_reg = PMIC_REG_GPIO_MODE8_15; - bitmask = 1U << (bit-8); - } - - ret = da9063_get_reg(pmic_reg, ®); - - if (ret == 0) { - if (state) reg |= bitmask; - else reg &= ~bitmask; - - (void)da9063_set_reg(pmic_reg, reg); - } -} diff --git a/board/nm/nrhw24/da9063.h b/board/nm/nrhw24/da9063.h deleted file mode 100644 index d0bde44d07..0000000000 --- a/board/nm/nrhw24/da9063.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * da9063.c - * - * Dialog DA9063 PMIC - * - * Copyright (C) 2018-2019 NetModule AG - http://www.netmodule.com/ - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#ifndef DA9063_H -#define DA9063_H - -/* -TODO: Add include for uint32_t (stdtypes.h) -#include -*/ - -#define CONFIG_PMIC_I2C_BUS 0 -#define CONFIG_PMIC_I2C_ADDR 0x58 /* Pages 0 and 1, Pages 2 and 3 -> 0x59 */ - -#define PMIC_REG_STATUS_A 0x01 /* Status of ON_KEY, WAKE, COMP1V2, DVC */ -#define PMIC_REG_CONTROL_D 0x11 /* Control register for blink/watchdog */ -#define PMIC_REG_GPIO14_15 0x1C /* Configuration of GPIO14/15 (mode, wake) */ -#define PMIC_REG_GPIO_MODE0_7 0x1D /* Control register for GPIOs 0..7 */ -#define PMIC_REG_GPIO_MODE8_15 0x1E /* Control register for GPIOs 8..15 */ - -#define PMIC_REG_BCORE1_CONT 0x21 /* Control register of BCORE1 */ -#define PMIC_REG_BCORE2_CONT 0x20 /* Control register of BCORE2 */ -#define PMIC_REG_BPERI_CONT 0x25 /* Control register of BPERI */ -#define PMIC_REG_BIO_CONT 0x24 /* Control register of BIO */ -#define PMIC_REG_BMEM_CONT 0x23 /* Control register of BMEM */ - -#define PMIC_REG_LDO3_CONT 0x28 /* Control register of LDO3 */ -#define PMIC_REG_LDO6_CONT 0x2B /* Control register of LDO6 */ -#define PMIC_REG_LDO7_CONT 0x2C /* Control register of LDO7 */ -#define PMIC_REG_LDO11_CONT 0x30 /* Control register of LDO11 */ - -#define PMIC_LDOx_EN_MASK 0x01 -#define PMIC_LDOx_CONF_MASK 0x80 - -#define PMIC_REG_ID_4_3 0x84 - -#define PMIC_REG_BUCK_ILIM_A 0x9A -#define PMIC_REG_BUCK_ILIM_B 0x9B -#define PMIC_REG_BUCK_ILIM_C 0x9C - -#define PMIC_REG_BCORE1_CONF 0x9E /* Configuration register of BCORE1 */ -#define PMIC_REG_BCORE2_CONF 0x9D /* Configuration register of BCORE2 */ -#define PMIC_REG_BPERI_CONF 0xA2 /* Configuration register of BPERI */ -#define PMIC_REG_BIO_CONF 0xA0 /* Configuration register of BIO */ -#define PMIC_REG_BMEM_CONF 0xA1 /* Configuration register of BMEM */ - -#define PMIC_CONF_MODE_MASK 0xC0 -#define PMIC_CONF_MODE_SLEEP 0x40 -#define PMIC_CONF_MODE_SYNC 0x80 -#define PMIC_CONF_MODE_AUTO 0xC0 - - -#define PMIC_REG_BBAT_CONT 0xC5 /* Control register for backup battery */ - -#define PMIC_REG_CONFIG_E 0x10A -#define PMIC_REG_CONFIG_G 0x10C -#define PMIC_REG_CONFIG_L 0x111 - -#define PMIC_REG_TRIM_CLDR 0x120 /* Calendar Trim register, 2's complement, 1.9ppm per bit */ - -#define PMIC_REG_CONFIG_ID 0x184 /* OTP Config ID */ - - -extern void da9063_init(int i2c_bus); - -extern int da9063_claim_i2c_bus(void); -extern void da9063_release_i2c_bus(int bus); - -extern int da9063_get_reg(uint32_t reg, uint8_t* val); -extern int da9063_set_reg(uint32_t reg, uint8_t val); - -extern void da9063_set_gpio(unsigned bit, int state); - - -#endif /* DA9063_H */ diff --git a/include/configs/am335x_nmhw21.h b/include/configs/am335x_nmhw21.h index 3ef98c1777..bcd874ce6e 100644 --- a/include/configs/am335x_nmhw21.h +++ b/include/configs/am335x_nmhw21.h @@ -131,6 +131,9 @@ int eth_phy_timeout(void); #define CONFIG_SYS_NS16550_COM2 0x48022000 /* UART1: Unused, see note below */ #define CONFIG_SYS_NS16550_COM3 0x48024000 /* UART2: eMMC Boot, User UART */ /* NOTE: NS16550 definitions are cumulative, need to set COM2 to have COM3 */ +#define CONFIG_SYS_NS16550_COM4 0x481A6000 /* UART3: xxx */ +#define CONFIG_SYS_NS16550_COM5 0x481A8000 /* UART4: yyy */ +#define CONFIG_SYS_NS16550_COM6 0x481AA000 /* UART5: zzz */ #define CONFIG_I2C #define CONFIG_I2C_MULTI_BUS diff --git a/include/configs/am335x_nrhw20.h b/include/configs/am335x_nrhw20.h index 4aac523525..79b6e29f2d 100644 --- a/include/configs/am335x_nrhw20.h +++ b/include/configs/am335x_nrhw20.h @@ -1,7 +1,7 @@ /* * am335x_nrhw20.h * - * Copyright (C) 2018 NetModule AG - http://www.netmodule.com/ + * Copyright (C) 2018-2019 NetModule AG - http://www.netmodule.com/ * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ * * This program is free software; you can redistribute it and/or @@ -36,12 +36,29 @@ #define CONFIG_MACH_TYPE MACH_TYPE_TIAM335EVM #define CONFIG_BOARD_LATE_INIT +/* TODO: +#define CONFIG_PRE_CONSOLE_BUFFER 1 +#define CONFIG_PRE_CON_BUF_ADDR 0x80000000 +#define CONFIG_PRE_CON_BUF_SZ 64*1024 +*/ + /* Clock Defines */ #define V_OSCK 0 /* 0 means detect from sysboot1 config */ #define V_SCLK (V_OSCK) #include +/* Dynamic override for PHY_ANEG_TIMEOUT value */ +#if 0 /* TODO */ +#ifndef CONFIG_SPL_BUILD +# ifndef __ASSEMBLER__ +int eth_phy_timeout(void); +# endif +#endif +#define PHY_ANEG_TIMEOUT eth_phy_timeout() +#endif +#define PHY_ANEG_DEFAULT_TIMEOUT 5000 + #define CONFIG_ARP_TIMEOUT 200 #undef CONFIG_NET_RETRY_COUNT #define CONFIG_NET_RETRY_COUNT 5 @@ -111,6 +128,10 @@ /* UART Configuration */ #define CONFIG_SYS_NS16550_COM1 0x44e09000 /* UART0: XModem Boot, Shield */ #define CONFIG_SYS_NS16550_COM2 0x48022000 /* UART1: eMMC Boot, User UART */ +#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 @@ -136,13 +157,6 @@ #define CONFIG_ENV_IS_IN_MMC #define CONFIG_SYS_MMC_ENV_DEV 1 -#if 0 -#define CONFIG_SYS_MMC_ENV_PART 2 -#define CONFIG_ENV_OFFSET_REDUND (CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE) -#define CONFIG_SYS_REDUNDAND_ENVIRONMENT -#endif - - #undef CONFIG_SPL_ENV_SUPPORT #undef CONFIG_SPL_NAND_SUPPORT #undef CONFIG_SPL_ONENAND_SUPPORT @@ -173,13 +187,15 @@ #define CONFIG_AM335X_USB0 #define CONFIG_AM335X_USB0_MODE MUSB_HOST +/* TODO: remove */ +#if 0 /* Fastboot */ #define CONFIG_USB_FUNCTION_FASTBOOT #define CONFIG_CMD_FASTBOOT #define CONFIG_ANDROID_BOOT_IMAGE #define CONFIG_FASTBOOT_BUF_ADDR CONFIG_SYS_LOAD_ADDR #define CONFIG_FASTBOOT_BUF_SIZE 0x07000000 -/* TODO: Check */ +#endif /* To support eMMC booting */ #define CONFIG_STORAGE_EMMC @@ -228,23 +244,22 @@ #define CONFIG_SYS_MEMTEST_START 0x80000000 #define CONFIG_SYS_MEMTEST_END 0x87900000 -#if 0 -#define CONFIG_POWER -#define CONFIG_POWER_I2C -#define CONFIG_POWER_DA9063 /* TODO: Provide driver */ -#endif +/* Enable for NRSW support +#define CONFIG_NM_LOGIN +#define CONFIG_CRYPT +*/ #define CONFIG_CMD_PXE #define CONFIG_OF_BOARD_SETUP +#define CONFIG_JTAG_MARKER_SPL 0x402FFF00 +#define CONFIG_JTAG_MARKER_UBOOT 0x807FFF00 + /* SPL command is not needed */ #undef CONFIG_CMD_SPL /* Never enable ISO it is broken and can lead to a crash */ #undef CONFIG_ISO_PARTITION - - - #endif /* ! __CONFIG_AM335X_NRHW20_H */