From patchwork Sat Oct 9 12:18:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angelo Dureghello X-Patchwork-Id: 1538790 X-Patchwork-Delegate: andre.przywara@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=timesys-com.20210112.gappssmtp.com header.i=@timesys-com.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=Sbr/KcAr; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HRPLg0RQ3z9sNH for ; Sat, 9 Oct 2021 23:21:46 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4AD3B8364E; Sat, 9 Oct 2021 14:21:28 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=timesys.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=timesys-com.20210112.gappssmtp.com header.i=@timesys-com.20210112.gappssmtp.com header.b="Sbr/KcAr"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1CDE683622; Sat, 9 Oct 2021 14:21:21 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id DCB4683328 for ; Sat, 9 Oct 2021 14:21:15 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=timesys.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=angelo.dureghello@timesys.com Received: by mail-ed1-x52a.google.com with SMTP id y12so33597435eda.4 for ; Sat, 09 Oct 2021 05:21:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=timesys-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=0r2XiMIaHVugUJDWjvmPGh4hvfe7BD2jzQw6Sz1PvDA=; b=Sbr/KcArxvut1CLzXs8qPVt2ejb0oqakYx7Tdz9Yo+a3igPBv8mcHr5QTO0+qf2WV0 Dne5vMNdJW/XV18vhUZSO5zUfODETMiV18rjc1wt6bnSK0jQpCyss1aaCspsljKgk7eV SlthjaGej/KU29b5fHzItryF0iGpUWVoAl6pVVMeduSzia2AdEFvLzvt5qwae3KTx92d PaAZCLzC52nFZ73CobP3/dsdru72ffu8f/4TmAnmNSoDgJZtxiAusAoDQBhTPHj63twg PHyYpBYY5JtZ4/Jgx8NR8uvOfKJ8NE0lnGaa/Z3q7hOPKVZ1NNZ1PByYTM6pWFWOiTQq 24Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=0r2XiMIaHVugUJDWjvmPGh4hvfe7BD2jzQw6Sz1PvDA=; b=1S9wldYZL8wsEsd21cGJDN/NA7lSeZSLHAlvevWpm6z4prfe+THcnfdCC4l9Z0AstS nceFQw7QX/H3vaFZ3Vf23IjEXNzAtTF3Kz190zHbmWs8hUoDbL3a3ExvOmMbFsYVL4Ez dZNl996UGbc4KfmDntTCQIRnKGSH4JmZxJHrNmIuzQajU6JrWMRWrWWs8Q5iI7TKNJHX AOrPhBy6FKcJ/56dOExX5jDXZzxFmR71oTrDHMJcqwZA6GxMYGm8inLNU9zJzBybPZCS 0tPPFqiIiyEfnnOk9tmmmqU855mmnIFY3mf6RrfVzlKYREmMWc0LFHiCZ5t32xCfFQ6j 9Snw== X-Gm-Message-State: AOAM531hKof3+1AbgyFw5yG6AoPn6E/TvoFKvT/v9F8R8tOdr/bbts4H B3P7k9XAWrNk670PbiL+Jge8Og== X-Google-Smtp-Source: ABdhPJxOZFGHSDB22Id2HJ3GNewrbRHus+j5Lo5oPFYgvDQzNPAuoAZHHRMKe9QNikmlWbWAhqDC0w== X-Received: by 2002:a50:ff14:: with SMTP id a20mr24071851edu.81.1633782075267; Sat, 09 Oct 2021 05:21:15 -0700 (PDT) Received: from dfj.1.1.1.1 (host-95-249-225-173.retail.telecomitalia.it. [95.249.225.173]) by smtp.gmail.com with ESMTPSA id h7sm1173932ede.19.2021.10.09.05.21.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Oct 2021 05:21:14 -0700 (PDT) From: Angelo Dureghello To: jagan@amarulasolutions.com, andre.przywara@arm.com, trini@konsulko.com Cc: u-boot@lists.denx.de, Angelo Dureghello Subject: [PATCH 1/2] sunxi: add H2+ config option Date: Sat, 9 Oct 2021 14:18:58 +0200 Message-Id: <20211009121859.1384658-1-angelo.dureghello@timesys.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Add H2+ Kconfig oiption to display proper cpu at boot time, and for other future uses, if needed, to differentiate against H3. The patch does not change any board defconfig at this stage, so that nothing is broken. Tested this CONFIG_MACH_SUN8I_H2_PLUS to work properly on banana pi m2 zero. Signed-off-by: Angelo Dureghello --- arch/arm/cpu/armv7/sunxi/Makefile | 1 + arch/arm/cpu/armv7/sunxi/psci.c | 2 ++ arch/arm/cpu/armv7/sunxi/tzpc.c | 2 +- arch/arm/dts/Makefile | 5 +++++ arch/arm/include/asm/arch-sunxi/cpu_sun4i.h | 4 ++-- arch/arm/mach-sunxi/Kconfig | 9 +++++++++ arch/arm/mach-sunxi/board.c | 3 ++- arch/arm/mach-sunxi/cpu_info.c | 6 ++++-- arch/arm/mach-sunxi/dram_sunxi_dw.c | 4 ++-- drivers/clk/sunxi/Makefile | 1 + drivers/video/sunxi/sunxi_de2.c | 2 +- 11 files changed, 30 insertions(+), 9 deletions(-) diff --git a/arch/arm/cpu/armv7/sunxi/Makefile b/arch/arm/cpu/armv7/sunxi/Makefile index 1d40d6a18d..5fdfe45401 100644 --- a/arch/arm/cpu/armv7/sunxi/Makefile +++ b/arch/arm/cpu/armv7/sunxi/Makefile @@ -8,6 +8,7 @@ obj-y += timer.o obj-$(CONFIG_MACH_SUN6I) += tzpc.o +obj-$(CONFIG_MACH_SUN8I_H2_PLUS) += tzpc.o obj-$(CONFIG_MACH_SUN8I_H3) += tzpc.o ifndef CONFIG_SPL_BUILD diff --git a/arch/arm/cpu/armv7/sunxi/psci.c b/arch/arm/cpu/armv7/sunxi/psci.c index 1ac50f558a..bcdbe888bc 100644 --- a/arch/arm/cpu/armv7/sunxi/psci.c +++ b/arch/arm/cpu/armv7/sunxi/psci.c @@ -79,6 +79,7 @@ static void __secure __mdelay(u32 ms) static void __secure clamp_release(u32 __maybe_unused *clamp) { #if defined(CONFIG_MACH_SUN6I) || defined(CONFIG_MACH_SUN7I) || \ + defined(CONFIG_MACH_SUN8I_H2_PLUS) || \ defined(CONFIG_MACH_SUN8I_H3) || \ defined(CONFIG_MACH_SUN8I_R40) u32 tmp = 0x1ff; @@ -94,6 +95,7 @@ static void __secure clamp_release(u32 __maybe_unused *clamp) static void __secure clamp_set(u32 __maybe_unused *clamp) { #if defined(CONFIG_MACH_SUN6I) || defined(CONFIG_MACH_SUN7I) || \ + defined(CONFIG_MACH_SUN8I_H2_PLUS) || \ defined(CONFIG_MACH_SUN8I_H3) || \ defined(CONFIG_MACH_SUN8I_R40) writel(0xff, clamp); diff --git a/arch/arm/cpu/armv7/sunxi/tzpc.c b/arch/arm/cpu/armv7/sunxi/tzpc.c index 0c86a21a3f..44640509ff 100644 --- a/arch/arm/cpu/armv7/sunxi/tzpc.c +++ b/arch/arm/cpu/armv7/sunxi/tzpc.c @@ -17,7 +17,7 @@ void tzpc_init(void) writel(SUN6I_TZPC_DECPORT0_RTC, &tzpc->decport0_set); #endif -#ifdef CONFIG_MACH_SUN8I_H3 +#if defined(CONFIG_MACH_SUN8I_H2_PLUS) || defined(CONFIG_MACH_SUN8I_H3) /* Enable non-secure access to all peripherals */ writel(SUN8I_H3_TZPC_DECPORT0_ALL, &tzpc->decport0_set); writel(SUN8I_H3_TZPC_DECPORT1_ALL, &tzpc->decport1_set); diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile index b8a382d153..2e58815769 100644 --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile @@ -598,6 +598,11 @@ dtb-$(CONFIG_MACH_SUN8I_A83T) += \ sun8i-a83t-bananapi-m3.dtb \ sun8i-a83t-cubietruck-plus.dtb \ sun8i-a83t-tbs-a711.dtb +dtb-$(CONFIG_MACH_SUN8I_H2_PLUS) += \ + sun8i-h2-plus-bananapi-m2-zero.dtb \ + sun8i-h2-plus-libretech-all-h3-cc.dtb \ + sun8i-h2-plus-orangepi-r1.dtb \ + sun8i-h2-plus-orangepi-zero.dtb dtb-$(CONFIG_MACH_SUN8I_H3) += \ sun8i-h2-plus-bananapi-m2-zero.dtb \ sun8i-h2-plus-libretech-all-h3-cc.dtb \ diff --git a/arch/arm/include/asm/arch-sunxi/cpu_sun4i.h b/arch/arm/include/asm/arch-sunxi/cpu_sun4i.h index d4c795d89c..b7a66b91e7 100644 --- a/arch/arm/include/asm/arch-sunxi/cpu_sun4i.h +++ b/arch/arm/include/asm/arch-sunxi/cpu_sun4i.h @@ -15,7 +15,7 @@ !defined(CONFIG_MACH_SUN8I_R40) && \ !defined(CONFIG_MACH_SUN8I_V3S) #define SUNXI_SRAM_A2_BASE 0x00040000 -#ifdef CONFIG_MACH_SUN8I_H3 +#if defined(CONFIG_MACH_SUN8I_H2_PLUS) || defined(CONFIG_MACH_SUN8I_H3) #define SUNXI_SRAM_A2_SIZE (48 * 1024) /* 16+32 kiB */ #else #define SUNXI_SRAM_A2_SIZE (80 * 1024) /* 16+64 kiB */ @@ -174,7 +174,7 @@ defined(CONFIG_MACH_SUN50I) /* module sram */ #define SUNXI_SRAM_C_BASE 0x01d00000 -#ifndef CONFIG_MACH_SUN8I_H3 +#if !defined(CONFIG_MACH_SUN8I_H2_PLUS) && !defined(CONFIG_MACH_SUN8I_H3) #define SUNXI_DE_FE0_BASE 0x01e00000 #else #define SUNXI_TVE0_BASE 0x01e00000 diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig index 1d4a4fdd0c..eae8a0e68b 100644 --- a/arch/arm/mach-sunxi/Kconfig +++ b/arch/arm/mach-sunxi/Kconfig @@ -288,6 +288,15 @@ config MACH_SUN8I_A83T select MMC_SUNXI_HAS_MODE_SWITCH select SUPPORT_SPL +config MACH_SUN8I_H2_PLUS + bool "sun8i (Allwinner H2+)" + select CPU_V7A + select CPU_V7_HAS_NONSEC + select CPU_V7_HAS_VIRT + select ARCH_SUPPORT_PSCI + select MACH_SUNXI_H3_H5 + select ARMV7_BOOT_SEC_DEFAULT if OLD_SUNXI_KERNEL_COMPAT + config MACH_SUN8I_H3 bool "sun8i (Allwinner H3)" select CPU_V7A diff --git a/arch/arm/mach-sunxi/board.c b/arch/arm/mach-sunxi/board.c index d9b04f75fc..adb63e93e7 100644 --- a/arch/arm/mach-sunxi/board.c +++ b/arch/arm/mach-sunxi/board.c @@ -228,7 +228,8 @@ void s_init(void) "mcr p15, 0, r0, c1, c0, 1\n" ::: "r0"); #endif -#if defined CONFIG_MACH_SUN6I || defined CONFIG_MACH_SUN8I_H3 +#if defined CONFIG_MACH_SUN6I || defined CONFIG_MACH_SUN8I_H2_PLUS || \ + defined CONFIG_MACH_SUN8I_H3 /* Enable non-secure access to some peripherals */ tzpc_init(); #endif diff --git a/arch/arm/mach-sunxi/cpu_info.c b/arch/arm/mach-sunxi/cpu_info.c index ba33ef2430..429e5ce283 100644 --- a/arch/arm/mach-sunxi/cpu_info.c +++ b/arch/arm/mach-sunxi/cpu_info.c @@ -85,6 +85,8 @@ int print_cpuinfo(void) printf("CPU: Allwinner A33 (SUN8I %04x)\n", sunxi_get_sram_id()); #elif defined CONFIG_MACH_SUN8I_A83T printf("CPU: Allwinner A83T (SUN8I %04x)\n", sunxi_get_sram_id()); +#elif defined CONFIG_MACH_SUN8I_H2_PLUS + printf("CPU: Allwinner H2+ (SUN8I %04x)\n", sunxi_get_sram_id()); #elif defined CONFIG_MACH_SUN8I_H3 printf("CPU: Allwinner H3 (SUN8I %04x)\n", sunxi_get_sram_id()); #elif defined CONFIG_MACH_SUN8I_R40 @@ -109,7 +111,7 @@ int print_cpuinfo(void) } #endif -#ifdef CONFIG_MACH_SUN8I_H3 +#if defined(CONFIG_MACH_SUN8I_H2_PLUS) || defined(CONFIG_MACH_SUN8I_H3) #define SIDC_PRCTL 0x40 #define SIDC_RDKEY 0x60 @@ -143,7 +145,7 @@ int sunxi_get_sid(unsigned int *sid) { #ifdef CONFIG_AXP221_POWER return axp_get_sid(sid); -#elif defined CONFIG_MACH_SUN8I_H3 +#elif defined(CONFIG_MACH_SUN8I_H2_PLUS) || defined(CONFIG_MACH_SUN8I_H3) /* * H3 SID controller has a bug, which makes the initial value of * SUNXI_SID_BASE at boot wrong. diff --git a/arch/arm/mach-sunxi/dram_sunxi_dw.c b/arch/arm/mach-sunxi/dram_sunxi_dw.c index 9107b114df..f28c23d0c6 100644 --- a/arch/arm/mach-sunxi/dram_sunxi_dw.c +++ b/arch/arm/mach-sunxi/dram_sunxi_dw.c @@ -863,7 +863,7 @@ unsigned long sunxi_dram_init(void) } }, -#if defined(CONFIG_MACH_SUN8I_H3) +#if defined(CONFIG_MACH_SUN8I_H2_PLUS) || defined(CONFIG_MACH_SUN8I_H3) .dx_read_delays = SUN8I_H3_DX_READ_DELAYS, .dx_write_delays = SUN8I_H3_DX_WRITE_DELAYS, .ac_delays = SUN8I_H3_AC_DELAYS, @@ -890,7 +890,7 @@ unsigned long sunxi_dram_init(void) * the static functions. This saves us #ifdefs, but still keeps the binary * small. */ -#if defined(CONFIG_MACH_SUN8I_H3) +#if defined(CONFIG_MACH_SUN8I_H2_PLUS) || defined(CONFIG_MACH_SUN8I_H3) uint16_t socid = SOCID_H3; #elif defined(CONFIG_MACH_SUN8I_R40) uint16_t socid = SOCID_R40; diff --git a/drivers/clk/sunxi/Makefile b/drivers/clk/sunxi/Makefile index 4f9282a8b9..d8565b3946 100644 --- a/drivers/clk/sunxi/Makefile +++ b/drivers/clk/sunxi/Makefile @@ -16,6 +16,7 @@ obj-$(CONFIG_CLK_SUN8I_A83T) += clk_a83t.o obj-$(CONFIG_CLK_SUN8I_R40) += clk_r40.o obj-$(CONFIG_CLK_SUN8I_V3S) += clk_v3s.o obj-$(CONFIG_CLK_SUN9I_A80) += clk_a80.o +obj-$(CONFIG_CLK_SUN8I_H2_PLUS) += clk_h3.o obj-$(CONFIG_CLK_SUN8I_H3) += clk_h3.o obj-$(CONFIG_CLK_SUN50I_H6) += clk_h6.o obj-$(CONFIG_CLK_SUN50I_H616) += clk_h616.o diff --git a/drivers/video/sunxi/sunxi_de2.c b/drivers/video/sunxi/sunxi_de2.c index e02d359cd2..2af2ae4cac 100644 --- a/drivers/video/sunxi/sunxi_de2.c +++ b/drivers/video/sunxi/sunxi_de2.c @@ -84,7 +84,7 @@ static void sunxi_de2_mode_set(int mux, const struct display_timing *mode, u32 format; /* enable clock */ -#ifdef CONFIG_MACH_SUN8I_H3 +#if defined(CONFIG_MACH_SUN8I_H2_PLUS) || defined(CONFIG_MACH_SUN8I_H3) setbits_le32(&de_clk_regs->rst_cfg, (mux == 0) ? 1 : 4); #else setbits_le32(&de_clk_regs->rst_cfg, BIT(mux));