All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jorge Ramirez-Ortiz <jorge.ramirez.ortiz@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v1 05/07] db410c: use the device tree parsed by the lk loader.
Date: Wed, 10 Jan 2018 11:34:38 +0100	[thread overview]
Message-ID: <1515580480-26075-5-git-send-email-jorge.ramirez.ortiz@gmail.com> (raw)
In-Reply-To: <1515580480-26075-1-git-send-email-jorge.ramirez.ortiz@gmail.com>

From: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>

We dont need to keep copies of the properties that we are going to
fixup since we will be using the dtb provided by the firmware.

Signed-off-by: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
---
 board/qualcomm/dragonboard410c/dragonboard410c.c | 71 ++++++++++++++----------
 configs/dragonboard410c_defconfig                |  1 +
 2 files changed, 44 insertions(+), 28 deletions(-)

diff --git a/board/qualcomm/dragonboard410c/dragonboard410c.c b/board/qualcomm/dragonboard410c/dragonboard410c.c
index 8ef4338..236160a 100644
--- a/board/qualcomm/dragonboard410c/dragonboard410c.c
+++ b/board/qualcomm/dragonboard410c/dragonboard410c.c
@@ -15,14 +15,22 @@
 DECLARE_GLOBAL_DATA_PTR;
 
 /* pointer to the device tree ammended by the firmware */
-extern const void *fw_dtb;
+extern void *fw_dtb;
 
-static char wlan_mac[ARP_HLEN];
-static char bt_mac[ARP_HLEN];
+void *board_fdt_blob_setup(void)
+{
+	if (fdt_magic(fw_dtb) != FDT_MAGIC) {
+		printf("Firmware provided invalid dtb!\n");
+		return NULL;
+	}
+
+	return fw_dtb;
+}
 
 int dram_init(void)
 {
 	gd->ram_size = PHYS_SDRAM_1_SIZE;
+
 	return 0;
 }
 
@@ -138,36 +146,43 @@ int misc_init_r(void)
 
 int board_init(void)
 {
-	int offset, len;
-	const char *mac;
-
-	/* take a copy of the firmware information (the user could unknownly
-	   overwrite that DDR via tftp or other means)  */
-
-	offset = fdt_node_offset_by_compatible(fw_dtb, -1, "qcom,wcnss-wlan");
-	if (offset >= 0) {
-		mac = fdt_getprop(fw_dtb, offset, "local-mac-address", &len);
-		if (mac)
-			memcpy(wlan_mac, mac, ARP_HLEN);
-	}
-
-	offset = fdt_node_offset_by_compatible(fw_dtb, -1, "qcom,wcnss-bt");
-	if (offset >= 0) {
-		mac = fdt_getprop(fw_dtb, offset, "local-bd-address", &len);
-		if (mac)
-			memcpy(bt_mac, mac, ARP_HLEN);
-	}
-
 	return 0;
 }
 
 int ft_board_setup(void *blob, bd_t *bd)
 {
-	do_fixup_by_compat(blob, "qcom,wcnss-wlan", "local-mac-address",
-		wlan_mac, ARP_HLEN, 1);
-
-	do_fixup_by_compat(blob, "qcom,wcnss-bt", "local-bd-address",
-		bt_mac, ARP_HLEN, 1);
+	int offset, len, i;
+	const char *mac;
+	struct {
+		const char *compatible;
+		const char *property;
+	} fix[] = {
+		[0] = {
+			/* update the kernel's dtb with wlan mac */
+			.compatible = "qcom,wcnss-wlan",
+			.property = "local-mac-address",
+		},
+		[1] = {
+			/* update the kernel's dtb with bt mac */
+			.compatible = "qcom,wcnss-bt",
+			.property = "local-bd-address",
+		},
+	};
+
+	for ( i = 0; i < sizeof(fix)/sizeof(fix[0]); i++) {
+
+		offset = fdt_node_offset_by_compatible(gd->fdt_blob, -1,
+							fix[i].compatible);
+		if (offset < 0)
+			continue;
+
+		mac = fdt_getprop(gd->fdt_blob, offset, fix[i].property, &len);
+		if (mac)
+			do_fixup_by_compat(blob,
+				fix[i].compatible,
+				fix[i].property,
+				mac, ARP_HLEN, 1);
+	}
 
 	return 0;
 }
diff --git a/configs/dragonboard410c_defconfig b/configs/dragonboard410c_defconfig
index de923ad..4389f52 100644
--- a/configs/dragonboard410c_defconfig
+++ b/configs/dragonboard410c_defconfig
@@ -47,3 +47,4 @@ CONFIG_OF_CONTROL=y
 CONFIG_ENV_IS_IN_MMC=y
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_PSCI_RESET=y
+CONFIG_OF_SEPARATE=y
-- 
2.7.4

  parent reply	other threads:[~2018-01-10 10:34 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-10 10:34 [U-Boot] [PATCH v1 01/07] db410c: configs: increase gunzip buffer size for the kernel Jorge Ramirez-Ortiz
2018-01-10 10:34 ` [U-Boot] [PATCH v1 02/07] db410c: update wlan and bt mac addresses from firmware Jorge Ramirez-Ortiz
2018-01-15 21:43   ` [U-Boot] [U-Boot, v1, " Tom Rini
2018-01-10 10:34 ` [U-Boot] [PATCH v1 03/07] db410c: replace reset driver with psci Jorge Ramirez-Ortiz
2018-01-15 21:43   ` [U-Boot] [U-Boot, v1, " Tom Rini
2018-01-10 10:34 ` [U-Boot] [PATCH v1 04/07] fdtdec: allow board to provide fdt for CONFIG_OF_SEPARATE Jorge Ramirez-Ortiz
2018-01-15 21:43   ` [U-Boot] [U-Boot, v1, " Tom Rini
2018-01-10 10:34 ` Jorge Ramirez-Ortiz [this message]
2018-01-15 21:43   ` [U-Boot] [U-Boot, v1, 05/07] db410c: use the device tree parsed by the lk loader Tom Rini
2018-01-10 10:34 ` [U-Boot] [PATCH v1 06/07] db410c: add reserved-memory node to dts Jorge Ramirez-Ortiz
2018-01-15 21:43   ` [U-Boot] [U-Boot, v1, " Tom Rini
2018-01-10 10:34 ` [U-Boot] [PATCH v1 07/07] db410c: on aarch64 the fdtfile is in per-vendor subdirectory Jorge Ramirez-Ortiz
2018-01-15 21:43   ` [U-Boot] [U-Boot, v1, " Tom Rini
2018-01-15 21:43 ` [U-Boot] [U-Boot, v1, 01/07] db410c: configs: increase gunzip buffer size for the kernel Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1515580480-26075-5-git-send-email-jorge.ramirez.ortiz@gmail.com \
    --to=jorge.ramirez.ortiz@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.