JetHub: Update JetHub D2 uboot to 2025.04
Signed-off-by: Viacheslav Bocharov <adeep@lexina.in>
This commit is contained in:
parent
b24a33b917
commit
43a786c327
@ -31,8 +31,8 @@ elif [[ "$BOARD" == "jethubj200" ]]; then
|
||||
ASOUND_STATE="${ASOUND_STATE:-"asound.state.meson64"}"
|
||||
CPUMIN=667000
|
||||
CPUMAX=2100000
|
||||
BOOTBRANCH="tag:v2024.07"
|
||||
BOOTPATCHDIR="v2024.07"
|
||||
BOOTBRANCH="tag:v2025.04"
|
||||
BOOTPATCHDIR="v2025.04"
|
||||
fi
|
||||
|
||||
# JetHub builds userspace tooling with c++ (gpp) toolchain in buildjethomecmds() below.
|
||||
|
||||
@ -6,22 +6,22 @@ Subject: Add JetHub D2
|
||||
---
|
||||
arch/arm/dts/Makefile | 3 +-
|
||||
arch/arm/dts/meson-sm1-jethome-jethub-j200-u-boot.dtsi | 13 +
|
||||
arch/arm/dts/meson-sm1-jethome-jethub-j200.dts | 654 ++++++++++
|
||||
arch/arm/dts/meson-sm1-jethome-jethub-j200.dts | 711 ++++++++++
|
||||
board/amlogic/jethub-j200/MAINTAINERS | 8 +
|
||||
board/amlogic/jethub-j200/Makefile | 6 +
|
||||
board/amlogic/jethub-j200/jethub-j200.c | 89 ++
|
||||
configs/jethub_j200_defconfig | 119 ++
|
||||
configs/jethub_j200_defconfig | 120 ++
|
||||
doc/board/amlogic/index.rst | 1 +
|
||||
doc/board/amlogic/jethub-j200.rst | 50 +
|
||||
drivers/power/regulator/regulator-uclass.c | 2 +-
|
||||
include/configs/jethub.h | 9 +
|
||||
11 files changed, 952 insertions(+), 2 deletions(-)
|
||||
11 files changed, 1010 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
|
||||
index 111111111111..222222222222 100644
|
||||
--- a/arch/arm/dts/Makefile
|
||||
+++ b/arch/arm/dts/Makefile
|
||||
@@ -100,7 +100,8 @@ dtb-$(CONFIG_ARCH_S5P4418) += \
|
||||
@@ -78,7 +78,8 @@ dtb-$(CONFIG_ARCH_S5P4418) += \
|
||||
s5p4418-nanopi2.dtb
|
||||
|
||||
dtb-$(CONFIG_ARCH_MESON) += \
|
||||
@ -29,8 +29,8 @@ index 111111111111..222222222222 100644
|
||||
+ meson-a1-ad401.dtb \
|
||||
+ meson-sm1-jethome-jethub-j200.dtb
|
||||
|
||||
dtb-$(CONFIG_ARCH_TEGRA) += tegra20-harmony.dtb \
|
||||
tegra20-medcom-wide.dtb \
|
||||
dtb-$(CONFIG_ARCH_TEGRA) += \
|
||||
tegra20-acer-a500-picasso.dtb \
|
||||
diff --git a/arch/arm/dts/meson-sm1-jethome-jethub-j200-u-boot.dtsi b/arch/arm/dts/meson-sm1-jethome-jethub-j200-u-boot.dtsi
|
||||
new file mode 100644
|
||||
index 000000000000..111111111111
|
||||
@ -55,7 +55,7 @@ new file mode 100644
|
||||
index 000000000000..111111111111
|
||||
--- /dev/null
|
||||
+++ b/arch/arm/dts/meson-sm1-jethome-jethub-j200.dts
|
||||
@@ -0,0 +1,654 @@
|
||||
@@ -0,0 +1,711 @@
|
||||
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
|
||||
+/*
|
||||
+ * Copyright (c) 2024 JetHome
|
||||
@ -710,6 +710,63 @@ index 000000000000..111111111111
|
||||
+ reg = <0x32 0x20>;
|
||||
+ };
|
||||
+};
|
||||
+
|
||||
+&cpu_thermal {
|
||||
+ trips {
|
||||
+ cpu_passive: cpu-passive {
|
||||
+ temperature = <70000>; /* millicelsius */
|
||||
+ hysteresis = <2000>; /* millicelsius */
|
||||
+ type = "passive"; /* */
|
||||
+ };
|
||||
+
|
||||
+ cpu_hot: cpu-hot {
|
||||
+ temperature = <85000>; /* millicelsius */
|
||||
+ hysteresis = <2000>; /* millicelsius */
|
||||
+ type = "hot";
|
||||
+ };
|
||||
+
|
||||
+ cpu_critical: cpu-critical {
|
||||
+ temperature = <90000>; /* millicelsius */
|
||||
+ hysteresis = <2000>; /* millicelsius */
|
||||
+ type = "critical";
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ cooling-maps {
|
||||
+ map0 {
|
||||
+ trip = <&cpu_passive>;
|
||||
+ cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
|
||||
+ <&cpu1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
|
||||
+ <&cpu2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
|
||||
+ <&cpu3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
|
||||
+ };
|
||||
+
|
||||
+ map1 {
|
||||
+ trip = <&cpu_hot>;
|
||||
+ cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
|
||||
+ <&cpu1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
|
||||
+ <&cpu2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
|
||||
+ <&cpu3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
|
||||
+ };
|
||||
+ };
|
||||
+};
|
||||
+
|
||||
+&ddr_thermal {
|
||||
+ trips {
|
||||
+ ddr_passive: ddr-passive {
|
||||
+ temperature = <70000>; /* millicelsius */
|
||||
+ hysteresis = <2000>; /* millicelsius */
|
||||
+ type = "passive";
|
||||
+ };
|
||||
+
|
||||
+ ddr_critical: ddr-critical {
|
||||
+ temperature = <85000>; /* millicelsius */
|
||||
+ hysteresis = <2000>; /* millicelsius */
|
||||
+ type = "critical";
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+};
|
||||
diff --git a/board/amlogic/jethub-j200/MAINTAINERS b/board/amlogic/jethub-j200/MAINTAINERS
|
||||
new file mode 100644
|
||||
index 000000000000..111111111111
|
||||
@ -749,7 +806,7 @@ index 000000000000..111111111111
|
||||
+ *
|
||||
+ */
|
||||
+
|
||||
+#include <common.h>
|
||||
+//#include <common.h>
|
||||
+#include <dm.h>
|
||||
+#include <adc.h>
|
||||
+#include <env.h>
|
||||
@ -836,7 +893,7 @@ new file mode 100644
|
||||
index 000000000000..111111111111
|
||||
--- /dev/null
|
||||
+++ b/configs/jethub_j200_defconfig
|
||||
@@ -0,0 +1,119 @@
|
||||
@@ -0,0 +1,120 @@
|
||||
+CONFIG_OF_UPSTREAM=n
|
||||
+CONFIG_ARM=y
|
||||
+CONFIG_SYS_BOARD="jethub-j200"
|
||||
@ -893,6 +950,7 @@ index 000000000000..111111111111
|
||||
+CONFIG_DM_SPI_FLASH=y
|
||||
+CONFIG_SPI_FLASH_WINBOND=y
|
||||
+CONFIG_SPI_FLASH_XTX=y
|
||||
+CONFIG_SPI_LOAD=y
|
||||
+CONFIG_PHY_REALTEK=y
|
||||
+CONFIG_DM_MDIO=y
|
||||
+CONFIG_DM_MDIO_MUX=y
|
||||
@ -960,7 +1018,7 @@ diff --git a/doc/board/amlogic/index.rst b/doc/board/amlogic/index.rst
|
||||
index 111111111111..222222222222 100644
|
||||
--- a/doc/board/amlogic/index.rst
|
||||
+++ b/doc/board/amlogic/index.rst
|
||||
@@ -95,6 +95,7 @@ Board Documentation
|
||||
@@ -97,6 +97,7 @@ Board Documentation
|
||||
beelink-gtkingpro
|
||||
jethub-j80
|
||||
jethub-j100
|
||||
@ -1028,7 +1086,7 @@ diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/regulato
|
||||
index 111111111111..222222222222 100644
|
||||
--- a/drivers/power/regulator/regulator-uclass.c
|
||||
+++ b/drivers/power/regulator/regulator-uclass.c
|
||||
@@ -186,7 +186,7 @@ int regulator_set_enable(struct udevice *dev, bool enable)
|
||||
@@ -191,7 +191,7 @@ int regulator_set_enable(struct udevice *dev, bool enable)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4,33 +4,27 @@ Date: Thu, 27 Nov 2025 17:30:11 +0300
|
||||
Subject: add ssd1306, joystick and gpio expander support
|
||||
|
||||
---
|
||||
arch/arm/dts/meson-sm1-jethome-jethub-j200.dts | 78 ++++++++++++++++++-
|
||||
arch/arm/dts/meson-sm1-jethome-jethub-j200.dts | 78 +++++++++-
|
||||
1 file changed, 77 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/arch/arm/dts/meson-sm1-jethome-jethub-j200.dts b/arch/arm/dts/meson-sm1-jethome-jethub-j200.dts
|
||||
index 3151a99974c..8acc3785ba3 100644
|
||||
index 111111111111..222222222222 100644
|
||||
--- a/arch/arm/dts/meson-sm1-jethome-jethub-j200.dts
|
||||
+++ b/arch/arm/dts/meson-sm1-jethome-jethub-j200.dts
|
||||
@@ -9,11 +9,12 @@
|
||||
#include "meson-sm1.dtsi"
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
#include <dt-bindings/gpio/meson-g12a-gpio.h>
|
||||
#include <dt-bindings/leds/common.h>
|
||||
#include <dt-bindings/sound/meson-g12a-tohdmitx.h>
|
||||
-
|
||||
+#include <dt-bindings/input/input.h>
|
||||
+#include <dt-bindings/gpio/gpio.h>
|
||||
|
||||
|
||||
/ {
|
||||
|
||||
compatible = "jethome,jethub-j200", "amlogic,sm1";
|
||||
model = "JetHome JetHub D2";
|
||||
@@ -245,10 +246,63 @@
|
||||
|
||||
sound {
|
||||
model = "JETHUB-D2";
|
||||
};
|
||||
|
||||
|
||||
@@ -247,6 +248,59 @@
|
||||
model = "JETHUB-D2";
|
||||
};
|
||||
|
||||
+ gpio-keys {
|
||||
+ compatible = "gpio-keys-polled";
|
||||
+ poll-interval = <100>;
|
||||
@ -85,16 +79,12 @@ index 3151a99974c..8acc3785ba3 100644
|
||||
+ };
|
||||
+ };
|
||||
};
|
||||
|
||||
|
||||
&arb {
|
||||
status = "okay";
|
||||
};
|
||||
@@ -627,10 +681,32 @@
|
||||
temp2: tmp102@49 {
|
||||
compatible = "ti,tmp102";
|
||||
reg = <0x49>;
|
||||
};
|
||||
|
||||
@@ -629,6 +683,28 @@
|
||||
reg = <0x49>;
|
||||
};
|
||||
|
||||
+ ssd1306: oled@3c {
|
||||
+ compatible = "solomon,ssd1306";
|
||||
+ reg = <0x3c>;
|
||||
@ -118,9 +108,8 @@ index 3151a99974c..8acc3785ba3 100644
|
||||
+ "JOY_CENTER", "JOY_HOME", "JOY_BACK", "";
|
||||
+ };
|
||||
};
|
||||
|
||||
|
||||
&efuse {
|
||||
eth_mac: eth-mac@0 {
|
||||
reg = <0x0 0x6>;
|
||||
--
|
||||
--
|
||||
Armbian
|
||||
|
||||
@ -0,0 +1,63 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Evgeny Bachinin <EABachinin@salutedevices.com>
|
||||
Date: Mon, 10 Feb 2025 20:50:14 +0300
|
||||
Subject: arm: meson: unify type being used for socinfo
|
||||
|
||||
socinfo_ API uses u32 type, hence let's use it everywhere
|
||||
for consistency.
|
||||
|
||||
Signed-off-by: Evgeny Bachinin <EABachinin@salutedevices.com>
|
||||
Link: https://lore.kernel.org/r/20250210-meson_chip_id_all_vers-v1-1-b98f8b6880b8@salutedevices.com
|
||||
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
|
||||
---
|
||||
arch/arm/mach-meson/board-info.c | 9 +++++----
|
||||
1 file changed, 5 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/arch/arm/mach-meson/board-info.c b/arch/arm/mach-meson/board-info.c
|
||||
index 111111111111..222222222222 100644
|
||||
--- a/arch/arm/mach-meson/board-info.c
|
||||
+++ b/arch/arm/mach-meson/board-info.c
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <init.h>
|
||||
#include <asm/global_data.h>
|
||||
#include <asm/io.h>
|
||||
+#include <asm/types.h>
|
||||
#include <dm.h>
|
||||
#include <linux/bitfield.h>
|
||||
#include <regmap.h>
|
||||
@@ -125,12 +126,12 @@ static const char *socinfo_to_soc_id(u32 socinfo)
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
-static unsigned int get_socinfo(void)
|
||||
+static u32 get_socinfo(void)
|
||||
{
|
||||
struct regmap *regmap;
|
||||
int nodeoffset, ret;
|
||||
ofnode node;
|
||||
- unsigned int socinfo;
|
||||
+ u32 socinfo;
|
||||
|
||||
/* find the offset of compatible node */
|
||||
nodeoffset = fdt_node_offset_by_compatible(gd->fdt_blob, -1,
|
||||
@@ -162,7 +163,7 @@ static unsigned int get_socinfo(void)
|
||||
|
||||
int checkboard(void)
|
||||
{
|
||||
- unsigned int socinfo;
|
||||
+ u32 socinfo;
|
||||
|
||||
socinfo = get_socinfo();
|
||||
if (!socinfo)
|
||||
@@ -181,7 +182,7 @@ int checkboard(void)
|
||||
|
||||
int meson_get_soc_rev(char *buff, size_t buff_len)
|
||||
{
|
||||
- unsigned int socinfo;
|
||||
+ u32 socinfo;
|
||||
|
||||
socinfo = get_socinfo();
|
||||
if (!socinfo)
|
||||
--
|
||||
Armbian
|
||||
|
||||
@ -0,0 +1,30 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Evgeny Bachinin <EABachinin@salutedevices.com>
|
||||
Date: Mon, 10 Feb 2025 20:50:15 +0300
|
||||
Subject: arm: meson: sm: get rid of SM_CHIP_ID_SIZE
|
||||
|
||||
SM_CHIP_ID_SIZE is used nowhere. Moreover, it specifies wrong
|
||||
chip_id size: Amlogic chip_id v1 and v2 is always 16 bytes long.
|
||||
|
||||
Signed-off-by: Evgeny Bachinin <EABachinin@salutedevices.com>
|
||||
Link: https://lore.kernel.org/r/20250210-meson_chip_id_all_vers-v1-2-b98f8b6880b8@salutedevices.com
|
||||
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
|
||||
---
|
||||
arch/arm/mach-meson/sm.c | 1 -
|
||||
1 file changed, 1 deletion(-)
|
||||
|
||||
diff --git a/arch/arm/mach-meson/sm.c b/arch/arm/mach-meson/sm.c
|
||||
index 111111111111..222222222222 100644
|
||||
--- a/arch/arm/mach-meson/sm.c
|
||||
+++ b/arch/arm/mach-meson/sm.c
|
||||
@@ -78,7 +78,6 @@ ssize_t meson_sm_write_efuse(uintptr_t offset, void *buffer, size_t size)
|
||||
|
||||
#define SM_CHIP_ID_LENGTH 119
|
||||
#define SM_CHIP_ID_OFFSET 4
|
||||
-#define SM_CHIP_ID_SIZE 12
|
||||
|
||||
int meson_sm_get_serial(void *buffer, size_t size)
|
||||
{
|
||||
--
|
||||
Armbian
|
||||
|
||||
@ -0,0 +1,322 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Evgeny Bachinin <EABachinin@salutedevices.com>
|
||||
Date: Mon, 10 Feb 2025 20:50:16 +0300
|
||||
Subject: arch: arm: meson: support Amlogic chip_id v1 and v2
|
||||
|
||||
Patch introduces:
|
||||
* chip_id API - useful for various things, but used now for
|
||||
device_id (did) generation as mentioned in [1] on our private board
|
||||
code. Our device_id is calculated by means of permutations of
|
||||
chip_id value.
|
||||
* new SoCs (a1, s4, etc) are usually coming with the support of chip_id
|
||||
v2 right away, whereas secure monitors on old SoCs (like axg, g12b,
|
||||
g12a, etc) may support only chip_id v1. Chip_id API handles both
|
||||
cases
|
||||
* meson_sm_get_serial() is described via chip_id API.
|
||||
|
||||
Links:
|
||||
[1] https://lore.kernel.org/linux-arm-kernel/202311242104.RjBPI3uI-lkp@intel.com/T/#m630fbeea6a6e7d531290b5c0af205af4fb979757
|
||||
|
||||
Signed-off-by: Viacheslav Bocharov <adeep@lexina.in>
|
||||
Co-developed-by: Arseniy Krasnov <avkrasnov@salutedevices.com>
|
||||
Signed-off-by: Arseniy Krasnov <avkrasnov@salutedevices.com>
|
||||
Signed-off-by: Evgeny Bachinin <EABachinin@salutedevices.com>
|
||||
Link: https://lore.kernel.org/r/20250210-meson_chip_id_all_vers-v1-3-b98f8b6880b8@salutedevices.com
|
||||
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
|
||||
---
|
||||
arch/arm/include/asm/arch-meson/boot.h | 14 ++
|
||||
arch/arm/include/asm/arch-meson/sm.h | 48 +++-
|
||||
arch/arm/mach-meson/board-info.c | 6 +-
|
||||
arch/arm/mach-meson/sm.c | 119 +++++++++-
|
||||
4 files changed, 175 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/arch/arm/include/asm/arch-meson/boot.h b/arch/arm/include/asm/arch-meson/boot.h
|
||||
index 111111111111..222222222222 100644
|
||||
--- a/arch/arm/include/asm/arch-meson/boot.h
|
||||
+++ b/arch/arm/include/asm/arch-meson/boot.h
|
||||
@@ -21,4 +21,18 @@ int meson_get_boot_device(void);
|
||||
|
||||
int meson_get_soc_rev(char *buff, size_t buff_len);
|
||||
|
||||
+/**
|
||||
+ * meson_get_socinfo - retrieve cpu_id of the Amlogic SoC
|
||||
+ *
|
||||
+ * The value in the following format is read from register:
|
||||
+ * +-----------+------------+------------+------------+
|
||||
+ * | family_id | package_id | chip_rev | layout_rev |
|
||||
+ * +-----------+------------+------------+------------+
|
||||
+ * | 31 24 | 23 16 | 15 8 | 7 0 |
|
||||
+ * +-----------+------------+------------+------------+
|
||||
+ *
|
||||
+ * Return: 4 bytes value of cpu_id on success or 0 on failure.
|
||||
+ */
|
||||
+u32 meson_get_socinfo(void);
|
||||
+
|
||||
#endif /* __MESON_BOOT_H__ */
|
||||
diff --git a/arch/arm/include/asm/arch-meson/sm.h b/arch/arm/include/asm/arch-meson/sm.h
|
||||
index 111111111111..222222222222 100644
|
||||
--- a/arch/arm/include/asm/arch-meson/sm.h
|
||||
+++ b/arch/arm/include/asm/arch-meson/sm.h
|
||||
@@ -6,6 +6,8 @@
|
||||
#ifndef __MESON_SM_H__
|
||||
#define __MESON_SM_H__
|
||||
|
||||
+#include <asm/types.h>
|
||||
+
|
||||
/**
|
||||
* meson_sm_read_efuse - read efuse memory into buffer
|
||||
*
|
||||
@@ -27,16 +29,60 @@ ssize_t meson_sm_read_efuse(uintptr_t offset, void *buffer, size_t size);
|
||||
ssize_t meson_sm_write_efuse(uintptr_t offset, void *buffer, size_t size);
|
||||
|
||||
#define SM_SERIAL_SIZE 12
|
||||
+#define MESON_CPU_ID_SZ 4
|
||||
+#define MESON_CHIP_ID_SZ 16
|
||||
+
|
||||
+/**
|
||||
+ * union meson_cpu_id - Amlogic cpu_id.
|
||||
+ * @raw: buffer to hold the cpu_id value as sequential bytes.
|
||||
+ * @val: cpu_id represented as 32 bit value.
|
||||
+ */
|
||||
+union meson_cpu_id {
|
||||
+ u8 raw[MESON_CPU_ID_SZ];
|
||||
+ u32 val;
|
||||
+};
|
||||
+
|
||||
+/**
|
||||
+ * struct meson_sm_chip_id - Amlogic chip_id.
|
||||
+ * @cpu_id: cpu_id value, which is distinct from socinfo in that the order of
|
||||
+ * PACK & MINOR bytes are swapped according to Amlogic chip_id format.
|
||||
+ * @serial: 12 byte unique SoC number, identifying particular die, read
|
||||
+ * usually from efuse OTP storage. Serial comes in little-endian
|
||||
+ * order.
|
||||
+ */
|
||||
+struct meson_sm_chip_id {
|
||||
+ union meson_cpu_id cpu_id;
|
||||
+ u8 serial[SM_SERIAL_SIZE];
|
||||
+};
|
||||
|
||||
/**
|
||||
- * meson_sm_get_serial - read chip unique id into buffer
|
||||
+ * meson_sm_get_serial - read chip unique serial (OTP data) into buffer
|
||||
*
|
||||
* @buffer: pointer to buffer
|
||||
* @size: buffer size.
|
||||
+ *
|
||||
+ * Serial is returned in big-endian order.
|
||||
+ *
|
||||
* @return: zero on success or -errno on failure
|
||||
*/
|
||||
int meson_sm_get_serial(void *buffer, size_t size);
|
||||
|
||||
+/**
|
||||
+ * meson_sm_get_chip_id - read Amlogic chip_id
|
||||
+ *
|
||||
+ * @chip_id: pointer to buffer capable to hold the struct meson_sm_chip_id
|
||||
+ *
|
||||
+ * Amlogic SoCs support 2 versions of chip_id. Function requests the newest
|
||||
+ * one (v2), but if chip_id v2 is not supported, then secure monitor returns
|
||||
+ * v1. All differences between v1 and v2 versions are handled by this function
|
||||
+ * and chip_id is returned in unified format.
|
||||
+ *
|
||||
+ * chip_id contains serial, which is returned here in little-endian order.
|
||||
+ *
|
||||
+ * @return: 0 on success or -errno on failure
|
||||
+ */
|
||||
+int meson_sm_get_chip_id(struct meson_sm_chip_id *chip_id);
|
||||
+
|
||||
enum {
|
||||
REBOOT_REASON_COLD = 0,
|
||||
REBOOT_REASON_NORMAL = 1,
|
||||
diff --git a/arch/arm/mach-meson/board-info.c b/arch/arm/mach-meson/board-info.c
|
||||
index 111111111111..222222222222 100644
|
||||
--- a/arch/arm/mach-meson/board-info.c
|
||||
+++ b/arch/arm/mach-meson/board-info.c
|
||||
@@ -126,7 +126,7 @@ static const char *socinfo_to_soc_id(u32 socinfo)
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
-static u32 get_socinfo(void)
|
||||
+u32 meson_get_socinfo(void)
|
||||
{
|
||||
struct regmap *regmap;
|
||||
int nodeoffset, ret;
|
||||
@@ -165,7 +165,7 @@ int checkboard(void)
|
||||
{
|
||||
u32 socinfo;
|
||||
|
||||
- socinfo = get_socinfo();
|
||||
+ socinfo = meson_get_socinfo();
|
||||
if (!socinfo)
|
||||
return 0;
|
||||
|
||||
@@ -184,7 +184,7 @@ int meson_get_soc_rev(char *buff, size_t buff_len)
|
||||
{
|
||||
u32 socinfo;
|
||||
|
||||
- socinfo = get_socinfo();
|
||||
+ socinfo = meson_get_socinfo();
|
||||
if (!socinfo)
|
||||
return -1;
|
||||
|
||||
diff --git a/arch/arm/mach-meson/sm.c b/arch/arm/mach-meson/sm.c
|
||||
index 111111111111..222222222222 100644
|
||||
--- a/arch/arm/mach-meson/sm.c
|
||||
+++ b/arch/arm/mach-meson/sm.c
|
||||
@@ -10,11 +10,13 @@
|
||||
#include <regmap.h>
|
||||
#include <sm.h>
|
||||
#include <syscon.h>
|
||||
+#include <asm/arch/boot.h>
|
||||
#include <asm/arch/sm.h>
|
||||
#include <asm/cache.h>
|
||||
#include <asm/global_data.h>
|
||||
#include <asm/ptrace.h>
|
||||
#include <linux/bitops.h>
|
||||
+#include <linux/compiler_attributes.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/bitfield.h>
|
||||
@@ -76,30 +78,131 @@ ssize_t meson_sm_write_efuse(uintptr_t offset, void *buffer, size_t size)
|
||||
return err;
|
||||
}
|
||||
|
||||
-#define SM_CHIP_ID_LENGTH 119
|
||||
-#define SM_CHIP_ID_OFFSET 4
|
||||
+/*
|
||||
+ * Helps to handle two flavors of cpu_id layouts:
|
||||
+ *
|
||||
+ * - in-register view (value read from cpu_id reg, a.k.a. socinfo):
|
||||
+ * +-----------+------------+------------+------------+
|
||||
+ * | family_id | package_id | chip_rev | layout_rev |
|
||||
+ * +-----------+------------+------------+------------+
|
||||
+ * | 31 24 | 23 16 | 15 8 | 7 0 |
|
||||
+ * +-----------+------------+------------+------------+
|
||||
+ *
|
||||
+ * - in-efuse view (value, residing inside efuse/shmem data usually for
|
||||
+ * chip_id v2. Chip_id v1 does not contain cpu_id value inside efuse
|
||||
+ * data (i.e. in chip_id_efuse)):
|
||||
+ * +-----------+------------+------------+------------+
|
||||
+ * | family_id | chip_rev | package_id | layout_rev |
|
||||
+ * +-----------+------------+------------+------------+
|
||||
+ * | 31 24 | 23 16 | 15 8 | 7 0 |
|
||||
+ * +-----------+------------+------------+------------+
|
||||
+ */
|
||||
+enum {
|
||||
+ /* In-register view of cpu_id */
|
||||
+ CPU_ID_REG_MAJOR, /* 31-24 bits */
|
||||
+ CPU_ID_REG_PACK, /* 23-16 bits */
|
||||
+ CPU_ID_REG_MINOR, /* 15-8 bits */
|
||||
+ CPU_ID_REG_MISC, /* 7-0 bits */
|
||||
|
||||
-int meson_sm_get_serial(void *buffer, size_t size)
|
||||
+ /* In-efuse view of cpu_id */
|
||||
+ CPU_ID_MAJOR = CPU_ID_REG_MAJOR,
|
||||
+ CPU_ID_PACK = CPU_ID_REG_MINOR,
|
||||
+ CPU_ID_MINOR = CPU_ID_REG_PACK,
|
||||
+ CPU_ID_MISC = CPU_ID_REG_MISC,
|
||||
+};
|
||||
+
|
||||
+/*
|
||||
+ * This is a beginning chunk of the whole efuse storage area, containing
|
||||
+ * data related to chip_id only
|
||||
+ */
|
||||
+struct chip_id_efuse {
|
||||
+ u32 version;
|
||||
+ u8 raw[MESON_CHIP_ID_SZ]; /* payload */
|
||||
+} __packed;
|
||||
+
|
||||
+static void meson_sm_serial_reverse(u8 serial[SM_SERIAL_SIZE])
|
||||
+{
|
||||
+ for (int i = 0; i < SM_SERIAL_SIZE / 2; i++) {
|
||||
+ int k = SM_SERIAL_SIZE - 1 - i;
|
||||
+
|
||||
+ swap(serial[i], serial[k]);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+int meson_sm_get_chip_id(struct meson_sm_chip_id *chip_id)
|
||||
{
|
||||
struct udevice *dev;
|
||||
+ union meson_cpu_id socinfo;
|
||||
struct pt_regs regs = { 0 };
|
||||
- u8 id_buffer[SM_CHIP_ID_LENGTH];
|
||||
+ struct chip_id_efuse chip_id_efuse;
|
||||
int err;
|
||||
|
||||
dev = meson_get_sm_device();
|
||||
if (IS_ERR(dev))
|
||||
return PTR_ERR(dev);
|
||||
|
||||
- err = sm_call_read(dev, id_buffer, SM_CHIP_ID_LENGTH,
|
||||
+ /*
|
||||
+ * Request v2. If not supported by secure monitor, then v1 should be
|
||||
+ * returned.
|
||||
+ */
|
||||
+ regs.regs[1] = 2;
|
||||
+
|
||||
+ err = sm_call_read(dev, &chip_id_efuse, sizeof(chip_id_efuse),
|
||||
MESON_SMC_CMD_CHIP_ID_GET, ®s);
|
||||
- if (err < 0)
|
||||
- pr_err("Failed to read serial number (%d)\n", err);
|
||||
+ if (err < 0) {
|
||||
+ pr_err("Failed to read chip_id (%d)\n", err);
|
||||
+ return err;
|
||||
+ }
|
||||
+
|
||||
+ if (chip_id_efuse.version == 2) {
|
||||
+ memcpy((u8 *)chip_id, chip_id_efuse.raw,
|
||||
+ sizeof(struct meson_sm_chip_id));
|
||||
+ return 0;
|
||||
+ }
|
||||
|
||||
- memcpy(buffer, id_buffer + SM_CHIP_ID_OFFSET, size);
|
||||
+ /*
|
||||
+ * Legacy chip_id (v1) read out, transform data
|
||||
+ * to expected order format (little-endian)
|
||||
+ */
|
||||
+ memcpy(chip_id->serial, chip_id_efuse.raw, sizeof(chip_id->serial));
|
||||
+ meson_sm_serial_reverse(chip_id->serial);
|
||||
+
|
||||
+ socinfo.val = meson_get_socinfo();
|
||||
+ if (!socinfo.val)
|
||||
+ return -ENODEV;
|
||||
+
|
||||
+ chip_id->cpu_id = (union meson_cpu_id){
|
||||
+ .raw[CPU_ID_MAJOR] = socinfo.raw[CPU_ID_REG_MAJOR],
|
||||
+ .raw[CPU_ID_PACK] = socinfo.raw[CPU_ID_REG_PACK],
|
||||
+ .raw[CPU_ID_MINOR] = socinfo.raw[CPU_ID_REG_MINOR],
|
||||
+ .raw[CPU_ID_MISC] = socinfo.raw[CPU_ID_REG_MISC],
|
||||
+ };
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
+int meson_sm_get_serial(void *buffer, size_t size)
|
||||
+{
|
||||
+ struct meson_sm_chip_id chip_id;
|
||||
+ int ret;
|
||||
+
|
||||
+ if (size < SM_SERIAL_SIZE)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ ret = meson_sm_get_chip_id(&chip_id);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ /*
|
||||
+ * The order of serial inside chip_id and serial which function must
|
||||
+ * return does not match: stick here to big-endian for backward
|
||||
+ * compatibility.
|
||||
+ */
|
||||
+ meson_sm_serial_reverse(chip_id.serial);
|
||||
+ memcpy(buffer, chip_id.serial, sizeof(chip_id.serial));
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
#define AO_SEC_SD_CFG15 0xfc
|
||||
#define REBOOT_REASON_MASK GENMASK(15, 12)
|
||||
|
||||
--
|
||||
Armbian
|
||||
|
||||
@ -1,24 +1,28 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Viacheslav Bocharov <adeep@lexina.in>
|
||||
Date: Tue, 31 Oct 2023 12:16:43 +0300
|
||||
Subject: Add some amlogic sm functions
|
||||
Date: Mon, 12 Jan 2026 15:26:33 +0300
|
||||
Subject: arm: meson: add securemonitor getmax function
|
||||
|
||||
Add sm getmax [name] cli function to get size of AmLogic soc efuse
|
||||
|
||||
Signed-off-by: Viacheslav Bocharov <adeep@lexina.in>
|
||||
---
|
||||
arch/arm/include/asm/arch-meson/sm.h | 18 ++++
|
||||
arch/arm/mach-meson/sm.c | 41 ++++++++
|
||||
cmd/meson/sm.c | 49 +++++++++-
|
||||
arch/arm/include/asm/arch-meson/sm.h | 9 ++++
|
||||
arch/arm/mach-meson/sm.c | 18 +++++++
|
||||
cmd/meson/sm.c | 27 +++++++++-
|
||||
drivers/sm/meson-sm.c | 1 +
|
||||
include/meson/sm.h | 1 +
|
||||
5 files changed, 109 insertions(+), 1 deletion(-)
|
||||
5 files changed, 55 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/arch/arm/include/asm/arch-meson/sm.h b/arch/arm/include/asm/arch-meson/sm.h
|
||||
index 111111111111..222222222222 100644
|
||||
--- a/arch/arm/include/asm/arch-meson/sm.h
|
||||
+++ b/arch/arm/include/asm/arch-meson/sm.h
|
||||
@@ -26,7 +26,16 @@ ssize_t meson_sm_read_efuse(uintptr_t offset, void *buffer, size_t size);
|
||||
@@ -83,6 +83,15 @@ int meson_sm_get_serial(void *buffer, size_t size);
|
||||
*/
|
||||
ssize_t meson_sm_write_efuse(uintptr_t offset, void *buffer, size_t size);
|
||||
int meson_sm_get_chip_id(struct meson_sm_chip_id *chip_id);
|
||||
|
||||
+
|
||||
+/**
|
||||
+ * meson_sm_getmax - get max size of user efuse
|
||||
+ * @buffer: pointer to buffer
|
||||
@ -26,24 +30,6 @@ index 111111111111..222222222222 100644
|
||||
+ * @return: size of user efuse or -errno on failure
|
||||
+ */
|
||||
+ssize_t meson_sm_getmax(void *buffer, size_t size);
|
||||
+
|
||||
#define SM_SERIAL_SIZE 12
|
||||
+#define SM_SERIAL2_SIZE 16
|
||||
|
||||
/**
|
||||
* meson_sm_get_serial - read chip unique id into buffer
|
||||
@@ -37,6 +46,15 @@ ssize_t meson_sm_write_efuse(uintptr_t offset, void *buffer, size_t size);
|
||||
*/
|
||||
int meson_sm_get_serial(void *buffer, size_t size);
|
||||
|
||||
+/**
|
||||
+ * meson_sm_get_serial2 - read chip unique id (ver.2) into buffer
|
||||
+ *
|
||||
+ * @buffer: pointer to buffer
|
||||
+ * @size: buffer size.
|
||||
+ * @return: zero on success or -errno on failure
|
||||
+ */
|
||||
+int meson_sm_get_serial2(void *buffer, size_t size);
|
||||
+
|
||||
enum {
|
||||
REBOOT_REASON_COLD = 0,
|
||||
@ -52,7 +38,7 @@ diff --git a/arch/arm/mach-meson/sm.c b/arch/arm/mach-meson/sm.c
|
||||
index 111111111111..222222222222 100644
|
||||
--- a/arch/arm/mach-meson/sm.c
|
||||
+++ b/arch/arm/mach-meson/sm.c
|
||||
@@ -77,7 +77,26 @@ ssize_t meson_sm_write_efuse(uintptr_t offset, void *buffer, size_t size)
|
||||
@@ -78,6 +78,24 @@ ssize_t meson_sm_write_efuse(uintptr_t offset, void *buffer, size_t size)
|
||||
return err;
|
||||
}
|
||||
|
||||
@ -74,71 +60,14 @@ index 111111111111..222222222222 100644
|
||||
+ return err;
|
||||
+}
|
||||
+
|
||||
#define SM_CHIP_ID_LENGTH 119
|
||||
+#define SM_CHIP_ID_LENGTH2 128
|
||||
#define SM_CHIP_ID_OFFSET 4
|
||||
#define SM_CHIP_ID_SIZE 12
|
||||
|
||||
@@ -102,6 +121,28 @@ int meson_sm_get_serial(void *buffer, size_t size)
|
||||
return 0;
|
||||
}
|
||||
|
||||
+int meson_sm_get_serial2(void *buffer, size_t size)
|
||||
+{
|
||||
+ struct udevice *dev;
|
||||
+ struct pt_regs regs = { 0 };
|
||||
+ regs.regs[1] = 2;
|
||||
+ u8 id_buffer[SM_CHIP_ID_LENGTH2];
|
||||
+ int err;
|
||||
+
|
||||
+ dev = meson_get_sm_device();
|
||||
+ if (IS_ERR(dev))
|
||||
+ return PTR_ERR(dev);
|
||||
+
|
||||
+ err = sm_call_read(dev, id_buffer, SM_CHIP_ID_LENGTH,
|
||||
+ MESON_SMC_CMD_CHIP_ID_GET, ®s);
|
||||
+ if (err < 0)
|
||||
+ pr_err("Failed to read serial number (%d)\n", err);
|
||||
+
|
||||
+ memcpy(buffer, id_buffer + SM_CHIP_ID_OFFSET, size);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
#define AO_SEC_SD_CFG15 0xfc
|
||||
#define REBOOT_REASON_MASK GENMASK(15, 12)
|
||||
|
||||
/*
|
||||
* Helps to handle two flavors of cpu_id layouts:
|
||||
*
|
||||
diff --git a/cmd/meson/sm.c b/cmd/meson/sm.c
|
||||
index 111111111111..222222222222 100644
|
||||
--- a/cmd/meson/sm.c
|
||||
+++ b/cmd/meson/sm.c
|
||||
@@ -33,6 +33,25 @@ static int do_sm_serial(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||
return CMD_RET_SUCCESS;
|
||||
}
|
||||
|
||||
+static int do_sm_serialv2(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||
+ char *const argv[])
|
||||
+{
|
||||
+ ulong address;
|
||||
+ int ret;
|
||||
+
|
||||
+ if (argc < 2)
|
||||
+ return CMD_RET_USAGE;
|
||||
+
|
||||
+ address = simple_strtoul(argv[1], NULL, 0);
|
||||
+
|
||||
+ ret = meson_sm_get_serial2((void *)address, SM_SERIAL2_SIZE);
|
||||
+ if (ret)
|
||||
+ return CMD_RET_FAILURE;
|
||||
+
|
||||
+ return CMD_RET_SUCCESS;
|
||||
+}
|
||||
+
|
||||
+
|
||||
#define MAX_REBOOT_REASONS 14
|
||||
|
||||
static const char *reboot_reasons[MAX_REBOOT_REASONS] = {
|
||||
@@ -152,12 +171,38 @@ free_buffer:
|
||||
@@ -152,12 +152,36 @@ free_buffer:
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -167,33 +96,27 @@ index 111111111111..222222222222 100644
|
||||
+
|
||||
static struct cmd_tbl cmd_sm_sub[] = {
|
||||
U_BOOT_CMD_MKENT(serial, 2, 1, do_sm_serial, "", ""),
|
||||
+ U_BOOT_CMD_MKENT(serialv2, 2, 1, do_sm_serialv2, "", ""),
|
||||
U_BOOT_CMD_MKENT(reboot_reason, 1, 1, do_sm_reboot_reason, "", ""),
|
||||
U_BOOT_CMD_MKENT(efuseread, 4, 1, do_efuse_read, "", ""),
|
||||
U_BOOT_CMD_MKENT(efusewrite, 4, 0, do_efuse_write, "", ""),
|
||||
U_BOOT_CMD_MKENT(efusedump, 3, 1, do_efuse_dump, "", ""),
|
||||
+ U_BOOT_CMD_MKENT(getmax, 2, 1, do_efuse_getmax, "", ""),
|
||||
+
|
||||
};
|
||||
|
||||
static int do_sm(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||
@@ -184,8 +229,10 @@ U_BOOT_CMD(
|
||||
sm, 5, 0, do_sm,
|
||||
"Secure Monitor Control",
|
||||
"serial <address> - read chip unique id to memory address\n"
|
||||
+ "serialv2 <address> - read chip unique id (ver 2) to memory address\n"
|
||||
@@ -187,5 +211,6 @@ U_BOOT_CMD(
|
||||
"sm reboot_reason [name] - get reboot reason and store to environment\n"
|
||||
"sm efuseread <offset> <size> <address> - read efuse to memory address\n"
|
||||
"sm efusewrite <offset> <size> <address> - write into efuse from memory address\n"
|
||||
- "sm efusedump <offset> <size> - dump efuse data range to console"
|
||||
+ "sm efusedump <offset> <size> - dump efuse data range to console\n"
|
||||
+ "sm getmax [name] - get max size of user accesible efuse and store to environment\n"
|
||||
+ "sm getmax [name] - get max size of user accessible efuse and store to environment"
|
||||
);
|
||||
diff --git a/drivers/sm/meson-sm.c b/drivers/sm/meson-sm.c
|
||||
index 111111111111..222222222222 100644
|
||||
--- a/drivers/sm/meson-sm.c
|
||||
+++ b/drivers/sm/meson-sm.c
|
||||
@@ -167,6 +167,7 @@ static const struct meson_sm_data meson_sm_gxbb_data = {
|
||||
@@ -166,6 +166,7 @@ static const struct meson_sm_data meson_sm_gxbb_data = {
|
||||
.cmd_get_shmem_out = 0x82000021,
|
||||
.shmem_size = SZ_4K,
|
||||
.cmd = {
|
||||
@ -1,7 +1,7 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Martin Ayotte <martinayotte@yahoo.ca>
|
||||
Date: Thu, 13 Dec 2018 17:09:54 -0500
|
||||
Subject: [ARCHEOLOGY] add missing u-boot-meson64 patch for overlays
|
||||
Subject: add missing u-boot-meson64 patch for overlays
|
||||
|
||||
> X-Git-Archeology: - Revision c779ae2faadbfd5472927f58742cdb2371944935: https://github.com/armbian/build/commit/c779ae2faadbfd5472927f58742cdb2371944935
|
||||
> X-Git-Archeology: Date: Thu, 13 Dec 2018 17:09:54 -0500
|
||||
@ -36,7 +36,7 @@ diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
|
||||
index 111111111111..222222222222 100644
|
||||
--- a/arch/arm/Kconfig
|
||||
+++ b/arch/arm/Kconfig
|
||||
@@ -811,6 +811,8 @@ config ARCH_OMAP2PLUS
|
||||
@@ -830,6 +830,8 @@ config ARCH_OMAP2PLUS
|
||||
config ARCH_MESON
|
||||
bool "Amlogic Meson"
|
||||
select GPIO_EXTRA_HEADER
|
||||
Loading…
Reference in New Issue
Block a user