2 * Copyright (c) 2018, Renesas Electronics Corporation. All rights reserved.
4 * SPDX-License-Identifier: BSD-3-Clause
11 #include <platform_def.h>
13 #include <arch_helpers.h>
15 #include <common/bl_common.h>
16 #include <common/debug.h>
17 #include <common/desc_image_load.h>
18 #include <drivers/console.h>
20 #include <lib/xlat_tables/xlat_tables_defs.h>
21 #include <plat/common/platform.h>
23 #include "avs_driver.h"
24 #include "boot_init_dram.h"
25 #include "cpg_registers.h"
31 #if PMIC_ROHM_BD9571 && RCAR_SYSTEM_RESET_KEEPON_DDR
35 #include "io_common.h"
38 #include "rcar_private.h"
39 #include "rcar_version.h"
42 IMPORT_SYM(unsigned long, __RO_START__
, BL2_RO_BASE
)
43 IMPORT_SYM(unsigned long, __RO_END__
, BL2_RO_LIMIT
)
46 IMPORT_SYM(unsigned long, __COHERENT_RAM_START__
, BL2_COHERENT_RAM_BASE
)
47 IMPORT_SYM(unsigned long, __COHERENT_RAM_END__
, BL2_COHERENT_RAM_LIMIT
)
50 extern void plat_rcar_gic_driver_init(void);
51 extern void plat_rcar_gic_init(void);
52 extern void bl2_enter_bl31(const struct entry_point_info
*bl_ep_info
);
53 extern void bl2_system_cpg_init(void);
54 extern void bl2_secure_setting(void);
55 extern void bl2_cpg_init(void);
56 extern void rcar_io_emmc_setup(void);
57 extern void rcar_io_setup(void);
58 extern void rcar_swdt_release(void);
59 extern void rcar_swdt_init(void);
60 extern void rcar_rpc_init(void);
61 extern void rcar_pfc_init(void);
62 extern void rcar_dma_init(void);
64 /* R-Car Gen3 product check */
65 #if (RCAR_LSI == RCAR_H3) || (RCAR_LSI == RCAR_H3N)
66 #define TARGET_PRODUCT RCAR_PRODUCT_H3
67 #define TARGET_NAME "R-Car H3"
68 #elif RCAR_LSI == RCAR_M3
69 #define TARGET_PRODUCT RCAR_PRODUCT_M3
70 #define TARGET_NAME "R-Car M3"
71 #elif RCAR_LSI == RCAR_M3N
72 #define TARGET_PRODUCT RCAR_PRODUCT_M3N
73 #define TARGET_NAME "R-Car M3N"
74 #elif RCAR_LSI == RCAR_E3
75 #define TARGET_PRODUCT RCAR_PRODUCT_E3
76 #define TARGET_NAME "R-Car E3"
79 #if (RCAR_LSI == RCAR_E3)
80 #define GPIO_INDT (GPIO_INDT6)
81 #define GPIO_BKUP_TRG_SHIFT ((uint32_t)1U<<13U)
83 #define GPIO_INDT (GPIO_INDT1)
84 #define GPIO_BKUP_TRG_SHIFT ((uint32_t)1U<<8U)
87 CASSERT((PARAMS_BASE
+ sizeof(bl2_to_bl31_params_mem_t
) + 0x100)
88 < (RCAR_SHARED_MEM_BASE
+ RCAR_SHARED_MEM_SIZE
),
89 assert_bl31_params_do_not_fit_in_shared_memory
);
91 static meminfo_t bl2_tzram_layout
__aligned(CACHE_WRITEBACK_GRANULE
);
93 /* FDT with DRAM configuration */
94 uint64_t fdt_blob
[PAGE_SIZE_4KB
/ sizeof(uint64_t)];
95 static void *fdt
= (void *)fdt_blob
;
97 static void unsigned_num_print(unsigned long long int unum
, unsigned int radix
,
100 /* Just need enough space to store 64 bit decimal integer */
108 num_buf
[i
] = '0' + rem
;
110 num_buf
[i
] = 'a' + (rem
- 0xa);
116 *string
++ = num_buf
[i
];
119 #if (RCAR_LOSSY_ENABLE == 1)
120 typedef struct bl2_lossy_info
{
126 static void bl2_lossy_gen_fdt(uint32_t no
, uint64_t start_addr
,
127 uint64_t end_addr
, uint32_t format
,
128 uint32_t enable
, int fcnlnode
)
130 const uint64_t fcnlsize
= cpu_to_fdt64(end_addr
- start_addr
);
131 char nodename
[40] = { 0 };
134 /* Ignore undefined addresses */
135 if (start_addr
== 0 && end_addr
== 0)
138 snprintf(nodename
, sizeof(nodename
), "lossy-decompression@");
139 unsigned_num_print(start_addr
, 16, nodename
+ strlen(nodename
));
141 node
= ret
= fdt_add_subnode(fdt
, fcnlnode
, nodename
);
143 NOTICE("BL2: Cannot create FCNL node (ret=%i)\n", ret
);
147 ret
= fdt_setprop_string(fdt
, node
, "compatible",
148 "renesas,lossy-decompression");
150 NOTICE("BL2: Cannot add FCNL compat string (ret=%i)\n", ret
);
154 ret
= fdt_appendprop_string(fdt
, node
, "compatible",
157 NOTICE("BL2: Cannot append FCNL compat string (ret=%i)\n", ret
);
161 ret
= fdt_setprop_u64(fdt
, node
, "reg", start_addr
);
163 NOTICE("BL2: Cannot add FCNL reg prop (ret=%i)\n", ret
);
167 ret
= fdt_appendprop(fdt
, node
, "reg", &fcnlsize
, sizeof(fcnlsize
));
169 NOTICE("BL2: Cannot append FCNL reg size prop (ret=%i)\n", ret
);
173 ret
= fdt_setprop(fdt
, node
, "no-map", NULL
, 0);
175 NOTICE("BL2: Cannot add FCNL no-map prop (ret=%i)\n", ret
);
179 ret
= fdt_setprop_u32(fdt
, node
, "renesas,formats", format
);
181 NOTICE("BL2: Cannot add FCNL formats prop (ret=%i)\n", ret
);
186 static void bl2_lossy_setting(uint32_t no
, uint64_t start_addr
,
187 uint64_t end_addr
, uint32_t format
,
188 uint32_t enable
, int fcnlnode
)
190 bl2_lossy_info_t info
;
193 bl2_lossy_gen_fdt(no
, start_addr
, end_addr
, format
, enable
, fcnlnode
);
195 reg
= format
| (start_addr
>> 20);
196 mmio_write_32(AXI_DCMPAREACRA0
+ 0x8 * no
, reg
);
197 mmio_write_32(AXI_DCMPAREACRB0
+ 0x8 * no
, end_addr
>> 20);
198 mmio_write_32(AXI_DCMPAREACRA0
+ 0x8 * no
, reg
| enable
);
200 info
.magic
= 0x12345678U
;
201 info
.a0
= mmio_read_32(AXI_DCMPAREACRA0
+ 0x8 * no
);
202 info
.b0
= mmio_read_32(AXI_DCMPAREACRB0
+ 0x8 * no
);
204 mmio_write_32(LOSSY_PARAMS_BASE
+ sizeof(info
) * no
, info
.magic
);
205 mmio_write_32(LOSSY_PARAMS_BASE
+ sizeof(info
) * no
+ 0x4, info
.a0
);
206 mmio_write_32(LOSSY_PARAMS_BASE
+ sizeof(info
) * no
+ 0x8, info
.b0
);
208 NOTICE(" Entry %d: DCMPAREACRAx:0x%x DCMPAREACRBx:0x%x\n", no
,
209 mmio_read_32(AXI_DCMPAREACRA0
+ 0x8 * no
),
210 mmio_read_32(AXI_DCMPAREACRB0
+ 0x8 * no
));
214 void bl2_plat_flush_bl31_params(void)
216 uint32_t product_cut
, product
, cut
;
217 uint32_t boot_dev
, boot_cpu
;
218 uint32_t lcs
, reg
, val
;
220 reg
= mmio_read_32(RCAR_MODEMR
);
221 boot_dev
= reg
& MODEMR_BOOT_DEV_MASK
;
223 if (boot_dev
== MODEMR_BOOT_DEV_EMMC_25X1
||
224 boot_dev
== MODEMR_BOOT_DEV_EMMC_50X8
)
227 if ((reg
& MODEMR_BOOT_CPU_MASK
) != MODEMR_BOOT_CPU_CR7
)
228 bl2_secure_setting();
230 reg
= mmio_read_32(RCAR_PRR
);
231 product_cut
= reg
& (RCAR_PRODUCT_MASK
| RCAR_CUT_MASK
);
232 product
= reg
& RCAR_PRODUCT_MASK
;
233 cut
= reg
& RCAR_CUT_MASK
;
235 if (product
== RCAR_PRODUCT_M3
)
238 if (product
== RCAR_PRODUCT_H3
&& RCAR_CUT_VER20
> cut
)
241 /* Disable MFIS write protection */
242 mmio_write_32(MFISWPCNTR
, MFISWPCNTR_PASSWORD
| 1);
245 reg
= mmio_read_32(RCAR_MODEMR
);
246 boot_cpu
= reg
& MODEMR_BOOT_CPU_MASK
;
247 if (boot_cpu
!= MODEMR_BOOT_CPU_CA57
&&
248 boot_cpu
!= MODEMR_BOOT_CPU_CA53
)
251 if (product_cut
== RCAR_PRODUCT_H3_CUT20
) {
252 mmio_write_32(IPMMUVI0_IMSCTLR
, IMSCTLR_DISCACHE
);
253 mmio_write_32(IPMMUVI1_IMSCTLR
, IMSCTLR_DISCACHE
);
254 mmio_write_32(IPMMUPV0_IMSCTLR
, IMSCTLR_DISCACHE
);
255 mmio_write_32(IPMMUPV1_IMSCTLR
, IMSCTLR_DISCACHE
);
256 mmio_write_32(IPMMUPV2_IMSCTLR
, IMSCTLR_DISCACHE
);
257 mmio_write_32(IPMMUPV3_IMSCTLR
, IMSCTLR_DISCACHE
);
258 } else if (product_cut
== (RCAR_PRODUCT_M3N
| RCAR_CUT_VER10
) ||
259 product_cut
== (RCAR_PRODUCT_M3N
| RCAR_CUT_VER11
)) {
260 mmio_write_32(IPMMUVI0_IMSCTLR
, IMSCTLR_DISCACHE
);
261 mmio_write_32(IPMMUPV0_IMSCTLR
, IMSCTLR_DISCACHE
);
262 } else if (product_cut
== (RCAR_PRODUCT_E3
| RCAR_CUT_VER10
)) {
263 mmio_write_32(IPMMUVI0_IMSCTLR
, IMSCTLR_DISCACHE
);
264 mmio_write_32(IPMMUPV0_IMSCTLR
, IMSCTLR_DISCACHE
);
267 if (product_cut
== (RCAR_PRODUCT_H3_CUT20
) ||
268 product_cut
== (RCAR_PRODUCT_M3N
| RCAR_CUT_VER10
) ||
269 product_cut
== (RCAR_PRODUCT_M3N
| RCAR_CUT_VER11
) ||
270 product_cut
== (RCAR_PRODUCT_E3
| RCAR_CUT_VER10
)) {
271 mmio_write_32(IPMMUHC_IMSCTLR
, IMSCTLR_DISCACHE
);
272 mmio_write_32(IPMMURT_IMSCTLR
, IMSCTLR_DISCACHE
);
273 mmio_write_32(IPMMUMP_IMSCTLR
, IMSCTLR_DISCACHE
);
275 mmio_write_32(IPMMUDS0_IMSCTLR
, IMSCTLR_DISCACHE
);
276 mmio_write_32(IPMMUDS1_IMSCTLR
, IMSCTLR_DISCACHE
);
280 mmio_write_32(IPMMUMM_IMSCTLR
, IPMMUMM_IMSCTLR_ENABLE
);
281 mmio_write_32(IPMMUMM_IMAUXCTLR
, IPMMUMM_IMAUXCTLR_NMERGE40_BIT
);
283 val
= rcar_rom_get_lcs(&lcs
);
285 ERROR("BL2: Failed to get the LCS. (%d)\n", val
);
290 mmio_clrbits_32(P_ARMREG_SEC_CTRL
, P_ARMREG_SEC_CTRL_PROT
);
293 bl2_system_cpg_init();
295 #if RCAR_BL2_DCACHE == 1
296 /* Disable data cache (clean and invalidate) */
301 static uint32_t is_ddr_backup_mode(void)
303 #if RCAR_SYSTEM_SUSPEND
304 static uint32_t reason
= RCAR_COLD_BOOT
;
305 static uint32_t once
;
307 #if PMIC_ROHM_BD9571 && RCAR_SYSTEM_RESET_KEEPON_DDR
314 if ((mmio_read_32(GPIO_INDT
) & GPIO_BKUP_TRG_SHIFT
) == 0)
317 #if PMIC_ROHM_BD9571 && RCAR_SYSTEM_RESET_KEEPON_DDR
318 if (rcar_iic_dvfs_receive(PMIC
, REG_KEEP10
, &data
)) {
319 ERROR("BL2: REG Keep10 READ ERROR.\n");
323 if (KEEP10_MAGIC
!= data
)
324 reason
= RCAR_WARM_BOOT
;
326 reason
= RCAR_WARM_BOOT
;
330 return RCAR_COLD_BOOT
;
334 int bl2_plat_handle_pre_image_load(unsigned int image_id
)
336 u_register_t
*boot_kind
= (void *) BOOT_KIND_BASE
;
337 bl_mem_params_node_t
*bl_mem_params
;
339 if (image_id
!= BL31_IMAGE_ID
)
342 bl_mem_params
= get_bl_mem_params_node(image_id
);
344 if (is_ddr_backup_mode() == RCAR_COLD_BOOT
)
347 *boot_kind
= RCAR_WARM_BOOT
;
348 flush_dcache_range(BOOT_KIND_BASE
, sizeof(*boot_kind
));
351 bl2_plat_flush_bl31_params();
353 /* will not return */
354 bl2_enter_bl31(&bl_mem_params
->ep_info
);
357 *boot_kind
= RCAR_COLD_BOOT
;
358 flush_dcache_range(BOOT_KIND_BASE
, sizeof(*boot_kind
));
363 int bl2_plat_handle_post_image_load(unsigned int image_id
)
365 static bl2_to_bl31_params_mem_t
*params
;
366 bl_mem_params_node_t
*bl_mem_params
;
369 params
= (bl2_to_bl31_params_mem_t
*) PARAMS_BASE
;
370 memset((void *)PARAMS_BASE
, 0, sizeof(*params
));
373 bl_mem_params
= get_bl_mem_params_node(image_id
);
379 memcpy(¶ms
->bl32_ep_info
, &bl_mem_params
->ep_info
,
380 sizeof(entry_point_info_t
));
383 memcpy(¶ms
->bl33_ep_info
, &bl_mem_params
->ep_info
,
384 sizeof(entry_point_info_t
));
391 meminfo_t
*bl2_plat_sec_mem_layout(void)
393 return &bl2_tzram_layout
;
396 static void bl2_populate_compatible_string(void *fdt
)
403 /* Populate compatible string */
404 rcar_get_board_type(&board_type
, &board_rev
);
405 switch (board_type
) {
406 case BOARD_SALVATOR_X
:
407 ret
= fdt_setprop_string(fdt
, 0, "compatible",
408 "renesas,salvator-x");
410 case BOARD_SALVATOR_XS
:
411 ret
= fdt_setprop_string(fdt
, 0, "compatible",
412 "renesas,salvator-xs");
414 case BOARD_STARTER_KIT
:
415 ret
= fdt_setprop_string(fdt
, 0, "compatible",
418 case BOARD_STARTER_KIT_PRE
:
419 ret
= fdt_setprop_string(fdt
, 0, "compatible",
424 ret
= fdt_setprop_string(fdt
, 0, "compatible",
428 NOTICE("BL2: Cannot set compatible string, board unsupported\n");
433 NOTICE("BL2: Cannot set compatible string (ret=%i)\n", ret
);
437 reg
= mmio_read_32(RCAR_PRR
);
438 switch (reg
& RCAR_PRODUCT_MASK
) {
439 case RCAR_PRODUCT_H3
:
440 ret
= fdt_appendprop_string(fdt
, 0, "compatible",
443 case RCAR_PRODUCT_M3
:
444 ret
= fdt_appendprop_string(fdt
, 0, "compatible",
447 case RCAR_PRODUCT_M3N
:
448 ret
= fdt_appendprop_string(fdt
, 0, "compatible",
451 case RCAR_PRODUCT_E3
:
452 ret
= fdt_appendprop_string(fdt
, 0, "compatible",
456 NOTICE("BL2: Cannot set compatible string, SoC unsupported\n");
461 NOTICE("BL2: Cannot set compatible string (ret=%i)\n", ret
);
466 static void bl2_advertise_dram_entries(uint64_t dram_config
[8])
468 char nodename
[32] = { 0 };
469 uint64_t start
, size
;
473 for (chan
= 0; chan
< 4; chan
++) {
474 start
= dram_config
[2 * chan
];
475 size
= dram_config
[2 * chan
+ 1];
479 NOTICE("BL2: CH%d: %llx - %llx, %lld GiB\n",
480 chan
, start
, start
+ size
- 1, size
>> 30);
484 * We add the DT nodes in reverse order here. The fdt_add_subnode()
485 * adds the DT node before the first existing DT node, so we have
486 * to add them in reverse order to get nodes sorted by address in
489 for (chan
= 3; chan
>= 0; chan
--) {
490 start
= dram_config
[2 * chan
];
491 size
= dram_config
[2 * chan
+ 1];
496 * Channel 0 is mapped in 32bit space and the first
497 * 128 MiB are reserved
504 fdtsize
= cpu_to_fdt64(size
);
506 snprintf(nodename
, sizeof(nodename
), "memory@");
507 unsigned_num_print(start
, 16, nodename
+ strlen(nodename
));
508 node
= ret
= fdt_add_subnode(fdt
, 0, nodename
);
512 ret
= fdt_setprop_string(fdt
, node
, "device_type", "memory");
516 ret
= fdt_setprop_u64(fdt
, node
, "reg", start
);
520 ret
= fdt_appendprop(fdt
, node
, "reg", &fdtsize
,
528 NOTICE("BL2: Cannot add memory node to FDT (ret=%i)\n", ret
);
532 static void bl2_advertise_dram_size(uint32_t product
)
534 uint64_t dram_config
[8] = {
535 [0] = 0x400000000ULL
,
536 [2] = 0x500000000ULL
,
537 [4] = 0x600000000ULL
,
538 [6] = 0x700000000ULL
,
542 case RCAR_PRODUCT_H3
:
543 #if (RCAR_DRAM_LPDDR4_MEMCONF == 0)
545 dram_config
[1] = 0x40000000ULL
;
546 dram_config
[3] = 0x40000000ULL
;
547 dram_config
[5] = 0x40000000ULL
;
548 dram_config
[7] = 0x40000000ULL
;
549 #elif (RCAR_DRAM_LPDDR4_MEMCONF == 1) && \
550 (RCAR_DRAM_CHANNEL == 5) && \
551 (RCAR_DRAM_SPLIT == 2)
552 /* 4GB(2GBx2 2ch split) */
553 dram_config
[1] = 0x80000000ULL
;
554 dram_config
[3] = 0x80000000ULL
;
555 #elif (RCAR_DRAM_LPDDR4_MEMCONF == 1) && (RCAR_DRAM_CHANNEL == 15)
556 /* 8GB(2GBx4: default) */
557 dram_config
[1] = 0x80000000ULL
;
558 dram_config
[3] = 0x80000000ULL
;
559 dram_config
[5] = 0x80000000ULL
;
560 dram_config
[7] = 0x80000000ULL
;
561 #endif /* RCAR_DRAM_LPDDR4_MEMCONF == 0 */
564 case RCAR_PRODUCT_M3
:
565 /* 4GB(2GBx2 2ch split) */
566 dram_config
[1] = 0x80000000ULL
;
567 dram_config
[5] = 0x80000000ULL
;
570 case RCAR_PRODUCT_M3N
:
572 dram_config
[1] = 0x80000000ULL
;
575 case RCAR_PRODUCT_E3
:
576 #if (RCAR_DRAM_DDR3L_MEMCONF == 0)
578 dram_config
[1] = 0x40000000ULL
;
579 #elif (RCAR_DRAM_DDR3L_MEMCONF == 1)
581 dram_config
[1] = 0x80000000ULL
;
582 #elif (RCAR_DRAM_DDR3L_MEMCONF == 2)
584 dram_config
[1] = 0x100000000ULL
;
585 #endif /* RCAR_DRAM_DDR3L_MEMCONF == 0 */
589 bl2_advertise_dram_entries(dram_config
);
592 void bl2_el3_early_platform_setup(u_register_t arg1
, u_register_t arg2
,
593 u_register_t arg3
, u_register_t arg4
)
595 uint32_t reg
, midr
, lcs
, boot_dev
, boot_cpu
, sscg
, type
, rev
;
596 uint32_t product
, product_cut
, major
, minor
;
599 const char *unknown
= "unknown";
600 const char *cpu_ca57
= "CA57";
601 const char *cpu_ca53
= "CA53";
602 const char *product_m3n
= "M3N";
603 const char *product_h3
= "H3";
604 const char *product_m3
= "M3";
605 const char *product_e3
= "E3";
606 const char *lcs_secure
= "SE";
607 const char *lcs_cm
= "CM";
608 const char *lcs_dm
= "DM";
609 const char *lcs_sd
= "SD";
610 const char *lcs_fa
= "FA";
611 const char *sscg_off
= "PLL1 nonSSCG Clock select";
612 const char *sscg_on
= "PLL1 SSCG Clock select";
613 const char *boot_hyper80
= "HyperFlash(80MHz)";
614 const char *boot_qspi40
= "QSPI Flash(40MHz)";
615 const char *boot_qspi80
= "QSPI Flash(80MHz)";
616 const char *boot_emmc25x1
= "eMMC(25MHz x1)";
617 const char *boot_emmc50x8
= "eMMC(50MHz x8)";
618 #if RCAR_LSI == RCAR_E3
619 const char *boot_hyper160
= "HyperFlash(150MHz)";
621 const char *boot_hyper160
= "HyperFlash(160MHz)";
623 #if (RCAR_LOSSY_ENABLE == 1)
627 reg
= mmio_read_32(RCAR_MODEMR
);
628 boot_dev
= reg
& MODEMR_BOOT_DEV_MASK
;
629 boot_cpu
= reg
& MODEMR_BOOT_CPU_MASK
;
633 if (boot_cpu
== MODEMR_BOOT_CPU_CA57
||
634 boot_cpu
== MODEMR_BOOT_CPU_CA53
) {
636 /* console configuration (platform specific) done in driver */
637 console_init(0, 0, 0);
640 plat_rcar_gic_driver_init();
641 plat_rcar_gic_init();
644 /* FIQ interrupts are taken to EL3 */
645 write_scr_el3(read_scr_el3() | SCR_FIQ_BIT
);
647 write_daifclr(DAIF_FIQ_BIT
);
650 midr
= reg
& (MIDR_PN_MASK
<< MIDR_PN_SHIFT
);
663 NOTICE("BL2: R-Car Gen3 Initial Program Loader(%s) Rev.%s\n", str
,
666 reg
= mmio_read_32(RCAR_PRR
);
667 product_cut
= reg
& (RCAR_PRODUCT_MASK
| RCAR_CUT_MASK
);
668 product
= reg
& RCAR_PRODUCT_MASK
;
671 case RCAR_PRODUCT_H3
:
674 case RCAR_PRODUCT_M3
:
677 case RCAR_PRODUCT_M3N
:
680 case RCAR_PRODUCT_E3
:
688 if (RCAR_PRODUCT_M3_CUT11
== product_cut
) {
689 NOTICE("BL2: PRR is R-Car %s Ver.1.1 / Ver.1.2\n", str
);
691 major
= (reg
& RCAR_MAJOR_MASK
) >> RCAR_MAJOR_SHIFT
;
692 major
= major
+ RCAR_MAJOR_OFFSET
;
693 minor
= reg
& RCAR_MINOR_MASK
;
694 NOTICE("BL2: PRR is R-Car %s Ver.%d.%d\n", str
, major
, minor
);
697 if (product
== RCAR_PRODUCT_E3
) {
698 reg
= mmio_read_32(RCAR_MODEMR
);
699 sscg
= reg
& RCAR_SSCG_MASK
;
700 str
= sscg
== RCAR_SSCG_ENABLE
? sscg_on
: sscg_off
;
701 NOTICE("BL2: %s\n", str
);
704 rcar_get_board_type(&type
, &rev
);
707 case BOARD_SALVATOR_X
:
709 case BOARD_STARTER_KIT
:
710 case BOARD_SALVATOR_XS
:
712 case BOARD_STARTER_KIT_PRE
:
716 type
= BOARD_UNKNOWN
;
720 if (type
== BOARD_UNKNOWN
|| rev
== BOARD_REV_UNKNOWN
)
721 NOTICE("BL2: Board is %s Rev.---\n", GET_BOARD_NAME(type
));
723 NOTICE("BL2: Board is %s Rev.%d.%d\n",
724 GET_BOARD_NAME(type
),
725 GET_BOARD_MAJOR(rev
), GET_BOARD_MINOR(rev
));
728 #if RCAR_LSI != RCAR_AUTO
729 if (product
!= TARGET_PRODUCT
) {
730 ERROR("BL2: IPL was been built for the %s.\n", TARGET_NAME
);
731 ERROR("BL2: Please write the correct IPL to flash memory.\n");
739 case MODEMR_BOOT_DEV_HYPERFLASH160
:
742 case MODEMR_BOOT_DEV_HYPERFLASH80
:
745 case MODEMR_BOOT_DEV_QSPI_FLASH40
:
748 case MODEMR_BOOT_DEV_QSPI_FLASH80
:
751 case MODEMR_BOOT_DEV_EMMC_25X1
:
754 case MODEMR_BOOT_DEV_EMMC_50X8
:
761 NOTICE("BL2: Boot device is %s\n", str
);
764 reg
= rcar_rom_get_lcs(&lcs
);
792 NOTICE("BL2: LCM state is %s\n", str
);
795 is_ddr_backup_mode();
797 bl2_tzram_layout
.total_base
= BL31_BASE
;
798 bl2_tzram_layout
.total_size
= BL31_LIMIT
- BL31_BASE
;
800 if (boot_cpu
== MODEMR_BOOT_CPU_CA57
||
801 boot_cpu
== MODEMR_BOOT_CPU_CA53
) {
802 ret
= rcar_dram_init();
804 NOTICE("BL2: Failed to DRAM initialize (%d).\n", ret
);
811 ret
= fdt_create_empty_tree(fdt
, sizeof(fdt_blob
));
813 NOTICE("BL2: Cannot allocate FDT for U-Boot (ret=%i)\n", ret
);
817 /* Add platform compatible string */
818 bl2_populate_compatible_string(fdt
);
820 /* Print DRAM layout */
821 bl2_advertise_dram_size(product
);
823 if (boot_dev
== MODEMR_BOOT_DEV_EMMC_25X1
||
824 boot_dev
== MODEMR_BOOT_DEV_EMMC_50X8
) {
825 if (rcar_emmc_init() != EMMC_SUCCESS
) {
826 NOTICE("BL2: Failed to eMMC driver initialize.\n");
829 rcar_emmc_memcard_power(EMMC_POWER_ON
);
830 if (rcar_emmc_mount() != EMMC_SUCCESS
) {
831 NOTICE("BL2: Failed to eMMC mount operation.\n");
839 reg
= mmio_read_32(RST_WDTRSTCR
);
840 reg
&= ~WDTRSTCR_RWDT_RSTMSK
;
841 reg
|= WDTRSTCR_PASSWORD
;
842 mmio_write_32(RST_WDTRSTCR
, reg
);
844 mmio_write_32(CPG_CPGWPR
, CPGWPR_PASSWORD
);
845 mmio_write_32(CPG_CPGWPCR
, CPGWPCR_PASSWORD
);
847 reg
= mmio_read_32(RCAR_PRR
);
848 if ((reg
& RCAR_CPU_MASK_CA57
) == RCAR_CPU_HAVE_CA57
)
849 mmio_write_32(CPG_CA57DBGRCR
,
850 DBGCPUPREN
| mmio_read_32(CPG_CA57DBGRCR
));
852 if ((reg
& RCAR_CPU_MASK_CA53
) == RCAR_CPU_HAVE_CA53
)
853 mmio_write_32(CPG_CA53DBGRCR
,
854 DBGCPUPREN
| mmio_read_32(CPG_CA53DBGRCR
));
856 if (product_cut
== RCAR_PRODUCT_H3_CUT10
) {
857 reg
= mmio_read_32(CPG_PLL2CR
);
858 reg
&= ~((uint32_t) 1 << 5);
859 mmio_write_32(CPG_PLL2CR
, reg
);
861 reg
= mmio_read_32(CPG_PLL4CR
);
862 reg
&= ~((uint32_t) 1 << 5);
863 mmio_write_32(CPG_PLL4CR
, reg
);
865 reg
= mmio_read_32(CPG_PLL0CR
);
866 reg
&= ~((uint32_t) 1 << 12);
867 mmio_write_32(CPG_PLL0CR
, reg
);
869 #if (RCAR_LOSSY_ENABLE == 1)
870 NOTICE("BL2: Lossy Decomp areas\n");
872 fcnlnode
= fdt_add_subnode(fdt
, 0, "reserved-memory");
874 NOTICE("BL2: Cannot create reserved mem node (ret=%i)\n",
879 bl2_lossy_setting(0, LOSSY_ST_ADDR0
, LOSSY_END_ADDR0
,
880 LOSSY_FMT0
, LOSSY_ENA_DIS0
, fcnlnode
);
881 bl2_lossy_setting(1, LOSSY_ST_ADDR1
, LOSSY_END_ADDR1
,
882 LOSSY_FMT1
, LOSSY_ENA_DIS1
, fcnlnode
);
883 bl2_lossy_setting(2, LOSSY_ST_ADDR2
, LOSSY_END_ADDR2
,
884 LOSSY_FMT2
, LOSSY_ENA_DIS2
, fcnlnode
);
888 NOTICE("BL2: FDT at %p\n", fdt
);
890 if (boot_dev
== MODEMR_BOOT_DEV_EMMC_25X1
||
891 boot_dev
== MODEMR_BOOT_DEV_EMMC_50X8
)
892 rcar_io_emmc_setup();
897 void bl2_el3_plat_arch_setup(void)
899 #if RCAR_BL2_DCACHE == 1
900 NOTICE("BL2: D-Cache enable\n");
901 rcar_configure_mmu_el3(BL2_BASE
,
902 RCAR_SYSRAM_LIMIT
- BL2_BASE
,
903 BL2_RO_BASE
, BL2_RO_LIMIT
905 , BL2_COHERENT_RAM_BASE
, BL2_COHERENT_RAM_LIMIT
911 void bl2_platform_setup(void)