From patchwork Sat Mar 26 01:47:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "dalias@libc.org" X-Patchwork-Id: 8673581 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id ED39B9F65E for ; Sat, 26 Mar 2016 01:47:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D0435202A1 for ; Sat, 26 Mar 2016 01:47:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 88E6F20268 for ; Sat, 26 Mar 2016 01:47:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752782AbcCZBrP (ORCPT ); Fri, 25 Mar 2016 21:47:15 -0400 Received: from 216-12-86-13.cv.mvl.ntelos.net ([216.12.86.13]:51975 "EHLO brightrain.aerifal.cx" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752594AbcCZBrO (ORCPT ); Fri, 25 Mar 2016 21:47:14 -0400 Received: from dalias by brightrain.aerifal.cx with local (Exim 3.15 #2) id 1ajdJo-0007bm-00; Sat, 26 Mar 2016 01:47:12 +0000 Date: Fri, 25 Mar 2016 21:47:12 -0400 From: Rich Felker To: linux-sh@vger.kernel.org Cc: Yoshinori Sato , Geert Uytterhoeven Subject: [PATCH] sh: add support for linking a builtin device tree blob in the kernel Message-ID: <20160326014711.GA29106@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Rich Felker --- I'd like to add this patch to the new device tree support to ease the transition to device tree on legacy hardware where replacing the bootloader with a new one that can pass a DTB may be extra work. Since I'm not familiar with this kind of build system change, though, I'd like some feedback on whether I'm doing it right. arch/sh/Kconfig | 20 ++++++++++++++++++++ arch/sh/Makefile | 2 ++ arch/sh/boards/of-generic.c | 15 ++++++++++++--- arch/sh/boot/dts/Makefile | 3 +++ arch/sh/kernel/setup.c | 4 ++++ 5 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 arch/sh/boot/dts/Makefile diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index 9dec535..b6db094 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig @@ -755,6 +755,26 @@ endmenu menu "Boot options" +config USE_BUILTIN_DTB + bool "Use builtin DTB" + default n + depends on SH_DEVICE_TREE + help + Link a device tree blob for particular hardware into the kernel, + suppressing use of the DTB pointer provided by the bootloader. + This option should only be used with legacy bootloaders that are + not capable of providing a DTB to the kernel, or for experimental + hardware without stable device tree bindings. + +config BUILTIN_DTB_SOURCE + string "Source file for builtin DTB" + default "" + depends on USE_BUILTIN_DTB + help + Base name (without suffix, relative to arch/sh/boot/dts) for the + a DTS file that will be used to produce the DTB linked into the + kernel. + config ZERO_PAGE_OFFSET hex default "0x00010000" if PAGE_SIZE_64KB || SH_RTS7751R2D || \ diff --git a/arch/sh/Makefile b/arch/sh/Makefile index 3566a759..0047666 100644 --- a/arch/sh/Makefile +++ b/arch/sh/Makefile @@ -131,6 +131,8 @@ head-y := arch/sh/kernel/head_$(BITS).o core-y += arch/sh/kernel/ arch/sh/mm/ arch/sh/boards/ core-$(CONFIG_SH_FPU_EMU) += arch/sh/math-emu/ +core-$(CONFIG_USE_BUILTIN_DTB) += arch/sh/boot/dts/ + # Mach groups machdir-$(CONFIG_SOLUTION_ENGINE) += mach-se machdir-$(CONFIG_SH_HP6XX) += mach-hp6xx diff --git a/arch/sh/boards/of-generic.c b/arch/sh/boards/of-generic.c index bf3a166..57d45dc 100644 --- a/arch/sh/boards/of-generic.c +++ b/arch/sh/boards/of-generic.c @@ -126,13 +126,22 @@ static void __init sh_of_time_init(void) static void __init sh_of_setup(char **cmdline_p) { + struct device_node *root; + +#ifdef CONFIG_USE_BUILTIN_DTB + unflatten_and_copy_device_tree(); +#else unflatten_device_tree(); +#endif board_time_init = sh_of_time_init; - sh_mv.mv_name = of_flat_dt_get_machine_name(); - if (!sh_mv.mv_name) - sh_mv.mv_name = "Unknown SH model"; + sh_mv.mv_name = "Unknown SH model"; + root = of_find_node_by_path("/"); + if (root) { + of_property_read_string(root, "model", &sh_mv.mv_name); + of_node_put(root); + } sh_of_smp_probe(); } diff --git a/arch/sh/boot/dts/Makefile b/arch/sh/boot/dts/Makefile new file mode 100644 index 0000000..e5ce3a0 --- /dev/null +++ b/arch/sh/boot/dts/Makefile @@ -0,0 +1,3 @@ +obj-$(CONFIG_USE_BUILTIN_DTB) += $(patsubst "%",%,$(CONFIG_BUILTIN_DTB_SOURCE)).dtb.o + +clean-files := *.dtb.S diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c index efb60ce..ec7c99f 100644 --- a/arch/sh/kernel/setup.c +++ b/arch/sh/kernel/setup.c @@ -251,7 +251,11 @@ void __ref sh_fdt_init(phys_addr_t dt_phys) /* Avoid calling an __init function on secondary cpus. */ if (done) return; +#ifdef CONFIG_USE_BUILTIN_DTB + dt_virt = __dtb_start; +#else dt_virt = phys_to_virt(dt_phys); +#endif if (!dt_virt || !early_init_dt_scan(dt_virt)) { pr_crit("Error: invalid device tree blob"