1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2013 Freescale Semiconductor, Inc.
9 #include <fdt_support.h>
15 #include <linux/compiler.h>
17 #include <asm/processor.h>
18 #include <asm/cache.h>
19 #include <asm/immap_85xx.h>
20 #include <asm/fsl_fdt.h>
21 #include <asm/fsl_law.h>
22 #include <asm/fsl_serdes.h>
23 #include <asm/fsl_liodn.h>
25 #include "../common/sleep.h"
29 DECLARE_GLOBAL_DATA_PTR;
33 struct cpu_type *cpu = gd->arch.cpu;
36 #if defined(CONFIG_TARGET_T1040D4RDB) || defined(CONFIG_TARGET_T1042D4RDB)
37 printf("Board: %sD4RDB\n", cpu->name);
39 printf("Board: %sRDB\n", cpu->name);
41 printf("Board rev: 0x%02x CPLD ver: 0x%02x, ",
42 CPLD_READ(hw_ver), CPLD_READ(sw_ver));
44 sw = CPLD_READ(flash_ctl_status);
45 sw = ((sw & CPLD_LBMAP_MASK) >> CPLD_LBMAP_SHIFT);
47 printf("vBank: %d\n", sw);
52 int board_early_init_f(void)
54 #if defined(CONFIG_DEEP_SLEEP)
56 fsl_dp_disable_console();
62 int board_early_init_r(void)
64 #ifdef CONFIG_SYS_FLASH_BASE
65 const unsigned int flashbase = CONFIG_SYS_FLASH_BASE;
66 int flash_esel = find_tlb_idx((void *)flashbase, 1);
69 * Remap Boot flash region to caching-inhibited
70 * so that flash can be erased properly.
73 /* Flush d-cache and invalidate i-cache of any FLASH data */
77 if (flash_esel == -1) {
78 /* very unlikely unless something is messed up */
79 puts("Error: Could not find TLB for FLASH BASE\n");
80 flash_esel = 2; /* give our best effort to continue */
82 /* invalidate existing TLB entry for flash */
83 disable_tlb(flash_esel);
86 set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS,
87 MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
88 0, flash_esel, BOOKE_PAGESZ_256M, 1);
95 ccsr_gur_t __iomem *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
98 srds_s1 = in_be32(&gur->rcwsr[4]) >> 24;
100 printf("SERDES Reference : 0x%X\n", srds_s1);
104 CPLD_WRITE(misc_ctl_status, CPLD_READ(misc_ctl_status) |
107 /* select SGMII and Aurora*/
109 CPLD_WRITE(misc_ctl_status, CPLD_READ(misc_ctl_status) |
110 MISC_CTL_SG_SEL | MISC_CTL_AURORA_SEL);
112 #if defined(CONFIG_TARGET_T1040D4RDB)
113 if (hwconfig("qe-tdm")) {
114 CPLD_WRITE(sfp_ctl_status, CPLD_READ(sfp_ctl_status) |
116 printf("QECSR : 0x%02x, mux to qe-tdm\n",
117 CPLD_READ(sfp_ctl_status));
119 /* Mask all CPLD interrupt sources, except QSGMII interrupts */
120 if (CPLD_READ(sw_ver) < 0x03) {
121 debug("CPLD SW version 0x%02x doesn't support int_mask\n",
124 CPLD_WRITE(int_mask, CPLD_INT_MASK_ALL &
125 ~(CPLD_INT_MASK_QSGMII1 | CPLD_INT_MASK_QSGMII2));
132 int ft_board_setup(void *blob, bd_t *bd)
137 ft_cpu_setup(blob, bd);
139 base = env_get_bootm_low();
140 size = env_get_bootm_size();
142 fdt_fixup_memory(blob, (u64)base, (u64)size);
145 pci_of_setup(blob, bd);
148 fdt_fixup_liodn(blob);
150 #ifdef CONFIG_HAS_FSL_DR_USB
151 fsl_fdt_fixup_dr_usb(blob, bd);
154 #ifdef CONFIG_SYS_DPAA_FMAN
155 fdt_fixup_fman_ethernet(blob);
158 if (hwconfig("qe-tdm"))