1 // SPDX-License-Identifier: GPL-2.0+
5 * Board functions for B&R BRSMARC1 Board
7 * Copyright (C) 2017 Hannes Schmelzer <oe5hpm@oevsv.at>
8 * B&R Industrial Automation GmbH - http://www.br-automation.com
14 #include <asm/arch/cpu.h>
15 #include <asm/arch/hardware.h>
16 #include <asm/arch/omap.h>
17 #include <asm/arch/ddr_defs.h>
18 #include <asm/arch/clock.h>
19 #include <asm/arch/sys_proto.h>
20 #include <asm/arch/mem.h>
24 #include <power/tps65217.h>
25 #include "../common/bur_common.h"
26 #include "../common/br_resetc.h"
28 /* -------------------------------------------------------------------------*/
29 /* -- defines for used GPIO Hardware -- */
30 #define PER_RESET (2 * 32 + 0)
32 DECLARE_GLOBAL_DATA_PTR;
34 #if defined(CONFIG_SPL_BUILD)
35 static const struct ddr_data ddr3_data = {
36 .datardsratio0 = MT41K256M16HA125E_RD_DQS,
37 .datawdsratio0 = MT41K256M16HA125E_WR_DQS,
38 .datafwsratio0 = MT41K256M16HA125E_PHY_FIFO_WE,
39 .datawrsratio0 = MT41K256M16HA125E_PHY_WR_DATA,
42 static const struct cmd_control ddr3_cmd_ctrl_data = {
43 .cmd0csratio = MT41K256M16HA125E_RATIO,
44 .cmd0iclkout = MT41K256M16HA125E_INVERT_CLKOUT,
46 .cmd1csratio = MT41K256M16HA125E_RATIO,
47 .cmd1iclkout = MT41K256M16HA125E_INVERT_CLKOUT,
49 .cmd2csratio = MT41K256M16HA125E_RATIO,
50 .cmd2iclkout = MT41K256M16HA125E_INVERT_CLKOUT,
53 static struct emif_regs ddr3_emif_reg_data = {
54 .sdram_config = MT41K256M16HA125E_EMIF_SDCFG,
55 .ref_ctrl = MT41K256M16HA125E_EMIF_SDREF,
56 .sdram_tim1 = MT41K256M16HA125E_EMIF_TIM1,
57 .sdram_tim2 = MT41K256M16HA125E_EMIF_TIM2,
58 .sdram_tim3 = MT41K256M16HA125E_EMIF_TIM3,
59 .zq_config = MT41K256M16HA125E_ZQ_CFG,
60 .emif_ddr_phy_ctlr_1 = MT41K256M16HA125E_EMIF_READ_LATENCY,
63 static const struct ctrl_ioregs ddr3_ioregs = {
64 .cm0ioctl = MT41K256M16HA125E_IOCTRL_VALUE,
65 .cm1ioctl = MT41K256M16HA125E_IOCTRL_VALUE,
66 .cm2ioctl = MT41K256M16HA125E_IOCTRL_VALUE,
67 .dt0ioctl = MT41K256M16HA125E_IOCTRL_VALUE,
68 .dt1ioctl = MT41K256M16HA125E_IOCTRL_VALUE,
71 #define OSC (V_OSCK / 1000000)
72 const struct dpll_params dpll_ddr3 = { 400, OSC - 1, 1, -1, -1, -1, -1};
74 void am33xx_spl_board_init(void)
76 struct cm_perpll *const cmper = (struct cm_perpll *)CM_PER;
77 struct cm_wkuppll *const cmwkup = (struct cm_wkuppll *)CM_WKUP;
81 * enable additional clocks of modules which are accessed later from
84 u32 *const clk_domains[] = { 0 };
85 u32 *const clk_modules_specific[] = {
86 &cmwkup->wkup_adctscctrl,
90 &cmper->timer4clkctrl,
91 &cmper->timer5clkctrl,
93 &cmper->lcdcclkstctrl,
96 do_enable_clocks(clk_domains, clk_modules_specific, 1);
101 /* peripheral reset */
102 rc = gpio_request(PER_RESET, "PER_RESET");
104 printf("cannot request PER_RESET GPIO!\n");
106 rc = gpio_direction_output(PER_RESET, 0);
108 printf("cannot set PER_RESET GPIO!\n");
114 const struct dpll_params *get_dpll_ddr_params(void)
119 void sdram_init(void)
121 config_ddr(400, &ddr3_ioregs,
124 &ddr3_emif_reg_data, 0);
126 #endif /* CONFIG_SPL_BUILD */
127 #if !defined(CONFIG_SPL_BUILD)
129 /* decision if backlight is switched on or not on powerup */
130 int board_backlightstate(void)
132 u8 bklmask, rstcause;
135 rc |= br_resetc_regget(RSTCTRL_SCRATCHREG1, &bklmask);
136 rc |= br_resetc_regget(RSTCTRL_ERSTCAUSE, &rstcause);
139 printf("%s: read rstctrl failed!\n", __func__);
143 if ((rstcause & bklmask) != 0)
149 /* Basic board specific setup. run quite after relocation */
152 if (power_tps65217_init(0))
153 printf("WARN: cannot setup PMIC 0x24 @ bus #0, not found!.\n");
158 #if defined(CONFIG_BOARD_LATE_INIT)
160 int board_late_init(void)
167 #endif /* CONFIG_BOARD_LATE_INIT */
168 #endif /* !CONFIG_SPL_BUILD */