diff options
Diffstat (limited to 'roms/u-boot/board/Synology/common')
-rw-r--r-- | roms/u-boot/board/Synology/common/Makefile | 5 | ||||
-rw-r--r-- | roms/u-boot/board/Synology/common/legacy.c | 76 | ||||
-rw-r--r-- | roms/u-boot/board/Synology/common/legacy.h | 33 |
3 files changed, 114 insertions, 0 deletions
diff --git a/roms/u-boot/board/Synology/common/Makefile b/roms/u-boot/board/Synology/common/Makefile new file mode 100644 index 000000000..62354cc2e --- /dev/null +++ b/roms/u-boot/board/Synology/common/Makefile @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2021 Phil Sutter <phil@nwl.cc> + +obj-y += legacy.o diff --git a/roms/u-boot/board/Synology/common/legacy.c b/roms/u-boot/board/Synology/common/legacy.c new file mode 100644 index 000000000..3c89e92ae --- /dev/null +++ b/roms/u-boot/board/Synology/common/legacy.c @@ -0,0 +1,76 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2021 + * Walter Schweizer <swwa@users.sourceforge.net> + * Phil Sutter <phil@nwl.cc> + */ + +#include <config.h> +#include <vsprintf.h> +#include <env.h> +#include <net.h> +#include <asm/setup.h> + +#include "legacy.h" + +static unsigned int syno_board_id(void) +{ + switch (CONFIG_MACH_TYPE) { + case 527: + return SYNO_DS109_ID; + case 3036: + return SYNO_AXP_4BAY_2BAY; + default: + return 0; + } +} + +static unsigned int usb_port_modes(void) +{ + unsigned int i, ret = 0; + char var[32], *val; + + for (i = 0; i < USBPORT_MAX; i++) { + snprintf(var, 32, "usb%dMode", i); + val = env_get(var); + + if (!val || strcasecmp(val, "host")) + continue; + + ret |= 1 << i; + } + return ret; +} + +/* Support old kernels */ +void setup_board_tags(struct tag **in_params) +{ + struct tag_mv_uboot *t; + struct tag *params; + int i; + + debug("Synology board tags...\n"); + + params = *in_params; + t = (struct tag_mv_uboot *)¶ms->u; + + t->uboot_version = VER_NUM | syno_board_id(); + t->tclk = CONFIG_SYS_TCLK; + t->sysclk = CONFIG_SYS_TCLK * 2; + t->isusbhost = usb_port_modes(); + + for (i = 0; i < ETHADDR_MAX; i++) { + char addrvar[16], mtuvar[16]; + + sprintf(addrvar, i ? "eth%daddr" : "ethaddr", i); + sprintf(mtuvar, i ? "eth%dmtu" : "ethmtu", i); + + eth_env_get_enetaddr(addrvar, t->macaddr[i]); + t->mtu[i] = env_get_ulong(mtuvar, 10, 0); + } + + params->hdr.tag = ATAG_MV_UBOOT; + params->hdr.size = tag_size(tag_mv_uboot); + params = tag_next(params); + *in_params = params; +} diff --git a/roms/u-boot/board/Synology/common/legacy.h b/roms/u-boot/board/Synology/common/legacy.h new file mode 100644 index 000000000..0a814324d --- /dev/null +++ b/roms/u-boot/board/Synology/common/legacy.h @@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (C) 2021 + * Walter Schweizer <swwa@users.sourceforge.net> + * Phil Sutter <phil@nwl.cc> + */ + +#ifndef __SYNO_LEGACY_H +#define __SYNO_LEGACY_H + +/* Marvell uboot parameters */ +#define ATAG_MV_UBOOT 0x41000403 +#define VER_NUM 0x03040400 /* 3.4.4 */ + +#define BOARD_ID_BASE 0x0 +#define SYNO_DS109_ID (BOARD_ID_BASE + 0x15) +#define SYNO_AXP_4BAY_2BAY (0xf + 1) + +#define ETHADDR_MAX 4 +#define USBPORT_MAX 3 + +struct tag_mv_uboot { + u32 uboot_version; + u32 tclk; + u32 sysclk; + u32 isusbhost; + u8 macaddr[ETHADDR_MAX][ETH_ALEN]; + u16 mtu[ETHADDR_MAX]; + u32 fw_image_base; + u32 fw_image_size; +}; + +#endif /* __SYNO_LEGACY_H */ |