da9063: move driver to common netmodule codebase
- change nmhw21, nrhw24 makefiles/include - change nrhw20 to use improved da9063 code (bus claim/release)
This commit is contained in:
parent
82f1fedaa3
commit
a8cc1f2d85
|
|
@ -10,4 +10,4 @@ ifeq ($(CONFIG_SKIP_LOWLEVEL_INIT),)
|
||||||
obj-y := mux.o
|
obj-y := mux.o
|
||||||
endif
|
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
|
||||||
|
|
|
||||||
|
|
@ -40,8 +40,8 @@
|
||||||
|
|
||||||
#include "../common/bdparser.h"
|
#include "../common/bdparser.h"
|
||||||
#include "../common/board_descriptor.h"
|
#include "../common/board_descriptor.h"
|
||||||
|
#include "../common/da9063.h"
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
#include "da9063.h"
|
|
||||||
#include "sja1105.h"
|
#include "sja1105.h"
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
#include "um.h"
|
#include "um.h"
|
||||||
|
|
|
||||||
|
|
@ -10,4 +10,4 @@ ifeq ($(CONFIG_SKIP_LOWLEVEL_INIT),)
|
||||||
obj-y := mux.o
|
obj-y := mux.o
|
||||||
endif
|
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
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
*
|
*
|
||||||
* Board functions for Netmodule NRHW 20, based on AM335x EVB
|
* 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/
|
* Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: GPL-2.0+
|
* SPDX-License-Identifier: GPL-2.0+
|
||||||
|
|
@ -21,10 +21,6 @@
|
||||||
#include <asm/arch/clk_synthesizer.h>
|
#include <asm/arch/clk_synthesizer.h>
|
||||||
#include <asm/arch/gpio.h>
|
#include <asm/arch/gpio.h>
|
||||||
#include <asm/arch/mmc_host_def.h>
|
#include <asm/arch/mmc_host_def.h>
|
||||||
#include <asm/arch/sys_proto.h>
|
|
||||||
#include <asm/arch/mem.h>
|
|
||||||
#include <asm/io.h>
|
|
||||||
#include <asm/emif.h>
|
|
||||||
#include <asm/gpio.h>
|
#include <asm/gpio.h>
|
||||||
#include <i2c.h>
|
#include <i2c.h>
|
||||||
#include <pca953x.h>
|
#include <pca953x.h>
|
||||||
|
|
@ -33,11 +29,12 @@
|
||||||
#include <environment.h>
|
#include <environment.h>
|
||||||
#include <watchdog.h>
|
#include <watchdog.h>
|
||||||
#include <libfdt.h>
|
#include <libfdt.h>
|
||||||
|
#include <version.h>
|
||||||
|
|
||||||
#include "../common/bdparser.h"
|
#include "../common/bdparser.h"
|
||||||
#include "../common/board_descriptor.h"
|
#include "../common/board_descriptor.h"
|
||||||
|
#include "../common/da9063.h"
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
#include "da9063.h"
|
|
||||||
#include "shield.h"
|
#include "shield.h"
|
||||||
#include "shield_can.h"
|
#include "shield_can.h"
|
||||||
#include "shield_comio.h"
|
#include "shield_comio.h"
|
||||||
|
|
@ -45,7 +42,6 @@
|
||||||
|
|
||||||
DECLARE_GLOBAL_DATA_PTR;
|
DECLARE_GLOBAL_DATA_PTR;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CPU GPIOs
|
* CPU GPIOs
|
||||||
*
|
*
|
||||||
|
|
@ -78,25 +74,24 @@ DECLARE_GLOBAL_DATA_PTR;
|
||||||
|
|
||||||
#define GPIO_TO_PIN(bank, gpio) (32 * (bank) + (gpio))
|
#define GPIO_TO_PIN(bank, gpio) (32 * (bank) + (gpio))
|
||||||
|
|
||||||
#define NETBIRD_GPIO_RST_PHY_N GPIO_TO_PIN(0, 16)
|
#define GPIO_RST_PHY_N GPIO_TO_PIN(0, 16)
|
||||||
#define NETBIRD_GPIO_RST_USB_HUB_N GPIO_TO_PIN(3, 21)
|
#define GPIO_RST_USB_HUB_N GPIO_TO_PIN(3, 21)
|
||||||
|
|
||||||
#define NETBIRD_GPIO_RST_GNSS GPIO_TO_PIN(0, 2)
|
#define GPIO_RST_GNSS GPIO_TO_PIN(0, 2)
|
||||||
#define NETBIRD_GPIO_RST_PCI GPIO_TO_PIN(3, 10)
|
#define GPIO_RST_PCI GPIO_TO_PIN(3, 10)
|
||||||
|
|
||||||
#define NETBIRD_GPIO_RST_GSM GPIO_TO_PIN(1, 25)
|
#define GPIO_RST_GSM GPIO_TO_PIN(1, 25)
|
||||||
#define NETBIRD_GPIO_PWR_GSM GPIO_TO_PIN(1, 21)
|
#define GPIO_PWR_GSM GPIO_TO_PIN(1, 21)
|
||||||
#define NETBIRD_GPIO_WAKE_GSM GPIO_TO_PIN(0, 31)
|
#define GPIO_WAKE_GSM GPIO_TO_PIN(0, 31)
|
||||||
#define NETBIRD_GPIO_SIM_SEL GPIO_TO_PIN(3, 17)
|
#define GPIO_SIM_SEL GPIO_TO_PIN(3, 17)
|
||||||
|
|
||||||
#define NETBIRD_GPIO_WLAN_EN GPIO_TO_PIN(1, 26)
|
#define GPIO_WLAN_EN GPIO_TO_PIN(1, 26)
|
||||||
#define NETBIRD_GPIO_BT_EN GPIO_TO_PIN(1, 20)
|
#define GPIO_BT_EN GPIO_TO_PIN(1, 20)
|
||||||
|
|
||||||
#define NETBIRD_GPIO_DIG_OUT GPIO_TO_PIN(1, 14)
|
#define GPIO_DIG_OUT GPIO_TO_PIN(1, 14)
|
||||||
#define NETBIRD_GPIO_DIG_IN GPIO_TO_PIN(1, 15)
|
#define GPIO_DIG_IN GPIO_TO_PIN(1, 15)
|
||||||
|
|
||||||
#define NETBIRD_GPIO_PCI_WDIS GPIO_TO_PIN(3, 9)
|
|
||||||
|
|
||||||
|
#define GPIO_PCI_WDIS GPIO_TO_PIN(3, 9)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* PMIC GPIOs
|
* PMIC GPIOs
|
||||||
|
|
@ -141,6 +136,15 @@ DECLARE_GLOBAL_DATA_PTR;
|
||||||
|
|
||||||
#define DDR3_CLOCK_FREQUENCY (400)
|
#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)
|
#if !defined(CONFIG_SPL_BUILD)
|
||||||
static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
|
static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -158,6 +162,84 @@ static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
|
||||||
static BD_Context bdctx[3]; /* The descriptor contexts */
|
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)
|
static void init_i2c(void)
|
||||||
{
|
{
|
||||||
i2c_set_bus_num(0);
|
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) {
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -196,41 +278,17 @@ static int _bd_init(void)
|
||||||
return 0;
|
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();
|
if (strcmp(jtag_token, "JTAGBOOT") == 0) {
|
||||||
i2c_set_bus_num(CONFIG_SYS_I2C_PCA953X_BUS);
|
strcpy(jtag_token, "jtagboot");
|
||||||
|
return true;
|
||||||
/* Set all IOs as output */
|
}
|
||||||
(void)pca953x_set_dir(CONFIG_SYS_I2C_PCA953X_ADDR, IOEXT_LEDS_ALL_MASK, PCA953X_DIR_OUT);
|
else {
|
||||||
|
return false;
|
||||||
/* 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -241,24 +299,33 @@ static inline int __maybe_unused read_eeprom(void)
|
||||||
return _bd_init();
|
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)
|
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();
|
enable_uart0_pin_mux();
|
||||||
return &eserial1_device;
|
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
|
#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 */
|
/* Ratios were optimized by DDR3 training software from TI */
|
||||||
.datardsratio0 = 0x39,
|
.datardsratio0 = 0x39,
|
||||||
.datawdsratio0 = 0x3f,
|
.datawdsratio0 = 0x3f,
|
||||||
|
|
@ -266,7 +333,7 @@ static const struct ddr_data ddr3_netbird_data = {
|
||||||
.datawrsratio0 = 0x7d,
|
.datawrsratio0 = 0x7d,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct cmd_control ddr3_netbird_cmd_ctrl_data = {
|
static const struct cmd_control ddr3_cmd_ctrl_data = {
|
||||||
.cmd0csratio = MT41K256M16HA125E_RATIO,
|
.cmd0csratio = MT41K256M16HA125E_RATIO,
|
||||||
.cmd0iclkout = MT41K256M16HA125E_INVERT_CLKOUT,
|
.cmd0iclkout = MT41K256M16HA125E_INVERT_CLKOUT,
|
||||||
|
|
||||||
|
|
@ -290,21 +357,21 @@ static struct emif_regs ddr3_emif_reg_data = {
|
||||||
|
|
||||||
#define OSC (V_OSCK/1000000)
|
#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
|
DDR3_CLOCK_FREQUENCY, OSC-1, 1, -1, -1, -1, -1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void am33xx_spl_board_init(void)
|
static void init_pmic_spl(void)
|
||||||
{
|
{
|
||||||
/* Set CPU speed to 600 MHz (fix) */
|
int bus;
|
||||||
dpll_mpu_opp100.m = MPUPLL_M_600;
|
|
||||||
|
|
||||||
/* Set CORE Frequencies to OPP100 (600MHz) */
|
/* PMIC basic configuration */
|
||||||
do_setup_dpll(&dpll_core_regs, &dpll_core_opp100);
|
da9063_init(CONFIG_PMIC_I2C_BUS);
|
||||||
|
|
||||||
/* Configure both I2C buses used in NRHW20 */
|
bus = da9063_claim_i2c_bus();
|
||||||
init_i2c();
|
|
||||||
|
/* TODO: Move to init_pmic_spl() */
|
||||||
|
|
||||||
/* Configure default PMIC current limits. Will be overridden in Linux.
|
/* Configure default PMIC current limits. Will be overridden in Linux.
|
||||||
* MEM = 1.5A (0.55A)
|
* MEM = 1.5A (0.55A)
|
||||||
|
|
@ -314,31 +381,72 @@ void am33xx_spl_board_init(void)
|
||||||
* CORE2 = 2.0A (0.55A)
|
* CORE2 = 2.0A (0.55A)
|
||||||
* CORE1 = 2.0A (0.25A, seems too low)
|
* CORE1 = 2.0A (0.25A, seems too low)
|
||||||
*/
|
*/
|
||||||
da9063_init(CONFIG_PMIC_I2C_BUS);
|
(void)da9063_set_reg(PMIC_REG_BUCK_ILIM_A, 0x00);
|
||||||
da9063_set_reg(PMIC_REG_BUCK_ILIM_A, 0x00);
|
(void)da9063_set_reg(PMIC_REG_BUCK_ILIM_B, 0x50);
|
||||||
da9063_set_reg(PMIC_REG_BUCK_ILIM_B, 0x50);
|
(void)da9063_set_reg(PMIC_REG_BUCK_ILIM_C, 0xFF);
|
||||||
da9063_set_reg(PMIC_REG_BUCK_ILIM_C, 0xFF);
|
|
||||||
|
|
||||||
init_indicator_leds();
|
/* 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) */
|
||||||
|
dpll_mpu_opp100.m = MPUPLL_M_600;
|
||||||
|
|
||||||
|
/* Set CORE Frequencies to OPP100 (600MHz) */
|
||||||
|
do_setup_dpll(&dpll_core_regs, &dpll_core_opp100);
|
||||||
|
|
||||||
|
/* Configure both I2C buses used */
|
||||||
|
init_i2c();
|
||||||
|
|
||||||
|
/* Setup PMIC */
|
||||||
|
init_pmic_spl();
|
||||||
|
|
||||||
|
init_leds();
|
||||||
|
#if 0 /* TODO: missing ? */
|
||||||
|
set_status_led(1, 0); /* Red */
|
||||||
|
#endif
|
||||||
set_indicator(0, 1, 1); /* Orange */
|
set_indicator(0, 1, 1); /* Orange */
|
||||||
|
|
||||||
/* Set MPU Frequency to what we detected now that voltages are set */
|
/* Set MPU Frequency to what we detected now that voltages are set */
|
||||||
do_setup_dpll(&dpll_mpu_regs, &dpll_mpu_opp100);
|
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)
|
const struct dpll_params *get_dpll_ddr_params(void)
|
||||||
{
|
{
|
||||||
dpll_ddr_nrhw20.n = (get_osclk() / 1000000) - 1;
|
dpll_ddr.n = (get_osclk() / 1000000) - 1;
|
||||||
return &dpll_ddr_nrhw20;
|
return &dpll_ddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_uart_mux_conf(void)
|
void set_uart_mux_conf(void)
|
||||||
{
|
{
|
||||||
enable_uart0_pin_mux();
|
enable_uart0_pin_mux();
|
||||||
enable_uart1_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)
|
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,
|
.cm0ioctl = MT41K256M16HA125E_IOCTRL_VALUE,
|
||||||
.cm1ioctl = MT41K256M16HA125E_IOCTRL_VALUE,
|
.cm1ioctl = MT41K256M16HA125E_IOCTRL_VALUE,
|
||||||
.cm2ioctl = MT41K256M16HA125E_IOCTRL_VALUE,
|
.cm2ioctl = MT41K256M16HA125E_IOCTRL_VALUE,
|
||||||
.dt0ioctl = MT41K256M16HA125E_IOCTRL_VALUE,
|
.dt0ioctl = MT41K256M16HA125E_IOCTRL_VALUE,
|
||||||
.dt1ioctl = MT41K256M16HA125E_IOCTRL_VALUE,
|
.dt1ioctl = MT41K256M16HA125E_IOCTRL_VALUE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void sdram_init(void)
|
void sdram_init(void)
|
||||||
{
|
{
|
||||||
config_ddr(DDR3_CLOCK_FREQUENCY, &ioregs_netbird,
|
config_ddr(DDR3_CLOCK_FREQUENCY, &ioregs,
|
||||||
&ddr3_netbird_data,
|
&ddr3_data,
|
||||||
&ddr3_netbird_cmd_ctrl_data,
|
&ddr3_cmd_ctrl_data,
|
||||||
&ddr3_emif_reg_data, 0);
|
&ddr3_emif_reg_data, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -368,54 +475,47 @@ void sdram_init(void)
|
||||||
|
|
||||||
#if !defined(CONFIG_SPL_BUILD)
|
#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);
|
timeout = PHY_ANEG_DEFAULT_TIMEOUT;
|
||||||
if (ret < 0) {
|
|
||||||
printf("%s: Unable to request %s\n", __func__, name);
|
/*
|
||||||
return;
|
* 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 */
|
return timeout;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define REQUEST_AND_SET_GPIO(N) request_and_set_gpio(N, #N, 1);
|
#endif /* !defined(CONFIG_SPL_BUILD) */
|
||||||
#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);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !defined(CONFIG_SPL_BUILD)
|
#if !defined(CONFIG_SPL_BUILD)
|
||||||
|
|
||||||
static void init_ethernet_switch(void)
|
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);
|
mdelay(1);
|
||||||
|
|
||||||
/* OMAP3 does not feature open drain pins, thus configure pin as input */
|
/* 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
|
/* When the Ethernet switch senses reset, it drives reset for 8..14ms
|
||||||
* Wait longer than this time to avoid IO congestion later on.
|
* 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)
|
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 */
|
/* Minimum Reset Pulse = 1us */
|
||||||
mdelay(2);
|
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)
|
static void init_pcie_slot(void)
|
||||||
{
|
{
|
||||||
|
int bus;
|
||||||
|
|
||||||
puts("PCIe: ");
|
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 */
|
da9063_set_gpio(PMIC_PCIe_SUPPLY_EN_IO, 0); /* Switch PCIe Supply off */
|
||||||
mdelay(30); /* Give time to discharge output */
|
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 */
|
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 */
|
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");
|
puts("ready\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init_gsm(void)
|
static void init_gsm(void)
|
||||||
{
|
{
|
||||||
|
/* TODO: Check and update for Toby-L2 */
|
||||||
/*
|
/*
|
||||||
* Perform power up sequence for Huawei ME909s.
|
* Perform power up sequence for Huawei ME909s.
|
||||||
*
|
*
|
||||||
|
|
@ -465,13 +572,16 @@ static void init_gsm(void)
|
||||||
* 3.3.2 Power Supply VBAT Interface
|
* 3.3.2 Power Supply VBAT Interface
|
||||||
* 3.4.2 Power-on/off Pin, Figure 3.7
|
* 3.4.2 Power-on/off Pin, Figure 3.7
|
||||||
*/
|
*/
|
||||||
|
int bus;
|
||||||
|
|
||||||
puts("GSM: ");
|
puts("GSM: ");
|
||||||
|
|
||||||
|
bus = da9063_claim_i2c_bus();
|
||||||
|
|
||||||
/* TODO: Keep Power-On and use GSM Modem Reset Signal to restart */
|
/* 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_SET_GPIO(GPIO_RST_GSM); /* Assert reset (active high) */
|
||||||
REQUEST_AND_CLEAR_GPIO(NETBIRD_GPIO_PWR_GSM); /* Keep power switch inactive (released) */
|
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 */
|
da9063_set_gpio(PMIC_GSM_SUPPLY_EN_IO, 0); /* Switch GSM Supply off */
|
||||||
mdelay(30+100); /* Give time to discharge supply */
|
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 */
|
da9063_set_gpio(PMIC_GSM_SUPPLY_EN_IO, 1); /* Enable GSM supply */
|
||||||
mdelay(10);
|
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 */
|
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);
|
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");
|
puts("ready\n");
|
||||||
}
|
}
|
||||||
|
|
@ -493,9 +605,9 @@ static void init_gsm(void)
|
||||||
static void init_gnss(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;
|
gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
|
||||||
|
|
||||||
/* Configure both I2C buses used in NRHW20 */
|
/* Configure both I2C buses used */
|
||||||
init_i2c();
|
init_i2c();
|
||||||
|
|
||||||
da9063_init(CONFIG_PMIC_I2C_BUS);
|
da9063_init(CONFIG_PMIC_I2C_BUS);
|
||||||
|
|
||||||
/* Let user know we're starting */
|
/* Let user know we're starting */
|
||||||
init_indicator_leds();
|
init_leds();
|
||||||
set_status_led(1, 1); /* Orange */
|
set_status_led(1, 1); /* Orange */
|
||||||
|
/* TODO: Status LED correct? */
|
||||||
|
|
||||||
printf("OSC: %lu MHz\n", get_osclk()/1000000);
|
printf("OSC: %lu MHz\n", get_osclk()/1000000);
|
||||||
|
|
||||||
|
|
@ -530,6 +643,10 @@ int board_init(void)
|
||||||
|
|
||||||
#if !defined(CONFIG_SPL_BUILD)
|
#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
|
* Set Linux console based on
|
||||||
* - Selection in /root/boot/consoledev
|
* - Selection in /root/boot/consoledev
|
||||||
|
|
@ -540,7 +657,8 @@ int board_init(void)
|
||||||
void set_console(void)
|
void set_console(void)
|
||||||
{
|
{
|
||||||
const char *defaultconsole = getenv("defaultconsole");
|
const char *defaultconsole = getenv("defaultconsole");
|
||||||
char buf[8];
|
char buf[20];
|
||||||
|
int i;
|
||||||
|
|
||||||
/* Set default console to ttyS1 if not yet defined in env */
|
/* Set default console to ttyS1 if not yet defined in env */
|
||||||
if (defaultconsole == 0) {
|
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 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) {
|
if (strstr(buf, "tty") == buf) {
|
||||||
buf[5] = 0;
|
buf[sizeof(buf)-1] = 0;
|
||||||
|
for (i=0; i<sizeof(buf); i++) {
|
||||||
|
if (buf[i]<=' ') {
|
||||||
|
buf[i] = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
setenv("defaultconsole", buf);
|
setenv("defaultconsole", buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(CONFIG_PRE_CONSOLE_BUFFER)
|
||||||
|
defaultconsole = getenv("defaultconsole");
|
||||||
|
|
||||||
|
if (strstr(defaultconsole, "ttyS0")) {
|
||||||
|
/* Only use internal console, if explicitely specified */
|
||||||
|
serial_set_console_index(0);
|
||||||
|
// } else if (strstr(defaultconsole, "ttyNull")) {
|
||||||
|
// /* If no console shall be available use bluetooth uart. */
|
||||||
|
// serial_set_console_index(5);
|
||||||
|
} else {
|
||||||
|
/* Otherwise and especially, if no console is specified
|
||||||
|
use the default console, which is the external console */
|
||||||
|
serial_set_console_index(1);
|
||||||
|
}
|
||||||
|
serial_init(); /* serial communications setup */
|
||||||
|
console_init_f(); /* stage 1 init of console */
|
||||||
|
#else
|
||||||
|
serial_set_console_index(1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_devicetree_name(void)
|
static void set_devicetree_name(void)
|
||||||
|
|
@ -583,24 +727,66 @@ static void set_root_partition(void)
|
||||||
setenv_ulong("root_part", boot_partition + 1);
|
setenv_ulong("root_part", boot_partition + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void get_variant_name(void)
|
||||||
|
{
|
||||||
|
bd_get_variantname(hw_variant_name, sizeof(hw_variant_name));
|
||||||
|
|
||||||
|
printf("SYS: %s\n", hw_variant_name);
|
||||||
|
}
|
||||||
|
|
||||||
static void get_hw_version(void)
|
static void get_hw_version(void)
|
||||||
{
|
{
|
||||||
int hw_ver, hw_rev;
|
|
||||||
char hw_versions[16];
|
char hw_versions[16];
|
||||||
char new_env[256]; /* current bootargs = 84 bytes */
|
char new_env[256]; /* current bootargs = 84 bytes */
|
||||||
|
|
||||||
bd_get_hw_version(&hw_ver, &hw_rev);
|
bd_get_hw_version(&hw_ver, &hw_rev);
|
||||||
|
bd_get_hw_patch(&hw_patch);
|
||||||
|
|
||||||
printf("HW20: V%d.%d\n", hw_ver, hw_rev);
|
printf("HW20: V%d.%d\n", hw_ver, hw_rev);
|
||||||
|
|
||||||
|
/* TODO: Check if this can be removed eventually */
|
||||||
/* add hardware versions to environment */
|
/* add hardware versions to environment */
|
||||||
snprintf(hw_versions, sizeof(hw_versions), "CP=%d.%d", hw_ver, hw_rev);
|
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);
|
snprintf(new_env, sizeof(new_env), "setenv bootargs $bootargs %s", hw_versions);
|
||||||
setenv("add_version_bootargs", new_env);
|
setenv("add_version_bootargs", new_env);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void get_pmic_version(void)
|
||||||
|
{
|
||||||
|
uint8_t val = 0x00;
|
||||||
|
uint8_t ver, rev;
|
||||||
|
int bus;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
bus = da9063_claim_i2c_bus();
|
||||||
|
|
||||||
|
rc = da9063_get_reg(PMIC_REG_CONFIG_ID, &val);
|
||||||
|
if (!rc) {
|
||||||
|
ver = (val >> 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)
|
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.
|
* In this case we are connected to the factory test station.
|
||||||
* Clear the bootcmd, so that test system can easily connect.
|
* 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 probe fails we are sure no eeprom is connected */
|
||||||
if (i2c_probe(0x51) == 0) {
|
if (i2c_probe(0x51) == 0) {
|
||||||
printf("Entering fct mode\n");
|
|
||||||
setenv ("bootcmd", "");
|
setenv ("bootcmd", "");
|
||||||
|
puts("Detected factory test system. Waiting on command line\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
i2c_set_bus_num(old_bus);
|
i2c_set_bus_num(old_bus);
|
||||||
|
|
@ -700,11 +886,20 @@ static void shield_init(void)
|
||||||
|
|
||||||
static bool get_button_state(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)
|
static void blink_led(void)
|
||||||
|
|
@ -713,7 +908,8 @@ static void blink_led(void)
|
||||||
|
|
||||||
/* Assumes green status LED is on */
|
/* Assumes green status LED is on */
|
||||||
udelay(pulse_width);
|
udelay(pulse_width);
|
||||||
set_status_led(0, 0);
|
set_status_led(0, 0); /* Off */
|
||||||
|
|
||||||
udelay(pulse_width);
|
udelay(pulse_width);
|
||||||
set_status_led(0, 1);
|
set_status_led(0, 1);
|
||||||
}
|
}
|
||||||
|
|
@ -750,9 +946,9 @@ static void check_reset_button(void)
|
||||||
char new_bootargs[512];
|
char new_bootargs[512];
|
||||||
char *bootargs = getenv("bootargs");
|
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));
|
strncpy(new_bootargs, bootargs, sizeof(new_bootargs));
|
||||||
strncat(new_bootargs, " factory-reset", sizeof(new_bootargs));
|
strncat(new_bootargs, " factory-reset", sizeof(new_bootargs));
|
||||||
|
|
@ -762,8 +958,7 @@ static void check_reset_button(void)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Boot into recovery for duration > 12s */
|
/* Boot into recovery for duration > 12s */
|
||||||
|
puts("Booting recovery image...\n");
|
||||||
printf("Booting recovery image...\n");
|
|
||||||
|
|
||||||
/* Set consoledev to external port */
|
/* Set consoledev to external port */
|
||||||
setenv("defaultconsole", "ttyS1");
|
setenv("defaultconsole", "ttyS1");
|
||||||
|
|
@ -772,23 +967,27 @@ static void check_reset_button(void)
|
||||||
setenv("bootcmd", "run recovery");
|
setenv("bootcmd", "run recovery");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* !defined(CONFIG_SPL_BUILD) */
|
|
||||||
|
|
||||||
|
#endif /* !defined(CONFIG_SPL_BUILD) */
|
||||||
|
|
||||||
int board_late_init(void)
|
int board_late_init(void)
|
||||||
{
|
{
|
||||||
#if !defined(CONFIG_SPL_BUILD)
|
#if !defined(CONFIG_SPL_BUILD)
|
||||||
if (read_eeprom() < 0)
|
if (read_eeprom() < 0) {
|
||||||
puts("Could not get board ID.\n");
|
puts("Could not get board ID.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
get_variant_name();
|
||||||
get_hw_version();
|
get_hw_version();
|
||||||
|
get_pmic_version();
|
||||||
|
|
||||||
set_root_partition();
|
set_root_partition();
|
||||||
set_devicetree_name();
|
set_devicetree_name();
|
||||||
|
|
||||||
/* Initialize pins */
|
/* Initialize pins */
|
||||||
REQUEST_AND_CLEAR_GPIO(NETBIRD_GPIO_WLAN_EN);
|
REQUEST_AND_CLEAR_GPIO(GPIO_WLAN_EN);
|
||||||
REQUEST_AND_CLEAR_GPIO(NETBIRD_GPIO_BT_EN);
|
REQUEST_AND_CLEAR_GPIO(GPIO_BT_EN);
|
||||||
REQUEST_AND_CLEAR_GPIO(NETBIRD_GPIO_DIG_OUT);
|
REQUEST_AND_CLEAR_GPIO(GPIO_DIG_OUT);
|
||||||
|
|
||||||
init_ethernet_switch();
|
init_ethernet_switch();
|
||||||
init_usb_hub();
|
init_usb_hub();
|
||||||
|
|
@ -796,9 +995,11 @@ int board_late_init(void)
|
||||||
init_gsm();
|
init_gsm();
|
||||||
init_gnss();
|
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();
|
check_reset_button();
|
||||||
|
|
||||||
set_console();
|
set_console();
|
||||||
|
|
@ -808,6 +1009,7 @@ int board_late_init(void)
|
||||||
set_indicator(0, 0, 1); /* Green */
|
set_indicator(0, 0, 1); /* Green */
|
||||||
|
|
||||||
check_fct();
|
check_fct();
|
||||||
|
check_jtag_boot();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -885,13 +1087,10 @@ static void set_mac_address(int index, uchar mac[6])
|
||||||
*/
|
*/
|
||||||
int board_eth_init(bd_t *bis)
|
int board_eth_init(bd_t *bis)
|
||||||
{
|
{
|
||||||
int rv, n = 0;
|
int n = 0;
|
||||||
uint8_t mac_addr0[6] = {02,00,00,00,00,01};
|
__maybe_unused uint8_t mac_addr0[6] = {02,00,00,00,00,01};
|
||||||
__maybe_unused struct ti_am_eeprom *header;
|
|
||||||
|
|
||||||
#if !defined(CONFIG_SPL_BUILD)
|
#if !defined(CONFIG_SPL_BUILD)
|
||||||
#ifdef CONFIG_DRIVER_TI_CPSW
|
#ifdef CONFIG_DRIVER_TI_CPSW
|
||||||
|
|
||||||
cpsw_data.mdio_div = 0x3E;
|
cpsw_data.mdio_div = 0x3E;
|
||||||
|
|
||||||
bd_get_mac(0, mac_addr0, sizeof(mac_addr0));
|
bd_get_mac(0, mac_addr0, sizeof(mac_addr0));
|
||||||
|
|
@ -899,25 +1098,35 @@ int board_eth_init(bd_t *bis)
|
||||||
|
|
||||||
writel(RMII_MODE_ENABLE | RMII_CHIPCKL_ENABLE, &cdev->miisel);
|
writel(RMII_MODE_ENABLE | RMII_CHIPCKL_ENABLE, &cdev->miisel);
|
||||||
|
|
||||||
rv = cpsw_register(&cpsw_data);
|
{
|
||||||
if (rv < 0)
|
int rv = cpsw_register(&cpsw_data);
|
||||||
printf("Error %d registering CPSW switch\n", rv);
|
if (rv < 0)
|
||||||
else
|
{
|
||||||
n += rv;
|
printf("Error %d registering CPSW switch\n", rv);
|
||||||
|
} else {
|
||||||
|
n += rv;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_USB_ETHER) && \
|
#if defined(CONFIG_USB_ETHER) && \
|
||||||
(!defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_USBETH_SUPPORT))
|
(!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);
|
eth_setenv_enetaddr("usbnet_devaddr", mac_addr0);
|
||||||
|
}
|
||||||
|
|
||||||
rv = usb_eth_initialize(bis);
|
{
|
||||||
if (rv < 0)
|
int rv = usb_eth_initialize(bis);
|
||||||
printf("Error %d registering USB_ETHER\n", rv);
|
if (rv < 0)
|
||||||
else
|
{
|
||||||
n += rv;
|
printf("Error %d registering USB_ETHER\n", rv);
|
||||||
|
} else {
|
||||||
|
n += rv;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -931,7 +1140,7 @@ int board_fit_config_name_match(const char *name)
|
||||||
}
|
}
|
||||||
#endif
|
#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)
|
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)
|
static void ft_serial(void *blob, int shield_type)
|
||||||
{
|
{
|
||||||
switch (shield_type) {
|
switch (shield_type) {
|
||||||
/* If COM/IO shield is present enable uart1 (ttyS0) */
|
/* Enable uart1 (ttyS0) always as kernel needs it as fallback
|
||||||
case SHIELD_COM_IO:
|
console, if (ttyS1) is not available as console. */
|
||||||
/* TODO: Should use alias serial0 */
|
|
||||||
ft_enable_node(blob, "/ocp/serial@44e09000");
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
/* TODO: Should use alias serial0 */
|
||||||
|
ft_enable_node(blob, "/ocp/serial@44e09000");
|
||||||
break;
|
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 ft_board_setup(void *blob, bd_t *bd)
|
||||||
{
|
{
|
||||||
int shield_type = -1;
|
int shield_type = -1;
|
||||||
|
|
||||||
|
ft_bootloader_version(blob);
|
||||||
|
ft_hw_info(blob);
|
||||||
|
|
||||||
shield_type = bd_get_shield(0);
|
shield_type = bd_get_shield(0);
|
||||||
|
|
||||||
ft_dio(blob, shield_type);
|
ft_dio(blob, shield_type);
|
||||||
|
|
@ -999,4 +1235,4 @@ int ft_board_setup(void *blob, bd_t *bd)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif /* defined(CONFIG_OF_BOARD_SETUP) && !defined(CONFIG_SPL_BUILD) */
|
||||||
|
|
|
||||||
|
|
@ -19,12 +19,9 @@
|
||||||
void enable_uart0_pin_mux(void);
|
void enable_uart0_pin_mux(void);
|
||||||
void disable_uart0_pin_mux(void);
|
void disable_uart0_pin_mux(void);
|
||||||
void enable_uart1_pin_mux(void);
|
void enable_uart1_pin_mux(void);
|
||||||
/*
|
|
||||||
void enable_uart2_pin_mux(void);
|
|
||||||
void enable_uart3_pin_mux(void);
|
void enable_uart3_pin_mux(void);
|
||||||
void enable_uart4_pin_mux(void);
|
|
||||||
void enable_uart5_pin_mux(void);
|
void enable_uart5_pin_mux(void);
|
||||||
*/
|
|
||||||
void enable_i2c0_pin_mux(void);
|
void enable_i2c0_pin_mux(void);
|
||||||
void enable_i2c2_pin_mux(void);
|
void enable_i2c2_pin_mux(void);
|
||||||
void enable_board_pin_mux(void);
|
void enable_board_pin_mux(void);
|
||||||
|
|
|
||||||
|
|
@ -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 <common.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <i2c.h>
|
|
||||||
|
|
||||||
#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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -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 */
|
|
||||||
|
|
@ -249,3 +249,12 @@ void enable_uart1_pin_mux(void)
|
||||||
configure_module_pin_mux(uart1_pin_mux);
|
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);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,4 +10,4 @@ ifeq ($(CONFIG_SKIP_LOWLEVEL_INIT),)
|
||||||
obj-y := mux.o
|
obj-y := mux.o
|
||||||
endif
|
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
|
||||||
|
|
|
||||||
|
|
@ -33,8 +33,8 @@
|
||||||
|
|
||||||
#include "../common/bdparser.h"
|
#include "../common/bdparser.h"
|
||||||
#include "../common/board_descriptor.h"
|
#include "../common/board_descriptor.h"
|
||||||
|
#include "../common/da9063.h"
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
#include "da9063.h"
|
|
||||||
#include "shield.h"
|
#include "shield.h"
|
||||||
#include "shield_can.h"
|
#include "shield_can.h"
|
||||||
#include "shield_comio.h"
|
#include "shield_comio.h"
|
||||||
|
|
@ -338,6 +338,7 @@ static void init_pmic_spl(void)
|
||||||
|
|
||||||
/* Enable charging of RTC backup capacitor (1mA, 3.1V) */
|
/* Enable charging of RTC backup capacitor (1mA, 3.1V) */
|
||||||
(void)da9063_set_reg(PMIC_REG_BBAT_CONT, 0xAF);
|
(void)da9063_set_reg(PMIC_REG_BBAT_CONT, 0xAF);
|
||||||
|
/* TODO: Check documentation 1 mA correct ? */
|
||||||
|
|
||||||
da9063_release_i2c_bus(bus);
|
da9063_release_i2c_bus(bus);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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 <common.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <i2c.h>
|
|
||||||
|
|
||||||
#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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -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 <types.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_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 <ver.rev> */
|
|
||||||
|
|
||||||
|
|
||||||
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 */
|
|
||||||
|
|
@ -131,6 +131,9 @@ int eth_phy_timeout(void);
|
||||||
#define CONFIG_SYS_NS16550_COM2 0x48022000 /* UART1: Unused, see note below */
|
#define CONFIG_SYS_NS16550_COM2 0x48022000 /* UART1: Unused, see note below */
|
||||||
#define CONFIG_SYS_NS16550_COM3 0x48024000 /* UART2: eMMC Boot, User UART */
|
#define CONFIG_SYS_NS16550_COM3 0x48024000 /* UART2: eMMC Boot, User UART */
|
||||||
/* NOTE: NS16550 definitions are cumulative, need to set COM2 to have COM3 */
|
/* 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
|
||||||
#define CONFIG_I2C_MULTI_BUS
|
#define CONFIG_I2C_MULTI_BUS
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* am335x_nrhw20.h
|
* 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/
|
* Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
|
|
@ -36,12 +36,29 @@
|
||||||
#define CONFIG_MACH_TYPE MACH_TYPE_TIAM335EVM
|
#define CONFIG_MACH_TYPE MACH_TYPE_TIAM335EVM
|
||||||
#define CONFIG_BOARD_LATE_INIT
|
#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 */
|
/* Clock Defines */
|
||||||
#define V_OSCK 0 /* 0 means detect from sysboot1 config */
|
#define V_OSCK 0 /* 0 means detect from sysboot1 config */
|
||||||
#define V_SCLK (V_OSCK)
|
#define V_SCLK (V_OSCK)
|
||||||
|
|
||||||
#include <config_distro_bootcmd.h>
|
#include <config_distro_bootcmd.h>
|
||||||
|
|
||||||
|
/* 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
|
#define CONFIG_ARP_TIMEOUT 200
|
||||||
#undef CONFIG_NET_RETRY_COUNT
|
#undef CONFIG_NET_RETRY_COUNT
|
||||||
#define CONFIG_NET_RETRY_COUNT 5
|
#define CONFIG_NET_RETRY_COUNT 5
|
||||||
|
|
@ -111,6 +128,10 @@
|
||||||
/* UART Configuration */
|
/* UART Configuration */
|
||||||
#define CONFIG_SYS_NS16550_COM1 0x44e09000 /* UART0: XModem Boot, Shield */
|
#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_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
|
||||||
#define CONFIG_I2C_MULTI_BUS
|
#define CONFIG_I2C_MULTI_BUS
|
||||||
|
|
@ -136,13 +157,6 @@
|
||||||
#define CONFIG_ENV_IS_IN_MMC
|
#define CONFIG_ENV_IS_IN_MMC
|
||||||
#define CONFIG_SYS_MMC_ENV_DEV 1
|
#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_ENV_SUPPORT
|
||||||
#undef CONFIG_SPL_NAND_SUPPORT
|
#undef CONFIG_SPL_NAND_SUPPORT
|
||||||
#undef CONFIG_SPL_ONENAND_SUPPORT
|
#undef CONFIG_SPL_ONENAND_SUPPORT
|
||||||
|
|
@ -173,13 +187,15 @@
|
||||||
#define CONFIG_AM335X_USB0
|
#define CONFIG_AM335X_USB0
|
||||||
#define CONFIG_AM335X_USB0_MODE MUSB_HOST
|
#define CONFIG_AM335X_USB0_MODE MUSB_HOST
|
||||||
|
|
||||||
|
/* TODO: remove */
|
||||||
|
#if 0
|
||||||
/* Fastboot */
|
/* Fastboot */
|
||||||
#define CONFIG_USB_FUNCTION_FASTBOOT
|
#define CONFIG_USB_FUNCTION_FASTBOOT
|
||||||
#define CONFIG_CMD_FASTBOOT
|
#define CONFIG_CMD_FASTBOOT
|
||||||
#define CONFIG_ANDROID_BOOT_IMAGE
|
#define CONFIG_ANDROID_BOOT_IMAGE
|
||||||
#define CONFIG_FASTBOOT_BUF_ADDR CONFIG_SYS_LOAD_ADDR
|
#define CONFIG_FASTBOOT_BUF_ADDR CONFIG_SYS_LOAD_ADDR
|
||||||
#define CONFIG_FASTBOOT_BUF_SIZE 0x07000000
|
#define CONFIG_FASTBOOT_BUF_SIZE 0x07000000
|
||||||
/* TODO: Check */
|
#endif
|
||||||
|
|
||||||
/* To support eMMC booting */
|
/* To support eMMC booting */
|
||||||
#define CONFIG_STORAGE_EMMC
|
#define CONFIG_STORAGE_EMMC
|
||||||
|
|
@ -228,23 +244,22 @@
|
||||||
#define CONFIG_SYS_MEMTEST_START 0x80000000
|
#define CONFIG_SYS_MEMTEST_START 0x80000000
|
||||||
#define CONFIG_SYS_MEMTEST_END 0x87900000
|
#define CONFIG_SYS_MEMTEST_END 0x87900000
|
||||||
|
|
||||||
#if 0
|
/* Enable for NRSW support
|
||||||
#define CONFIG_POWER
|
#define CONFIG_NM_LOGIN
|
||||||
#define CONFIG_POWER_I2C
|
#define CONFIG_CRYPT
|
||||||
#define CONFIG_POWER_DA9063 /* TODO: Provide driver */
|
*/
|
||||||
#endif
|
|
||||||
|
|
||||||
#define CONFIG_CMD_PXE
|
#define CONFIG_CMD_PXE
|
||||||
|
|
||||||
#define CONFIG_OF_BOARD_SETUP
|
#define CONFIG_OF_BOARD_SETUP
|
||||||
|
|
||||||
|
#define CONFIG_JTAG_MARKER_SPL 0x402FFF00
|
||||||
|
#define CONFIG_JTAG_MARKER_UBOOT 0x807FFF00
|
||||||
|
|
||||||
/* SPL command is not needed */
|
/* SPL command is not needed */
|
||||||
#undef CONFIG_CMD_SPL
|
#undef CONFIG_CMD_SPL
|
||||||
|
|
||||||
/* Never enable ISO it is broken and can lead to a crash */
|
/* Never enable ISO it is broken and can lead to a crash */
|
||||||
#undef CONFIG_ISO_PARTITION
|
#undef CONFIG_ISO_PARTITION
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* ! __CONFIG_AM335X_NRHW20_H */
|
#endif /* ! __CONFIG_AM335X_NRHW20_H */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue