From patchwork Sat Feb 20 01:13:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Daney X-Patchwork-Id: 8365371 Return-Path: X-Original-To: patchwork-linux-arm@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 08B639F2F0 for ; Sat, 20 Feb 2016 01:16:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 00D0020585 for ; Sat, 20 Feb 2016 01:16:32 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B465120571 for ; Sat, 20 Feb 2016 01:16:30 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aWw7v-00027T-4H; Sat, 20 Feb 2016 01:14:27 +0000 Received: from mail-pa0-x235.google.com ([2607:f8b0:400e:c03::235]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aWw7Q-0001oL-Fs for linux-arm-kernel@lists.infradead.org; Sat, 20 Feb 2016 01:13:59 +0000 Received: by mail-pa0-x235.google.com with SMTP id fy10so58845913pac.1 for ; Fri, 19 Feb 2016 17:13:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AnlI1KxszWMFqFGBU2IfTHppPX5dNMnQ2FyidpcIC1I=; b=hviQ2LlbdxYNBs5tgQoJVfYXuPgFBLqF9s0i7hd5EwsauhrryZCA+YETWi2Hm/sXLO LN/nmr3PA2wCYOSvTW+SPhC7fy/dafD4SkUmsVUXhOo1iKHnB3AEktaE72myRiKa/qeT izZOcLIXi/L0VwcyO1KAcioGuyxyJeyEenIRsxVoG7AXZeykskUyVkSBhvsFWwtdt8pO EtAGLr6/lKHhr+8Ew09WYUCOHog7ETWrJ1N9dju7ABvSD714k7zdS4eI/tbzeZH60I2j 79XW4DPaIjdM8ZLetzNTaGJ+NXHZ+dWKUzK+Oj2chkKV4uXc9rMQ/8Iylm5ahQQBTxSL bXEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AnlI1KxszWMFqFGBU2IfTHppPX5dNMnQ2FyidpcIC1I=; b=duhh7McnEYH9nMhQKSy8tDFbQZ6bWqFMAnJyLeyXiBFOduKnAsZrhGOuEtJ0bzuAhL vv/B5vxbgWg3QS44Z/5+zTDURLRbwYREV4z9ZUTr9aPW339NDYzdUDO1DxrX49Yf+R9X FynaGNwntH9lSIK24FARddWl7nCIPOnyTUdTcC+Gajm1YsAT+llAz5HjF0qNaocOAz14 lKAeBPBCzoNWFFBgb6RROVoqbydidASbVrI1gxYnRcFd78ZfKbMPgAGoXWK2Kg5B/XNv /z3pstAKaVQOO+1qsVokDXOP3unEJpBmUbp9k3zispWXaE7OeapjvoLl/Zt+i3xKOzSh ymlA== X-Gm-Message-State: AG10YOQiSusC61l/Dcs3dYO4sX1IO/quNMlxAYH39Idi53JrrYFxw2reQqTSuxu5RHgTeA== X-Received: by 10.66.242.17 with SMTP id wm17mr22085515pac.155.1455930814693; Fri, 19 Feb 2016 17:13:34 -0800 (PST) Received: from dl.caveonetworks.com ([64.2.3.194]) by smtp.gmail.com with ESMTPSA id ta2sm20451568pab.42.2016.02.19.17.13.28 (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 19 Feb 2016 17:13:31 -0800 (PST) Received: from dl.caveonetworks.com (localhost.localdomain [127.0.0.1]) by dl.caveonetworks.com (8.14.5/8.14.5) with ESMTP id u1K1DRM9005426; Fri, 19 Feb 2016 17:13:27 -0800 Received: (from ddaney@localhost) by dl.caveonetworks.com (8.14.5/8.14.5/Submit) id u1K1DRgo005425; Fri, 19 Feb 2016 17:13:27 -0800 From: David Daney To: Will Deacon , linux-arm-kernel@lists.infradead.org, Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , devicetree@vger.kernel.org, Ard Biesheuvel , Frank Rowand , Grant Likely , Catalin Marinas , Matt Fleming , linux-efi@vger.kernel.org, Ganapatrao Kulkarni , Robert Richter Subject: [PATCH v11 03/10] efi: move FDT handling to separate object file Date: Fri, 19 Feb 2016 17:13:12 -0800 Message-Id: <1455930799-5371-4-git-send-email-ddaney.cavm@gmail.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1455930799-5371-1-git-send-email-ddaney.cavm@gmail.com> References: <1455930799-5371-1-git-send-email-ddaney.cavm@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160219_171356_822089_49659F28 X-CRM114-Status: GOOD ( 23.60 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, David Daney MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable 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 From: Ard Biesheuvel The EFI specific FDT handling is compiled conditionally, and is logically independent of the rest of efi.o. So move it to a separate file before making changes to it in subsequent patches. Acked-by: Matt Fleming Acked-by: Leif Lindholm Signed-off-by: Ard Biesheuvel [ rric: Ported to v4.5-rc1 ] Signed-off-by: Robert Richter Signed-off-by: David Daney --- drivers/firmware/efi/Makefile | 1 + drivers/firmware/efi/efi-fdt.c | 91 ++++++++++++++++++++++++++++++++++++++++++ drivers/firmware/efi/efi.c | 84 -------------------------------------- 3 files changed, 92 insertions(+), 84 deletions(-) create mode 100644 drivers/firmware/efi/efi-fdt.c diff --git a/drivers/firmware/efi/Makefile b/drivers/firmware/efi/Makefile index 62e654f..bb7ec2f 100644 --- a/drivers/firmware/efi/Makefile +++ b/drivers/firmware/efi/Makefile @@ -18,6 +18,7 @@ obj-$(CONFIG_EFI_RUNTIME_MAP) += runtime-map.o obj-$(CONFIG_EFI_RUNTIME_WRAPPERS) += runtime-wrappers.o obj-$(CONFIG_EFI_STUB) += libstub/ obj-$(CONFIG_EFI_FAKE_MEMMAP) += fake_mem.o +obj-$(CONFIG_EFI_PARAMS_FROM_FDT) += efi-fdt.o arm-obj-$(CONFIG_EFI) := arm-init.o arm-runtime.o obj-$(CONFIG_ARM) += $(arm-obj-y) diff --git a/drivers/firmware/efi/efi-fdt.c b/drivers/firmware/efi/efi-fdt.c new file mode 100644 index 0000000..8f3ce66 --- /dev/null +++ b/drivers/firmware/efi/efi-fdt.c @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2013 - 2015 Linaro Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include + +#define UEFI_PARAM(name, prop, field) \ + { \ + { name }, \ + { prop }, \ + offsetof(struct efi_fdt_params, field), \ + FIELD_SIZEOF(struct efi_fdt_params, field) \ + } + +static __initdata struct { + const char name[32]; + const char propname[32]; + int offset; + int size; +} dt_params[] = { + UEFI_PARAM("System Table", "linux,uefi-system-table", system_table), + UEFI_PARAM("MemMap Address", "linux,uefi-mmap-start", mmap), + UEFI_PARAM("MemMap Size", "linux,uefi-mmap-size", mmap_size), + UEFI_PARAM("MemMap Desc. Size", "linux,uefi-mmap-desc-size", desc_size), + UEFI_PARAM("MemMap Desc. Version", "linux,uefi-mmap-desc-ver", desc_ver) +}; + +struct param_info { + int found; + void *params; +}; + +static int __init fdt_find_uefi_params(unsigned long node, const char *uname, + int depth, void *data) +{ + struct param_info *info = data; + const void *prop; + void *dest; + u64 val; + int i, len; + + if (depth != 1 || strcmp(uname, "chosen") != 0) + return 0; + + for (i = 0; i < ARRAY_SIZE(dt_params); i++) { + prop = of_get_flat_dt_prop(node, dt_params[i].propname, &len); + if (!prop) + return 0; + dest = info->params + dt_params[i].offset; + info->found++; + + val = of_read_number(prop, len / sizeof(u32)); + + if (dt_params[i].size == sizeof(u32)) + *(u32 *)dest = val; + else + *(u64 *)dest = val; + + if (efi_enabled(EFI_DBG)) + pr_info(" %s: 0x%0*llx\n", dt_params[i].name, + dt_params[i].size * 2, val); + } + return 1; +} + +int __init efi_get_fdt_params(struct efi_fdt_params *params) +{ + struct param_info info; + int ret; + + pr_info("Getting EFI parameters from FDT:\n"); + + info.found = 0; + info.params = params; + + ret = of_scan_flat_dt(fdt_find_uefi_params, &info); + if (!info.found) + pr_info("UEFI not found.\n"); + else if (!ret) + pr_err("Can't find '%s' in device tree!\n", + dt_params[info.found].name); + + return ret; +} diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 2cd37da..7c41c428 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -20,8 +20,6 @@ #include #include #include -#include -#include #include #include @@ -490,88 +488,6 @@ static int __init efi_load_efivars(void) device_initcall(efi_load_efivars); #endif -#ifdef CONFIG_EFI_PARAMS_FROM_FDT - -#define UEFI_PARAM(name, prop, field) \ - { \ - { name }, \ - { prop }, \ - offsetof(struct efi_fdt_params, field), \ - FIELD_SIZEOF(struct efi_fdt_params, field) \ - } - -static __initdata struct { - const char name[32]; - const char propname[32]; - int offset; - int size; -} dt_params[] = { - UEFI_PARAM("System Table", "linux,uefi-system-table", system_table), - UEFI_PARAM("MemMap Address", "linux,uefi-mmap-start", mmap), - UEFI_PARAM("MemMap Size", "linux,uefi-mmap-size", mmap_size), - UEFI_PARAM("MemMap Desc. Size", "linux,uefi-mmap-desc-size", desc_size), - UEFI_PARAM("MemMap Desc. Version", "linux,uefi-mmap-desc-ver", desc_ver) -}; - -struct param_info { - int found; - void *params; -}; - -static int __init fdt_find_uefi_params(unsigned long node, const char *uname, - int depth, void *data) -{ - struct param_info *info = data; - const void *prop; - void *dest; - u64 val; - int i, len; - - if (depth != 1 || strcmp(uname, "chosen") != 0) - return 0; - - for (i = 0; i < ARRAY_SIZE(dt_params); i++) { - prop = of_get_flat_dt_prop(node, dt_params[i].propname, &len); - if (!prop) - return 0; - dest = info->params + dt_params[i].offset; - info->found++; - - val = of_read_number(prop, len / sizeof(u32)); - - if (dt_params[i].size == sizeof(u32)) - *(u32 *)dest = val; - else - *(u64 *)dest = val; - - if (efi_enabled(EFI_DBG)) - pr_info(" %s: 0x%0*llx\n", dt_params[i].name, - dt_params[i].size * 2, val); - } - return 1; -} - -int __init efi_get_fdt_params(struct efi_fdt_params *params) -{ - struct param_info info; - int ret; - - pr_info("Getting EFI parameters from FDT:\n"); - - info.found = 0; - info.params = params; - - ret = of_scan_flat_dt(fdt_find_uefi_params, &info); - if (!info.found) - pr_info("UEFI not found.\n"); - else if (!ret) - pr_err("Can't find '%s' in device tree!\n", - dt_params[info.found].name); - - return ret; -} -#endif /* CONFIG_EFI_PARAMS_FROM_FDT */ - static __initdata char memory_type_name[][20] = { "Reserved", "Loader Code",