1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2018 Stefan Roese <sr@denx.de>
12 #include <linux/sizes.h>
17 #ifdef CONFIG_BOOT_ROM
18 int mach_cpu_init(void)
28 gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE, SZ_256M);
33 int print_cpuinfo(void)
35 static const char * const boot_str[] = { "PLL (3-Byte SPI Addr)",
36 "PLL (4-Byte SPI Addr)",
37 "XTAL (3-Byte SPI Addr)",
38 "XTAL (4-Byte SPI Addr)" };
39 const void *blob = gd->fdt_blob;
40 void __iomem *sysc_base;
41 char buf[STR_LEN + 1];
48 /* Get system controller base address */
49 node = fdt_node_offset_by_compatible(blob, -1, "ralink,mt7620a-sysc");
51 return -FDT_ERR_NOTFOUND;
53 base = fdtdec_get_addr_size_auto_noparent(blob, node, "reg",
55 if (base == FDT_ADDR_T_NONE)
58 sysc_base = ioremap_nocache(base, size);
60 str = (char *)sysc_base + MT76XX_CHIPID_OFFS;
61 snprintf(buf, STR_LEN + 1, "%s", str);
62 val = readl(sysc_base + MT76XX_CHIP_REV_ID_OFFS);
63 printf("CPU: %-*s Rev %ld.%ld - ", STR_LEN, buf,
64 (val & GENMASK(11, 8)) >> 8, val & GENMASK(3, 0));
66 val = (readl(sysc_base + MT76XX_SYSCFG0_OFFS) & GENMASK(3, 1)) >> 1;
67 printf("Boot from %s\n", boot_str[val]);
72 int last_stage_init(void)
79 printf("Can't allocate buffer for cache cleanup copy!\n");
84 * It has been noticed, that sometimes the d-cache is not in a
85 * "clean-state" when U-Boot is running on MT7688. This was
86 * detected when using the ethernet driver (which uses d-cache)
87 * and a TFTP command does not complete. Copying an area of 64KiB
88 * in DDR at a very late bootup time in U-Boot, directly before
89 * calling into the prompt, seems to fix this issue.
91 memcpy(dst, src, SZ_64K);