From patchwork Fri Jun 15 09:40:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulrich Hecht X-Patchwork-Id: 10465909 X-Patchwork-Delegate: horms@verge.net.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8FD7060348 for ; Fri, 15 Jun 2018 09:40:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7555F28C49 for ; Fri, 15 Jun 2018 09:40:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 67C4B28D3F; Fri, 15 Jun 2018 09:40:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 005DD28C49 for ; Fri, 15 Jun 2018 09:40:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755749AbeFOJkQ (ORCPT ); Fri, 15 Jun 2018 05:40:16 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:51902 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755735AbeFOJkP (ORCPT ); Fri, 15 Jun 2018 05:40:15 -0400 Received: by mail-wm0-f65.google.com with SMTP id r15-v6so2521073wmc.1 for ; Fri, 15 Jun 2018 02:40:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=azuguG0J2NODLzOWRWd1Gi/iLYmazEsGUFlh8YFEwwM=; b=rXJFjuUFchkPubVjv95Fytcn7DNpghExKcHkW9FsjxqROgnnOEuVxSPX0cuUGTuqsL 4fTrqjyyOYoMiTiVUeSZklL5arKYIBAttB2NgVFA+mqKtWYyfcruJIoiizCt6Awg7l92 HgHb1WH+hSbATKGT64vyoSap0myHdHvkS82jAUxj86ZL0igxT+itBEhIHfE3Ledew4Lf /5SZLLxvFYE0w8TFckzItX16WmWWisS5aPXxqXdQI6nv1iOZOzAFOaWC0Ddz9O8NNhSb cGxaL+8Rajh7sUkD4vCnuZg953EPtDtVnjrCL96xfqsQIDgrJ8S9YlErabnlI0IDLaVa jxWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=azuguG0J2NODLzOWRWd1Gi/iLYmazEsGUFlh8YFEwwM=; b=dMNDfgHPETIfx7EEF+qLfwKgtNHd7HZn/73/quq4KmImtuhGquCJWWY7n7dZ+T1kGq o9mM9NR2a3MfaB7lEqP2nu3vhfbMXNeU5QGVetQ0d3pMf1pXNPobtahwAR9tZQsrFzQA B5h37X6RSCqvCfTlM+RJ+pHpG7EHTgtz38wq3uWriIdcFJv0PAPMQ9E9kHIt1Qym07Me n4kjemhl2sxxPJ4FYD+G0emk52yA8NWFRoNXJDoxxIzhqmCDnbUKAxSmf9QN33KYa7EE XueUEN0k6UGSNtEUX7Pamh5O5RG77wheEmuLKgn1tzmIIQoi4U7x+2+dUqLqd443CvoZ TVGA== X-Gm-Message-State: APt69E2bIn8VWiMvzJu99zvelBrPZLFztzYHgB6X9hkrlyzUiiNX4JxD yYhm7hevk3agfQOUX+1sX9DV89k= X-Google-Smtp-Source: ADUXVKKberk7PpvjgeqdCVaJpYP0d8N9TFKpLD2uepDmqG8obyTMYELzPfioSDSgMOkYabt8m7cd0w== X-Received: by 2002:a1c:5790:: with SMTP id l138-v6mr684156wmb.126.1529055613786; Fri, 15 Jun 2018 02:40:13 -0700 (PDT) Received: from groucho.site (ipbcc3ea18.dynamic.kabel-deutschland.de. [188.195.234.24]) by smtp.gmail.com with ESMTPSA id p6-v6sm10864431wrq.19.2018.06.15.02.40.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 15 Jun 2018 02:40:13 -0700 (PDT) From: Ulrich Hecht To: linux-renesas-soc@vger.kernel.org, u-boot@lists.denx.de Cc: geert@linux-m68k.org, marek.vasut@gmail.com, yoshihiro.shimoda.uh@renesas.com, magnus.damm@gmail.com, takuya.sakata.wz@bp.renesas.com, Ulrich Hecht Subject: [RFC] ARM: rmobile: create DT memory nodes for R8A7795 3.0 and newer Date: Fri, 15 Jun 2018 11:40:04 +0200 Message-Id: <1529055605-29942-1-git-send-email-ulrich.hecht+renesas@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Uses an SMC call to the ATF to determine the memory configuration, then creates appropriate DT memory nodes. Signed-off-by: Ulrich Hecht --- This is an attempt to avoid having to have a ton of different device trees for Renesas R8A7795 H3 SoCs from revision 3.0, which come in a number of different memory configurations. The specific configuration is statically baked into the ARM Trusted Firmware binary, so this solution adds an SMC "SiP Service Call" to the ATF returning the memory configuration, and then has u-boot build appropriate memory nodes. This has not been tested in the flesh successfully, as I only have a revision 1.0 board. I'd like to get some feedback on whether this approach is sound, though. Thanks. Depends on "[RFC ATF] Add SMCCC_RENESAS_MEMCONF SMC call". CU Uli board/renesas/salvator-x/salvator-x.c | 51 +++++++++++++++++++++++++++++++++++ configs/r8a7795_salvator-x_defconfig | 2 ++ 2 files changed, 53 insertions(+) diff --git a/board/renesas/salvator-x/salvator-x.c b/board/renesas/salvator-x/salvator-x.c index 651877c..307cb64 100644 --- a/board/renesas/salvator-x/salvator-x.c +++ b/board/renesas/salvator-x/salvator-x.c @@ -24,6 +24,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -136,3 +137,53 @@ void reset_cpu(ulong addr) writel(RST_CODE, RST_CA57RESCNT); #endif } + +#define ARM_SMCCC_RENESAS_MEMCONF 0x82000000UL +int ft_board_setup(void *blob, bd_t *bd) +{ + if (rmobile_get_cpu_type() == RMOBILE_CPU_TYPE_R8A7795 && + rmobile_get_cpu_rev_integer() >= 3) { + u64 base[CONFIG_NR_DRAM_BANKS]; + u64 size[CONFIG_NR_DRAM_BANKS]; + struct arm_smccc_res res; + + arm_smccc_smc(ARM_SMCCC_RENESAS_MEMCONF, + 0, 0, 0, 0, 0, 0, 0, &res); + + switch (res.a0) { + case 1: + base[0] = 0x048000000ULL; + size[0] = 0x038000000ULL; + base[1] = 0x500000000ULL; + size[1] = 0x040000000ULL; + base[2] = 0x600000000ULL; + size[2] = 0x040000000ULL; + base[3] = 0x700000000ULL; + size[3] = 0x040000000ULL; + fdt_fixup_memory_banks(blob, base, size, 4); + break; + case 2: + base[0] = 0x048000000ULL; + size[0] = 0x078000000ULL; + base[1] = 0x500000000ULL; + size[1] = 0x080000000ULL; + fdt_fixup_memory_banks(blob, base, size, 2); + break; + case 3: + base[0] = 0x048000000ULL; + size[0] = 0x078000000ULL; + base[1] = 0x500000000ULL; + size[1] = 0x080000000ULL; + base[2] = 0x600000000ULL; + size[2] = 0x080000000ULL; + base[3] = 0x700000000ULL; + size[3] = 0x080000000ULL; + fdt_fixup_memory_banks(blob, base, size, 4); + break; + default: + break; + } + } + + return 0; +} diff --git a/configs/r8a7795_salvator-x_defconfig b/configs/r8a7795_salvator-x_defconfig index fdfa41c..cd2bb59 100644 --- a/configs/r8a7795_salvator-x_defconfig +++ b/configs/r8a7795_salvator-x_defconfig @@ -61,3 +61,5 @@ CONFIG_USB_EHCI_GENERIC=y CONFIG_USB_STORAGE=y CONFIG_OF_LIBFDT_OVERLAY=y CONFIG_SMBIOS_MANUFACTURER="" +CONFIG_OF_BOARD_SETUP=y +CONFIG_ARM_SMCCC=y