Skip to content

Commit 726c768

Browse files
Josua-SRlizthegrey
authored andcommitted
add separate platform for solidrun cex7 module
Signed-off-by: Josua Mayer <josua@solid-run.com>
1 parent 7d298be commit 726c768

6 files changed

Lines changed: 363 additions & 0 deletions

File tree

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/*
2+
* Copyright 2021 NXP
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*
6+
*/
7+
8+
#include <assert.h>
9+
#include <errno.h>
10+
#include <stdbool.h>
11+
#include <stdint.h>
12+
#include <stdio.h>
13+
#include <stdlib.h>
14+
#include <string.h>
15+
16+
#include <common/debug.h>
17+
#include <ddr.h>
18+
#include <lib/utils.h>
19+
#include <load_img.h>
20+
21+
#include "plat_common.h"
22+
#include <platform_def.h>
23+
24+
#if defined(CONFIG_STATIC_DDR) || defined(CONFIG_DDR_NODIMM)
25+
#error not implemented
26+
#endif /* defined(CONFIG_STATIC_DDR) || defined(CONFIG_DDR_NODIMM) */
27+
28+
int ddr_board_options(struct ddr_info *priv)
29+
{
30+
struct memctl_opt *popts = &priv->opt;
31+
const struct ddr_conf *conf = &priv->conf;
32+
33+
popts->vref_dimm = U(0x24); /* range 1, 83.4% */
34+
popts->rtt_override = 0U;
35+
popts->rtt_park = U(240);
36+
popts->otf_burst_chop_en = 0;
37+
popts->burst_length = U(DDR_BL8);
38+
popts->trwt_override = 1U;
39+
popts->bstopre = 0U; /* auto precharge */
40+
popts->addr_hash = 1;
41+
42+
/* Set ODT impedance on PHY side */
43+
switch (conf->cs_on_dimm[1]) {
44+
case 0xc: /* Two slots dual rank */
45+
case 0x4: /* Two slots single rank, not valid for interleaving */
46+
popts->trwt = U(0xf);
47+
popts->twrt = U(0x7);
48+
popts->trrt = U(0x7);
49+
popts->twwt = U(0x7);
50+
popts->vref_phy = U(0x6B); /* 83.6% */
51+
popts->odt = U(60);
52+
popts->phy_tx_impedance = U(28);
53+
break;
54+
case 0: /* One slot used */
55+
default:
56+
popts->trwt = U(0x3);
57+
popts->twrt = U(0x3);
58+
popts->trrt = U(0x3);
59+
popts->twwt = U(0x3);
60+
popts->vref_phy = U(0x60); /* 75% */
61+
popts->odt = U(48);
62+
popts->phy_tx_impedance = U(28);
63+
break;
64+
}
65+
66+
return 0;
67+
}
68+
69+
long long init_ddr(void)
70+
{
71+
int spd_addr[] = { 0x51, 0x52, 0x53, 0x54 };
72+
struct ddr_info info;
73+
struct sysinfo sys;
74+
long long dram_size;
75+
76+
zeromem(&sys, sizeof(sys));
77+
if (get_clocks(&sys) != 0) {
78+
ERROR("System clocks are not set\n");
79+
panic();
80+
}
81+
debug("platform clock %lu\n", sys.freq_platform);
82+
debug("DDR PLL1 %lu\n", sys.freq_ddr_pll0);
83+
debug("DDR PLL2 %lu\n", sys.freq_ddr_pll1);
84+
85+
zeromem(&info, sizeof(info));
86+
87+
/* Set two DDRC. Unused DDRC will be removed automatically. */
88+
info.num_ctlrs = NUM_OF_DDRC;
89+
info.spd_addr = spd_addr;
90+
info.ddr[0] = (void *)NXP_DDR_ADDR;
91+
info.ddr[1] = (void *)NXP_DDR2_ADDR;
92+
info.phy[0] = (void *)NXP_DDR_PHY1_ADDR;
93+
info.phy[1] = (void *)NXP_DDR_PHY2_ADDR;
94+
info.clk = get_ddr_freq(&sys, 0);
95+
info.img_loadr = load_img;
96+
info.phy_gen2_fw_img_buf = PHY_GEN2_FW_IMAGE_BUFFER;
97+
if (info.clk == 0) {
98+
info.clk = get_ddr_freq(&sys, 1);
99+
}
100+
info.dimm_on_ctlr = DDRC_NUM_DIMM;
101+
102+
info.warm_boot_flag = DDR_WRM_BOOT_NT_SUPPORTED;
103+
104+
dram_size = dram_init(&info
105+
#if defined(NXP_HAS_CCN504) || defined(NXP_HAS_CCN508)
106+
, NXP_CCN_HN_F_0_ADDR
107+
#endif
108+
);
109+
110+
111+
if (dram_size < 0) {
112+
ERROR("DDR init failed.\n");
113+
}
114+
115+
return dram_size;
116+
}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/*
2+
* Copyright 2021 NXP
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*
6+
*/
7+
8+
#ifndef PLAT_DEF_H
9+
#define PLAT_DEF_H
10+
11+
#include <arch.h>
12+
#include <cortex_a72.h>
13+
/* Required without TBBR.
14+
* To include the defines for DDR PHY
15+
* Images.
16+
*/
17+
#include <tbbr_img_def.h>
18+
19+
#include <policy.h>
20+
#include <soc.h>
21+
22+
#if defined(IMAGE_BL31)
23+
#define LS_SYS_TIMCTL_BASE 0x2890000
24+
#define PLAT_LS_NSTIMER_FRAME_ID 0
25+
#define LS_CONFIG_CNTACR 1
26+
#endif
27+
28+
#define NXP_SYSCLK_FREQ 100000000
29+
#define NXP_DDRCLK_FREQ 100000000
30+
31+
/* UART related definition */
32+
#define NXP_CONSOLE_ADDR NXP_UART_ADDR
33+
#define NXP_CONSOLE_BAUDRATE 115200
34+
35+
/* Size of cacheable stacks */
36+
#if defined(IMAGE_BL2)
37+
#if defined(TRUSTED_BOARD_BOOT)
38+
#define PLATFORM_STACK_SIZE 0x2000
39+
#else
40+
#define PLATFORM_STACK_SIZE 0x1000
41+
#endif
42+
#elif defined(IMAGE_BL31)
43+
#define PLATFORM_STACK_SIZE 0x1000
44+
#endif
45+
46+
/* SD block buffer */
47+
#define NXP_SD_BLOCK_BUF_SIZE (0x8000)
48+
#define NXP_SD_BLOCK_BUF_ADDR (NXP_OCRAM_ADDR + NXP_OCRAM_SIZE \
49+
- NXP_SD_BLOCK_BUF_SIZE)
50+
51+
#ifdef SD_BOOT
52+
#define BL2_LIMIT (NXP_OCRAM_ADDR + NXP_OCRAM_SIZE \
53+
- NXP_SD_BLOCK_BUF_SIZE)
54+
#else
55+
#define BL2_LIMIT (NXP_OCRAM_ADDR + NXP_OCRAM_SIZE)
56+
#endif
57+
58+
/* IO defines as needed by IO driver framework */
59+
#define MAX_IO_DEVICES 4
60+
#define MAX_IO_BLOCK_DEVICES 1
61+
#define MAX_IO_HANDLES 4
62+
63+
#define PHY_GEN2_FW_IMAGE_BUFFER (NXP_OCRAM_ADDR + CSF_HDR_SZ)
64+
65+
/*
66+
* FIP image defines - Offset at which FIP Image would be present
67+
* Image would include Bl31 , Bl33 and Bl32 (optional)
68+
*/
69+
#ifdef POLICY_FUSE_PROVISION
70+
#define MAX_FIP_DEVICES 3
71+
#endif
72+
73+
#ifndef MAX_FIP_DEVICES
74+
#define MAX_FIP_DEVICES 2
75+
#endif
76+
77+
/*
78+
* ID of the secure physical generic timer interrupt used by the BL32.
79+
*/
80+
#define BL32_IRQ_SEC_PHY_TIMER 29
81+
82+
#define BL31_WDOG_SEC 89
83+
84+
#define BL31_NS_WDOG_WS1 108
85+
86+
/*
87+
* Define properties of Group 1 Secure and Group 0 interrupts as per GICv3
88+
* terminology. On a GICv2 system or mode, the lists will be merged and treated
89+
* as Group 0 interrupts.
90+
*/
91+
#define PLAT_LS_G1S_IRQ_PROPS(grp) \
92+
INTR_PROP_DESC(BL32_IRQ_SEC_PHY_TIMER, GIC_HIGHEST_SEC_PRIORITY, grp, \
93+
GIC_INTR_CFG_EDGE)
94+
95+
/* SGI 15 and Secure watchdog interrupts assigned to Group 0 */
96+
#define NXP_IRQ_SEC_SGI_7 15
97+
98+
#define PLAT_LS_G0_IRQ_PROPS(grp) \
99+
INTR_PROP_DESC(BL31_WDOG_SEC, GIC_HIGHEST_SEC_PRIORITY, grp, \
100+
GIC_INTR_CFG_EDGE), \
101+
INTR_PROP_DESC(BL31_NS_WDOG_WS1, GIC_HIGHEST_SEC_PRIORITY, grp, \
102+
GIC_INTR_CFG_EDGE), \
103+
INTR_PROP_DESC(NXP_IRQ_SEC_SGI_7, GIC_HIGHEST_SEC_PRIORITY, grp, \
104+
GIC_INTR_CFG_LEVEL)
105+
#endif
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright 2021 NXP
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*
6+
*/
7+
8+
#include <plat_common.h>
9+
10+
#pragma weak board_enable_povdd
11+
#pragma weak board_disable_povdd
12+
13+
bool board_enable_povdd(void)
14+
{
15+
#ifdef CONFIG_POVDD_ENABLE
16+
return true;
17+
#else
18+
return false;
19+
#endif
20+
}
21+
22+
bool board_disable_povdd(void)
23+
{
24+
#ifdef CONFIG_POVDD_ENABLE
25+
return true;
26+
#else
27+
return false;
28+
#endif
29+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#
2+
# Copyright 2021 NXP
3+
#
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
#
6+
7+
# board-specific build parameters
8+
9+
BOOT_MODE ?= flexspi_nor
10+
BOARD ?= lx2160acex7
11+
POVDD_ENABLE := no
12+
NXP_COINED_BB := no
13+
14+
# DDR Compilation Configs
15+
NUM_OF_DDRC := 2
16+
DDRC_NUM_DIMM := 2
17+
DDRC_NUM_CS := 4
18+
DDR_ECC_EN := yes
19+
#enable address decoding feature
20+
DDR_ADDR_DEC := yes
21+
APPLY_MAX_CDD := yes
22+
23+
# S5 GPIO
24+
LX2160A_S5_GPIO_ADDR := NXP_GPIO3_ADDR
25+
LX2160A_S5_GPIO := 7
26+
27+
# I2C Bus Flushing: IIC1
28+
LX2160_FLUSH_IIC := 1,
29+
# I2C Mux Flushing: IIC1: PCA9547@77: Channel 0 (SPD EEPROM)
30+
LX2160_FLUSH_IIC_MUX := { 1, 0x77, 0x01 },
31+
32+
# DDR Errata
33+
ERRATA_DDR_A011396 := 1
34+
ERRATA_DDR_A050450 := 1
35+
36+
# On-Board Flash Details
37+
FLASH_TYPE := MT35XU512A
38+
XSPI_FLASH_SZ := 0x10000000
39+
NXP_XSPI_NOR_UNIT_SIZE := 0x20000
40+
BL2_BIN_XSPI_NOR_END_ADDRESS := 0x100000
41+
# CONFIG_FSPI_ERASE_4K is required to erase 4K sector sizes. This
42+
# config is enabled for future use cases.
43+
FSPI_ERASE_4K := 0
44+
45+
# Platform specific features.
46+
WARM_BOOT := no
47+
48+
# Adding Platform files build files
49+
BL2_SOURCES += ${BOARD_PATH}/ddr_init.c\
50+
${BOARD_PATH}/platform.c
51+
52+
SUPPORTED_BOOT_MODE := flexspi_nor \
53+
sd \
54+
emmc \
55+
auto
56+
57+
# Adding platform board build info
58+
include plat/nxp/common/plat_make_helper/plat_common_def.mk
59+
60+
# Adding SoC build info
61+
include plat/nxp/soc-lx2160a/soc.mk
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright 2021 NXP
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*
6+
*/
7+
8+
#ifndef PLATFORM_DEF_H
9+
#define PLATFORM_DEF_H
10+
11+
#include "plat_def.h"
12+
#include "plat_default_def.h"
13+
14+
#endif
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright 2021 NXP
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*
6+
*/
7+
8+
#ifndef POLICY_H
9+
#define POLICY_H
10+
11+
/* Following defines affect the PLATFORM SECURITY POLICY */
12+
13+
/* set this to 0x0 if the platform is not using/responding to ECC errors
14+
* set this to 0x1 if ECC is being used (we have to do some init)
15+
*/
16+
#define POLICY_USING_ECC 0x0
17+
18+
/* Set this to 0x0 to leave the default SMMU page size in sACR
19+
* Set this to 0x1 to change the SMMU page size to 64K
20+
*/
21+
#define POLICY_SMMU_PAGESZ_64K 0x1
22+
23+
/*
24+
* POLICY_PERF_WRIOP = 0 : No Performance enhancement for WRIOP RN-I
25+
* POLICY_PERF_WRIOP = 1 : No Performance enhancement for WRIOP RN-I = 7
26+
* POLICY_PERF_WRIOP = 2 : No Performance enhancement for WRIOP RN-I = 23
27+
*/
28+
#define POLICY_PERF_WRIOP 0
29+
30+
/*
31+
* set this to '1' if the debug clocks need to remain enabled during
32+
* system entry to low-power (LPM20) - this should only be necessary
33+
* for testing and NEVER set for normal production
34+
*/
35+
#define POLICY_DEBUG_ENABLE 0
36+
37+
38+
#endif /* POLICY_H */

0 commit comments

Comments
 (0)