1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2013 Freescale Semiconductor, Inc.
8 #include <asm/processor.h>
10 #include <asm/cache.h>
11 #include <asm/immap_85xx.h>
15 #include <linux/libfdt.h>
16 #include <fdt_support.h>
23 #include <asm/fsl_pci.h>
27 DECLARE_GLOBAL_DATA_PTR;
31 struct cpu_type *cpu = gd->arch.cpu;
32 struct cpld_data *cpld_data = (void *)(CONFIG_SYS_CPLD_BASE);
34 printf("Board: %sPCIe, ", cpu->name);
35 printf("CPLD Ver: 0x%02x\n", in_8(&cpld_data->cpldver));
40 int board_early_init_f(void)
42 struct fsl_ifc ifc = {(void *)CONFIG_SYS_IFC_ADDR, (void *)NULL};
44 /* Clock configuration to access CPLD using IFC(GPCM) */
45 setbits_be32(&ifc.gregs->ifc_gcr, 1 << IFC_GCR_TBCTL_TRN_TIME_SHIFT);
50 int board_early_init_r(void)
52 const unsigned long flashbase = CONFIG_SYS_FLASH_BASE;
53 int flash_esel = find_tlb_idx((void *)flashbase, 1);
56 * Remap Boot flash region to caching-inhibited
57 * so that flash can be erased properly.
60 /* Flush d-cache and invalidate i-cache of any FLASH data */
64 if (flash_esel == -1) {
65 /* very unlikely unless something is messed up */
66 puts("Error: Could not find TLB for FLASH BASE\n");
67 flash_esel = 1; /* give our best effort to continue */
69 /* invalidate existing TLB entry for flash */
70 disable_tlb(flash_esel);
73 set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS,
74 MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
75 0, flash_esel, BOOKE_PAGESZ_64M, 1);
81 void pci_init_board(void)
83 fsl_pcie_init_board(0);
85 #endif /* ifdef CONFIG_PCI */
87 int board_eth_init(bd_t *bis)
89 #ifdef CONFIG_TSEC_ENET
90 struct fsl_pq_mdio_info mdio_info;
91 struct tsec_info_struct tsec_info[2];
95 SET_STD_TSEC_INFO(tsec_info[num], 1);
99 SET_STD_TSEC_INFO(tsec_info[num], 2);
103 printf("No TSECs initialized\n");
107 /* Register 1G MDIO bus */
108 mdio_info.regs = (struct tsec_mii_mng *)CONFIG_SYS_MDIO_BASE_ADDR;
109 mdio_info.name = DEFAULT_MII_NAME;
111 fsl_pq_mdio_init(bis, &mdio_info);
113 tsec_eth_init(bis, tsec_info, num);
116 return pci_eth_init(bis);
119 #if defined(CONFIG_OF_BOARD_SETUP)
120 void fdt_del_sec(void *blob, int offset)
124 while ((nodeoff = fdt_node_offset_by_compat_reg(blob, "fsl,sec-v6.0",
125 CONFIG_SYS_CCSRBAR_PHYS + CONFIG_SYS_FSL_SEC_OFFSET
126 + offset * CONFIG_SYS_FSL_SEC_IDX_OFFSET)) >= 0) {
127 fdt_del_node(blob, nodeoff);
132 int ft_board_setup(void *blob, bd_t *bd)
136 struct cpu_type *cpu;
140 ft_cpu_setup(blob, bd);
142 base = env_get_bootm_low();
143 size = env_get_bootm_size();
145 #if defined(CONFIG_PCI)
149 fdt_fixup_memory(blob, (u64)base, (u64)size);
150 if (cpu->soc_ver == SVR_C291)
151 fdt_del_sec(blob, 1);
152 else if (cpu->soc_ver == SVR_C292)
153 fdt_del_sec(blob, 2);