]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/armltd/vexpress64/vexpress64.c
armv8/vexpress64: make multientry conditional
[karo-tx-uboot.git] / board / armltd / vexpress64 / vexpress64.c
1 /*
2  * (C) Copyright 2013
3  * David Feng <fenghua@phytium.com.cn>
4  * Sharma Bhupesh <bhupesh.sharma@freescale.com>
5  *
6  * SPDX-License-Identifier:     GPL-2.0+
7  */
8 #include <common.h>
9 #include <malloc.h>
10 #include <errno.h>
11 #include <netdev.h>
12 #include <asm/io.h>
13 #include <linux/compiler.h>
14 #include <asm/semihosting.h>
15
16 DECLARE_GLOBAL_DATA_PTR;
17
18 int board_init(void)
19 {
20         return 0;
21 }
22
23 int dram_init(void)
24 {
25         gd->ram_size = PHYS_SDRAM_1_SIZE;
26         return 0;
27 }
28
29 /*
30  * Board specific reset that is system reset.
31  */
32 void reset_cpu(ulong addr)
33 {
34 }
35
36 #ifdef CONFIG_BOARD_LATE_INIT
37 int board_late_init(void)
38 {
39 #ifdef CONFIG_SEMIHOSTING
40         /*
41          * Please refer to doc/README.semihosting for a more complete
42          * description.
43          *
44          * We require that the board include file defines these env variables:
45          * - kernel_name
46          * - kernel_addr_r
47          * - initrd_name
48          * - initrd_addr_r
49          * - fdt_name
50          * - fdt_addr_r
51          *
52          * For the "fdt chosen" startup macro, this code will then define:
53          * - initrd_end (based on initrd_addr_r plus actual initrd_size)
54          *
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.
58          */
59
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];
68
69         /* Actual addresses converted from env variables */
70         void *kernel_addr_r;
71         void *initrd_addr_r;
72         void *fdt_addr_r;
73
74         /* Actual initrd base and size */
75         unsigned long initrd_base;
76         unsigned long initrd_size;
77
78         /* Space available */
79         int avail;
80
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__);
84                 return -1;
85         }
86         if (!(kernel_name && initrd_name && fdt_name)) {
87                 printf("%s: Define {kernel/initrd/fdt}_name\n", __func__);
88                 return -1;
89         }
90
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__,
95                        initrd_name);
96                 return -1;
97         }
98
99         /* Set initrd_end */
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);
104
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);
108
109         /*
110          * The kernel must be lower in memory than fdt and loading the
111          * kernel must not trample the fdt or vice versa.
112          */
113         avail = fdt_addr_r - kernel_addr_r;
114         if (avail < 0) {
115                 printf("%s: fdt must be after kernel\n", __func__);
116                 return -1;
117         }
118         smh_load(kernel_name, kernel_addr_r, avail, 1);
119
120         /* Load fdt to memory */
121         smh_load(fdt_name, fdt_addr_r, 0x20000, 1);
122
123         /* Load initrd to memory */
124         smh_load(initrd_name, initrd_addr_r, initrd_size, 1);
125
126 #endif                          /* CONFIG_SEMIHOSTING */
127         return 0;
128 }
129 #endif                          /* CONFIG_BOARD_LATE_INIT */
130
131 /*
132  * Board specific ethernet initialization routine.
133  */
134 int board_eth_init(bd_t *bis)
135 {
136         int rc = 0;
137 #ifdef CONFIG_SMC91111
138         rc = smc91111_initialize(0, CONFIG_SMC91111_BASE);
139 #endif
140 #ifdef CONFIG_SMC911X
141         rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
142 #endif
143         return rc;
144 }