[PATCH 1/5] ARM: tegra: rework fdt_serial_tag_setup_one

twarren at nvidia.com twarren at nvidia.com
Mon Mar 16 20:40:45 CET 2020


From: Stephen Warren <swarren at nvidia.com>

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 <swarren at nvidia.com>
Signed-off-by: Tom Warren <twarren at nvidia.com>
---
 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 <www.nvidia.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <fdt_support.h>
+#include <fdtdec.h>
+#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 <www.nvidia.com>
+ *
+ * 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
-- 
1.8.2.1.610.g562af5b


-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------


More information about the U-Boot mailing list