From patchwork Tue Nov 12 11:00:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Brugger X-Patchwork-Id: 1193425 X-Patchwork-Delegate: matthias.bgg@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="U43POqYm"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 47C4ZG4qcYz9s7T for ; Tue, 12 Nov 2019 22:01:58 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 2341AC21EBF; Tue, 12 Nov 2019 11:01:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 8AFA8C21EA7; Tue, 12 Nov 2019 11:00:54 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 37A40C21EBE; Tue, 12 Nov 2019 11:00:45 +0000 (UTC) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by lists.denx.de (Postfix) with ESMTPS id 8F481C21E7F for ; Tue, 12 Nov 2019 11:00:42 +0000 (UTC) Received: from ziggy.de (unknown [37.223.138.214]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EBD6A2084E; Tue, 12 Nov 2019 11:00:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573556441; bh=LtPYg0hvheurLsTbbd7V6CbiyvA9PpUYBisF7HJ3JxQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U43POqYmBfSkoz0+ROJ/y8LixNetUlnXWIUF1YdvXRAuvO2LdpBDUoYLOKwRrNtSg 77G0uUesYzPPh9nJQ7hpoFgNInid4kBWP2EYCy8fIX/CISEwN+sBmZdNqglT5gNYtE TTYdLdOYhY4sVnR/6+jy7lk2FWQ4opeXz+FuJvlk= From: matthias.bgg@kernel.org To: u-boot@lists.denx.de, Alexander Graf , fvogt@suse.com, matthias.bgg@kernel.org Date: Tue, 12 Nov 2019 12:00:28 +0100 Message-Id: <20191112110029.847-4-matthias.bgg@kernel.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191112110029.847-1-matthias.bgg@kernel.org> References: <20191112110029.847-1-matthias.bgg@kernel.org> MIME-Version: 1.0 Cc: Matthias Brugger Subject: [U-Boot] [PATCH v3 3/4] ARM: bcm283x: Set rpi_bcm283x_base at run-time X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: Matthias Brugger As part of the effort to create one binary for several bcm83x SoCs we use the SoC compatible to decide which IO base address we use. Signed-off-by: Matthias Brugger --- Changes in v3: None Changes in v2: - rename BCM2838 to BCM2711 in the correct patch - push rpi_bcm283x_base into the .data section arch/arm/mach-bcm283x/Kconfig | 6 ---- arch/arm/mach-bcm283x/init.c | 62 +++++++++++++++++++++++++++++++++-- 2 files changed, 60 insertions(+), 8 deletions(-) diff --git a/arch/arm/mach-bcm283x/Kconfig b/arch/arm/mach-bcm283x/Kconfig index b08275f598..e8e0ff0eb4 100644 --- a/arch/arm/mach-bcm283x/Kconfig +++ b/arch/arm/mach-bcm283x/Kconfig @@ -202,10 +202,4 @@ config SYS_SOC config SYS_CONFIG_NAME default "rpi" -config BCM283x_BASE - hex - default "0x20000000" if BCM2835 - default "0x3f000000" if BCM2836 || BCM2837 - default "0xfe000000" if BCM2711 - endmenu diff --git a/arch/arm/mach-bcm283x/init.c b/arch/arm/mach-bcm283x/init.c index d36017e823..d374fb60ba 100644 --- a/arch/arm/mach-bcm283x/init.c +++ b/arch/arm/mach-bcm283x/init.c @@ -7,8 +7,48 @@ */ #include +#include -unsigned long rpi_bcm283x_base; +#define PDATA_BCM2835 0 +#define PDATA_BCM2836 1 +#define PDATA_BCM2837 2 +#define PDATA_BCM2711 3 + +unsigned long rpi_bcm283x_base = 0x3f000000; + +struct bcm283x_pdata { + unsigned long io_base; +}; + +struct bcm283x_pdata pdata_bcm283x[] = { + [PDATA_BCM2835] = { + .io_base = 0x20000000, + }, + [PDATA_BCM2836] = { + .io_base = 0x3f000000, + }, +#ifdef CONFIG_ARM64 + [PDATA_BCM2837] = { + .io_base = 0x3f000000, + }, + [PDATA_BCM2711] = { + .io_base = 0xfe000000, + }, +#endif +}; + +/* + * I/O address space varies on different chip versions. + * We set the base address by inspecting the DTB. + */ +static const struct udevice_id board_ids[] = { + { .compatible = "brcm,bcm2835", .data = PDATA_BCM2835}, + { .compatible = "brcm,bcm2836", .data = PDATA_BCM2836}, + { .compatible = "brcm,bcm2837", .data = PDATA_BCM2837}, + { .compatible = "brcm,bcm2838", .data = PDATA_BCM2711}, + { .compatible = "brcm,bcm2711", .data = PDATA_BCM2711}, + { }, +}; int arch_cpu_init(void) { @@ -19,10 +59,28 @@ int arch_cpu_init(void) int mach_cpu_init(void) { - rpi_bcm283x_base = CONFIG_BCM283x_BASE; + const struct udevice_id *of_match = board_ids; + int ret; + + rpi_bcm283x_base = 0; + + while (of_match->compatible) { + struct bcm283x_pdata pdat; + + ret = fdt_node_check_compatible(gd->fdt_blob, 0, + of_match->compatible); + if (!ret) { + pdat = pdata_bcm283x[of_match->data]; + rpi_bcm283x_base = pdat.io_base; + break; + } + + of_match++; + } return 0; } + #ifdef CONFIG_ARMV7_LPAE void enable_caches(void) {