3 * David Feng <fenghua@phytium.com.cn>
4 * Sharma Bhupesh <bhupesh.sharma@freescale.com>
6 * SPDX-License-Identifier: GPL-2.0+
13 #include <linux/compiler.h>
14 #include <asm/semihosting.h>
16 DECLARE_GLOBAL_DATA_PTR;
25 gd->ram_size = PHYS_SDRAM_1_SIZE;
30 * Board specific reset that is system reset.
32 void reset_cpu(ulong addr)
36 #ifdef CONFIG_BOARD_LATE_INIT
37 int board_late_init(void)
39 #ifdef CONFIG_SEMIHOSTING
41 * Please refer to doc/README.semihosting for a more complete
44 * We require that the board include file defines these env variables:
52 * For the "fdt chosen" startup macro, this code will then define:
53 * - initrd_end (based on initrd_addr_r plus actual initrd_size)
55 * We will then load the kernel, initrd, and fdt into the specified
56 * locations in memory in a similar way that the ATF fastmodel code
57 * uses semihosting calls to load other boot stages and u-boot itself.
60 /* Env variable strings */
61 char *kernel_name = getenv("kernel_name");
62 char *kernel_addr_str = getenv("kernel_addr_r");
63 char *initrd_name = getenv("initrd_name");
64 char *initrd_addr_str = getenv("initrd_addr_r");
65 char *fdt_name = getenv("fdt_name");
66 char *fdt_addr_str = getenv("fdt_addr_r");
67 char initrd_end_str[64];
69 /* Actual addresses converted from env variables */
74 /* Actual initrd base and size */
75 unsigned long initrd_base;
76 unsigned long initrd_size;
81 /* Make sure the environment variables needed are set */
82 if (!(kernel_addr_str && initrd_addr_str && fdt_addr_str)) {
83 printf("%s: Define {kernel/initrd/fdt}_addr_r\n", __func__);
86 if (!(kernel_name && initrd_name && fdt_name)) {
87 printf("%s: Define {kernel/initrd/fdt}_name\n", __func__);
91 /* Get exact initrd_size */
92 initrd_size = smh_len(initrd_name);
93 if (initrd_size == -1) {
94 printf("%s: Can't get file size for \'%s\'\n", __func__,
100 initrd_base = simple_strtoul(initrd_addr_str, NULL, 16);
101 initrd_addr_r = (void *)initrd_base;
102 sprintf(initrd_end_str, "0x%lx", initrd_base + initrd_size - 1);
103 setenv("initrd_end", initrd_end_str);
105 /* Load kernel to memory */
106 fdt_addr_r = (void *)simple_strtoul(fdt_addr_str, NULL, 16);
107 kernel_addr_r = (void *)simple_strtoul(kernel_addr_str, NULL, 16);
110 * The kernel must be lower in memory than fdt and loading the
111 * kernel must not trample the fdt or vice versa.
113 avail = fdt_addr_r - kernel_addr_r;
115 printf("%s: fdt must be after kernel\n", __func__);
118 smh_load(kernel_name, kernel_addr_r, avail, 1);
120 /* Load fdt to memory */
121 smh_load(fdt_name, fdt_addr_r, 0x20000, 1);
123 /* Load initrd to memory */
124 smh_load(initrd_name, initrd_addr_r, initrd_size, 1);
126 #endif /* CONFIG_SEMIHOSTING */
129 #endif /* CONFIG_BOARD_LATE_INIT */
132 * Board specific ethernet initialization routine.
134 int board_eth_init(bd_t *bis)
137 #ifdef CONFIG_SMC91111
138 rc = smc91111_initialize(0, CONFIG_SMC91111_BASE);
140 #ifdef CONFIG_SMC911X
141 rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);