1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3 * Copyright 2022 Marek Vasut <marex@denx.de>
4 */
5
6 #include <common.h>
7 #include <asm/arch/clock.h>
8 #include <asm/io.h>
9 #include <dm.h>
10 #include <dm/device-internal.h>
11 #include <env.h>
12 #include <env_internal.h>
13 #include <malloc.h>
14 #include <net.h>
15 #include <spl.h>
16
17 #include "../common/common.h"
18
19 DECLARE_GLOBAL_DATA_PTR;
20
dmo_setup_second_mac_address(void)21 static void dmo_setup_second_mac_address(void)
22 {
23 u8 enetaddr[6];
24 int ret;
25
26 /* In case 'eth1addr' is already set in environment, do nothing. */
27 ret = eth_env_get_enetaddr_by_index("eth", 1, enetaddr);
28 if (ret) /* valid 'eth1addr' is already set */
29 return;
30
31 /* Read 'ethaddr' from environment and validate. */
32 ret = eth_env_get_enetaddr_by_index("eth", 0, enetaddr);
33 if (!ret) /* 'ethaddr' in environment is not valid, stop */
34 return;
35
36 /* Set 'eth1addr' as 'ethaddr' + 1 */
37 enetaddr[5]++;
38
39 eth_env_set_enetaddr_by_index("eth", 1, enetaddr);
40 }
41
env_get_location(enum env_operation op,int prio)42 enum env_location env_get_location(enum env_operation op, int prio)
43 {
44 /* Environment is always in eMMC boot partitions */
45 return prio ? ENVL_UNKNOWN : ENVL_MMC;
46 }
47
board_init(void)48 int board_init(void)
49 {
50 return 0;
51 }
52
board_late_init(void)53 int board_late_init(void)
54 {
55 struct udevice *dev;
56 int ret;
57
58 dmo_setup_boot_device();
59 dmo_setup_mac_address();
60 dmo_setup_second_mac_address();
61
62 ret = uclass_get_device_by_name(UCLASS_MISC, "usb-hub@2c", &dev);
63 if (ret)
64 printf("Error bringing up USB hub (%d)\n", ret);
65
66 return 0;
67 }
68