1
0
mirror of https://github.com/libretro/Lakka-LibreELEC.git synced 2024-11-24 10:16:18 +00:00
Lakka-LibreELEC/projects/Amlogic/patches/u-boot/u-boot-0007-WIP-boards-amlogic-add-board-files-for-wetek-gxbb-de.patch
2023-03-09 15:51:26 +00:00

104 lines
2.9 KiB
Diff

From cec8965a83baea925ac82ca0be5dac3cc1823915 Mon Sep 17 00:00:00 2001
From: Christian Hewitt <christianshewitt@gmail.com>
Date: Thu, 22 Apr 2021 05:45:29 +0000
Subject: [PATCH 07/25] WIP: boards: amlogic: add board files for wetek-gxbb
devices
These support the WeTek Hub and Play2 devices.
Signed-off-by: Christian Hewitt <christianshewitt@gmail.com>
---
board/amlogic/wetek-gxbb/MAINTAINERS | 8 +++++
board/amlogic/wetek-gxbb/Makefile | 6 ++++
board/amlogic/wetek-gxbb/wetek-gxbb.c | 50 +++++++++++++++++++++++++++
3 files changed, 64 insertions(+)
create mode 100644 board/amlogic/wetek-gxbb/MAINTAINERS
create mode 100644 board/amlogic/wetek-gxbb/Makefile
create mode 100644 board/amlogic/wetek-gxbb/wetek-gxbb.c
diff --git a/board/amlogic/wetek-gxbb/MAINTAINERS b/board/amlogic/wetek-gxbb/MAINTAINERS
new file mode 100644
index 0000000000..8aaa82ce17
--- /dev/null
+++ b/board/amlogic/wetek-gxbb/MAINTAINERS
@@ -0,0 +1,8 @@
+WETEK-GXBB
+M: Christian Hewitt <christianshewitt@gmail.com>
+S: Maintained
+L: u-boot-amlogic@groups.io
+F: board/amlogic/wetek-gxbb/
+F: configs/wetek-hub_defconfig
+F: configs/wetek-play2_defconfig
+F: doc/board/amlogic/wetek-gxbb.rst
diff --git a/board/amlogic/wetek-gxbb/Makefile b/board/amlogic/wetek-gxbb/Makefile
new file mode 100644
index 0000000000..7a5266b028
--- /dev/null
+++ b/board/amlogic/wetek-gxbb/Makefile
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# (C) Copyright 2020 BayLibre, SAS
+# Author: Neil Armstrong <narmstrong@baylibre.com>
+
+obj-y := wetek-gxbb.o
diff --git a/board/amlogic/wetek-gxbb/wetek-gxbb.c b/board/amlogic/wetek-gxbb/wetek-gxbb.c
new file mode 100644
index 0000000000..fb07eefa53
--- /dev/null
+++ b/board/amlogic/wetek-gxbb/wetek-gxbb.c
@@ -0,0 +1,50 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2016 Beniamino Galvani <b.galvani@gmail.com>
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <env.h>
+#include <init.h>
+#include <net.h>
+#include <asm/io.h>
+#include <asm/arch/gx.h>
+#include <asm/arch/sm.h>
+#include <asm/arch/eth.h>
+#include <asm/arch/mem.h>
+
+#define EFUSE_MAC_OFFSET 0
+#define EFUSE_MAC_SIZE 12
+#define MAC_ADDR_LEN 6
+
+int misc_init_r(void)
+{
+ u8 mac_addr[MAC_ADDR_LEN];
+ char efuse_mac_addr[EFUSE_MAC_SIZE], tmp[3];
+ ssize_t len;
+
+ if (!eth_env_get_enetaddr("ethaddr", mac_addr)) {
+ len = meson_sm_read_efuse(EFUSE_MAC_OFFSET,
+ efuse_mac_addr, EFUSE_MAC_SIZE);
+ if (len != EFUSE_MAC_SIZE)
+ return 0;
+
+ /* MAC is stored in ASCII format, 1bytes = 2characters */
+ for (int i = 0; i < 6; i++) {
+ tmp[0] = efuse_mac_addr[i * 2];
+ tmp[1] = efuse_mac_addr[i * 2 + 1];
+ tmp[2] = '\0';
+ mac_addr[i] = simple_strtoul(tmp, NULL, 16);
+ }
+
+ if (is_valid_ethaddr(mac_addr))
+ eth_env_set_enetaddr("ethaddr", mac_addr);
+ else
+ meson_generate_serial_ethaddr();
+
+ eth_env_get_enetaddr("ethaddr", mac_addr);
+ }
+
+ return 0;
+}
--
2.34.1