From patchwork Mon Mar 16 19:40:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Warren X-Patchwork-Id: 243707 List-Id: U-Boot discussion From: twarren at nvidia.com (twarren at nvidia.com) Date: Mon, 16 Mar 2020 12:40:45 -0700 Subject: [PATCH 1/5] ARM: tegra: rework fdt_serial_tag_setup_one In-Reply-To: <1584387649-20959-1-git-send-email-twarren@nvidia.com> References: <1584387649-20959-1-git-send-email-twarren@nvidia.com> Message-ID: <1584387649-20959-2-git-send-email-twarren@nvidia.com> From: Stephen Warren Reword fdt_serial_tag_setup_one() so that the types it uses aren't tied to CONFIG_SERIAL_TAG, and rename the function to better indicate its purpose. This will allow it to be re-used by future board info related code. Signed-off-by: Stephen Warren Signed-off-by: Tom Warren --- arch/arm/mach-tegra/ft_board_info.c | 77 +++++++++++++++++++++++++++++++++++++ arch/arm/mach-tegra/ft_board_info.h | 23 +++++++++++ 2 files changed, 100 insertions(+) create mode 100644 arch/arm/mach-tegra/ft_board_info.c create mode 100644 arch/arm/mach-tegra/ft_board_info.h diff --git a/arch/arm/mach-tegra/ft_board_info.c b/arch/arm/mach-tegra/ft_board_info.c new file mode 100644 index 0000000..7dd3a40 --- /dev/null +++ b/arch/arm/mach-tegra/ft_board_info.c @@ -0,0 +1,77 @@ +/* + * (C) Copyright 2010-2016 + * NVIDIA Corporation + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include +#include +#include "ft_board_info.h" + +int ft_board_info_set(void *blob, const struct ft_board_info *bi, + const char *chosen_subnode_name) +{ + int chosen, offset, ret; + u32 val; + + chosen = fdt_path_offset(blob, "/chosen"); + if (!chosen) { + chosen = fdt_add_subnode(blob, 0, "chosen"); + if (chosen < 0) { + error("fdt_add_subnode(/, chosen) failed: %s.\n", + fdt_strerror(chosen)); + return chosen; + } + } + + offset = fdt_add_subnode(blob, chosen, chosen_subnode_name); + if (offset < 0) { + error("fdt_add_subnode(/chosen, %s): %s.\n", + chosen_subnode_name, fdt_strerror(offset)); + return offset; + } + + val = cpu_to_fdt32(bi->id); + ret = fdt_setprop(blob, offset, "id", &val, sizeof(val)); + if (ret < 0) { + error("could not update id property %s.\n", + fdt_strerror(ret)); + return ret; + } + + val = cpu_to_fdt32(bi->sku); + ret = fdt_setprop(blob, offset, "sku", &val, sizeof(val)); + if (ret < 0) { + error("could not update sku property %s.\n", + fdt_strerror(ret)); + return ret; + } + + val = cpu_to_fdt32(bi->fab); + ret = fdt_setprop(blob, offset, "fab", &val, sizeof(val)); + if (ret < 0) { + error("could not update fab property %s.\n", + fdt_strerror(ret)); + return ret; + } + + val = cpu_to_fdt32(bi->major); + ret = fdt_setprop(blob, offset, "major_revision", &val, sizeof(val)); + if (ret < 0) { + error("could not update major_revision property %s.\n", + fdt_strerror(ret)); + return ret; + } + + val = cpu_to_fdt32(bi->minor); + ret = fdt_setprop(blob, offset, "minor_revision", &val, sizeof(val)); + if (ret < 0) { + error("could not update minor_revision property %s.\n", + fdt_strerror(ret)); + return ret; + } + + return 0; +} diff --git a/arch/arm/mach-tegra/ft_board_info.h b/arch/arm/mach-tegra/ft_board_info.h new file mode 100644 index 0000000..c320aee --- /dev/null +++ b/arch/arm/mach-tegra/ft_board_info.h @@ -0,0 +1,23 @@ +/* + * Board info related definitions + * + * (C) Copyright 2015 NVIDIA Corporation + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef _BOARD_INFO_H_ +#define _BOARD_INFO_H_ + +struct ft_board_info { + u32 id; + u32 sku; + u32 fab; + u32 major; + u32 minor; +}; + +int ft_board_info_set(void *blob, const struct ft_board_info *bi, + const char *chosen_subnode_name); + +#endif