[U-Boot] [PATCH v1 07/11] sunxi: Scan DT tree node '/clocks' on sunxi boards

Philipp Tomsich philipp.tomsich at theobroma-systems.com
Fri Feb 17 17:52:44 UTC 2017


Moving to a DT-based clock framework on sunxi requires the subnodes
of /clocks to be bound on boot-up.  As /clocks does not contain a
compatible-string, the U-Boot DT parsing code ignores it (and any
subnodes).  To overcome this limitation, the sunxi board-init code
retrieves the /clocks node and explicitly starts a DM scan of the
subnodes.

Signed-off-by: Philipp Tomsich <philipp.tomsich at theobroma-systems.com>
---
 board/sunxi/board.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index 89edf2e..838e89f 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -1,39 +1,40 @@
 /*
  * (C) Copyright 2012-2013 Henrik Nordstrom <henrik at henriknordstrom.net>
  * (C) Copyright 2013 Luke Kenneth Casson Leighton <lkcl at lkcl.net>
  *
  * (C) Copyright 2007-2011
  * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
  * Tom Cubie <tangliang at allwinnertech.com>
  *
  * Some board init for the Allwinner A10-evb board.
  *
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
 #include <common.h>
 #include <mmc.h>
 #include <axp_pmic.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/cpu.h>
 #include <asm/arch/display.h>
 #include <asm/arch/dram.h>
 #include <asm/arch/gpio.h>
 #include <asm/arch/mmc.h>
 #include <asm/arch/spl.h>
 #include <asm/arch/usb_phy.h>
 #ifndef CONFIG_ARM64
 #include <asm/armv7.h>
 #endif
 #include <asm/gpio.h>
 #include <asm/io.h>
 #include <crc.h>
+#include <dm/root.h>
 #include <environment.h>
 #include <libfdt.h>
 #include <fdtdec.h>
 #include <led.h>
 #include <nand.h>
 #include <net.h>
 #include <sy8106a.h>
 #include <command.h>
 
@@ -109,76 +110,87 @@ static int setup_led(void)
 int board_init(void)
 {
 	__maybe_unused int id_pfr1, ret;
+	int __maybe_unused offset;
 
 	gd->bd->bi_boot_params = (PHYS_SDRAM_0 + 0x100);
 
+#if defined(CONFIG_CLK)
+	/* Sunxi device trees have their clock definitions in a tree
+	 * below /clocks, which is a node without a compatible-string.
+	 * We need to manually locate it and scan its subnodes.
+	 */
+	offset = fdt_path_offset(gd->fdt_blob, "/clocks");
+	if (offset > 0)
+		dm_scan_fdt_node(gd->dm_root, gd->fdt_blob, offset, false);
+#endif
+
 #ifndef CONFIG_ARM64
 	asm volatile("mrc p15, 0, %0, c0, c1, 1" : "=r"(id_pfr1));
 	debug("id_pfr1: 0x%08x\n", id_pfr1);
 	/* Generic Timer Extension available? */
 	if ((id_pfr1 >> CPUID_ARM_GENTIMER_SHIFT) & 0xf) {
 		uint32_t freq;
 
 		debug("Setting CNTFRQ\n");
 
 		/*
 		 * CNTFRQ is a secure register, so we will crash if we try to
 		 * write this from the non-secure world (read is OK, though).
 		 * In case some bootcode has already set the correct value,
 		 * we avoid the risk of writing to it.
 		 */
 		asm volatile("mrc p15, 0, %0, c14, c0, 0" : "=r"(freq));
 		if (freq != CONFIG_TIMER_CLK_FREQ) {
 			debug("arch timer frequency is %d Hz, should be %d, fixing ...\n",
 			      freq, CONFIG_TIMER_CLK_FREQ);
 #ifdef CONFIG_NON_SECURE
 			printf("arch timer frequency is wrong, but cannot adjust it\n");
 #else
 			asm volatile("mcr p15, 0, %0, c14, c0, 0"
 				     : : "r"(CONFIG_TIMER_CLK_FREQ));
 #endif
 		}
 	}
 #endif /* !CONFIG_ARM64 */
 
 	sunxi_gpio_set_cfgpin(SUNXI_GPG(10), SUN6I_GPG_USB3);
 	sunxi_gpio_set_cfgpin(SUNXI_GPG(11), SUN6I_GPG_USB3);
 
 	gpio_request(SUNXI_GPC(3), "STM32 Boot0");
 	sunxi_gpio_set_cfgpin(SUNXI_GPC(3), SUNXI_GPIO_OUTPUT);
 	gpio_request(SUNXI_GPC(26), "STM32 Reset");
 	sunxi_gpio_set_cfgpin(SUNXI_GPC(26), SUNXI_GPIO_OUTPUT);
 #if !defined(CONFIG_DM_GPIO)
 	gpio_request(SUNXI_GPA(7), "PHY Reset");
 	sunxi_gpio_set_cfgpin(SUNXI_GPA(7), SUNXI_GPIO_OUTPUT);
 	gpio_direction_output(SUNXI_GPA(7), 0);
 #endif
 
 	gpio_direction_output(SUNXI_GPC(3), 0);
 	gpio_direction_output(SUNXI_GPC(26), 0);
 	mdelay(10);
 	gpio_direction_output(SUNXI_GPC(26), 1);
 #if !defined(CONFIG_DM_GPIO)
 	gpio_direction_output(SUNXI_GPA(7), 1);
 #endif
 
 	setup_led();
 
 	ret = axp_gpio_init();
 	if (ret)
 		return ret;
 
 #ifdef CONFIG_SATAPWR
 	gpio_request(CONFIG_SATAPWR, "satapwr");
 	gpio_direction_output(CONFIG_SATAPWR, 1);
 #endif
 #ifdef CONFIG_MACPWR
 	gpio_request(CONFIG_MACPWR, "macpwr");
 	gpio_direction_output(CONFIG_MACPWR, 1);
 #endif
 
 	/* Uses dm gpio code so do this here and not in i2c_init_board() */
 	return soft_i2c_board_init();
 
 }
 
@@ -1018,24 +1030,23 @@ U_BOOT_CMD(
 int board_fit_config_name_match(const char *name)
 {
 #ifdef CONFIG_SPL_LOAD_FIT
 	const char *cmp_str;
 
 #ifdef CONFIG_DEFAULT_DEVICE_TREE
 	cmp_str = CONFIG_DEFAULT_DEVICE_TREE;
 #else
 	return 0;
 #endif
 
 	/* Differentiate the two Pine64 board DTs by their DRAM size. */
 	if (strstr(name, "-pine64") && strstr(cmp_str, "-pine64")) {
 		if ((gd->ram_size > 512 * 1024 * 1024))
 			return !strstr(name, "plus");
 		else
 			return !!strstr(name, "plus");
 	} else {
 		return strcmp(name, cmp_str);
 	}
 #endif
 }
 
-
-- 
1.9.1



More information about the U-Boot mailing list