@@ -1,5 +1,5 @@
#
-# Copyright (C) 2017-2019 Tomasz Maciej Nowak <tmn505@gmail.com>
+# Copyright (C) 2017-2024 Tomasz Maciej Nowak <tmn505@gmail.com>
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
@@ -20,19 +20,26 @@ include $(INCLUDE_DIR)/package.mk
define U-Boot/Default
BUILD_TARGET := tegra
- BUILD_SUBTARGET := armv7
HIDDEN := y
endef
+define U-Boot/jetson-tx1
+ NAME := NVIDIA Jetson TX1
+ BUILD_SUBTARGET := armv8
+ BUILD_DEVICES := nvidia_jetson-tx1
+ UBOOT_CONFIG := p2371-2180
+endef
+UBOOT_TARGETS += jetson-tx1
+
define U-Boot/trimslice
NAME := CompuLab TrimSlice
+ BUILD_SUBTARGET := armv7
BUILD_DEVICES := compulab_trimslice
UBOOT_IMAGE := trimslice-mmc.img trimslice-spi.img
SOC := tegra20
VENDOR := compulab
endef
-
-UBOOT_TARGETS := trimslice
+UBOOT_TARGETS += trimslice
define Build/bct-image
$(CP) $(PKG_BUILD_DIR)/u-boot-dtb-tegra.bin $(PKG_BUILD_DIR)/u-boot.bin
@@ -50,7 +57,7 @@ endef
define Build/Compile
$(call Build/Compile/U-Boot)
- $(call Build/bct-image)
+ $(if $(CONFIG_ARCH_64BIT),,$(call Build/bct-image))
endef
define Build/InstallDev
new file mode 100644
@@ -0,0 +1,176 @@
+From 7a5f171d5bd4ec458ffd1bb3cb162d7a42662319 Mon Sep 17 00:00:00 2001
+From: Tomasz Maciej Nowak <tmn505@gmail.com>
+Date: Thu, 8 Aug 2024 19:34:28 +0200
+Subject: [PATCH 1/2] ARM: tegra: pass cboot MAC addresses to os fdt
+
+Beside Ethernet MAC address cboot provided fdt also contains Bluetooth
+and WiFi addresses, so lets pass them to OS FDT blob if board integrator
+requests them.
+
+Signed-off-by: Tomasz Maciej Nowak <tmn505@gmail.com>
+---
+ arch/arm/include/asm/arch-tegra/board.h | 2 +
+ arch/arm/include/asm/arch-tegra/cboot.h | 2 +
+ arch/arm/mach-tegra/cboot.c | 58 +++++++++++++++++++++++
+ arch/arm/mach-tegra/dt-setup.c | 61 +++++++++++++++++++++++++
+ 4 files changed, 123 insertions(+)
+
+--- a/arch/arm/include/asm/arch-tegra/board.h
++++ b/arch/arm/include/asm/arch-tegra/board.h
+@@ -36,6 +36,8 @@ void pin_mux_display(void); /* overrida
+
+ #if defined(CONFIG_ARM64)
+ void ft_mac_address_setup(void *fdt);
++void ft_btmac_address_setup(void *fdt, const char *compatible);
++void ft_wifimac_address_setup(void *fdt, const char *compatible);
+ void ft_carveout_setup(void *fdt, const char *const *nodes,
+ unsigned int count);
+ #endif
+--- a/arch/arm/include/asm/arch-tegra/cboot.h
++++ b/arch/arm/include/asm/arch-tegra/cboot.h
+@@ -18,6 +18,8 @@ int cboot_dram_init(void);
+ int cboot_dram_init_banksize(void);
+ ulong cboot_get_usable_ram_top(ulong total_size);
+ int cboot_get_ethaddr(const void *fdt, uint8_t mac[ETH_ALEN]);
++int cboot_get_bdaddr(const void *fdt, uint8_t mac[ETH_ALEN]);
++int cboot_get_wifiaddr(const void *fdt, uint8_t mac[ETH_ALEN]);
+ #else
+ static inline void cboot_save_boot_params(unsigned long x0, unsigned long x1,
+ unsigned long x2, unsigned long x3)
+--- a/arch/arm/mach-tegra/cboot.c
++++ b/arch/arm/mach-tegra/cboot.c
+@@ -555,6 +555,64 @@ out:
+ return err;
+ }
+
++int cboot_get_bdaddr(const void *fdt, uint8_t mac[ETH_ALEN])
++{
++ const char *prop;
++ int node, len;
++
++ node = fdt_path_offset(fdt, "/chosen");
++ if (node < 0) {
++ printf("Can't find /chosen node in cboot DTB\n");
++ return node;
++ }
++
++ prop = fdt_getprop(fdt, node, "nvidia,bluetooth-mac", &len);
++ if (!prop) {
++ printf("Can't find Bluetooth MAC address in cboot DTB\n");
++ return -ENOENT;
++ }
++
++ string_to_enetaddr(prop, mac);
++
++ if (!is_valid_ethaddr(mac)) {
++ printf("Invalid MAC address: %s\n", prop);
++ return -EINVAL;
++ }
++
++ debug("Bluetooth MAC address: %pM\n", mac);
++
++ return 0;
++}
++
++int cboot_get_wifiaddr(const void *fdt, uint8_t mac[ETH_ALEN])
++{
++ const char *prop;
++ int node, len;
++
++ node = fdt_path_offset(fdt, "/chosen");
++ if (node < 0) {
++ printf("Can't find /chosen node in cboot DTB\n");
++ return node;
++ }
++
++ prop = fdt_getprop(fdt, node, "nvidia,wifi-mac", &len);
++ if (!prop) {
++ printf("Can't find WiFi MAC address in cboot DTB\n");
++ return -ENOENT;
++ }
++
++ string_to_enetaddr(prop, mac);
++
++ if (!is_valid_ethaddr(mac)) {
++ printf("Invalid MAC address: %s\n", prop);
++ return -EINVAL;
++ }
++
++ debug("WiFi MAC address: %pM\n", mac);
++
++ return 0;
++}
++
+ static char *strip(const char *ptr)
+ {
+ const char *end;
+--- a/arch/arm/mach-tegra/dt-setup.c
++++ b/arch/arm/mach-tegra/dt-setup.c
+@@ -76,6 +76,67 @@ void ft_mac_address_setup(void *fdt)
+ }
+ }
+
++void ft_btmac_address_setup(void *fdt, const char *compatible)
++{
++ const void *cboot_fdt = (const void *)cboot_boot_x0;
++ uint8_t mac[ETH_ALEN];
++ int offset, err, i, o;
++
++ if (!compatible[0])
++ return;
++
++ err = cboot_get_bdaddr(cboot_fdt, mac);
++ if (err < 0)
++ memset(mac, 0, ETH_ALEN);
++
++ offset = fdt_node_offset_by_compatible(fdt, -1, compatible);
++ if (offset < 0) {
++ printf("compatible %s not found\n", compatible);
++ return;
++ }
++
++ if (is_valid_ethaddr(mac)) {
++ /* least significant byte first */
++ for (i = 0, o = 5; i < o; i++, o--) {
++ err = mac[i];
++ mac[i] = mac[o];
++ mac[o] = err;
++ }
++
++ err = fdt_setprop(fdt, offset, "local-bd-address", mac,
++ ETH_ALEN);
++ if (!err)
++ debug("Bluetooth MAC address set: %pM\n", mac);
++ }
++}
++
++void ft_wifimac_address_setup(void *fdt, const char *compatible)
++{
++ const void *cboot_fdt = (const void *)cboot_boot_x0;
++ uint8_t mac[ETH_ALEN];
++ int offset, err;
++
++ if (!compatible[0])
++ return;
++
++ err = cboot_get_wifiaddr(cboot_fdt, mac);
++ if (err < 0)
++ memset(mac, 0, ETH_ALEN);
++
++ offset = fdt_node_offset_by_compatible(fdt, -1, compatible);
++ if (offset < 0) {
++ printf("compatible %s not found\n", compatible);
++ return;
++ }
++
++ if (is_valid_ethaddr(mac)) {
++ err = fdt_setprop(fdt, offset, "local-mac-address", mac,
++ ETH_ALEN);
++ if (!err)
++ debug("WiFi MAC address set: %pM\n", mac);
++ }
++}
++
+ static int ft_copy_carveout(void *dst, const void *src, const char *node)
+ {
+ const char *names = "memory-region-names";
new file mode 100644
@@ -0,0 +1,27 @@
+From c63792769405eba7ba04787cf0426495f062d0bd Mon Sep 17 00:00:00 2001
+From: Tomasz Maciej Nowak <tmn505@gmail.com>
+Date: Thu, 8 Aug 2024 20:54:34 +0200
+Subject: [PATCH 2/2] ARM: tegra: p2371-2180: pass bt and wifi mac to booting
+ os
+
+P2180 has Bluetooth+WiFi module integrated and while Ethernet MAC address
+is passed from cboot FDT, the addresses for Bluetooth and WiFi aren't.
+Therefore do the same for them in nodes specified by compatible, so
+booted OS can use them.
+
+Signed-off-by: Tomasz Maciej Nowak <tmn505@gmail.com>
+---
+ board/nvidia/p2371-2180/p2371-2180.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/board/nvidia/p2371-2180/p2371-2180.c
++++ b/board/nvidia/p2371-2180/p2371-2180.c
+@@ -93,6 +93,8 @@ static const char * const nodes[] = {
+ int ft_board_setup(void *fdt, struct bd_info *bd)
+ {
+ ft_mac_address_setup(fdt);
++ ft_btmac_address_setup(fdt, "brcm,bcm43540-bt");
++ ft_wifimac_address_setup(fdt, "brcm,bcm4354-fmac");
+ ft_carveout_setup(fdt, nodes, ARRAY_SIZE(nodes));
+
+ return 0;