blob: 2e3aa660eaace9e77c93641ec8570dbe1b6c3447 [file] [log] [blame]
Phil Sutteref534b22021-03-07 22:22:27 +01001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2021
4 * Walter Schweizer <swwa@users.sourceforge.net>
5 * Phil Sutter <phil@nwl.cc>
6 */
7
8#include <config.h>
Raymond Mao24da8312024-05-16 14:11:52 -07009#include <stdio.h>
Phil Sutteref534b22021-03-07 22:22:27 +010010#include <vsprintf.h>
11#include <env.h>
12#include <net.h>
13#include <asm/setup.h>
14
15#include "legacy.h"
16
17static unsigned int syno_board_id(void)
18{
Tom Rinieb6aadc2021-08-30 09:16:32 -040019#ifdef CONFIG_MACH_TYPE
Phil Sutteref534b22021-03-07 22:22:27 +010020 switch (CONFIG_MACH_TYPE) {
21 case 527:
22 return SYNO_DS109_ID;
23 case 3036:
24 return SYNO_AXP_4BAY_2BAY;
Phil Sutteref534b22021-03-07 22:22:27 +010025 }
Tom Rinieb6aadc2021-08-30 09:16:32 -040026#endif
27 return 0;
Phil Sutteref534b22021-03-07 22:22:27 +010028}
29
30static unsigned int usb_port_modes(void)
31{
32 unsigned int i, ret = 0;
33 char var[32], *val;
34
35 for (i = 0; i < USBPORT_MAX; i++) {
36 snprintf(var, 32, "usb%dMode", i);
37 val = env_get(var);
38
39 if (!val || strcasecmp(val, "host"))
40 continue;
41
42 ret |= 1 << i;
43 }
44 return ret;
45}
46
47/* Support old kernels */
48void setup_board_tags(struct tag **in_params)
49{
50 struct tag_mv_uboot *t;
51 struct tag *params;
52 int i;
53
54 debug("Synology board tags...\n");
55
56 params = *in_params;
57 t = (struct tag_mv_uboot *)&params->u;
58
59 t->uboot_version = VER_NUM | syno_board_id();
Tom Rini6a5dccc2022-11-16 13:10:41 -050060 t->tclk = CFG_SYS_TCLK;
61 t->sysclk = CFG_SYS_TCLK * 2;
Phil Sutteref534b22021-03-07 22:22:27 +010062 t->isusbhost = usb_port_modes();
63
64 for (i = 0; i < ETHADDR_MAX; i++) {
65 char addrvar[16], mtuvar[16];
66
67 sprintf(addrvar, i ? "eth%daddr" : "ethaddr", i);
68 sprintf(mtuvar, i ? "eth%dmtu" : "ethmtu", i);
69
70 eth_env_get_enetaddr(addrvar, t->macaddr[i]);
71 t->mtu[i] = env_get_ulong(mtuvar, 10, 0);
72 }
73
74 params->hdr.tag = ATAG_MV_UBOOT;
75 params->hdr.size = tag_size(tag_mv_uboot);
76 params = tag_next(params);
77 *in_params = params;
78}