From: Tomasz Maciej Nowak <tmn...@gmail.com> Complementary addition for upcoming NVIDIA Jetson TX1 DevKit support.
Signed-off-by: Tomasz Maciej Nowak <tmn...@gmail.com> --- package/boot/uboot-tegra/Makefile | 17 +- ...a-pass-cboot-MAC-addresses-to-os-fdt.patch | 176 ++++++++++++++++++ ...2180-pass-bt-and-wifi-mac-to-booting.patch | 27 +++ 3 files changed, 215 insertions(+), 5 deletions(-) create mode 100644 package/boot/uboot-tegra/patches/001-ARM-tegra-pass-cboot-MAC-addresses-to-os-fdt.patch create mode 100644 package/boot/uboot-tegra/patches/002-ARM-tegra-p2371-2180-pass-bt-and-wifi-mac-to-booting.patch diff --git a/package/boot/uboot-tegra/Makefile b/package/boot/uboot-tegra/Makefile index 372a75175448..cbe22fd96497 100644 --- a/package/boot/uboot-tegra/Makefile +++ b/package/boot/uboot-tegra/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2017-2019 Tomasz Maciej Nowak <tmn...@gmail.com> +# Copyright (C) 2017-2024 Tomasz Maciej Nowak <tmn...@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 diff --git a/package/boot/uboot-tegra/patches/001-ARM-tegra-pass-cboot-MAC-addresses-to-os-fdt.patch b/package/boot/uboot-tegra/patches/001-ARM-tegra-pass-cboot-MAC-addresses-to-os-fdt.patch new file mode 100644 index 000000000000..8284bbd3e368 --- /dev/null +++ b/package/boot/uboot-tegra/patches/001-ARM-tegra-pass-cboot-MAC-addresses-to-os-fdt.patch @@ -0,0 +1,176 @@ +From 7a5f171d5bd4ec458ffd1bb3cb162d7a42662319 Mon Sep 17 00:00:00 2001 +From: Tomasz Maciej Nowak <tmn...@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 <tmn...@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"; diff --git a/package/boot/uboot-tegra/patches/002-ARM-tegra-p2371-2180-pass-bt-and-wifi-mac-to-booting.patch b/package/boot/uboot-tegra/patches/002-ARM-tegra-p2371-2180-pass-bt-and-wifi-mac-to-booting.patch new file mode 100644 index 000000000000..4da66f9990c7 --- /dev/null +++ b/package/boot/uboot-tegra/patches/002-ARM-tegra-p2371-2180-pass-bt-and-wifi-mac-to-booting.patch @@ -0,0 +1,27 @@ +From c63792769405eba7ba04787cf0426495f062d0bd Mon Sep 17 00:00:00 2001 +From: Tomasz Maciej Nowak <tmn...@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 <tmn...@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; -- 2.47.0 _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel