2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2014-02-07 13:06:50 +00:00
|
|
|
/*
|
|
|
|
* board.c
|
|
|
|
*
|
2016-06-22 10:36:14 +00:00
|
|
|
* Board functions for B&R BRXRE1 Board
|
2014-02-07 13:06:50 +00:00
|
|
|
*
|
2015-05-28 13:41:12 +00:00
|
|
|
* Copyright (C) 2013 Hannes Schmelzer <oe5hpm@oevsv.at>
|
2014-02-07 13:06:50 +00:00
|
|
|
* Bernecker & Rainer Industrieelektronik GmbH - http://www.br-automation.com
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#include <common.h>
|
2019-08-01 15:46:48 +00:00
|
|
|
#include <env.h>
|
2014-02-07 13:06:50 +00:00
|
|
|
#include <errno.h>
|
2019-11-14 19:57:46 +00:00
|
|
|
#include <init.h>
|
2014-02-07 13:06:50 +00:00
|
|
|
#include <spl.h>
|
|
|
|
#include <asm/arch/cpu.h>
|
|
|
|
#include <asm/arch/hardware.h>
|
|
|
|
#include <asm/arch/omap.h>
|
|
|
|
#include <asm/arch/ddr_defs.h>
|
|
|
|
#include <asm/arch/clock.h>
|
|
|
|
#include <asm/arch/gpio.h>
|
|
|
|
#include <asm/arch/sys_proto.h>
|
|
|
|
#include <asm/arch/mem.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <asm/global_data.h>
|
2014-02-07 13:06:50 +00:00
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/emif.h>
|
|
|
|
#include <asm/gpio.h>
|
2019-02-06 12:25:59 +00:00
|
|
|
#include <dm.h>
|
2014-02-07 13:06:50 +00:00
|
|
|
#include <power/tps65217.h>
|
|
|
|
#include "../common/bur_common.h"
|
2019-04-10 12:13:16 +00:00
|
|
|
#include "../common/br_resetc.h"
|
2014-02-07 13:06:50 +00:00
|
|
|
|
|
|
|
/* -------------------------------------------------------------------------*/
|
|
|
|
/* -- defines for used GPIO Hardware -- */
|
2019-04-10 12:13:15 +00:00
|
|
|
#define ESC_KEY (0 + 19)
|
|
|
|
#define LCD_PWR (0 + 5)
|
2014-02-07 13:06:50 +00:00
|
|
|
|
2019-04-10 12:13:16 +00:00
|
|
|
#define RSTCTRL_FORCE_PWR_NEN 0x04
|
|
|
|
#define RSTCTRL_CAN_STB 0x40
|
2014-02-07 13:06:50 +00:00
|
|
|
|
2015-02-03 12:22:42 +00:00
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2014-02-07 13:06:50 +00:00
|
|
|
#if defined(CONFIG_SPL_BUILD)
|
|
|
|
static const struct ddr_data ddr3_data = {
|
|
|
|
.datardsratio0 = MT41K256M16HA125E_RD_DQS,
|
|
|
|
.datawdsratio0 = MT41K256M16HA125E_WR_DQS,
|
|
|
|
.datafwsratio0 = MT41K256M16HA125E_PHY_FIFO_WE,
|
|
|
|
.datawrsratio0 = MT41K256M16HA125E_PHY_WR_DATA,
|
|
|
|
};
|
2019-04-10 12:13:15 +00:00
|
|
|
|
2014-02-07 13:06:50 +00:00
|
|
|
static const struct cmd_control ddr3_cmd_ctrl_data = {
|
|
|
|
.cmd0csratio = MT41K256M16HA125E_RATIO,
|
|
|
|
.cmd0iclkout = MT41K256M16HA125E_INVERT_CLKOUT,
|
|
|
|
|
|
|
|
.cmd1csratio = MT41K256M16HA125E_RATIO,
|
|
|
|
.cmd1iclkout = MT41K256M16HA125E_INVERT_CLKOUT,
|
|
|
|
|
|
|
|
.cmd2csratio = MT41K256M16HA125E_RATIO,
|
|
|
|
.cmd2iclkout = MT41K256M16HA125E_INVERT_CLKOUT,
|
|
|
|
};
|
2019-04-10 12:13:15 +00:00
|
|
|
|
2014-02-07 13:06:50 +00:00
|
|
|
static struct emif_regs ddr3_emif_reg_data = {
|
|
|
|
.sdram_config = MT41K256M16HA125E_EMIF_SDCFG,
|
|
|
|
.ref_ctrl = MT41K256M16HA125E_EMIF_SDREF,
|
|
|
|
.sdram_tim1 = MT41K256M16HA125E_EMIF_TIM1,
|
|
|
|
.sdram_tim2 = MT41K256M16HA125E_EMIF_TIM2,
|
|
|
|
.sdram_tim3 = MT41K256M16HA125E_EMIF_TIM3,
|
|
|
|
.zq_config = MT41K256M16HA125E_ZQ_CFG,
|
|
|
|
.emif_ddr_phy_ctlr_1 = MT41K256M16HA125E_EMIF_READ_LATENCY,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct ctrl_ioregs ddr3_ioregs = {
|
|
|
|
.cm0ioctl = MT41K256M16HA125E_IOCTRL_VALUE,
|
|
|
|
.cm1ioctl = MT41K256M16HA125E_IOCTRL_VALUE,
|
|
|
|
.cm2ioctl = MT41K256M16HA125E_IOCTRL_VALUE,
|
|
|
|
.dt0ioctl = MT41K256M16HA125E_IOCTRL_VALUE,
|
|
|
|
.dt1ioctl = MT41K256M16HA125E_IOCTRL_VALUE,
|
|
|
|
};
|
|
|
|
|
2019-04-10 12:13:15 +00:00
|
|
|
#define OSC (V_OSCK / 1000000)
|
|
|
|
const struct dpll_params dpll_ddr3 = { 400, OSC - 1, 1, -1, -1, -1, -1};
|
2014-02-07 13:06:50 +00:00
|
|
|
|
|
|
|
void am33xx_spl_board_init(void)
|
|
|
|
{
|
2019-02-06 12:25:59 +00:00
|
|
|
int rc;
|
2014-02-07 13:06:50 +00:00
|
|
|
|
|
|
|
struct cm_perpll *const cmper = (struct cm_perpll *)CM_PER;
|
|
|
|
struct cm_wkuppll *const cmwkup = (struct cm_wkuppll *)CM_WKUP;
|
|
|
|
/*
|
|
|
|
* enable additional clocks of modules which are accessed later from
|
|
|
|
* VxWorks OS
|
|
|
|
*/
|
|
|
|
u32 *const clk_domains[] = { 0 };
|
|
|
|
|
2016-06-22 10:36:14 +00:00
|
|
|
u32 *const clk_modules_xre1specific[] = {
|
2014-02-07 13:06:50 +00:00
|
|
|
&cmwkup->wkup_adctscctrl,
|
|
|
|
&cmper->spi1clkctrl,
|
|
|
|
&cmper->dcan0clkctrl,
|
|
|
|
&cmper->dcan1clkctrl,
|
|
|
|
&cmper->epwmss0clkctrl,
|
|
|
|
&cmper->epwmss1clkctrl,
|
|
|
|
&cmper->epwmss2clkctrl,
|
2015-02-03 12:22:39 +00:00
|
|
|
&cmper->lcdclkctrl,
|
|
|
|
&cmper->lcdcclkstctrl,
|
2014-02-07 13:06:50 +00:00
|
|
|
0
|
|
|
|
};
|
2016-06-22 10:36:14 +00:00
|
|
|
do_enable_clocks(clk_domains, clk_modules_xre1specific, 1);
|
2014-02-07 13:06:50 +00:00
|
|
|
/* power-OFF LCD-Display */
|
2019-02-06 12:25:59 +00:00
|
|
|
if (gpio_request(LCD_PWR, "LCD_PWR") != 0)
|
|
|
|
printf("cannot request gpio for LCD_PWR!\n");
|
|
|
|
else if (gpio_direction_output(LCD_PWR, 0) != 0)
|
|
|
|
printf("cannot set direction output on LCD_PWR!\n");
|
2014-02-07 13:06:50 +00:00
|
|
|
|
|
|
|
/* setup I2C */
|
2015-03-19 09:43:15 +00:00
|
|
|
enable_i2c_pin_mux();
|
2014-02-07 13:06:50 +00:00
|
|
|
|
2019-02-06 12:25:59 +00:00
|
|
|
/* power-ON 3V3 via Resetcontroller */
|
2019-04-10 12:13:16 +00:00
|
|
|
rc = br_resetc_regset(RSTCTRL_CTRLREG,
|
|
|
|
RSTCTRL_FORCE_PWR_NEN | RSTCTRL_CAN_STB);
|
2019-02-06 12:25:59 +00:00
|
|
|
if (rc != 0)
|
2019-04-10 12:13:16 +00:00
|
|
|
printf("ERROR: cannot write to resetc (turn on PWR_nEN)!\n");
|
2014-02-07 13:06:50 +00:00
|
|
|
|
2019-01-31 08:24:45 +00:00
|
|
|
pmicsetup(0, 0);
|
2014-02-07 13:06:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const struct dpll_params *get_dpll_ddr_params(void)
|
|
|
|
{
|
|
|
|
return &dpll_ddr3;
|
|
|
|
}
|
|
|
|
|
|
|
|
void sdram_init(void)
|
|
|
|
{
|
|
|
|
config_ddr(400, &ddr3_ioregs,
|
|
|
|
&ddr3_data,
|
|
|
|
&ddr3_cmd_ctrl_data,
|
|
|
|
&ddr3_emif_reg_data, 0);
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_SPL_BUILD */
|
|
|
|
/*
|
|
|
|
* Basic board specific setup. Pinmux has been handled already.
|
|
|
|
*/
|
|
|
|
int board_init(void)
|
|
|
|
{
|
2019-04-10 12:13:16 +00:00
|
|
|
/* request common used gpios */
|
|
|
|
gpio_request(ESC_KEY, "boot-key");
|
|
|
|
|
2019-02-06 12:25:59 +00:00
|
|
|
if (power_tps65217_init(0))
|
|
|
|
printf("WARN: cannot setup PMIC 0x24 @ bus #0, not found!.\n");
|
|
|
|
|
2014-02-07 13:06:50 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_BOARD_LATE_INIT
|
|
|
|
|
2019-04-10 12:13:16 +00:00
|
|
|
int board_boot_key(void)
|
|
|
|
{
|
|
|
|
return gpio_get_value(ESC_KEY);
|
|
|
|
}
|
2014-02-07 13:06:50 +00:00
|
|
|
|
2019-04-10 12:13:16 +00:00
|
|
|
int board_late_init(void)
|
|
|
|
{
|
|
|
|
char othbootargs[128];
|
2014-02-07 13:06:50 +00:00
|
|
|
|
2019-04-10 12:13:16 +00:00
|
|
|
br_resetc_bmode();
|
2019-02-06 12:25:59 +00:00
|
|
|
|
2015-09-29 06:43:33 +00:00
|
|
|
/* setup othbootargs for bootvx-command (vxWorks bootline) */
|
|
|
|
snprintf(othbootargs, sizeof(othbootargs),
|
|
|
|
"u=vxWorksFTP pw=vxWorks o=0x%08x;0x%08x;0x%08x;0x%08x",
|
2019-04-10 12:13:15 +00:00
|
|
|
(u32)gd->fb_base - 0x20,
|
|
|
|
(u32)env_get_ulong("vx_memtop", 16, gd->fb_base - 0x20),
|
2017-08-03 18:22:13 +00:00
|
|
|
(u32)env_get_ulong("vx_romfsbase", 16, 0),
|
|
|
|
(u32)env_get_ulong("vx_romfssize", 16, 0));
|
2017-08-03 18:22:09 +00:00
|
|
|
env_set("othbootargs", othbootargs);
|
2014-02-07 13:06:50 +00:00
|
|
|
/*
|
|
|
|
* reset VBAR registers to its reset location, VxWorks 6.9.3.2 does
|
|
|
|
* expect that vectors are there, original u-boot moves them to _start
|
|
|
|
*/
|
|
|
|
__asm__("ldr r0,=0x20000");
|
|
|
|
__asm__("mcr p15, 0, r0, c12, c0, 0"); /* Set VBAR */
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_BOARD_LATE_INIT */
|