summaryrefslogtreecommitdiff
path: root/board/liebherr
diff options
context:
space:
mode:
Diffstat (limited to 'board/liebherr')
-rw-r--r--board/liebherr/display5/common.c10
-rw-r--r--board/liebherr/display5/common.h1
-rw-r--r--board/liebherr/display5/display5.c41
-rw-r--r--board/liebherr/display5/spl.c78
4 files changed, 128 insertions, 2 deletions
diff --git a/board/liebherr/display5/common.c b/board/liebherr/display5/common.c
index 26575f73bd..4eb86d8c5d 100644
--- a/board/liebherr/display5/common.c
+++ b/board/liebherr/display5/common.c
@@ -34,6 +34,16 @@ void displ5_set_iomux_uart(void)
SETUP_IOMUX_PADS(uart_pads);
}
+iomux_v3_cfg_t const misc_pads_spl[] = {
+ /* Emergency recovery pin */
+ MX6_PAD_EIM_D29__GPIO3_IO29 | MUX_PAD_CTRL(NO_PAD_CTRL),
+};
+
+void displ5_set_iomux_misc_spl(void)
+{
+ SETUP_IOMUX_PADS(misc_pads_spl);
+}
+
#ifdef CONFIG_MXC_SPI
iomux_v3_cfg_t const ecspi_pads[] = {
/* SPI3 */
diff --git a/board/liebherr/display5/common.h b/board/liebherr/display5/common.h
index a507ef9ce8..78c64b02e2 100644
--- a/board/liebherr/display5/common.h
+++ b/board/liebherr/display5/common.h
@@ -37,5 +37,6 @@ void displ5_set_iomux_ecspi_spl(void);
void displ5_set_iomux_ecspi(void);
void displ5_set_iomux_usdhc_spl(void);
void displ5_set_iomux_usdhc(void);
+void displ5_set_iomux_misc_spl(void);
#endif /* __DISPL5_COMMON_H_ */
diff --git a/board/liebherr/display5/display5.c b/board/liebherr/display5/display5.c
index ebc643e7e3..d8383170d2 100644
--- a/board/liebherr/display5/display5.c
+++ b/board/liebherr/display5/display5.c
@@ -25,6 +25,7 @@
#include <miiphy.h>
#include <netdev.h>
#include <i2c.h>
+#include <environment.h>
#include <dm.h>
#include <dm/platform_data/serial_mxc.h>
@@ -44,6 +45,7 @@ static bool sw_ids_valid;
static u32 cpu_id;
static u32 unit_id;
+#define EM_PAD IMX_GPIO_NR(3, 29)
#define SW0 IMX_GPIO_NR(2, 4)
#define SW1 IMX_GPIO_NR(2, 5)
#define SW2 IMX_GPIO_NR(2, 6)
@@ -179,6 +181,9 @@ iomux_v3_cfg_t const misc_pads[] = {
/* XTALOSC */
MX6_PAD_GPIO_3__XTALOSC_REF_CLK_24M | MUX_PAD_CTRL(NO_PAD_CTRL),
+
+ /* Emergency recovery pin */
+ MX6_PAD_EIM_D29__GPIO3_IO29 | MUX_PAD_CTRL(NO_PAD_CTRL),
};
#ifdef CONFIG_FSL_ESDHC
@@ -250,6 +255,25 @@ static void setup_iomux_enet(void)
gpio_direction_input(IMX_GPIO_NR(1, 28)); /*INT#_GBE*/
}
+static int setup_mac_from_fuse(void)
+{
+ unsigned char enetaddr[6];
+ int ret;
+
+ ret = eth_env_get_enetaddr("ethaddr", enetaddr);
+ if (ret) /* ethaddr is already set */
+ return 0;
+
+ imx_get_mac_from_fuse(0, enetaddr);
+
+ if (is_valid_ethaddr(enetaddr)) {
+ eth_env_set_enetaddr("ethaddr", enetaddr);
+ return 0;
+ }
+
+ return 0;
+}
+
int board_eth_init(bd_t *bd)
{
struct phy_device *phydev;
@@ -264,6 +288,8 @@ int board_eth_init(bd_t *bd)
if (ret)
return ret;
+ setup_mac_from_fuse();
+
bus = fec_get_miibus(IMX_FEC_BASE, -1);
if (!bus)
return -ENODEV;
@@ -369,7 +395,22 @@ static inline void setup_boot_modes(void) {}
int misc_init_r(void)
{
+ int ret;
+
setup_boot_modes();
+
+ ret = gpio_request(EM_PAD, "Emergency_PAD");
+ if (ret) {
+ printf("Can't request emergency PAD gpio\n");
+ return ret;
+ }
+
+ ret = gpio_direction_input(EM_PAD);
+ if (ret) {
+ printf("Can't set emergency PAD direction\n");
+ return ret;
+ }
+
return 0;
}
diff --git a/board/liebherr/display5/spl.c b/board/liebherr/display5/spl.c
index 6508e0ffa7..0c0172e201 100644
--- a/board/liebherr/display5/spl.c
+++ b/board/liebherr/display5/spl.c
@@ -16,10 +16,12 @@
#include <asm/arch/imx-regs.h>
#include "asm/arch/iomux.h"
#include <asm/mach-imx/iomux-v3.h>
+#include <asm/gpio.h>
#include <environment.h>
#include <fsl_esdhc.h>
#include <netdev.h>
#include <bootcount.h>
+#include <watchdog.h>
#include "common.h"
DECLARE_GLOBAL_DATA_PTR;
@@ -115,6 +117,49 @@ static void ccgr_init(void)
writel(0x000003FF, &ccm->CCGR6);
}
+#ifdef CONFIG_MX6_DDRCAL
+static void spl_dram_print_cal(struct mx6_ddr_sysinfo const *sysinfo)
+{
+ struct mx6_mmdc_calibration calibration = {0};
+
+ mmdc_read_calibration(sysinfo, &calibration);
+
+ debug(".p0_mpdgctrl0\t= 0x%08X\n", calibration.p0_mpdgctrl0);
+ debug(".p0_mpdgctrl1\t= 0x%08X\n", calibration.p0_mpdgctrl1);
+ debug(".p0_mprddlctl\t= 0x%08X\n", calibration.p0_mprddlctl);
+ debug(".p0_mpwrdlctl\t= 0x%08X\n", calibration.p0_mpwrdlctl);
+ debug(".p0_mpwldectrl0\t= 0x%08X\n", calibration.p0_mpwldectrl0);
+ debug(".p0_mpwldectrl1\t= 0x%08X\n", calibration.p0_mpwldectrl1);
+ debug(".p1_mpdgctrl0\t= 0x%08X\n", calibration.p1_mpdgctrl0);
+ debug(".p1_mpdgctrl1\t= 0x%08X\n", calibration.p1_mpdgctrl1);
+ debug(".p1_mprddlctl\t= 0x%08X\n", calibration.p1_mprddlctl);
+ debug(".p1_mpwrdlctl\t= 0x%08X\n", calibration.p1_mpwrdlctl);
+ debug(".p1_mpwldectrl0\t= 0x%08X\n", calibration.p1_mpwldectrl0);
+ debug(".p1_mpwldectrl1\t= 0x%08X\n", calibration.p1_mpwldectrl1);
+}
+
+static void spl_dram_perform_cal(struct mx6_ddr_sysinfo const *sysinfo)
+{
+ int ret;
+
+ /* Perform DDR DRAM calibration */
+ udelay(100);
+ ret = mmdc_do_write_level_calibration(sysinfo);
+ if (ret) {
+ printf("DDR: Write level calibration error [%d]\n", ret);
+ return;
+ }
+
+ ret = mmdc_do_dqs_calibration(sysinfo);
+ if (ret) {
+ printf("DDR: DQS calibration error [%d]\n", ret);
+ return;
+ }
+
+ spl_dram_print_cal(sysinfo);
+}
+#endif /* CONFIG_MX6_DDRCAL */
+
static void spl_dram_init(void)
{
struct mx6_ddr_sysinfo sysinfo = {
@@ -141,6 +186,10 @@ static void spl_dram_init(void)
mx6dq_dram_iocfg(64, &mx6_ddr_ioregs, &mx6_grp_ioregs);
mx6_dram_cfg(&sysinfo, &mx6_4x256mx16_mmdc_calib, &mt41k128m16jt_125);
+
+#ifdef CONFIG_MX6_DDRCAL
+ spl_dram_perform_cal(&sysinfo);
+#endif
}
#ifdef CONFIG_SPL_SPI_SUPPORT
@@ -194,10 +243,28 @@ void board_init_f(ulong dummy)
/* Clear the BSS. */
memset(__bss_start, 0, __bss_end - __bss_start);
+ displ5_set_iomux_misc_spl();
+
+ /* Initialize and reset WDT in SPL */
+ hw_watchdog_init();
+ WATCHDOG_RESET();
+
/* load/boot image from boot device */
board_init_r(NULL, 0);
}
+#define EM_PAD IMX_GPIO_NR(3, 29)
+int board_check_emergency_pad(void)
+{
+ int ret;
+
+ ret = gpio_direction_input(EM_PAD);
+ if (ret)
+ return ret;
+
+ return !gpio_get_value(EM_PAD);
+}
+
void board_boot_order(u32 *spl_boot_list)
{
/* Default boot sequence SPI -> MMC */
@@ -206,12 +273,19 @@ void board_boot_order(u32 *spl_boot_list)
spl_boot_list[2] = BOOT_DEVICE_UART;
spl_boot_list[3] = BOOT_DEVICE_NONE;
+ /*
+ * In case of emergency PAD pressed, we always boot
+ * to proper u-boot and perform recovery tasks there.
+ */
+ if (board_check_emergency_pad())
+ return;
+
#ifdef CONFIG_SPL_ENV_SUPPORT
/* 'fastboot' */
const char *s;
- env_init();
- env_load();
+ if (env_init() || env_load())
+ return;
s = env_get("BOOT_FROM");
if (s && !bootcount_error() && strcmp(s, "ACTIVE") == 0) {