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