1 /*
2 * (C) Copyright 2020 Rockchip Electronics Co., Ltd.
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7 #include <common.h>
8 #include <debug_uart.h>
9 #include <malloc.h>
10 #include <mmc.h>
11 #include <stdlib.h>
12
13 DECLARE_GLOBAL_DATA_PTR;
14
bootdev_rockusb_cmd(void)15 static char *bootdev_rockusb_cmd(void)
16 {
17 const char *devtype, *devnum;
18 const char *bootdev_list[] = {
19 "mmc", "0",
20 "mtd", "0",
21 "mtd", "1",
22 "mtd", "2",
23 "rknand", "0",
24 NULL, NULL,
25 };
26 char *cmd;
27 int i = 0;
28
29 devtype = bootdev_list[0];
30 devnum = bootdev_list[1];
31 while (devtype) {
32 if (!strcmp("mmc", devtype))
33 mmc_initialize(gd->bd);
34
35 if (blk_get_devnum_by_typename(devtype, atoi(devnum)))
36 break;
37
38 i += 2;
39 devtype = bootdev_list[i];
40 devnum = bootdev_list[i + 1];
41 }
42
43 if (!devtype) {
44 printf("No boot device\n");
45 return NULL;
46 }
47
48 printf("Bootdev: %s %s\n", devtype, devnum);
49
50 cmd = malloc(32);
51 if (!cmd)
52 return NULL;
53
54 snprintf(cmd, 32, "rockusb 0 %s %s", devtype, devnum);
55
56 return cmd;
57 }
58
board_init(void)59 int board_init(void)
60 {
61 return run_command(bootdev_rockusb_cmd(), 0);
62 }
63
64